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