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 
52 #include "vtkSphereSource.h" // Needed for fast access to the sphere source
53 
54 class vtkActor;
55 class vtkPolyDataMapper;
56 class vtkSphere;
57 class vtkSphereSource;
58 class vtkCellPicker;
59 class vtkProperty;
60 class vtkPolyData;
61 class vtkPoints;
63 class vtkTransform;
64 class vtkDoubleArray;
65 class vtkMatrix4x4;
66 class vtkTextMapper;
67 class vtkActor2D;
68 class vtkTextProperty;
69 class vtkLineSource;
70 
71 #define VTK_SPHERE_OFF 0
72 #define VTK_SPHERE_WIREFRAME 1
73 #define VTK_SPHERE_SURFACE 2
74 
76 {
77 public:
79  static vtkSphereRepresentation *New();
80 
82 
85  void PrintSelf(ostream& os, vtkIndent indent);
87 
88 //BTX - used to manage the state of the widget
89  enum {Outside=0,MovingHandle,OnSphere,Translating,Scaling};
90 //ETX
91 
93 
95  vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
96  vtkGetMacro(Representation,int);
98  { this->SetRepresentation(VTK_SPHERE_OFF);}
100  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
102  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
104 
106 
107  void SetThetaResolution(int r)
108  { this->SphereSource->SetThetaResolution(r); }
110  { return this->SphereSource->GetThetaResolution(); }
112 
114 
115  void SetPhiResolution(int r)
116  { this->SphereSource->SetPhiResolution(r); }
118  { return this->SphereSource->GetPhiResolution(); }
120 
122 
125  void SetCenter(double c[3]);
126  void SetCenter(double x, double y, double z)
127  {double c[3]; c[0]=x; c[1]=y; c[2]=z; this->SetCenter(c);}
128  double* GetCenter()
129  {return this->SphereSource->GetCenter();}
130  void GetCenter(double xyz[3])
131  {this->SphereSource->GetCenter(xyz);}
133 
135 
137  void SetRadius(double r);
138  double GetRadius()
139  { return this->SphereSource->GetRadius(); }
141 
143 
147  vtkSetMacro(HandleVisibility,int);
148  vtkGetMacro(HandleVisibility,int);
149  vtkBooleanMacro(HandleVisibility,int);
151 
153 
155  void SetHandlePosition(double handle[3]);
156  void SetHandlePosition(double x, double y, double z)
157  {double p[3]; p[0]=x; p[1]=y; p[2]=z; this->SetHandlePosition(p);}
158  vtkGetVector3Macro(HandlePosition,double);
160 
162 
165  void SetHandleDirection(double dir[3]);
166  void SetHandleDirection(double dx, double dy, double dz)
167  {double d[3]; d[0]=dx; d[1]=dy; d[2]=dz; this->SetHandleDirection(d);}
168  vtkGetVector3Macro(HandleDirection,double);
170 
172 
177  vtkSetMacro(HandleText,int);
178  vtkGetMacro(HandleText,int);
179  vtkBooleanMacro(HandleText,int);
181 
183 
185  vtkSetMacro(RadialLine,int);
186  vtkGetMacro(RadialLine,int);
187  vtkBooleanMacro(RadialLine,int);
189 
196  void GetPolyData(vtkPolyData *pd);
197 
202  void GetSphere(vtkSphere *sphere);
203 
205 
207  vtkGetObjectMacro(SphereProperty,vtkProperty);
208  vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
210 
212 
215  vtkGetObjectMacro(HandleProperty,vtkProperty);
216  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
218 
220 
222  vtkGetObjectMacro(HandleTextProperty,vtkTextProperty);
224 
226 
228  vtkGetObjectMacro(RadialLineProperty,vtkProperty);
230 
238  void SetInteractionState(int state);
239 
241 
244  virtual void PlaceWidget(double bounds[6]);
245  virtual void PlaceWidget(double center[3], double handlePosition[3]);
246  virtual void BuildRepresentation();
247  virtual int ComputeInteractionState(int X, int Y, int modify=0);
248  virtual void StartWidgetInteraction(double e[2]);
249  virtual void WidgetInteraction(double e[2]);
250  virtual double *GetBounds();
252 
254 
255  virtual void ReleaseGraphicsResources(vtkWindow*);
256  virtual int RenderOpaqueGeometry(vtkViewport*);
258  virtual int RenderOverlay(vtkViewport*);
259  virtual int HasTranslucentPolygonalGeometry();
261 
262 protected:
265 
266  // Manage how the representation appears
267  double LastEventPosition[3];
268 
269  // the sphere
273  void HighlightSphere(int highlight);
274 
275  // The representation of the sphere
277 
278  // Do the picking
281  double LastPickPosition[3];
282 
283  // Methods to manipulate the sphere widget
284  void Translate(double *p1, double *p2);
285  void Scale(double *p1, double *p2, int X, int Y);
286  void PlaceHandle(double *center, double radius);
287  virtual void SizeHandles();
288 
289  // Properties used to control the appearance of selected objects and
290  // the manipulator in general.
295  void CreateDefaultProperties();
296 
297  // Managing the handle
301  void HighlightHandle(int);
303  double HandleDirection[3];
304  double HandlePosition[3];
305 
306  // Manage the handle label
311 
312  // Manage the radial line segment
318 
319 private:
320  vtkSphereRepresentation(const vtkSphereRepresentation&); //Not implemented
321  void operator=(const vtkSphereRepresentation&); //Not implemented
322 };
323 
324 #endif