forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkOpenVRPanelRepresentation.h
181 lines (152 loc) · 5.52 KB
/
vtkOpenVRPanelRepresentation.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
/*=========================================================================
Program: Visualization Toolkit
Module: vtkImplicitPlaneRepresentation.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 vtkOpenVRPanelRepresentation
* @brief Widget representation for vtkOpenVRPanelWidget
* Implementation of the popup panel representation for the
* vtkOpenVRPanelWidget.
* This representation is rebuilt every time the hovered prop changes.
* Its position is set according to the camera orientation and is placed at a
* distance defined in meters in the BuildRepresentation() method.
*
* WARNING: The panel might be occluded by other props.
* TODO: Improve placement method.
**/
#ifndef vtkOpenVRPanelRepresentation_h
#define vtkOpenVRPanelRepresentation_h
#include "vtkRenderingOpenVRModule.h" // For export macro
#include "vtkWidgetRepresentation.h"
#include <string> // for ivar
class vtkPicker;
class vtkTextActor3D;
class VTKRENDERINGOPENVR_EXPORT vtkOpenVRPanelRepresentation : public vtkWidgetRepresentation
{
public:
/**
* Instantiate the class.
*/
static vtkOpenVRPanelRepresentation *New();
//@{
/**
* Standard methods for the class.
*/
vtkTypeMacro(vtkOpenVRPanelRepresentation, vtkWidgetRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) override;
//@}
// Enums define the state of the representation relative to the mouse pointer
// position. Used by ComputeInteractionState() to communicate with the
// widget. Note that ComputeInteractionState() and several other methods
// must be implemented by subclasses.
enum _InteractionState { Outside=0, Moving };
//@{
/**
* Methods to interface with the vtkOpenVRPanelWidget.
*/
void BuildRepresentation() override;
void PlaceWidget(double bounds[6]) override;
void StartComplexInteraction(
vtkRenderWindowInteractor *iren,
vtkAbstractWidget *widget,
unsigned long event, void *calldata) override;
void ComplexInteraction(
vtkRenderWindowInteractor *iren,
vtkAbstractWidget *widget,
unsigned long event, void *calldata) override;
int ComputeComplexInteractionState(
vtkRenderWindowInteractor *iren,
vtkAbstractWidget *widget,
unsigned long event, void *calldata, int modify = 0) override;
void EndComplexInteraction(
vtkRenderWindowInteractor *iren,
vtkAbstractWidget *widget,
unsigned long event, void *calldata) override;
//@}
// Place the widget with a few more options
// This method allows you to place the panel
// and provides more options so that you can get
// the exact positioning you want.
// Bounds are the bounds that you want the panel to
// fit within. For World coordinates they should be in
// world coordinates. For all others they should be in
// physical meters relative to the HMD or controller origin.
// The normal is the direction the planel should face.
// The coordinate system for the controller is X right
// Y up and Z towards the handle. Upvec specifies the
// vector to use as up for the panel. Note that upvec
// has priority over normal, if they are not orthogonal
// normal will be modified to be orthogonal to upvec.
// Scale is the physical scale from the RenderWindow
// and is used to position/scale the panel correctly.
//
// Note that you should set the Text on the panel
// before calling this method as the positioning
// and scaling is done based on the current text.
//
// All vectors will be normalized prior to use.
void PlaceWidgetExtended(const double *bounds,
const double *normal, const double *upvec, double scale);
//@{
/**
* Methods supporting the rendering process.
*/
void ReleaseGraphicsResources(vtkWindow*) override;
int RenderOpaqueGeometry(vtkViewport*) override;
int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
int HasTranslucentPolygonalGeometry() override;
//@}
//@{
/**
* Set panel text
*/
void SetText(const char* str);
//@}
// allow access to the underlying text actor
// so that properties can be set
vtkGetObjectMacro(TextActor, vtkTextActor3D);
// Set the coordinate system to use for this prop
void SetCoordinateSystemToWorld();
void SetCoordinateSystemToHMD();
void SetCoordinateSystemToLeftController();
void SetCoordinateSystemToRightController();
//@{
/**
* Can the panel be relocated by the user
*/
vtkSetMacro(AllowAdjustment, bool);
vtkGetMacro(AllowAdjustment, bool);
vtkBooleanMacro(AllowAdjustment, bool);
//@}
protected:
vtkOpenVRPanelRepresentation();
~vtkOpenVRPanelRepresentation() override;
// Keep track of event positions
double LastEventPosition[3];
double LastEventOrientation[4];
double StartEventOrientation[4];
double LastScale;
bool AllowAdjustment;
void UpdatePose(double *p1, double *d1, double *p2, double *d2);
void ComputeMatrix(vtkRenderer *ren);
enum CoordinateSystems {
World = 0,
HMD = 1,
LeftController = 2,
RightController = 3,
};
CoordinateSystems CoordinateSystem;
// The text
vtkTextActor3D *TextActor;
std::string Text;
private:
vtkOpenVRPanelRepresentation(const vtkOpenVRPanelRepresentation&) = delete;
void operator=(const vtkOpenVRPanelRepresentation&) = delete;
};
#endif