4
// Handlers for events relating to the display of a survey.
6
// Copyright (C) 2000-2002,2005 Mark R. Shinwell
7
// Copyright (C) 2001,2003,2004,2005,2006 Olly Betts
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.
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.
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
28
#include "guicontrol.h"
30
#include <wx/confbase.h>
32
const int DISPLAY_SHIFT = 10;
33
const double FLYFREE_SHIFT = 0.2;
34
const double ROTATE_STEP = 2.0;
36
GUIControl::GUIControl()
40
m_ReverseControls = false;
41
m_LastDrag = drag_NONE;
44
GUIControl::~GUIControl()
49
void GUIControl::SetView(GfxCore* view)
54
bool GUIControl::MouseDown() const
56
return (dragging != NO_DRAG);
59
void GUIControl::HandleTilt(wxPoint point)
61
// Handle a mouse movement during tilt mode.
63
// wxGTK (at least) fails to update the cursor while dragging.
64
m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY);
66
int dy = point.y - m_DragStart.y;
68
if (m_ReverseControls != m_View->GetPerspective()) dy = -dy;
70
m_View->TiltCave(Double(-dy) * 0.36);
74
m_View->ForceRefresh();
77
void GUIControl::HandleTranslate(wxPoint point)
79
// Handle a mouse movement during translation mode.
81
// wxGTK (at least) fails to update the cursor while dragging.
82
m_View->SetCursor(GfxCore::CURSOR_DRAGGING_HAND);
84
int dx = point.x - m_DragStart.x;
85
int dy = point.y - m_DragStart.y;
87
if (m_ReverseControls) {
92
if (m_View->GetPerspective())
93
m_View->MoveViewer(0, -dy * .1, dx * .1);
95
m_View->TranslateCave(dx, dy);
100
void GUIControl::HandleScaleRotate(wxPoint point)
102
// Handle a mouse movement during scale/rotate mode.
104
// wxGTK (at least) fails to update the cursor while dragging.
105
m_View->SetCursor(GfxCore::CURSOR_ZOOM_ROTATE);
109
if (m_ScaleRotateLock == NONE) {
110
// Dragging to scale or rotate but we've not decided which yet.
111
dx = point.x - m_DragRealStart.x;
112
dy = point.y - m_DragRealStart.y;
115
dx = point.x - m_DragStart.x;
116
dy = point.y - m_DragStart.y;
121
if (dx2 + dy2 < threshold) return;
123
switch (m_ScaleRotateLock) {
126
m_ScaleRotateLock = ROTATE;
127
// m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY);
129
m_ScaleRotateLock = SCALE;
130
// m_View->SetCursor(GfxCore::CURSOR_ZOOM);
134
if (dx2 >= 8 * dy2) {
135
m_ScaleRotateLock = ROTATE;
136
// m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY);
140
if (dy2 >= 8 * dx2) {
141
m_ScaleRotateLock = SCALE;
142
// m_View->SetCursor(GfxCore::CURSOR_ZOOM);
147
if (m_ScaleRotateLock == ROTATE) {
153
if (m_ReverseControls) {
158
if (m_View->GetPerspective()) {
159
if (dy) m_View->MoveViewer(-dy * .1, 0, 0);
162
if (dy) m_View->SetScale(m_View->GetScale() * pow(1.06, 0.08 * dy));
163
// left/right => rotate.
164
if (dx) m_View->TurnCave(Double(dx) * -0.36);
165
if (dx || dy) m_View->ForceRefresh();
171
void GUIControl::HandleTiltRotate(wxPoint point)
173
// Handle a mouse movement during tilt/rotate mode.
174
if (m_View->IsExtendedElevation()) return;
176
// wxGTK (at least) fails to update the cursor while dragging.
177
m_View->SetCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY);
179
int dx = point.x - m_DragStart.x;
180
int dy = point.y - m_DragStart.y;
182
if (m_ReverseControls != m_View->GetPerspective()) {
187
// left/right => rotate, up/down => tilt.
188
// Make tilt less sensitive than rotate as that feels better.
189
m_View->TurnCave(Double(dx) * -0.36);
190
m_View->TiltCave(Double(dy) * -0.18);
192
m_View->ForceRefresh();
197
void GUIControl::HandleRotate(wxPoint point)
199
// Handle a mouse movement during rotate mode.
200
if (m_View->IsExtendedElevation()) return;
202
// wxGTK (at least) fails to update the cursor while dragging.
203
m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY);
205
int dx = point.x - m_DragStart.x;
206
int dy = point.y - m_DragStart.y;
208
if (m_ReverseControls != m_View->GetPerspective()) {
213
// left/right => rotate.
214
m_View->TurnCave(Double(dx) * -0.36);
216
m_View->ForceRefresh();
221
void GUIControl::RestoreCursor()
223
if (m_View->HereIsReal()) {
224
m_View->SetCursor(GfxCore::CURSOR_POINTING_HAND);
226
m_View->SetCursor(GfxCore::CURSOR_DEFAULT);
230
void GUIControl::HandleNonDrag(const wxPoint & point) {
231
if (m_View->CheckHitTestGrid(point, false)) {
232
m_View->SetCursor(GfxCore::CURSOR_POINTING_HAND);
233
} else if (m_View->PointWithinScaleBar(point)) {
234
m_View->SetCursor(GfxCore::CURSOR_HORIZONTAL_RESIZE);
235
} else if (m_View->PointWithinCompass(point)) {
236
m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY);
237
} else if (m_View->PointWithinClino(point)) {
238
m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY);
245
// Mouse event handling methods
248
void GUIControl::OnMouseMove(wxMouseEvent& event)
250
// Mouse motion event handler.
251
if (!m_View->HasData()) return;
253
// Ignore moves which don't change the position.
254
if (event.GetPosition() == m_DragStart) {
258
static long timestamp = LONG_MIN;
259
if (dragging != NO_DRAG && m_ScaleRotateLock != NONE && timestamp != LONG_MIN) {
260
// If no motion for a second, reset the direction lock.
261
if (event.GetTimestamp() - timestamp >= 1000) {
262
m_ScaleRotateLock = NONE;
263
m_DragRealStart = m_DragStart;
267
timestamp = event.GetTimestamp();
269
wxPoint point(event.GetPosition());
271
// Check hit-test grid (only if no buttons are pressed).
272
if (!event.LeftIsDown() && !event.MiddleIsDown() && !event.RightIsDown()) {
273
HandleNonDrag(point);
276
// Update coordinate display if in plan view,
277
// or altitude if in elevation view.
278
m_View->SetCoords(point);
282
switch (m_LastDrag) {
284
// Drag in heading indicator.
285
m_View->SetCompassFromPoint(point);
288
// Drag in clinometer.
289
m_View->SetClinoFromPoint(point);
292
m_View->SetScaleBarFromOffset(point.x - m_DragLast.x);
295
if (event.ControlDown()) {
296
HandleTiltRotate(point);
298
HandleScaleRotate(point);
302
// Shouldn't happen?! FIXME: assert or something.
310
HandleTranslate(point);
319
void GUIControl::OnLButtonDown(wxMouseEvent& event)
321
if (m_View->HasData()) {
322
dragging = LEFT_DRAG;
324
m_DragStart = m_DragRealStart = event.GetPosition();
326
if (m_View->PointWithinCompass(m_DragStart)) {
327
m_LastDrag = drag_COMPASS;
328
} else if (m_View->PointWithinClino(m_DragStart)) {
329
m_LastDrag = drag_ELEV;
330
} else if (m_View->PointWithinScaleBar(m_DragStart)) {
331
m_LastDrag = drag_SCALE;
333
if (event.ControlDown()) {
334
if (m_View->IsExtendedElevation()) {
338
m_View->SetCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY);
340
m_View->SetCursor(GfxCore::CURSOR_ZOOM_ROTATE);
343
m_LastDrag = drag_MAIN;
344
m_ScaleRotateLock = NONE;
347
m_View->CaptureMouse();
351
void GUIControl::OnLButtonUp(wxMouseEvent& event)
353
if (m_View->HasData()) {
354
if (event.GetPosition() == m_DragRealStart) {
356
m_View->CheckHitTestGrid(m_DragStart, true);
357
} else if (dragging == NO_DRAG) {
361
// m_View->RedrawIndicators();
362
m_View->ReleaseMouse();
364
m_LastDrag = drag_NONE;
367
m_View->DragFinished();
369
if (event.GetPosition() == m_DragRealStart) {
372
HandleNonDrag(event.GetPosition());
377
void GUIControl::OnMButtonDown(wxMouseEvent& event)
379
if (m_View->HasData() && !m_View->IsExtendedElevation()) {
380
dragging = MIDDLE_DRAG;
381
m_DragStart = event.GetPosition();
383
m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY);
385
m_View->CaptureMouse();
389
void GUIControl::OnMButtonUp(wxMouseEvent&)
391
if (m_View->HasData()) {
393
m_View->ReleaseMouse();
394
m_View->DragFinished();
400
void GUIControl::OnRButtonDown(wxMouseEvent& event)
402
if (m_View->HasData()) {
403
m_DragStart = event.GetPosition();
405
dragging = RIGHT_DRAG;
407
m_View->SetCursor(GfxCore::CURSOR_DRAGGING_HAND);
408
m_View->CaptureMouse();
412
void GUIControl::OnRButtonUp(wxMouseEvent&)
414
m_LastDrag = drag_NONE;
415
m_View->ReleaseMouse();
421
m_View->DragFinished();
424
void GUIControl::OnMouseWheel(wxMouseEvent& event) {
425
int dy = event.GetWheelRotation();
426
if (m_View->GetPerspective()) {
427
m_View->MoveViewer(-dy, 0, 0);
429
m_View->SetScale(m_View->GetScale() * pow(1.06, -0.04 * dy));
430
m_View->ForceRefresh();
434
void GUIControl::OnDisplayOverlappingNames()
436
m_View->ToggleOverlappingNames();
439
void GUIControl::OnDisplayOverlappingNamesUpdate(wxUpdateUIEvent& cmd)
441
cmd.Enable(m_View->HasData() && m_View->ShowingStationNames());
442
cmd.Check(m_View->ShowingOverlappingNames());
445
void GUIControl::OnColourByDepth()
447
if (m_View->ColouringBy() == COLOUR_BY_DEPTH) {
448
m_View->SetColourBy(COLOUR_BY_NONE);
450
m_View->SetColourBy(COLOUR_BY_DEPTH);
454
void GUIControl::OnColourByDate()
456
if (m_View->ColouringBy() == COLOUR_BY_DATE) {
457
m_View->SetColourBy(COLOUR_BY_NONE);
459
m_View->SetColourBy(COLOUR_BY_DATE);
463
void GUIControl::OnColourByError()
465
if (m_View->ColouringBy() == COLOUR_BY_ERROR) {
466
m_View->SetColourBy(COLOUR_BY_NONE);
468
m_View->SetColourBy(COLOUR_BY_ERROR);
472
void GUIControl::OnColourByDepthUpdate(wxUpdateUIEvent& cmd)
474
cmd.Enable(m_View->HasData() && !m_View->HasDepth());
475
cmd.Check(m_View->ColouringBy() == COLOUR_BY_DEPTH);
478
void GUIControl::OnColourByDateUpdate(wxUpdateUIEvent& cmd)
480
cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs() && m_View->HasRangeOfDates());
481
cmd.Check(m_View->ColouringBy() == COLOUR_BY_DATE);
484
void GUIControl::OnColourByErrorUpdate(wxUpdateUIEvent& cmd)
486
cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs() && m_View->HasErrorInformation());
487
cmd.Check(m_View->ColouringBy() == COLOUR_BY_ERROR);
490
void GUIControl::OnShowCrosses()
492
m_View->ToggleCrosses();
495
void GUIControl::OnShowCrossesUpdate(wxUpdateUIEvent& cmd)
497
cmd.Enable(m_View->HasData());
498
cmd.Check(m_View->ShowingCrosses());
501
void GUIControl::OnShowStationNames()
503
m_View->ToggleStationNames();
506
void GUIControl::OnShowStationNamesUpdate(wxUpdateUIEvent& cmd)
508
cmd.Enable(m_View->HasData());
509
cmd.Check(m_View->ShowingStationNames());
512
void GUIControl::OnShowSurveyLegs()
514
m_View->ToggleUndergroundLegs();
517
void GUIControl::OnShowSurveyLegsUpdate(wxUpdateUIEvent& cmd)
519
cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs());
520
cmd.Check(m_View->ShowingUndergroundLegs());
523
void GUIControl::OnMoveEast()
525
m_View->TurnCaveTo(90.0);
526
m_View->ForceRefresh();
529
void GUIControl::OnMoveEastUpdate(wxUpdateUIEvent& cmd)
531
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
534
void GUIControl::OnMoveNorth()
536
m_View->TurnCaveTo(0.0);
537
m_View->ForceRefresh();
540
void GUIControl::OnMoveNorthUpdate(wxUpdateUIEvent& cmd)
542
cmd.Enable(m_View->HasData());
545
void GUIControl::OnMoveSouth()
547
m_View->TurnCaveTo(180.0);
548
m_View->ForceRefresh();
551
void GUIControl::OnMoveSouthUpdate(wxUpdateUIEvent& cmd)
553
cmd.Enable(m_View->HasData());
556
void GUIControl::OnMoveWest()
558
m_View->TurnCaveTo(270.0);
559
m_View->ForceRefresh();
562
void GUIControl::OnMoveWestUpdate(wxUpdateUIEvent& cmd)
564
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
567
void GUIControl::OnToggleRotation()
569
m_View->ToggleRotation();
572
void GUIControl::OnToggleRotationUpdate(wxUpdateUIEvent& cmd)
574
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
575
cmd.Check(m_View->HasData() && m_View->IsRotating());
578
void GUIControl::OnReverseControls()
580
m_ReverseControls = !m_ReverseControls;
583
void GUIControl::OnReverseControlsUpdate(wxUpdateUIEvent& cmd)
585
cmd.Enable(m_View->HasData());
586
cmd.Check(m_ReverseControls);
589
void GUIControl::OnReverseDirectionOfRotation()
591
m_View->ReverseRotation();
594
void GUIControl::OnReverseDirectionOfRotationUpdate(wxUpdateUIEvent& cmd)
596
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
599
void GUIControl::OnSlowDown(bool accel)
601
m_View->RotateSlower(accel);
604
void GUIControl::OnSlowDownUpdate(wxUpdateUIEvent& cmd)
606
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
609
void GUIControl::OnSpeedUp(bool accel)
611
m_View->RotateFaster(accel);
614
void GUIControl::OnSpeedUpUpdate(wxUpdateUIEvent& cmd)
616
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
619
void GUIControl::OnStepOnceAnticlockwise(bool accel)
621
if (m_View->GetPerspective()) {
622
m_View->TurnCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP);
624
m_View->TurnCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP);
626
m_View->ForceRefresh();
629
void GUIControl::OnStepOnceAnticlockwiseUpdate(wxUpdateUIEvent& cmd)
631
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->IsRotating());
634
void GUIControl::OnStepOnceClockwise(bool accel)
636
if (m_View->GetPerspective()) {
637
m_View->TurnCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP);
639
m_View->TurnCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP);
641
m_View->ForceRefresh();
644
void GUIControl::OnStepOnceClockwiseUpdate(wxUpdateUIEvent& cmd)
646
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->IsRotating());
649
void GUIControl::OnDefaults()
654
void GUIControl::OnDefaultsUpdate(wxUpdateUIEvent& cmd)
656
cmd.Enable(m_View->HasData());
659
void GUIControl::OnElevation()
661
// Switch to elevation view.
663
m_View->SwitchToElevation();
666
void GUIControl::OnElevationUpdate(wxUpdateUIEvent& cmd)
668
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingElevation());
671
void GUIControl::OnHigherViewpoint(bool accel)
673
// Raise the viewpoint.
674
if (m_View->GetPerspective()) {
675
m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP);
677
m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP);
679
m_View->ForceRefresh();
682
void GUIControl::OnHigherViewpointUpdate(wxUpdateUIEvent& cmd)
684
cmd.Enable(m_View->HasData() && m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation());
687
void GUIControl::OnLowerViewpoint(bool accel)
689
// Lower the viewpoint.
690
if (m_View->GetPerspective()) {
691
m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP);
693
m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP);
695
m_View->ForceRefresh();
698
void GUIControl::OnLowerViewpointUpdate(wxUpdateUIEvent& cmd)
700
cmd.Enable(m_View->HasData() && m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation());
703
void GUIControl::OnPlan()
705
// Switch to plan view.
706
m_View->SwitchToPlan();
709
void GUIControl::OnPlanUpdate(wxUpdateUIEvent& cmd)
711
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingPlan());
714
void GUIControl::OnShiftDisplayDown(bool accel)
716
if (m_View->GetPerspective())
717
m_View->MoveViewer(0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0);
719
m_View->TranslateCave(0, accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT);
722
void GUIControl::OnShiftDisplayDownUpdate(wxUpdateUIEvent& cmd)
724
cmd.Enable(m_View->HasData());
727
void GUIControl::OnShiftDisplayLeft(bool accel)
729
if (m_View->GetPerspective())
730
m_View->MoveViewer(0, 0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT);
732
m_View->TranslateCave(accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT, 0);
735
void GUIControl::OnShiftDisplayLeftUpdate(wxUpdateUIEvent& cmd)
737
cmd.Enable(m_View->HasData());
740
void GUIControl::OnShiftDisplayRight(bool accel)
742
if (m_View->GetPerspective())
743
m_View->MoveViewer(0, 0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT);
745
m_View->TranslateCave(accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT, 0);
748
void GUIControl::OnShiftDisplayRightUpdate(wxUpdateUIEvent& cmd)
750
cmd.Enable(m_View->HasData());
753
void GUIControl::OnShiftDisplayUp(bool accel)
755
if (m_View->GetPerspective())
756
m_View->MoveViewer(0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0);
758
m_View->TranslateCave(0, accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT);
761
void GUIControl::OnShiftDisplayUpUpdate(wxUpdateUIEvent& cmd)
763
cmd.Enable(m_View->HasData());
766
void GUIControl::OnZoomIn(bool accel)
768
// Increase the scale.
770
if (m_View->GetPerspective()) {
771
m_View->MoveViewer(accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0, 0);
773
m_View->SetScale(m_View->GetScale() * (accel ? 1.1236 : 1.06));
774
m_View->ForceRefresh();
778
void GUIControl::OnZoomInUpdate(wxUpdateUIEvent& cmd)
780
cmd.Enable(m_View->HasData());
783
void GUIControl::OnZoomOut(bool accel)
785
// Decrease the scale.
787
if (m_View->GetPerspective()) {
788
m_View->MoveViewer(accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0, 0);
790
m_View->SetScale(m_View->GetScale() / (accel ? 1.1236 : 1.06));
791
m_View->ForceRefresh();
795
void GUIControl::OnZoomOutUpdate(wxUpdateUIEvent& cmd)
797
cmd.Enable(m_View->HasData());
800
void GUIControl::OnToggleScalebar()
802
m_View->ToggleScaleBar();
805
void GUIControl::OnToggleScalebarUpdate(wxUpdateUIEvent& cmd)
807
cmd.Enable(m_View->HasData());
808
cmd.Check(m_View->ShowingScaleBar());
811
void GUIControl::OnToggleDepthbar() /* FIXME naming */
813
m_View->ToggleDepthBar();
816
void GUIControl::OnToggleDepthbarUpdate(wxUpdateUIEvent& cmd)
818
cmd.Enable(m_View->HasData() && m_View->ColouringBy() == COLOUR_BY_DEPTH);
819
cmd.Check(m_View->ShowingDepthBar());
822
void GUIControl::OnViewCompass()
824
m_View->ToggleCompass();
827
void GUIControl::OnViewCompassUpdate(wxUpdateUIEvent& cmd)
829
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
830
cmd.Check(m_View->ShowingCompass());
833
void GUIControl::OnViewClino()
835
m_View->ToggleClino();
838
void GUIControl::OnViewClinoUpdate(wxUpdateUIEvent& cmd)
840
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
841
cmd.Check(m_View->ShowingClino());
844
void GUIControl::OnShowSurface()
846
m_View->ToggleSurfaceLegs();
849
void GUIControl::OnShowSurfaceUpdate(wxUpdateUIEvent& cmd)
851
cmd.Enable(m_View->HasData() && m_View->HasSurfaceLegs());
852
cmd.Check(m_View->ShowingSurfaceLegs());
855
void GUIControl::OnShowEntrances()
857
m_View->ToggleEntrances();
860
void GUIControl::OnShowEntrancesUpdate(wxUpdateUIEvent& cmd)
862
cmd.Enable(m_View->HasData() && (m_View->GetNumEntrances() > 0));
863
cmd.Check(m_View->ShowingEntrances());
866
void GUIControl::OnShowFixedPts()
868
m_View->ToggleFixedPts();
871
void GUIControl::OnShowFixedPtsUpdate(wxUpdateUIEvent& cmd)
873
cmd.Enable(m_View->HasData() && (m_View->GetNumFixedPts() > 0));
874
cmd.Check(m_View->ShowingFixedPts());
877
void GUIControl::OnShowExportedPts()
879
m_View->ToggleExportedPts();
882
void GUIControl::OnShowExportedPtsUpdate(wxUpdateUIEvent& cmd)
884
cmd.Enable(m_View->HasData() && (m_View->GetNumExportedPts() > 0));
885
cmd.Check(m_View->ShowingExportedPts());
888
void GUIControl::OnViewGrid()
890
m_View->ToggleGrid();
893
void GUIControl::OnViewGridUpdate(wxUpdateUIEvent& cmd)
895
cmd.Enable(m_View->HasData());
896
cmd.Check(m_View->ShowingGrid());
899
void GUIControl::OnIndicatorsUpdate(wxUpdateUIEvent& cmd)
901
cmd.Enable(m_View->HasData());
904
void GUIControl::OnViewPerspective()
906
m_View->TogglePerspective();
907
// Force update of coordinate display.
908
if (m_View->GetPerspective()) {
909
m_View->MoveViewer(0, 0, 0);
911
m_View->ClearCoords();
915
void GUIControl::OnViewPerspectiveUpdate(wxUpdateUIEvent& cmd)
917
cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation());
918
cmd.Check(m_View->GetPerspective());
921
void GUIControl::OnViewSmoothShading()
923
m_View->ToggleSmoothShading();
926
void GUIControl::OnViewSmoothShadingUpdate(wxUpdateUIEvent& cmd)
928
cmd.Enable(m_View->HasData());
929
cmd.Check(m_View->GetSmoothShading());
932
void GUIControl::OnViewTextured()
934
m_View->ToggleTextured();
937
void GUIControl::OnViewTexturedUpdate(wxUpdateUIEvent& cmd)
939
cmd.Enable(m_View->HasData());
940
cmd.Check(m_View->GetTextured());
943
void GUIControl::OnViewFog()
948
void GUIControl::OnViewFogUpdate(wxUpdateUIEvent& cmd)
950
cmd.Enable(m_View->HasData());
951
cmd.Check(m_View->GetFog());
954
void GUIControl::OnViewSmoothLines()
956
m_View->ToggleAntiAlias();
959
void GUIControl::OnViewSmoothLinesUpdate(wxUpdateUIEvent& cmd)
961
cmd.Enable(m_View->HasData());
962
cmd.Check(m_View->GetAntiAlias());
965
void GUIControl::OnToggleMetric()
967
m_View->ToggleMetric();
969
wxConfigBase::Get()->Write(wxT("metric"), m_View->GetMetric());
970
wxConfigBase::Get()->Flush();
973
void GUIControl::OnToggleMetricUpdate(wxUpdateUIEvent& cmd)
975
cmd.Enable(m_View->HasData());
976
cmd.Check(m_View->GetMetric());
979
void GUIControl::OnToggleDegrees()
981
m_View->ToggleDegrees();
983
wxConfigBase::Get()->Write(wxT("degrees"), m_View->GetDegrees());
984
wxConfigBase::Get()->Flush();
987
void GUIControl::OnToggleDegreesUpdate(wxUpdateUIEvent& cmd)
989
cmd.Enable(m_View->HasData());
990
cmd.Check(m_View->GetDegrees());
993
void GUIControl::OnToggleTubes()
995
m_View->ToggleTubes();
998
void GUIControl::OnToggleTubesUpdate(wxUpdateUIEvent& cmd)
1000
cmd.Enable(m_View->HasData() && m_View->HasTubes());
1001
cmd.Check(m_View->GetTubes());
1004
void GUIControl::OnCancelDistLine()
1006
m_View->ClearTreeSelection();
1009
void GUIControl::OnCancelDistLineUpdate(wxUpdateUIEvent& cmd)
1011
cmd.Enable(m_View->ShowingMeasuringLine());
1014
void GUIControl::OnKeyPress(wxKeyEvent &e)
1016
if (!m_View->HasData()) {
1021
// The changelog says this is meant to keep animation going while keys are
1022
// pressed, but that happens anyway (on linux at least - perhaps it helps
1023
// on windows?) FIXME : check!
1024
//bool refresh = m_View->Animate();
1026
switch (e.m_keyCode) {
1028
if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation())
1029
OnLowerViewpoint(e.m_shiftDown);
1031
case '\'': case '@': case '"': // both shifted forms - US and UK kbd
1032
if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation())
1033
OnHigherViewpoint(e.m_shiftDown);
1036
if (!m_View->IsExtendedElevation() && !m_View->IsRotating())
1037
OnStepOnceAnticlockwise(e.m_shiftDown);
1040
if (!m_View->IsExtendedElevation() && !m_View->IsRotating())
1041
OnStepOnceClockwise(e.m_shiftDown);
1044
OnZoomIn(e.m_shiftDown);
1047
OnZoomOut(e.m_shiftDown);
1056
if (!m_View->IsExtendedElevation())
1060
if (!m_View->IsExtendedElevation())
1064
if (!m_View->IsExtendedElevation())
1065
OnSpeedUp(e.m_shiftDown);
1068
if (!m_View->IsExtendedElevation())
1069
OnSlowDown(e.m_shiftDown);
1072
if (!m_View->IsExtendedElevation())
1073
OnReverseDirectionOfRotation();
1076
if (!m_View->IsExtendedElevation() && !m_View->ShowingPlan())
1080
if (!m_View->IsExtendedElevation() && !m_View->ShowingElevation())
1084
OnDisplayOverlappingNames();
1090
// For compatibility with older versions.
1091
if (!m_View->IsExtendedElevation() && !m_View->IsRotating())
1092
m_View->StartRotation();
1095
if (!m_View->IsExtendedElevation())
1099
if (e.m_controlDown) {
1100
if (!m_View->IsExtendedElevation() && !m_View->IsRotating())
1101
OnStepOnceAnticlockwise(e.m_shiftDown);
1103
OnShiftDisplayLeft(e.m_shiftDown);
1107
if (e.m_controlDown) {
1108
if (!m_View->IsExtendedElevation() && !m_View->IsRotating())
1109
OnStepOnceClockwise(e.m_shiftDown);
1111
OnShiftDisplayRight(e.m_shiftDown);
1115
if (e.m_controlDown) {
1116
if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation())
1117
OnHigherViewpoint(e.m_shiftDown);
1119
OnShiftDisplayUp(e.m_shiftDown);
1123
if (e.m_controlDown) {
1124
if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation())
1125
OnLowerViewpoint(e.m_shiftDown);
1127
OnShiftDisplayDown(e.m_shiftDown);
1131
if (m_View->ShowingMeasuringLine()) {
1139
//if (refresh) m_View->ForceRefresh();
1142
void GUIControl::OnViewFullScreenUpdate(wxUpdateUIEvent& cmd)
1144
cmd.Check(m_View->IsFullScreen());
1147
void GUIControl::OnViewFullScreen()
1149
m_View->FullScreenMode();
1152
void GUIControl::OnViewBoundingBoxUpdate(wxUpdateUIEvent& cmd)
1154
cmd.Enable(m_View->HasData());
1155
cmd.Check(m_View->DisplayingBoundingBox());
1158
void GUIControl::OnViewBoundingBox()
1160
m_View->ToggleBoundingBox();