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:
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 
97  vtkGetMacro(Representation,int);
99  { this->SetRepresentation(VTK_SPHERE_OFF);}
101  { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
103  { this->SetRepresentation(VTK_SPHERE_SURFACE);}
105 
107 
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 
198 
203  void GetSphere(vtkSphere *sphere);
204 
206 
209  vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
211 
213 
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 
259  virtual int RenderOverlay(vtkViewport*);
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.
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
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:42
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkSphereRepresentation::SetHandleDirection
void SetHandleDirection(double dx, double dy, double dz)
Definition: vtkSphereRepresentation.h:167
vtkWidgetRepresentation.h
vtkgl::z
GLdouble GLdouble z
Definition: vtkgl.h:11754
vtkSphereRepresentation::SetCenter
void SetCenter(double x, double y, double z)
Definition: vtkSphereRepresentation.h:127
vtkSphereRepresentation::SetRadius
void SetRadius(double r)
vtkGetObjectMacro
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
vtkSphereRepresentation::SetRepresentationToOff
void SetRepresentationToOff()
Definition: vtkSphereRepresentation.h:98
vtkSphereRepresentation::GetSphere
void GetSphere(vtkSphere *sphere)
vtkSphereRepresentation::HandleVisibility
int HandleVisibility
Definition: vtkSphereRepresentation.h:306
vtkSphereRepresentation::SetCenter
void SetCenter(double c[3])
vtkSphereRepresentation::GetCenter
void GetCenter(double xyz[3])
Definition: vtkSphereRepresentation.h:131
vtkSphereRepresentation::RadialLineProperty
vtkProperty * RadialLineProperty
Definition: vtkSphereRepresentation.h:318
vtkSphereRepresentation::GetCenter
double * GetCenter()
Definition: vtkSphereRepresentation.h:129
vtkSphereRepresentation::CreateDefaultProperties
void CreateDefaultProperties()
VTK_SPHERE_WIREFRAME
#define VTK_SPHERE_WIREFRAME
Definition: vtkSphereRepresentation.h:73
vtkSphereRepresentation::vtkSphereRepresentation
vtkSphereRepresentation()
vtkSphereRepresentation::WidgetInteraction
virtual void WidgetInteraction(double e[2])
vtkSphereRepresentation::SphereActor
vtkActor * SphereActor
Definition: vtkSphereRepresentation.h:271
vtkSphereRepresentation::HandleTextActor
vtkActor2D * HandleTextActor
Definition: vtkSphereRepresentation.h:314
vtkSphereRepresentation
a class defining the representation for the vtkSphereWidget2
Definition: vtkSphereRepresentation.h:77
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:54
vtkSphereRepresentation::Translating
@ Translating
Definition: vtkSphereRepresentation.h:90
vtkSphereRepresentation::RadialLineActor
vtkActor * RadialLineActor
Definition: vtkSphereRepresentation.h:321
vtkX3D::dir
@ dir
Definition: vtkX3D.h:324
vtkSphereRepresentation::PlaceWidget
virtual void PlaceWidget(double bounds[6])
vtkInteractionWidgetsModule.h
VTK_SPHERE_SURFACE
#define VTK_SPHERE_SURFACE
Definition: vtkSphereRepresentation.h:74
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkSphereRepresentation::SphereSource
vtkSphereSource * SphereSource
Definition: vtkSphereRepresentation.h:273
vtkX3D::center
@ center
Definition: vtkX3D.h:230
vtkSphere
implicit function for a sphere
Definition: vtkSphere.h:37
vtkSphereRepresentation::RenderOpaqueGeometry
virtual int RenderOpaqueGeometry(vtkViewport *)
vtkSphereRepresentation::BuildRepresentation
virtual void BuildRepresentation()
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkSphereRepresentation::Representation
int Representation
Definition: vtkSphereRepresentation.h:277
vtkSphereRepresentation::SetThetaResolution
void SetThetaResolution(int r)
Definition: vtkSphereRepresentation.h:108
vtkSphereRepresentation::HandleTextMapper
vtkTextMapper * HandleTextMapper
Definition: vtkSphereRepresentation.h:313
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkSphereRepresentation::HandleSource
vtkSphereSource * HandleSource
Definition: vtkSphereRepresentation.h:304
vtkSphereRepresentation::RenderOverlay
virtual int RenderOverlay(vtkViewport *)
vtkSphereRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkSphereRepresentation::SetHandlePosition
void SetHandlePosition(double x, double y, double z)
Definition: vtkSphereRepresentation.h:157
vtkSphereRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkSphereRepresentation::SetPhiResolution
void SetPhiResolution(int r)
Definition: vtkSphereRepresentation.h:116
vtkSphereRepresentation::GetRadius
double GetRadius()
Definition: vtkSphereRepresentation.h:139
vtkSetClampMacro
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:143
vtkSphereRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkSphereRepresentation.h:280
vtkGetVector3Macro
#define vtkGetVector3Macro(name, type)
Definition: vtkSetGet.h:304
vtkTextMapper
2D text annotation
Definition: vtkTextMapper.h:53
vtkSphereRepresentation::RadialLineSource
vtkLineSource * RadialLineSource
Definition: vtkSphereRepresentation.h:319
vtkgl::c
const GLubyte * c
Definition: vtkgl.h:15720
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:46
VTK_SPHERE_OFF
#define VTK_SPHERE_OFF
Definition: vtkSphereRepresentation.h:72
vtkSphereRepresentation::HandleActor
vtkActor * HandleActor
Definition: vtkSphereRepresentation.h:302
vtkSphereRepresentation::SetRepresentationToWireframe
void SetRepresentationToWireframe()
Definition: vtkSphereRepresentation.h:100
vtkSphereRepresentation::HandleTextProperty
vtkTextProperty * HandleTextProperty
Definition: vtkSphereRepresentation.h:312
vtkSphereRepresentation::PlaceWidget
virtual void PlaceWidget(double center[3], double handlePosition[3])
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkSphereRepresentation::RadialLineMapper
vtkPolyDataMapper * RadialLineMapper
Definition: vtkSphereRepresentation.h:320
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:39
vtkSphereRepresentation::Translate
void Translate(double *p1, double *p2)
vtkSphereRepresentation::GetPolyData
void GetPolyData(vtkPolyData *pd)
vtkSphereRepresentation::SetInteractionState
void SetInteractionState(int state)
vtkSphereRepresentation::GetBounds
virtual double * GetBounds()
vtkSphereRepresentation::SetHandleDirection
void SetHandleDirection(double dir[3])
vtkSphereSource.h
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:42
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:39
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
vtkSphereRepresentation::RenderTranslucentPolygonalGeometry
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *)
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkSphereRepresentation::SetRepresentationToSurface
void SetRepresentationToSurface()
Definition: vtkSphereRepresentation.h:102
vtkSphereRepresentation::SetHandlePosition
void SetHandlePosition(double handle[3])
vtkgl::r
GLdouble GLdouble GLdouble r
Definition: vtkgl.h:11610
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:45
vtkSphereRepresentation::SphereProperty
vtkProperty * SphereProperty
Definition: vtkSphereRepresentation.h:295
vtkSphereRepresentation::Scale
void Scale(double *p1, double *p2, int X, int Y)
VTKINTERACTIONWIDGETS_EXPORT
#define VTKINTERACTIONWIDGETS_EXPORT
Definition: vtkInteractionWidgetsModule.h:15
vtkgl::y
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
vtkSphereRepresentation::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
vtkSphereRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkSphereRepresentation.h:297
vtkSphereRepresentation::New
static vtkSphereRepresentation * New()
vtkSphereRepresentation::HandleMapper
vtkPolyDataMapper * HandleMapper
Definition: vtkSphereRepresentation.h:303
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkSphereRepresentation::RadialLine
int RadialLine
Definition: vtkSphereRepresentation.h:317
vtkgl::p
GLfloat GLfloat p
Definition: vtkgl.h:15717
vtkSphereRepresentation::HandleText
int HandleText
Definition: vtkSphereRepresentation.h:311
vtkSphereRepresentation::RegisterPickers
virtual void RegisterPickers()
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:49
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:64
vtkSphereRepresentation::GetThetaResolution
int GetThetaResolution()
Definition: vtkSphereRepresentation.h:110
vtkSphereRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkSphereRepresentation.h:298
vtkSphereRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double e[2])
vtkSphereRepresentation::HasTranslucentPolygonalGeometry
virtual int HasTranslucentPolygonalGeometry()
vtkSphereRepresentation::SpherePicker
vtkCellPicker * SpherePicker
Definition: vtkSphereRepresentation.h:281
vtkX3D::radius
@ radius
Definition: vtkX3D.h:252
vtkSphereRepresentation::GetPhiResolution
int GetPhiResolution()
Definition: vtkSphereRepresentation.h:118
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkSphereRepresentation::~vtkSphereRepresentation
~vtkSphereRepresentation()
vtkSphereRepresentation::HighlightSphere
void HighlightSphere(int highlight)
vtkSphereRepresentation::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkSphereRepresentation.h:272
vtkSphereRepresentation::PlaceHandle
void PlaceHandle(double *center, double radius)
vtkSphereRepresentation::HighlightHandle
void HighlightHandle(int)
vtkSphereRepresentation::SelectedSphereProperty
vtkProperty * SelectedSphereProperty
Definition: vtkSphereRepresentation.h:296
vtkSphereRepresentation::SizeHandles
virtual void SizeHandles()
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:44