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) VTK_OVERRIDE;
83 
85 
88  void SetEnabled(int) VTK_OVERRIDE;
89  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
90  void PlaceWidget() VTK_OVERRIDE
91  {this->Superclass::PlaceWidget();}
92  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
93  double zmin, double zmax) VTK_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()
160  {return this->SphereSource->GetCenter();}
161  void GetCenter(double xyz[3])
162  {this->SphereSource->GetCenter(xyz);}
164 
166 
170  vtkSetMacro(Translation,int);
171  vtkGetMacro(Translation,int);
172  vtkBooleanMacro(Translation,int);
173  vtkSetMacro(Scale,int);
174  vtkGetMacro(Scale,int);
175  vtkBooleanMacro(Scale,int);
177 
179 
185  vtkSetMacro(HandleVisibility,int);
186  vtkGetMacro(HandleVisibility,int);
187  vtkBooleanMacro(HandleVisibility,int);
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() VTK_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() VTK_OVERRIDE;
286 
287  // Methods to manipulate the sphere widget
288  int Translation;
289  int Scale;
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.
297  vtkProperty *SphereProperty;
298  vtkProperty *SelectedSphereProperty;
299  vtkProperty *HandleProperty;
300  vtkProperty *SelectedHandleProperty;
301  void CreateDefaultProperties();
302 
303  // Managing the handle
304  vtkActor *HandleActor;
305  vtkPolyDataMapper *HandleMapper;
306  vtkSphereSource *HandleSource;
307  void HighlightHandle(int);
308  int HandleVisibility;
309  double HandleDirection[3];
310  double HandlePosition[3];
311  void SizeHandles() VTK_OVERRIDE;
312 
313 private:
314  vtkSphereWidget(const vtkSphereWidget&) VTK_DELETE_FUNCTION;
315  void operator=(const vtkSphereWidget&) VTK_DELETE_FUNCTION;
316 };
317 
318 #endif
void SetRadius(double r)
Set/Get the radius of sphere.
void SetRepresentationToWireframe()
Set the representation of the sphere.
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the Phi direction.
represents an object (geometry &amp; properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:53
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the Theta direction.
vtkSphereSource * SphereSource
represent surface properties of a geometric object
Definition: vtkProperty.h:58
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass&#39; API.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_SPHERE_OFF
vtkActor * SphereActor
#define VTK_SPHERE_SURFACE
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkCellPicker * Picker
void SetRepresentationToSurface()
Set the representation of the sphere.
create a polygonal sphere centered at the origin
implicit function for a sphere
Definition: vtkSphere.h:31
a simple class to control print indentation
Definition: vtkIndent.h:33
double * GetCenter()
Set/Get the center of the sphere.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
#define VTK_SPHERE_WIREFRAME
void SetCenter(double x, double y, double z)
Set/Get the center of the sphere.
map vtkPolyData to graphics primitives
double GetRadius()
Set/Get the radius of sphere.
vtkPolyDataMapper * SphereMapper
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
void GetCenter(double xyz[3])
Set/Get the center of the sphere.
void SetCenter(double x[3])
Set/Get the center of the sphere.
3D widget for manipulating a sphere
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void SetRepresentationToOff()
Set the representation of the sphere.
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
represent and manipulate 3D points
Definition: vtkPoints.h:33