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
66class vtkActor;
68class vtkPoints;
69class vtkPolyData;
70class vtkSphereSource;
71class vtkSphere;
72class vtkCellPicker;
73class vtkProperty;
74
75#define VTK_SPHERE_OFF 0
76#define VTK_SPHERE_WIREFRAME 1
77#define VTK_SPHERE_SURFACE 2
78
79class VTKINTERACTIONWIDGETS_EXPORT vtkSphereWidget : public vtk3DWidget
80{
81public:
86
88 void PrintSelf(ostream& os, vtkIndent indent);
89
91
94 virtual void SetEnabled(int);
95 virtual void PlaceWidget(double bounds[6]);
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
124 { this->SphereSource->SetThetaResolution(r); }
126 { return this->SphereSource->GetThetaResolution(); }
127
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
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
249protected:
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.
276
277 // the sphere
281 void HighlightSphere(int highlight);
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.
308
309 // Managing the handle
315 double HandleDirection[3];
316 double HandlePosition[3];
317 virtual void SizeHandles();
318
319private:
320 vtkSphereWidget(const vtkSphereWidget&) VTK_DELETE_FUNCTION;
321 void operator=(const vtkSphereWidget&) VTK_DELETE_FUNCTION;
322};
323
324#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:70
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
represent and manipulate 3D points
Definition: vtkPoints.h:40
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
represent surface properties of a geometric object
Definition: vtkProperty.h:65
create a polygonal sphere centered at the origin
3D widget for manipulating a sphere
double * GetCenter()
vtkCellPicker * Picker
void GetCenter(double xyz[3])
void OnRightButtonUp()
vtkProperty * SelectedSphereProperty
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
void SelectRepresentation()
vtkPolyDataMapper * HandleMapper
void SetCenter(double x[3])
void HighlightHandle(int)
void SetCenter(double x, double y, double z)
Set/Get the center of the sphere.
void CreateDefaultProperties()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the sphere.
void SetRadius(double r)
Set/Get the radius of sphere.
vtkSphereSource * HandleSource
virtual void SizeHandles()
static vtkSphereWidget * New()
Instantiate the object.
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the Theta direction.
void OnLeftButtonUp()
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
vtkPolyDataMapper * SphereMapper
vtkProperty * SphereProperty
void OnLeftButtonDown()
void Translate(double *p1, double *p2)
vtkActor * HandleActor
void HighlightSphere(int highlight)
void MoveHandle(double *p1, double *p2, int X, int Y)
void SetRepresentationToSurface()
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the Phi direction.
vtkProperty * HandleProperty
virtual void PlaceWidget(double bounds[6])
This method is used to initially place the widget.
void GetSphere(vtkSphere *sphere)
Get the spherical implicit function defined by this widget.
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkActor * SphereActor
void SetRepresentationToWireframe()
vtkSphereSource * SphereSource
void SetRepresentationToOff()
void OnRightButtonDown()
virtual void SetEnabled(int)
Methods that satisfy the superclass' API.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void ScaleSphere(double *p1, double *p2, int X, int Y)
vtkProperty * SelectedHandleProperty
void PlaceHandle(double *center, double radius)
implicit function for a sphere
Definition: vtkSphere.h:38
@ center
Definition: vtkX3D.h:230
@ radius
Definition: vtkX3D.h:252
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
#define VTK_SPHERE_SURFACE
#define VTK_SPHERE_OFF
#define VTK_SPHERE_WIREFRAME