VTK  9.1.0
vtkSphereWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSphereWidget.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
88 #ifndef vtkSphereWidget_h
89 #define vtkSphereWidget_h
90 
91 #include "vtk3DWidget.h"
92 #include "vtkInteractionWidgetsModule.h" // For export macro
93 #include "vtkSphereSource.h" // Needed for faster access to the sphere source
94 
95 class vtkActor;
96 class vtkPolyDataMapper;
97 class vtkPoints;
98 class vtkPolyData;
99 class vtkSphereSource;
100 class vtkSphere;
101 class vtkCellPicker;
102 class vtkProperty;
103 
104 #define VTK_SPHERE_OFF 0
105 #define VTK_SPHERE_WIREFRAME 1
106 #define VTK_SPHERE_SURFACE 2
107 
108 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereWidget : public vtk3DWidget
109 {
110 public:
114  static vtkSphereWidget* New();
115 
116  vtkTypeMacro(vtkSphereWidget, vtk3DWidget);
117  void PrintSelf(ostream& os, vtkIndent indent) override;
118 
120 
123  void SetEnabled(int) override;
124  void PlaceWidget(double bounds[6]) override;
125  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
127  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
128  {
129  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
130  }
132 
134 
139  vtkSetClampMacro(Representation, int, VTK_SPHERE_OFF, VTK_SPHERE_SURFACE);
140  vtkGetMacro(Representation, int);
141  void SetRepresentationToOff() { this->SetRepresentation(VTK_SPHERE_OFF); }
142  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_SPHERE_WIREFRAME); }
143  void SetRepresentationToSurface() { this->SetRepresentation(VTK_SPHERE_SURFACE); }
145 
150  void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
151  int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
152 
157  void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
158  int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
159 
161 
164  void SetRadius(double r)
165  {
166  if (r <= 0)
167  {
168  r = .00001;
169  }
170  this->SphereSource->SetRadius(r);
171  }
172  double GetRadius() { return this->SphereSource->GetRadius(); }
174 
176 
179  void SetCenter(double x, double y, double z) { this->SphereSource->SetCenter(x, y, z); }
180  void SetCenter(double x[3]) { this->SetCenter(x[0], x[1], x[2]); }
181  double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
182  void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
184 
186 
190  vtkSetMacro(Translation, vtkTypeBool);
191  vtkGetMacro(Translation, vtkTypeBool);
192  vtkBooleanMacro(Translation, vtkTypeBool);
193  vtkSetMacro(Scale, vtkTypeBool);
194  vtkGetMacro(Scale, vtkTypeBool);
195  vtkBooleanMacro(Scale, vtkTypeBool);
197 
199 
205  vtkSetMacro(HandleVisibility, vtkTypeBool);
206  vtkGetMacro(HandleVisibility, vtkTypeBool);
207  vtkBooleanMacro(HandleVisibility, vtkTypeBool);
209 
211 
216  vtkSetVector3Macro(HandleDirection, double);
217  vtkGetVector3Macro(HandleDirection, double);
219 
221 
224  vtkGetVector3Macro(HandlePosition, double);
226 
235 
242  void GetSphere(vtkSphere* sphere);
243 
245 
249  vtkGetObjectMacro(SphereProperty, vtkProperty);
250  vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
252 
254 
259  vtkGetObjectMacro(HandleProperty, vtkProperty);
260  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
262 
263 protected:
265  ~vtkSphereWidget() override;
266 
267  // Manage the state of the widget
268  int State;
270  {
271  Start = 0,
275  Outside
276  };
277 
278  // handles the events
279  static void ProcessEvents(
280  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
281 
282  // ProcessEvents() dispatches to these methods.
287  void OnMouseMove();
288 
289  // the sphere
293  void HighlightSphere(int highlight);
295 
296  // The representation of the sphere
298 
299  // Do the picking
301 
302  // Register internal Pickers within PickingManager
303  void RegisterPickers() override;
304 
305  // Methods to manipulate the sphere widget
308  void Translate(double* p1, double* p2);
309  void ScaleSphere(double* p1, double* p2, int X, int Y);
310  void MoveHandle(double* p1, double* p2, int X, int Y);
311  void PlaceHandle(double* center, double radius);
312 
313  // Properties used to control the appearance of selected objects and
314  // the manipulator in general.
320 
321  // Managing the handle
325  void HighlightHandle(int);
327  double HandleDirection[3];
328  double HandlePosition[3];
329  void SizeHandles() override;
330 
331 private:
332  vtkSphereWidget(const vtkSphereWidget&) = delete;
333  void operator=(const vtkSphereWidget&) = delete;
334 };
335 
336 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:146
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkSphereWidget::OnMouseMove
void OnMouseMove()
vtkSphereWidget::SphereSource
vtkSphereSource * SphereSource
Definition: vtkSphereWidget.h:292
vtkSphereWidget::vtkSphereWidget
vtkSphereWidget()
vtkSphereWidget::Picker
vtkCellPicker * Picker
Definition: vtkSphereWidget.h:300
vtkSphereWidget::ScaleSphere
void ScaleSphere(double *p1, double *p2, int X, int Y)
vtkSphereWidget::SetRadius
void SetRadius(double r)
Set/Get the radius of sphere.
Definition: vtkSphereWidget.h:164
vtkSphereWidget::PlaceHandle
void PlaceHandle(double *center, double radius)
vtkSphereWidget::GetCenter
double * GetCenter()
Set/Get the center of the sphere.
Definition: vtkSphereWidget.h:181
vtkSphereWidget::Translation
vtkTypeBool Translation
Definition: vtkSphereWidget.h:306
vtkSphereWidget::RegisterPickers
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkSphereWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSphereWidget::SetThetaResolution
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the Theta direction.
Definition: vtkSphereWidget.h:150
vtkSphereWidget::PlaceWidget
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkSphereWidget::HighlightHandle
void HighlightHandle(int)
vtkSphereWidget::WidgetState
WidgetState
Definition: vtkSphereWidget.h:270
vtkSphereWidget::Moving
@ Moving
Definition: vtkSphereWidget.h:272
VTK_SPHERE_OFF
#define VTK_SPHERE_OFF
Definition: vtkSphereWidget.h:104
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkSphereWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkSphereWidget.h:318
VTK_SPHERE_WIREFRAME
#define VTK_SPHERE_WIREFRAME
Definition: vtkSphereWidget.h:105
vtkSphereWidget::HandleMapper
vtkPolyDataMapper * HandleMapper
Definition: vtkSphereWidget.h:323
vtkX3D::center
@ center
Definition: vtkX3D.h:236
vtkSphereWidget::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkSphereWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkSphereWidget.h:317
vtkSphere
implicit function for a sphere
Definition: vtkSphere.h:141
vtkSphereWidget::Representation
int Representation
Definition: vtkSphereWidget.h:297
vtkSphereWidget::Scale
vtkTypeBool Scale
Definition: vtkSphereWidget.h:307
vtkSphereWidget::PlaceWidget
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkSphereWidget.h:125
vtkSphereWidget::HighlightSphere
void HighlightSphere(int highlight)
vtkSphereWidget::HandleVisibility
vtkTypeBool HandleVisibility
Definition: vtkSphereWidget.h:326
vtkSphereWidget::GetThetaResolution
int GetThetaResolution()
Definition: vtkSphereWidget.h:151
vtkSphereWidget::MoveHandle
void MoveHandle(double *p1, double *p2, int X, int Y)
vtkSphereWidget::SetEnabled
void SetEnabled(int) override
Methods that satisfy the superclass' API.
vtkSphereWidget::SphereProperty
vtkProperty * SphereProperty
Definition: vtkSphereWidget.h:315
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:48
vtkSphereWidget::CreateDefaultProperties
void CreateDefaultProperties()
vtkSphereWidget::SelectedSphereProperty
vtkProperty * SelectedSphereProperty
Definition: vtkSphereWidget.h:316
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:149
vtkSphereWidget::GetCenter
void GetCenter(double xyz[3])
Set/Get the center of the sphere.
Definition: vtkSphereWidget.h:182
vtkSphereWidget::~vtkSphereWidget
~vtkSphereWidget() override
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkSphereWidget::Scaling
@ Scaling
Definition: vtkSphereWidget.h:273
VTK_SPHERE_SURFACE
#define VTK_SPHERE_SURFACE
Definition: vtkSphereWidget.h:106
vtkSphereWidget::SetPhiResolution
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the Phi direction.
Definition: vtkSphereWidget.h:157
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
vtkSphereWidget::SphereActor
vtkActor * SphereActor
Definition: vtkSphereWidget.h:290
vtkSphereSource.h
vtkSphereWidget::GetPolyData
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the sphere.
vtkSphereWidget::OnLeftButtonUp
void OnLeftButtonUp()
vtkSphereWidget::OnRightButtonDown
void OnRightButtonDown()
vtkSphereWidget::SelectRepresentation
void SelectRepresentation()
vtkSphereWidget::GetRadius
double GetRadius()
Set/Get the radius of sphere.
Definition: vtkSphereWidget.h:172
vtkSphereWidget::GetSphere
void GetSphere(vtkSphere *sphere)
Get the spherical implicit function defined by this widget.
vtkSphereWidget::Translate
void Translate(double *p1, double *p2)
vtkSphereWidget::SizeHandles
void SizeHandles() override
vtkSphereWidget::State
int State
Definition: vtkSphereWidget.h:268
vtkSphereWidget::SetCenter
void SetCenter(double x[3])
Set/Get the center of the sphere.
Definition: vtkSphereWidget.h:180
vtkSphereWidget::SetRepresentationToWireframe
void SetRepresentationToWireframe()
Set the representation of the sphere.
Definition: vtkSphereWidget.h:142
vtkSphereWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
Definition: vtkSphereWidget.h:126
vtkSphereWidget::SetRepresentationToSurface
void SetRepresentationToSurface()
Set the representation of the sphere.
Definition: vtkSphereWidget.h:143
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkSphereWidget
3D widget for manipulating a sphere
Definition: vtkSphereWidget.h:109
vtkSphereWidget::New
static vtkSphereWidget * New()
Instantiate the object.
vtkSphereWidget::SetRepresentationToOff
void SetRepresentationToOff()
Set the representation of the sphere.
Definition: vtkSphereWidget.h:141
vtkSphereWidget::GetPhiResolution
int GetPhiResolution()
Definition: vtkSphereWidget.h:158
vtkSphereWidget::SetCenter
void SetCenter(double x, double y, double z)
Set/Get the center of the sphere.
Definition: vtkSphereWidget.h:179
vtkSphereWidget::HandleActor
vtkActor * HandleActor
Definition: vtkSphereWidget.h:322
vtkSphereWidget::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkSphereWidget.h:291
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:171
vtkSphereWidget::OnLeftButtonDown
void OnLeftButtonDown()
vtkSphereWidget::OnRightButtonUp
void OnRightButtonUp()
vtkX3D::radius
@ radius
Definition: vtkX3D.h:258
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
vtkSphereWidget::Positioning
@ Positioning
Definition: vtkSphereWidget.h:274
vtkSphereWidget::HandleSource
vtkSphereSource * HandleSource
Definition: vtkSphereWidget.h:324
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69