Skip to content
/ VTK Public

Commit 1aac3fe

Browse files
committed
Create VRInteractorStyle and VRRenderWindowInteractor
Also include adequate changes to VRRenderWindow. Move independent methods and variables to VR, except for action handling.
1 parent 5a3e0c2 commit 1aac3fe

15 files changed

+2650
-2349
lines changed

Rendering/OpenVR/vtkOpenVRInteractorStyle.cxx

Lines changed: 17 additions & 1332 deletions
Large diffs are not rendered by default.

Rendering/OpenVR/vtkOpenVRInteractorStyle.h

Lines changed: 10 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -21,183 +21,24 @@ PURPOSE. See the above copyright notice for more information.
2121
#define vtkOpenVRInteractorStyle_h
2222

2323
#include "vtkRenderingOpenVRModule.h" // For export macro
24+
#include "vtkVRInteractorStyle.h"
2425

25-
#include "vtkEventData.h" // for enums
26-
#include "vtkInteractorStyle3D.h"
27-
#include "vtkNew.h" // for ivars
28-
#include "vtkOpenVRRenderWindow.h" // for enums
26+
class vtkRenderWindowInteractor;
27+
class vtkVRControlsHelper;
2928

30-
class vtkCell;
31-
class vtkPlane;
32-
class vtkOpenVRControlsHelper;
33-
class vtkVRHardwarePicker;
34-
class vtkVRMenuRepresentation;
35-
class vtkVRMenuWidget;
36-
class vtkTextActor3D;
37-
class vtkSelection;
38-
class vtkSphereSource;
39-
40-
class VTKRENDERINGOPENVR_EXPORT vtkOpenVRInteractorStyle : public vtkInteractorStyle3D
29+
class VTKRENDERINGOPENVR_EXPORT vtkOpenVRInteractorStyle : public vtkVRInteractorStyle
4130
{
4231
public:
4332
static vtkOpenVRInteractorStyle* New();
44-
vtkTypeMacro(vtkOpenVRInteractorStyle, vtkInteractorStyle3D);
45-
void PrintSelf(ostream& os, vtkIndent indent) override;
46-
47-
///@{
48-
/**
49-
* Override generic event bindings to call the corresponding action.
50-
*/
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;
56-
///@}
57-
58-
///@{
59-
/**
60-
* Interaction mode entry points.
61-
*/
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*);
72-
///@}
73-
74-
///@{
75-
/**
76-
* Multitouch events binding.
77-
*/
78-
void OnPan() override;
79-
void OnPinch() override;
80-
void OnRotate() override;
81-
///@}
82-
83-
///@{
84-
/**
85-
* Methods for intertaction.
86-
*/
87-
void ProbeData(vtkEventDataDevice controller);
88-
void LoadNextCameraPose();
89-
virtual void PositionProp(vtkEventData*, double* lwpos = nullptr, double* lwori = nullptr);
90-
virtual void Clip(vtkEventDataDevice3D*);
91-
///@}
92-
93-
///@{
94-
/**
95-
* Map controller inputs to actions.
96-
* Actions are defined by a VTKIS_*STATE*, interaction entry points,
97-
* and the corresponding method for interaction.
98-
*/
99-
void MapInputToAction(vtkCommand::EventIds eid, int state);
100-
void MapInputToAction(vtkCommand::EventIds eid, vtkEventDataAction action, int state);
101-
///@}
102-
103-
///@{
104-
/**
105-
* Define the helper text that goes with an input,
106-
* deprecated as open vr mostly provides it
107-
*/
108-
void AddTooltipForInput(
109-
vtkEventDataDevice device, vtkEventDataDeviceInput input, const std::string& text);
110-
///@}
111-
112-
///@{
113-
/**
114-
* Indicates if picking should be updated every frame. If so, the interaction
115-
* picker will try to pick a prop and rays will be updated accordingly.
116-
* Default is set to off.
117-
*/
118-
vtkSetMacro(HoverPick, bool);
119-
vtkGetMacro(HoverPick, bool);
120-
vtkBooleanMacro(HoverPick, bool);
121-
///@}
122-
123-
///@{
124-
/**
125-
* Specify if the grab mode use the ray to grab distant objects
126-
*/
127-
vtkSetMacro(GrabWithRay, bool);
128-
vtkGetMacro(GrabWithRay, bool);
129-
vtkBooleanMacro(GrabWithRay, bool);
130-
///@}
131-
132-
int GetInteractionState(vtkEventDataDevice device)
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);
141-
void HideBillboard();
142-
143-
void ShowPickSphere(double* pos, double radius, vtkProp3D*);
144-
void ShowPickCell(vtkCell* cell, vtkProp3D*);
145-
void HidePickActor();
33+
vtkTypeMacro(vtkOpenVRInteractorStyle, vtkVRInteractorStyle);
14634

147-
void ToggleDrawControls();
148-
void SetDrawControls(bool);
149-
150-
void SetInteractor(vtkRenderWindowInteractor* iren) override;
151-
152-
// allow the user to add options to the menu
153-
vtkVRMenuWidget* GetMenu() { return this->Menu.Get(); }
35+
virtual void SetupActions(vtkRenderWindowInteractor* iren) override;
36+
virtual void LoadNextCameraPose() override;
37+
vtkVRControlsHelper* MakeControlsHelper() override;
15438

15539
protected:
156-
vtkOpenVRInteractorStyle();
157-
~vtkOpenVRInteractorStyle() override;
158-
159-
void EndPickCallback(vtkSelection* sel);
160-
161-
// Ray drawing
162-
void UpdateRay(vtkEventDataDevice controller);
163-
164-
vtkNew<vtkVRMenuWidget> Menu;
165-
vtkNew<vtkVRMenuRepresentation> MenuRepresentation;
166-
vtkCallbackCommand* MenuCommand;
167-
static void MenuCallback(
168-
vtkObject* object, unsigned long event, void* clientdata, void* calldata);
169-
170-
vtkNew<vtkTextActor3D> TextActor3D;
171-
vtkNew<vtkActor> PickActor;
172-
vtkNew<vtkSphereSource> Sphere;
173-
174-
// device input to interaction state mapping
175-
std::map<std::tuple<vtkCommand::EventIds, vtkEventDataAction>, int> InputMap;
176-
vtkOpenVRControlsHelper* ControlsHelpers[vtkEventDataNumberOfDevices][vtkEventDataNumberOfInputs];
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;
186-
bool GrabWithRay;
187-
188-
/**
189-
* Store required controllers information when performing action
190-
*/
191-
int InteractionState[vtkEventDataNumberOfDevices];
192-
vtkProp3D* InteractionProps[vtkEventDataNumberOfDevices];
193-
vtkPlane* ClippingPlanes[vtkEventDataNumberOfDevices];
194-
195-
vtkNew<vtkVRHardwarePicker> HardwarePicker;
196-
197-
/**
198-
* Controls helpers drawing
199-
*/
200-
void AddTooltipForInput(vtkEventDataDevice device, vtkEventDataDeviceInput input);
40+
vtkOpenVRInteractorStyle() = default;
41+
~vtkOpenVRInteractorStyle() override = default;
20142

20243
private:
20344
vtkOpenVRInteractorStyle(const vtkOpenVRInteractorStyle&) = delete;

0 commit comments

Comments
 (0)