VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 =========================================================================*/
58 #ifndef __vtkSphereWidget_h
59 #define __vtkSphereWidget_h
60 
61 #include "vtkInteractionWidgetsModule.h" // For export macro
62 #include "vtk3DWidget.h"
63 #include "vtkSphereSource.h" // Needed for faster access to the sphere source
64 
65 class vtkActor;
66 class vtkPolyDataMapper;
67 class vtkPoints;
68 class vtkPolyData;
69 class vtkSphereSource;
70 class vtkSphere;
71 class vtkCellPicker;
72 class vtkProperty;
73 
74 #define VTK_SPHERE_OFF 0
75 #define VTK_SPHERE_WIREFRAME 1
76 #define VTK_SPHERE_SURFACE 2
77 
78 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereWidget : public vtk3DWidget
79 {
80 public:
82  static vtkSphereWidget *New();
83 
85  void PrintSelf(ostream& os, vtkIndent indent);
86 
88 
89  virtual void SetEnabled(int);
90  virtual void PlaceWidget(double bounds[6]);
91  void PlaceWidget()
92  {this->Superclass::PlaceWidget();}
93  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
94  double zmin, double zmax)
95  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
97 
99 
102  vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
103  vtkGetMacro(Representation,int);
105  { this->SetRepresentation(VTK_SPHERE_OFF);}
107  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
109  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
111 
113 
115  void SetThetaResolution(int r)
116  { this->SphereSource->SetThetaResolution(r); }
118  { return this->SphereSource->GetThetaResolution(); }
120 
122 
124  void SetPhiResolution(int r)
125  { this->SphereSource->SetPhiResolution(r); }
127  { return this->SphereSource->GetPhiResolution(); }
129 
131 
132  void SetRadius(double r)
133  {
134  if ( r <= 0 )
135  {
136  r = .00001;
137  }
138  this->SphereSource->SetRadius(r);
139  }
140  double GetRadius()
141  { return this->SphereSource->GetRadius(); }
143 
145 
146  void SetCenter(double x, double y, double z)
147  {
148  this->SphereSource->SetCenter(x,y,z);
149  }
150  void SetCenter(double x[3])
151  {
152  this->SetCenter(x[0], x[1], x[2]);
153  }
154  double* GetCenter()
155  {return this->SphereSource->GetCenter();}
156  void GetCenter(double xyz[3])
157  {this->SphereSource->GetCenter(xyz);}
159 
161 
163  vtkSetMacro(Translation,int);
164  vtkGetMacro(Translation,int);
165  vtkBooleanMacro(Translation,int);
166  vtkSetMacro(Scale,int);
167  vtkGetMacro(Scale,int);
168  vtkBooleanMacro(Scale,int);
170 
172 
176  vtkSetMacro(HandleVisibility,int);
177  vtkGetMacro(HandleVisibility,int);
178  vtkBooleanMacro(HandleVisibility,int);
180 
182 
185  vtkSetVector3Macro(HandleDirection,double);
186  vtkGetVector3Macro(HandleDirection,double);
188 
190 
191  vtkGetVector3Macro(HandlePosition,double);
193 
200  void GetPolyData(vtkPolyData *pd);
201 
206  void GetSphere(vtkSphere *sphere);
207 
209 
211  vtkGetObjectMacro(SphereProperty,vtkProperty);
212  vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
214 
216 
219  vtkGetObjectMacro(HandleProperty,vtkProperty);
220  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
222 
223 protected:
224  vtkSphereWidget();
225  ~vtkSphereWidget();
226 
227 //BTX - manage the state of the widget
228  int State;
230  {
231  Start=0,
235  Outside
236  };
237 //ETX
238 
239  //handles the events
240  static void ProcessEvents(vtkObject* object,
241  unsigned long event,
242  void* clientdata,
243  void* calldata);
244 
245  // ProcessEvents() dispatches to these methods.
246  void OnLeftButtonDown();
247  void OnLeftButtonUp();
248  void OnRightButtonDown();
249  void OnRightButtonUp();
250  void OnMouseMove();
251 
252  // the sphere
253  vtkActor *SphereActor;
254  vtkPolyDataMapper *SphereMapper;
256  void HighlightSphere(int highlight);
257  void SelectRepresentation();
258 
259  // The representation of the sphere
261 
262  // Do the picking
263  vtkCellPicker *Picker;
264 
265  // Register internal Pickers within PickingManager
266  virtual void RegisterPickers();
267 
268  // Methods to manipulate the sphere widget
270  int Scale;
271  void Translate(double *p1, double *p2);
272  void ScaleSphere(double *p1, double *p2, int X, int Y);
273  void MoveHandle(double *p1, double *p2, int X, int Y);
274  void PlaceHandle(double *center, double radius);
275 
276  // Properties used to control the appearance of selected objects and
277  // the manipulator in general.
278  vtkProperty *SphereProperty;
280  vtkProperty *HandleProperty;
282  void CreateDefaultProperties();
283 
284  // Managing the handle
285  vtkActor *HandleActor;
286  vtkPolyDataMapper *HandleMapper;
288  void HighlightHandle(int);
290  double HandleDirection[3];
291  double HandlePosition[3];
292  virtual void SizeHandles();
293 
294 private:
295  vtkSphereWidget(const vtkSphereWidget&); //Not implemented
296  void operator=(const vtkSphereWidget&); //Not implemented
297 };
298 
299 #endif
void SetRadius(double r)
vtkSphereSource * HandleSource
void SetRepresentationToWireframe()
void SetPhiResolution(int r)
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
void SetThetaResolution(int r)
vtkSphereSource * SphereSource
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:82
#define VTK_SPHERE_OFF
vtkActor * SphereActor
#define VTK_SPHERE_SURFACE
vtkProperty * SphereProperty
vtkPolyDataMapper * HandleMapper
vtkCellPicker * Picker
void SetRepresentationToSurface()
create a polygonal sphere centered at the origin
vtkActor * HandleActor
vtkProperty * SelectedHandleProperty
double * GetCenter()
#define VTK_SPHERE_WIREFRAME
void SetCenter(double x, double y, double z)
vtkProperty * HandleProperty
vtkPolyDataMapper * SphereMapper
void GetCenter(double xyz[3])
void SetCenter(double x[3])
3D widget for manipulating a sphere
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