VTK  9.5.2
vtkSphereWidget.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
72
73#ifndef vtkSphereWidget_h
74#define vtkSphereWidget_h
75
76#include "vtk3DWidget.h"
77#include "vtkInteractionWidgetsModule.h" // For export macro
78#include "vtkSphereSource.h" // Needed for faster access to the sphere source
79
80VTK_ABI_NAMESPACE_BEGIN
81class vtkActor;
83class vtkPoints;
84class vtkPolyData;
85class vtkSphereSource;
86class vtkSphere;
87class vtkCellPicker;
88class vtkProperty;
89
90#define VTK_SPHERE_OFF 0
91#define VTK_SPHERE_WIREFRAME 1
92#define VTK_SPHERE_SURFACE 2
93
94class VTKINTERACTIONWIDGETS_EXPORT vtkSphereWidget : public vtk3DWidget
95{
96public:
101
103 void PrintSelf(ostream& os, vtkIndent indent) override;
104
106
109 void SetEnabled(int) override;
110 void PlaceWidget(double bounds[6]) override;
111 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
113 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
114 {
115 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
116 }
117
118
120
126 vtkGetMacro(Representation, int);
131
136 void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
137 int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
138
143 void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
144 int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
145
147
150 void SetRadius(double r)
151 {
152 if (r <= 0)
153 {
154 r = .00001;
155 }
156 this->SphereSource->SetRadius(r);
157 }
158 double GetRadius() { return this->SphereSource->GetRadius(); }
160
162
165 void SetCenter(double x, double y, double z) { this->SphereSource->SetCenter(x, y, z); }
166 void SetCenter(double x[3]) { this->SetCenter(x[0], x[1], x[2]); }
167 double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
168 void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
170
172
178 vtkBooleanMacro(Translation, vtkTypeBool);
179 vtkSetMacro(Scale, vtkTypeBool);
180 vtkGetMacro(Scale, vtkTypeBool);
181 vtkBooleanMacro(Scale, vtkTypeBool);
183
185
193 vtkBooleanMacro(HandleVisibility, vtkTypeBool);
195
197
202 vtkSetVector3Macro(HandleDirection, double);
203 vtkGetVector3Macro(HandleDirection, double);
205
207
210 vtkGetVector3Macro(HandlePosition, double);
212
221
228 void GetSphere(vtkSphere* sphere);
229
231
235 vtkGetObjectMacro(SphereProperty, vtkProperty);
238
240
245 vtkGetObjectMacro(HandleProperty, vtkProperty);
248
249protected:
252
253 // Manage the state of the widget
254 int State;
263
264 // handles the events
265 static void ProcessEvents(
266 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
267
268 // ProcessEvents() dispatches to these methods.
274
275 // the sphere
279 void HighlightSphere(int highlight);
281
282 // The representation of the sphere
284
285 // Do the picking
287
288 // Register internal Pickers within PickingManager
289 void RegisterPickers() override;
290
291 // Methods to manipulate the sphere widget
294 void Translate(double* p1, double* p2);
295 void ScaleSphere(double* p1, double* p2, int X, int Y);
296 void MoveHandle(double* p1, double* p2, int X, int Y);
297 void PlaceHandle(double* center, double radius);
298
299 // Properties used to control the appearance of selected objects and
300 // the manipulator in general.
306
307 // Managing the handle
314 double HandlePosition[3];
315 void SizeHandles() override;
316
317private:
318 vtkSphereWidget(const vtkSphereWidget&) = delete;
319 void operator=(const vtkSphereWidget&) = delete;
320};
321
322VTK_ABI_NAMESPACE_END
323#endif
virtual void PlaceWidget(double bounds[6])=0
This method is used to initially place the widget.
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 3D points
Definition vtkPoints.h:139
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
represent surface properties of a geometric object
create a polygonal sphere centered at the origin
double * GetCenter()
Set/Get the center of the sphere.
double HandlePosition[3]
vtkCellPicker * Picker
double HandleDirection[3]
void GetCenter(double xyz[3])
Set/Get the center of the sphere.
~vtkSphereWidget() override
void OnRightButtonUp()
vtkProperty * SelectedSphereProperty
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
void SizeHandles() override
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
void SelectRepresentation()
vtkPolyDataMapper * HandleMapper
void SetCenter(double x[3])
Set/Get the center of the sphere.
double GetRadius()
Set/Get the radius of sphere.
void HighlightHandle(int)
void SetCenter(double x, double y, double z)
Set/Get the center of the sphere.
void CreateDefaultProperties()
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the sphere.
void SetRadius(double r)
Set/Get the radius of sphere.
vtkSphereSource * HandleSource
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkTypeBool HandleVisibility
static vtkSphereWidget * New()
Instantiate the object.
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the Theta direction.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
virtual void SetRepresentation(int)
Set the representation of the sphere.
void OnLeftButtonUp()
vtkPolyDataMapper * SphereMapper
vtkProperty * SphereProperty
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void OnLeftButtonDown()
void Translate(double *p1, double *p2)
vtkActor * HandleActor
void HighlightSphere(int highlight)
void MoveHandle(double *p1, double *p2, int X, int Y)
vtkTypeBool Translation
void SetRepresentationToSurface()
Set the representation of the sphere.
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the Phi direction.
vtkProperty * HandleProperty
void GetSphere(vtkSphere *sphere)
Get the spherical implicit function defined by this widget.
vtkActor * SphereActor
void SetRepresentationToWireframe()
Set the representation of the sphere.
vtkSphereSource * SphereSource
void SetRepresentationToOff()
Set the representation of the sphere.
void OnRightButtonDown()
void PlaceWidget() override
Methods that satisfy the superclass' API.
void ScaleSphere(double *p1, double *p2, int X, int Y)
vtkProperty * SelectedHandleProperty
void PlaceHandle(double *center, double radius)
implicit function for a sphere
Definition vtkSphere.h:133
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SPHERE_SURFACE
#define VTK_SPHERE_OFF
#define VTK_SPHERE_WIREFRAME
#define VTK_SIZEHINT(...)