VTK  9.3.0
vtkSphereRepresentation.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
37#ifndef vtkSphereRepresentation_h
38#define vtkSphereRepresentation_h
39
40#include "vtkInteractionWidgetsModule.h" // For export macro
41#include "vtkSphereSource.h" // Needed for fast access to the sphere source
43
44VTK_ABI_NAMESPACE_BEGIN
45class vtkActor;
47class vtkSphere;
48class vtkSphereSource;
49class vtkCellPicker;
50class vtkProperty;
51class vtkPolyData;
52class vtkPoints;
54class vtkTransform;
55class vtkDoubleArray;
56class vtkMatrix4x4;
57class vtkTextMapper;
58class vtkActor2D;
59class vtkTextProperty;
60class vtkLineSource;
61class vtkCursor3D;
62
63#define VTK_SPHERE_OFF 0
64#define VTK_SPHERE_WIREFRAME 1
65#define VTK_SPHERE_SURFACE 2
66
67class VTKINTERACTIONWIDGETS_EXPORT vtkSphereRepresentation : public vtkWidgetRepresentation
68{
69public:
74
76
80 void PrintSelf(ostream& os, vtkIndent indent) override;
82
83 // Used to manage the state of the widget
84 enum
85 {
86 Outside = 0,
90 Scaling
91 };
92
94
98 vtkSetClampMacro(Representation, int, VTK_SPHERE_OFF, VTK_SPHERE_SURFACE);
99 vtkGetMacro(Representation, int);
100 void SetRepresentationToOff() { this->SetRepresentation(VTK_SPHERE_OFF); }
101 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_SPHERE_WIREFRAME); }
102 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SPHERE_SURFACE); }
104
108 void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
109 int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
110
114 void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
115 int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
116
122 void SetCenter(double c[3]);
123 void SetCenter(double x, double y, double z)
124 {
125 double c[3];
126 c[0] = x;
127 c[1] = y;
128 c[2] = z;
129 this->SetCenter(c);
130 }
131 double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
132 void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
133
138 void SetRadius(double r);
139 double GetRadius() { return this->SphereSource->GetRadius(); }
140
142
148 vtkSetMacro(HandleVisibility, vtkTypeBool);
149 vtkGetMacro(HandleVisibility, vtkTypeBool);
150 vtkBooleanMacro(HandleVisibility, vtkTypeBool);
152
154
158 void SetHandlePosition(double handle[3]);
159 void SetHandlePosition(double x, double y, double z)
160 {
161 double p[3];
162 p[0] = x;
163 p[1] = y;
164 p[2] = z;
165 this->SetHandlePosition(p);
166 }
167 vtkGetVector3Macro(HandlePosition, double);
169
171
176 void SetHandleDirection(double dir[3]);
177 void SetHandleDirection(double dx, double dy, double dz)
178 {
179 double d[3];
180 d[0] = dx;
181 d[1] = dy;
182 d[2] = dz;
183 this->SetHandleDirection(d);
184 }
185 vtkGetVector3Macro(HandleDirection, double);
187
189
196 vtkSetMacro(HandleText, vtkTypeBool);
197 vtkGetMacro(HandleText, vtkTypeBool);
198 vtkBooleanMacro(HandleText, vtkTypeBool);
200
202
206 vtkSetMacro(RadialLine, vtkTypeBool);
207 vtkGetMacro(RadialLine, vtkTypeBool);
208 vtkBooleanMacro(RadialLine, vtkTypeBool);
210
212
216 vtkSetMacro(CenterCursor, bool);
217 vtkGetMacro(CenterCursor, bool);
218 vtkBooleanMacro(CenterCursor, bool);
220
229
236 void GetSphere(vtkSphere* sphere);
237
239
243 vtkGetObjectMacro(SphereProperty, vtkProperty);
244 vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
246
248
253 vtkGetObjectMacro(HandleProperty, vtkProperty);
254 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
256
258
262 vtkGetObjectMacro(HandleTextProperty, vtkTextProperty);
264
266
270 vtkGetObjectMacro(RadialLineProperty, vtkProperty);
272
274
278 void SetInteractionColor(double, double, double);
279 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
280 void SetHandleColor(double, double, double);
281 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
282 void SetForegroundColor(double, double, double);
283 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
285
295 void SetInteractionState(int state);
296
298
303 void PlaceWidget(double bounds[6]) override;
304 virtual void PlaceWidget(double center[3], double handlePosition[3]);
305 void BuildRepresentation() override;
306 int ComputeInteractionState(int X, int Y, int modify = 0) override;
307 void StartWidgetInteraction(double e[2]) override;
308 void WidgetInteraction(double e[2]) override;
309 double* GetBounds() override;
311
313
322
323 /*
324 * Register internal Pickers within PickingManager
325 */
326 void RegisterPickers() override;
327
329
333 vtkGetMacro(TranslationAxis, int);
334 vtkSetClampMacro(TranslationAxis, int, -1, 2);
336
338
341 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
342 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
343 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
344 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
346
348
351 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
353
354protected:
357
358 // Manage how the representation appears
359 double LastEventPosition[3];
360
362
363 // the sphere
367 void HighlightSphere(int highlight);
368
369 // The representation of the sphere
371
372 // Do the picking
375 double LastPickPosition[3];
376
377 // Methods to manipulate the sphere widget
378 void Translate(const double* p1, const double* p2);
379 void Scale(const double* p1, const double* p2, int X, int Y);
380 void PlaceHandle(const double* center, double radius);
381 virtual void SizeHandles();
382
383 // Method to adapt the center cursor bounds
384 // so it always have the same pixel size on screen
386
387 // Properties used to control the appearance of selected objects and
388 // the manipulator in general.
394
395 // Managing the handle
401 double HandleDirection[3];
402 double HandlePosition[3];
403
404 // Manage the handle label
409
410 // Manage the radial line segment
416
417 // Managing the center cursor
422
423private:
425 void operator=(const vtkSphereRepresentation&) = delete;
426};
427
428VTK_ABI_NAMESPACE_END
429#endif
a actor that draws 2D data
Definition vtkActor2D.h:35
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
ray-cast cell picker for all kinds of Prop3Ds
generate a 3D cursor representation
Definition vtkCursor3D.h:29
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:29
create a line defined by two end points
represent and manipulate 4x4 transformation matrices
represent and manipulate 3D points
Definition vtkPoints.h:29
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:80
represent surface properties of a geometric object
Definition vtkProperty.h:57
a class defining the representation for the vtkSphereWidget2
void SetHandleDirection(double dx, double dy, double dz)
Set/Get the direction vector of the handle relative to the center of the sphere.
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the phi direction.
void SetRepresentationToWireframe()
Set the representation (i.e., appearance) of the sphere.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the sphere.
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and to print out the contents of the class.
void SetForegroundColor(double, double, double)
Set the interaction color of sphere and handle.
void SetHandleDirection(double dir[3])
Set/Get the direction vector of the handle relative to the center of the sphere.
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetCenter(double x, double y, double z)
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
static vtkSphereRepresentation * New()
Instantiate the class.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void SetForegroundColor(double c[3])
Set the interaction color of sphere and handle.
void SetHandleColor(double, double, double)
Set the interaction color of sphere and handle.
void SetInteractionColor(double c[3])
Set the interaction color of sphere and handle.
void SetRepresentationToOff()
Set the representation (i.e., appearance) of the sphere.
virtual void PlaceWidget(double center[3], double handlePosition[3])
These are methods that satisfy vtkWidgetRepresentation's API.
void SetCenter(double c[3])
Set/Get the center position of the sphere.
void PlaceHandle(const double *center, double radius)
vtkPolyDataMapper * RadialLineMapper
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the theta direction.
void SetHandleColor(double c[3])
Set the interaction color of sphere and handle.
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkSphereWidget2) or other object.
void SetInteractionColor(double, double, double)
Set the interaction color of sphere and handle.
void GetSphere(vtkSphere *sphere)
Get the spherical implicit function defined by this widget.
void HighlightSphere(int highlight)
void SetRadius(double r)
Set/Get the radius of sphere.
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
~vtkSphereRepresentation() override
void SetHandlePosition(double x, double y, double z)
Set/Get the position of the handle.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
int RenderOverlay(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetRepresentationToSurface()
Set the representation (i.e., appearance) of the sphere.
void SetHandlePosition(double handle[3])
Set/Get the position of the handle.
virtual void SizeHandles()
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting, and required by, the rendering process.
void Scale(const double *p1, const double *p2, int X, int Y)
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void AdaptCenterCursorBounds()
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting, and required by, the rendering process.
void Translate(const double *p1, const double *p2)
create a polygonal sphere centered at the origin
implicit function for a sphere
Definition vtkSphere.h:24
2D text annotation
represent text properties.
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SPHERE_SURFACE
#define VTK_SPHERE_OFF
#define VTK_SPHERE_WIREFRAME
#define VTK_SIZEHINT(...)