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