forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkSliderRepresentation3D.h
257 lines (215 loc) · 7.3 KB
/
vtkSliderRepresentation3D.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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/*=========================================================================
Program: Visualization Toolkit
Module: vtkSliderRepresentation3D.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 vtkSliderRepresentation3D
* @brief provide the representation for a vtkSliderWidget with a 3D skin
*
* This class is used to represent and render a vtkSliderWidget. To use this
* class, you must at a minimum specify the end points of the
* slider. Optional instance variable can be used to modify the appearance of
* the widget.
*
*
* @sa
* vtkSliderWidget
*/
#ifndef vtkSliderRepresentation3D_h
#define vtkSliderRepresentation3D_h
#include "vtkInteractionWidgetsModule.h" // For export macro
#include "vtkSliderRepresentation.h"
#include "vtkCoordinate.h" // For vtkViewportCoordinateMacro
class vtkActor;
class vtkPolyDataMapper;
class vtkSphereSource;
class vtkCellPicker;
class vtkProperty;
class vtkCylinderSource;
class vtkVectorText;
class vtkAssembly;
class vtkTransform;
class vtkTransformPolyDataFilter;
class vtkMatrix4x4;
class VTKINTERACTIONWIDGETS_EXPORT vtkSliderRepresentation3D : public vtkSliderRepresentation
{
public:
/**
* Instantiate the class.
*/
static vtkSliderRepresentation3D *New();
//@{
/**
* Standard methods for the class.
*/
vtkTypeMacro(vtkSliderRepresentation3D,vtkSliderRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
//@}
//@{
/**
* Position the first end point of the slider. Note that this point is an
* instance of vtkCoordinate, meaning that Point 1 can be specified in a
* variety of coordinate systems, and can even be relative to another
* point. To set the point, you'll want to get the Point1Coordinate and
* then invoke the necessary methods to put it into the correct coordinate
* system and set the correct initial value.
*/
vtkCoordinate *GetPoint1Coordinate();
void SetPoint1InWorldCoordinates(double x, double y, double z);
//@}
//@{
/**
* Position the second end point of the slider. Note that this point is an
* instance of vtkCoordinate, meaning that Point 1 can be specified in a
* variety of coordinate systems, and can even be relative to another
* point. To set the point, you'll want to get the Point2Coordinate and
* then invoke the necessary methods to put it into the correct coordinate
* system and set the correct initial value.
*/
vtkCoordinate *GetPoint2Coordinate();
void SetPoint2InWorldCoordinates(double x, double y, double z);
//@}
//@{
/**
* Specify the title text for this widget. If the value is not set, or set
* to the empty string "", then the title text is not displayed.
*/
void SetTitleText(const char*) VTK_OVERRIDE;
const char* GetTitleText() VTK_OVERRIDE;
//@}
//@{
/**
* Specify whether to use a sphere or cylinder slider shape. By default, a
* sphere shape is used.
*/
vtkSetClampMacro(SliderShape,int,SphereShape,CylinderShape);
vtkGetMacro(SliderShape, int);
void SetSliderShapeToSphere() { this->SetSliderShape(SphereShape); }
void SetSliderShapeToCylinder() { this->SetSliderShape(CylinderShape); }
//@}
//@{
/**
* Set the rotation of the slider widget around the axis of the widget. This is
* used to control which way the widget is initially oriented. (This is especially
* important for the label and title.)
*/
vtkSetMacro(Rotation,double);
vtkGetMacro(Rotation,double);
//@}
//@{
/**
* Get the slider properties. The properties of the slider when selected
* and unselected can be manipulated.
*/
vtkGetObjectMacro(SliderProperty,vtkProperty);
//@}
//@{
/**
* Get the properties for the tube and end caps.
*/
vtkGetObjectMacro(TubeProperty,vtkProperty);
vtkGetObjectMacro(CapProperty,vtkProperty);
//@}
//@{
/**
* Get the selection property. This property is used to modify the appearance of
* selected objects (e.g., the slider).
*/
vtkGetObjectMacro(SelectedProperty,vtkProperty);
//@}
//@{
/**
* Methods to interface with the vtkSliderWidget.
*/
void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
void BuildRepresentation() VTK_OVERRIDE;
void StartWidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
void WidgetInteraction(double newEventPos[2]) VTK_OVERRIDE;
void Highlight(int) VTK_OVERRIDE;
//@}
//@{
/**
* Methods supporting the rendering process.
*/
double *GetBounds() VTK_OVERRIDE;
void GetActors(vtkPropCollection*) VTK_OVERRIDE;
void ReleaseGraphicsResources(vtkWindow*) VTK_OVERRIDE;
int RenderOpaqueGeometry(vtkViewport*) VTK_OVERRIDE;
int RenderTranslucentPolygonalGeometry(vtkViewport*) VTK_OVERRIDE;
int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
//@}
/**
* Override GetMTime to include point coordinates
*/
vtkMTimeType GetMTime() VTK_OVERRIDE;
protected:
vtkSliderRepresentation3D();
~vtkSliderRepresentation3D() VTK_OVERRIDE;
// Positioning the widget
vtkCoordinate *Point1Coordinate;
vtkCoordinate *Point2Coordinate;
double Length;
// These are the slider end points taking into account the thickness
// of the slider
double SP1[3];
double SP2[3];
// More ivars controlling the appearance of the widget
double Rotation;
int SliderShape;
// Do the picking
vtkCellPicker *Picker;
// Register internal Pickers within PickingManager
void RegisterPickers() VTK_OVERRIDE;
// Determine the parameter t along the slider
virtual double ComputePickPosition(double eventPos[2]);
// The widget consists of several actors, all grouped
// together using an assembly. This makes it easier to
// perform the final transformation into
vtkAssembly *WidgetAssembly;
// Cylinder used by other objects
vtkCylinderSource *CylinderSource;
vtkTransformPolyDataFilter *Cylinder;
// The tube
vtkPolyDataMapper *TubeMapper;
vtkActor *TubeActor;
vtkProperty *TubeProperty;
// The slider
vtkSphereSource *SliderSource;
vtkPolyDataMapper *SliderMapper;
vtkActor *SliderActor;
vtkProperty *SliderProperty;
vtkProperty *SelectedProperty;
// The left cap
vtkPolyDataMapper *LeftCapMapper;
vtkActor *LeftCapActor;
vtkProperty *CapProperty;
// The right cap
vtkPolyDataMapper *RightCapMapper;
vtkActor *RightCapActor;
// The text. There is an extra transform used to rotate
// both the title and label
vtkVectorText *LabelText;
vtkPolyDataMapper *LabelMapper;
vtkActor *LabelActor;
vtkVectorText *TitleText;
vtkPolyDataMapper *TitleMapper;
vtkActor *TitleActor;
// Transform used during slider motion
vtkMatrix4x4 *Matrix;
vtkTransform *Transform;
// Manage the state of the widget
enum _SliderShape {
SphereShape,
CylinderShape
};
private:
vtkSliderRepresentation3D(const vtkSliderRepresentation3D&) VTK_DELETE_FUNCTION;
void operator=(const vtkSliderRepresentation3D&) VTK_DELETE_FUNCTION;
};
#endif