-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathvtkVirtualRealityViewInteractorStyle.h
More file actions
214 lines (171 loc) · 6.78 KB
/
vtkVirtualRealityViewInteractorStyle.h
File metadata and controls
214 lines (171 loc) · 6.78 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*==============================================================================
Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
Queen's University, Kingston, ON, Canada. All Rights Reserved.
See COPYRIGHT.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file was originally developed by Csaba Pinter, PerkLab, Queen's University
and was supported through CANARIE's Research Software Program, and Cancer
Care Ontario.
==============================================================================*/
#ifndef __vtkVirtualRealityViewInteractorStyle_h
#define __vtkVirtualRealityViewInteractorStyle_h
// MRML includes
#include "vtkMRMLDisplayableManagerGroup.h"
#include "vtkMRMLInteractionEventData.h"
#include "vtkMRMLModelDisplayNode.h"
// VTK includes
#include "vtkObject.h"
#include "vtkInteractorStyle3D.h"
#include "vtkOpenVRRenderWindow.h" // for enums
#include "vtkEventData.h"
#include "vtkSlicerVirtualRealityModuleMRMLExport.h"
class vtkMRMLScene;
/// \brief Virtual reality interactions
///
/// TODO:
///
class VTK_SLICER_VIRTUALREALITY_MODULE_MRML_EXPORT vtkVirtualRealityViewInteractorStyle :
public vtkInteractorStyle3D
{
public:
static vtkVirtualRealityViewInteractorStyle *New();
vtkTypeMacro(vtkVirtualRealityViewInteractorStyle,vtkInteractorStyle3D);
void PrintSelf(ostream& os, vtkIndent indent) override;
/// Set the Interactor wrapper being controlled by this object. (Satisfy superclass API.)
void SetInteractor(vtkRenderWindowInteractor *interactor) override;
/// Main process event method
static void ProcessEvents(vtkObject* object, unsigned long event, void* clientdata, void* calldata);
/// Get MRML scene from the displayable manager group (the first displayable manager's if any)
vtkMRMLScene* GetMRMLScene();
//@{
/// 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;
void OnPinch3D();
void OnStartGesture();
void OnEndGesture();
//@}
//@{
/**
* Methods for interaction.
*/
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 ShowLaser(vtkEventDataDevice controller);
void HideLaser(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();
//// allow the user to add options to the menu
//vtkOpenVRMenuWidget *GetMenu() {
// return this->Menu.Get(); }
/// Get the displayable managers
vtkGetObjectMacro(DisplayableManagerGroup, vtkMRMLDisplayableManagerGroup);
/// Set the displayable managers
vtkSetObjectMacro(DisplayableManagerGroup, vtkMRMLDisplayableManagerGroup);
/// Set physical to world magnification. Valid value range is [0.01, 100].
/// Note: Conversion is physicalScale = 1000 / magnification
void SetMagnification(double magnification);
double GetMagnification();
protected:
//void EndPickCallback(vtkSelection *sel);
////Laser drawing
void CreateLaser();
void UpdateLaser(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);
///**
//* Controls helpers drawing
//*/
//void AddTooltipForInput(vtkEventDataDevice device, vtkEventDataDeviceInput input);
protected:
///**
//* 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;
//vtkNew<vtkOpenVRHardwarePicker> HardwarePicker;
vtkMRMLDisplayableManagerGroup* DisplayableManagerGroup;
vtkMRMLAbstractDisplayableManager* FocusedDisplayableManager;
vtkSmartPointer<vtkPoints> LaserPoints;
vtkSmartPointer<vtkMRMLModelDisplayNode> LaserModelDisplay;
protected:
vtkVirtualRealityViewInteractorStyle();
~vtkVirtualRealityViewInteractorStyle() override;
private:
vtkVirtualRealityViewInteractorStyle(const vtkVirtualRealityViewInteractorStyle&); /// Not implemented.
void operator=(const vtkVirtualRealityViewInteractorStyle&); /// Not implemented.
class vtkInternal;
vtkInternal* Internal;
};
#endif