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 =========================================================================*/
49 #ifndef vtkSphereRepresentation_h
50 #define vtkSphereRepresentation_h
51 
52 #include "vtkInteractionWidgetsModule.h" // For export macro
54 #include "vtkSphereSource.h" // Needed for fast access to the sphere source
55 
56 class vtkActor;
57 class vtkPolyDataMapper;
58 class vtkSphere;
59 class vtkSphereSource;
60 class vtkCellPicker;
61 class vtkProperty;
62 class vtkPolyData;
63 class vtkPoints;
65 class vtkTransform;
66 class vtkDoubleArray;
67 class vtkMatrix4x4;
68 class vtkTextMapper;
69 class vtkActor2D;
70 class vtkTextProperty;
71 class vtkLineSource;
72 class vtkCursor3D;
73 
74 #define VTK_SPHERE_OFF 0
75 #define VTK_SPHERE_WIREFRAME 1
76 #define VTK_SPHERE_SURFACE 2
77 
78 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereRepresentation : public vtkWidgetRepresentation
79 {
80 public:
85 
87 
91  void PrintSelf(ostream& os, vtkIndent indent);
93 
94  // Used to manage the state of the widget
95  enum {Outside=0,MovingHandle,OnSphere,Translating,Scaling};
96 
98 
102  vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
103  vtkGetMacro(Representation,int);
105  { this->SetRepresentation(VTK_SPHERE_OFF);}
107  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
109  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
111 
115  void SetThetaResolution(int r)
116  { this->SphereSource->SetThetaResolution(r); }
118  { return this->SphereSource->GetThetaResolution(); }
119 
123  void SetPhiResolution(int r)
124  { this->SphereSource->SetPhiResolution(r); }
126  { return this->SphereSource->GetPhiResolution(); }
127 
133  void SetCenter(double c[3]);
134  void SetCenter(double x, double y, double z)
135  {double c[3]; c[0]=x; c[1]=y; c[2]=z; this->SetCenter(c);}
136  double* GetCenter()
137  {return this->SphereSource->GetCenter();}
138  void GetCenter(double xyz[3])
139  {this->SphereSource->GetCenter(xyz);}
140 
145  void SetRadius(double r);
146  double GetRadius()
147  { return this->SphereSource->GetRadius(); }
148 
150 
156  vtkSetMacro(HandleVisibility,int);
157  vtkGetMacro(HandleVisibility,int);
158  vtkBooleanMacro(HandleVisibility,int);
160 
162 
166  void SetHandlePosition(double handle[3]);
167  void SetHandlePosition(double x, double y, double z)
168  {double p[3]; p[0]=x; p[1]=y; p[2]=z; this->SetHandlePosition(p);}
169  vtkGetVector3Macro(HandlePosition,double);
171 
173 
178  void SetHandleDirection(double dir[3]);
179  void SetHandleDirection(double dx, double dy, double dz)
180  {double d[3]; d[0]=dx; d[1]=dy; d[2]=dz; this->SetHandleDirection(d);}
181  vtkGetVector3Macro(HandleDirection,double);
183 
185 
192  vtkSetMacro(HandleText,int);
193  vtkGetMacro(HandleText,int);
194  vtkBooleanMacro(HandleText,int);
196 
198 
202  vtkSetMacro(RadialLine,int);
203  vtkGetMacro(RadialLine,int);
204  vtkBooleanMacro(RadialLine,int);
206 
208 
212  vtkSetMacro(CenterCursor, bool);
213  vtkGetMacro(CenterCursor, bool);
214  vtkBooleanMacro(CenterCursor, bool);
216 
225 
232  void GetSphere(vtkSphere *sphere);
233 
235 
239  vtkGetObjectMacro(SphereProperty,vtkProperty);
240  vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
242 
244 
249  vtkGetObjectMacro(HandleProperty,vtkProperty);
250  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
252 
254 
258  vtkGetObjectMacro(HandleTextProperty,vtkTextProperty);
260 
262 
266  vtkGetObjectMacro(RadialLineProperty,vtkProperty);
268 
278  void SetInteractionState(int state);
279 
281 
286  virtual void PlaceWidget(double bounds[6]);
287  virtual void PlaceWidget(double center[3], double handlePosition[3]);
288  virtual void BuildRepresentation();
289  virtual int ComputeInteractionState(int X, int Y, int modify=0);
290  virtual void StartWidgetInteraction(double e[2]);
291  virtual void WidgetInteraction(double e[2]);
292  virtual double *GetBounds();
294 
296 
302  virtual int RenderOverlay(vtkViewport*);
305 
306 protected:
309 
310  // Manage how the representation appears
311  double LastEventPosition[3];
312 
313  // the sphere
317  void HighlightSphere(int highlight);
318 
319  // The representation of the sphere
321 
322  // Do the picking
325  double LastPickPosition[3];
326 
327  // Register internal Pickers within PickingManager
328  virtual void RegisterPickers();
329 
330  // Methods to manipulate the sphere widget
331  void Translate(double *p1, double *p2);
332  void Scale(double *p1, double *p2, int X, int Y);
333  void PlaceHandle(double *center, double radius);
334  virtual void SizeHandles();
335 
336  // Method to adapt the center cursor bounds
337  // so it always have the same pixel size on screen
338  virtual void AdaptCenterCursorBounds();
339 
340  // Properties used to control the appearance of selected objects and
341  // the manipulator in general.
347 
348  // Managing the handle
352  void HighlightHandle(int);
354  double HandleDirection[3];
355  double HandlePosition[3];
356 
357  // Manage the handle label
362 
363  // Manage the radial line segment
369 
370  // Managing the center cursor
375 
376 private:
377  vtkSphereRepresentation(const vtkSphereRepresentation&) VTK_DELETE_FUNCTION;
378  void operator=(const vtkSphereRepresentation&) VTK_DELETE_FUNCTION;
379 };
380 
381 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:43
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:40
vtkSphereRepresentation::SetHandleDirection
void SetHandleDirection(double dx, double dy, double dz)
Definition: vtkSphereRepresentation.h:179
vtkWidgetRepresentation.h
vtkSphereRepresentation::SetCenter
void SetCenter(double x, double y, double z)
Definition: vtkSphereRepresentation.h:134
vtkSphereRepresentation::SetRadius
void SetRadius(double r)
Set/Get the radius of sphere.
vtkSphereRepresentation::CenterMapper
vtkPolyDataMapper * CenterMapper
Definition: vtkSphereRepresentation.h:372
vtkSphereRepresentation::SetRepresentationToOff
void SetRepresentationToOff()
Definition: vtkSphereRepresentation.h:104
vtkSphereRepresentation::GetSphere
void GetSphere(vtkSphere *sphere)
Get the spherical implicit function defined by this widget.
vtkSphereRepresentation::HandleVisibility
int HandleVisibility
Definition: vtkSphereRepresentation.h:353
vtkSphereRepresentation::SetCenter
void SetCenter(double c[3])
Set/Get the center position of the sphere.
vtkSphereRepresentation::GetCenter
void GetCenter(double xyz[3])
Definition: vtkSphereRepresentation.h:138
vtkSphereRepresentation::RadialLineProperty
vtkProperty * RadialLineProperty
Definition: vtkSphereRepresentation.h:365
vtkSphereRepresentation::GetCenter
double * GetCenter()
Definition: vtkSphereRepresentation.h:136
vtkSphereRepresentation::CreateDefaultProperties
void CreateDefaultProperties()
vtkCursor3D
generate a 3D cursor representation
Definition: vtkCursor3D.h:40
VTK_SPHERE_WIREFRAME
#define VTK_SPHERE_WIREFRAME
Definition: vtkSphereRepresentation.h:75
vtkSphereRepresentation::vtkSphereRepresentation
vtkSphereRepresentation()
vtkSphereRepresentation::WidgetInteraction
virtual void WidgetInteraction(double e[2])
vtkSphereRepresentation::SphereActor
vtkActor * SphereActor
Definition: vtkSphereRepresentation.h:314
vtkSphereRepresentation::HandleTextActor
vtkActor2D * HandleTextActor
Definition: vtkSphereRepresentation.h:361
vtkSphereRepresentation
a class defining the representation for the vtkSphereWidget2
Definition: vtkSphereRepresentation.h:79
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:55
vtkSphereRepresentation::RadialLineActor
vtkActor * RadialLineActor
Definition: vtkSphereRepresentation.h:368
vtkX3D::dir
@ dir
Definition: vtkX3D.h:324
vtkSphereRepresentation::PlaceWidget
virtual void PlaceWidget(double bounds[6])
These are methods that satisfy vtkWidgetRepresentation's API.
VTK_SPHERE_SURFACE
#define VTK_SPHERE_SURFACE
Definition: vtkSphereRepresentation.h:76
vtkSphereRepresentation::SphereSource
vtkSphereSource * SphereSource
Definition: vtkSphereRepresentation.h:316
vtkSphereRepresentation::CenterCursor
bool CenterCursor
Definition: vtkSphereRepresentation.h:374
vtkX3D::center
@ center
Definition: vtkX3D.h:230
vtkSphere
implicit function for a sphere
Definition: vtkSphere.h:38
vtkSphereRepresentation::RenderOpaqueGeometry
virtual int RenderOpaqueGeometry(vtkViewport *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
vtkSphereRepresentation::CenterCursorSource
vtkCursor3D * CenterCursorSource
Definition: vtkSphereRepresentation.h:373
vtkSphereRepresentation::BuildRepresentation
virtual void BuildRepresentation()
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
vtkSphereRepresentation::Representation
int Representation
Definition: vtkSphereRepresentation.h:320
vtkSphereRepresentation::SetThetaResolution
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the theta direction.
Definition: vtkSphereRepresentation.h:115
vtkSphereRepresentation::AdaptCenterCursorBounds
virtual void AdaptCenterCursorBounds()
vtkSphereRepresentation::HandleTextMapper
vtkTextMapper * HandleTextMapper
Definition: vtkSphereRepresentation.h:360
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
vtkSphereRepresentation::HandleSource
vtkSphereSource * HandleSource
Definition: vtkSphereRepresentation.h:351
vtkSphereRepresentation::RenderOverlay
virtual int RenderOverlay(vtkViewport *)
vtkSphereRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkSphereRepresentation::SetHandlePosition
void SetHandlePosition(double x, double y, double z)
Definition: vtkSphereRepresentation.h:167
vtkSphereRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkSphereRepresentation::SetPhiResolution
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the phi direction.
Definition: vtkSphereRepresentation.h:123
vtkSphereRepresentation::GetRadius
double GetRadius()
Definition: vtkSphereRepresentation.h:146
vtkSphereRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkSphereRepresentation.h:323
vtkTextMapper
2D text annotation
Definition: vtkTextMapper.h:54
vtkSphereRepresentation::RadialLineSource
vtkLineSource * RadialLineSource
Definition: vtkSphereRepresentation.h:366
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:47
VTK_SPHERE_OFF
#define VTK_SPHERE_OFF
Definition: vtkSphereRepresentation.h:74
vtkSphereRepresentation::HandleActor
vtkActor * HandleActor
Definition: vtkSphereRepresentation.h:349
vtkSphereRepresentation::SetRepresentationToWireframe
void SetRepresentationToWireframe()
Definition: vtkSphereRepresentation.h:106
vtkSphereRepresentation::HandleTextProperty
vtkTextProperty * HandleTextProperty
Definition: vtkSphereRepresentation.h:359
vtkSphereRepresentation::PlaceWidget
virtual void PlaceWidget(double center[3], double handlePosition[3])
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
vtkSphereRepresentation::RadialLineMapper
vtkPolyDataMapper * RadialLineMapper
Definition: vtkSphereRepresentation.h:367
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
vtkSphereRepresentation::Translate
void Translate(double *p1, double *p2)
vtkSphereRepresentation::GetPolyData
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the sphere.
vtkSphereRepresentation::SetInteractionState
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkSphereWidget2) or other object.
vtkSphereRepresentation::GetBounds
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
vtkSphereRepresentation::SetHandleDirection
void SetHandleDirection(double dir[3])
Set/Get the direction vector of the handle relative to the center of the sphere.
vtkSphereSource.h
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:43
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:48
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:40
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkSphereRepresentation::RenderTranslucentPolygonalGeometry
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *)
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkSphereRepresentation::SetRepresentationToSurface
void SetRepresentationToSurface()
Definition: vtkSphereRepresentation.h:108
vtkSphereRepresentation::SetHandlePosition
void SetHandlePosition(double handle[3])
Set/Get the position of the handle.
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:46
vtkSphereRepresentation::SphereProperty
vtkProperty * SphereProperty
Definition: vtkSphereRepresentation.h:342
vtkSphereRepresentation::Scale
void Scale(double *p1, double *p2, int X, int Y)
vtkSphereRepresentation::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
Methods supporting, and required by, the rendering process.
vtkSphereRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkSphereRepresentation.h:344
vtkSphereRepresentation::CenterActor
vtkActor * CenterActor
Definition: vtkSphereRepresentation.h:371
vtkSphereRepresentation::New
static vtkSphereRepresentation * New()
Instantiate the class.
vtkSphereRepresentation::HandleMapper
vtkPolyDataMapper * HandleMapper
Definition: vtkSphereRepresentation.h:350
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
vtkSphereRepresentation::RadialLine
int RadialLine
Definition: vtkSphereRepresentation.h:364
vtkSphereRepresentation::HandleText
int HandleText
Definition: vtkSphereRepresentation.h:358
vtkSphereRepresentation::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:42
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:65
vtkSphereRepresentation::GetThetaResolution
int GetThetaResolution()
Definition: vtkSphereRepresentation.h:117
vtkSphereRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkSphereRepresentation.h:345
vtkSphereRepresentation::Translating
@ Translating
Definition: vtkSphereRepresentation.h:95
vtkSphereRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double e[2])
vtkSphereRepresentation::HasTranslucentPolygonalGeometry
virtual int HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
vtkSphereRepresentation::SpherePicker
vtkCellPicker * SpherePicker
Definition: vtkSphereRepresentation.h:324
vtkX3D::radius
@ radius
Definition: vtkX3D.h:252
vtkSphereRepresentation::GetPhiResolution
int GetPhiResolution()
Definition: vtkSphereRepresentation.h:125
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:70
vtkSphereRepresentation::~vtkSphereRepresentation
~vtkSphereRepresentation()
vtkSphereRepresentation::HighlightSphere
void HighlightSphere(int highlight)
vtkSphereRepresentation::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkSphereRepresentation.h:315
vtkSphereRepresentation::PlaceHandle
void PlaceHandle(double *center, double radius)
vtkSphereRepresentation::HighlightHandle
void HighlightHandle(int)
vtkSphereRepresentation::SelectedSphereProperty
vtkProperty * SelectedSphereProperty
Definition: vtkSphereRepresentation.h:343
vtkSphereRepresentation::SizeHandles
virtual void SizeHandles()
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:45