forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkSphereHandleRepresentation.h
187 lines (159 loc) · 5.73 KB
/
vtkSphereHandleRepresentation.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
/*=========================================================================
Program: Visualization Toolkit
Module: vtkSphereHandleRepresentation.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 vtkSphereHandleRepresentation
* @brief A spherical rendition of point in 3D space
*
*
* This class is a concrete implementation of vtkHandleRepresentation. It
* renders handles as spherical blobs in 3D space.
*
* @sa
* vtkHandleRepresentation vtkHandleWidget vtkSphereSource
*/
#ifndef vtkSphereHandleRepresentation_h
#define vtkSphereHandleRepresentation_h
#include "vtkInteractionWidgetsModule.h" // For export macro
#include "vtkHandleRepresentation.h"
#include "vtkSphereSource.h" // Needed for delegation to sphere
class vtkSphereSource;
class vtkProperty;
class vtkActor;
class vtkPolyDataMapper;
class vtkCellPicker;
class VTKINTERACTIONWIDGETS_EXPORT vtkSphereHandleRepresentation
: public vtkHandleRepresentation
{
public:
/**
* Instantiate this class.
*/
static vtkSphereHandleRepresentation *New();
//@{
/**
* Standard methods for instances of this class.
*/
vtkTypeMacro(vtkSphereHandleRepresentation,vtkHandleRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
//@}
//@{
/**
* Set the position of the point in world and display coordinates. Note
* that if the position is set outside of the bounding box, it will be
* clamped to the boundary of the bounding box. This method overloads
* the superclasses' SetWorldPosition() and SetDisplayPosition() in
* order to set the focal point of the cursor properly.
*/
void SetWorldPosition(double p[3]) VTK_OVERRIDE;
void SetDisplayPosition(double p[3]) VTK_OVERRIDE;
//@}
//@{
/**
* If translation mode is on, as the widget is moved the bounding box,
* shadows, and cursor are all translated simultaneously as the point moves
* (i.e., the left and middle mouse buttons act the same). Otherwise, only
* the cursor focal point moves, which is constrained by the bounds of the
* point representation. (Note that the bounds can be scaled up using the
* right mouse button.)
*/
vtkSetMacro(TranslationMode,int);
vtkGetMacro(TranslationMode,int);
vtkBooleanMacro(TranslationMode,int);
//@}
void SetSphereRadius(double);
double GetSphereRadius();
//@{
/**
* Set/Get the handle properties when unselected and selected.
*/
void SetProperty(vtkProperty*);
void SetSelectedProperty(vtkProperty*);
vtkGetObjectMacro(Property,vtkProperty);
vtkGetObjectMacro(SelectedProperty,vtkProperty);
//@}
//@{
/**
* Set the "hot spot" size; i.e., the region around the focus, in which the
* motion vector is used to control the constrained sliding action. Note the
* size is specified as a fraction of the length of the diagonal of the
* point widget's bounding box.
*/
vtkSetClampMacro(HotSpotSize,double,0.0,1.0);
vtkGetMacro(HotSpotSize,double);
//@}
/**
* Overload the superclasses SetHandleSize() method to update internal
* variables.
*/
void SetHandleSize(double size) VTK_OVERRIDE;
//@{
/**
* Methods to make this class properly act like a vtkWidgetRepresentation.
*/
double *GetBounds() VTK_OVERRIDE;
void BuildRepresentation() VTK_OVERRIDE;
void StartWidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
void WidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
int ComputeInteractionState(int X, int Y, int modify=0) VTK_OVERRIDE;
void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
//@}
//@{
/**
* Methods to make this class behave as a vtkProp.
*/
void ShallowCopy(vtkProp *prop) VTK_OVERRIDE;
void DeepCopy(vtkProp *prop) VTK_OVERRIDE;
void GetActors(vtkPropCollection *) VTK_OVERRIDE;
void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
int RenderOpaqueGeometry(vtkViewport *viewport) VTK_OVERRIDE;
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) VTK_OVERRIDE;
int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
//@}
void Highlight(int highlight) VTK_OVERRIDE;
protected:
vtkSphereHandleRepresentation();
~vtkSphereHandleRepresentation() VTK_OVERRIDE;
// the cursor3D
vtkActor *Actor;
vtkPolyDataMapper *Mapper;
vtkSphereSource *Sphere;
// void Highlight(int highlight);
// Do the picking
vtkCellPicker *CursorPicker;
double LastPickPosition[3];
double LastEventPosition[2];
// Register internal Pickers within PickingManager
void RegisterPickers() VTK_OVERRIDE;
// Methods to manipulate the cursor
int ConstraintAxis;
void Translate(double *p1, double *p2);
void Scale(double *p1, double *p2, double eventPos[2]);
void MoveFocus(double *p1, double *p2);
void SizeBounds();
// Properties used to control the appearance of selected objects and
// the manipulator in general.
vtkProperty *Property;
vtkProperty *SelectedProperty;
void CreateDefaultProperties();
// The size of the hot spot.
double HotSpotSize;
int DetermineConstraintAxis(int constraint, double *x);
int WaitingForMotion;
int WaitCount;
// Current handle sized (may reflect scaling)
double CurrentHandleSize;
// Control how translation works
int TranslationMode;
private:
vtkSphereHandleRepresentation(const vtkSphereHandleRepresentation&) VTK_DELETE_FUNCTION;
void operator=(const vtkSphereHandleRepresentation&) VTK_DELETE_FUNCTION;
};
#endif