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