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