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 =========================================================================*/
61 #ifndef vtkSphereWidget_h
62 #define vtkSphereWidget_h
63 
64 #include "vtkInteractionWidgetsModule.h" // For export macro
65 #include "vtk3DWidget.h"
66 #include "vtkSphereSource.h" // Needed for faster access to the sphere source
67 
68 class vtkActor;
69 class vtkPolyDataMapper;
70 class vtkPoints;
71 class vtkPolyData;
72 class vtkSphereSource;
73 class vtkSphere;
74 class vtkCellPicker;
75 class vtkProperty;
76 
77 #define VTK_SPHERE_OFF 0
78 #define VTK_SPHERE_WIREFRAME 1
79 #define VTK_SPHERE_SURFACE 2
80 
82 {
83 public:
85  static vtkSphereWidget *New();
86 
88  void PrintSelf(ostream& os, vtkIndent indent);
89 
91 
92  virtual void SetEnabled(int);
93  virtual void PlaceWidget(double bounds[6]);
94  void PlaceWidget()
95  {this->Superclass::PlaceWidget();}
96  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
97  double zmin, double zmax)
98  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
100 
102 
105  vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
106  vtkGetMacro(Representation,int);
108  { this->SetRepresentation(VTK_SPHERE_OFF);}
110  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
112  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
114 
116 
118  void SetThetaResolution(int r)
119  { this->SphereSource->SetThetaResolution(r); }
121  { return this->SphereSource->GetThetaResolution(); }
123 
125 
127  void SetPhiResolution(int r)
128  { this->SphereSource->SetPhiResolution(r); }
130  { return this->SphereSource->GetPhiResolution(); }
132 
134 
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 
149  void SetCenter(double x, double y, double z)
150  {
151  this->SphereSource->SetCenter(x,y,z);
152  }
153  void SetCenter(double x[3])
154  {
155  this->SetCenter(x[0], x[1], x[2]);
156  }
157  double* GetCenter()
158  {return this->SphereSource->GetCenter();}
159  void GetCenter(double xyz[3])
160  {this->SphereSource->GetCenter(xyz);}
162 
164 
166  vtkSetMacro(Translation,int);
167  vtkGetMacro(Translation,int);
168  vtkBooleanMacro(Translation,int);
169  vtkSetMacro(Scale,int);
170  vtkGetMacro(Scale,int);
171  vtkBooleanMacro(Scale,int);
173 
175 
179  vtkSetMacro(HandleVisibility,int);
180  vtkGetMacro(HandleVisibility,int);
181  vtkBooleanMacro(HandleVisibility,int);
183 
185 
188  vtkSetVector3Macro(HandleDirection,double);
189  vtkGetVector3Macro(HandleDirection,double);
191 
193 
194  vtkGetVector3Macro(HandlePosition,double);
196 
203  void GetPolyData(vtkPolyData *pd);
204 
209  void GetSphere(vtkSphere *sphere);
210 
212 
214  vtkGetObjectMacro(SphereProperty,vtkProperty);
215  vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
217 
219 
222  vtkGetObjectMacro(HandleProperty,vtkProperty);
223  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
225 
226 protected:
227  vtkSphereWidget();
228  ~vtkSphereWidget();
229 
230  // Manage the state of the widget
231  int State;
233  {
234  Start=0,
238  Outside
239  };
240 
241  //handles the events
242  static void ProcessEvents(vtkObject* object,
243  unsigned long event,
244  void* clientdata,
245  void* calldata);
246 
247  // ProcessEvents() dispatches to these methods.
248  void OnLeftButtonDown();
249  void OnLeftButtonUp();
250  void OnRightButtonDown();
251  void OnRightButtonUp();
252  void OnMouseMove();
253 
254  // the sphere
258  void HighlightSphere(int highlight);
259  void SelectRepresentation();
260 
261  // The representation of the sphere
263 
264  // Do the picking
266 
267  // Register internal Pickers within PickingManager
268  virtual void RegisterPickers();
269 
270  // Methods to manipulate the sphere widget
272  int Scale;
273  void Translate(double *p1, double *p2);
274  void ScaleSphere(double *p1, double *p2, int X, int Y);
275  void MoveHandle(double *p1, double *p2, int X, int Y);
276  void PlaceHandle(double *center, double radius);
277 
278  // Properties used to control the appearance of selected objects and
279  // the manipulator in general.
284  void CreateDefaultProperties();
285 
286  // Managing the handle
290  void HighlightHandle(int);
292  double HandleDirection[3];
293  double HandlePosition[3];
294  virtual void SizeHandles();
295 
296 private:
297  vtkSphereWidget(const vtkSphereWidget&); //Not implemented
298  void operator=(const vtkSphereWidget&); //Not implemented
299 };
300 
301 #endif
void SetRadius(double r)
vtkSphereSource * HandleSource
void SetRepresentationToWireframe()
void SetPhiResolution(int r)
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
void SetThetaResolution(int r)
vtkSphereSource * SphereSource
represent surface properties of a geometric object
Definition: vtkProperty.h:63
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void SetEnabled(int)
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
#define VTK_SPHERE_OFF
vtkActor * SphereActor
#define VTK_SPHERE_SURFACE
virtual void RegisterPickers()
vtkProperty * SphereProperty
vtkPolyDataMapper * HandleMapper
vtkCellPicker * Picker
#define VTKINTERACTIONWIDGETS_EXPORT
void SetRepresentationToSurface()
create a polygonal sphere centered at the origin
implicit function for a sphere
Definition: vtkSphere.h:36
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkActor * HandleActor
vtkProperty * SelectedHandleProperty
double * GetCenter()
#define VTK_SPHERE_WIREFRAME
void SetCenter(double x, double y, double z)
map vtkPolyData to graphics primitives
vtkProperty * HandleProperty
vtkPolyDataMapper * SphereMapper
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
void GetCenter(double xyz[3])
void SetCenter(double x[3])
3D widget for manipulating a sphere
static vtkObject * New()
void SetRepresentationToOff()
void PrintSelf(ostream &os, vtkIndent indent)
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:69
virtual void SizeHandles()
Definition: vtk3DWidget.h:145
virtual void PlaceWidget()
vtkProperty * SelectedSphereProperty
represent and manipulate 3D points
Definition: vtkPoints.h:38