-
Notifications
You must be signed in to change notification settings - Fork 5
/
TerraFormMain.cs
179 lines (143 loc) · 5.38 KB
/
TerraFormMain.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Tao.Glfw;
using Tao.OpenGl;
using las.datamanager;
using TerraForm.Configuration;
using TerraForm.MetricsPanel;
using laslib;
using las.datamanager.structures;
using TerraForm.AboutBox;
namespace TerraForm
{
public partial class TerraFormMain : Form
{
private ProgressForm progresForm;
private ConfigurationForm configurationForm;
private MetricsPanel.MetricsPanel metricsPanel;
private MiniMap.MiniMapForm miniMap;
private WorldView worldViewForm = null;
private Movement.MovementForm movementForm;
private LasDataManager dataManager;
public TerraFormMain()
{
InitializeComponent();
configurationForm = new ConfigurationForm();
metricsPanel = new TerraForm.MetricsPanel.MetricsPanel();
miniMap = new TerraForm.MiniMap.MiniMapForm();
movementForm = new TerraForm.Movement.MovementForm();
configurationForm.MdiParent = this;
configurationForm.Show();
metricsPanel.MdiParent = this;
metricsPanel.Show();
miniMap.MdiParent = this;
miniMap.Show();
movementForm.MdiParent = this;
movementForm.Show();
}
private void OpenFile(object sender, EventArgs e)
{
if (dataManager == null)
{
createWorldViewButton_Click(null, null);
}
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Las Files (*.las)|*.las;*." + LasDataManager.serializiationExtension + "|All Files (*.*)|*.*";
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
{
string file = openFileDialog.FileName;
progresForm = new ProgressForm();
progresForm.Show();
dataManager.Load(file, forcePreprocessingToolStripMenuItem.Checked);
LasDataManager.ColorPallette = new ColorPalette(dataManager.GlobalBoundingCube.minZ, dataManager.GlobalBoundingCube.maxZ);
if (dataManager.QTrees.Count == 1)
{
worldViewForm.MovePositionToData();
}
Console.WriteLine("Memmory before collection: {0}", (float)System.GC.GetTotalMemory(false) / (1024 * 1024));
System.GC.Collect();
Console.WriteLine("Memmory after collection: {0}", (float)System.GC.GetTotalMemory(false) / (1024 * 1024));
}
}
void dataManager_loadingStatusEvent(string status, float progress)
{
progresForm.setProgress(status, progress);
}
void dataManager_loadingEndedEvent(bool success)
{
progresForm.Hide();
progresForm.Dispose();
progresForm = null;
}
private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void shadersToolStripMenuItem_Click(object sender, EventArgs e)
{
simplePointsToolStripMenuItem.Checked = false;
shadersToolStripMenuItem.Checked = true;
}
private IRenderEngine GetSelectedRenderEngine()
{
if (simplePointsToolStripMenuItem.Checked)
{
return new SimplePointRenderEngine();
}
else
{
return new TestVertexPixelSprite();
}
}
private void createWorldViewButton_Click(object sender, EventArgs e)
{
dataManager = LasDataManager.GetInstance();
dataManager.loadingStatusEvent += new LasFileLoadingStatus(dataManager_loadingStatusEvent);
dataManager.loadingEndedEvent += new LasFileLoadingEnd(dataManager_loadingEndedEvent);
worldViewForm = new WorldView();
worldViewForm.FormClosed += new FormClosedEventHandler(worldViewForm_FormClosed);
worldViewForm.positionChangedEvent += movementForm.updatePosition;
movementForm.changePositionEvent += worldViewForm.ChangePosition;
worldViewForm.updateFormsEvent += miniMap.Refresh;
worldViewForm.updateFormsEvent += metricsPanel.Refresh;
worldViewForm.updateFormsEvent += configurationForm.Refresh;
worldViewForm.MdiParent = this;
worldViewForm.Text = "World View";
worldViewForm.RenderEngine = GetSelectedRenderEngine();
worldViewForm.RenderEngine.Minimap = miniMap;
worldViewForm.DataSource = dataManager;
worldViewForm.RenderEngine.Init();
worldViewForm.OnResize(null, null);
configurationForm.ConfigurationChangedEvent += new ConfigurationChanged(worldViewForm.RenderEngine.RenderingConfigurationChanged);
configurationForm.updateRendering();
//childForm.MovePositionToData();
worldViewForm.Show();
}
void worldViewForm_FormClosed(object sender, FormClosedEventArgs e)
{
worldViewForm = null;
dataManager.Close();
dataManager = null;
}
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
{
SettingsForm settingsForm = new SettingsForm();
settingsForm.ShowDialog();
}
private void simplePointsToolStripMenuItem_Click(object sender, EventArgs e)
{
simplePointsToolStripMenuItem.Checked = true;
shadersToolStripMenuItem.Checked = false;
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
AboutBox1 a = new AboutBox1();
a.ShowDialog();
}
}
}