1 | // |
---|
2 | // guicontrol.cc |
---|
3 | // |
---|
4 | // Handlers for events relating to the display of a survey. |
---|
5 | // |
---|
6 | // Copyright (C) 2000-2002,2005 Mark R. Shinwell |
---|
7 | // Copyright (C) 2001,2003,2004,2005,2006,2011,2012,2014,2015,2016 Olly Betts |
---|
8 | // |
---|
9 | // This program is free software; you can redistribute it and/or modify |
---|
10 | // it under the terms of the GNU General Public License as published by |
---|
11 | // the Free Software Foundation; either version 2 of the License, or |
---|
12 | // (at your option) any later version. |
---|
13 | // |
---|
14 | // This program is distributed in the hope that it will be useful, |
---|
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | // GNU General Public License for more details. |
---|
18 | // |
---|
19 | // You should have received a copy of the GNU General Public License |
---|
20 | // along with this program; if not, write to the Free Software |
---|
21 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | // |
---|
23 | |
---|
24 | #ifdef HAVE_CONFIG_H |
---|
25 | #include <config.h> |
---|
26 | #endif |
---|
27 | |
---|
28 | #include "guicontrol.h" |
---|
29 | #include "gfxcore.h" |
---|
30 | #include <wx/confbase.h> |
---|
31 | |
---|
32 | const int DISPLAY_SHIFT = 10; |
---|
33 | const double FLYFREE_SHIFT = 0.2; |
---|
34 | const double ROTATE_STEP = 2.0; |
---|
35 | |
---|
36 | GUIControl::GUIControl() |
---|
37 | : dragging(NO_DRAG) |
---|
38 | { |
---|
39 | m_View = NULL; |
---|
40 | m_ReverseControls = false; |
---|
41 | m_LastDrag = drag_NONE; |
---|
42 | } |
---|
43 | |
---|
44 | void GUIControl::SetView(GfxCore* view) |
---|
45 | { |
---|
46 | m_View = view; |
---|
47 | } |
---|
48 | |
---|
49 | bool GUIControl::MouseDown() const |
---|
50 | { |
---|
51 | return (dragging != NO_DRAG); |
---|
52 | } |
---|
53 | |
---|
54 | void GUIControl::HandleTilt(wxPoint point) |
---|
55 | { |
---|
56 | // Handle a mouse movement during tilt mode. |
---|
57 | |
---|
58 | // wxGTK (at least) fails to update the cursor while dragging. |
---|
59 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
---|
60 | |
---|
61 | int dy = point.y - m_DragStart.y; |
---|
62 | |
---|
63 | if (m_ReverseControls != m_View->GetPerspective()) dy = -dy; |
---|
64 | |
---|
65 | m_View->TiltCave(Double(dy) * 0.36); |
---|
66 | |
---|
67 | m_DragStart = point; |
---|
68 | |
---|
69 | m_View->ForceRefresh(); |
---|
70 | } |
---|
71 | |
---|
72 | void GUIControl::HandleTranslate(wxPoint point) |
---|
73 | { |
---|
74 | // Handle a mouse movement during translation mode. |
---|
75 | |
---|
76 | // wxGTK (at least) fails to update the cursor while dragging. |
---|
77 | m_View->UpdateCursor(GfxCore::CURSOR_DRAGGING_HAND); |
---|
78 | |
---|
79 | int dx = point.x - m_DragStart.x; |
---|
80 | int dy = point.y - m_DragStart.y; |
---|
81 | |
---|
82 | if (m_ReverseControls) { |
---|
83 | dx = -dx; |
---|
84 | dy = -dy; |
---|
85 | } |
---|
86 | |
---|
87 | if (m_View->GetPerspective()) |
---|
88 | m_View->MoveViewer(0, -dy * .1, dx * .1); |
---|
89 | else |
---|
90 | m_View->TranslateCave(dx, dy); |
---|
91 | |
---|
92 | m_DragStart = point; |
---|
93 | } |
---|
94 | |
---|
95 | void GUIControl::HandleScaleRotate(wxPoint point) |
---|
96 | { |
---|
97 | // Handle a mouse movement during scale/rotate mode. |
---|
98 | |
---|
99 | // wxGTK (at least) fails to update the cursor while dragging. |
---|
100 | m_View->UpdateCursor(GfxCore::CURSOR_ZOOM_ROTATE); |
---|
101 | |
---|
102 | int dx, dy; |
---|
103 | int threshold; |
---|
104 | if (m_ScaleRotateLock == lock_NONE) { |
---|
105 | // Dragging to scale or rotate but we've not decided which yet. |
---|
106 | dx = point.x - m_DragRealStart.x; |
---|
107 | dy = point.y - m_DragRealStart.y; |
---|
108 | threshold = 8 * 8; |
---|
109 | } else { |
---|
110 | dx = point.x - m_DragStart.x; |
---|
111 | dy = point.y - m_DragStart.y; |
---|
112 | threshold = 5; |
---|
113 | } |
---|
114 | int dx2 = dx * dx; |
---|
115 | int dy2 = dy * dy; |
---|
116 | if (dx2 + dy2 < threshold) return; |
---|
117 | |
---|
118 | switch (m_ScaleRotateLock) { |
---|
119 | case lock_NONE: |
---|
120 | if (dx2 > dy2) { |
---|
121 | m_ScaleRotateLock = lock_ROTATE; |
---|
122 | // m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
123 | } else { |
---|
124 | m_ScaleRotateLock = lock_SCALE; |
---|
125 | // m_View->UpdateCursor(GfxCore::CURSOR_ZOOM); |
---|
126 | } |
---|
127 | break; |
---|
128 | case lock_SCALE: |
---|
129 | if (dx2 >= 8 * dy2) { |
---|
130 | m_ScaleRotateLock = lock_ROTATE; |
---|
131 | // m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
132 | } |
---|
133 | break; |
---|
134 | case lock_ROTATE: |
---|
135 | if (dy2 >= 8 * dx2) { |
---|
136 | m_ScaleRotateLock = lock_SCALE; |
---|
137 | // m_View->UpdateCursor(GfxCore::CURSOR_ZOOM); |
---|
138 | } |
---|
139 | break; |
---|
140 | } |
---|
141 | |
---|
142 | if (m_ScaleRotateLock == lock_ROTATE) { |
---|
143 | dy = 0; |
---|
144 | } else { |
---|
145 | dx = 0; |
---|
146 | } |
---|
147 | |
---|
148 | if (m_ReverseControls) { |
---|
149 | dx = -dx; |
---|
150 | dy = -dy; |
---|
151 | } |
---|
152 | |
---|
153 | if (m_View->GetPerspective()) { |
---|
154 | if (dy) m_View->MoveViewer(-dy * .1, 0, 0); |
---|
155 | } else { |
---|
156 | // up/down => scale. |
---|
157 | if (dy) m_View->SetScale(m_View->GetScale() * pow(1.06, 0.08 * dy)); |
---|
158 | // left/right => rotate. |
---|
159 | if (dx) m_View->TurnCave(Double(dx) * -0.36); |
---|
160 | if (dx || dy) m_View->ForceRefresh(); |
---|
161 | } |
---|
162 | |
---|
163 | m_DragStart = point; |
---|
164 | } |
---|
165 | |
---|
166 | void GUIControl::HandleTiltRotate(wxPoint point) |
---|
167 | { |
---|
168 | // Handle a mouse movement during tilt/rotate mode. |
---|
169 | if (m_View->IsExtendedElevation()) return; |
---|
170 | |
---|
171 | // wxGTK (at least) fails to update the cursor while dragging. |
---|
172 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY); |
---|
173 | |
---|
174 | int dx = point.x - m_DragStart.x; |
---|
175 | int dy = point.y - m_DragStart.y; |
---|
176 | |
---|
177 | if (m_ReverseControls != m_View->GetPerspective()) { |
---|
178 | dx = -dx; |
---|
179 | dy = -dy; |
---|
180 | } |
---|
181 | |
---|
182 | // left/right => rotate, up/down => tilt. |
---|
183 | // Make tilt less sensitive than rotate as that feels better. |
---|
184 | m_View->TurnCave(Double(dx) * -0.36); |
---|
185 | m_View->TiltCave(Double(dy) * 0.18); |
---|
186 | |
---|
187 | m_View->ForceRefresh(); |
---|
188 | |
---|
189 | m_DragStart = point; |
---|
190 | } |
---|
191 | |
---|
192 | void GUIControl::HandleRotate(wxPoint point) |
---|
193 | { |
---|
194 | // Handle a mouse movement during rotate mode. |
---|
195 | if (m_View->IsExtendedElevation()) return; |
---|
196 | |
---|
197 | // wxGTK (at least) fails to update the cursor while dragging. |
---|
198 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
199 | |
---|
200 | int dx = point.x - m_DragStart.x; |
---|
201 | int dy = point.y - m_DragStart.y; |
---|
202 | |
---|
203 | if (m_ReverseControls != m_View->GetPerspective()) { |
---|
204 | dx = -dx; |
---|
205 | dy = -dy; |
---|
206 | } |
---|
207 | |
---|
208 | // left/right => rotate. |
---|
209 | m_View->TurnCave(Double(dx) * -0.36); |
---|
210 | |
---|
211 | m_View->ForceRefresh(); |
---|
212 | |
---|
213 | m_DragStart = point; |
---|
214 | } |
---|
215 | |
---|
216 | void GUIControl::RestoreCursor() |
---|
217 | { |
---|
218 | if (m_View->HereIsReal()) { |
---|
219 | m_View->UpdateCursor(GfxCore::CURSOR_POINTING_HAND); |
---|
220 | } else { |
---|
221 | m_View->UpdateCursor(GfxCore::CURSOR_DEFAULT); |
---|
222 | } |
---|
223 | } |
---|
224 | |
---|
225 | void GUIControl::HandleNonDrag(const wxPoint & point) { |
---|
226 | if (m_View->IsFullScreen()) { |
---|
227 | if (m_View->FullScreenModeShowingMenus()) { |
---|
228 | if (point.y > 8) |
---|
229 | m_View->FullScreenModeShowMenus(false); |
---|
230 | } else { |
---|
231 | if (point.y == 0) { |
---|
232 | m_View->FullScreenModeShowMenus(true); |
---|
233 | } |
---|
234 | } |
---|
235 | } |
---|
236 | if (m_View->CheckHitTestGrid(point, false)) { |
---|
237 | m_View->UpdateCursor(GfxCore::CURSOR_POINTING_HAND); |
---|
238 | } else if (m_View->PointWithinScaleBar(point)) { |
---|
239 | m_View->UpdateCursor(GfxCore::CURSOR_HORIZONTAL_RESIZE); |
---|
240 | } else if (m_View->PointWithinCompass(point)) { |
---|
241 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
242 | } else if (m_View->PointWithinClino(point)) { |
---|
243 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
---|
244 | } else { |
---|
245 | RestoreCursor(); |
---|
246 | } |
---|
247 | } |
---|
248 | |
---|
249 | // |
---|
250 | // Mouse event handling methods |
---|
251 | // |
---|
252 | |
---|
253 | void GUIControl::OnMouseMove(wxMouseEvent& event) |
---|
254 | { |
---|
255 | // Mouse motion event handler. |
---|
256 | if (!m_View->HasData()) return; |
---|
257 | |
---|
258 | // Ignore moves which don't change the position. |
---|
259 | if (event.GetPosition() == m_DragStart) { |
---|
260 | return; |
---|
261 | } |
---|
262 | |
---|
263 | static long timestamp = LONG_MIN; |
---|
264 | if (dragging != NO_DRAG && m_ScaleRotateLock != lock_NONE && |
---|
265 | timestamp != LONG_MIN) { |
---|
266 | // If no motion for a second, reset the direction lock. |
---|
267 | if (event.GetTimestamp() - timestamp >= 1000) { |
---|
268 | m_ScaleRotateLock = lock_NONE; |
---|
269 | m_DragRealStart = m_DragStart; |
---|
270 | RestoreCursor(); |
---|
271 | } |
---|
272 | } |
---|
273 | timestamp = event.GetTimestamp(); |
---|
274 | |
---|
275 | wxPoint point(event.GetPosition()); |
---|
276 | |
---|
277 | // Check hit-test grid (only if no buttons are pressed). |
---|
278 | if (!event.LeftIsDown() && !event.MiddleIsDown() && !event.RightIsDown()) { |
---|
279 | HandleNonDrag(point); |
---|
280 | } |
---|
281 | |
---|
282 | // Update coordinate display if in plan view, |
---|
283 | // or altitude if in elevation view. |
---|
284 | m_View->SetCoords(point); |
---|
285 | |
---|
286 | switch (dragging) { |
---|
287 | case LEFT_DRAG: |
---|
288 | switch (m_LastDrag) { |
---|
289 | case drag_COMPASS: |
---|
290 | // Drag in heading indicator. |
---|
291 | m_View->SetCompassFromPoint(point); |
---|
292 | break; |
---|
293 | case drag_ELEV: |
---|
294 | // Drag in clinometer. |
---|
295 | m_View->SetClinoFromPoint(point); |
---|
296 | break; |
---|
297 | case drag_SCALE: |
---|
298 | m_View->SetScaleBarFromOffset(point.x - m_DragLast.x); |
---|
299 | break; |
---|
300 | case drag_MAIN: |
---|
301 | if (event.ControlDown()) { |
---|
302 | HandleTiltRotate(point); |
---|
303 | } else { |
---|
304 | HandleScaleRotate(point); |
---|
305 | } |
---|
306 | break; |
---|
307 | case drag_ZOOM: |
---|
308 | m_View->SetZoomBox(m_DragStart, point, !event.ShiftDown(), event.ControlDown()); |
---|
309 | break; |
---|
310 | case drag_NONE: |
---|
311 | // Shouldn't happen?! FIXME: assert or something. |
---|
312 | break; |
---|
313 | } |
---|
314 | break; |
---|
315 | case MIDDLE_DRAG: |
---|
316 | HandleTilt(point); |
---|
317 | break; |
---|
318 | case RIGHT_DRAG: |
---|
319 | HandleTranslate(point); |
---|
320 | break; |
---|
321 | case NO_DRAG: |
---|
322 | break; |
---|
323 | } |
---|
324 | |
---|
325 | m_DragLast = point; |
---|
326 | } |
---|
327 | |
---|
328 | void GUIControl::OnLButtonDown(wxMouseEvent& event) |
---|
329 | { |
---|
330 | if (m_View->HasData()) { |
---|
331 | m_DragStart = m_DragRealStart = event.GetPosition(); |
---|
332 | |
---|
333 | if (m_View->PointWithinCompass(m_DragStart)) { |
---|
334 | m_LastDrag = drag_COMPASS; |
---|
335 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
336 | } else if (m_View->PointWithinClino(m_DragStart)) { |
---|
337 | m_LastDrag = drag_ELEV; |
---|
338 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
---|
339 | } else if (m_View->PointWithinScaleBar(m_DragStart)) { |
---|
340 | m_LastDrag = drag_SCALE; |
---|
341 | m_View->UpdateCursor(GfxCore::CURSOR_HORIZONTAL_RESIZE); |
---|
342 | } else if (event.ShiftDown()) { |
---|
343 | m_LastDrag = drag_ZOOM; |
---|
344 | m_View->UpdateCursor(GfxCore::CURSOR_ZOOM); |
---|
345 | } else { |
---|
346 | if (event.ControlDown() && !m_View->IsExtendedElevation()) { |
---|
347 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY); |
---|
348 | } else { |
---|
349 | m_View->UpdateCursor(GfxCore::CURSOR_ZOOM_ROTATE); |
---|
350 | } |
---|
351 | |
---|
352 | m_LastDrag = drag_MAIN; |
---|
353 | m_ScaleRotateLock = lock_NONE; |
---|
354 | } |
---|
355 | |
---|
356 | // We need to release and recapture for the cursor to update (noticed |
---|
357 | // with wxGTK). |
---|
358 | if (dragging != NO_DRAG) m_View->ReleaseMouse(); |
---|
359 | m_View->CaptureMouse(); |
---|
360 | |
---|
361 | dragging = LEFT_DRAG; |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | void GUIControl::OnLButtonUp(wxMouseEvent& event) |
---|
366 | { |
---|
367 | if (m_View->HasData()) { |
---|
368 | if (dragging != LEFT_DRAG) |
---|
369 | return; |
---|
370 | |
---|
371 | if (event.MiddleIsDown()) { |
---|
372 | if (m_LastDrag == drag_ZOOM) |
---|
373 | m_View->UnsetZoomBox(); |
---|
374 | OnMButtonDown(event); |
---|
375 | return; |
---|
376 | } |
---|
377 | |
---|
378 | if (event.RightIsDown()) { |
---|
379 | if (m_LastDrag == drag_ZOOM) |
---|
380 | m_View->UnsetZoomBox(); |
---|
381 | OnRButtonDown(event); |
---|
382 | return; |
---|
383 | } |
---|
384 | |
---|
385 | if (m_LastDrag == drag_ZOOM) { |
---|
386 | m_View->ZoomBoxGo(); |
---|
387 | } |
---|
388 | |
---|
389 | m_View->ReleaseMouse(); |
---|
390 | |
---|
391 | m_LastDrag = drag_NONE; |
---|
392 | dragging = NO_DRAG; |
---|
393 | |
---|
394 | m_View->DragFinished(); |
---|
395 | |
---|
396 | if (event.GetPosition() == m_DragRealStart) { |
---|
397 | // Just a "click"... |
---|
398 | m_View->CheckHitTestGrid(m_DragStart, true); |
---|
399 | RestoreCursor(); |
---|
400 | } else { |
---|
401 | HandleNonDrag(event.GetPosition()); |
---|
402 | } |
---|
403 | } |
---|
404 | } |
---|
405 | |
---|
406 | void GUIControl::OnMButtonDown(wxMouseEvent& event) |
---|
407 | { |
---|
408 | if (m_View->HasData() && !m_View->IsExtendedElevation()) { |
---|
409 | m_DragStart = event.GetPosition(); |
---|
410 | |
---|
411 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
---|
412 | |
---|
413 | if (dragging != NO_DRAG) { |
---|
414 | if (m_LastDrag == drag_ZOOM) |
---|
415 | m_View->UnsetZoomBox(); |
---|
416 | // We need to release and recapture for the cursor to update |
---|
417 | // (noticed with wxGTK). |
---|
418 | m_View->ReleaseMouse(); |
---|
419 | } |
---|
420 | m_View->CaptureMouse(); |
---|
421 | dragging = MIDDLE_DRAG; |
---|
422 | } |
---|
423 | } |
---|
424 | |
---|
425 | void GUIControl::OnMButtonUp(wxMouseEvent& event) |
---|
426 | { |
---|
427 | if (m_View->HasData()) { |
---|
428 | if (dragging != MIDDLE_DRAG) |
---|
429 | return; |
---|
430 | |
---|
431 | if (event.LeftIsDown()) { |
---|
432 | OnLButtonDown(event); |
---|
433 | return; |
---|
434 | } |
---|
435 | |
---|
436 | if (event.RightIsDown()) { |
---|
437 | OnRButtonDown(event); |
---|
438 | return; |
---|
439 | } |
---|
440 | |
---|
441 | dragging = NO_DRAG; |
---|
442 | m_View->ReleaseMouse(); |
---|
443 | m_View->DragFinished(); |
---|
444 | |
---|
445 | RestoreCursor(); |
---|
446 | } |
---|
447 | } |
---|
448 | |
---|
449 | void GUIControl::OnRButtonDown(wxMouseEvent& event) |
---|
450 | { |
---|
451 | if (m_View->HasData()) { |
---|
452 | if (m_View->HandleRClick(event.GetPosition())) |
---|
453 | return; |
---|
454 | |
---|
455 | m_DragStart = event.GetPosition(); |
---|
456 | |
---|
457 | m_View->UpdateCursor(GfxCore::CURSOR_DRAGGING_HAND); |
---|
458 | |
---|
459 | if (dragging != NO_DRAG) { |
---|
460 | if (m_LastDrag == drag_ZOOM) |
---|
461 | m_View->UnsetZoomBox(); |
---|
462 | // We need to release and recapture for the cursor to update |
---|
463 | // (noticed with wxGTK). |
---|
464 | m_View->ReleaseMouse(); |
---|
465 | } |
---|
466 | m_View->CaptureMouse(); |
---|
467 | dragging = RIGHT_DRAG; |
---|
468 | } |
---|
469 | } |
---|
470 | |
---|
471 | void GUIControl::OnRButtonUp(wxMouseEvent& event) |
---|
472 | { |
---|
473 | if (dragging != RIGHT_DRAG) |
---|
474 | return; |
---|
475 | |
---|
476 | if (event.LeftIsDown()) { |
---|
477 | OnLButtonDown(event); |
---|
478 | return; |
---|
479 | } |
---|
480 | |
---|
481 | if (event.MiddleIsDown()) { |
---|
482 | OnMButtonDown(event); |
---|
483 | return; |
---|
484 | } |
---|
485 | |
---|
486 | m_LastDrag = drag_NONE; |
---|
487 | m_View->ReleaseMouse(); |
---|
488 | |
---|
489 | dragging = NO_DRAG; |
---|
490 | |
---|
491 | RestoreCursor(); |
---|
492 | |
---|
493 | m_View->DragFinished(); |
---|
494 | } |
---|
495 | |
---|
496 | void GUIControl::OnMouseWheel(wxMouseEvent& event) { |
---|
497 | int dy = event.GetWheelRotation(); |
---|
498 | if (m_View->GetPerspective()) { |
---|
499 | m_View->MoveViewer(-dy, 0, 0); |
---|
500 | } else { |
---|
501 | m_View->SetScale(m_View->GetScale() * pow(1.06, -0.04 * dy)); |
---|
502 | m_View->ForceRefresh(); |
---|
503 | } |
---|
504 | } |
---|
505 | |
---|
506 | void GUIControl::OnDisplayOverlappingNames() |
---|
507 | { |
---|
508 | m_View->ToggleOverlappingNames(); |
---|
509 | } |
---|
510 | |
---|
511 | void GUIControl::OnDisplayOverlappingNamesUpdate(wxUpdateUIEvent& cmd) |
---|
512 | { |
---|
513 | cmd.Enable(m_View->HasData() && m_View->ShowingStationNames()); |
---|
514 | cmd.Check(m_View->ShowingOverlappingNames()); |
---|
515 | } |
---|
516 | |
---|
517 | void GUIControl::OnColourByDepth() |
---|
518 | { |
---|
519 | if (m_View->ColouringBy() == COLOUR_BY_DEPTH) { |
---|
520 | m_View->SetColourBy(COLOUR_BY_NONE); |
---|
521 | } else { |
---|
522 | m_View->SetColourBy(COLOUR_BY_DEPTH); |
---|
523 | } |
---|
524 | } |
---|
525 | |
---|
526 | void GUIControl::OnColourByDate() |
---|
527 | { |
---|
528 | if (m_View->ColouringBy() == COLOUR_BY_DATE) { |
---|
529 | m_View->SetColourBy(COLOUR_BY_NONE); |
---|
530 | } else { |
---|
531 | m_View->SetColourBy(COLOUR_BY_DATE); |
---|
532 | } |
---|
533 | } |
---|
534 | |
---|
535 | void GUIControl::OnColourByError() |
---|
536 | { |
---|
537 | if (m_View->ColouringBy() == COLOUR_BY_ERROR) { |
---|
538 | m_View->SetColourBy(COLOUR_BY_NONE); |
---|
539 | } else { |
---|
540 | m_View->SetColourBy(COLOUR_BY_ERROR); |
---|
541 | } |
---|
542 | } |
---|
543 | |
---|
544 | void GUIControl::OnColourByGradient() |
---|
545 | { |
---|
546 | if (m_View->ColouringBy() == COLOUR_BY_GRADIENT) { |
---|
547 | m_View->SetColourBy(COLOUR_BY_NONE); |
---|
548 | } else { |
---|
549 | m_View->SetColourBy(COLOUR_BY_GRADIENT); |
---|
550 | } |
---|
551 | } |
---|
552 | |
---|
553 | void GUIControl::OnColourByLength() |
---|
554 | { |
---|
555 | if (m_View->ColouringBy() == COLOUR_BY_LENGTH) { |
---|
556 | m_View->SetColourBy(COLOUR_BY_NONE); |
---|
557 | } else { |
---|
558 | m_View->SetColourBy(COLOUR_BY_LENGTH); |
---|
559 | } |
---|
560 | } |
---|
561 | |
---|
562 | void GUIControl::OnColourByUpdate(wxUpdateUIEvent& cmd) |
---|
563 | { |
---|
564 | cmd.Enable(m_View->HasData()); |
---|
565 | } |
---|
566 | |
---|
567 | void GUIControl::OnColourByDepthUpdate(wxUpdateUIEvent& cmd) |
---|
568 | { |
---|
569 | cmd.Enable(m_View->HasData()); |
---|
570 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_DEPTH); |
---|
571 | } |
---|
572 | |
---|
573 | void GUIControl::OnColourByDateUpdate(wxUpdateUIEvent& cmd) |
---|
574 | { |
---|
575 | cmd.Enable(m_View->HasData()); |
---|
576 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_DATE); |
---|
577 | } |
---|
578 | |
---|
579 | void GUIControl::OnColourByErrorUpdate(wxUpdateUIEvent& cmd) |
---|
580 | { |
---|
581 | cmd.Enable(m_View->HasData()); |
---|
582 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_ERROR); |
---|
583 | } |
---|
584 | |
---|
585 | void GUIControl::OnColourByGradientUpdate(wxUpdateUIEvent& cmd) |
---|
586 | { |
---|
587 | cmd.Enable(m_View->HasData()); |
---|
588 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_GRADIENT); |
---|
589 | } |
---|
590 | |
---|
591 | void GUIControl::OnColourByLengthUpdate(wxUpdateUIEvent& cmd) |
---|
592 | { |
---|
593 | cmd.Enable(m_View->HasData()); |
---|
594 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_LENGTH); |
---|
595 | } |
---|
596 | |
---|
597 | void GUIControl::OnShowCrosses() |
---|
598 | { |
---|
599 | m_View->ToggleCrosses(); |
---|
600 | } |
---|
601 | |
---|
602 | void GUIControl::OnShowCrossesUpdate(wxUpdateUIEvent& cmd) |
---|
603 | { |
---|
604 | cmd.Enable(m_View->HasData()); |
---|
605 | cmd.Check(m_View->ShowingCrosses()); |
---|
606 | } |
---|
607 | |
---|
608 | void GUIControl::OnShowStationNames() |
---|
609 | { |
---|
610 | m_View->ToggleStationNames(); |
---|
611 | } |
---|
612 | |
---|
613 | void GUIControl::OnShowStationNamesUpdate(wxUpdateUIEvent& cmd) |
---|
614 | { |
---|
615 | cmd.Enable(m_View->HasData()); |
---|
616 | cmd.Check(m_View->ShowingStationNames()); |
---|
617 | } |
---|
618 | |
---|
619 | void GUIControl::OnShowSurveyLegs() |
---|
620 | { |
---|
621 | m_View->ToggleUndergroundLegs(); |
---|
622 | } |
---|
623 | |
---|
624 | void GUIControl::OnShowSurveyLegsUpdate(wxUpdateUIEvent& cmd) |
---|
625 | { |
---|
626 | cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs()); |
---|
627 | cmd.Check(m_View->ShowingUndergroundLegs()); |
---|
628 | } |
---|
629 | |
---|
630 | void GUIControl::OnHideSplays() |
---|
631 | { |
---|
632 | m_View->SetSplaysMode(SHOW_HIDE); |
---|
633 | } |
---|
634 | |
---|
635 | void GUIControl::OnShowSplaysNormal() |
---|
636 | { |
---|
637 | m_View->SetSplaysMode(SHOW_NORMAL); |
---|
638 | } |
---|
639 | |
---|
640 | void GUIControl::OnShowSplaysFaded() |
---|
641 | { |
---|
642 | m_View->SetSplaysMode(SHOW_FADED); |
---|
643 | } |
---|
644 | |
---|
645 | void GUIControl::OnSplaysUpdate(wxUpdateUIEvent& cmd) |
---|
646 | { |
---|
647 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
---|
648 | } |
---|
649 | |
---|
650 | void GUIControl::OnHideSplaysUpdate(wxUpdateUIEvent& cmd) |
---|
651 | { |
---|
652 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
---|
653 | cmd.Check(m_View->ShowingSplaysMode() == SHOW_HIDE); |
---|
654 | } |
---|
655 | |
---|
656 | void GUIControl::OnShowSplaysNormalUpdate(wxUpdateUIEvent& cmd) |
---|
657 | { |
---|
658 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
---|
659 | cmd.Check(m_View->ShowingSplaysMode() == SHOW_NORMAL); |
---|
660 | } |
---|
661 | |
---|
662 | void GUIControl::OnShowSplaysFadedUpdate(wxUpdateUIEvent& cmd) |
---|
663 | { |
---|
664 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
---|
665 | cmd.Check(m_View->ShowingSplaysMode() == SHOW_FADED); |
---|
666 | } |
---|
667 | |
---|
668 | void GUIControl::OnHideDupes() { |
---|
669 | m_View->SetDupesMode(SHOW_HIDE); |
---|
670 | } |
---|
671 | |
---|
672 | void GUIControl::OnShowDupesNormal() { |
---|
673 | m_View->SetDupesMode(SHOW_NORMAL); |
---|
674 | } |
---|
675 | |
---|
676 | void GUIControl::OnShowDupesDashed() { |
---|
677 | m_View->SetDupesMode(SHOW_DASHED); |
---|
678 | } |
---|
679 | |
---|
680 | void GUIControl::OnDupesUpdate(wxUpdateUIEvent& cmd) { |
---|
681 | cmd.Enable(m_View->HasData() && m_View->HasDupes()); |
---|
682 | } |
---|
683 | |
---|
684 | void GUIControl::OnHideDupesUpdate(wxUpdateUIEvent& cmd) { |
---|
685 | cmd.Enable(m_View->HasData() && m_View->HasDupes()); |
---|
686 | cmd.Check(m_View->ShowingDupesMode() == SHOW_HIDE); |
---|
687 | } |
---|
688 | |
---|
689 | void GUIControl::OnShowDupesNormalUpdate(wxUpdateUIEvent& cmd) { |
---|
690 | cmd.Enable(m_View->HasData() && m_View->HasDupes()); |
---|
691 | cmd.Check(m_View->ShowingDupesMode() == SHOW_NORMAL); |
---|
692 | } |
---|
693 | |
---|
694 | void GUIControl::OnShowDupesDashedUpdate(wxUpdateUIEvent& cmd) { |
---|
695 | cmd.Enable(m_View->HasData() && m_View->HasDupes()); |
---|
696 | cmd.Check(m_View->ShowingDupesMode() == SHOW_DASHED); |
---|
697 | } |
---|
698 | |
---|
699 | void GUIControl::OnMoveEast() |
---|
700 | { |
---|
701 | m_View->TurnCaveTo(90.0); |
---|
702 | m_View->ForceRefresh(); |
---|
703 | } |
---|
704 | |
---|
705 | void GUIControl::OnMoveEastUpdate(wxUpdateUIEvent& cmd) |
---|
706 | { |
---|
707 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && m_View->GetCompassValue() != 90.0); |
---|
708 | } |
---|
709 | |
---|
710 | void GUIControl::OnMoveNorth() |
---|
711 | { |
---|
712 | m_View->TurnCaveTo(0.0); |
---|
713 | m_View->ForceRefresh(); |
---|
714 | } |
---|
715 | |
---|
716 | void GUIControl::OnMoveNorthUpdate(wxUpdateUIEvent& cmd) |
---|
717 | { |
---|
718 | cmd.Enable(m_View->HasData() && m_View->GetCompassValue() != 0.0); |
---|
719 | } |
---|
720 | |
---|
721 | void GUIControl::OnMoveSouth() |
---|
722 | { |
---|
723 | m_View->TurnCaveTo(180.0); |
---|
724 | m_View->ForceRefresh(); |
---|
725 | } |
---|
726 | |
---|
727 | void GUIControl::OnMoveSouthUpdate(wxUpdateUIEvent& cmd) |
---|
728 | { |
---|
729 | cmd.Enable(m_View->HasData() && m_View->GetCompassValue() != 180.0); |
---|
730 | } |
---|
731 | |
---|
732 | void GUIControl::OnMoveWest() |
---|
733 | { |
---|
734 | m_View->TurnCaveTo(270.0); |
---|
735 | m_View->ForceRefresh(); |
---|
736 | } |
---|
737 | |
---|
738 | void GUIControl::OnMoveWestUpdate(wxUpdateUIEvent& cmd) |
---|
739 | { |
---|
740 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && m_View->GetCompassValue() != 270.0); |
---|
741 | } |
---|
742 | |
---|
743 | void GUIControl::OnToggleRotation() |
---|
744 | { |
---|
745 | m_View->ToggleRotation(); |
---|
746 | } |
---|
747 | |
---|
748 | void GUIControl::OnToggleRotationUpdate(wxUpdateUIEvent& cmd) |
---|
749 | { |
---|
750 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
751 | cmd.Check(m_View->HasData() && m_View->IsRotating()); |
---|
752 | } |
---|
753 | |
---|
754 | void GUIControl::OnReverseControls() |
---|
755 | { |
---|
756 | m_ReverseControls = !m_ReverseControls; |
---|
757 | } |
---|
758 | |
---|
759 | void GUIControl::OnReverseControlsUpdate(wxUpdateUIEvent& cmd) |
---|
760 | { |
---|
761 | cmd.Enable(m_View->HasData()); |
---|
762 | cmd.Check(m_ReverseControls); |
---|
763 | } |
---|
764 | |
---|
765 | void GUIControl::OnReverseDirectionOfRotation() |
---|
766 | { |
---|
767 | m_View->ReverseRotation(); |
---|
768 | } |
---|
769 | |
---|
770 | void GUIControl::OnReverseDirectionOfRotationUpdate(wxUpdateUIEvent& cmd) |
---|
771 | { |
---|
772 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
773 | } |
---|
774 | |
---|
775 | void GUIControl::OnStepOnceAnticlockwise(bool accel) |
---|
776 | { |
---|
777 | if (m_View->GetPerspective()) { |
---|
778 | m_View->TurnCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
---|
779 | } else { |
---|
780 | m_View->TurnCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
---|
781 | } |
---|
782 | m_View->ForceRefresh(); |
---|
783 | } |
---|
784 | |
---|
785 | void GUIControl::OnStepOnceClockwise(bool accel) |
---|
786 | { |
---|
787 | if (m_View->GetPerspective()) { |
---|
788 | m_View->TurnCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
---|
789 | } else { |
---|
790 | m_View->TurnCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
---|
791 | } |
---|
792 | m_View->ForceRefresh(); |
---|
793 | } |
---|
794 | |
---|
795 | void GUIControl::OnDefaults() |
---|
796 | { |
---|
797 | m_View->Defaults(); |
---|
798 | } |
---|
799 | |
---|
800 | void GUIControl::OnDefaultsUpdate(wxUpdateUIEvent& cmd) |
---|
801 | { |
---|
802 | cmd.Enable(m_View->HasData()); |
---|
803 | } |
---|
804 | |
---|
805 | void GUIControl::OnElevation() |
---|
806 | { |
---|
807 | // Switch to elevation view. |
---|
808 | |
---|
809 | m_View->SwitchToElevation(); |
---|
810 | } |
---|
811 | |
---|
812 | void GUIControl::OnElevationUpdate(wxUpdateUIEvent& cmd) |
---|
813 | { |
---|
814 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingElevation()); |
---|
815 | } |
---|
816 | |
---|
817 | void GUIControl::OnHigherViewpoint(bool accel) |
---|
818 | { |
---|
819 | // Raise the viewpoint. |
---|
820 | if (m_View->GetPerspective()) { |
---|
821 | m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
---|
822 | } else { |
---|
823 | m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
---|
824 | } |
---|
825 | m_View->ForceRefresh(); |
---|
826 | } |
---|
827 | |
---|
828 | void GUIControl::OnLowerViewpoint(bool accel) |
---|
829 | { |
---|
830 | // Lower the viewpoint. |
---|
831 | if (m_View->GetPerspective()) { |
---|
832 | m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
---|
833 | } else { |
---|
834 | m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
---|
835 | } |
---|
836 | m_View->ForceRefresh(); |
---|
837 | } |
---|
838 | |
---|
839 | void GUIControl::OnPlan() |
---|
840 | { |
---|
841 | // Switch to plan view. |
---|
842 | m_View->SwitchToPlan(); |
---|
843 | } |
---|
844 | |
---|
845 | void GUIControl::OnPlanUpdate(wxUpdateUIEvent& cmd) |
---|
846 | { |
---|
847 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingPlan()); |
---|
848 | } |
---|
849 | |
---|
850 | void GUIControl::OnShiftDisplayDown(bool accel) |
---|
851 | { |
---|
852 | if (m_View->GetPerspective()) |
---|
853 | m_View->MoveViewer(0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0); |
---|
854 | else |
---|
855 | m_View->TranslateCave(0, accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT); |
---|
856 | } |
---|
857 | |
---|
858 | void GUIControl::OnShiftDisplayLeft(bool accel) |
---|
859 | { |
---|
860 | if (m_View->GetPerspective()) |
---|
861 | m_View->MoveViewer(0, 0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT); |
---|
862 | else |
---|
863 | m_View->TranslateCave(accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT, 0); |
---|
864 | } |
---|
865 | |
---|
866 | void GUIControl::OnShiftDisplayRight(bool accel) |
---|
867 | { |
---|
868 | if (m_View->GetPerspective()) |
---|
869 | m_View->MoveViewer(0, 0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT); |
---|
870 | else |
---|
871 | m_View->TranslateCave(accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT, 0); |
---|
872 | } |
---|
873 | |
---|
874 | void GUIControl::OnShiftDisplayUp(bool accel) |
---|
875 | { |
---|
876 | if (m_View->GetPerspective()) |
---|
877 | m_View->MoveViewer(0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0); |
---|
878 | else |
---|
879 | m_View->TranslateCave(0, accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT); |
---|
880 | } |
---|
881 | |
---|
882 | void GUIControl::OnZoomIn(bool accel) |
---|
883 | { |
---|
884 | // Increase the scale. |
---|
885 | |
---|
886 | if (m_View->GetPerspective()) { |
---|
887 | m_View->MoveViewer(accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0, 0); |
---|
888 | } else { |
---|
889 | m_View->SetScale(m_View->GetScale() * (accel ? 1.1236 : 1.06)); |
---|
890 | m_View->ForceRefresh(); |
---|
891 | } |
---|
892 | } |
---|
893 | |
---|
894 | void GUIControl::OnZoomOut(bool accel) |
---|
895 | { |
---|
896 | // Decrease the scale. |
---|
897 | |
---|
898 | if (m_View->GetPerspective()) { |
---|
899 | m_View->MoveViewer(accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0, 0); |
---|
900 | } else { |
---|
901 | m_View->SetScale(m_View->GetScale() / (accel ? 1.1236 : 1.06)); |
---|
902 | m_View->ForceRefresh(); |
---|
903 | } |
---|
904 | } |
---|
905 | |
---|
906 | void GUIControl::OnToggleScalebar() |
---|
907 | { |
---|
908 | m_View->ToggleScaleBar(); |
---|
909 | } |
---|
910 | |
---|
911 | void GUIControl::OnToggleScalebarUpdate(wxUpdateUIEvent& cmd) |
---|
912 | { |
---|
913 | cmd.Enable(m_View->HasData()); |
---|
914 | cmd.Check(m_View->ShowingScaleBar()); |
---|
915 | } |
---|
916 | |
---|
917 | void GUIControl::OnToggleColourKey() |
---|
918 | { |
---|
919 | m_View->ToggleColourKey(); |
---|
920 | } |
---|
921 | |
---|
922 | void GUIControl::OnToggleColourKeyUpdate(wxUpdateUIEvent& cmd) |
---|
923 | { |
---|
924 | cmd.Enable(m_View->HasData() && m_View->ColouringBy() != COLOUR_BY_NONE); |
---|
925 | cmd.Check(m_View->ShowingColourKey()); |
---|
926 | } |
---|
927 | |
---|
928 | void GUIControl::OnViewCompass() |
---|
929 | { |
---|
930 | m_View->ToggleCompass(); |
---|
931 | } |
---|
932 | |
---|
933 | void GUIControl::OnViewCompassUpdate(wxUpdateUIEvent& cmd) |
---|
934 | { |
---|
935 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
936 | cmd.Check(m_View->ShowingCompass()); |
---|
937 | } |
---|
938 | |
---|
939 | void GUIControl::OnViewClino() |
---|
940 | { |
---|
941 | m_View->ToggleClino(); |
---|
942 | } |
---|
943 | |
---|
944 | void GUIControl::OnViewClinoUpdate(wxUpdateUIEvent& cmd) |
---|
945 | { |
---|
946 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
947 | cmd.Check(m_View->ShowingClino()); |
---|
948 | } |
---|
949 | |
---|
950 | void GUIControl::OnShowSurface() |
---|
951 | { |
---|
952 | m_View->ToggleSurfaceLegs(); |
---|
953 | } |
---|
954 | |
---|
955 | void GUIControl::OnShowSurfaceUpdate(wxUpdateUIEvent& cmd) |
---|
956 | { |
---|
957 | cmd.Enable(m_View->HasData() && m_View->HasSurfaceLegs()); |
---|
958 | cmd.Check(m_View->ShowingSurfaceLegs()); |
---|
959 | } |
---|
960 | |
---|
961 | void GUIControl::OnShowEntrances() |
---|
962 | { |
---|
963 | m_View->ToggleEntrances(); |
---|
964 | } |
---|
965 | |
---|
966 | void GUIControl::OnShowEntrancesUpdate(wxUpdateUIEvent& cmd) |
---|
967 | { |
---|
968 | cmd.Enable(m_View->HasData() && (m_View->GetNumEntrances() > 0)); |
---|
969 | cmd.Check(m_View->ShowingEntrances()); |
---|
970 | } |
---|
971 | |
---|
972 | void GUIControl::OnShowFixedPts() |
---|
973 | { |
---|
974 | m_View->ToggleFixedPts(); |
---|
975 | } |
---|
976 | |
---|
977 | void GUIControl::OnShowFixedPtsUpdate(wxUpdateUIEvent& cmd) |
---|
978 | { |
---|
979 | cmd.Enable(m_View->HasData() && (m_View->GetNumFixedPts() > 0)); |
---|
980 | cmd.Check(m_View->ShowingFixedPts()); |
---|
981 | } |
---|
982 | |
---|
983 | void GUIControl::OnShowExportedPts() |
---|
984 | { |
---|
985 | m_View->ToggleExportedPts(); |
---|
986 | } |
---|
987 | |
---|
988 | void GUIControl::OnShowExportedPtsUpdate(wxUpdateUIEvent& cmd) |
---|
989 | { |
---|
990 | cmd.Enable(m_View->HasData() && (m_View->GetNumExportedPts() > 0)); |
---|
991 | cmd.Check(m_View->ShowingExportedPts()); |
---|
992 | } |
---|
993 | |
---|
994 | void GUIControl::OnViewGrid() |
---|
995 | { |
---|
996 | m_View->ToggleGrid(); |
---|
997 | } |
---|
998 | |
---|
999 | void GUIControl::OnViewGridUpdate(wxUpdateUIEvent& cmd) |
---|
1000 | { |
---|
1001 | cmd.Enable(m_View->HasData()); |
---|
1002 | cmd.Check(m_View->ShowingGrid()); |
---|
1003 | } |
---|
1004 | |
---|
1005 | void GUIControl::OnIndicatorsUpdate(wxUpdateUIEvent& cmd) |
---|
1006 | { |
---|
1007 | cmd.Enable(m_View->HasData()); |
---|
1008 | } |
---|
1009 | |
---|
1010 | void GUIControl::OnViewPerspective() |
---|
1011 | { |
---|
1012 | m_View->TogglePerspective(); |
---|
1013 | // Force update of coordinate display. |
---|
1014 | if (m_View->GetPerspective()) { |
---|
1015 | m_View->MoveViewer(0, 0, 0); |
---|
1016 | } else { |
---|
1017 | m_View->ClearCoords(); |
---|
1018 | } |
---|
1019 | } |
---|
1020 | |
---|
1021 | void GUIControl::OnViewPerspectiveUpdate(wxUpdateUIEvent& cmd) |
---|
1022 | { |
---|
1023 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
1024 | cmd.Check(m_View->GetPerspective()); |
---|
1025 | } |
---|
1026 | |
---|
1027 | void GUIControl::OnViewSmoothShading() |
---|
1028 | { |
---|
1029 | m_View->ToggleSmoothShading(); |
---|
1030 | } |
---|
1031 | |
---|
1032 | void GUIControl::OnViewSmoothShadingUpdate(wxUpdateUIEvent& cmd) |
---|
1033 | { |
---|
1034 | cmd.Enable(m_View->HasData()); |
---|
1035 | cmd.Check(m_View->GetSmoothShading()); |
---|
1036 | } |
---|
1037 | |
---|
1038 | void GUIControl::OnViewTextured() |
---|
1039 | { |
---|
1040 | m_View->ToggleTextured(); |
---|
1041 | } |
---|
1042 | |
---|
1043 | void GUIControl::OnViewTexturedUpdate(wxUpdateUIEvent& cmd) |
---|
1044 | { |
---|
1045 | cmd.Enable(m_View->HasData()); |
---|
1046 | cmd.Check(m_View->GetTextured()); |
---|
1047 | } |
---|
1048 | |
---|
1049 | void GUIControl::OnViewFog() |
---|
1050 | { |
---|
1051 | m_View->ToggleFog(); |
---|
1052 | } |
---|
1053 | |
---|
1054 | void GUIControl::OnViewFogUpdate(wxUpdateUIEvent& cmd) |
---|
1055 | { |
---|
1056 | cmd.Enable(m_View->HasData()); |
---|
1057 | cmd.Check(m_View->GetFog()); |
---|
1058 | } |
---|
1059 | |
---|
1060 | void GUIControl::OnViewSmoothLines() |
---|
1061 | { |
---|
1062 | m_View->ToggleAntiAlias(); |
---|
1063 | } |
---|
1064 | |
---|
1065 | void GUIControl::OnViewSmoothLinesUpdate(wxUpdateUIEvent& cmd) |
---|
1066 | { |
---|
1067 | cmd.Enable(m_View->HasData()); |
---|
1068 | cmd.Check(m_View->GetAntiAlias()); |
---|
1069 | } |
---|
1070 | |
---|
1071 | void GUIControl::OnToggleMetric() |
---|
1072 | { |
---|
1073 | m_View->ToggleMetric(); |
---|
1074 | |
---|
1075 | wxConfigBase::Get()->Write(wxT("metric"), m_View->GetMetric()); |
---|
1076 | wxConfigBase::Get()->Flush(); |
---|
1077 | } |
---|
1078 | |
---|
1079 | void GUIControl::OnToggleMetricUpdate(wxUpdateUIEvent& cmd) |
---|
1080 | { |
---|
1081 | cmd.Enable(m_View->HasData()); |
---|
1082 | cmd.Check(m_View->GetMetric()); |
---|
1083 | } |
---|
1084 | |
---|
1085 | void GUIControl::OnToggleDegrees() |
---|
1086 | { |
---|
1087 | m_View->ToggleDegrees(); |
---|
1088 | |
---|
1089 | wxConfigBase::Get()->Write(wxT("degrees"), m_View->GetDegrees()); |
---|
1090 | wxConfigBase::Get()->Flush(); |
---|
1091 | } |
---|
1092 | |
---|
1093 | void GUIControl::OnToggleDegreesUpdate(wxUpdateUIEvent& cmd) |
---|
1094 | { |
---|
1095 | cmd.Enable(m_View->HasData()); |
---|
1096 | cmd.Check(m_View->GetDegrees()); |
---|
1097 | } |
---|
1098 | |
---|
1099 | void GUIControl::OnTogglePercent() |
---|
1100 | { |
---|
1101 | m_View->TogglePercent(); |
---|
1102 | |
---|
1103 | wxConfigBase::Get()->Write(wxT("percent"), m_View->GetPercent()); |
---|
1104 | wxConfigBase::Get()->Flush(); |
---|
1105 | } |
---|
1106 | |
---|
1107 | void GUIControl::OnTogglePercentUpdate(wxUpdateUIEvent& cmd) |
---|
1108 | { |
---|
1109 | cmd.Enable(m_View->HasData()); |
---|
1110 | cmd.Check(m_View->GetPercent()); |
---|
1111 | } |
---|
1112 | |
---|
1113 | void GUIControl::OnToggleTubes() |
---|
1114 | { |
---|
1115 | m_View->ToggleTubes(); |
---|
1116 | } |
---|
1117 | |
---|
1118 | void GUIControl::OnToggleTubesUpdate(wxUpdateUIEvent& cmd) |
---|
1119 | { |
---|
1120 | cmd.Enable(m_View->HasData() && m_View->HasTubes()); |
---|
1121 | cmd.Check(m_View->GetTubes()); |
---|
1122 | } |
---|
1123 | |
---|
1124 | void GUIControl::OnCancelDistLine() |
---|
1125 | { |
---|
1126 | m_View->ClearTreeSelection(); |
---|
1127 | } |
---|
1128 | |
---|
1129 | void GUIControl::OnCancelDistLineUpdate(wxUpdateUIEvent& cmd) |
---|
1130 | { |
---|
1131 | cmd.Enable(m_View->ShowingMeasuringLine()); |
---|
1132 | } |
---|
1133 | |
---|
1134 | void GUIControl::OnKeyPress(wxKeyEvent &e) |
---|
1135 | { |
---|
1136 | if (!m_View->HasData() || |
---|
1137 | (e.GetModifiers() &~ (wxMOD_CONTROL|wxMOD_SHIFT))) { |
---|
1138 | // Pass on the event if there's no survey data, or if any modifier keys |
---|
1139 | // other than Ctrl and Shift are pressed. |
---|
1140 | e.Skip(); |
---|
1141 | return; |
---|
1142 | } |
---|
1143 | |
---|
1144 | // The changelog says this is meant to keep animation going while keys are |
---|
1145 | // pressed, but that happens anyway (on linux at least - perhaps it helps |
---|
1146 | // on windows?) FIXME : check! |
---|
1147 | //bool refresh = m_View->Animate(); |
---|
1148 | |
---|
1149 | switch (e.GetKeyCode()) { |
---|
1150 | case '/': case '?': |
---|
1151 | if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()) |
---|
1152 | OnLowerViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
---|
1153 | break; |
---|
1154 | case '\'': case '@': case '"': // both shifted forms - US and UK kbd |
---|
1155 | if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()) |
---|
1156 | OnHigherViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
---|
1157 | break; |
---|
1158 | case 'C': case 'c': |
---|
1159 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1160 | OnStepOnceAnticlockwise(e.GetModifiers() == wxMOD_SHIFT); |
---|
1161 | break; |
---|
1162 | case 'V': case 'v': |
---|
1163 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1164 | OnStepOnceClockwise(e.GetModifiers() == wxMOD_SHIFT); |
---|
1165 | break; |
---|
1166 | case ']': case '}': |
---|
1167 | OnZoomIn(e.GetModifiers() == wxMOD_SHIFT); |
---|
1168 | break; |
---|
1169 | case '[': case '{': |
---|
1170 | OnZoomOut(e.GetModifiers() == wxMOD_SHIFT); |
---|
1171 | break; |
---|
1172 | case 'N': case 'n': |
---|
1173 | OnMoveNorth(); |
---|
1174 | break; |
---|
1175 | case 'S': case 's': |
---|
1176 | OnMoveSouth(); |
---|
1177 | break; |
---|
1178 | case 'E': case 'e': |
---|
1179 | if (!m_View->IsExtendedElevation()) |
---|
1180 | OnMoveEast(); |
---|
1181 | break; |
---|
1182 | case 'W': case 'w': |
---|
1183 | if (!m_View->IsExtendedElevation()) |
---|
1184 | OnMoveWest(); |
---|
1185 | break; |
---|
1186 | case 'Z': case 'z': |
---|
1187 | if (!m_View->IsExtendedElevation()) |
---|
1188 | m_View->RotateFaster(e.GetModifiers() == wxMOD_SHIFT); |
---|
1189 | break; |
---|
1190 | case 'X': case 'x': |
---|
1191 | if (!m_View->IsExtendedElevation()) |
---|
1192 | m_View->RotateSlower(e.GetModifiers() == wxMOD_SHIFT); |
---|
1193 | break; |
---|
1194 | case 'R': case 'r': |
---|
1195 | if (!m_View->IsExtendedElevation()) |
---|
1196 | OnReverseDirectionOfRotation(); |
---|
1197 | break; |
---|
1198 | case 'P': case 'p': |
---|
1199 | if (!m_View->IsExtendedElevation() && !m_View->ShowingPlan()) |
---|
1200 | OnPlan(); |
---|
1201 | break; |
---|
1202 | case 'L': case 'l': |
---|
1203 | if (!m_View->IsExtendedElevation() && !m_View->ShowingElevation()) |
---|
1204 | OnElevation(); |
---|
1205 | break; |
---|
1206 | case 'O': case 'o': |
---|
1207 | OnDisplayOverlappingNames(); |
---|
1208 | break; |
---|
1209 | case WXK_DELETE: |
---|
1210 | if (e.GetModifiers() == 0) |
---|
1211 | OnDefaults(); |
---|
1212 | break; |
---|
1213 | case WXK_RETURN: |
---|
1214 | if (e.GetModifiers() == 0) { |
---|
1215 | // For compatibility with older versions. |
---|
1216 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1217 | m_View->StartRotation(); |
---|
1218 | } |
---|
1219 | break; |
---|
1220 | case WXK_SPACE: |
---|
1221 | if (e.GetModifiers() == 0) { |
---|
1222 | if (!m_View->IsExtendedElevation()) |
---|
1223 | OnToggleRotation(); |
---|
1224 | } |
---|
1225 | break; |
---|
1226 | case WXK_LEFT: |
---|
1227 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
---|
1228 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1229 | OnStepOnceAnticlockwise(e.GetModifiers() == wxMOD_SHIFT); |
---|
1230 | } else { |
---|
1231 | OnShiftDisplayLeft(e.GetModifiers() == wxMOD_SHIFT); |
---|
1232 | } |
---|
1233 | break; |
---|
1234 | case WXK_RIGHT: |
---|
1235 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
---|
1236 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1237 | OnStepOnceClockwise(e.GetModifiers() == wxMOD_SHIFT); |
---|
1238 | } else { |
---|
1239 | OnShiftDisplayRight(e.GetModifiers() == wxMOD_SHIFT); |
---|
1240 | } |
---|
1241 | break; |
---|
1242 | case WXK_UP: |
---|
1243 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
---|
1244 | if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()) |
---|
1245 | OnHigherViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
---|
1246 | } else { |
---|
1247 | OnShiftDisplayUp(e.GetModifiers() == wxMOD_SHIFT); |
---|
1248 | } |
---|
1249 | break; |
---|
1250 | case WXK_DOWN: |
---|
1251 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
---|
1252 | if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()) |
---|
1253 | OnLowerViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
---|
1254 | } else { |
---|
1255 | OnShiftDisplayDown(e.GetModifiers() == wxMOD_SHIFT); |
---|
1256 | } |
---|
1257 | break; |
---|
1258 | case WXK_ESCAPE: |
---|
1259 | if (e.GetModifiers() == 0) { |
---|
1260 | if (m_View->ShowingMeasuringLine()) { |
---|
1261 | OnCancelDistLine(); |
---|
1262 | } else if (m_View->IsFullScreen()) { |
---|
1263 | // Cancel full-screen mode on "Escape" if it isn't cancelling |
---|
1264 | // the measuring line. |
---|
1265 | m_View->FullScreenMode(); |
---|
1266 | } |
---|
1267 | } |
---|
1268 | break; |
---|
1269 | case WXK_F2: |
---|
1270 | if (e.GetModifiers() == 0) |
---|
1271 | m_View->ToggleFatFinger(); |
---|
1272 | break; |
---|
1273 | case WXK_F3: |
---|
1274 | if (e.GetModifiers() == 0) |
---|
1275 | m_View->ToggleHitTestDebug(); |
---|
1276 | break; |
---|
1277 | case WXK_F4: { |
---|
1278 | if (e.GetModifiers() == 0) { |
---|
1279 | const wxChar * msg; |
---|
1280 | #if wxDEBUG_LEVEL |
---|
1281 | if (wxTheAssertHandler) |
---|
1282 | wxTheAssertHandler = NULL; |
---|
1283 | else |
---|
1284 | wxSetDefaultAssertHandler(); |
---|
1285 | if (wxTheAssertHandler) |
---|
1286 | msg = wxT("Assertions enabled"); |
---|
1287 | else |
---|
1288 | msg = wxT("Assertions disabled"); |
---|
1289 | #else |
---|
1290 | msg = wxT("wxWidgets was built without assertions"); |
---|
1291 | #endif |
---|
1292 | wxMessageBox(msg, wxT("Aven Debug"), wxOK | wxICON_INFORMATION); |
---|
1293 | } |
---|
1294 | break; |
---|
1295 | } |
---|
1296 | case WXK_F5: |
---|
1297 | if (e.GetModifiers() == 0) { |
---|
1298 | m_View->InvalidateAllLists(); |
---|
1299 | m_View->ForceRefresh(); |
---|
1300 | } |
---|
1301 | break; |
---|
1302 | case WXK_F6: |
---|
1303 | if (e.GetModifiers() == 0) |
---|
1304 | m_View->ToggleRenderStats(); |
---|
1305 | break; |
---|
1306 | default: |
---|
1307 | e.Skip(); |
---|
1308 | } |
---|
1309 | |
---|
1310 | //if (refresh) m_View->ForceRefresh(); |
---|
1311 | } |
---|
1312 | |
---|
1313 | void GUIControl::OnViewFullScreenUpdate(wxUpdateUIEvent& cmd) |
---|
1314 | { |
---|
1315 | cmd.Check(m_View->IsFullScreen()); |
---|
1316 | } |
---|
1317 | |
---|
1318 | void GUIControl::OnViewFullScreen() |
---|
1319 | { |
---|
1320 | m_View->FullScreenMode(); |
---|
1321 | } |
---|
1322 | |
---|
1323 | void GUIControl::OnViewBoundingBoxUpdate(wxUpdateUIEvent& cmd) |
---|
1324 | { |
---|
1325 | cmd.Enable(m_View->HasData()); |
---|
1326 | cmd.Check(m_View->DisplayingBoundingBox()); |
---|
1327 | } |
---|
1328 | |
---|
1329 | void GUIControl::OnViewBoundingBox() |
---|
1330 | { |
---|
1331 | m_View->ToggleBoundingBox(); |
---|
1332 | } |
---|
1333 | |
---|
1334 | void GUIControl::OnViewTerrainUpdate(wxUpdateUIEvent& cmd) |
---|
1335 | { |
---|
1336 | cmd.Enable(m_View->HasTerrain()); |
---|
1337 | cmd.Check(m_View->DisplayingTerrain()); |
---|
1338 | } |
---|
1339 | |
---|
1340 | void GUIControl::OnViewTerrain() |
---|
1341 | { |
---|
1342 | m_View->ToggleTerrain(); |
---|
1343 | } |
---|