VTK
vtkOpenVRInteractorStyle.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkOpenVRInteractorStyle.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
20 #ifndef vtkOpenVRInteractorStyle_h
21 #define vtkOpenVRInteractorStyle_h
22 
23 #include "vtkRenderingOpenVRModule.h" // For export macro
24 
25 #include "vtkInteractorStyle3D.h"
26 #include "vtkOpenVRRenderWindow.h" // for enums
27 #include "vtkNew.h" // for ivars
28 #include "vtkEventData.h" // for enums
29 
30 class vtkCell;
31 class vtkPlane;
36 class vtkTextActor3D;
37 class vtkSelection;
38 class vtkSphereSource;
39 
40 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRInteractorStyle : public vtkInteractorStyle3D
41 {
42 public:
43  static vtkOpenVRInteractorStyle *New();
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
48 
51  void OnButton3D(vtkEventData *edata) override;
52  void OnMove3D(vtkEventData *edata) override;
54 
56 
59  virtual void StartPick(vtkEventDataDevice3D *);
60  virtual void EndPick(vtkEventDataDevice3D *);
61  virtual void StartLoadCamPose(vtkEventDataDevice3D *);
62  virtual void EndLoadCamPose(vtkEventDataDevice3D *);
63  virtual void StartPositionProp(vtkEventDataDevice3D *);
64  virtual void EndPositionProp(vtkEventDataDevice3D *);
65  virtual void StartClip(vtkEventDataDevice3D *);
66  virtual void EndClip(vtkEventDataDevice3D *);
67  virtual void StartDolly3D(vtkEventDataDevice3D *);
68  virtual void EndDolly3D(vtkEventDataDevice3D *);
70 
72 
75  void OnPan() override;
76  void OnPinch() override;
77  void OnRotate() override;
79 
81 
84  void ProbeData(vtkEventDataDevice controller);
85  void LoadNextCameraPose();
86  virtual void PositionProp(vtkEventData *);
87  virtual void Clip(vtkEventDataDevice3D *);
89 
91 
96  void MapInputToAction(vtkEventDataDevice device,
97  vtkEventDataDeviceInput input, int state);
99 
101 
104  void AddTooltipForInput(vtkEventDataDevice device,
105  vtkEventDataDeviceInput input, const std::string &text);
107 
108  vtkSetClampMacro(HoverPick, int, 0, 1);
109  vtkGetMacro(HoverPick, int);
110  vtkBooleanMacro(HoverPick, int);
111 
113  return this->InteractionState[static_cast<int>(device)]; }
114 
115  void ShowRay(vtkEventDataDevice controller);
116  void HideRay(vtkEventDataDevice controller);
117 
118  void ShowBillboard(const std::string &text);
119  void HideBillboard();
120 
121  void ShowPickSphere(double *pos, double radius, vtkProp3D *);
122  void ShowPickCell(vtkCell *cell, vtkProp3D *);
123  void HidePickActor();
124 
125  void ToggleDrawControls();
126 
127  void SetInteractor(vtkRenderWindowInteractor* iren) override;
128 
129  // allow the user to add options to the menu
131  return this->Menu.Get(); }
132 
133 protected:
135  ~vtkOpenVRInteractorStyle() override;
136 
137  void EndPickCallback(vtkSelection *sel);
138 
139  //Ray drawing
140  void UpdateRay(vtkEventDataDevice controller);
141 
145  static void MenuCallback(vtkObject* object,
146  unsigned long event,
147  void* clientdata,
148  void* calldata);
149 
153 
154  //device input to interaction state mapping
157 
158  //Utility routines
159  void StartAction(int VTKIS_STATE, vtkEventDataDevice3D *edata);
160  void EndAction(int VTKIS_STATE, vtkEventDataDevice3D *edata);
161 
168 
172  int InteractionState[vtkEventDataNumberOfDevices];
175 
177 
181  void AddTooltipForInput(vtkEventDataDevice device, vtkEventDataDeviceInput input);
182 
183 private:
184  vtkOpenVRInteractorStyle(const vtkOpenVRInteractorStyle&) = delete; // Not implemented.
185  void operator=(const vtkOpenVRInteractorStyle&) = delete; // Not implemented.
186 };
187 
188 #endif
vtkPlane
perform various plane computations
Definition: vtkPlane.h:37
vtkOpenVRRenderWindow.h
vtkEventData
Definition: vtkEventData.h:63
vtkEventDataDeviceInput
vtkEventDataDeviceInput
Definition: vtkEventData.h:37
vtkOpenVRInteractorStyle::GetMenu
vtkOpenVRMenuWidget * GetMenu()
Definition: vtkOpenVRInteractorStyle.h:130
vtkInteractorStyle3D.h
vtkEventDataDevice3D
Definition: vtkEventData.h:139
vtkProp3D
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:46
vtkOpenVRInteractorStyle::GetInteractionState
int GetInteractionState(vtkEventDataDevice device)
Definition: vtkOpenVRInteractorStyle.h:112
vtkTextActor3D
An actor that displays text.
Definition: vtkTextActor3D.h:47
vtkOpenVRControlsHelper
Tooltip helper explaining controls Helper class to draw one tooltip per button around the controller.
Definition: vtkOpenVRControlsHelper.h:49
vtkOpenVRInteractorStyle::PickActor
vtkNew< vtkActor > PickActor
Definition: vtkOpenVRInteractorStyle.h:151
vtkInteractorStyle3D::New
static vtkInteractorStyle3D * New()
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkEventDataNumberOfInputs
const int vtkEventDataNumberOfInputs
Definition: vtkEventData.h:47
vtkSelection
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:63
vtkInteractorStyle::OnPinch
virtual void OnPinch()
gesture based events
Definition: vtkInteractorStyle.h:306
vtkInteractorStyle::SetInteractor
void SetInteractor(vtkRenderWindowInteractor *interactor) override
Set/Get the Interactor wrapper being controlled by this object.
vtkInteractorStyle::OnButton3D
virtual void OnButton3D(vtkEventData *)
Definition: vtkInteractorStyle.h:248
vtkOpenVRHardwarePicker
pick an actor/prop given a controller position and orientation
Definition: vtkOpenVRHardwarePicker.h:34
vtkOpenVRInteractorStyle::Sphere
vtkNew< vtkSphereSource > Sphere
Definition: vtkOpenVRInteractorStyle.h:152
vtkInteractorStyle::OnPan
virtual void OnPan()
Definition: vtkInteractorStyle.h:308
vtkInteractorStyle3D::PositionProp
virtual void PositionProp(vtkEventData *)
vtkEventDataNumberOfDevices
const int vtkEventDataNumberOfDevices
Definition: vtkEventData.h:33
vtkInteractorStyle3D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:46
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:59
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkEventData.h
vtkNew< vtkOpenVRMenuWidget >
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:78
vtkOpenVRInteractorStyle::Menu
vtkNew< vtkOpenVRMenuWidget > Menu
Definition: vtkOpenVRInteractorStyle.h:142
vtkOpenVRInteractorStyle::MenuRepresentation
vtkNew< vtkOpenVRMenuRepresentation > MenuRepresentation
Definition: vtkOpenVRInteractorStyle.h:143
vtkInteractorStyle3D
extends interaction to support 3D input
Definition: vtkInteractorStyle3D.h:66
vtkX3D::string
Definition: vtkX3D.h:490
vtkOpenVRInteractorStyle::TextActor3D
vtkNew< vtkTextActor3D > TextActor3D
Definition: vtkOpenVRInteractorStyle.h:150
vtkOpenVRInteractorStyle::HoverPick
int HoverPick
Indicates if picking should be updated every frame.
Definition: vtkOpenVRInteractorStyle.h:167
vtkEventDataDevice
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:25
vtkNew.h
vtkOpenVRInteractorStyle
extended from vtkInteractorStyle3D to override command methods
Definition: vtkOpenVRInteractorStyle.h:40
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:50
vtkInteractorStyle::OnRotate
virtual void OnRotate()
Definition: vtkInteractorStyle.h:307
vtkOpenVRInteractorStyle::HardwarePicker
vtkNew< vtkOpenVRHardwarePicker > HardwarePicker
Definition: vtkOpenVRInteractorStyle.h:176
vtkOpenVRMenuWidget
3D widget to display a menu in VR
Definition: vtkOpenVRMenuWidget.h:36
vtkX3D::radius
Definition: vtkX3D.h:252
vtkOpenVRMenuRepresentation
Widget representation for vtkOpenVRPanelWidget Implementation of the popup panel representation for t...
Definition: vtkOpenVRMenuRepresentation.h:43
vtkOpenVRInteractorStyle::MenuCommand
vtkCallbackCommand * MenuCommand
Definition: vtkOpenVRInteractorStyle.h:144
vtkInteractorStyle::OnMove3D
virtual void OnMove3D(vtkEventData *)
Generic 3D event bindings can be overridden in subclasses.
Definition: vtkInteractorStyle.h:247