VTK
vtkSphereRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSphereRepresentation.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 =========================================================================*/
48 #ifndef vtkSphereRepresentation_h
49 #define vtkSphereRepresentation_h
50 
51 #include "vtkInteractionWidgetsModule.h" // For export macro
53 #include "vtkSphereSource.h" // Needed for fast access to the sphere source
54 
55 class vtkActor;
56 class vtkPolyDataMapper;
57 class vtkSphere;
58 class vtkSphereSource;
59 class vtkCellPicker;
60 class vtkProperty;
61 class vtkPolyData;
62 class vtkPoints;
64 class vtkTransform;
65 class vtkDoubleArray;
66 class vtkMatrix4x4;
67 class vtkTextMapper;
68 class vtkActor2D;
69 class vtkTextProperty;
70 class vtkLineSource;
71 
72 #define VTK_SPHERE_OFF 0
73 #define VTK_SPHERE_WIREFRAME 1
74 #define VTK_SPHERE_SURFACE 2
75 
77 {
78 public:
80  static vtkSphereRepresentation *New();
81 
83 
86  void PrintSelf(ostream& os, vtkIndent indent);
88 
89 //BTX - used to manage the state of the widget
90  enum {Outside=0,MovingHandle,OnSphere,Translating,Scaling};
91 //ETX
92 
94 
96  vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
97  vtkGetMacro(Representation,int);
99  { this->SetRepresentation(VTK_SPHERE_OFF);}
101  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
103  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
105 
107 
108  void SetThetaResolution(int r)
109  { this->SphereSource->SetThetaResolution(r); }
111  { return this->SphereSource->GetThetaResolution(); }
113 
115 
116  void SetPhiResolution(int r)
117  { this->SphereSource->SetPhiResolution(r); }
119  { return this->SphereSource->GetPhiResolution(); }
121 
123 
126  void SetCenter(double c[3]);
127  void SetCenter(double x, double y, double z)
128  {double c[3]; c[0]=x; c[1]=y; c[2]=z; this->SetCenter(c);}
129  double* GetCenter()
130  {return this->SphereSource->GetCenter();}
131  void GetCenter(double xyz[3])
132  {this->SphereSource->GetCenter(xyz);}
134 
136 
138  void SetRadius(double r);
139  double GetRadius()
140  { return this->SphereSource->GetRadius(); }
142 
144 
148  vtkSetMacro(HandleVisibility,int);
149  vtkGetMacro(HandleVisibility,int);
150  vtkBooleanMacro(HandleVisibility,int);
152 
154 
156  void SetHandlePosition(double handle[3]);
157  void SetHandlePosition(double x, double y, double z)
158  {double p[3]; p[0]=x; p[1]=y; p[2]=z; this->SetHandlePosition(p);}
159  vtkGetVector3Macro(HandlePosition,double);
161 
163 
166  void SetHandleDirection(double dir[3]);
167  void SetHandleDirection(double dx, double dy, double dz)
168  {double d[3]; d[0]=dx; d[1]=dy; d[2]=dz; this->SetHandleDirection(d);}
169  vtkGetVector3Macro(HandleDirection,double);
171 
173 
178  vtkSetMacro(HandleText,int);
179  vtkGetMacro(HandleText,int);
180  vtkBooleanMacro(HandleText,int);
182 
184 
186  vtkSetMacro(RadialLine,int);
187  vtkGetMacro(RadialLine,int);
188  vtkBooleanMacro(RadialLine,int);
190 
197  void GetPolyData(vtkPolyData *pd);
198 
203  void GetSphere(vtkSphere *sphere);
204 
206 
208  vtkGetObjectMacro(SphereProperty,vtkProperty);
209  vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
211 
213 
216  vtkGetObjectMacro(HandleProperty,vtkProperty);
217  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
219 
221 
223  vtkGetObjectMacro(HandleTextProperty,vtkTextProperty);
225 
227 
229  vtkGetObjectMacro(RadialLineProperty,vtkProperty);
231 
239  void SetInteractionState(int state);
240 
242 
245  virtual void PlaceWidget(double bounds[6]);
246  virtual void PlaceWidget(double center[3], double handlePosition[3]);
247  virtual void BuildRepresentation();
248  virtual int ComputeInteractionState(int X, int Y, int modify=0);
249  virtual void StartWidgetInteraction(double e[2]);
250  virtual void WidgetInteraction(double e[2]);
251  virtual double *GetBounds();
253 
255 
256  virtual void ReleaseGraphicsResources(vtkWindow*);
257  virtual int RenderOpaqueGeometry(vtkViewport*);
259  virtual int RenderOverlay(vtkViewport*);
260  virtual int HasTranslucentPolygonalGeometry();
262 
263 protected:
266 
267  // Manage how the representation appears
268  double LastEventPosition[3];
269 
270  // the sphere
274  void HighlightSphere(int highlight);
275 
276  // The representation of the sphere
278 
279  // Do the picking
282  double LastPickPosition[3];
283 
284  // Register internal Pickers within PickingManager
285  virtual void RegisterPickers();
286 
287  // Methods to manipulate the sphere widget
288  void Translate(double *p1, double *p2);
289  void Scale(double *p1, double *p2, int X, int Y);
290  void PlaceHandle(double *center, double radius);
291  virtual void SizeHandles();
292 
293  // Properties used to control the appearance of selected objects and
294  // the manipulator in general.
299  void CreateDefaultProperties();
300 
301  // Managing the handle
305  void HighlightHandle(int);
307  double HandleDirection[3];
308  double HandlePosition[3];
309 
310  // Manage the handle label
315 
316  // Manage the radial line segment
322 
323 private:
324  vtkSphereRepresentation(const vtkSphereRepresentation&); //Not implemented
325  void operator=(const vtkSphereRepresentation&); //Not implemented
326 };
327 
328 #endif
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
#define VTK_SPHERE_SURFACE
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
vtkPolyDataMapper * SphereMapper
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:63
void SetHandleDirection(double dx, double dy, double dz)
virtual void StartWidgetInteraction(double eventPos[2])
void SetCenter(double x, double y, double z)
a actor that draws 2D data
Definition: vtkActor2D.h:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
2D text annotation
Definition: vtkTextMapper.h:52
dynamic, self-adjusting array of double
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
#define VTKINTERACTIONWIDGETS_EXPORT
create a polygonal sphere centered at the origin
implicit function for a sphere
Definition: vtkSphere.h:36
Superclass for algorithms that produce only polydata as output.
virtual int HasTranslucentPolygonalGeometry()
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void RegisterPickers()
#define VTK_SPHERE_WIREFRAME
void SetHandlePosition(double x, double y, double z)
virtual void WidgetInteraction(double newEventPos[2])
#define VTK_SPHERE_OFF
represent text properties.
vtkTextProperty * HandleTextProperty
vtkPolyDataMapper * RadialLineMapper
create a line defined by two end points
Definition: vtkLineSource.h:41
map vtkPolyData to graphics primitives
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
a class defining the representation for the vtkSphereWidget2
vtkPolyDataMapper * HandleMapper
represent and manipulate 3D points
Definition: vtkPoints.h:38