| 1 | // |
|---|
| 2 | // guicontrol.cc |
|---|
| 3 | // |
|---|
| 4 | // Handlers for events relating to the display of a survey. |
|---|
| 5 | // |
|---|
| 6 | // Copyright (C) 2000-2002,2005 Mark R. Shinwell |
|---|
| 7 | // Copyright (C) 2001,2003,2004,2005,2006,2011,2012,2014,2015,2016 Olly Betts |
|---|
| 8 | // |
|---|
| 9 | // This program is free software; you can redistribute it and/or modify |
|---|
| 10 | // it under the terms of the GNU General Public License as published by |
|---|
| 11 | // the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | // (at your option) any later version. |
|---|
| 13 | // |
|---|
| 14 | // This program is distributed in the hope that it will be useful, |
|---|
| 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | // GNU General Public License for more details. |
|---|
| 18 | // |
|---|
| 19 | // You should have received a copy of the GNU General Public License |
|---|
| 20 | // along with this program; if not, write to the Free Software |
|---|
| 21 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 22 | // |
|---|
| 23 | |
|---|
| 24 | #include <config.h> |
|---|
| 25 | |
|---|
| 26 | #include "guicontrol.h" |
|---|
| 27 | #include "gfxcore.h" |
|---|
| 28 | #include <wx/confbase.h> |
|---|
| 29 | |
|---|
| 30 | const int DISPLAY_SHIFT = 10; |
|---|
| 31 | const double FLYFREE_SHIFT = 0.2; |
|---|
| 32 | const double ROTATE_STEP = 2.0; |
|---|
| 33 | |
|---|
| 34 | GUIControl::GUIControl() |
|---|
| 35 | : dragging(NO_DRAG) |
|---|
| 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 | |
|---|
| 47 | bool GUIControl::MouseDown() const |
|---|
| 48 | { |
|---|
| 49 | return (dragging != NO_DRAG); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | void GUIControl::HandleTilt(wxPoint point) |
|---|
| 53 | { |
|---|
| 54 | // Handle a mouse movement during tilt mode. |
|---|
| 55 | |
|---|
| 56 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 57 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
|---|
| 58 | |
|---|
| 59 | int dy = point.y - m_DragStart.y; |
|---|
| 60 | |
|---|
| 61 | if (m_ReverseControls != m_View->GetPerspective()) dy = -dy; |
|---|
| 62 | |
|---|
| 63 | m_View->TiltCave(Double(dy) * 0.36); |
|---|
| 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. |
|---|
| 73 | |
|---|
| 74 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 75 | m_View->UpdateCursor(GfxCore::CURSOR_DRAGGING_HAND); |
|---|
| 76 | |
|---|
| 77 | int dx = point.x - m_DragStart.x; |
|---|
| 78 | int dy = point.y - m_DragStart.y; |
|---|
| 79 | |
|---|
| 80 | if (m_ReverseControls) { |
|---|
| 81 | dx = -dx; |
|---|
| 82 | dy = -dy; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | if (m_View->GetPerspective()) |
|---|
| 86 | m_View->MoveViewer(0, -dy * .1, dx * .1); |
|---|
| 87 | else |
|---|
| 88 | m_View->TranslateCave(dx, dy); |
|---|
| 89 | |
|---|
| 90 | m_DragStart = point; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | void GUIControl::HandleScaleRotate(wxPoint point) |
|---|
| 94 | { |
|---|
| 95 | // Handle a mouse movement during scale/rotate mode. |
|---|
| 96 | |
|---|
| 97 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 98 | m_View->UpdateCursor(GfxCore::CURSOR_ZOOM_ROTATE); |
|---|
| 99 | |
|---|
| 100 | int dx, dy; |
|---|
| 101 | int threshold; |
|---|
| 102 | if (m_ScaleRotateLock == lock_NONE) { |
|---|
| 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) { |
|---|
| 117 | case lock_NONE: |
|---|
| 118 | if (dx2 > dy2) { |
|---|
| 119 | m_ScaleRotateLock = lock_ROTATE; |
|---|
| 120 | // m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 121 | } else { |
|---|
| 122 | m_ScaleRotateLock = lock_SCALE; |
|---|
| 123 | // m_View->UpdateCursor(GfxCore::CURSOR_ZOOM); |
|---|
| 124 | } |
|---|
| 125 | break; |
|---|
| 126 | case lock_SCALE: |
|---|
| 127 | if (dx2 >= 8 * dy2) { |
|---|
| 128 | m_ScaleRotateLock = lock_ROTATE; |
|---|
| 129 | // m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 130 | } |
|---|
| 131 | break; |
|---|
| 132 | case lock_ROTATE: |
|---|
| 133 | if (dy2 >= 8 * dx2) { |
|---|
| 134 | m_ScaleRotateLock = lock_SCALE; |
|---|
| 135 | // m_View->UpdateCursor(GfxCore::CURSOR_ZOOM); |
|---|
| 136 | } |
|---|
| 137 | break; |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | if (m_ScaleRotateLock == lock_ROTATE) { |
|---|
| 141 | dy = 0; |
|---|
| 142 | } else { |
|---|
| 143 | dx = 0; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | if (m_ReverseControls) { |
|---|
| 147 | dx = -dx; |
|---|
| 148 | dy = -dy; |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | if (m_View->GetPerspective()) { |
|---|
| 152 | if (dy) m_View->MoveViewer(-dy * .1, 0, 0); |
|---|
| 153 | } else { |
|---|
| 154 | // up/down => scale. |
|---|
| 155 | if (dy) m_View->SetScale(m_View->GetScale() * pow(1.06, 0.08 * dy)); |
|---|
| 156 | // left/right => rotate. |
|---|
| 157 | if (dx) m_View->TurnCave(Double(dx) * -0.36); |
|---|
| 158 | if (dx || dy) m_View->ForceRefresh(); |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | m_DragStart = point; |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | void GUIControl::HandleTiltRotate(wxPoint point) |
|---|
| 165 | { |
|---|
| 166 | // Handle a mouse movement during tilt/rotate mode. |
|---|
| 167 | if (m_View->IsExtendedElevation()) return; |
|---|
| 168 | |
|---|
| 169 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 170 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY); |
|---|
| 171 | |
|---|
| 172 | int dx = point.x - m_DragStart.x; |
|---|
| 173 | int dy = point.y - m_DragStart.y; |
|---|
| 174 | |
|---|
| 175 | if (m_ReverseControls != m_View->GetPerspective()) { |
|---|
| 176 | dx = -dx; |
|---|
| 177 | dy = -dy; |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | // left/right => rotate, up/down => tilt. |
|---|
| 181 | // Make tilt less sensitive than rotate as that feels better. |
|---|
| 182 | m_View->TurnCave(Double(dx) * -0.36); |
|---|
| 183 | m_View->TiltCave(Double(dy) * 0.18); |
|---|
| 184 | |
|---|
| 185 | m_View->ForceRefresh(); |
|---|
| 186 | |
|---|
| 187 | m_DragStart = point; |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | void GUIControl::HandleRotate(wxPoint point) |
|---|
| 191 | { |
|---|
| 192 | // Handle a mouse movement during rotate mode. |
|---|
| 193 | if (m_View->IsExtendedElevation()) return; |
|---|
| 194 | |
|---|
| 195 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 196 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 197 | |
|---|
| 198 | int dx = point.x - m_DragStart.x; |
|---|
| 199 | int dy = point.y - m_DragStart.y; |
|---|
| 200 | |
|---|
| 201 | if (m_ReverseControls != m_View->GetPerspective()) { |
|---|
| 202 | dx = -dx; |
|---|
| 203 | dy = -dy; |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | // left/right => rotate. |
|---|
| 207 | m_View->TurnCave(Double(dx) * -0.36); |
|---|
| 208 | |
|---|
| 209 | m_View->ForceRefresh(); |
|---|
| 210 | |
|---|
| 211 | m_DragStart = point; |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | void GUIControl::RestoreCursor() |
|---|
| 215 | { |
|---|
| 216 | if (m_View->HereIsReal()) { |
|---|
| 217 | m_View->UpdateCursor(GfxCore::CURSOR_POINTING_HAND); |
|---|
| 218 | } else { |
|---|
| 219 | m_View->UpdateCursor(GfxCore::CURSOR_DEFAULT); |
|---|
| 220 | } |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | void GUIControl::HandleNonDrag(const wxPoint & point) { |
|---|
| 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 | } |
|---|
| 234 | if (m_View->CheckHitTestGrid(point, false)) { |
|---|
| 235 | m_View->UpdateCursor(GfxCore::CURSOR_POINTING_HAND); |
|---|
| 236 | } else if (m_View->PointWithinScaleBar(point)) { |
|---|
| 237 | m_View->UpdateCursor(GfxCore::CURSOR_HORIZONTAL_RESIZE); |
|---|
| 238 | } else if (m_View->PointWithinCompass(point)) { |
|---|
| 239 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 240 | } else if (m_View->PointWithinClino(point)) { |
|---|
| 241 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
|---|
| 242 | } else { |
|---|
| 243 | RestoreCursor(); |
|---|
| 244 | } |
|---|
| 245 | } |
|---|
| 246 | |
|---|
| 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 | |
|---|
| 256 | // Ignore moves which don't change the position. |
|---|
| 257 | if (event.GetPosition() == m_DragStart) { |
|---|
| 258 | return; |
|---|
| 259 | } |
|---|
| 260 | |
|---|
| 261 | static long timestamp = LONG_MIN; |
|---|
| 262 | if (dragging != NO_DRAG && m_ScaleRotateLock != lock_NONE && |
|---|
| 263 | timestamp != LONG_MIN) { |
|---|
| 264 | // If no motion for a second, reset the direction lock. |
|---|
| 265 | if (event.GetTimestamp() - timestamp >= 1000) { |
|---|
| 266 | m_ScaleRotateLock = lock_NONE; |
|---|
| 267 | m_DragRealStart = m_DragStart; |
|---|
| 268 | RestoreCursor(); |
|---|
| 269 | } |
|---|
| 270 | } |
|---|
| 271 | timestamp = event.GetTimestamp(); |
|---|
| 272 | |
|---|
| 273 | wxPoint point(event.GetPosition()); |
|---|
| 274 | |
|---|
| 275 | // Check hit-test grid (only if no buttons are pressed). |
|---|
| 276 | if (!event.LeftIsDown() && !event.MiddleIsDown() && !event.RightIsDown()) { |
|---|
| 277 | HandleNonDrag(point); |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | // Update coordinate display if in plan view, |
|---|
| 281 | // or altitude if in elevation view. |
|---|
| 282 | m_View->SetCoords(point); |
|---|
| 283 | |
|---|
| 284 | switch (dragging) { |
|---|
| 285 | case LEFT_DRAG: |
|---|
| 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 { |
|---|
| 302 | HandleScaleRotate(point); |
|---|
| 303 | } |
|---|
| 304 | break; |
|---|
| 305 | case drag_ZOOM: |
|---|
| 306 | m_View->SetZoomBox(m_DragStart, point, !event.ShiftDown(), event.ControlDown()); |
|---|
| 307 | break; |
|---|
| 308 | case drag_NONE: |
|---|
| 309 | // Shouldn't happen?! FIXME: assert or something. |
|---|
| 310 | break; |
|---|
| 311 | } |
|---|
| 312 | break; |
|---|
| 313 | case MIDDLE_DRAG: |
|---|
| 314 | HandleTilt(point); |
|---|
| 315 | break; |
|---|
| 316 | case RIGHT_DRAG: |
|---|
| 317 | HandleTranslate(point); |
|---|
| 318 | break; |
|---|
| 319 | case NO_DRAG: |
|---|
| 320 | break; |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | m_DragLast = point; |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | void GUIControl::OnLButtonDown(wxMouseEvent& event) |
|---|
| 327 | { |
|---|
| 328 | if (m_View->HasData()) { |
|---|
| 329 | m_DragStart = m_DragRealStart = event.GetPosition(); |
|---|
| 330 | |
|---|
| 331 | if (m_View->PointWithinCompass(m_DragStart)) { |
|---|
| 332 | m_LastDrag = drag_COMPASS; |
|---|
| 333 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 334 | } else if (m_View->PointWithinClino(m_DragStart)) { |
|---|
| 335 | m_LastDrag = drag_ELEV; |
|---|
| 336 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
|---|
| 337 | } else if (m_View->PointWithinScaleBar(m_DragStart)) { |
|---|
| 338 | m_LastDrag = drag_SCALE; |
|---|
| 339 | m_View->UpdateCursor(GfxCore::CURSOR_HORIZONTAL_RESIZE); |
|---|
| 340 | } else if (event.ShiftDown()) { |
|---|
| 341 | m_LastDrag = drag_ZOOM; |
|---|
| 342 | m_View->UpdateCursor(GfxCore::CURSOR_ZOOM); |
|---|
| 343 | } else { |
|---|
| 344 | if (event.ControlDown() && !m_View->IsExtendedElevation()) { |
|---|
| 345 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY); |
|---|
| 346 | } else { |
|---|
| 347 | m_View->UpdateCursor(GfxCore::CURSOR_ZOOM_ROTATE); |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | m_LastDrag = drag_MAIN; |
|---|
| 351 | m_ScaleRotateLock = lock_NONE; |
|---|
| 352 | } |
|---|
| 353 | |
|---|
| 354 | // We need to release and recapture for the cursor to update (noticed |
|---|
| 355 | // with wxGTK). |
|---|
| 356 | if (dragging != NO_DRAG) m_View->ReleaseMouse(); |
|---|
| 357 | m_View->CaptureMouse(); |
|---|
| 358 | |
|---|
| 359 | dragging = LEFT_DRAG; |
|---|
| 360 | } |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | void GUIControl::OnLButtonUp(wxMouseEvent& event) |
|---|
| 364 | { |
|---|
| 365 | if (m_View->HasData()) { |
|---|
| 366 | if (dragging != LEFT_DRAG) |
|---|
| 367 | return; |
|---|
| 368 | |
|---|
| 369 | if (event.MiddleIsDown()) { |
|---|
| 370 | if (m_LastDrag == drag_ZOOM) |
|---|
| 371 | m_View->UnsetZoomBox(); |
|---|
| 372 | OnMButtonDown(event); |
|---|
| 373 | return; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | if (event.RightIsDown()) { |
|---|
| 377 | if (m_LastDrag == drag_ZOOM) |
|---|
| 378 | m_View->UnsetZoomBox(); |
|---|
| 379 | OnRButtonDown(event); |
|---|
| 380 | return; |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | if (m_LastDrag == drag_ZOOM) { |
|---|
| 384 | m_View->ZoomBoxGo(); |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | m_View->ReleaseMouse(); |
|---|
| 388 | |
|---|
| 389 | m_LastDrag = drag_NONE; |
|---|
| 390 | dragging = NO_DRAG; |
|---|
| 391 | |
|---|
| 392 | m_View->DragFinished(); |
|---|
| 393 | |
|---|
| 394 | if (event.GetPosition() == m_DragRealStart) { |
|---|
| 395 | // Just a "click"... |
|---|
| 396 | m_View->CheckHitTestGrid(m_DragStart, true); |
|---|
| 397 | RestoreCursor(); |
|---|
| 398 | } else { |
|---|
| 399 | HandleNonDrag(event.GetPosition()); |
|---|
| 400 | } |
|---|
| 401 | } |
|---|
| 402 | } |
|---|
| 403 | |
|---|
| 404 | void GUIControl::OnMButtonDown(wxMouseEvent& event) |
|---|
| 405 | { |
|---|
| 406 | if (m_View->HasData() && !m_View->IsExtendedElevation()) { |
|---|
| 407 | m_DragStart = event.GetPosition(); |
|---|
| 408 | |
|---|
| 409 | m_View->UpdateCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
|---|
| 410 | |
|---|
| 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 | } |
|---|
| 418 | m_View->CaptureMouse(); |
|---|
| 419 | dragging = MIDDLE_DRAG; |
|---|
| 420 | } |
|---|
| 421 | } |
|---|
| 422 | |
|---|
| 423 | void GUIControl::OnMButtonUp(wxMouseEvent& event) |
|---|
| 424 | { |
|---|
| 425 | if (m_View->HasData()) { |
|---|
| 426 | if (dragging != MIDDLE_DRAG) |
|---|
| 427 | return; |
|---|
| 428 | |
|---|
| 429 | if (event.LeftIsDown()) { |
|---|
| 430 | OnLButtonDown(event); |
|---|
| 431 | return; |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | if (event.RightIsDown()) { |
|---|
| 435 | OnRButtonDown(event); |
|---|
| 436 | return; |
|---|
| 437 | } |
|---|
| 438 | |
|---|
| 439 | dragging = NO_DRAG; |
|---|
| 440 | m_View->ReleaseMouse(); |
|---|
| 441 | m_View->DragFinished(); |
|---|
| 442 | |
|---|
| 443 | RestoreCursor(); |
|---|
| 444 | } |
|---|
| 445 | } |
|---|
| 446 | |
|---|
| 447 | void GUIControl::OnRButtonDown(wxMouseEvent& event) |
|---|
| 448 | { |
|---|
| 449 | if (m_View->HasData()) { |
|---|
| 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(); |
|---|
| 456 | dragging = NO_DRAG; |
|---|
| 457 | } |
|---|
| 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 | |
|---|
| 466 | m_View->CaptureMouse(); |
|---|
| 467 | dragging = RIGHT_DRAG; |
|---|
| 468 | } |
|---|
| 469 | } |
|---|
| 470 | |
|---|
| 471 | void GUIControl::OnRButtonUp(wxMouseEvent& event) |
|---|
| 472 | { |
|---|
| 473 | if (dragging != RIGHT_DRAG) |
|---|
| 474 | return; |
|---|
| 475 | |
|---|
| 476 | if (event.LeftIsDown()) { |
|---|
| 477 | OnLButtonDown(event); |
|---|
| 478 | return; |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | if (event.MiddleIsDown()) { |
|---|
| 482 | OnMButtonDown(event); |
|---|
| 483 | return; |
|---|
| 484 | } |
|---|
| 485 | |
|---|
| 486 | m_LastDrag = drag_NONE; |
|---|
| 487 | m_View->ReleaseMouse(); |
|---|
| 488 | |
|---|
| 489 | dragging = NO_DRAG; |
|---|
| 490 | |
|---|
| 491 | RestoreCursor(); |
|---|
| 492 | |
|---|
| 493 | m_View->DragFinished(); |
|---|
| 494 | } |
|---|
| 495 | |
|---|
| 496 | void GUIControl::OnMouseWheel(wxMouseEvent& event) { |
|---|
| 497 | int dy = event.GetWheelRotation(); |
|---|
| 498 | if (m_View->GetPerspective()) { |
|---|
| 499 | m_View->MoveViewer(-dy, 0, 0); |
|---|
| 500 | } else { |
|---|
| 501 | m_View->SetScale(m_View->GetScale() * pow(1.06, -0.04 * dy)); |
|---|
| 502 | m_View->ForceRefresh(); |
|---|
| 503 | } |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | void GUIControl::OnDisplayOverlappingNames() |
|---|
| 507 | { |
|---|
| 508 | m_View->ToggleOverlappingNames(); |
|---|
| 509 | } |
|---|
| 510 | |
|---|
| 511 | void GUIControl::OnDisplayOverlappingNamesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 512 | { |
|---|
| 513 | cmd.Enable(m_View->HasData() && m_View->ShowingStationNames()); |
|---|
| 514 | cmd.Check(m_View->ShowingOverlappingNames()); |
|---|
| 515 | } |
|---|
| 516 | |
|---|
| 517 | void GUIControl::OnColourByDepth() |
|---|
| 518 | { |
|---|
| 519 | if (m_View->ColouringBy() == COLOUR_BY_DEPTH) { |
|---|
| 520 | m_View->SetColourBy(COLOUR_BY_NONE); |
|---|
| 521 | } else { |
|---|
| 522 | m_View->SetColourBy(COLOUR_BY_DEPTH); |
|---|
| 523 | } |
|---|
| 524 | } |
|---|
| 525 | |
|---|
| 526 | void GUIControl::OnColourByDate() |
|---|
| 527 | { |
|---|
| 528 | if (m_View->ColouringBy() == COLOUR_BY_DATE) { |
|---|
| 529 | m_View->SetColourBy(COLOUR_BY_NONE); |
|---|
| 530 | } else { |
|---|
| 531 | m_View->SetColourBy(COLOUR_BY_DATE); |
|---|
| 532 | } |
|---|
| 533 | } |
|---|
| 534 | |
|---|
| 535 | void GUIControl::OnColourByError() |
|---|
| 536 | { |
|---|
| 537 | if (m_View->ColouringBy() == COLOUR_BY_ERROR) { |
|---|
| 538 | m_View->SetColourBy(COLOUR_BY_NONE); |
|---|
| 539 | } else { |
|---|
| 540 | m_View->SetColourBy(COLOUR_BY_ERROR); |
|---|
| 541 | } |
|---|
| 542 | } |
|---|
| 543 | |
|---|
| 544 | void GUIControl::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 | |
|---|
| 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 | |
|---|
| 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 | |
|---|
| 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 | |
|---|
| 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 | |
|---|
| 598 | void GUIControl::OnColourByUpdate(wxUpdateUIEvent& cmd) |
|---|
| 599 | { |
|---|
| 600 | cmd.Enable(m_View->HasData()); |
|---|
| 601 | } |
|---|
| 602 | |
|---|
| 603 | void GUIControl::OnColourByDepthUpdate(wxUpdateUIEvent& cmd) |
|---|
| 604 | { |
|---|
| 605 | cmd.Enable(m_View->HasData()); |
|---|
| 606 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_DEPTH); |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | void GUIControl::OnColourByDateUpdate(wxUpdateUIEvent& cmd) |
|---|
| 610 | { |
|---|
| 611 | cmd.Enable(m_View->HasData()); |
|---|
| 612 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_DATE); |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | void GUIControl::OnColourByErrorUpdate(wxUpdateUIEvent& cmd) |
|---|
| 616 | { |
|---|
| 617 | cmd.Enable(m_View->HasData()); |
|---|
| 618 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_ERROR); |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 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 | |
|---|
| 633 | void GUIControl::OnColourByGradientUpdate(wxUpdateUIEvent& cmd) |
|---|
| 634 | { |
|---|
| 635 | cmd.Enable(m_View->HasData()); |
|---|
| 636 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_GRADIENT); |
|---|
| 637 | } |
|---|
| 638 | |
|---|
| 639 | void GUIControl::OnColourByLengthUpdate(wxUpdateUIEvent& cmd) |
|---|
| 640 | { |
|---|
| 641 | cmd.Enable(m_View->HasData()); |
|---|
| 642 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_LENGTH); |
|---|
| 643 | } |
|---|
| 644 | |
|---|
| 645 | void GUIControl::OnColourBySurveyUpdate(wxUpdateUIEvent& cmd) |
|---|
| 646 | { |
|---|
| 647 | cmd.Enable(m_View->HasData()); |
|---|
| 648 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_SURVEY); |
|---|
| 649 | } |
|---|
| 650 | |
|---|
| 651 | void GUIControl::OnColourByStyleUpdate(wxUpdateUIEvent& cmd) |
|---|
| 652 | { |
|---|
| 653 | cmd.Enable(m_View->HasData()); |
|---|
| 654 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_STYLE); |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 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 | { |
|---|
| 686 | cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs()); |
|---|
| 687 | cmd.Check(m_View->ShowingUndergroundLegs()); |
|---|
| 688 | } |
|---|
| 689 | |
|---|
| 690 | void GUIControl::OnHideSplays() |
|---|
| 691 | { |
|---|
| 692 | m_View->SetSplaysMode(SHOW_HIDE); |
|---|
| 693 | } |
|---|
| 694 | |
|---|
| 695 | void GUIControl::OnShowSplaysDashed() |
|---|
| 696 | { |
|---|
| 697 | m_View->SetSplaysMode(SHOW_DASHED); |
|---|
| 698 | } |
|---|
| 699 | |
|---|
| 700 | void GUIControl::OnShowSplaysFaded() |
|---|
| 701 | { |
|---|
| 702 | m_View->SetSplaysMode(SHOW_FADED); |
|---|
| 703 | } |
|---|
| 704 | |
|---|
| 705 | void GUIControl::OnShowSplaysNormal() |
|---|
| 706 | { |
|---|
| 707 | m_View->SetSplaysMode(SHOW_NORMAL); |
|---|
| 708 | } |
|---|
| 709 | |
|---|
| 710 | void GUIControl::OnSplaysUpdate(wxUpdateUIEvent& cmd) |
|---|
| 711 | { |
|---|
| 712 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
|---|
| 713 | } |
|---|
| 714 | |
|---|
| 715 | void GUIControl::OnHideSplaysUpdate(wxUpdateUIEvent& cmd) |
|---|
| 716 | { |
|---|
| 717 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
|---|
| 718 | cmd.Check(m_View->ShowingSplaysMode() == SHOW_HIDE); |
|---|
| 719 | } |
|---|
| 720 | |
|---|
| 721 | void GUIControl::OnShowSplaysDashedUpdate(wxUpdateUIEvent& cmd) |
|---|
| 722 | { |
|---|
| 723 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
|---|
| 724 | cmd.Check(m_View->ShowingSplaysMode() == SHOW_DASHED); |
|---|
| 725 | } |
|---|
| 726 | |
|---|
| 727 | void GUIControl::OnShowSplaysFadedUpdate(wxUpdateUIEvent& cmd) |
|---|
| 728 | { |
|---|
| 729 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
|---|
| 730 | cmd.Check(m_View->ShowingSplaysMode() == SHOW_FADED); |
|---|
| 731 | } |
|---|
| 732 | |
|---|
| 733 | void GUIControl::OnShowSplaysNormalUpdate(wxUpdateUIEvent& cmd) |
|---|
| 734 | { |
|---|
| 735 | cmd.Enable(m_View->HasData() && m_View->HasSplays()); |
|---|
| 736 | cmd.Check(m_View->ShowingSplaysMode() == SHOW_NORMAL); |
|---|
| 737 | } |
|---|
| 738 | |
|---|
| 739 | void GUIControl::OnHideDupes() { |
|---|
| 740 | m_View->SetDupesMode(SHOW_HIDE); |
|---|
| 741 | } |
|---|
| 742 | |
|---|
| 743 | void GUIControl::OnShowDupesDashed() { |
|---|
| 744 | m_View->SetDupesMode(SHOW_DASHED); |
|---|
| 745 | } |
|---|
| 746 | |
|---|
| 747 | void GUIControl::OnShowDupesFaded() { |
|---|
| 748 | m_View->SetDupesMode(SHOW_FADED); |
|---|
| 749 | } |
|---|
| 750 | |
|---|
| 751 | void GUIControl::OnShowDupesNormal() { |
|---|
| 752 | m_View->SetDupesMode(SHOW_NORMAL); |
|---|
| 753 | } |
|---|
| 754 | |
|---|
| 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()); |
|---|
| 761 | cmd.Check(m_View->ShowingDupesMode() == SHOW_HIDE); |
|---|
| 762 | } |
|---|
| 763 | |
|---|
| 764 | void GUIControl::OnShowDupesDashedUpdate(wxUpdateUIEvent& cmd) { |
|---|
| 765 | cmd.Enable(m_View->HasData() && m_View->HasDupes()); |
|---|
| 766 | cmd.Check(m_View->ShowingDupesMode() == SHOW_DASHED); |
|---|
| 767 | } |
|---|
| 768 | |
|---|
| 769 | void GUIControl::OnShowDupesFadedUpdate(wxUpdateUIEvent& cmd) { |
|---|
| 770 | cmd.Enable(m_View->HasData() && m_View->HasDupes()); |
|---|
| 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); |
|---|
| 777 | } |
|---|
| 778 | |
|---|
| 779 | void GUIControl::OnMoveEast() |
|---|
| 780 | { |
|---|
| 781 | m_View->TurnCaveTo(90.0); |
|---|
| 782 | m_View->ForceRefresh(); |
|---|
| 783 | } |
|---|
| 784 | |
|---|
| 785 | void GUIControl::OnMoveEastUpdate(wxUpdateUIEvent& cmd) |
|---|
| 786 | { |
|---|
| 787 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && m_View->GetCompassValue() != 90.0); |
|---|
| 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 | { |
|---|
| 798 | cmd.Enable(m_View->HasData() && m_View->GetCompassValue() != 0.0); |
|---|
| 799 | } |
|---|
| 800 | |
|---|
| 801 | void GUIControl::OnMoveSouth() |
|---|
| 802 | { |
|---|
| 803 | m_View->TurnCaveTo(180.0); |
|---|
| 804 | m_View->ForceRefresh(); |
|---|
| 805 | } |
|---|
| 806 | |
|---|
| 807 | void GUIControl::OnMoveSouthUpdate(wxUpdateUIEvent& cmd) |
|---|
| 808 | { |
|---|
| 809 | cmd.Enable(m_View->HasData() && m_View->GetCompassValue() != 180.0); |
|---|
| 810 | } |
|---|
| 811 | |
|---|
| 812 | void GUIControl::OnMoveWest() |
|---|
| 813 | { |
|---|
| 814 | m_View->TurnCaveTo(270.0); |
|---|
| 815 | m_View->ForceRefresh(); |
|---|
| 816 | } |
|---|
| 817 | |
|---|
| 818 | void GUIControl::OnMoveWestUpdate(wxUpdateUIEvent& cmd) |
|---|
| 819 | { |
|---|
| 820 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && m_View->GetCompassValue() != 270.0); |
|---|
| 821 | } |
|---|
| 822 | |
|---|
| 823 | void GUIControl::OnToggleRotation() |
|---|
| 824 | { |
|---|
| 825 | m_View->ToggleRotation(); |
|---|
| 826 | } |
|---|
| 827 | |
|---|
| 828 | void GUIControl::OnToggleRotationUpdate(wxUpdateUIEvent& cmd) |
|---|
| 829 | { |
|---|
| 830 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 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 | { |
|---|
| 852 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 853 | } |
|---|
| 854 | |
|---|
| 855 | void GUIControl::OnStepOnceAnticlockwise(bool accel) |
|---|
| 856 | { |
|---|
| 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 | } |
|---|
| 862 | m_View->ForceRefresh(); |
|---|
| 863 | } |
|---|
| 864 | |
|---|
| 865 | void GUIControl::OnStepOnceClockwise(bool accel) |
|---|
| 866 | { |
|---|
| 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 | } |
|---|
| 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 | { |
|---|
| 894 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingElevation()); |
|---|
| 895 | } |
|---|
| 896 | |
|---|
| 897 | void GUIControl::OnHigherViewpoint(bool accel) |
|---|
| 898 | { |
|---|
| 899 | // Raise the viewpoint. |
|---|
| 900 | if (m_View->GetPerspective()) { |
|---|
| 901 | m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
|---|
| 902 | } else { |
|---|
| 903 | m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
|---|
| 904 | } |
|---|
| 905 | m_View->ForceRefresh(); |
|---|
| 906 | } |
|---|
| 907 | |
|---|
| 908 | void GUIControl::OnLowerViewpoint(bool accel) |
|---|
| 909 | { |
|---|
| 910 | // Lower the viewpoint. |
|---|
| 911 | if (m_View->GetPerspective()) { |
|---|
| 912 | m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
|---|
| 913 | } else { |
|---|
| 914 | m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
|---|
| 915 | } |
|---|
| 916 | m_View->ForceRefresh(); |
|---|
| 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 | { |
|---|
| 927 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingPlan()); |
|---|
| 928 | } |
|---|
| 929 | |
|---|
| 930 | void GUIControl::OnShiftDisplayDown(bool accel) |
|---|
| 931 | { |
|---|
| 932 | if (m_View->GetPerspective()) |
|---|
| 933 | m_View->MoveViewer(0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0); |
|---|
| 934 | else |
|---|
| 935 | m_View->TranslateCave(0, accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT); |
|---|
| 936 | } |
|---|
| 937 | |
|---|
| 938 | void GUIControl::OnShiftDisplayLeft(bool accel) |
|---|
| 939 | { |
|---|
| 940 | if (m_View->GetPerspective()) |
|---|
| 941 | m_View->MoveViewer(0, 0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT); |
|---|
| 942 | else |
|---|
| 943 | m_View->TranslateCave(accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT, 0); |
|---|
| 944 | } |
|---|
| 945 | |
|---|
| 946 | void GUIControl::OnShiftDisplayRight(bool accel) |
|---|
| 947 | { |
|---|
| 948 | if (m_View->GetPerspective()) |
|---|
| 949 | m_View->MoveViewer(0, 0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT); |
|---|
| 950 | else |
|---|
| 951 | m_View->TranslateCave(accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT, 0); |
|---|
| 952 | } |
|---|
| 953 | |
|---|
| 954 | void GUIControl::OnShiftDisplayUp(bool accel) |
|---|
| 955 | { |
|---|
| 956 | if (m_View->GetPerspective()) |
|---|
| 957 | m_View->MoveViewer(0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0); |
|---|
| 958 | else |
|---|
| 959 | m_View->TranslateCave(0, accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT); |
|---|
| 960 | } |
|---|
| 961 | |
|---|
| 962 | void GUIControl::OnZoomIn(bool accel) |
|---|
| 963 | { |
|---|
| 964 | // Increase the scale. |
|---|
| 965 | |
|---|
| 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 | } |
|---|
| 972 | } |
|---|
| 973 | |
|---|
| 974 | void GUIControl::OnZoomOut(bool accel) |
|---|
| 975 | { |
|---|
| 976 | // Decrease the scale. |
|---|
| 977 | |
|---|
| 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 | } |
|---|
| 984 | } |
|---|
| 985 | |
|---|
| 986 | void GUIControl::OnToggleScalebar() |
|---|
| 987 | { |
|---|
| 988 | m_View->ToggleScaleBar(); |
|---|
| 989 | } |
|---|
| 990 | |
|---|
| 991 | void GUIControl::OnToggleScalebarUpdate(wxUpdateUIEvent& cmd) |
|---|
| 992 | { |
|---|
| 993 | cmd.Enable(m_View->HasData()); |
|---|
| 994 | cmd.Check(m_View->ShowingScaleBar()); |
|---|
| 995 | } |
|---|
| 996 | |
|---|
| 997 | void GUIControl::OnToggleColourKey() |
|---|
| 998 | { |
|---|
| 999 | m_View->ToggleColourKey(); |
|---|
| 1000 | } |
|---|
| 1001 | |
|---|
| 1002 | void GUIControl::OnToggleColourKeyUpdate(wxUpdateUIEvent& cmd) |
|---|
| 1003 | { |
|---|
| 1004 | cmd.Enable(m_View->HasData() && m_View->ColouringBy() != COLOUR_BY_NONE); |
|---|
| 1005 | cmd.Check(m_View->ShowingColourKey()); |
|---|
| 1006 | } |
|---|
| 1007 | |
|---|
| 1008 | void GUIControl::OnViewCompass() |
|---|
| 1009 | { |
|---|
| 1010 | m_View->ToggleCompass(); |
|---|
| 1011 | } |
|---|
| 1012 | |
|---|
| 1013 | void GUIControl::OnViewCompassUpdate(wxUpdateUIEvent& cmd) |
|---|
| 1014 | { |
|---|
| 1015 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 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 | { |
|---|
| 1026 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 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 | { |
|---|
| 1070 | cmd.Enable(m_View->HasData() && (m_View->GetNumExportedPts() > 0)); |
|---|
| 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()); |
|---|
| 1082 | cmd.Check(m_View->ShowingGrid()); |
|---|
| 1083 | } |
|---|
| 1084 | |
|---|
| 1085 | void GUIControl::OnIndicatorsUpdate(wxUpdateUIEvent& cmd) |
|---|
| 1086 | { |
|---|
| 1087 | cmd.Enable(m_View->HasData()); |
|---|
| 1088 | } |
|---|
| 1089 | |
|---|
| 1090 | void GUIControl::OnViewPerspective() |
|---|
| 1091 | { |
|---|
| 1092 | m_View->TogglePerspective(); |
|---|
| 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 | } |
|---|
| 1099 | } |
|---|
| 1100 | |
|---|
| 1101 | void GUIControl::OnViewPerspectiveUpdate(wxUpdateUIEvent& cmd) |
|---|
| 1102 | { |
|---|
| 1103 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 1104 | cmd.Check(m_View->GetPerspective()); |
|---|
| 1105 | } |
|---|
| 1106 | |
|---|
| 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 | |
|---|
| 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 | |
|---|
| 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 | |
|---|
| 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 | |
|---|
| 1151 | void GUIControl::OnToggleMetric() |
|---|
| 1152 | { |
|---|
| 1153 | m_View->ToggleMetric(); |
|---|
| 1154 | |
|---|
| 1155 | wxConfigBase::Get()->Write(wxT("metric"), m_View->GetMetric()); |
|---|
| 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(); |
|---|
| 1168 | |
|---|
| 1169 | wxConfigBase::Get()->Write(wxT("degrees"), m_View->GetDegrees()); |
|---|
| 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 | |
|---|
| 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 | |
|---|
| 1193 | void GUIControl::OnToggleTubes() |
|---|
| 1194 | { |
|---|
| 1195 | m_View->ToggleTubes(); |
|---|
| 1196 | } |
|---|
| 1197 | |
|---|
| 1198 | void GUIControl::OnToggleTubesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 1199 | { |
|---|
| 1200 | cmd.Enable(m_View->HasData() && m_View->HasTubes()); |
|---|
| 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 | { |
|---|
| 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. |
|---|
| 1220 | e.Skip(); |
|---|
| 1221 | return; |
|---|
| 1222 | } |
|---|
| 1223 | |
|---|
| 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(); |
|---|
| 1228 | |
|---|
| 1229 | switch (e.GetKeyCode()) { |
|---|
| 1230 | case '/': case '?': |
|---|
| 1231 | if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()) |
|---|
| 1232 | OnLowerViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1233 | break; |
|---|
| 1234 | case '\'': case '@': case '"': // both shifted forms - US and UK kbd |
|---|
| 1235 | if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()) |
|---|
| 1236 | OnHigherViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1237 | break; |
|---|
| 1238 | case 'C': case 'c': |
|---|
| 1239 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1240 | OnStepOnceAnticlockwise(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1241 | break; |
|---|
| 1242 | case 'V': case 'v': |
|---|
| 1243 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1244 | OnStepOnceClockwise(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1245 | break; |
|---|
| 1246 | case ']': case '}': |
|---|
| 1247 | OnZoomIn(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1248 | break; |
|---|
| 1249 | case '[': case '{': |
|---|
| 1250 | OnZoomOut(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1251 | break; |
|---|
| 1252 | case 'N': case 'n': |
|---|
| 1253 | OnMoveNorth(); |
|---|
| 1254 | break; |
|---|
| 1255 | case 'S': case 's': |
|---|
| 1256 | OnMoveSouth(); |
|---|
| 1257 | break; |
|---|
| 1258 | case 'E': case 'e': |
|---|
| 1259 | if (!m_View->IsExtendedElevation()) |
|---|
| 1260 | OnMoveEast(); |
|---|
| 1261 | break; |
|---|
| 1262 | case 'W': case 'w': |
|---|
| 1263 | if (!m_View->IsExtendedElevation()) |
|---|
| 1264 | OnMoveWest(); |
|---|
| 1265 | break; |
|---|
| 1266 | case 'Z': case 'z': |
|---|
| 1267 | if (!m_View->IsExtendedElevation()) |
|---|
| 1268 | m_View->RotateFaster(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1269 | break; |
|---|
| 1270 | case 'X': case 'x': |
|---|
| 1271 | if (!m_View->IsExtendedElevation()) |
|---|
| 1272 | m_View->RotateSlower(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1273 | break; |
|---|
| 1274 | case 'R': case 'r': |
|---|
| 1275 | if (!m_View->IsExtendedElevation()) |
|---|
| 1276 | OnReverseDirectionOfRotation(); |
|---|
| 1277 | break; |
|---|
| 1278 | case 'P': case 'p': |
|---|
| 1279 | if (!m_View->IsExtendedElevation() && !m_View->ShowingPlan()) |
|---|
| 1280 | OnPlan(); |
|---|
| 1281 | break; |
|---|
| 1282 | case 'L': case 'l': |
|---|
| 1283 | if (!m_View->IsExtendedElevation() && !m_View->ShowingElevation()) |
|---|
| 1284 | OnElevation(); |
|---|
| 1285 | break; |
|---|
| 1286 | case 'O': case 'o': |
|---|
| 1287 | OnDisplayOverlappingNames(); |
|---|
| 1288 | break; |
|---|
| 1289 | case WXK_DELETE: |
|---|
| 1290 | if (e.GetModifiers() == 0) |
|---|
| 1291 | OnDefaults(); |
|---|
| 1292 | break; |
|---|
| 1293 | case WXK_RETURN: |
|---|
| 1294 | if (e.GetModifiers() == 0) { |
|---|
| 1295 | // For compatibility with older versions. |
|---|
| 1296 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1297 | m_View->StartRotation(); |
|---|
| 1298 | } |
|---|
| 1299 | break; |
|---|
| 1300 | case WXK_SPACE: |
|---|
| 1301 | if (e.GetModifiers() == 0) { |
|---|
| 1302 | if (!m_View->IsExtendedElevation()) |
|---|
| 1303 | OnToggleRotation(); |
|---|
| 1304 | } |
|---|
| 1305 | break; |
|---|
| 1306 | case WXK_LEFT: |
|---|
| 1307 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
|---|
| 1308 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1309 | OnStepOnceAnticlockwise(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1310 | } else { |
|---|
| 1311 | OnShiftDisplayLeft(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1312 | } |
|---|
| 1313 | break; |
|---|
| 1314 | case WXK_RIGHT: |
|---|
| 1315 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
|---|
| 1316 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1317 | OnStepOnceClockwise(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1318 | } else { |
|---|
| 1319 | OnShiftDisplayRight(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1320 | } |
|---|
| 1321 | break; |
|---|
| 1322 | case WXK_UP: |
|---|
| 1323 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
|---|
| 1324 | if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()) |
|---|
| 1325 | OnHigherViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1326 | } else { |
|---|
| 1327 | OnShiftDisplayUp(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1328 | } |
|---|
| 1329 | break; |
|---|
| 1330 | case WXK_DOWN: |
|---|
| 1331 | if ((e.GetModifiers() &~ wxMOD_SHIFT) == wxMOD_CONTROL) { |
|---|
| 1332 | if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()) |
|---|
| 1333 | OnLowerViewpoint(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1334 | } else { |
|---|
| 1335 | OnShiftDisplayDown(e.GetModifiers() == wxMOD_SHIFT); |
|---|
| 1336 | } |
|---|
| 1337 | break; |
|---|
| 1338 | case WXK_ESCAPE: |
|---|
| 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 | } |
|---|
| 1347 | } |
|---|
| 1348 | break; |
|---|
| 1349 | case WXK_F2: |
|---|
| 1350 | if (e.GetModifiers() == 0) |
|---|
| 1351 | m_View->ToggleFatFinger(); |
|---|
| 1352 | break; |
|---|
| 1353 | case WXK_F3: |
|---|
| 1354 | if (e.GetModifiers() == 0) |
|---|
| 1355 | m_View->ToggleHitTestDebug(); |
|---|
| 1356 | break; |
|---|
| 1357 | case WXK_F4: { |
|---|
| 1358 | if (e.GetModifiers() == 0) { |
|---|
| 1359 | const wxChar * msg; |
|---|
| 1360 | #if wxDEBUG_LEVEL |
|---|
| 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"); |
|---|
| 1369 | #else |
|---|
| 1370 | msg = wxT("wxWidgets was built without assertions"); |
|---|
| 1371 | #endif |
|---|
| 1372 | wxMessageBox(msg, wxT("Aven Debug"), wxOK | wxICON_INFORMATION); |
|---|
| 1373 | } |
|---|
| 1374 | break; |
|---|
| 1375 | } |
|---|
| 1376 | case WXK_F5: |
|---|
| 1377 | if (e.GetModifiers() == 0) { |
|---|
| 1378 | m_View->InvalidateAllLists(); |
|---|
| 1379 | m_View->ForceRefresh(); |
|---|
| 1380 | } |
|---|
| 1381 | break; |
|---|
| 1382 | case WXK_F6: |
|---|
| 1383 | if (e.GetModifiers() == 0) |
|---|
| 1384 | m_View->ToggleRenderStats(); |
|---|
| 1385 | break; |
|---|
| 1386 | default: |
|---|
| 1387 | e.Skip(); |
|---|
| 1388 | } |
|---|
| 1389 | |
|---|
| 1390 | //if (refresh) m_View->ForceRefresh(); |
|---|
| 1391 | } |
|---|
| 1392 | |
|---|
| 1393 | void GUIControl::OnViewFullScreenUpdate(wxUpdateUIEvent& cmd) |
|---|
| 1394 | { |
|---|
| 1395 | cmd.Check(m_View->IsFullScreen()); |
|---|
| 1396 | } |
|---|
| 1397 | |
|---|
| 1398 | void GUIControl::OnViewFullScreen() |
|---|
| 1399 | { |
|---|
| 1400 | m_View->FullScreenMode(); |
|---|
| 1401 | } |
|---|
| 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 | } |
|---|
| 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 | } |
|---|