| 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 22 | // |
|---|
| 23 | |
|---|
| 24 | #ifdef HAVE_CONFIG_H |
|---|
| 25 | #include <config.h> |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | #include "guicontrol.h" |
|---|
| 29 | #include "gfxcore.h" |
|---|
| 30 | #include <wx/confbase.h> |
|---|
| 31 | |
|---|
| 32 | const int DISPLAY_SHIFT = 10; |
|---|
| 33 | const double FLYFREE_SHIFT = 0.2; |
|---|
| 34 | const double ROTATE_STEP = 2.0; |
|---|
| 35 | |
|---|
| 36 | GUIControl::GUIControl() |
|---|
| 37 | : dragging(NO_DRAG) |
|---|
| 38 | { |
|---|
| 39 | m_View = NULL; |
|---|
| 40 | m_ReverseControls = false; |
|---|
| 41 | m_LastDrag = drag_NONE; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | GUIControl::~GUIControl() |
|---|
| 45 | { |
|---|
| 46 | // no action |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | void GUIControl::SetView(GfxCore* view) |
|---|
| 50 | { |
|---|
| 51 | m_View = view; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | bool GUIControl::MouseDown() const |
|---|
| 55 | { |
|---|
| 56 | return (dragging != NO_DRAG); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | void GUIControl::HandleTilt(wxPoint point) |
|---|
| 60 | { |
|---|
| 61 | // Handle a mouse movement during tilt mode. |
|---|
| 62 | |
|---|
| 63 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 64 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
|---|
| 65 | |
|---|
| 66 | int dy = point.y - m_DragStart.y; |
|---|
| 67 | |
|---|
| 68 | if (m_ReverseControls != m_View->GetPerspective()) dy = -dy; |
|---|
| 69 | |
|---|
| 70 | m_View->TiltCave(Double(-dy) * 0.36); |
|---|
| 71 | |
|---|
| 72 | m_DragStart = point; |
|---|
| 73 | |
|---|
| 74 | m_View->ForceRefresh(); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | void GUIControl::HandleTranslate(wxPoint point) |
|---|
| 78 | { |
|---|
| 79 | // Handle a mouse movement during translation mode. |
|---|
| 80 | |
|---|
| 81 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 82 | m_View->SetCursor(GfxCore::CURSOR_DRAGGING_HAND); |
|---|
| 83 | |
|---|
| 84 | int dx = point.x - m_DragStart.x; |
|---|
| 85 | int dy = point.y - m_DragStart.y; |
|---|
| 86 | |
|---|
| 87 | if (m_ReverseControls) { |
|---|
| 88 | dx = -dx; |
|---|
| 89 | dy = -dy; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | if (m_View->GetPerspective()) |
|---|
| 93 | m_View->MoveViewer(0, -dy * .1, dx * .1); |
|---|
| 94 | else |
|---|
| 95 | m_View->TranslateCave(dx, dy); |
|---|
| 96 | |
|---|
| 97 | m_DragStart = point; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | void GUIControl::HandleScaleRotate(wxPoint point) |
|---|
| 101 | { |
|---|
| 102 | // Handle a mouse movement during scale/rotate mode. |
|---|
| 103 | |
|---|
| 104 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 105 | m_View->SetCursor(GfxCore::CURSOR_ZOOM_ROTATE); |
|---|
| 106 | |
|---|
| 107 | int dx, dy; |
|---|
| 108 | int threshold; |
|---|
| 109 | if (m_ScaleRotateLock == NONE) { |
|---|
| 110 | // Dragging to scale or rotate but we've not decided which yet. |
|---|
| 111 | dx = point.x - m_DragRealStart.x; |
|---|
| 112 | dy = point.y - m_DragRealStart.y; |
|---|
| 113 | threshold = 8 * 8; |
|---|
| 114 | } else { |
|---|
| 115 | dx = point.x - m_DragStart.x; |
|---|
| 116 | dy = point.y - m_DragStart.y; |
|---|
| 117 | threshold = 5; |
|---|
| 118 | } |
|---|
| 119 | int dx2 = dx * dx; |
|---|
| 120 | int dy2 = dy * dy; |
|---|
| 121 | if (dx2 + dy2 < threshold) return; |
|---|
| 122 | |
|---|
| 123 | switch (m_ScaleRotateLock) { |
|---|
| 124 | case NONE: |
|---|
| 125 | if (dx2 > dy2) { |
|---|
| 126 | m_ScaleRotateLock = ROTATE; |
|---|
| 127 | // m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 128 | } else { |
|---|
| 129 | m_ScaleRotateLock = SCALE; |
|---|
| 130 | // m_View->SetCursor(GfxCore::CURSOR_ZOOM); |
|---|
| 131 | } |
|---|
| 132 | break; |
|---|
| 133 | case SCALE: |
|---|
| 134 | if (dx2 >= 8 * dy2) { |
|---|
| 135 | m_ScaleRotateLock = ROTATE; |
|---|
| 136 | // m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 137 | } |
|---|
| 138 | break; |
|---|
| 139 | case ROTATE: |
|---|
| 140 | if (dy2 >= 8 * dx2) { |
|---|
| 141 | m_ScaleRotateLock = SCALE; |
|---|
| 142 | // m_View->SetCursor(GfxCore::CURSOR_ZOOM); |
|---|
| 143 | } |
|---|
| 144 | break; |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | if (m_ScaleRotateLock == ROTATE) { |
|---|
| 148 | dy = 0; |
|---|
| 149 | } else { |
|---|
| 150 | dx = 0; |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | if (m_ReverseControls) { |
|---|
| 154 | dx = -dx; |
|---|
| 155 | dy = -dy; |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | if (m_View->GetPerspective()) { |
|---|
| 159 | if (dy) m_View->MoveViewer(-dy * .1, 0, 0); |
|---|
| 160 | } else { |
|---|
| 161 | // up/down => scale. |
|---|
| 162 | if (dy) m_View->SetScale(m_View->GetScale() * pow(1.06, 0.08 * dy)); |
|---|
| 163 | // left/right => rotate. |
|---|
| 164 | if (dx) m_View->TurnCave(Double(dx) * -0.36); |
|---|
| 165 | if (dx || dy) m_View->ForceRefresh(); |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | m_DragStart = point; |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | void GUIControl::HandleTiltRotate(wxPoint point) |
|---|
| 172 | { |
|---|
| 173 | // Handle a mouse movement during tilt/rotate mode. |
|---|
| 174 | if (m_View->IsExtendedElevation()) return; |
|---|
| 175 | |
|---|
| 176 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 177 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY); |
|---|
| 178 | |
|---|
| 179 | int dx = point.x - m_DragStart.x; |
|---|
| 180 | int dy = point.y - m_DragStart.y; |
|---|
| 181 | |
|---|
| 182 | if (m_ReverseControls != m_View->GetPerspective()) { |
|---|
| 183 | dx = -dx; |
|---|
| 184 | dy = -dy; |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | // left/right => rotate, up/down => tilt. |
|---|
| 188 | // Make tilt less sensitive than rotate as that feels better. |
|---|
| 189 | m_View->TurnCave(Double(dx) * -0.36); |
|---|
| 190 | m_View->TiltCave(Double(dy) * -0.18); |
|---|
| 191 | |
|---|
| 192 | m_View->ForceRefresh(); |
|---|
| 193 | |
|---|
| 194 | m_DragStart = point; |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| 197 | void GUIControl::HandleRotate(wxPoint point) |
|---|
| 198 | { |
|---|
| 199 | // Handle a mouse movement during rotate mode. |
|---|
| 200 | if (m_View->IsExtendedElevation()) return; |
|---|
| 201 | |
|---|
| 202 | // wxGTK (at least) fails to update the cursor while dragging. |
|---|
| 203 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 204 | |
|---|
| 205 | int dx = point.x - m_DragStart.x; |
|---|
| 206 | int dy = point.y - m_DragStart.y; |
|---|
| 207 | |
|---|
| 208 | if (m_ReverseControls != m_View->GetPerspective()) { |
|---|
| 209 | dx = -dx; |
|---|
| 210 | dy = -dy; |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | // left/right => rotate. |
|---|
| 214 | m_View->TurnCave(Double(dx) * -0.36); |
|---|
| 215 | |
|---|
| 216 | m_View->ForceRefresh(); |
|---|
| 217 | |
|---|
| 218 | m_DragStart = point; |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | void GUIControl::RestoreCursor() |
|---|
| 222 | { |
|---|
| 223 | if (m_View->ShowingMeasuringLine()) { |
|---|
| 224 | m_View->SetCursor(GfxCore::CURSOR_POINTING_HAND); |
|---|
| 225 | } else { |
|---|
| 226 | m_View->SetCursor(GfxCore::CURSOR_DEFAULT); |
|---|
| 227 | } |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | // |
|---|
| 231 | // Mouse event handling methods |
|---|
| 232 | // |
|---|
| 233 | |
|---|
| 234 | void GUIControl::OnMouseMove(wxMouseEvent& event) |
|---|
| 235 | { |
|---|
| 236 | // Mouse motion event handler. |
|---|
| 237 | if (!m_View->HasData()) return; |
|---|
| 238 | |
|---|
| 239 | // Ignore moves which don't change the position. |
|---|
| 240 | if (event.GetX() == m_DragStart.x && event.GetY() == m_DragStart.y) { |
|---|
| 241 | return; |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | static long timestamp = LONG_MIN; |
|---|
| 245 | if (dragging != NO_DRAG && m_ScaleRotateLock != NONE && timestamp != LONG_MIN) { |
|---|
| 246 | // If no motion for a second, reset the direction lock. |
|---|
| 247 | if (event.GetTimestamp() - timestamp >= 1000) { |
|---|
| 248 | m_ScaleRotateLock = NONE; |
|---|
| 249 | m_DragRealStart = m_DragStart; |
|---|
| 250 | RestoreCursor(); |
|---|
| 251 | } |
|---|
| 252 | } |
|---|
| 253 | timestamp = event.GetTimestamp(); |
|---|
| 254 | |
|---|
| 255 | wxPoint point(event.GetX(), event.GetY()); |
|---|
| 256 | |
|---|
| 257 | // Check hit-test grid (only if no buttons are pressed). |
|---|
| 258 | if (!event.LeftIsDown() && !event.MiddleIsDown() && !event.RightIsDown()) { |
|---|
| 259 | if (m_View->CheckHitTestGrid(point, false)) { |
|---|
| 260 | m_View->SetCursor(GfxCore::CURSOR_POINTING_HAND); |
|---|
| 261 | } else if (m_View->PointWithinScaleBar(point)) { |
|---|
| 262 | m_View->SetCursor(GfxCore::CURSOR_HORIZONTAL_RESIZE); |
|---|
| 263 | } else if (m_View->PointWithinCompass(point)) { |
|---|
| 264 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_HORIZONTALLY); |
|---|
| 265 | } else if (m_View->PointWithinClino(point)) { |
|---|
| 266 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
|---|
| 267 | } else { |
|---|
| 268 | RestoreCursor(); |
|---|
| 269 | } |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | // Update coordinate display if in plan view, |
|---|
| 273 | // or altitude if in elevation view. |
|---|
| 274 | m_View->SetCoords(point); |
|---|
| 275 | |
|---|
| 276 | switch (dragging) { |
|---|
| 277 | case LEFT_DRAG: |
|---|
| 278 | switch (m_LastDrag) { |
|---|
| 279 | case drag_COMPASS: |
|---|
| 280 | // Drag in heading indicator. |
|---|
| 281 | m_View->SetCompassFromPoint(point); |
|---|
| 282 | break; |
|---|
| 283 | case drag_ELEV: |
|---|
| 284 | // Drag in clinometer. |
|---|
| 285 | m_View->SetClinoFromPoint(point); |
|---|
| 286 | break; |
|---|
| 287 | case drag_SCALE: |
|---|
| 288 | m_View->SetScaleBarFromOffset(point.x - m_DragLast.x); |
|---|
| 289 | break; |
|---|
| 290 | case drag_MAIN: |
|---|
| 291 | if (event.ControlDown()) { |
|---|
| 292 | HandleTiltRotate(point); |
|---|
| 293 | } else { |
|---|
| 294 | HandleScaleRotate(point); |
|---|
| 295 | } |
|---|
| 296 | break; |
|---|
| 297 | case drag_NONE: |
|---|
| 298 | // Shouldn't happen?! FIXME: assert or something. |
|---|
| 299 | break; |
|---|
| 300 | } |
|---|
| 301 | break; |
|---|
| 302 | case MIDDLE_DRAG: |
|---|
| 303 | HandleTilt(point); |
|---|
| 304 | break; |
|---|
| 305 | case RIGHT_DRAG: |
|---|
| 306 | HandleTranslate(point); |
|---|
| 307 | break; |
|---|
| 308 | case NO_DRAG: |
|---|
| 309 | break; |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | m_DragLast = point; |
|---|
| 313 | } |
|---|
| 314 | |
|---|
| 315 | void GUIControl::OnLButtonDown(wxMouseEvent& event) |
|---|
| 316 | { |
|---|
| 317 | if (m_View->HasData()) { |
|---|
| 318 | dragging = LEFT_DRAG; |
|---|
| 319 | |
|---|
| 320 | m_DragStart = m_DragRealStart = wxPoint(event.GetX(), event.GetY()); |
|---|
| 321 | |
|---|
| 322 | if (m_View->PointWithinCompass(m_DragStart)) { |
|---|
| 323 | m_LastDrag = drag_COMPASS; |
|---|
| 324 | } else if (m_View->PointWithinClino(m_DragStart)) { |
|---|
| 325 | m_LastDrag = drag_ELEV; |
|---|
| 326 | } else if (m_View->PointWithinScaleBar(m_DragStart)) { |
|---|
| 327 | m_LastDrag = drag_SCALE; |
|---|
| 328 | } else { |
|---|
| 329 | if (event.ControlDown()) { |
|---|
| 330 | if (m_View->IsExtendedElevation()) { |
|---|
| 331 | dragging = NO_DRAG; |
|---|
| 332 | return; |
|---|
| 333 | } |
|---|
| 334 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_EITHER_WAY); |
|---|
| 335 | } else { |
|---|
| 336 | m_View->SetCursor(GfxCore::CURSOR_ZOOM_ROTATE); |
|---|
| 337 | } |
|---|
| 338 | |
|---|
| 339 | m_LastDrag = drag_MAIN; |
|---|
| 340 | m_ScaleRotateLock = NONE; |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | m_View->CaptureMouse(); |
|---|
| 344 | } |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | void GUIControl::OnLButtonUp(wxMouseEvent& event) |
|---|
| 348 | { |
|---|
| 349 | if (m_View->HasData()) { |
|---|
| 350 | if (event.GetPosition() == m_DragRealStart) { |
|---|
| 351 | // Just a "click"... |
|---|
| 352 | m_View->CheckHitTestGrid(m_DragStart, true); |
|---|
| 353 | } else if (dragging == NO_DRAG) { |
|---|
| 354 | return; |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | // m_View->RedrawIndicators(); |
|---|
| 358 | m_View->ReleaseMouse(); |
|---|
| 359 | |
|---|
| 360 | m_LastDrag = drag_NONE; |
|---|
| 361 | dragging = NO_DRAG; |
|---|
| 362 | |
|---|
| 363 | m_View->DragFinished(); |
|---|
| 364 | |
|---|
| 365 | RestoreCursor(); |
|---|
| 366 | } |
|---|
| 367 | } |
|---|
| 368 | |
|---|
| 369 | void GUIControl::OnMButtonDown(wxMouseEvent& event) |
|---|
| 370 | { |
|---|
| 371 | if (m_View->HasData() && !m_View->IsExtendedElevation()) { |
|---|
| 372 | dragging = MIDDLE_DRAG; |
|---|
| 373 | m_DragStart = wxPoint(event.GetX(), event.GetY()); |
|---|
| 374 | |
|---|
| 375 | m_View->SetCursor(GfxCore::CURSOR_ROTATE_VERTICALLY); |
|---|
| 376 | |
|---|
| 377 | m_View->CaptureMouse(); |
|---|
| 378 | } |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | void GUIControl::OnMButtonUp(wxMouseEvent&) |
|---|
| 382 | { |
|---|
| 383 | if (m_View->HasData()) { |
|---|
| 384 | dragging = NO_DRAG; |
|---|
| 385 | m_View->ReleaseMouse(); |
|---|
| 386 | m_View->DragFinished(); |
|---|
| 387 | |
|---|
| 388 | RestoreCursor(); |
|---|
| 389 | } |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | void GUIControl::OnRButtonDown(wxMouseEvent& event) |
|---|
| 393 | { |
|---|
| 394 | if (m_View->HasData()) { |
|---|
| 395 | m_DragStart = wxPoint(event.GetX(), event.GetY()); |
|---|
| 396 | |
|---|
| 397 | dragging = RIGHT_DRAG; |
|---|
| 398 | |
|---|
| 399 | m_View->SetCursor(GfxCore::CURSOR_DRAGGING_HAND); |
|---|
| 400 | m_View->CaptureMouse(); |
|---|
| 401 | } |
|---|
| 402 | } |
|---|
| 403 | |
|---|
| 404 | void GUIControl::OnRButtonUp(wxMouseEvent&) |
|---|
| 405 | { |
|---|
| 406 | m_LastDrag = drag_NONE; |
|---|
| 407 | m_View->ReleaseMouse(); |
|---|
| 408 | |
|---|
| 409 | dragging = NO_DRAG; |
|---|
| 410 | |
|---|
| 411 | RestoreCursor(); |
|---|
| 412 | |
|---|
| 413 | m_View->DragFinished(); |
|---|
| 414 | } |
|---|
| 415 | |
|---|
| 416 | void GUIControl::OnMouseWheel(wxMouseEvent& event) { |
|---|
| 417 | int dy = event.GetWheelRotation(); |
|---|
| 418 | if (m_View->GetPerspective()) { |
|---|
| 419 | m_View->MoveViewer(-dy, 0, 0); |
|---|
| 420 | } else { |
|---|
| 421 | m_View->SetScale(m_View->GetScale() * pow(1.06, -0.04 * dy)); |
|---|
| 422 | m_View->ForceRefresh(); |
|---|
| 423 | } |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | void GUIControl::OnDisplayOverlappingNames() |
|---|
| 427 | { |
|---|
| 428 | m_View->ToggleOverlappingNames(); |
|---|
| 429 | } |
|---|
| 430 | |
|---|
| 431 | void GUIControl::OnDisplayOverlappingNamesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 432 | { |
|---|
| 433 | cmd.Enable(m_View->HasData() && m_View->ShowingStationNames()); |
|---|
| 434 | cmd.Check(m_View->ShowingOverlappingNames()); |
|---|
| 435 | } |
|---|
| 436 | |
|---|
| 437 | void GUIControl::OnColourByDepth() |
|---|
| 438 | { |
|---|
| 439 | if (m_View->ColouringBy() == COLOUR_BY_DEPTH) { |
|---|
| 440 | m_View->SetColourBy(COLOUR_BY_NONE); |
|---|
| 441 | } else { |
|---|
| 442 | m_View->SetColourBy(COLOUR_BY_DEPTH); |
|---|
| 443 | } |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | void GUIControl::OnColourByDate() |
|---|
| 447 | { |
|---|
| 448 | if (m_View->ColouringBy() == COLOUR_BY_DATE) { |
|---|
| 449 | m_View->SetColourBy(COLOUR_BY_NONE); |
|---|
| 450 | } else { |
|---|
| 451 | m_View->SetColourBy(COLOUR_BY_DATE); |
|---|
| 452 | } |
|---|
| 453 | } |
|---|
| 454 | |
|---|
| 455 | void GUIControl::OnColourByDepthUpdate(wxUpdateUIEvent& cmd) |
|---|
| 456 | { |
|---|
| 457 | cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs() && !m_View->IsFlat()); |
|---|
| 458 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_DEPTH); |
|---|
| 459 | } |
|---|
| 460 | |
|---|
| 461 | void GUIControl::OnColourByDateUpdate(wxUpdateUIEvent& cmd) |
|---|
| 462 | { |
|---|
| 463 | cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs() && m_View->HasRangeOfDates()); |
|---|
| 464 | cmd.Check(m_View->ColouringBy() == COLOUR_BY_DATE); |
|---|
| 465 | } |
|---|
| 466 | |
|---|
| 467 | void GUIControl::OnShowCrosses() |
|---|
| 468 | { |
|---|
| 469 | m_View->ToggleCrosses(); |
|---|
| 470 | } |
|---|
| 471 | |
|---|
| 472 | void GUIControl::OnShowCrossesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 473 | { |
|---|
| 474 | cmd.Enable(m_View->HasData()); |
|---|
| 475 | cmd.Check(m_View->ShowingCrosses()); |
|---|
| 476 | } |
|---|
| 477 | |
|---|
| 478 | void GUIControl::OnShowStationNames() |
|---|
| 479 | { |
|---|
| 480 | m_View->ToggleStationNames(); |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | void GUIControl::OnShowStationNamesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 484 | { |
|---|
| 485 | cmd.Enable(m_View->HasData()); |
|---|
| 486 | cmd.Check(m_View->ShowingStationNames()); |
|---|
| 487 | } |
|---|
| 488 | |
|---|
| 489 | void GUIControl::OnShowSurveyLegs() |
|---|
| 490 | { |
|---|
| 491 | m_View->ToggleUndergroundLegs(); |
|---|
| 492 | } |
|---|
| 493 | |
|---|
| 494 | void GUIControl::OnShowSurveyLegsUpdate(wxUpdateUIEvent& cmd) |
|---|
| 495 | { |
|---|
| 496 | cmd.Enable(m_View->HasData() && m_View->HasUndergroundLegs()); |
|---|
| 497 | cmd.Check(m_View->ShowingUndergroundLegs()); |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | void GUIControl::OnMoveEast() |
|---|
| 501 | { |
|---|
| 502 | m_View->TurnCaveTo(90.0); |
|---|
| 503 | m_View->ForceRefresh(); |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | void GUIControl::OnMoveEastUpdate(wxUpdateUIEvent& cmd) |
|---|
| 507 | { |
|---|
| 508 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 509 | } |
|---|
| 510 | |
|---|
| 511 | void GUIControl::OnMoveNorth() |
|---|
| 512 | { |
|---|
| 513 | m_View->TurnCaveTo(0.0); |
|---|
| 514 | m_View->ForceRefresh(); |
|---|
| 515 | } |
|---|
| 516 | |
|---|
| 517 | void GUIControl::OnMoveNorthUpdate(wxUpdateUIEvent& cmd) |
|---|
| 518 | { |
|---|
| 519 | cmd.Enable(m_View->HasData()); |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | void GUIControl::OnMoveSouth() |
|---|
| 523 | { |
|---|
| 524 | m_View->TurnCaveTo(180.0); |
|---|
| 525 | m_View->ForceRefresh(); |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | void GUIControl::OnMoveSouthUpdate(wxUpdateUIEvent& cmd) |
|---|
| 529 | { |
|---|
| 530 | cmd.Enable(m_View->HasData()); |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | void GUIControl::OnMoveWest() |
|---|
| 534 | { |
|---|
| 535 | m_View->TurnCaveTo(270.0); |
|---|
| 536 | m_View->ForceRefresh(); |
|---|
| 537 | } |
|---|
| 538 | |
|---|
| 539 | void GUIControl::OnMoveWestUpdate(wxUpdateUIEvent& cmd) |
|---|
| 540 | { |
|---|
| 541 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 542 | } |
|---|
| 543 | |
|---|
| 544 | void GUIControl::OnToggleRotation() |
|---|
| 545 | { |
|---|
| 546 | m_View->ToggleRotation(); |
|---|
| 547 | } |
|---|
| 548 | |
|---|
| 549 | void GUIControl::OnToggleRotationUpdate(wxUpdateUIEvent& cmd) |
|---|
| 550 | { |
|---|
| 551 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 552 | cmd.Check(m_View->HasData() && m_View->IsRotating()); |
|---|
| 553 | } |
|---|
| 554 | |
|---|
| 555 | void GUIControl::OnReverseControls() |
|---|
| 556 | { |
|---|
| 557 | m_ReverseControls = !m_ReverseControls; |
|---|
| 558 | } |
|---|
| 559 | |
|---|
| 560 | void GUIControl::OnReverseControlsUpdate(wxUpdateUIEvent& cmd) |
|---|
| 561 | { |
|---|
| 562 | cmd.Enable(m_View->HasData()); |
|---|
| 563 | cmd.Check(m_ReverseControls); |
|---|
| 564 | } |
|---|
| 565 | |
|---|
| 566 | void GUIControl::OnReverseDirectionOfRotation() |
|---|
| 567 | { |
|---|
| 568 | m_View->ReverseRotation(); |
|---|
| 569 | } |
|---|
| 570 | |
|---|
| 571 | void GUIControl::OnReverseDirectionOfRotationUpdate(wxUpdateUIEvent& cmd) |
|---|
| 572 | { |
|---|
| 573 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 574 | } |
|---|
| 575 | |
|---|
| 576 | void GUIControl::OnSlowDown(bool accel) |
|---|
| 577 | { |
|---|
| 578 | m_View->RotateSlower(accel); |
|---|
| 579 | } |
|---|
| 580 | |
|---|
| 581 | void GUIControl::OnSlowDownUpdate(wxUpdateUIEvent& cmd) |
|---|
| 582 | { |
|---|
| 583 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 584 | } |
|---|
| 585 | |
|---|
| 586 | void GUIControl::OnSpeedUp(bool accel) |
|---|
| 587 | { |
|---|
| 588 | m_View->RotateFaster(accel); |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | void GUIControl::OnSpeedUpUpdate(wxUpdateUIEvent& cmd) |
|---|
| 592 | { |
|---|
| 593 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 594 | } |
|---|
| 595 | |
|---|
| 596 | void GUIControl::OnStepOnceAnticlockwise(bool accel) |
|---|
| 597 | { |
|---|
| 598 | if (m_View->GetPerspective()) { |
|---|
| 599 | m_View->TurnCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
|---|
| 600 | } else { |
|---|
| 601 | m_View->TurnCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
|---|
| 602 | } |
|---|
| 603 | m_View->ForceRefresh(); |
|---|
| 604 | } |
|---|
| 605 | |
|---|
| 606 | void GUIControl::OnStepOnceAnticlockwiseUpdate(wxUpdateUIEvent& cmd) |
|---|
| 607 | { |
|---|
| 608 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->IsRotating()); |
|---|
| 609 | } |
|---|
| 610 | |
|---|
| 611 | void GUIControl::OnStepOnceClockwise(bool accel) |
|---|
| 612 | { |
|---|
| 613 | if (m_View->GetPerspective()) { |
|---|
| 614 | m_View->TurnCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
|---|
| 615 | } else { |
|---|
| 616 | m_View->TurnCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
|---|
| 617 | } |
|---|
| 618 | m_View->ForceRefresh(); |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 621 | void GUIControl::OnStepOnceClockwiseUpdate(wxUpdateUIEvent& cmd) |
|---|
| 622 | { |
|---|
| 623 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->IsRotating()); |
|---|
| 624 | } |
|---|
| 625 | |
|---|
| 626 | void GUIControl::OnDefaults() |
|---|
| 627 | { |
|---|
| 628 | m_View->Defaults(); |
|---|
| 629 | } |
|---|
| 630 | |
|---|
| 631 | void GUIControl::OnDefaultsUpdate(wxUpdateUIEvent& cmd) |
|---|
| 632 | { |
|---|
| 633 | cmd.Enable(m_View->HasData()); |
|---|
| 634 | } |
|---|
| 635 | |
|---|
| 636 | void GUIControl::OnElevation() |
|---|
| 637 | { |
|---|
| 638 | // Switch to elevation view. |
|---|
| 639 | |
|---|
| 640 | m_View->SwitchToElevation(); |
|---|
| 641 | } |
|---|
| 642 | |
|---|
| 643 | void GUIControl::OnElevationUpdate(wxUpdateUIEvent& cmd) |
|---|
| 644 | { |
|---|
| 645 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingElevation()); |
|---|
| 646 | } |
|---|
| 647 | |
|---|
| 648 | void GUIControl::OnHigherViewpoint(bool accel) |
|---|
| 649 | { |
|---|
| 650 | // Raise the viewpoint. |
|---|
| 651 | if (m_View->GetPerspective()) { |
|---|
| 652 | m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
|---|
| 653 | } else { |
|---|
| 654 | m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
|---|
| 655 | } |
|---|
| 656 | m_View->ForceRefresh(); |
|---|
| 657 | } |
|---|
| 658 | |
|---|
| 659 | void GUIControl::OnHigherViewpointUpdate(wxUpdateUIEvent& cmd) |
|---|
| 660 | { |
|---|
| 661 | cmd.Enable(m_View->HasData() && m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()); |
|---|
| 662 | } |
|---|
| 663 | |
|---|
| 664 | void GUIControl::OnLowerViewpoint(bool accel) |
|---|
| 665 | { |
|---|
| 666 | // Lower the viewpoint. |
|---|
| 667 | if (m_View->GetPerspective()) { |
|---|
| 668 | m_View->TiltCave(accel ? 5.0 * ROTATE_STEP : ROTATE_STEP); |
|---|
| 669 | } else { |
|---|
| 670 | m_View->TiltCave(accel ? -5.0 * ROTATE_STEP : -ROTATE_STEP); |
|---|
| 671 | } |
|---|
| 672 | m_View->ForceRefresh(); |
|---|
| 673 | } |
|---|
| 674 | |
|---|
| 675 | void GUIControl::OnLowerViewpointUpdate(wxUpdateUIEvent& cmd) |
|---|
| 676 | { |
|---|
| 677 | cmd.Enable(m_View->HasData() && m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()); |
|---|
| 678 | } |
|---|
| 679 | |
|---|
| 680 | void GUIControl::OnPlan() |
|---|
| 681 | { |
|---|
| 682 | // Switch to plan view. |
|---|
| 683 | m_View->SwitchToPlan(); |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | void GUIControl::OnPlanUpdate(wxUpdateUIEvent& cmd) |
|---|
| 687 | { |
|---|
| 688 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation() && !m_View->ShowingPlan()); |
|---|
| 689 | } |
|---|
| 690 | |
|---|
| 691 | void GUIControl::OnShiftDisplayDown(bool accel) |
|---|
| 692 | { |
|---|
| 693 | if (m_View->GetPerspective()) |
|---|
| 694 | m_View->MoveViewer(0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0); |
|---|
| 695 | else |
|---|
| 696 | m_View->TranslateCave(0, accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT); |
|---|
| 697 | } |
|---|
| 698 | |
|---|
| 699 | void GUIControl::OnShiftDisplayDownUpdate(wxUpdateUIEvent& cmd) |
|---|
| 700 | { |
|---|
| 701 | cmd.Enable(m_View->HasData()); |
|---|
| 702 | } |
|---|
| 703 | |
|---|
| 704 | void GUIControl::OnShiftDisplayLeft(bool accel) |
|---|
| 705 | { |
|---|
| 706 | if (m_View->GetPerspective()) |
|---|
| 707 | m_View->MoveViewer(0, 0, accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT); |
|---|
| 708 | else |
|---|
| 709 | m_View->TranslateCave(accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT, 0); |
|---|
| 710 | } |
|---|
| 711 | |
|---|
| 712 | void GUIControl::OnShiftDisplayLeftUpdate(wxUpdateUIEvent& cmd) |
|---|
| 713 | { |
|---|
| 714 | cmd.Enable(m_View->HasData()); |
|---|
| 715 | } |
|---|
| 716 | |
|---|
| 717 | void GUIControl::OnShiftDisplayRight(bool accel) |
|---|
| 718 | { |
|---|
| 719 | if (m_View->GetPerspective()) |
|---|
| 720 | m_View->MoveViewer(0, 0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT); |
|---|
| 721 | else |
|---|
| 722 | m_View->TranslateCave(accel ? 5 * DISPLAY_SHIFT : DISPLAY_SHIFT, 0); |
|---|
| 723 | } |
|---|
| 724 | |
|---|
| 725 | void GUIControl::OnShiftDisplayRightUpdate(wxUpdateUIEvent& cmd) |
|---|
| 726 | { |
|---|
| 727 | cmd.Enable(m_View->HasData()); |
|---|
| 728 | } |
|---|
| 729 | |
|---|
| 730 | void GUIControl::OnShiftDisplayUp(bool accel) |
|---|
| 731 | { |
|---|
| 732 | if (m_View->GetPerspective()) |
|---|
| 733 | m_View->MoveViewer(0, accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0); |
|---|
| 734 | else |
|---|
| 735 | m_View->TranslateCave(0, accel ? -5 * DISPLAY_SHIFT : -DISPLAY_SHIFT); |
|---|
| 736 | } |
|---|
| 737 | |
|---|
| 738 | void GUIControl::OnShiftDisplayUpUpdate(wxUpdateUIEvent& cmd) |
|---|
| 739 | { |
|---|
| 740 | cmd.Enable(m_View->HasData()); |
|---|
| 741 | } |
|---|
| 742 | |
|---|
| 743 | void GUIControl::OnZoomIn(bool accel) |
|---|
| 744 | { |
|---|
| 745 | // Increase the scale. |
|---|
| 746 | |
|---|
| 747 | if (m_View->GetPerspective()) { |
|---|
| 748 | m_View->MoveViewer(accel ? 5 * FLYFREE_SHIFT : FLYFREE_SHIFT, 0, 0); |
|---|
| 749 | } else { |
|---|
| 750 | m_View->SetScale(m_View->GetScale() * (accel ? 1.1236 : 1.06)); |
|---|
| 751 | m_View->ForceRefresh(); |
|---|
| 752 | } |
|---|
| 753 | } |
|---|
| 754 | |
|---|
| 755 | void GUIControl::OnZoomInUpdate(wxUpdateUIEvent& cmd) |
|---|
| 756 | { |
|---|
| 757 | cmd.Enable(m_View->HasData()); |
|---|
| 758 | } |
|---|
| 759 | |
|---|
| 760 | void GUIControl::OnZoomOut(bool accel) |
|---|
| 761 | { |
|---|
| 762 | // Decrease the scale. |
|---|
| 763 | |
|---|
| 764 | if (m_View->GetPerspective()) { |
|---|
| 765 | m_View->MoveViewer(accel ? -5 * FLYFREE_SHIFT : -FLYFREE_SHIFT, 0, 0); |
|---|
| 766 | } else { |
|---|
| 767 | m_View->SetScale(m_View->GetScale() / (accel ? 1.1236 : 1.06)); |
|---|
| 768 | m_View->ForceRefresh(); |
|---|
| 769 | } |
|---|
| 770 | } |
|---|
| 771 | |
|---|
| 772 | void GUIControl::OnZoomOutUpdate(wxUpdateUIEvent& cmd) |
|---|
| 773 | { |
|---|
| 774 | cmd.Enable(m_View->HasData()); |
|---|
| 775 | } |
|---|
| 776 | |
|---|
| 777 | void GUIControl::OnToggleScalebar() |
|---|
| 778 | { |
|---|
| 779 | m_View->ToggleScaleBar(); |
|---|
| 780 | } |
|---|
| 781 | |
|---|
| 782 | void GUIControl::OnToggleScalebarUpdate(wxUpdateUIEvent& cmd) |
|---|
| 783 | { |
|---|
| 784 | cmd.Enable(m_View->HasData()); |
|---|
| 785 | cmd.Check(m_View->ShowingScaleBar()); |
|---|
| 786 | } |
|---|
| 787 | |
|---|
| 788 | void GUIControl::OnToggleDepthbar() /* FIXME naming */ |
|---|
| 789 | { |
|---|
| 790 | m_View->ToggleDepthBar(); |
|---|
| 791 | } |
|---|
| 792 | |
|---|
| 793 | void GUIControl::OnToggleDepthbarUpdate(wxUpdateUIEvent& cmd) |
|---|
| 794 | { |
|---|
| 795 | cmd.Enable(m_View->HasData() && m_View->ColouringBy() == COLOUR_BY_DEPTH); |
|---|
| 796 | cmd.Check(m_View->ShowingDepthBar()); |
|---|
| 797 | } |
|---|
| 798 | |
|---|
| 799 | void GUIControl::OnViewCompass() |
|---|
| 800 | { |
|---|
| 801 | m_View->ToggleCompass(); |
|---|
| 802 | } |
|---|
| 803 | |
|---|
| 804 | void GUIControl::OnViewCompassUpdate(wxUpdateUIEvent& cmd) |
|---|
| 805 | { |
|---|
| 806 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 807 | cmd.Check(m_View->ShowingCompass()); |
|---|
| 808 | } |
|---|
| 809 | |
|---|
| 810 | void GUIControl::OnViewClino() |
|---|
| 811 | { |
|---|
| 812 | m_View->ToggleClino(); |
|---|
| 813 | } |
|---|
| 814 | |
|---|
| 815 | void GUIControl::OnViewClinoUpdate(wxUpdateUIEvent& cmd) |
|---|
| 816 | { |
|---|
| 817 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 818 | cmd.Check(m_View->ShowingClino()); |
|---|
| 819 | } |
|---|
| 820 | |
|---|
| 821 | void GUIControl::OnShowSurface() |
|---|
| 822 | { |
|---|
| 823 | m_View->ToggleSurfaceLegs(); |
|---|
| 824 | } |
|---|
| 825 | |
|---|
| 826 | void GUIControl::OnShowSurfaceUpdate(wxUpdateUIEvent& cmd) |
|---|
| 827 | { |
|---|
| 828 | cmd.Enable(m_View->HasData() && m_View->HasSurfaceLegs()); |
|---|
| 829 | cmd.Check(m_View->ShowingSurfaceLegs()); |
|---|
| 830 | } |
|---|
| 831 | |
|---|
| 832 | void GUIControl::OnShowEntrances() |
|---|
| 833 | { |
|---|
| 834 | m_View->ToggleEntrances(); |
|---|
| 835 | } |
|---|
| 836 | |
|---|
| 837 | void GUIControl::OnShowEntrancesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 838 | { |
|---|
| 839 | cmd.Enable(m_View->HasData() && (m_View->GetNumEntrances() > 0)); |
|---|
| 840 | cmd.Check(m_View->ShowingEntrances()); |
|---|
| 841 | } |
|---|
| 842 | |
|---|
| 843 | void GUIControl::OnShowFixedPts() |
|---|
| 844 | { |
|---|
| 845 | m_View->ToggleFixedPts(); |
|---|
| 846 | } |
|---|
| 847 | |
|---|
| 848 | void GUIControl::OnShowFixedPtsUpdate(wxUpdateUIEvent& cmd) |
|---|
| 849 | { |
|---|
| 850 | cmd.Enable(m_View->HasData() && (m_View->GetNumFixedPts() > 0)); |
|---|
| 851 | cmd.Check(m_View->ShowingFixedPts()); |
|---|
| 852 | } |
|---|
| 853 | |
|---|
| 854 | void GUIControl::OnShowExportedPts() |
|---|
| 855 | { |
|---|
| 856 | m_View->ToggleExportedPts(); |
|---|
| 857 | } |
|---|
| 858 | |
|---|
| 859 | void GUIControl::OnShowExportedPtsUpdate(wxUpdateUIEvent& cmd) |
|---|
| 860 | { |
|---|
| 861 | cmd.Enable(m_View->HasData() && (m_View->GetNumExportedPts() > 0)); |
|---|
| 862 | cmd.Check(m_View->ShowingExportedPts()); |
|---|
| 863 | } |
|---|
| 864 | |
|---|
| 865 | void GUIControl::OnViewGrid() |
|---|
| 866 | { |
|---|
| 867 | m_View->ToggleGrid(); |
|---|
| 868 | } |
|---|
| 869 | |
|---|
| 870 | void GUIControl::OnViewGridUpdate(wxUpdateUIEvent& cmd) |
|---|
| 871 | { |
|---|
| 872 | cmd.Enable(m_View->HasData()); |
|---|
| 873 | cmd.Check(m_View->ShowingGrid()); |
|---|
| 874 | } |
|---|
| 875 | |
|---|
| 876 | void GUIControl::OnIndicatorsUpdate(wxUpdateUIEvent& cmd) |
|---|
| 877 | { |
|---|
| 878 | cmd.Enable(m_View->HasData()); |
|---|
| 879 | } |
|---|
| 880 | |
|---|
| 881 | void GUIControl::OnViewPerspective() |
|---|
| 882 | { |
|---|
| 883 | m_View->TogglePerspective(); |
|---|
| 884 | // Force update of coordinate display. |
|---|
| 885 | if (m_View->GetPerspective()) { |
|---|
| 886 | m_View->MoveViewer(0, 0, 0); |
|---|
| 887 | } else { |
|---|
| 888 | m_View->ClearCoords(); |
|---|
| 889 | } |
|---|
| 890 | } |
|---|
| 891 | |
|---|
| 892 | void GUIControl::OnViewPerspectiveUpdate(wxUpdateUIEvent& cmd) |
|---|
| 893 | { |
|---|
| 894 | cmd.Enable(m_View->HasData() && !m_View->IsExtendedElevation()); |
|---|
| 895 | cmd.Check(m_View->GetPerspective()); |
|---|
| 896 | } |
|---|
| 897 | |
|---|
| 898 | void GUIControl::OnViewSmoothShading() |
|---|
| 899 | { |
|---|
| 900 | m_View->ToggleSmoothShading(); |
|---|
| 901 | } |
|---|
| 902 | |
|---|
| 903 | void GUIControl::OnViewSmoothShadingUpdate(wxUpdateUIEvent& cmd) |
|---|
| 904 | { |
|---|
| 905 | cmd.Enable(m_View->HasData()); |
|---|
| 906 | cmd.Check(m_View->GetSmoothShading()); |
|---|
| 907 | } |
|---|
| 908 | |
|---|
| 909 | void GUIControl::OnViewTextured() |
|---|
| 910 | { |
|---|
| 911 | m_View->ToggleTextured(); |
|---|
| 912 | } |
|---|
| 913 | |
|---|
| 914 | void GUIControl::OnViewTexturedUpdate(wxUpdateUIEvent& cmd) |
|---|
| 915 | { |
|---|
| 916 | cmd.Enable(m_View->HasData()); |
|---|
| 917 | cmd.Check(m_View->GetTextured()); |
|---|
| 918 | } |
|---|
| 919 | |
|---|
| 920 | void GUIControl::OnViewFog() |
|---|
| 921 | { |
|---|
| 922 | m_View->ToggleFog(); |
|---|
| 923 | } |
|---|
| 924 | |
|---|
| 925 | void GUIControl::OnViewFogUpdate(wxUpdateUIEvent& cmd) |
|---|
| 926 | { |
|---|
| 927 | cmd.Enable(m_View->HasData()); |
|---|
| 928 | cmd.Check(m_View->GetFog()); |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | void GUIControl::OnViewSmoothLines() |
|---|
| 932 | { |
|---|
| 933 | m_View->ToggleAntiAlias(); |
|---|
| 934 | } |
|---|
| 935 | |
|---|
| 936 | void GUIControl::OnViewSmoothLinesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 937 | { |
|---|
| 938 | cmd.Enable(m_View->HasData()); |
|---|
| 939 | cmd.Check(m_View->GetAntiAlias()); |
|---|
| 940 | } |
|---|
| 941 | |
|---|
| 942 | void GUIControl::OnToggleMetric() |
|---|
| 943 | { |
|---|
| 944 | m_View->ToggleMetric(); |
|---|
| 945 | |
|---|
| 946 | wxConfigBase::Get()->Write("metric", m_View->GetMetric()); |
|---|
| 947 | wxConfigBase::Get()->Flush(); |
|---|
| 948 | } |
|---|
| 949 | |
|---|
| 950 | void GUIControl::OnToggleMetricUpdate(wxUpdateUIEvent& cmd) |
|---|
| 951 | { |
|---|
| 952 | cmd.Enable(m_View->HasData()); |
|---|
| 953 | cmd.Check(m_View->GetMetric()); |
|---|
| 954 | } |
|---|
| 955 | |
|---|
| 956 | void GUIControl::OnToggleDegrees() |
|---|
| 957 | { |
|---|
| 958 | m_View->ToggleDegrees(); |
|---|
| 959 | |
|---|
| 960 | wxConfigBase::Get()->Write("degrees", m_View->GetDegrees()); |
|---|
| 961 | wxConfigBase::Get()->Flush(); |
|---|
| 962 | } |
|---|
| 963 | |
|---|
| 964 | void GUIControl::OnToggleDegreesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 965 | { |
|---|
| 966 | cmd.Enable(m_View->HasData()); |
|---|
| 967 | cmd.Check(m_View->GetDegrees()); |
|---|
| 968 | } |
|---|
| 969 | |
|---|
| 970 | void GUIControl::OnToggleTubes() |
|---|
| 971 | { |
|---|
| 972 | m_View->ToggleTubes(); |
|---|
| 973 | } |
|---|
| 974 | |
|---|
| 975 | void GUIControl::OnToggleTubesUpdate(wxUpdateUIEvent& cmd) |
|---|
| 976 | { |
|---|
| 977 | cmd.Enable(m_View->HasData() && m_View->HasTubes()); |
|---|
| 978 | cmd.Check(m_View->GetTubes()); |
|---|
| 979 | } |
|---|
| 980 | |
|---|
| 981 | void GUIControl::OnCancelDistLine() |
|---|
| 982 | { |
|---|
| 983 | m_View->ClearTreeSelection(); |
|---|
| 984 | } |
|---|
| 985 | |
|---|
| 986 | void GUIControl::OnCancelDistLineUpdate(wxUpdateUIEvent& cmd) |
|---|
| 987 | { |
|---|
| 988 | cmd.Enable(m_View->ShowingMeasuringLine()); |
|---|
| 989 | } |
|---|
| 990 | |
|---|
| 991 | void GUIControl::OnKeyPress(wxKeyEvent &e) |
|---|
| 992 | { |
|---|
| 993 | if (!m_View->HasData()) { |
|---|
| 994 | e.Skip(); |
|---|
| 995 | return; |
|---|
| 996 | } |
|---|
| 997 | |
|---|
| 998 | // The changelog says this is meant to keep animation going while keys are |
|---|
| 999 | // pressed, but that happens anyway (on linux at least - perhaps it helps |
|---|
| 1000 | // on windows?) FIXME : check! |
|---|
| 1001 | //bool refresh = m_View->Animate(); |
|---|
| 1002 | |
|---|
| 1003 | switch (e.m_keyCode) { |
|---|
| 1004 | case '/': case '?': |
|---|
| 1005 | if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()) |
|---|
| 1006 | OnLowerViewpoint(e.m_shiftDown); |
|---|
| 1007 | break; |
|---|
| 1008 | case '\'': case '@': case '"': // both shifted forms - US and UK kbd |
|---|
| 1009 | if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()) |
|---|
| 1010 | OnHigherViewpoint(e.m_shiftDown); |
|---|
| 1011 | break; |
|---|
| 1012 | case 'C': case 'c': |
|---|
| 1013 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1014 | OnStepOnceAnticlockwise(e.m_shiftDown); |
|---|
| 1015 | break; |
|---|
| 1016 | case 'V': case 'v': |
|---|
| 1017 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1018 | OnStepOnceClockwise(e.m_shiftDown); |
|---|
| 1019 | break; |
|---|
| 1020 | case ']': case '}': |
|---|
| 1021 | OnZoomIn(e.m_shiftDown); |
|---|
| 1022 | break; |
|---|
| 1023 | case '[': case '{': |
|---|
| 1024 | OnZoomOut(e.m_shiftDown); |
|---|
| 1025 | break; |
|---|
| 1026 | case 'N': case 'n': |
|---|
| 1027 | OnMoveNorth(); |
|---|
| 1028 | break; |
|---|
| 1029 | case 'S': case 's': |
|---|
| 1030 | OnMoveSouth(); |
|---|
| 1031 | break; |
|---|
| 1032 | case 'E': case 'e': |
|---|
| 1033 | if (!m_View->IsExtendedElevation()) |
|---|
| 1034 | OnMoveEast(); |
|---|
| 1035 | break; |
|---|
| 1036 | case 'W': case 'w': |
|---|
| 1037 | if (!m_View->IsExtendedElevation()) |
|---|
| 1038 | OnMoveWest(); |
|---|
| 1039 | break; |
|---|
| 1040 | case 'Z': case 'z': |
|---|
| 1041 | if (!m_View->IsExtendedElevation()) |
|---|
| 1042 | OnSpeedUp(e.m_shiftDown); |
|---|
| 1043 | break; |
|---|
| 1044 | case 'X': case 'x': |
|---|
| 1045 | if (!m_View->IsExtendedElevation()) |
|---|
| 1046 | OnSlowDown(e.m_shiftDown); |
|---|
| 1047 | break; |
|---|
| 1048 | case 'R': case 'r': |
|---|
| 1049 | if (!m_View->IsExtendedElevation()) |
|---|
| 1050 | OnReverseDirectionOfRotation(); |
|---|
| 1051 | break; |
|---|
| 1052 | case 'P': case 'p': |
|---|
| 1053 | if (!m_View->IsExtendedElevation() && !m_View->ShowingPlan()) |
|---|
| 1054 | OnPlan(); |
|---|
| 1055 | break; |
|---|
| 1056 | case 'L': case 'l': |
|---|
| 1057 | if (!m_View->IsExtendedElevation() && !m_View->ShowingElevation()) |
|---|
| 1058 | OnElevation(); |
|---|
| 1059 | break; |
|---|
| 1060 | case 'O': case 'o': |
|---|
| 1061 | OnDisplayOverlappingNames(); |
|---|
| 1062 | break; |
|---|
| 1063 | case WXK_DELETE: |
|---|
| 1064 | OnDefaults(); |
|---|
| 1065 | break; |
|---|
| 1066 | case WXK_RETURN: |
|---|
| 1067 | // For compatibility with older versions. |
|---|
| 1068 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1069 | m_View->StartRotation(); |
|---|
| 1070 | break; |
|---|
| 1071 | case WXK_SPACE: |
|---|
| 1072 | if (!m_View->IsExtendedElevation()) |
|---|
| 1073 | OnToggleRotation(); |
|---|
| 1074 | break; |
|---|
| 1075 | case WXK_LEFT: |
|---|
| 1076 | if (e.m_controlDown) { |
|---|
| 1077 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1078 | OnStepOnceAnticlockwise(e.m_shiftDown); |
|---|
| 1079 | } else { |
|---|
| 1080 | OnShiftDisplayLeft(e.m_shiftDown); |
|---|
| 1081 | } |
|---|
| 1082 | break; |
|---|
| 1083 | case WXK_RIGHT: |
|---|
| 1084 | if (e.m_controlDown) { |
|---|
| 1085 | if (!m_View->IsExtendedElevation() && !m_View->IsRotating()) |
|---|
| 1086 | OnStepOnceClockwise(e.m_shiftDown); |
|---|
| 1087 | } else { |
|---|
| 1088 | OnShiftDisplayRight(e.m_shiftDown); |
|---|
| 1089 | } |
|---|
| 1090 | break; |
|---|
| 1091 | case WXK_UP: |
|---|
| 1092 | if (e.m_controlDown) { |
|---|
| 1093 | if (m_View->CanRaiseViewpoint() && !m_View->IsExtendedElevation()) |
|---|
| 1094 | OnHigherViewpoint(e.m_shiftDown); |
|---|
| 1095 | } else { |
|---|
| 1096 | OnShiftDisplayUp(e.m_shiftDown); |
|---|
| 1097 | } |
|---|
| 1098 | break; |
|---|
| 1099 | case WXK_DOWN: |
|---|
| 1100 | if (e.m_controlDown) { |
|---|
| 1101 | if (m_View->CanLowerViewpoint() && !m_View->IsExtendedElevation()) |
|---|
| 1102 | OnLowerViewpoint(e.m_shiftDown); |
|---|
| 1103 | } else { |
|---|
| 1104 | OnShiftDisplayDown(e.m_shiftDown); |
|---|
| 1105 | } |
|---|
| 1106 | break; |
|---|
| 1107 | case WXK_ESCAPE: |
|---|
| 1108 | if (m_View->ShowingMeasuringLine()) { |
|---|
| 1109 | OnCancelDistLine(); |
|---|
| 1110 | } |
|---|
| 1111 | break; |
|---|
| 1112 | default: |
|---|
| 1113 | e.Skip(); |
|---|
| 1114 | } |
|---|
| 1115 | |
|---|
| 1116 | //if (refresh) m_View->ForceRefresh(); |
|---|
| 1117 | } |
|---|
| 1118 | |
|---|
| 1119 | void GUIControl::OnViewFullScreenUpdate(wxUpdateUIEvent& cmd) |
|---|
| 1120 | { |
|---|
| 1121 | cmd.Enable(m_View->HasData()); |
|---|
| 1122 | cmd.Check(m_View->IsFullScreen()); |
|---|
| 1123 | } |
|---|
| 1124 | |
|---|
| 1125 | void GUIControl::OnViewFullScreen() |
|---|
| 1126 | { |
|---|
| 1127 | m_View->FullScreenMode(); |
|---|
| 1128 | } |
|---|
| 1129 | |
|---|
| 1130 | void GUIControl::OnViewBoundingBoxUpdate(wxUpdateUIEvent& cmd) |
|---|
| 1131 | { |
|---|
| 1132 | cmd.Enable(m_View->HasData()); |
|---|
| 1133 | cmd.Check(m_View->DisplayingBoundingBox()); |
|---|
| 1134 | } |
|---|
| 1135 | |
|---|
| 1136 | void GUIControl::OnViewBoundingBox() |
|---|
| 1137 | { |
|---|
| 1138 | m_View->ToggleBoundingBox(); |
|---|
| 1139 | } |
|---|