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