VTK
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 =========================================================================*/
53 #ifndef vtkSphereWidget_h
54 #define vtkSphereWidget_h
55 
56 #include "vtkInteractionWidgetsModule.h" // For export macro
57 #include "vtk3DWidget.h"
58 #include "vtkSphereSource.h" // Needed for faster access to the sphere source
59 
60 class vtkActor;
61 class vtkPolyDataMapper;
62 class vtkPoints;
63 class vtkPolyData;
64 class vtkSphereSource;
65 class vtkSphere;
66 class vtkCellPicker;
67 class vtkProperty;
68 
69 #define VTK_SPHERE_OFF 0
70 #define VTK_SPHERE_WIREFRAME 1
71 #define VTK_SPHERE_SURFACE 2
72 
73 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereWidget : public vtk3DWidget
74 {
75 public:
79  static vtkSphereWidget *New();
80 
82  void PrintSelf(ostream& os, vtkIndent indent) override;
83 
85 
88  void SetEnabled(int) override;
89  void PlaceWidget(double bounds[6]) override;
90  void PlaceWidget() override
91  {this->Superclass::PlaceWidget();}
92  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
93  double zmin, double zmax) override
94  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
96 
98 
103  vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
104  vtkGetMacro(Representation,int);
106  { this->SetRepresentation(VTK_SPHERE_OFF);}
108  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
110  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
112 
117  void SetThetaResolution(int r)
118  { this->SphereSource->SetThetaResolution(r); }
120  { return this->SphereSource->GetThetaResolution(); }
121 
126  void SetPhiResolution(int r)
127  { this->SphereSource->SetPhiResolution(r); }
129  { return this->SphereSource->GetPhiResolution(); }
130 
132 
135  void SetRadius(double r)
136  {
137  if ( r <= 0 )
138  {
139  r = .00001;
140  }
141  this->SphereSource->SetRadius(r);
142  }
143  double GetRadius()
144  { return this->SphereSource->GetRadius(); }
146 
148 
151  void SetCenter(double x, double y, double z)
152  {
153  this->SphereSource->SetCenter(x,y,z);
154  }
155  void SetCenter(double x[3])
156  {
157  this->SetCenter(x[0], x[1], x[2]);
158  }
159  double* GetCenter() VTK_SIZEHINT(3)
160  {return this->SphereSource->GetCenter();}
161  void GetCenter(double xyz[3])
162  {this->SphereSource->GetCenter(xyz);}
164 
166 
170  vtkSetMacro(Translation,vtkTypeBool);
171  vtkGetMacro(Translation,vtkTypeBool);
172  vtkBooleanMacro(Translation,vtkTypeBool);
173  vtkSetMacro(Scale,vtkTypeBool);
174  vtkGetMacro(Scale,vtkTypeBool);
175  vtkBooleanMacro(Scale,vtkTypeBool);
177 
179 
185  vtkSetMacro(HandleVisibility,vtkTypeBool);
186  vtkGetMacro(HandleVisibility,vtkTypeBool);
187  vtkBooleanMacro(HandleVisibility,vtkTypeBool);
189 
191 
196  vtkSetVector3Macro(HandleDirection,double);
197  vtkGetVector3Macro(HandleDirection,double);
199 
201 
204  vtkGetVector3Macro(HandlePosition,double);
206 
214  void GetPolyData(vtkPolyData *pd);
215 
222  void GetSphere(vtkSphere *sphere);
223 
225 
229  vtkGetObjectMacro(SphereProperty,vtkProperty);
230  vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
232 
234 
239  vtkGetObjectMacro(HandleProperty,vtkProperty);
240  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
242 
243 protected:
244  vtkSphereWidget();
245  ~vtkSphereWidget() override;
246 
247  // Manage the state of the widget
248  int State;
250  {
251  Start=0,
255  Outside
256  };
257 
258  //handles the events
259  static void ProcessEvents(vtkObject* object,
260  unsigned long event,
261  void* clientdata,
262  void* calldata);
263 
264  // ProcessEvents() dispatches to these methods.
265  void OnLeftButtonDown();
266  void OnLeftButtonUp();
267  void OnRightButtonDown();
268  void OnRightButtonUp();
269  void OnMouseMove();
270 
271  // the sphere
275  void HighlightSphere(int highlight);
276  void SelectRepresentation();
277 
278  // The representation of the sphere
280 
281  // Do the picking
283 
284  // Register internal Pickers within PickingManager
285  void RegisterPickers() override;
286 
287  // Methods to manipulate the sphere widget
290  void Translate(double *p1, double *p2);
291  void ScaleSphere(double *p1, double *p2, int X, int Y);
292  void MoveHandle(double *p1, double *p2, int X, int Y);
293  void PlaceHandle(double *center, double radius);
294 
295  // Properties used to control the appearance of selected objects and
296  // the manipulator in general.
301  void CreateDefaultProperties();
302 
303  // Managing the handle
307  void HighlightHandle(int);
309  double HandleDirection[3];
310  double HandlePosition[3];
311  void SizeHandles() override;
312 
313 private:
314  vtkSphereWidget(const vtkSphereWidget&) = delete;
315  void operator=(const vtkSphereWidget&) = delete;
316 };
317 
318 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkSphereWidget::SphereSource
vtkSphereSource * SphereSource
Definition: vtkSphereWidget.h:274
vtkSphereWidget::Picker
vtkCellPicker * Picker
Definition: vtkSphereWidget.h:282
vtkSphereWidget::SetRadius
void SetRadius(double r)
Set/Get the radius of sphere.
Definition: vtkSphereWidget.h:135
vtkSphereWidget::GetCenter
double * GetCenter()
Definition: vtkSphereWidget.h:159
vtkSphereWidget::Translation
vtkTypeBool Translation
Definition: vtkSphereWidget.h:288
vtkSphereWidget::SetThetaResolution
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the Theta direction.
Definition: vtkSphereWidget.h:117
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkSphereWidget::WidgetState
WidgetState
Definition: vtkSphereWidget.h:249
vtkSphereWidget::Moving
Definition: vtkSphereWidget.h:252
VTK_SPHERE_OFF
#define VTK_SPHERE_OFF
Definition: vtkSphereWidget.h:69
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkSphereWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkSphereWidget.h:300
VTK_SPHERE_WIREFRAME
#define VTK_SPHERE_WIREFRAME
Definition: vtkSphereWidget.h:70
vtkSphereWidget::HandleMapper
vtkPolyDataMapper * HandleMapper
Definition: vtkSphereWidget.h:305
vtk3DWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkX3D::center
Definition: vtkX3D.h:230
vtkSphereWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkSphereWidget.h:299
vtkSphere
implicit function for a sphere
Definition: vtkSphere.h:31
vtkSphereWidget::Representation
int Representation
Definition: vtkSphereWidget.h:279
vtkSphereWidget::Scale
vtkTypeBool Scale
Definition: vtkSphereWidget.h:289
vtkSphereWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkSphereWidget.h:90
vtkSphereWidget::HandleVisibility
vtkTypeBool HandleVisibility
Definition: vtkSphereWidget.h:308
vtkSphereWidget::GetThetaResolution
int GetThetaResolution()
Definition: vtkSphereWidget.h:119
vtkSphereWidget::SphereProperty
vtkProperty * SphereProperty
Definition: vtkSphereWidget.h:297
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkSphereWidget::SelectedSphereProperty
vtkProperty * SelectedSphereProperty
Definition: vtkSphereWidget.h:298
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkInteractorObserver::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkSphereWidget::GetCenter
void GetCenter(double xyz[3])
Definition: vtkSphereWidget.h:161
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:73
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSphereWidget::Scaling
Definition: vtkSphereWidget.h:253
VTK_SPHERE_SURFACE
#define VTK_SPHERE_SURFACE
Definition: vtkSphereWidget.h:71
vtkSphereWidget::SetPhiResolution
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the Phi direction.
Definition: vtkSphereWidget.h:126
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
vtkSphereWidget::SphereActor
vtkActor * SphereActor
Definition: vtkSphereWidget.h:272
vtkSphereSource.h
vtkSphereWidget::GetRadius
double GetRadius()
Definition: vtkSphereWidget.h:143
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtk3DWidget::SizeHandles
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkSphereWidget::State
int State
Definition: vtkSphereWidget.h:248
vtkSphereWidget::SetCenter
void SetCenter(double x[3])
Definition: vtkSphereWidget.h:155
vtkSphereWidget::SetRepresentationToWireframe
void SetRepresentationToWireframe()
Definition: vtkSphereWidget.h:107
vtkSphereWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Definition: vtkSphereWidget.h:92
vtkSphereWidget::SetRepresentationToSurface
void SetRepresentationToSurface()
Definition: vtkSphereWidget.h:109
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkSphereWidget
3D widget for manipulating a sphere
Definition: vtkSphereWidget.h:73
vtkSphereWidget::SetRepresentationToOff
void SetRepresentationToOff()
Definition: vtkSphereWidget.h:105
vtkSphereWidget::GetPhiResolution
int GetPhiResolution()
Definition: vtkSphereWidget.h:128
vtkSphereWidget::SetCenter
void SetCenter(double x, double y, double z)
Set/Get the center of the sphere.
Definition: vtkSphereWidget.h:151
vtkSphereWidget::HandleActor
vtkActor * HandleActor
Definition: vtkSphereWidget.h:304
vtkSphereWidget::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkSphereWidget.h:273
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkX3D::radius
Definition: vtkX3D.h:252
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkSphereWidget::Positioning
Definition: vtkSphereWidget.h:254
vtkSphereWidget::HandleSource
vtkSphereSource * HandleSource
Definition: vtkSphereWidget.h:306
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69