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 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->SetCursor(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->SetCursor(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->SetCursor(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->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
123 | } else { |
---|
124 | m_ScaleRotateLock = lock_SCALE; |
---|
125 | // m_View->SetCursor(GfxCore::CURSOR_ZOOM); |
---|
126 | } |
---|
127 | break; |
---|
128 | case lock_SCALE: |
---|
129 | if (dx2 >= 8 * dy2) { |
---|
130 | m_ScaleRotateLock = lock_ROTATE; |
---|
131 | // m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
132 | } |
---|
133 | break; |
---|
134 | case lock_ROTATE: |
---|
135 | if (dy2 >= 8 * dx2) { |
---|
136 | m_ScaleRotateLock = lock_SCALE; |
---|
137 | // m_View->SetCursor(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->SetCursor(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->SetCursor(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->SetCursor(GfxCore::CURSOR_POINTING_HAND); |
---|
220 | } else { |
---|
221 | m_View->SetCursor(GfxCore::CURSOR_DEFAULT); |
---|
222 | } |
---|
223 | } |
---|
224 | |
---|
225 | void GUIControl::HandleNonDrag(const wxPoint & point) { |
---|
226 | if (m_View->CheckHitTestGrid(point, false)) { |
---|
227 | m_View->SetCursor(GfxCore::CURSOR_POINTING_HAND); |
---|
228 | } else if (m_View->PointWithinScaleBar(point)) { |
---|
229 | m_View->SetCursor(GfxCore::CURSOR_HORIZONTAL_RESIZE); |
---|
230 | } else if (m_View->PointWithinCompass(point)) { |
---|
231 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
232 | } else if (m_View->PointWithinClino(point)) { |
---|
233 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
---|
234 | } else { |
---|
235 | RestoreCursor(); |
---|
236 | } |
---|
237 | } |
---|
238 | |
---|
239 | // |
---|
240 | // Mouse event handling methods |
---|
241 | // |
---|
242 | |
---|
243 | void GUIControl::OnMouseMove(wxMouseEvent& event) |
---|
244 | { |
---|
245 | // Mouse motion event handler. |
---|
246 | if (!m_View->HasData()) return; |
---|
247 | |
---|
248 | // Ignore moves which don't change the position. |
---|
249 | if (event.GetPosition() == m_DragStart) { |
---|
250 | return; |
---|
251 | } |
---|
252 | |
---|
253 | static long timestamp = LONG_MIN; |
---|
254 | if (dragging != NO_DRAG && m_ScaleRotateLock != lock_NONE && |
---|
255 | timestamp != LONG_MIN) { |
---|
256 | // If no motion for a second, reset the direction lock. |
---|
257 | if (event.GetTimestamp() - timestamp >= 1000) { |
---|
258 | m_ScaleRotateLock = lock_NONE; |
---|
259 | m_DragRealStart = m_DragStart; |
---|
260 | RestoreCursor(); |
---|
261 | } |
---|
262 | } |
---|
263 | timestamp = event.GetTimestamp(); |
---|
264 | |
---|
265 | wxPoint point(event.GetPosition()); |
---|
266 | |
---|
267 | // Check hit-test grid (only if no buttons are pressed). |
---|
268 | if (!event.LeftIsDown() && !event.MiddleIsDown() && !event.RightIsDown()) { |
---|
269 | HandleNonDrag(point); |
---|
270 | } |
---|
271 | |
---|
272 | // Update coordinate display if in plan view, |
---|
273 | // or altitude if in elevation view. |
---|
274 | m_View->SetCoords(point); |
---|
275 | |
---|
276 | switch (dragging) { |
---|
277 | case LEFT_DRAG: |
---|
278 | switch (m_LastDrag) { |
---|
279 | case drag_COMPASS: |
---|
280 | // Drag in heading indicator. |
---|
281 | m_View->SetCompassFromPoint(point); |
---|
282 | break; |
---|
283 | case drag_ELEV: |
---|
284 | // Drag in clinometer. |
---|
285 | m_View->SetClinoFromPoint(point); |
---|
286 | break; |
---|
287 | case drag_SCALE: |
---|
288 | m_View->SetScaleBarFromOffset(point.x - m_DragLast.x); |
---|
289 | break; |
---|
290 | case drag_MAIN: |
---|
291 | if (event.ControlDown()) { |
---|
292 | HandleTiltRotate(point); |
---|
293 | } else { |
---|
294 | HandleScaleRotate(point); |
---|
295 | } |
---|
296 | break; |
---|
297 | case drag_NONE: |
---|
298 | // Shouldn't happen?! FIXME: assert or something. |
---|
299 | break; |
---|
300 | } |
---|
301 | break; |
---|
302 | case MIDDLE_DRAG: |
---|
303 | HandleTilt(point); |
---|
304 | break; |
---|
305 | case RIGHT_DRAG: |
---|
306 | HandleTranslate(point); |
---|
307 | break; |
---|
308 | case NO_DRAG: |
---|
309 | break; |
---|
310 | } |
---|
311 | |
---|
312 | m_DragLast = point; |
---|
313 | } |
---|
314 | |
---|
315 | void GUIControl::OnLButtonDown(wxMouseEvent& event) |
---|
316 | { |
---|
317 | if (m_View->HasData()) { |
---|
318 | m_DragStart = m_DragRealStart = event.GetPosition(); |
---|
319 | |
---|
320 | if (m_View->PointWithinCompass(m_DragStart)) { |
---|
321 | m_LastDrag = drag_COMPASS; |
---|
322 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
---|
323 | } else if (m_View->PointWithinClino(m_DragStart)) { |
---|
324 | m_LastDrag = drag_ELEV; |
---|
325 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
---|
326 | } else if (m_View->PointWithinScaleBar(m_DragStart)) { |
---|
327 | m_LastDrag = drag_SCALE; |
---|
328 | m_View->SetCursor(GfxCore::CURSOR_HORIZONTAL_RESIZE); |
---|
329 | } else { |
---|
330 | if (event.ControlDown() && !m_View->IsExtendedElevation()) { |
---|
331 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY); |
---|
332 | } else { |
---|
333 | m_View->SetCursor(GfxCore::CURSOR_ZOOM_ROTATE); |
---|
334 | } |
---|
335 | |
---|
336 | m_LastDrag = drag_MAIN; |
---|
337 | m_ScaleRotateLock = lock_NONE; |
---|
338 | } |
---|
339 | |
---|
340 | // We need to release and recapture for the cursor to update (noticed |
---|
341 | // with wxGTK). |
---|
342 | if (dragging != NO_DRAG) m_View->ReleaseMouse(); |
---|
343 | m_View->CaptureMouse(); |
---|
344 | |
---|
345 | dragging = LEFT_DRAG; |
---|
346 | } |
---|
347 | } |
---|
348 | |
---|
349 | void GUIControl::OnLButtonUp(wxMouseEvent& event) |
---|
350 | { |
---|
351 | if (m_View->HasData()) { |
---|
352 | if (dragging != LEFT_DRAG) |
---|
353 | return; |
---|
354 | |
---|
355 | if (event.GetPosition() == m_DragRealStart) { |
---|
356 | // Just a "click"... |
---|
357 | m_View->CheckHitTestGrid(m_DragStart, true); |
---|
358 | } |
---|
359 | |
---|
360 | if (event.MiddleIsDown()) { |
---|
361 | OnMButtonDown(event); |
---|
362 | return; |
---|
363 | } |
---|
364 | |
---|
365 | if (event.RightIsDown()) { |
---|
366 | OnRButtonDown(event); |
---|
367 | return; |
---|
368 | } |
---|
369 | |
---|
370 | m_View->ReleaseMouse(); |
---|
371 | |
---|
372 | m_LastDrag = drag_NONE; |
---|
373 | dragging = NO_DRAG; |
---|
374 | |
---|
375 | m_View->DragFinished(); |
---|
376 | |
---|
377 | if (event.GetPosition() == m_DragRealStart) { |
---|
378 | RestoreCursor(); |
---|
379 | } else { |
---|
380 | HandleNonDrag(event.GetPosition()); |
---|
381 | } |
---|
382 | } |
---|
383 | } |
---|
384 | |
---|
385 | void GUIControl::OnMButtonDown(wxMouseEvent& event) |
---|
386 | { |
---|
387 | if (m_View->HasData() && !m_View->IsExtendedElevation()) { |
---|
388 | m_DragStart = event.GetPosition(); |
---|
389 | |
---|
390 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
---|
391 | |
---|
392 | // We need to release and recapture for the cursor to update (noticed |
---|
393 | // with wxGTK). |
---|
394 | if (dragging != NO_DRAG) m_View->ReleaseMouse(); |
---|
395 | m_View->CaptureMouse(); |
---|
396 | dragging = MIDDLE_DRAG; |
---|
397 | } |
---|
398 | } |
---|
399 | |
---|
400 | void GUIControl::OnMButtonUp(wxMouseEvent& event) |
---|
401 | { |
---|
402 | if (m_View->HasData()) { |
---|
403 | if (dragging != MIDDLE_DRAG) |
---|
404 | return; |
---|
405 | |
---|
406 | if (event.LeftIsDown()) { |
---|
407 | OnLButtonDown(event); |
---|
408 | return; |
---|
409 | } |
---|
410 | |
---|
411 | if (event.RightIsDown()) { |
---|
412 | OnRButtonDown(event); |
---|
413 | return; |
---|
414 | } |
---|
415 | |
---|
416 | dragging = NO_DRAG; |
---|
417 | m_View->ReleaseMouse(); |
---|
418 | m_View->DragFinished(); |
---|
419 | |
---|
420 | RestoreCursor(); |
---|
421 | } |
---|
422 | } |
---|
423 | |
---|
424 | void GUIControl::OnRButtonDown(wxMouseEvent& event) |
---|
425 | { |
---|
426 | if (m_View->HasData()) { |
---|
427 | if (m_View->HandleRClick(event.GetPosition())) |
---|
428 | return; |
---|
429 | |
---|
430 | m_DragStart = event.GetPosition(); |
---|
431 | |
---|
432 | m_View->SetCursor(GfxCore::CURSOR_DRAGGING_HAND); |
---|
433 | |
---|
434 | // We need to release and recapture for the cursor to update (noticed |
---|
435 | // with wxGTK). |
---|
436 | if (dragging != NO_DRAG) m_View->ReleaseMouse(); |
---|
437 | m_View->CaptureMouse(); |
---|
438 | dragging = RIGHT_DRAG; |
---|
439 | } |
---|
440 | } |
---|
441 | |
---|
442 | void GUIControl::OnRButtonUp(wxMouseEvent& event) |
---|
443 | { |
---|
444 | if (dragging != RIGHT_DRAG) |
---|
445 | return; |
---|
446 | |
---|
447 | if (event.LeftIsDown()) { |
---|
448 | OnLButtonDown(event); |
---|
449 | return; |
---|
450 | } |
---|
451 | |
---|
452 | if (event.MiddleIsDown()) { |
---|
453 | OnMButtonDown(event); |
---|
454 | return; |
---|
455 | } |
---|
456 | |
---|
457 | m_LastDrag = drag_NONE; |
---|
458 | m_View->ReleaseMouse(); |
---|
459 | |
---|
460 | dragging = NO_DRAG; |
---|
461 | |
---|
462 | RestoreCursor(); |
---|
463 | |
---|
464 | m_View->DragFinished(); |
---|
465 | } |
---|
466 | |
---|
467 | void GUIControl::OnMouseWheel(wxMouseEvent& event) { |
---|
468 | int dy = event.GetWheelRotation(); |
---|
469 | if (m_View->GetPerspective()) { |
---|
470 | m_View->MoveViewer(-dy, 0, 0); |
---|
471 | } else { |
---|
472 | m_View->SetScale(m_View->GetScale() * pow(1.06, -0.04 * dy)); |
---|
473 | m_View->ForceRefresh(); |
---|
474 | } |
---|
475 | } |
---|
476 | |
---|
477 | void GUIControl::OnDisplayOverlappingNames() |
---|
478 | { |
---|
479 | m_View->ToggleOverlappingNames(); |
---|
480 | } |
---|
481 | |
---|
482 | void GUIControl::OnDisplayOverlappingNamesUpdate(wxUpdateUIEvent& cmd) |
---|
483 | { |
---|
484 | cmd.Enable(m_View->HasData() && m_View->ShowingStationNames()); |
---|
485 | cmd.Check(m_View->ShowingOverlappingNames()); |
---|
486 | } |
---|
487 | |
---|
488 | void GUIControl::OnColourByDepth() |
---|
489 | { |
---|
490 | if (m_View->ColouringBy() == COLOUR_BY_DEPTH) { |
---|
491 | m_View->SetColourBy(COLOUR_BY_NONE); |
---|
492 | } else { |
---|
493 | m_View->SetColourBy(COLOUR_BY_DEPTH); |
---|
494 | } |
---|
495 | } |
---|
496 | |
---|
497 | void GUIControl::OnColourByDate() |
---|
498 | { |
---|
499 | if (m_View->ColouringBy() == COLOUR_BY_DATE) { |
---|
500 | m_View->SetColourBy(COLOUR_BY_NONE); |
---|
501 | } else { |
---|
502 | m_View->SetColourBy(COLOUR_BY_DATE); |
---|
503 | } |
---|
504 | } |
---|
505 | |
---|
506 | void GUIControl::OnColourByError() |
---|
507 | { |
---|
508 | if (m_View->ColouringBy() == COLOUR_BY_ERROR) { |
---|
509 | m_View->SetColourBy(COLOUR_BY_NONE); |
---|
510 | } else { |
---|
511 | m_View->SetColourBy(COLOUR_BY_ERROR); |
---|
512 | } |
---|
513 | } |
---|
514 | |
---|
515 | void GUIControl::OnColourByDepthUpdate(wxUpdateUIEvent& cmd) |
---|
516 | { |
---|
517 | cmd.Enable(m_View->HasData()); |
---|
518 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_DEPTH); |
---|
519 | } |
---|
520 | |
---|
521 | void GUIControl::OnColourByDateUpdate(wxUpdateUIEvent& cmd) |
---|
522 | { |
---|
523 | cmd.Enable(m_View->HasData()); |
---|
524 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_DATE); |
---|
525 | } |
---|
526 | |
---|
527 | void GUIControl::OnColourByErrorUpdate(wxUpdateUIEvent& cmd) |
---|
528 | { |
---|
529 | cmd.Enable(m_View->HasData()); |
---|
530 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_ERROR); |
---|
531 | } |
---|
532 | |
---|
533 | void GUIControl::OnShowCrosses() |
---|
534 | { |
---|
535 | m_View->ToggleCrosses(); |
---|
536 | } |
---|
537 | |
---|
538 | void GUIControl::OnShowCrossesUpdate(wxUpdateUIEvent& cmd) |
---|
539 | { |
---|
540 | cmd.Enable(m_View->HasData()); |
---|
541 | cmd.Check(m_View->ShowingCrosses()); |
---|
542 | } |
---|
543 | |
---|
544 | void GUIControl::OnShowStationNames() |
---|
545 | { |
---|
546 | m_View->ToggleStationNames(); |
---|
547 | } |
---|
548 | |
---|
549 | void GUIControl::OnShowStationNamesUpdate(wxUpdateUIEvent& cmd) |
---|
550 | { |
---|
551 | cmd.Enable(m_View->HasData()); |
---|
552 | cmd.Check(m_View->ShowingStationNames()); |
---|
553 | } |
---|
554 | |
---|
555 | void GUIControl::OnShowSurveyLegs() |
---|
556 | { |
---|
557 | m_View->ToggleUndergroundLegs(); |
---|
558 | } |
---|
559 | |
---|
560 | void GUIControl::OnShowSurveyLegsUpdate(wxUpdateUIEvent& cmd) |
---|
561 | { |
---|
562 | cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs()); |
---|
563 | cmd.Check(m_View->ShowingUndergroundLegs()); |
---|
564 | } |
---|
565 | |
---|
566 | void GUIControl::OnHideSplays() |
---|
567 | { |
---|
568 | m_View->SetSplaysMode(SPLAYS_HIDE); |
---|
569 | } |
---|
570 | |
---|
571 | void GUIControl::OnShowSplaysNormal() |
---|
572 | { |
---|
573 | m_View->SetSplaysMode(SPLAYS_SHOW_NORMAL); |
---|
574 | } |
---|
575 | |
---|
576 | void GUIControl::OnShowSplaysFaded() |
---|
577 | { |
---|
578 | m_View->SetSplaysMode(SPLAYS_SHOW_FADED); |
---|
579 | } |
---|
580 | |
---|
581 | void GUIControl::OnSplaysUpdate(wxUpdateUIEvent& cmd) |
---|
582 | { |
---|
583 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
---|
584 | } |
---|
585 | |
---|
586 | void GUIControl::OnHideSplaysUpdate(wxUpdateUIEvent& cmd) |
---|
587 | { |
---|
588 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
---|
589 | cmd.Check(m_View->ShowingSplaysMode() == SPLAYS_HIDE); |
---|
590 | } |
---|
591 | |
---|
592 | void GUIControl::OnShowSplaysNormalUpdate(wxUpdateUIEvent& cmd) |
---|
593 | { |
---|
594 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
---|
595 | cmd.Check(m_View->ShowingSplaysMode() == SPLAYS_SHOW_NORMAL); |
---|
596 | } |
---|
597 | |
---|
598 | void GUIControl::OnShowSplaysFadedUpdate(wxUpdateUIEvent& cmd) |
---|
599 | { |
---|
600 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
---|
601 | cmd.Check(m_View->ShowingSplaysMode() == SPLAYS_SHOW_FADED); |
---|
602 | } |
---|
603 | |
---|
604 | void GUIControl::OnMoveEast() |
---|
605 | { |
---|
606 | m_View->TurnCaveTo(90.0); |
---|
607 | m_View->ForceRefresh(); |
---|
608 | } |
---|
609 | |
---|
610 | void GUIControl::OnMoveEastUpdate(wxUpdateUIEvent& cmd) |
---|
611 | { |
---|
612 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && m_View->GetCompassValue() != 90.0); |
---|
613 | } |
---|
614 | |
---|
615 | void GUIControl::OnMoveNorth() |
---|
616 | { |
---|
617 | m_View->TurnCaveTo(0.0); |
---|
618 | m_View->ForceRefresh(); |
---|
619 | } |
---|
620 | |
---|
621 | void GUIControl::OnMoveNorthUpdate(wxUpdateUIEvent& cmd) |
---|
622 | { |
---|
623 | cmd.Enable(m_View->HasData() && m_View->GetCompassValue() != 0.0); |
---|
624 | } |
---|
625 | |
---|
626 | void GUIControl::OnMoveSouth() |
---|
627 | { |
---|
628 | m_View->TurnCaveTo(180.0); |
---|
629 | m_View->ForceRefresh(); |
---|
630 | } |
---|
631 | |
---|
632 | void GUIControl::OnMoveSouthUpdate(wxUpdateUIEvent& cmd) |
---|
633 | { |
---|
634 | cmd.Enable(m_View->HasData() && m_View->GetCompassValue() != 180.0); |
---|
635 | } |
---|
636 | |
---|
637 | void GUIControl::OnMoveWest() |
---|
638 | { |
---|
639 | m_View->TurnCaveTo(270.0); |
---|
640 | m_View->ForceRefresh(); |
---|
641 | } |
---|
642 | |
---|
643 | void GUIControl::OnMoveWestUpdate(wxUpdateUIEvent& cmd) |
---|
644 | { |
---|
645 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && m_View->GetCompassValue() != 270.0); |
---|
646 | } |
---|
647 | |
---|
648 | void GUIControl::OnToggleRotation() |
---|
649 | { |
---|
650 | m_View->ToggleRotation(); |
---|
651 | } |
---|
652 | |
---|
653 | void GUIControl::OnToggleRotationUpdate(wxUpdateUIEvent& cmd) |
---|
654 | { |
---|
655 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
656 | cmd.Check(m_View->HasData() && m_View->IsRotating()); |
---|
657 | } |
---|
658 | |
---|
659 | void GUIControl::OnReverseControls() |
---|
660 | { |
---|
661 | m_ReverseControls = !m_ReverseControls; |
---|
662 | } |
---|
663 | |
---|
664 | void GUIControl::OnReverseControlsUpdate(wxUpdateUIEvent& cmd) |
---|
665 | { |
---|
666 | cmd.Enable(m_View->HasData()); |
---|
667 | cmd.Check(m_ReverseControls); |
---|
668 | } |
---|
669 | |
---|
670 | void GUIControl::OnReverseDirectionOfRotation() |
---|
671 | { |
---|
672 | m_View->ReverseRotation(); |
---|
673 | } |
---|
674 | |
---|
675 | void GUIControl::OnReverseDirectionOfRotationUpdate(wxUpdateUIEvent& cmd) |
---|
676 | { |
---|
677 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
678 | } |
---|
679 | |
---|
680 | void GUIControl::OnSlowDown(bool accel) |
---|
681 | { |
---|
682 | m_View->RotateSlower(accel); |
---|
683 | } |
---|
684 | |
---|
685 | void GUIControl::OnSlowDownUpdate(wxUpdateUIEvent& cmd) |
---|
686 | { |
---|
687 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
688 | } |
---|
689 | |
---|
690 | void GUIControl::OnSpeedUp(bool accel) |
---|
691 | { |
---|
692 | m_View->RotateFaster(accel); |
---|
693 | } |
---|
694 | |
---|
695 | void GUIControl::OnSpeedUpUpdate(wxUpdateUIEvent& cmd) |
---|
696 | { |
---|
697 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
698 | } |
---|
699 | |
---|
700 | void GUIControl::OnStepOnceAnticlockwise(bool accel) |
---|
701 | { |
---|
702 | if (m_View->GetPerspective()) { |
---|
703 | m_View->TurnCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
---|
704 | } else { |
---|
705 | m_View->TurnCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
---|
706 | } |
---|
707 | m_View->ForceRefresh(); |
---|
708 | } |
---|
709 | |
---|
710 | void GUIControl::OnStepOnceAnticlockwiseUpdate(wxUpdateUIEvent& cmd) |
---|
711 | { |
---|
712 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->IsRotating()); |
---|
713 | } |
---|
714 | |
---|
715 | void GUIControl::OnStepOnceClockwise(bool accel) |
---|
716 | { |
---|
717 | if (m_View->GetPerspective()) { |
---|
718 | m_View->TurnCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
---|
719 | } else { |
---|
720 | m_View->TurnCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
---|
721 | } |
---|
722 | m_View->ForceRefresh(); |
---|
723 | } |
---|
724 | |
---|
725 | void GUIControl::OnStepOnceClockwiseUpdate(wxUpdateUIEvent& cmd) |
---|
726 | { |
---|
727 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->IsRotating()); |
---|
728 | } |
---|
729 | |
---|
730 | void GUIControl::OnDefaults() |
---|
731 | { |
---|
732 | m_View->Defaults(); |
---|
733 | } |
---|
734 | |
---|
735 | void GUIControl::OnDefaultsUpdate(wxUpdateUIEvent& cmd) |
---|
736 | { |
---|
737 | cmd.Enable(m_View->HasData()); |
---|
738 | } |
---|
739 | |
---|
740 | void GUIControl::OnElevation() |
---|
741 | { |
---|
742 | // Switch to elevation view. |
---|
743 | |
---|
744 | m_View->SwitchToElevation(); |
---|
745 | } |
---|
746 | |
---|
747 | void GUIControl::OnElevationUpdate(wxUpdateUIEvent& cmd) |
---|
748 | { |
---|
749 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingElevation()); |
---|
750 | } |
---|
751 | |
---|
752 | void GUIControl::OnHigherViewpoint(bool accel) |
---|
753 | { |
---|
754 | // Raise the viewpoint. |
---|
755 | if (m_View->GetPerspective()) { |
---|
756 | m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
---|
757 | } else { |
---|
758 | m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
---|
759 | } |
---|
760 | m_View->ForceRefresh(); |
---|
761 | } |
---|
762 | |
---|
763 | void GUIControl::OnHigherViewpointUpdate(wxUpdateUIEvent& cmd) |
---|
764 | { |
---|
765 | cmd.Enable(m_View->HasData() && m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()); |
---|
766 | } |
---|
767 | |
---|
768 | void GUIControl::OnLowerViewpoint(bool accel) |
---|
769 | { |
---|
770 | // Lower the viewpoint. |
---|
771 | if (m_View->GetPerspective()) { |
---|
772 | m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
---|
773 | } else { |
---|
774 | m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
---|
775 | } |
---|
776 | m_View->ForceRefresh(); |
---|
777 | } |
---|
778 | |
---|
779 | void GUIControl::OnLowerViewpointUpdate(wxUpdateUIEvent& cmd) |
---|
780 | { |
---|
781 | cmd.Enable(m_View->HasData() && m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()); |
---|
782 | } |
---|
783 | |
---|
784 | void GUIControl::OnPlan() |
---|
785 | { |
---|
786 | // Switch to plan view. |
---|
787 | m_View->SwitchToPlan(); |
---|
788 | } |
---|
789 | |
---|
790 | void GUIControl::OnPlanUpdate(wxUpdateUIEvent& cmd) |
---|
791 | { |
---|
792 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingPlan()); |
---|
793 | } |
---|
794 | |
---|
795 | void GUIControl::OnShiftDisplayDown(bool accel) |
---|
796 | { |
---|
797 | if (m_View->GetPerspective()) |
---|
798 | m_View->MoveViewer(0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0); |
---|
799 | else |
---|
800 | m_View->TranslateCave(0, accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT); |
---|
801 | } |
---|
802 | |
---|
803 | void GUIControl::OnShiftDisplayDownUpdate(wxUpdateUIEvent& cmd) |
---|
804 | { |
---|
805 | cmd.Enable(m_View->HasData()); |
---|
806 | } |
---|
807 | |
---|
808 | void GUIControl::OnShiftDisplayLeft(bool accel) |
---|
809 | { |
---|
810 | if (m_View->GetPerspective()) |
---|
811 | m_View->MoveViewer(0, 0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT); |
---|
812 | else |
---|
813 | m_View->TranslateCave(accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT, 0); |
---|
814 | } |
---|
815 | |
---|
816 | void GUIControl::OnShiftDisplayLeftUpdate(wxUpdateUIEvent& cmd) |
---|
817 | { |
---|
818 | cmd.Enable(m_View->HasData()); |
---|
819 | } |
---|
820 | |
---|
821 | void GUIControl::OnShiftDisplayRight(bool accel) |
---|
822 | { |
---|
823 | if (m_View->GetPerspective()) |
---|
824 | m_View->MoveViewer(0, 0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT); |
---|
825 | else |
---|
826 | m_View->TranslateCave(accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT, 0); |
---|
827 | } |
---|
828 | |
---|
829 | void GUIControl::OnShiftDisplayRightUpdate(wxUpdateUIEvent& cmd) |
---|
830 | { |
---|
831 | cmd.Enable(m_View->HasData()); |
---|
832 | } |
---|
833 | |
---|
834 | void GUIControl::OnShiftDisplayUp(bool accel) |
---|
835 | { |
---|
836 | if (m_View->GetPerspective()) |
---|
837 | m_View->MoveViewer(0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0); |
---|
838 | else |
---|
839 | m_View->TranslateCave(0, accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT); |
---|
840 | } |
---|
841 | |
---|
842 | void GUIControl::OnShiftDisplayUpUpdate(wxUpdateUIEvent& cmd) |
---|
843 | { |
---|
844 | cmd.Enable(m_View->HasData()); |
---|
845 | } |
---|
846 | |
---|
847 | void GUIControl::OnZoomIn(bool accel) |
---|
848 | { |
---|
849 | // Increase the scale. |
---|
850 | |
---|
851 | if (m_View->GetPerspective()) { |
---|
852 | m_View->MoveViewer(accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0, 0); |
---|
853 | } else { |
---|
854 | m_View->SetScale(m_View->GetScale() * (accel ? 1.1236 : 1.06)); |
---|
855 | m_View->ForceRefresh(); |
---|
856 | } |
---|
857 | } |
---|
858 | |
---|
859 | void GUIControl::OnZoomInUpdate(wxUpdateUIEvent& cmd) |
---|
860 | { |
---|
861 | cmd.Enable(m_View->HasData()); |
---|
862 | } |
---|
863 | |
---|
864 | void GUIControl::OnZoomOut(bool accel) |
---|
865 | { |
---|
866 | // Decrease the scale. |
---|
867 | |
---|
868 | if (m_View->GetPerspective()) { |
---|
869 | m_View->MoveViewer(accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0, 0); |
---|
870 | } else { |
---|
871 | m_View->SetScale(m_View->GetScale() / (accel ? 1.1236 : 1.06)); |
---|
872 | m_View->ForceRefresh(); |
---|
873 | } |
---|
874 | } |
---|
875 | |
---|
876 | void GUIControl::OnZoomOutUpdate(wxUpdateUIEvent& cmd) |
---|
877 | { |
---|
878 | cmd.Enable(m_View->HasData()); |
---|
879 | } |
---|
880 | |
---|
881 | void GUIControl::OnToggleScalebar() |
---|
882 | { |
---|
883 | m_View->ToggleScaleBar(); |
---|
884 | } |
---|
885 | |
---|
886 | void GUIControl::OnToggleScalebarUpdate(wxUpdateUIEvent& cmd) |
---|
887 | { |
---|
888 | cmd.Enable(m_View->HasData()); |
---|
889 | cmd.Check(m_View->ShowingScaleBar()); |
---|
890 | } |
---|
891 | |
---|
892 | void GUIControl::OnToggleColourKey() |
---|
893 | { |
---|
894 | m_View->ToggleColourKey(); |
---|
895 | } |
---|
896 | |
---|
897 | void GUIControl::OnToggleColourKeyUpdate(wxUpdateUIEvent& cmd) |
---|
898 | { |
---|
899 | cmd.Enable(m_View->HasData() && m_View->ColouringBy() != COLOUR_BY_NONE); |
---|
900 | cmd.Check(m_View->ShowingColourKey()); |
---|
901 | } |
---|
902 | |
---|
903 | void GUIControl::OnViewCompass() |
---|
904 | { |
---|
905 | m_View->ToggleCompass(); |
---|
906 | } |
---|
907 | |
---|
908 | void GUIControl::OnViewCompassUpdate(wxUpdateUIEvent& cmd) |
---|
909 | { |
---|
910 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
911 | cmd.Check(m_View->ShowingCompass()); |
---|
912 | } |
---|
913 | |
---|
914 | void GUIControl::OnViewClino() |
---|
915 | { |
---|
916 | m_View->ToggleClino(); |
---|
917 | } |
---|
918 | |
---|
919 | void GUIControl::OnViewClinoUpdate(wxUpdateUIEvent& cmd) |
---|
920 | { |
---|
921 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
922 | cmd.Check(m_View->ShowingClino()); |
---|
923 | } |
---|
924 | |
---|
925 | void GUIControl::OnShowSurface() |
---|
926 | { |
---|
927 | m_View->ToggleSurfaceLegs(); |
---|
928 | } |
---|
929 | |
---|
930 | void GUIControl::OnShowSurfaceUpdate(wxUpdateUIEvent& cmd) |
---|
931 | { |
---|
932 | cmd.Enable(m_View->HasData() && m_View->HasSurfaceLegs()); |
---|
933 | cmd.Check(m_View->ShowingSurfaceLegs()); |
---|
934 | } |
---|
935 | |
---|
936 | void GUIControl::OnShowEntrances() |
---|
937 | { |
---|
938 | m_View->ToggleEntrances(); |
---|
939 | } |
---|
940 | |
---|
941 | void GUIControl::OnShowEntrancesUpdate(wxUpdateUIEvent& cmd) |
---|
942 | { |
---|
943 | cmd.Enable(m_View->HasData() && (m_View->GetNumEntrances() > 0)); |
---|
944 | cmd.Check(m_View->ShowingEntrances()); |
---|
945 | } |
---|
946 | |
---|
947 | void GUIControl::OnShowFixedPts() |
---|
948 | { |
---|
949 | m_View->ToggleFixedPts(); |
---|
950 | } |
---|
951 | |
---|
952 | void GUIControl::OnShowFixedPtsUpdate(wxUpdateUIEvent& cmd) |
---|
953 | { |
---|
954 | cmd.Enable(m_View->HasData() && (m_View->GetNumFixedPts() > 0)); |
---|
955 | cmd.Check(m_View->ShowingFixedPts()); |
---|
956 | } |
---|
957 | |
---|
958 | void GUIControl::OnShowExportedPts() |
---|
959 | { |
---|
960 | m_View->ToggleExportedPts(); |
---|
961 | } |
---|
962 | |
---|
963 | void GUIControl::OnShowExportedPtsUpdate(wxUpdateUIEvent& cmd) |
---|
964 | { |
---|
965 | cmd.Enable(m_View->HasData() && (m_View->GetNumExportedPts() > 0)); |
---|
966 | cmd.Check(m_View->ShowingExportedPts()); |
---|
967 | } |
---|
968 | |
---|
969 | void GUIControl::OnViewGrid() |
---|
970 | { |
---|
971 | m_View->ToggleGrid(); |
---|
972 | } |
---|
973 | |
---|
974 | void GUIControl::OnViewGridUpdate(wxUpdateUIEvent& cmd) |
---|
975 | { |
---|
976 | cmd.Enable(m_View->HasData()); |
---|
977 | cmd.Check(m_View->ShowingGrid()); |
---|
978 | } |
---|
979 | |
---|
980 | void GUIControl::OnIndicatorsUpdate(wxUpdateUIEvent& cmd) |
---|
981 | { |
---|
982 | cmd.Enable(m_View->HasData()); |
---|
983 | } |
---|
984 | |
---|
985 | void GUIControl::OnViewPerspective() |
---|
986 | { |
---|
987 | m_View->TogglePerspective(); |
---|
988 | // Force update of coordinate display. |
---|
989 | if (m_View->GetPerspective()) { |
---|
990 | m_View->MoveViewer(0, 0, 0); |
---|
991 | } else { |
---|
992 | m_View->ClearCoords(); |
---|
993 | } |
---|
994 | } |
---|
995 | |
---|
996 | void GUIControl::OnViewPerspectiveUpdate(wxUpdateUIEvent& cmd) |
---|
997 | { |
---|
998 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
---|
999 | cmd.Check(m_View->GetPerspective()); |
---|
1000 | } |
---|
1001 | |
---|
1002 | void GUIControl::OnViewSmoothShading() |
---|
1003 | { |
---|
1004 | m_View->ToggleSmoothShading(); |
---|
1005 | } |
---|
1006 | |
---|
1007 | void GUIControl::OnViewSmoothShadingUpdate(wxUpdateUIEvent& cmd) |
---|
1008 | { |
---|
1009 | cmd.Enable(m_View->HasData()); |
---|
1010 | cmd.Check(m_View->GetSmoothShading()); |
---|
1011 | } |
---|
1012 | |
---|
1013 | void GUIControl::OnViewTextured() |
---|
1014 | { |
---|
1015 | m_View->ToggleTextured(); |
---|
1016 | } |
---|
1017 | |
---|
1018 | void GUIControl::OnViewTexturedUpdate(wxUpdateUIEvent& cmd) |
---|
1019 | { |
---|
1020 | cmd.Enable(m_View->HasData()); |
---|
1021 | cmd.Check(m_View->GetTextured()); |
---|
1022 | } |
---|
1023 | |
---|
1024 | void GUIControl::OnViewFog() |
---|
1025 | { |
---|
1026 | m_View->ToggleFog(); |
---|
1027 | } |
---|
1028 | |
---|
1029 | void GUIControl::OnViewFogUpdate(wxUpdateUIEvent& cmd) |
---|
1030 | { |
---|
1031 | cmd.Enable(m_View->HasData()); |
---|
1032 | cmd.Check(m_View->GetFog()); |
---|
1033 | } |
---|
1034 | |
---|
1035 | void GUIControl::OnViewSmoothLines() |
---|
1036 | { |
---|
1037 | m_View->ToggleAntiAlias(); |
---|
1038 | } |
---|
1039 | |
---|
1040 | void GUIControl::OnViewSmoothLinesUpdate(wxUpdateUIEvent& cmd) |
---|
1041 | { |
---|
1042 | cmd.Enable(m_View->HasData()); |
---|
1043 | cmd.Check(m_View->GetAntiAlias()); |
---|
1044 | } |
---|
1045 | |
---|
1046 | void GUIControl::OnToggleMetric() |
---|
1047 | { |
---|
1048 | m_View->ToggleMetric(); |
---|
1049 | |
---|
1050 | wxConfigBase::Get()->Write(wxT("metric"), m_View->GetMetric()); |
---|
1051 | wxConfigBase::Get()->Flush(); |
---|
1052 | } |
---|
1053 | |
---|
1054 | void GUIControl::OnToggleMetricUpdate(wxUpdateUIEvent& cmd) |
---|
1055 | { |
---|
1056 | cmd.Enable(m_View->HasData()); |
---|
1057 | cmd.Check(m_View->GetMetric()); |
---|
1058 | } |
---|
1059 | |
---|
1060 | void GUIControl::OnToggleDegrees() |
---|
1061 | { |
---|
1062 | m_View->ToggleDegrees(); |
---|
1063 | |
---|
1064 | wxConfigBase::Get()->Write(wxT("degrees"), m_View->GetDegrees()); |
---|
1065 | wxConfigBase::Get()->Flush(); |
---|
1066 | } |
---|
1067 | |
---|
1068 | void GUIControl::OnToggleDegreesUpdate(wxUpdateUIEvent& cmd) |
---|
1069 | { |
---|
1070 | cmd.Enable(m_View->HasData()); |
---|
1071 | cmd.Check(m_View->GetDegrees()); |
---|
1072 | } |
---|
1073 | |
---|
1074 | void GUIControl::OnTogglePercent() |
---|
1075 | { |
---|
1076 | m_View->TogglePercent(); |
---|
1077 | |
---|
1078 | wxConfigBase::Get()->Write(wxT("percent"), m_View->GetPercent()); |
---|
1079 | wxConfigBase::Get()->Flush(); |
---|
1080 | } |
---|
1081 | |
---|
1082 | void GUIControl::OnTogglePercentUpdate(wxUpdateUIEvent& cmd) |
---|
1083 | { |
---|
1084 | cmd.Enable(m_View->HasData()); |
---|
1085 | cmd.Check(m_View->GetPercent()); |
---|
1086 | } |
---|
1087 | |
---|
1088 | void GUIControl::OnToggleTubes() |
---|
1089 | { |
---|
1090 | m_View->ToggleTubes(); |
---|
1091 | } |
---|
1092 | |
---|
1093 | void GUIControl::OnToggleTubesUpdate(wxUpdateUIEvent& cmd) |
---|
1094 | { |
---|
1095 | cmd.Enable(m_View->HasData() && m_View->HasTubes()); |
---|
1096 | cmd.Check(m_View->GetTubes()); |
---|
1097 | } |
---|
1098 | |
---|
1099 | void GUIControl::OnCancelDistLine() |
---|
1100 | { |
---|
1101 | m_View->ClearTreeSelection(); |
---|
1102 | } |
---|
1103 | |
---|
1104 | void GUIControl::OnCancelDistLineUpdate(wxUpdateUIEvent& cmd) |
---|
1105 | { |
---|
1106 | cmd.Enable(m_View->ShowingMeasuringLine()); |
---|
1107 | } |
---|
1108 | |
---|
1109 | void GUIControl::OnKeyPress(wxKeyEvent &e) |
---|
1110 | { |
---|
1111 | if (!m_View->HasData()) { |
---|
1112 | e.Skip(); |
---|
1113 | return; |
---|
1114 | } |
---|
1115 | |
---|
1116 | // The changelog says this is meant to keep animation going while keys are |
---|
1117 | // pressed, but that happens anyway (on linux at least - perhaps it helps |
---|
1118 | // on windows?) FIXME : check! |
---|
1119 | //bool refresh = m_View->Animate(); |
---|
1120 | |
---|
1121 | switch (e.GetKeyCode()) { |
---|
1122 | case '/': case '?': |
---|
1123 | if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()) |
---|
1124 | OnLowerViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
---|
1125 | break; |
---|
1126 | case '\'': case '@': case '"': // both shifted forms - US and UK kbd |
---|
1127 | if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()) |
---|
1128 | OnHigherViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
---|
1129 | break; |
---|
1130 | case 'C': case 'c': |
---|
1131 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1132 | OnStepOnceAnticlockwise(e.GetModifiers() == wxMOD_SHIFT); |
---|
1133 | break; |
---|
1134 | case 'V': case 'v': |
---|
1135 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1136 | OnStepOnceClockwise(e.GetModifiers() == wxMOD_SHIFT); |
---|
1137 | break; |
---|
1138 | case ']': case '}': |
---|
1139 | OnZoomIn(e.GetModifiers() == wxMOD_SHIFT); |
---|
1140 | break; |
---|
1141 | case '[': case '{': |
---|
1142 | OnZoomOut(e.GetModifiers() == wxMOD_SHIFT); |
---|
1143 | break; |
---|
1144 | case 'N': case 'n': |
---|
1145 | OnMoveNorth(); |
---|
1146 | break; |
---|
1147 | case 'S': case 's': |
---|
1148 | OnMoveSouth(); |
---|
1149 | break; |
---|
1150 | case 'E': case 'e': |
---|
1151 | if (!m_View->IsExtendedElevation()) |
---|
1152 | OnMoveEast(); |
---|
1153 | break; |
---|
1154 | case 'W': case 'w': |
---|
1155 | if (!m_View->IsExtendedElevation()) |
---|
1156 | OnMoveWest(); |
---|
1157 | break; |
---|
1158 | case 'Z': case 'z': |
---|
1159 | if (!m_View->IsExtendedElevation()) |
---|
1160 | OnSpeedUp(e.GetModifiers() == wxMOD_SHIFT); |
---|
1161 | break; |
---|
1162 | case 'X': case 'x': |
---|
1163 | if (!m_View->IsExtendedElevation()) |
---|
1164 | OnSlowDown(e.GetModifiers() == wxMOD_SHIFT); |
---|
1165 | break; |
---|
1166 | case 'R': case 'r': |
---|
1167 | if (!m_View->IsExtendedElevation()) |
---|
1168 | OnReverseDirectionOfRotation(); |
---|
1169 | break; |
---|
1170 | case 'P': case 'p': |
---|
1171 | if (!m_View->IsExtendedElevation() && !m_View->ShowingPlan()) |
---|
1172 | OnPlan(); |
---|
1173 | break; |
---|
1174 | case 'L': case 'l': |
---|
1175 | if (!m_View->IsExtendedElevation() && !m_View->ShowingElevation()) |
---|
1176 | OnElevation(); |
---|
1177 | break; |
---|
1178 | case 'O': case 'o': |
---|
1179 | OnDisplayOverlappingNames(); |
---|
1180 | break; |
---|
1181 | case WXK_DELETE: |
---|
1182 | OnDefaults(); |
---|
1183 | break; |
---|
1184 | case WXK_RETURN: |
---|
1185 | // For compatibility with older versions. |
---|
1186 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1187 | m_View->StartRotation(); |
---|
1188 | break; |
---|
1189 | case WXK_SPACE: |
---|
1190 | if (!m_View->IsExtendedElevation()) |
---|
1191 | OnToggleRotation(); |
---|
1192 | break; |
---|
1193 | case WXK_LEFT: |
---|
1194 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
---|
1195 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1196 | OnStepOnceAnticlockwise(e.GetModifiers() == wxMOD_SHIFT); |
---|
1197 | } else { |
---|
1198 | OnShiftDisplayLeft(e.GetModifiers() == wxMOD_SHIFT); |
---|
1199 | } |
---|
1200 | break; |
---|
1201 | case WXK_RIGHT: |
---|
1202 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
---|
1203 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
---|
1204 | OnStepOnceClockwise(e.GetModifiers() == wxMOD_SHIFT); |
---|
1205 | } else { |
---|
1206 | OnShiftDisplayRight(e.GetModifiers() == wxMOD_SHIFT); |
---|
1207 | } |
---|
1208 | break; |
---|
1209 | case WXK_UP: |
---|
1210 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
---|
1211 | if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()) |
---|
1212 | OnHigherViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
---|
1213 | } else { |
---|
1214 | OnShiftDisplayUp(e.GetModifiers() == wxMOD_SHIFT); |
---|
1215 | } |
---|
1216 | break; |
---|
1217 | case WXK_DOWN: |
---|
1218 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
---|
1219 | if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()) |
---|
1220 | OnLowerViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
---|
1221 | } else { |
---|
1222 | OnShiftDisplayDown(e.GetModifiers() == wxMOD_SHIFT); |
---|
1223 | } |
---|
1224 | break; |
---|
1225 | case WXK_ESCAPE: |
---|
1226 | if (m_View->ShowingMeasuringLine()) { |
---|
1227 | OnCancelDistLine(); |
---|
1228 | } |
---|
1229 | break; |
---|
1230 | case WXK_F5: |
---|
1231 | m_View->InvalidateAllLists(); |
---|
1232 | m_View->ForceRefresh(); |
---|
1233 | break; |
---|
1234 | default: |
---|
1235 | e.Skip(); |
---|
1236 | } |
---|
1237 | |
---|
1238 | //if (refresh) m_View->ForceRefresh(); |
---|
1239 | } |
---|
1240 | |
---|
1241 | void GUIControl::OnViewFullScreenUpdate(wxUpdateUIEvent& cmd) |
---|
1242 | { |
---|
1243 | cmd.Check(m_View->IsFullScreen()); |
---|
1244 | } |
---|
1245 | |
---|
1246 | void GUIControl::OnViewFullScreen() |
---|
1247 | { |
---|
1248 | m_View->FullScreenMode(); |
---|
1249 | } |
---|
1250 | |
---|
1251 | void GUIControl::OnViewBoundingBoxUpdate(wxUpdateUIEvent& cmd) |
---|
1252 | { |
---|
1253 | cmd.Enable(m_View->HasData()); |
---|
1254 | cmd.Check(m_View->DisplayingBoundingBox()); |
---|
1255 | } |
---|
1256 | |
---|
1257 | void GUIControl::OnViewBoundingBox() |
---|
1258 | { |
---|
1259 | m_View->ToggleBoundingBox(); |
---|
1260 | } |
---|