VTK  9.0.1
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 =========================================================================*/
23 #ifndef vtkOpenVRInteractorStyle_h
24 #define vtkOpenVRInteractorStyle_h
25 
26 #include "vtkRenderingOpenVRModule.h" // For export macro
27 
28 #include "vtkEventData.h" // for enums
29 #include "vtkInteractorStyle3D.h"
30 #include "vtkNew.h" // for ivars
31 #include "vtkOpenVRRenderWindow.h" // for enums
32 
33 class vtkCell;
34 class vtkPlane;
39 class vtkTextActor3D;
40 class vtkSelection;
41 class vtkSphereSource;
42 
43 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRInteractorStyle : public vtkInteractorStyle3D
44 {
45 public:
46  static vtkOpenVRInteractorStyle* New();
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
51 
54  void OnButton3D(vtkEventData* edata) override;
55  void OnMove3D(vtkEventData* edata) override;
57 
59 
62  virtual void StartPick(vtkEventDataDevice3D*);
63  virtual void EndPick(vtkEventDataDevice3D*);
64  virtual void StartLoadCamPose(vtkEventDataDevice3D*);
65  virtual void EndLoadCamPose(vtkEventDataDevice3D*);
66  virtual void StartPositionProp(vtkEventDataDevice3D*);
67  virtual void EndPositionProp(vtkEventDataDevice3D*);
68  virtual void StartClip(vtkEventDataDevice3D*);
69  virtual void EndClip(vtkEventDataDevice3D*);
70  virtual void StartDolly3D(vtkEventDataDevice3D*);
71  virtual void EndDolly3D(vtkEventDataDevice3D*);
73 
75 
78  void OnPan() override;
79  void OnPinch() override;
80  void OnRotate() override;
82 
84 
87  void ProbeData(vtkEventDataDevice controller);
88  void LoadNextCameraPose();
89  virtual void PositionProp(vtkEventData*);
90  virtual void Clip(vtkEventDataDevice3D*);
92 
94 
99  void MapInputToAction(vtkEventDataDevice device, vtkEventDataDeviceInput input, int state);
101 
103 
106  void AddTooltipForInput(
107  vtkEventDataDevice device, vtkEventDataDeviceInput input, const std::string& text);
109 
111 
116  vtkSetMacro(HoverPick, bool);
117  vtkGetMacro(HoverPick, bool);
118  vtkBooleanMacro(HoverPick, bool);
120 
122 
125  vtkSetMacro(GrabWithRay, bool);
126  vtkGetMacro(GrabWithRay, bool);
127  vtkBooleanMacro(GrabWithRay, bool);
129 
131  {
132  return this->InteractionState[static_cast<int>(device)];
133  }
134 
135  void ShowRay(vtkEventDataDevice controller);
136  void HideRay(vtkEventDataDevice controller);
137 
138  void ShowBillboard(const std::string& text);
139  void HideBillboard();
140 
141  void ShowPickSphere(double* pos, double radius, vtkProp3D*);
142  void ShowPickCell(vtkCell* cell, vtkProp3D*);
143  void HidePickActor();
144 
145  void ToggleDrawControls();
146  void SetDrawControls(bool);
147 
148  void SetInteractor(vtkRenderWindowInteractor* iren) override;
149 
150  // allow the user to add options to the menu
151  vtkOpenVRMenuWidget* GetMenu() { return this->Menu.Get(); }
152 
153 protected:
155  ~vtkOpenVRInteractorStyle() override;
156 
157  void EndPickCallback(vtkSelection* sel);
158 
159  // Ray drawing
160  void UpdateRay(vtkEventDataDevice controller);
161 
165  static void MenuCallback(
166  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
167 
171 
172  // device input to interaction state mapping
175 
176  // Utility routines
177  void StartAction(int VTKIS_STATE, vtkEventDataDevice3D* edata);
178  void EndAction(int VTKIS_STATE, vtkEventDataDevice3D* edata);
179 
180  // Pick using hardware selector
181  bool HardwareSelect(vtkEventDataDevice controller, bool actorPassOnly);
182 
183  bool HoverPick;
185 
189  int InteractionState[vtkEventDataNumberOfDevices];
192 
194 
198  void AddTooltipForInput(vtkEventDataDevice device, vtkEventDataDeviceInput input);
199 
200 private:
201  vtkOpenVRInteractorStyle(const vtkOpenVRInteractorStyle&) = delete; // Not implemented.
202  void operator=(const vtkOpenVRInteractorStyle&) = delete; // Not implemented.
203 };
204 
205 #endif
vtkPlane
perform various plane computations
Definition: vtkPlane.h:31
vtkOpenVRRenderWindow.h
vtkEventData
Definition: vtkEventData.h:65
vtkEventDataDeviceInput
vtkEventDataDeviceInput
Definition: vtkEventData.h:38
vtkOpenVRInteractorStyle::GetMenu
vtkOpenVRMenuWidget * GetMenu()
Definition: vtkOpenVRInteractorStyle.h:151
vtkInteractorStyle3D.h
vtkEventDataDevice3D
Definition: vtkEventData.h:145
vtkProp3D
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:43
vtkOpenVRInteractorStyle::GetInteractionState
int GetInteractionState(vtkEventDataDevice device)
Definition: vtkOpenVRInteractorStyle.h:130
vtkTextActor3D
An actor that displays text.
Definition: vtkTextActor3D.h:44
vtkOpenVRControlsHelper
Tooltip helper explaining controls Helper class to draw one tooltip per button around the controller.
Definition: vtkOpenVRControlsHelper.h:48
vtkOpenVRInteractorStyle::PickActor
vtkNew< vtkActor > PickActor
Definition: vtkOpenVRInteractorStyle.h:169
vtkInteractorStyle3D::New
static vtkInteractorStyle3D * New()
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkEventDataNumberOfInputs
const int vtkEventDataNumberOfInputs
Definition: vtkEventData.h:49
vtkSelection
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:57
vtkOpenVRInteractorStyle::HoverPick
bool HoverPick
Definition: vtkOpenVRInteractorStyle.h:183
vtkInteractorStyle::OnPinch
virtual void OnPinch()
Definition: vtkInteractorStyle.h:316
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:253
vtkOpenVRHardwarePicker
pick an actor/prop given a controller position and orientation
Definition: vtkOpenVRHardwarePicker.h:37
vtkOpenVRInteractorStyle::Sphere
vtkNew< vtkSphereSource > Sphere
Definition: vtkOpenVRInteractorStyle.h:170
vtkInteractorStyle::OnPan
virtual void OnPan()
Definition: vtkInteractorStyle.h:322
vtkInteractorStyle3D::PositionProp
virtual void PositionProp(vtkEventData *)
vtkEventDataNumberOfDevices
const int vtkEventDataNumberOfDevices
Definition: vtkEventData.h:35
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:40
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:56
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkEventData.h
vtkNew< vtkOpenVRMenuWidget >
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:82
vtkOpenVRInteractorStyle::Menu
vtkNew< vtkOpenVRMenuWidget > Menu
Definition: vtkOpenVRInteractorStyle.h:162
vtkOpenVRInteractorStyle::MenuRepresentation
vtkNew< vtkOpenVRMenuRepresentation > MenuRepresentation
Definition: vtkOpenVRInteractorStyle.h:163
vtkInteractorStyle3D
extends interaction to support 3D input
Definition: vtkInteractorStyle3D.h:66
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkOpenVRInteractorStyle::TextActor3D
vtkNew< vtkTextActor3D > TextActor3D
Definition: vtkOpenVRInteractorStyle.h:168
vtkEventDataDevice
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:25
vtkNew.h
vtkOpenVRInteractorStyle
extended from vtkInteractorStyle3D to override command methods
Definition: vtkOpenVRInteractorStyle.h:43
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:44
vtkInteractorStyle::OnRotate
virtual void OnRotate()
Definition: vtkInteractorStyle.h:319
vtkOpenVRInteractorStyle::HardwarePicker
vtkNew< vtkOpenVRHardwarePicker > HardwarePicker
Definition: vtkOpenVRInteractorStyle.h:193
vtkOpenVRMenuWidget
3D widget to display a menu in VR
Definition: vtkOpenVRMenuWidget.h:35
vtkOpenVRInteractorStyle::GrabWithRay
bool GrabWithRay
Definition: vtkOpenVRInteractorStyle.h:184
vtkX3D::radius
@ radius
Definition: vtkX3D.h:258
vtkOpenVRMenuRepresentation
Widget representation for vtkOpenVRPanelWidget Implementation of the popup panel representation for t...
Definition: vtkOpenVRMenuRepresentation.h:43
vtkOpenVRInteractorStyle::MenuCommand
vtkCallbackCommand * MenuCommand
Definition: vtkOpenVRInteractorStyle.h:164
vtkInteractorStyle::OnMove3D
virtual void OnMove3D(vtkEventData *)
Generic 3D event bindings can be overridden in subclasses.
Definition: vtkInteractorStyle.h:252