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  // Used to manage the state of the widget
90  enum {Outside=0,MovingHandle,OnSphere,Translating,Scaling};
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  // Register internal Pickers within PickingManager
284  virtual void RegisterPickers();
285 
286  // Methods to manipulate the sphere widget
287  void Translate(double *p1, double *p2);
288  void Scale(double *p1, double *p2, int X, int Y);
289  void PlaceHandle(double *center, double radius);
290  virtual void SizeHandles();
291 
292  // Properties used to control the appearance of selected objects and
293  // the manipulator in general.
298  void CreateDefaultProperties();
299 
300  // Managing the handle
304  void HighlightHandle(int);
306  double HandleDirection[3];
307  double HandlePosition[3];
308 
309  // Manage the handle label
314 
315  // Manage the radial line segment
321 
322 private:
323  vtkSphereRepresentation(const vtkSphereRepresentation&); //Not implemented
324  void operator=(const vtkSphereRepresentation&); //Not implemented
325 };
326 
327 #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:84
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