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