1 /**********************************************************
2 * Version $Id$
3 *********************************************************/
4
5 ///////////////////////////////////////////////////////////
6 // //
7 // SAGA //
8 // //
9 // System for Automated Geoscientific Analyses //
10 // //
11 // Tool Library //
12 // point_cloud_viewer //
13 // //
14 //-------------------------------------------------------//
15 // //
16 // points_view_dialog.cpp //
17 // //
18 // Copyright (C) 2009 by //
19 // Olaf Conrad //
20 // //
21 //-------------------------------------------------------//
22 // //
23 // This file is part of 'SAGA - System for Automated //
24 // Geoscientific Analyses'. SAGA is free software; you //
25 // can redistribute it and/or modify it under the terms //
26 // of the GNU General Public License as published by the //
27 // Free Software Foundation, either version 2 of the //
28 // License, or (at your option) any later version. //
29 // //
30 // SAGA is distributed in the hope that it will be //
31 // useful, but WITHOUT ANY WARRANTY; without even the //
32 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
33 // PARTICULAR PURPOSE. See the GNU General Public //
34 // License for more details. //
35 // //
36 // You should have received a copy of the GNU General //
37 // Public License along with this program; if not, see //
38 // <http://www.gnu.org/licenses/>. //
39 // //
40 //-------------------------------------------------------//
41 // //
42 // e-mail: oconrad@saga-gis.org //
43 // //
44 // contact: Olaf Conrad //
45 // Institute of Geography //
46 // University of Hamburg //
47 // Bundesstr. 55 //
48 // 20146 Hamburg //
49 // Germany //
50 // //
51 ///////////////////////////////////////////////////////////
52
53 //---------------------------------------------------------
54
55
56 ///////////////////////////////////////////////////////////
57 // //
58 // //
59 // //
60 ///////////////////////////////////////////////////////////
61
62 //---------------------------------------------------------
63 #include "points_view_control.h"
64 #include "points_view_extent.h"
65 #include "points_view_dialog.h"
66
67
68 ///////////////////////////////////////////////////////////
69 // //
70 // //
71 // //
72 ///////////////////////////////////////////////////////////
73
74 //---------------------------------------------------------
BEGIN_EVENT_TABLE(CPoints_View_Dialog,CSGDI_Dialog)75 BEGIN_EVENT_TABLE(CPoints_View_Dialog, CSGDI_Dialog)
76 EVT_MOUSEWHEEL (CPoints_View_Dialog::On_Mouse_Wheel)
77 EVT_BUTTON (wxID_ANY , CPoints_View_Dialog::On_Button)
78 EVT_CHECKBOX (wxID_ANY , CPoints_View_Dialog::On_Update_Control)
79 EVT_TEXT_ENTER (wxID_ANY , CPoints_View_Dialog::On_Update_Control)
80 EVT_SLIDER (wxID_ANY , CPoints_View_Dialog::On_Update_Control)
81 EVT_CHOICE (wxID_ANY , CPoints_View_Dialog::On_Update_Choices)
82 END_EVENT_TABLE()
83
84 //---------------------------------------------------------
85 CPoints_View_Dialog::CPoints_View_Dialog(CSG_PointCloud *pPoints)
86 : CSGDI_Dialog(_TL("Point Cloud Viewer"), SGDI_DLG_STYLE_START_MAXIMISED)
87 {
88 SetWindowStyle(wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE);
89
90 //-----------------------------------------------------
91 m_Settings.Create(_TL("Point Cloud Viewer Settings"));
92
93 m_pView = new CPoints_View_Control (this, pPoints, m_Settings);
94 m_pExtent = new CPoints_View_Extent (this, pPoints, m_Settings, wxSize(200, 200));
95
96 //-----------------------------------------------------
97 wxArrayString Attributes;
98
99 for(int i=0; i<pPoints->Get_Field_Count(); i++)
100 {
101 Attributes.Add(pPoints->Get_Field_Name(i));
102 }
103
104 //-----------------------------------------------------
105 Add_Button(_TL("Close"), wxID_OK);
106
107 m_pBtn_Prop = Add_Button (_TL("Advanced Settings") , wxID_ANY);
108
109 Add_Spacer();
110 m_pField_Z = Add_Choice (_TL("Z Attribute") , Attributes, m_pView->m_zField);
111 m_pField_Color = Add_Choice (_TL("Color Attribute") , Attributes, m_pView->m_cField);
112
113 Add_Spacer();
114 m_pCheck_Central = Add_CheckBox (_TL("Central Projection") , m_pView->m_bCentral);
115 m_pCheck_Stereo = Add_CheckBox (_TL("Anaglyph") , m_pView->m_bStereo);
116 m_pCheck_Scale = Add_CheckBox (_TL("Scale Point Size") , m_pView->m_bScale);
117
118 Add_Spacer();
119 m_pSlide_xRotate = Add_Slider (_TL("X-Rotation") , m_pView->m_xRotate * M_RAD_TO_DEG, -180.0, 180.0);
120 m_pSlide_yRotate = Add_Slider (_TL("Y-Rotation") , m_pView->m_yRotate * M_RAD_TO_DEG, -180.0, 180.0);
121 m_pSlide_zRotate = Add_Slider (_TL("Z-Rotation") , m_pView->m_zRotate * M_RAD_TO_DEG, -180.0, 180.0);
122
123 m_pSlide_Central = Add_Slider (_TL("Eye Distance") , m_pView->m_dCentral, 1.0, 2000.0);
124
125 m_pSlide_Detail = Add_Slider (_TL("Level of Detail") , m_pView->m_Detail, 0.0, 1.0);
126
127 // Add_Spacer();
128 // m_pParameters = Add_TextCtrl (_TL("Function Parameters"), wxTE_MULTILINE|wxTE_READONLY);
129
130 Add_Spacer();
131 Add_CustomCtrl(_TL("Extent"), m_pExtent);
132
133 Add_Output(m_pView);
134 }
135
136 //---------------------------------------------------------
On_Mouse_Wheel(wxMouseEvent & event)137 void CPoints_View_Dialog::On_Mouse_Wheel(wxMouseEvent &event)
138 {
139 m_pView->On_Mouse_Wheel(event);
140 }
141
142 //---------------------------------------------------------
On_Update_Control(wxCommandEvent & event)143 void CPoints_View_Dialog::On_Update_Control(wxCommandEvent &event)
144 {
145 if( event.GetEventObject() == m_pCheck_Central )
146 {
147 m_pView->m_bCentral = m_pCheck_Central ->GetValue() == 1 ? 1 : 0;
148 }
149 else if( event.GetEventObject() == m_pCheck_Stereo )
150 {
151 m_pView->m_bStereo = m_pCheck_Stereo ->GetValue() == 1 ? 1 : 0;
152 }
153 else if( event.GetEventObject() == m_pCheck_Scale )
154 {
155 m_pView->m_bScale = m_pCheck_Scale ->GetValue() == 1 ? 1 : 0;
156 }
157 else if( event.GetEventObject() == m_pSlide_xRotate )
158 {
159 m_pView->m_xRotate = m_pSlide_xRotate ->Get_Value() * M_DEG_TO_RAD;
160 }
161 else if( event.GetEventObject() == m_pSlide_yRotate )
162 {
163 m_pView->m_yRotate = m_pSlide_yRotate ->Get_Value() * M_DEG_TO_RAD;
164 }
165 else if( event.GetEventObject() == m_pSlide_zRotate )
166 {
167 m_pView->m_zRotate = m_pSlide_zRotate ->Get_Value() * M_DEG_TO_RAD;
168 }
169 else if( event.GetEventObject() == m_pSlide_Central )
170 {
171 m_pView->m_dCentral = m_pSlide_Central ->Get_Value();
172 }
173 else if( event.GetEventObject() == m_pSlide_Detail )
174 {
175 m_pView->m_Detail = m_pSlide_Detail ->Get_Value();
176 }
177 else
178 {
179 return;
180 }
181
182 m_pView->Update_View();
183 }
184
185 //---------------------------------------------------------
On_Update_Choices(wxCommandEvent & event)186 void CPoints_View_Dialog::On_Update_Choices(wxCommandEvent &event)
187 {
188 if( event.GetEventObject() == m_pField_Z )
189 {
190 m_pView ->m_zField = m_pField_Z ->GetSelection();
191
192 m_pView ->Update_View();
193 }
194
195 else if( event.GetEventObject() == m_pField_Color )
196 {
197 m_Settings("C_RANGE")->asRange()->Set_Range(0.0, 0.0);
198
199 m_pExtent ->m_cField = m_pField_Color->GetSelection();
200 m_pView ->m_cField = m_pField_Color->GetSelection();
201
202 m_pExtent ->Update_View();
203 m_pView ->Update_Extent(m_pExtent->Get_Extent());
204 }
205 else
206 {
207 return;
208 }
209 }
210
211 //---------------------------------------------------------
On_Button(wxCommandEvent & event)212 void CPoints_View_Dialog::On_Button(wxCommandEvent &event)
213 {
214 if( event.GetEventObject() == m_pBtn_Prop )
215 {
216 if( SG_UI_Dlg_Parameters(&m_Settings, m_Settings.Get_Name()) )
217 {
218 m_pExtent ->Update_View();
219 m_pView ->Update_View();
220 }
221 }
222 else
223 {
224 event.Skip();
225 }
226 }
227
228 //---------------------------------------------------------
Update_Extent(void)229 void CPoints_View_Dialog::Update_Extent(void)
230 {
231 m_pView->Update_Extent(m_pExtent->Get_Extent());
232 }
233
234 //---------------------------------------------------------
Update_Rotation(void)235 void CPoints_View_Dialog::Update_Rotation(void)
236 {
237 double d;
238
239 d = fmod(M_RAD_TO_DEG * m_pView->m_xRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0;
240 m_pSlide_xRotate->Set_Value(d);
241
242 d = fmod(M_RAD_TO_DEG * m_pView->m_yRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0;
243 m_pSlide_yRotate->Set_Value(d);
244
245 d = fmod(M_RAD_TO_DEG * m_pView->m_zRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0;
246 m_pSlide_zRotate->Set_Value(d);
247
248 m_pCheck_Scale ->SetValue(m_pView->m_bScale);
249 m_pCheck_Stereo ->SetValue(m_pView->m_bStereo);
250 }
251
252
253 ///////////////////////////////////////////////////////////
254 // //
255 // //
256 // //
257 ///////////////////////////////////////////////////////////
258
259 //---------------------------------------------------------
260