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