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 =========================================================================*/
59 #ifndef vtkSphereWidget_h
60 #define vtkSphereWidget_h
61 
62 #include "vtkInteractionWidgetsModule.h" // For export macro
63 #include "vtk3DWidget.h"
64 #include "vtkSphereSource.h" // Needed for faster access to the sphere source
65 
66 class vtkActor;
67 class vtkPolyDataMapper;
68 class vtkPoints;
69 class vtkPolyData;
70 class vtkSphereSource;
71 class vtkSphere;
72 class vtkCellPicker;
73 class vtkProperty;
74 
75 #define VTK_SPHERE_OFF 0
76 #define VTK_SPHERE_WIREFRAME 1
77 #define VTK_SPHERE_SURFACE 2
78 
79 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereWidget : public vtk3DWidget
80 {
81 public:
85  static vtkSphereWidget *New();
86 
88  void PrintSelf(ostream& os, vtkIndent indent);
89 
91 
94  virtual void SetEnabled(int);
95  virtual void PlaceWidget(double bounds[6]);
96  void PlaceWidget()
97  {this->Superclass::PlaceWidget();}
98  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
99  double zmin, double zmax)
100  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
102 
104 
109  vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
110  vtkGetMacro(Representation,int);
112  { this->SetRepresentation(VTK_SPHERE_OFF);}
114  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
116  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
118 
123  void SetThetaResolution(int r)
124  { this->SphereSource->SetThetaResolution(r); }
126  { return this->SphereSource->GetThetaResolution(); }
127 
132  void SetPhiResolution(int r)
133  { this->SphereSource->SetPhiResolution(r); }
135  { return this->SphereSource->GetPhiResolution(); }
136 
138 
141  void SetRadius(double r)
142  {
143  if ( r <= 0 )
144  {
145  r = .00001;
146  }
147  this->SphereSource->SetRadius(r);
148  }
149  double GetRadius()
150  { return this->SphereSource->GetRadius(); }
152 
154 
157  void SetCenter(double x, double y, double z)
158  {
159  this->SphereSource->SetCenter(x,y,z);
160  }
161  void SetCenter(double x[3])
162  {
163  this->SetCenter(x[0], x[1], x[2]);
164  }
165  double* GetCenter()
166  {return this->SphereSource->GetCenter();}
167  void GetCenter(double xyz[3])
168  {this->SphereSource->GetCenter(xyz);}
170 
172 
176  vtkSetMacro(Translation,int);
177  vtkGetMacro(Translation,int);
178  vtkBooleanMacro(Translation,int);
179  vtkSetMacro(Scale,int);
180  vtkGetMacro(Scale,int);
181  vtkBooleanMacro(Scale,int);
183 
185 
191  vtkSetMacro(HandleVisibility,int);
192  vtkGetMacro(HandleVisibility,int);
193  vtkBooleanMacro(HandleVisibility,int);
195 
197 
202  vtkSetVector3Macro(HandleDirection,double);
203  vtkGetVector3Macro(HandleDirection,double);
205 
207 
210  vtkGetVector3Macro(HandlePosition,double);
212 
220  void GetPolyData(vtkPolyData *pd);
221 
228  void GetSphere(vtkSphere *sphere);
229 
231 
235  vtkGetObjectMacro(SphereProperty,vtkProperty);
236  vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
238 
240 
245  vtkGetObjectMacro(HandleProperty,vtkProperty);
246  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
248 
249 protected:
250  vtkSphereWidget();
251  ~vtkSphereWidget();
252 
253  // Manage the state of the widget
254  int State;
256  {
257  Start=0,
261  Outside
262  };
263 
264  //handles the events
265  static void ProcessEvents(vtkObject* object,
266  unsigned long event,
267  void* clientdata,
268  void* calldata);
269 
270  // ProcessEvents() dispatches to these methods.
271  void OnLeftButtonDown();
272  void OnLeftButtonUp();
273  void OnRightButtonDown();
274  void OnRightButtonUp();
275  void OnMouseMove();
276 
277  // the sphere
281  void HighlightSphere(int highlight);
282  void SelectRepresentation();
283 
284  // The representation of the sphere
286 
287  // Do the picking
289 
290  // Register internal Pickers within PickingManager
291  virtual void RegisterPickers();
292 
293  // Methods to manipulate the sphere widget
295  int Scale;
296  void Translate(double *p1, double *p2);
297  void ScaleSphere(double *p1, double *p2, int X, int Y);
298  void MoveHandle(double *p1, double *p2, int X, int Y);
299  void PlaceHandle(double *center, double radius);
300 
301  // Properties used to control the appearance of selected objects and
302  // the manipulator in general.
307  void CreateDefaultProperties();
308 
309  // Managing the handle
313  void HighlightHandle(int);
315  double HandleDirection[3];
316  double HandlePosition[3];
317  virtual void SizeHandles();
318 
319 private:
320  vtkSphereWidget(const vtkSphereWidget&) VTK_DELETE_FUNCTION;
321  void operator=(const vtkSphereWidget&) VTK_DELETE_FUNCTION;
322 };
323 
324 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:42
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkSphereWidget::SphereSource
vtkSphereSource * SphereSource
Definition: vtkSphereWidget.h:280
vtkSphereWidget::Picker
vtkCellPicker * Picker
Definition: vtkSphereWidget.h:288
vtkSphereWidget::SetRadius
void SetRadius(double r)
Set/Get the radius of sphere.
Definition: vtkSphereWidget.h:141
vtkSphereWidget::PlaceWidget
void PlaceWidget()
Definition: vtkSphereWidget.h:96
vtkSphereWidget::GetCenter
double * GetCenter()
Definition: vtkSphereWidget.h:165
vtkSphereWidget::SetThetaResolution
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the Theta direction.
Definition: vtkSphereWidget.h:123
vtkSphereWidget::Translation
int Translation
Definition: vtkSphereWidget.h:294
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:255
vtkSphereWidget::HandleVisibility
int HandleVisibility
Definition: vtkSphereWidget.h:314
vtkSphereWidget::Moving
@ Moving
Definition: vtkSphereWidget.h:258
VTK_SPHERE_OFF
#define VTK_SPHERE_OFF
Definition: vtkSphereWidget.h:75
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkSphereWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkSphereWidget.h:306
VTK_SPHERE_WIREFRAME
#define VTK_SPHERE_WIREFRAME
Definition: vtkSphereWidget.h:76
vtkSphereWidget::HandleMapper
vtkPolyDataMapper * HandleMapper
Definition: vtkSphereWidget.h:311
vtkX3D::center
@ center
Definition: vtkX3D.h:230
vtkSphereWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkSphereWidget.h:305
vtkSphere
implicit function for a sphere
Definition: vtkSphere.h:37
vtkSphereWidget::Representation
int Representation
Definition: vtkSphereWidget.h:285
vtkSphereWidget::GetThetaResolution
int GetThetaResolution()
Definition: vtkSphereWidget.h:125
vtkSphereWidget::SphereProperty
vtkProperty * SphereProperty
Definition: vtkSphereWidget.h:303
vtkSphereWidget::SelectedSphereProperty
vtkProperty * SelectedSphereProperty
Definition: vtkSphereWidget.h:304
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:46
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:167
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
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:39
vtkSphereWidget::Scaling
@ Scaling
Definition: vtkSphereWidget.h:259
VTK_SPHERE_SURFACE
#define VTK_SPHERE_SURFACE
Definition: vtkSphereWidget.h:77
vtkSphereWidget::SetPhiResolution
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the Phi direction.
Definition: vtkSphereWidget.h:132
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
vtkSphereWidget::SphereActor
vtkActor * SphereActor
Definition: vtkSphereWidget.h:278
vtkSphereSource.h
vtkSphereWidget::GetRadius
double GetRadius()
Definition: vtkSphereWidget.h:149
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtk3DWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtk3DWidget::SizeHandles
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkSphereWidget::State
int State
Definition: vtkSphereWidget.h:254
vtkSphereWidget::SetCenter
void SetCenter(double x[3])
Definition: vtkSphereWidget.h:161
vtkSphereWidget::SetRepresentationToWireframe
void SetRepresentationToWireframe()
Definition: vtkSphereWidget.h:113
vtkSphereWidget::SetRepresentationToSurface
void SetRepresentationToSurface()
Definition: vtkSphereWidget.h:115
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkSphereWidget
3D widget for manipulating a sphere
Definition: vtkSphereWidget.h:79
vtkSphereWidget::SetRepresentationToOff
void SetRepresentationToOff()
Definition: vtkSphereWidget.h:111
vtkSphereWidget::GetPhiResolution
int GetPhiResolution()
Definition: vtkSphereWidget.h:134
vtkSphereWidget::SetCenter
void SetCenter(double x, double y, double z)
Set/Get the center of the sphere.
Definition: vtkSphereWidget.h:157
vtkSphereWidget::Scale
int Scale
Definition: vtkSphereWidget.h:295
vtkSphereWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Definition: vtkSphereWidget.h:98
vtkSphereWidget::HandleActor
vtkActor * HandleActor
Definition: vtkSphereWidget.h:310
vtkSphereWidget::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkSphereWidget.h:279
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:64
vtkX3D::radius
@ radius
Definition: vtkX3D.h:252
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkSphereWidget::Positioning
@ Positioning
Definition: vtkSphereWidget.h:260
vtkSphereWidget::HandleSource
vtkSphereSource * HandleSource
Definition: vtkSphereWidget.h:312