forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkOpenVRInteractorStyle.h
188 lines (152 loc) · 5.46 KB
/
vtkOpenVRInteractorStyle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOpenVRInteractorStyle.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkOpenVRInteractorStyle
* @brief extended from vtkInteractorStyle3D to override command methods
*/
#ifndef vtkOpenVRInteractorStyle_h
#define vtkOpenVRInteractorStyle_h
#include "vtkRenderingOpenVRModule.h" // For export macro
#include "vtkInteractorStyle3D.h"
#include "vtkOpenVRRenderWindow.h" // for enums
#include "vtkNew.h" // for ivars
#include "vtkEventData.h" // for enums
class vtkCell;
class vtkPlane;
class vtkOpenVRControlsHelper;
class vtkOpenVRHardwarePicker;
class vtkOpenVRMenuRepresentation;
class vtkOpenVRMenuWidget;
class vtkTextActor3D;
class vtkSelection;
class vtkSphereSource;
class VTKRENDERINGOPENVR_EXPORT vtkOpenVRInteractorStyle : public vtkInteractorStyle3D
{
public:
static vtkOpenVRInteractorStyle *New();
vtkTypeMacro(vtkOpenVRInteractorStyle, vtkInteractorStyle3D);
void PrintSelf(ostream& os, vtkIndent indent) override;
//@{
/**
* Override generic event bindings to call the corresponding action.
*/
void OnButton3D(vtkEventData *edata) override;
void OnMove3D(vtkEventData *edata) override;
//@}
//@{
/**
* Interaction mode entry points.
*/
virtual void StartPick(vtkEventDataDevice3D *);
virtual void EndPick(vtkEventDataDevice3D *);
virtual void StartLoadCamPose(vtkEventDataDevice3D *);
virtual void EndLoadCamPose(vtkEventDataDevice3D *);
virtual void StartPositionProp(vtkEventDataDevice3D *);
virtual void EndPositionProp(vtkEventDataDevice3D *);
virtual void StartClip(vtkEventDataDevice3D *);
virtual void EndClip(vtkEventDataDevice3D *);
virtual void StartDolly3D(vtkEventDataDevice3D *);
virtual void EndDolly3D(vtkEventDataDevice3D *);
//@}
//@{
/**
* Multitouch events binding.
*/
void OnPan() override;
void OnPinch() override;
void OnRotate() override;
//@}
//@{
/**
* Methods for intertaction.
*/
void ProbeData(vtkEventDataDevice controller);
void LoadNextCameraPose();
virtual void PositionProp(vtkEventData *);
virtual void Clip(vtkEventDataDevice3D *);
//@}
//@{
/**
* Map controller inputs to actions.
* Actions are defined by a VTKIS_*STATE*, interaction entry points,
* and the corresponding method for interaction.
*/
void MapInputToAction(vtkEventDataDevice device,
vtkEventDataDeviceInput input, int state);
//@}
//@{
/**
* Define the helper text that goes with an input
*/
void AddTooltipForInput(vtkEventDataDevice device,
vtkEventDataDeviceInput input, const std::string &text);
//@}
vtkSetClampMacro(HoverPick, int, 0, 1);
vtkGetMacro(HoverPick, int);
vtkBooleanMacro(HoverPick, int);
int GetInteractionState(vtkEventDataDevice device) {
return this->InteractionState[static_cast<int>(device)]; }
void ShowRay(vtkEventDataDevice controller);
void HideRay(vtkEventDataDevice controller);
void ShowBillboard(const std::string &text);
void HideBillboard();
void ShowPickSphere(double *pos, double radius, vtkProp3D *);
void ShowPickCell(vtkCell *cell, vtkProp3D *);
void HidePickActor();
void ToggleDrawControls();
void SetInteractor(vtkRenderWindowInteractor* iren) override;
// allow the user to add options to the menu
vtkOpenVRMenuWidget *GetMenu() {
return this->Menu.Get(); }
protected:
vtkOpenVRInteractorStyle();
~vtkOpenVRInteractorStyle() override;
void EndPickCallback(vtkSelection *sel);
//Ray drawing
void UpdateRay(vtkEventDataDevice controller);
vtkNew<vtkOpenVRMenuWidget> Menu;
vtkNew<vtkOpenVRMenuRepresentation> MenuRepresentation;
vtkCallbackCommand* MenuCommand;
static void MenuCallback(vtkObject* object,
unsigned long event,
void* clientdata,
void* calldata);
vtkNew<vtkTextActor3D> TextActor3D;
vtkNew<vtkActor> PickActor;
vtkNew<vtkSphereSource> Sphere;
//device input to interaction state mapping
int InputMap[vtkEventDataNumberOfDevices][vtkEventDataNumberOfInputs];
vtkOpenVRControlsHelper* ControlsHelpers[vtkEventDataNumberOfDevices][vtkEventDataNumberOfInputs];
//Utility routines
void StartAction(int VTKIS_STATE, vtkEventDataDevice3D *edata);
void EndAction(int VTKIS_STATE, vtkEventDataDevice3D *edata);
/**
* Indicates if picking should be updated every frame. If so, the interaction
* picker will try to pick a prop and rays will be updated accordingly.
* Default is set to off.
*/
int HoverPick;
/**
* Store required controllers information when performing action
*/
int InteractionState[vtkEventDataNumberOfDevices];
vtkProp3D* InteractionProps[vtkEventDataNumberOfDevices];
vtkPlane* ClippingPlanes[vtkEventDataNumberOfDevices];
vtkNew<vtkOpenVRHardwarePicker> HardwarePicker;
/**
* Controls helpers drawing
*/
void AddTooltipForInput(vtkEventDataDevice device, vtkEventDataDeviceInput input);
private:
vtkOpenVRInteractorStyle(const vtkOpenVRInteractorStyle&) = delete; // Not implemented.
void operator=(const vtkOpenVRInteractorStyle&) = delete; // Not implemented.
};
#endif