VTK  9.1.0
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 "vtkEventData.h" // for enums
26 #include "vtkInteractorStyle3D.h"
27 #include "vtkNew.h" // for ivars
28 #include "vtkOpenVRRenderWindow.h" // for enums
29 
30 class vtkCell;
31 class vtkPlane;
35 class vtkVRMenuWidget;
36 class vtkTextActor3D;
37 class vtkSelection;
38 class vtkSphereSource;
39 
40 class VTKRENDERINGOPENVR_EXPORT vtkOpenVRInteractorStyle : public vtkInteractorStyle3D
41 {
42 public:
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
48 
51  void OnSelect3D(vtkEventData* edata) override;
52  void OnNextPose3D(vtkEventData* edata) override;
53  void OnViewerMovement3D(vtkEventData* edata) override;
54  void OnMove3D(vtkEventData* edata) override;
55  void OnMenu3D(vtkEventData* edata) override;
57 
59 
63  virtual void EndPick(vtkEventDataDevice3D*);
69  virtual void EndClip(vtkEventDataDevice3D*);
73 
75 
78  void OnPan() override;
79  void OnPinch() override;
80  void OnRotate() override;
82 
84 
87  void ProbeData(vtkEventDataDevice controller);
89  virtual void PositionProp(vtkEventData*, double* lwpos = nullptr, double* lwori = nullptr);
90  virtual void Clip(vtkEventDataDevice3D*);
92 
94 
99  void MapInputToAction(vtkCommand::EventIds eid, int state);
102 
104 
109  vtkEventDataDevice device, vtkEventDataDeviceInput input, const std::string& text);
111 
113 
118  vtkSetMacro(HoverPick, bool);
119  vtkGetMacro(HoverPick, bool);
120  vtkBooleanMacro(HoverPick, bool);
122 
124 
127  vtkSetMacro(GrabWithRay, bool);
128  vtkGetMacro(GrabWithRay, bool);
129  vtkBooleanMacro(GrabWithRay, bool);
131 
133  {
134  return this->InteractionState[static_cast<int>(device)];
135  }
136 
137  void ShowRay(vtkEventDataDevice controller);
138  void HideRay(vtkEventDataDevice controller);
139 
140  void ShowBillboard(const std::string& text);
142 
143  void ShowPickSphere(double* pos, double radius, vtkProp3D*);
146 
148  void SetDrawControls(bool);
149 
151 
152  // allow the user to add options to the menu
153  vtkVRMenuWidget* GetMenu() { return this->Menu.Get(); }
154 
155 protected:
158 
160 
161  // Ray drawing
162  void UpdateRay(vtkEventDataDevice controller);
163 
167  static void MenuCallback(
168  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
169 
173 
174  // device input to interaction state mapping
175  std::map<std::tuple<vtkCommand::EventIds, vtkEventDataAction>, int> InputMap;
177 
178  // Utility routines
179  void StartAction(int VTKIS_STATE, vtkEventDataDevice3D* edata);
180  void EndAction(int VTKIS_STATE, vtkEventDataDevice3D* edata);
181 
182  // Pick using hardware selector
183  bool HardwareSelect(vtkEventDataDevice controller, bool actorPassOnly);
184 
185  bool HoverPick;
187 
191  int InteractionState[vtkEventDataNumberOfDevices];
194 
196 
201 
202 private:
204  void operator=(const vtkOpenVRInteractorStyle&) = delete;
205 };
206 
207 #endif
supports function callbacks
abstract class to specify cell behavior
Definition: vtkCell.h:58
a simple class to control print indentation
Definition: vtkIndent.h:34
extends interaction to support 3D input
abstract base class for most VTK objects
Definition: vtkObject.h:54
Tooltip helper explaining controls Helper class to draw one tooltip per button around the controller.
extended from vtkInteractorStyle3D to override command methods
virtual void EndDolly3D(vtkEventDataDevice3D *)
Interaction mode entry points.
static void MenuCallback(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void Clip(vtkEventDataDevice3D *)
Methods for intertaction.
~vtkOpenVRInteractorStyle() override
void HideRay(vtkEventDataDevice controller)
void ShowPickCell(vtkCell *cell, vtkProp3D *)
virtual void EndPositionProp(vtkEventDataDevice3D *)
Interaction mode entry points.
virtual void PositionProp(vtkEventData *, double *lwpos=nullptr, double *lwori=nullptr)
Methods for intertaction.
void AddTooltipForInput(vtkEventDataDevice device, vtkEventDataDeviceInput input)
Controls helpers drawing.
void ShowRay(vtkEventDataDevice controller)
void ProbeData(vtkEventDataDevice controller)
Methods for intertaction.
std::map< std::tuple< vtkCommand::EventIds, vtkEventDataAction >, int > InputMap
void AddTooltipForInput(vtkEventDataDevice device, vtkEventDataDeviceInput input, const std::string &text)
Define the helper text that goes with an input, deprecated as open vr mostly provides it.
void OnPinch() override
Multitouch events binding.
vtkNew< vtkVRMenuRepresentation > MenuRepresentation
vtkNew< vtkTextActor3D > TextActor3D
void OnPan() override
Multitouch events binding.
virtual void StartClip(vtkEventDataDevice3D *)
Interaction mode entry points.
void OnRotate() override
Multitouch events binding.
vtkNew< vtkVRMenuWidget > Menu
virtual void EndClip(vtkEventDataDevice3D *)
Interaction mode entry points.
virtual void StartDolly3D(vtkEventDataDevice3D *)
Interaction mode entry points.
int GetInteractionState(vtkEventDataDevice device)
void LoadNextCameraPose()
Methods for intertaction.
vtkNew< vtkVRHardwarePicker > HardwarePicker
void MapInputToAction(vtkCommand::EventIds eid, int state)
Map controller inputs to actions.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkOpenVRInteractorStyle * New()
virtual void EndPick(vtkEventDataDevice3D *)
Interaction mode entry points.
void OnMove3D(vtkEventData *edata) override
Override generic event bindings to call the corresponding action.
void EndAction(int VTKIS_STATE, vtkEventDataDevice3D *edata)
virtual void StartLoadCamPose(vtkEventDataDevice3D *)
Interaction mode entry points.
void OnViewerMovement3D(vtkEventData *edata) override
Override generic event bindings to call the corresponding action.
void ShowBillboard(const std::string &text)
void OnSelect3D(vtkEventData *edata) override
Override generic event bindings to call the corresponding action.
virtual void EndLoadCamPose(vtkEventDataDevice3D *)
Interaction mode entry points.
vtkNew< vtkSphereSource > Sphere
void StartAction(int VTKIS_STATE, vtkEventDataDevice3D *edata)
void OnMenu3D(vtkEventData *edata) override
Override generic event bindings to call the corresponding action.
void UpdateRay(vtkEventDataDevice controller)
void ShowPickSphere(double *pos, double radius, vtkProp3D *)
void SetInteractor(vtkRenderWindowInteractor *iren) override
Set/Get the Interactor wrapper being controlled by this object.
void OnNextPose3D(vtkEventData *edata) override
Override generic event bindings to call the corresponding action.
void MapInputToAction(vtkCommand::EventIds eid, vtkEventDataAction action, int state)
Map controller inputs to actions.
virtual void StartPick(vtkEventDataDevice3D *)
Interaction mode entry points.
virtual void StartPositionProp(vtkEventDataDevice3D *)
Interaction mode entry points.
bool HardwareSelect(vtkEventDataDevice controller, bool actorPassOnly)
void EndPickCallback(vtkSelection *sel)
perform various plane computations
Definition: vtkPlane.h:34
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:44
platform-independent render window interaction including picking and frame rate control.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:54
create a polygonal sphere centered at the origin
An actor that displays text.
pick an actor/prop given a controller position and orientation
Widget representation for vtkVRMenuWidget Implementation of the popup panel representation for the vt...
3D widget to display a menu in VR
@ radius
Definition: vtkX3D.h:258
@ string
Definition: vtkX3D.h:496
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:26
const int vtkEventDataNumberOfDevices
Definition: vtkEventData.h:36
vtkEventDataAction
Definition: vtkEventData.h:55
vtkEventDataDeviceInput
Definition: vtkEventData.h:40
const int vtkEventDataNumberOfInputs
Definition: vtkEventData.h:51