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 
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 
103  vtkGetMacro(Representation,int);
105  { this->SetRepresentation(VTK_SPHERE_OFF);}
107  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
109  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
111 
113 
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
256  void HighlightSphere(int highlight);
257  void SelectRepresentation();
258 
259  // The representation of the sphere
261 
262  // Do the picking
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.
282  void CreateDefaultProperties();
283 
284  // Managing the handle
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()
GLclampd zmax
Definition: vtkgl.h:17479
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)
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
virtual void SetEnabled(int)
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
GLdouble GLdouble GLdouble r
Definition: vtkgl.h:11610
#define VTK_SPHERE_OFF
vtkActor * SphereActor
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
#define VTK_SPHERE_SURFACE
virtual void RegisterPickers()
vtkProperty * SphereProperty
vtkPolyDataMapper * HandleMapper
GLdouble GLdouble z
Definition: vtkgl.h:11754
vtkCellPicker * Picker
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
#define VTKINTERACTIONWIDGETS_EXPORT
void SetRepresentationToSurface()
create a polygonal sphere centered at the origin
implicit function for a sphere
Definition: vtkSphere.h:36
struct _cl_event * event
Definition: vtkgl.h:14387
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkActor * HandleActor
vtkProperty * SelectedHandleProperty
#define vtkGetVector3Macro(name, type)
Definition: vtkSetGet.h:294
double * GetCenter()
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
#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])
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
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
#define vtkSetVector3Macro(name, type)
Definition: vtkSetGet.h:277
virtual void PlaceWidget()
vtkProperty * SelectedSphereProperty
represent and manipulate 3D points
Definition: vtkPoints.h:39
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69