VTK  9.4.20251007
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
36
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
44
45VTK_ABI_NAMESPACE_BEGIN
46class vtkActor;
48class vtkSphere;
49class vtkSphereSource;
50class vtkCellPicker;
51class vtkProperty;
52class vtkPolyData;
53class vtkPoints;
55class vtkTransform;
56class vtkDoubleArray;
57class vtkMatrix4x4;
58class vtkTextMapper;
59class vtkActor2D;
60class vtkTextProperty;
61class vtkLineSource;
62class vtkCursor3D;
63
64#define VTK_SPHERE_OFF 0
65#define VTK_SPHERE_WIREFRAME 1
66#define VTK_SPHERE_SURFACE 2
67
68class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkSphereRepresentation
70{
71public:
76
78
82 void PrintSelf(ostream& os, vtkIndent indent) override;
84
85 // Used to manage the state of the widget
86 enum
87 {
93 };
94
96
101 vtkGetMacro(Representation, int);
106
110 void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
111 int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
112
116 void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
117 int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
118
124 void SetCenter(double c[3]);
125 void SetCenter(double x, double y, double z)
126 {
127 double c[3];
128 c[0] = x;
129 c[1] = y;
130 c[2] = z;
131 this->SetCenter(c);
132 }
133 double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
134 void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
135
140 void SetRadius(double r);
141 double GetRadius() { return this->SphereSource->GetRadius(); }
142
144
152 vtkBooleanMacro(HandleVisibility, vtkTypeBool);
154
156
160 void SetHandlePosition(double handle[3]);
161 void SetHandlePosition(double x, double y, double z)
162 {
163 double p[3];
164 p[0] = x;
165 p[1] = y;
166 p[2] = z;
167 this->SetHandlePosition(p);
168 }
169 vtkGetVector3Macro(HandlePosition, double);
171
173
178 void SetHandleDirection(double dir[3]);
179 void SetHandleDirection(double dx, double dy, double dz)
180 {
181 double d[3];
182 d[0] = dx;
183 d[1] = dy;
184 d[2] = dz;
185 this->SetHandleDirection(d);
186 }
187 vtkGetVector3Macro(HandleDirection, double);
189
191
198 vtkSetMacro(HandleText, vtkTypeBool);
199 vtkGetMacro(HandleText, vtkTypeBool);
200 vtkBooleanMacro(HandleText, vtkTypeBool);
202
204
208 vtkSetMacro(RadialLine, vtkTypeBool);
209 vtkGetMacro(RadialLine, vtkTypeBool);
210 vtkBooleanMacro(RadialLine, vtkTypeBool);
212
214
218 vtkSetMacro(CenterCursor, bool);
219 vtkGetMacro(CenterCursor, bool);
220 vtkBooleanMacro(CenterCursor, bool);
222
231
238 void GetSphere(vtkSphere* sphere);
239
241
245 vtkGetObjectMacro(SphereProperty, vtkProperty);
248
250
255 vtkGetObjectMacro(HandleProperty, vtkProperty);
258
260
266
268
272 vtkGetObjectMacro(RadialLineProperty, vtkProperty);
274
276
280 void SetInteractionColor(double, double, double);
281 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
282 void SetHandleColor(double, double, double);
283 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
284 void SetForegroundColor(double, double, double);
285 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
287
297 void SetInteractionState(int state);
298
300
305 void PlaceWidget(double bounds[6]) override;
306 virtual void PlaceWidget(double center[3], double handlePosition[3]);
307 void BuildRepresentation() override;
308 int ComputeInteractionState(int X, int Y, int modify = 0) override;
309 void StartWidgetInteraction(double e[2]) override;
310 void WidgetInteraction(double e[2]) override;
311 double* GetBounds() override;
313
315
324
325 /*
326 * Register internal Pickers within PickingManager
327 */
328 void RegisterPickers() override;
329
331
335 vtkGetMacro(TranslationAxis, int);
336 vtkSetClampMacro(TranslationAxis, int, -1, 2);
338
340
348
350
355
356protected:
359
360 // Manage how the representation appears
362
364
365 // the sphere
369 void HighlightSphere(int highlight);
370
371 // The representation of the sphere
373
374 // Do the picking
378
379 // Methods to manipulate the sphere widget
380 void Translate(const double* p1, const double* p2);
381 void Scale(const double* p1, const double* p2, int X, int Y);
382 void PlaceHandle(const double* center, double radius);
383 virtual void SizeHandles();
384
385 // Method to adapt the center cursor bounds
386 // so it always have the same pixel size on screen
388
389 // Properties used to control the appearance of selected objects and
390 // the manipulator in general.
396
397 // Managing the handle
404 double HandlePosition[3];
405
406 // Manage the handle label
411
412 // Manage the radial line segment
418
419 // Managing the center cursor
424
425private:
427 void operator=(const vtkSphereRepresentation&) = delete;
428};
429
430VTK_ABI_NAMESPACE_END
431#endif
a actor that draws 2D data
Definition vtkActor2D.h:36
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
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:30
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
represent surface properties of a geometric object
Definition vtkProperty.h:60
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.
virtual void SetRepresentation(int)
Set the representation (i.e., appearance) of the sphere.
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:46
window superclass for vtkRenderWindow
Definition vtkWindow.h:29
int vtkTypeBool
Definition vtkABI.h:64
#define vtkPolyDataAlgorithm
#define VTK_SPHERE_SURFACE
#define VTK_SPHERE_OFF
#define VTK_SPHERE_WIREFRAME
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO