forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkAbstractPolygonalHandleRepresentation3D.h
261 lines (225 loc) · 8.83 KB
/
vtkAbstractPolygonalHandleRepresentation3D.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
258
259
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAbstractPolygonalHandleRepresentation3D.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 vtkAbstractPolygonalHandleRepresentation3D
* @brief represent a user defined handle geometry in 3D while maintaining a fixed orientation w.r.t the camera.
*
* This class serves as the geometrical representation of a vtkHandleWidget.
* The handle can be represented by an arbitrary polygonal data (vtkPolyData),
* set via SetHandle(vtkPolyData *). The actual position of the handle
* will be initially assumed to be (0,0,0). You can specify an offset from
* this position if desired. This class differs from
* vtkPolygonalHandleRepresentation3D in that the handle will always remain
* front facing, ie it maintains a fixed orientation with respect to the
* camera. This is done by using vtkFollowers internally to render the actors.
* @sa
* vtkPolygonalHandleRepresentation3D vtkHandleRepresentation vtkHandleWidget
*/
#ifndef vtkAbstractPolygonalHandleRepresentation3D_h
#define vtkAbstractPolygonalHandleRepresentation3D_h
#include "vtkInteractionWidgetsModule.h" // For export macro
#include "vtkHandleRepresentation.h"
class vtkProperty;
class vtkPolyDataMapper;
class vtkCellPicker;
class vtkTransformPolyDataFilter;
class vtkMatrixToLinearTransform;
class vtkMatrix4x4;
class vtkPolyData;
class vtkAbstractTransform;
class vtkActor;
class vtkFollower;
class vtkVectorText;
class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractPolygonalHandleRepresentation3D
: public vtkHandleRepresentation
{
public:
//@{
/**
* Standard methods for instances of this class.
*/
vtkTypeMacro(vtkAbstractPolygonalHandleRepresentation3D,vtkHandleRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) override;
//@}
//@{
/**
* Set the position of the point in world and display coordinates.
*/
void SetWorldPosition(double p[3]) override;
void SetDisplayPosition(double p[3]) override;
//@}
//@{
/**
* Set/get the handle polydata.
*/
void SetHandle( vtkPolyData * );
vtkPolyData * GetHandle();
//@}
//@{
/**
* Set/Get the handle properties when unselected and selected.
*/
void SetProperty(vtkProperty*);
void SetSelectedProperty(vtkProperty*);
vtkGetObjectMacro(Property,vtkProperty);
vtkGetObjectMacro(SelectedProperty,vtkProperty);
//@}
/**
* Get the transform used to transform the generic handle polydata before
* placing it in the render window
*/
virtual vtkAbstractTransform * GetTransform();
//@{
/**
* Methods to make this class properly act like a vtkWidgetRepresentation.
*/
void BuildRepresentation() override;
void StartWidgetInteraction(double eventPos[2]) override;
void WidgetInteraction(double eventPos[2]) override;
int ComputeInteractionState(int X, int Y, int modify=0) override;
//@}
//@{
/**
* Methods to make this class behave as a vtkProp.
*/
void ShallowCopy(vtkProp *prop) override;
void DeepCopy(vtkProp *prop) override;
void GetActors(vtkPropCollection *) override;
void ReleaseGraphicsResources(vtkWindow *) override;
int RenderOpaqueGeometry(vtkViewport *viewport) override;
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override;
vtkTypeBool HasTranslucentPolygonalGeometry() override;
double *GetBounds() override;
//@}
//@{
/**
* A label may be associated with the seed. The string can be set via
* SetLabelText. The visibility of the label can be turned on / off.
*/
vtkSetMacro( LabelVisibility, vtkTypeBool );
vtkGetMacro( LabelVisibility, vtkTypeBool );
vtkBooleanMacro( LabelVisibility, vtkTypeBool );
virtual void SetLabelText( const char * label );
virtual char * GetLabelText();
//@}
//@{
/**
* Scale text (font size along each dimension).
*/
virtual void SetLabelTextScale( double scale[3] );
void SetLabelTextScale(double x, double y, double z)
{
double scale[3] = {x, y, z};
this->SetLabelTextScale(scale);
}
virtual double * GetLabelTextScale();
//@}
//@{
/**
* Get the label text actor
*/
vtkGetObjectMacro( LabelTextActor, vtkFollower );
//@}
/**
* The handle may be scaled uniformly in all three dimensions using this
* API. The handle can also be scaled interactively using the right
* mouse button.
*/
virtual void SetUniformScale( double scale );
//@{
/**
* Toggle the visibility of the handle on and off
*/
vtkSetMacro( HandleVisibility, vtkTypeBool );
vtkGetMacro( HandleVisibility, vtkTypeBool );
vtkBooleanMacro( HandleVisibility, vtkTypeBool );
//@}
void Highlight(int highlight) override;
//@{
/**
* Turn on/off smooth motion of the handle. See the documentation of
* MoveFocusRequest for details. By default, SmoothMotion is ON. However,
* in certain applications the user may want to turn it off. For instance
* when using certain specific PointPlacer's with the representation such
* as the vtkCellCentersPointPlacer, which causes the representation to
* snap to the center of cells, or using a vtkPolygonalSurfacePointPlacer
* which constrains the widget to the surface of a mesh. In such cases,
* inherent restrictions on handle placement might conflict with a request
* for smooth motion of the handles.
*/
vtkSetMacro( SmoothMotion, vtkTypeBool );
vtkGetMacro( SmoothMotion, vtkTypeBool );
vtkBooleanMacro( SmoothMotion, vtkTypeBool );
//@}
/*
* Register internal Pickers within PickingManager
*/
void RegisterPickers() override;
protected:
vtkAbstractPolygonalHandleRepresentation3D();
~vtkAbstractPolygonalHandleRepresentation3D() override;
vtkActor * Actor;
vtkPolyDataMapper * Mapper;
vtkTransformPolyDataFilter * HandleTransformFilter;
vtkMatrixToLinearTransform * HandleTransform;
vtkMatrix4x4 * HandleTransformMatrix;
vtkCellPicker * HandlePicker;
double LastPickPosition[3];
double LastEventPosition[2];
int ConstraintAxis;
vtkProperty * Property;
vtkProperty * SelectedProperty;
int WaitingForMotion;
int WaitCount;
vtkTypeBool HandleVisibility;
// Methods to manipulate the cursor
virtual void Translate(double *p1, double *p2);
virtual void Scale(double *p1, double *p2, double eventPos[2]);
virtual void MoveFocus(double *p1, double *p2);
void CreateDefaultProperties();
// Given a motion vector defined by p1 --> p2 (p1 and p2 are in
// world coordinates), the new display position of the handle center is
// populated into requestedDisplayPos. This is again only a request for the
// new display position. It is up to the point placer to deduce the
// appropriate world co-ordinates that this display position will map into.
// The placer may even disallow such a movement.
// If "SmoothMotion" is OFF, the returned requestedDisplayPos is the same
// as the event position, ie the location of the mouse cursor. If its OFF,
// incremental offsets as described above are used to compute it.
void MoveFocusRequest( double *p1, double *p2,
double eventPos[2], double requestedDisplayPos[3] );
int DetermineConstraintAxis(int constraint, double *x, double *startPickPos);
/**
* Update the actor position. Different subclasses handle this differently.
* For instance vtkPolygonalHandleRepresentation3D updates the handle
* transformation and sets this on the handle.
* vtkOrientedPolygonalHandleRepresentation3D, which uses a vtkFollower to
* keep the handle geometry facinig the camera handles this differently. This
* is an opportunity for subclasses to update the actor's position etc each
* time the handle is rendered.
*/
virtual void UpdateHandle();
/**
* Opportunity to update the label position and text during each render.
*/
virtual void UpdateLabel();
// Handle the label.
vtkTypeBool LabelVisibility;
vtkFollower *LabelTextActor;
vtkPolyDataMapper *LabelTextMapper;
vtkVectorText *LabelTextInput;
bool LabelAnnotationTextScaleInitialized;
vtkTypeBool SmoothMotion;
private:
vtkAbstractPolygonalHandleRepresentation3D(const vtkAbstractPolygonalHandleRepresentation3D&) = delete;
void operator=(const vtkAbstractPolygonalHandleRepresentation3D&) = delete;
};
#endif