|
38 | 38 | #include <vtkCallbackCommand.h>
|
39 | 39 | #include <vtkInteractorStyle.h>
|
40 | 40 | #include <vtkMath.h>
|
41 |
| -#include <vtkVRMenuWidget.h> |
42 | 41 | #include <vtkObjectFactory.h>
|
43 | 42 | #include <vtkPoints.h>
|
44 | 43 | #include <vtkRenderer.h>
|
@@ -251,222 +250,12 @@ void vtkVirtualRealityViewInteractorStyle::PrintSelf(ostream& os, vtkIndent inde
|
251 | 250 | this->Superclass::PrintSelf(os,indent);
|
252 | 251 | }
|
253 | 252 |
|
254 |
| -//---------------------------------------------------------------------------- |
255 |
| -void vtkVirtualRealityViewInteractorStyle::SetInteractor(vtkRenderWindowInteractor *i) |
256 |
| -{ |
257 |
| - if (i == this->Interactor) |
258 |
| - { |
259 |
| - return; |
260 |
| - } |
261 |
| - |
262 |
| - this->Superclass::SetInteractor(i); |
263 |
| -} |
264 |
| - |
265 | 253 | //----------------------------------------------------------------------------
|
266 | 254 | void vtkVirtualRealityViewInteractorStyle::SetDisplayableManagers(vtkMRMLDisplayableManagerGroup* displayableManagers)
|
267 | 255 | {
|
268 | 256 | this->DisplayableManagers = displayableManagers;
|
269 | 257 | }
|
270 | 258 |
|
271 |
| -//---------------------------------------------------------------------------- |
272 |
| -void vtkVirtualRealityViewInteractorStyle::OnMove3D(vtkEventData* edata) |
273 |
| -{ |
274 |
| - vtkEventDataDevice3D* edd = edata->GetAsEventDataDevice3D(); |
275 |
| - if (!edd) |
276 |
| - { |
277 |
| - return; |
278 |
| - } |
279 |
| - |
280 |
| - // Retrieve device type |
281 |
| - int idev = static_cast<int>(edd->GetDevice()); |
282 |
| - |
283 |
| - if (edd->GetDevice() == vtkEventDataDevice::HeadMountedDisplay) |
284 |
| - { |
285 |
| - edd->GetWorldDirection(this->HeadsetDir); |
286 |
| - } |
287 |
| - |
288 |
| - // Update current state |
289 |
| - int x = this->Interactor->GetEventPosition()[0]; |
290 |
| - int y = this->Interactor->GetEventPosition()[1]; |
291 |
| - |
292 |
| - // Set current state and interaction prop |
293 |
| - this->InteractionProp = this->InteractionProps[idev]; |
294 |
| - |
295 |
| - auto interactionState = this->InteractionState[idev]; |
296 |
| - switch (interactionState) |
297 |
| - { |
298 |
| - case VTKIS_POSITION_PROP: |
299 |
| - this->FindPokedRenderer(x, y); |
300 |
| - this->PositionProp(edd); |
301 |
| - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); |
302 |
| - break; |
303 |
| - case VTKIS_DOLLY: |
304 |
| - case VTKIS_GROUNDMOVEMENT: |
305 |
| - case VTKIS_ELEVATION: |
306 |
| - this->FindPokedRenderer(x, y); |
307 |
| - this->Movement3D(interactionState, edd); |
308 |
| - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); |
309 |
| - break; |
310 |
| - case VTKIS_CLIP: |
311 |
| - this->FindPokedRenderer(x, y); |
312 |
| - this->Clip(edd); |
313 |
| - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); |
314 |
| - break; |
315 |
| - case VTKIS_USCALE: |
316 |
| - this->FindPokedRenderer(x, y); |
317 |
| - this->UniformScale(); |
318 |
| - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); |
319 |
| - break; |
320 |
| - default: |
321 |
| - vtkDebugMacro(<< "OnMove3D: unknown interaction state " << idev << ": " |
322 |
| - << this->InteractionState[idev]); |
323 |
| - break; |
324 |
| - } |
325 |
| - |
326 |
| - // Update rays |
327 |
| - this->UpdateRay(edd->GetDevice()); |
328 |
| -} |
329 |
| - |
330 |
| -//---------------------------------------------------------------------------- |
331 |
| -void vtkVirtualRealityViewInteractorStyle::OnSelect3D(vtkEventData* edata) |
332 |
| -{ |
333 |
| - vtkEventDataDevice3D* bd = edata->GetAsEventDataDevice3D(); |
334 |
| - if (!bd) |
335 |
| - { |
336 |
| - return; |
337 |
| - } |
338 |
| - |
339 |
| - int x = this->Interactor->GetEventPosition()[0]; |
340 |
| - int y = this->Interactor->GetEventPosition()[1]; |
341 |
| - this->FindPokedRenderer(x, y); |
342 |
| - |
343 |
| - decltype(this->InputMap)::key_type key(vtkCommand::Select3DEvent, bd->GetAction()); |
344 |
| - auto it = this->InputMap.find(key); |
345 |
| - if (it == this->InputMap.end()) |
346 |
| - { |
347 |
| - return; |
348 |
| - } |
349 |
| - |
350 |
| - int state = it->second; |
351 |
| - |
352 |
| - // if grab mode then convert event data into where the ray is intersecting geometry |
353 |
| - switch (bd->GetAction()) |
354 |
| - { |
355 |
| - case vtkEventDataAction::Press: |
356 |
| - case vtkEventDataAction::Touch: |
357 |
| - this->StartAction(state, bd); |
358 |
| - break; |
359 |
| - case vtkEventDataAction::Release: |
360 |
| - case vtkEventDataAction::Untouch: |
361 |
| - this->EndAction(state, bd); |
362 |
| - break; |
363 |
| - default: |
364 |
| - break; |
365 |
| - } |
366 |
| -} |
367 |
| - |
368 |
| -//------------------------------------------------------------------------------ |
369 |
| -void vtkVirtualRealityViewInteractorStyle::OnViewerMovement3D(vtkEventData* edata) |
370 |
| -{ |
371 |
| - if (this->Style == vtkVRInteractorStyle::FLY_STYLE) |
372 |
| - { |
373 |
| - this->Movement3D(VTKIS_DOLLY, edata); |
374 |
| - } |
375 |
| - else if (this->Style == vtkVRInteractorStyle::GROUNDED_STYLE) |
376 |
| - { |
377 |
| - this->Movement3D(VTKIS_GROUNDMOVEMENT, edata); |
378 |
| - } |
379 |
| -} |
380 |
| - |
381 |
| -//------------------------------------------------------------------------------ |
382 |
| -void vtkVirtualRealityViewInteractorStyle::Movement3D(int interactionState, vtkEventData* edata) |
383 |
| -{ |
384 |
| - vtkEventDataDevice3D* edd = edata->GetAsEventDataDevice3D(); |
385 |
| - if (!edd) |
386 |
| - { |
387 |
| - return; |
388 |
| - } |
389 |
| - |
390 |
| - // Retrieve device type |
391 |
| - int idev = static_cast<int>(edd->GetDevice()); |
392 |
| - |
393 |
| - // Update current state |
394 |
| - int x = this->Interactor->GetEventPosition()[0]; |
395 |
| - int y = this->Interactor->GetEventPosition()[1]; |
396 |
| - this->FindPokedRenderer(x, y); |
397 |
| - |
398 |
| - // Set current state and interaction prop |
399 |
| - this->InteractionProp = this->InteractionProps[idev]; |
400 |
| - |
401 |
| - double const* pos = edd->GetTrackPadPosition(); |
402 |
| - |
403 |
| - if (edd->GetAction() == vtkEventDataAction::Press) |
404 |
| - { |
405 |
| - this->StartAction(interactionState, edd); |
406 |
| - this->LastTrackPadPosition[0] = 0.0; |
407 |
| - this->LastTrackPadPosition[1] = 0.0; |
408 |
| - this->LastGroundMovementTrackPadPosition[0] = 0.0; |
409 |
| - this->LastGroundMovementTrackPadPosition[1] = 0.0; |
410 |
| - this->LastElevationTrackPadPosition[0] = 0.0; |
411 |
| - this->LastElevationTrackPadPosition[1] = 0.0; |
412 |
| - return; |
413 |
| - } |
414 |
| - |
415 |
| - if (edd->GetAction() == vtkEventDataAction::Release) |
416 |
| - { |
417 |
| - this->EndAction(interactionState, edd); |
418 |
| - return; |
419 |
| - } |
420 |
| - |
421 |
| - // If the input event is from a joystick and is away from the center then |
422 |
| - // call start. When the joystick returns to the center, call end. |
423 |
| - if ((edd->GetInput() == vtkEventDataDeviceInput::Joystick || |
424 |
| - edd->GetInput() == vtkEventDataDeviceInput::TrackPad) && |
425 |
| - this->InteractionState[idev] != interactionState && fabs(pos[1]) > 0.1) |
426 |
| - { |
427 |
| - this->StartAction(interactionState, edd); |
428 |
| - this->LastTrackPadPosition[0] = 0.0; |
429 |
| - this->LastTrackPadPosition[1] = 0.0; |
430 |
| - this->LastGroundMovementTrackPadPosition[0] = 0.0; |
431 |
| - this->LastGroundMovementTrackPadPosition[1] = 0.0; |
432 |
| - this->LastElevationTrackPadPosition[0] = 0.0; |
433 |
| - this->LastElevationTrackPadPosition[1] = 0.0; |
434 |
| - return; |
435 |
| - } |
436 |
| - |
437 |
| - if (this->InteractionState[idev] == interactionState) |
438 |
| - { |
439 |
| - // Stop when returning to the center on the joystick |
440 |
| - if ((edd->GetInput() == vtkEventDataDeviceInput::Joystick || |
441 |
| - edd->GetInput() == vtkEventDataDeviceInput::TrackPad) && |
442 |
| - fabs(pos[1]) < 0.1) |
443 |
| - { |
444 |
| - this->EndAction(interactionState, edd); |
445 |
| - return; |
446 |
| - } |
447 |
| - |
448 |
| - // Do the 3D movement corresponding to the interaction state |
449 |
| - switch (interactionState) |
450 |
| - { |
451 |
| - case VTKIS_DOLLY: |
452 |
| - this->Dolly3D(edd); |
453 |
| - break; |
454 |
| - case VTKIS_GROUNDMOVEMENT: |
455 |
| - this->GroundMovement3D(edd); |
456 |
| - break; |
457 |
| - case VTKIS_ELEVATION: |
458 |
| - this->Elevation3D(edd); |
459 |
| - break; |
460 |
| - default: |
461 |
| - break; |
462 |
| - } |
463 |
| - |
464 |
| - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); |
465 |
| - return; |
466 |
| - } |
467 |
| -} |
468 |
| - |
469 |
| - |
470 | 259 | //----------------------------------------------------------------------------
|
471 | 260 | // Interaction methods
|
472 | 261 | //----------------------------------------------------------------------------
|
@@ -823,115 +612,6 @@ int vtkVirtualRealityViewInteractorStyle::GetMappedAction(vtkCommand::EventIds e
|
823 | 612 | return VTKIS_NONE;
|
824 | 613 | }
|
825 | 614 |
|
826 |
| -//---------------------------------------------------------------------------- |
827 |
| -void vtkVirtualRealityViewInteractorStyle::StartAction(int state, vtkEventDataDevice3D* edata) |
828 |
| -{ |
829 |
| - switch (state) |
830 |
| - { |
831 |
| - case VTKIS_POSITION_PROP: |
832 |
| - this->StartPositionProp(edata); |
833 |
| - break; |
834 |
| - case VTKIS_DOLLY: |
835 |
| - this->StartMovement3D(state, edata); |
836 |
| - this->LastDolly3DEventTime->StartTimer(); |
837 |
| - break; |
838 |
| - case VTKIS_GROUNDMOVEMENT: |
839 |
| - this->StartMovement3D(state, edata); |
840 |
| - this->LastGroundMovement3DEventTime->StartTimer(); |
841 |
| - break; |
842 |
| - case VTKIS_ELEVATION: |
843 |
| - this->StartMovement3D(state, edata); |
844 |
| - this->LastElevation3DEventTime->StartTimer(); |
845 |
| - break; |
846 |
| - case VTKIS_CLIP: |
847 |
| - this->StartClip(edata); |
848 |
| - break; |
849 |
| - case VTKIS_PICK: |
850 |
| - this->StartPick(edata); |
851 |
| - break; |
852 |
| - case VTKIS_LOAD_CAMERA_POSE: |
853 |
| - this->StartLoadCamPose(edata); |
854 |
| - break; |
855 |
| - case VTKIS_MENU: |
856 |
| - // Menu is only displayed upon action end (e.g. button release) |
857 |
| - break; |
858 |
| - default: |
859 |
| - vtkDebugMacro(<< "StartAction: unknown state " << state); |
860 |
| - break; |
861 |
| - } |
862 |
| -} |
863 |
| - |
864 |
| -//---------------------------------------------------------------------------- |
865 |
| -void vtkVirtualRealityViewInteractorStyle::EndAction(int state, vtkEventDataDevice3D* edata) |
866 |
| -{ |
867 |
| - switch (state) |
868 |
| - { |
869 |
| - case VTKIS_POSITION_PROP: |
870 |
| - this->EndPositionProp(edata); |
871 |
| - break; |
872 |
| - case VTKIS_DOLLY: |
873 |
| - this->EndMovement3D(edata); |
874 |
| - this->LastDolly3DEventTime->StopTimer(); |
875 |
| - break; |
876 |
| - case VTKIS_GROUNDMOVEMENT: |
877 |
| - this->EndMovement3D(edata); |
878 |
| - this->LastGroundMovement3DEventTime->StopTimer(); |
879 |
| - break; |
880 |
| - case VTKIS_ELEVATION: |
881 |
| - this->EndMovement3D(edata); |
882 |
| - this->LastElevation3DEventTime->StopTimer(); |
883 |
| - break; |
884 |
| - case VTKIS_CLIP: |
885 |
| - this->EndClip(edata); |
886 |
| - break; |
887 |
| - case VTKIS_PICK: |
888 |
| - this->EndPick(edata); |
889 |
| - break; |
890 |
| - case VTKIS_MENU: |
891 |
| - this->Menu->SetInteractor(this->Interactor); |
892 |
| - this->Menu->Show(edata); |
893 |
| - break; |
894 |
| - case VTKIS_LOAD_CAMERA_POSE: |
895 |
| - this->EndLoadCamPose(edata); |
896 |
| - break; |
897 |
| - case VTKIS_TOGGLE_DRAW_CONTROLS: |
898 |
| - this->ToggleDrawControls(); |
899 |
| - break; |
900 |
| - case VTKIS_EXIT: |
901 |
| - if (this->Interactor) |
902 |
| - { |
903 |
| - this->Interactor->ExitCallback(); |
904 |
| - } |
905 |
| - break; |
906 |
| - case VTKIS_TELEPORTATION: |
907 |
| - this->Teleportation3D(edata); |
908 |
| - break; |
909 |
| - case VTKIS_USCALE: |
910 |
| - this->EndUniformScale(); |
911 |
| - break; |
912 |
| - default: |
913 |
| - vtkDebugMacro(<< "EndAction: unknown state " << state); |
914 |
| - break; |
915 |
| - } |
916 |
| - |
917 |
| - // Reset complex gesture state because a button has been released |
918 |
| - for (int d = 0; d < vtkEventDataNumberOfDevices; ++d) |
919 |
| - { |
920 |
| - switch (this->InteractionState[d]) |
921 |
| - { |
922 |
| - case VTKIS_PAN: |
923 |
| - case VTKIS_ZOOM: |
924 |
| - case VTKIS_ROTATE: |
925 |
| - this->InteractionState[d] = VTKIS_NONE; |
926 |
| - break; |
927 |
| - default: |
928 |
| - vtkDebugMacro(<< "EndAction: unknown interaction state " << d << ": " |
929 |
| - << this->InteractionState[d]); |
930 |
| - break; |
931 |
| - } |
932 |
| - } |
933 |
| -} |
934 |
| - |
935 | 615 | //---------------------------------------------------------------------------
|
936 | 616 | vtkMRMLScene* vtkVirtualRealityViewInteractorStyle::GetMRMLScene()
|
937 | 617 | {
|
|
0 commit comments