VTK  9.1.0
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 =========================================================================*/
85 #ifndef vtkSphereRepresentation_h
86 #define vtkSphereRepresentation_h
87 
88 #include "vtkInteractionWidgetsModule.h" // For export macro
89 #include "vtkSphereSource.h" // Needed for fast access to the sphere source
91 
92 class vtkActor;
93 class vtkPolyDataMapper;
94 class vtkSphere;
95 class vtkSphereSource;
96 class vtkCellPicker;
97 class vtkProperty;
98 class vtkPolyData;
99 class vtkPoints;
101 class vtkTransform;
102 class vtkDoubleArray;
103 class vtkMatrix4x4;
104 class vtkTextMapper;
105 class vtkActor2D;
106 class vtkTextProperty;
107 class vtkLineSource;
108 class vtkCursor3D;
109 
110 #define VTK_SPHERE_OFF 0
111 #define VTK_SPHERE_WIREFRAME 1
112 #define VTK_SPHERE_SURFACE 2
113 
114 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereRepresentation : public vtkWidgetRepresentation
115 {
116 public:
121 
123 
127  void PrintSelf(ostream& os, vtkIndent indent) override;
129 
130  // Used to manage the state of the widget
131  enum
132  {
133  Outside = 0,
137  Scaling
138  };
139 
141 
145  vtkSetClampMacro(Representation, int, VTK_SPHERE_OFF, VTK_SPHERE_SURFACE);
146  vtkGetMacro(Representation, int);
147  void SetRepresentationToOff() { this->SetRepresentation(VTK_SPHERE_OFF); }
148  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_SPHERE_WIREFRAME); }
149  void SetRepresentationToSurface() { this->SetRepresentation(VTK_SPHERE_SURFACE); }
151 
155  void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
156  int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
157 
161  void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
162  int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
163 
169  void SetCenter(double c[3]);
170  void SetCenter(double x, double y, double z)
171  {
172  double c[3];
173  c[0] = x;
174  c[1] = y;
175  c[2] = z;
176  this->SetCenter(c);
177  }
178  double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
179  void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
180 
185  void SetRadius(double r);
186  double GetRadius() { return this->SphereSource->GetRadius(); }
187 
189 
195  vtkSetMacro(HandleVisibility, vtkTypeBool);
196  vtkGetMacro(HandleVisibility, vtkTypeBool);
197  vtkBooleanMacro(HandleVisibility, vtkTypeBool);
199 
201 
205  void SetHandlePosition(double handle[3]);
206  void SetHandlePosition(double x, double y, double z)
207  {
208  double p[3];
209  p[0] = x;
210  p[1] = y;
211  p[2] = z;
212  this->SetHandlePosition(p);
213  }
214  vtkGetVector3Macro(HandlePosition, double);
216 
218 
223  void SetHandleDirection(double dir[3]);
224  void SetHandleDirection(double dx, double dy, double dz)
225  {
226  double d[3];
227  d[0] = dx;
228  d[1] = dy;
229  d[2] = dz;
230  this->SetHandleDirection(d);
231  }
232  vtkGetVector3Macro(HandleDirection, double);
234 
236 
243  vtkSetMacro(HandleText, vtkTypeBool);
244  vtkGetMacro(HandleText, vtkTypeBool);
245  vtkBooleanMacro(HandleText, vtkTypeBool);
247 
249 
253  vtkSetMacro(RadialLine, vtkTypeBool);
254  vtkGetMacro(RadialLine, vtkTypeBool);
255  vtkBooleanMacro(RadialLine, vtkTypeBool);
257 
259 
263  vtkSetMacro(CenterCursor, bool);
264  vtkGetMacro(CenterCursor, bool);
265  vtkBooleanMacro(CenterCursor, bool);
267 
276 
283  void GetSphere(vtkSphere* sphere);
284 
286 
290  vtkGetObjectMacro(SphereProperty, vtkProperty);
291  vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
293 
295 
300  vtkGetObjectMacro(HandleProperty, vtkProperty);
301  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
303 
305 
309  vtkGetObjectMacro(HandleTextProperty, vtkTextProperty);
311 
313 
317  vtkGetObjectMacro(RadialLineProperty, vtkProperty);
319 
329  void SetInteractionState(int state);
330 
332 
337  void PlaceWidget(double bounds[6]) override;
338  virtual void PlaceWidget(double center[3], double handlePosition[3]);
339  void BuildRepresentation() override;
340  int ComputeInteractionState(int X, int Y, int modify = 0) override;
341  void StartWidgetInteraction(double e[2]) override;
342  void WidgetInteraction(double e[2]) override;
343  double* GetBounds() override;
345 
347 
353  int RenderOverlay(vtkViewport*) override;
356 
357  /*
358  * Register internal Pickers within PickingManager
359  */
360  void RegisterPickers() override;
361 
363 
367  vtkGetMacro(TranslationAxis, int);
368  vtkSetClampMacro(TranslationAxis, int, -1, 2);
370 
372 
375  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
376  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
377  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
378  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
380 
382 
385  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
387 
388 protected:
391 
392  // Manage how the representation appears
393  double LastEventPosition[3];
394 
396 
397  // the sphere
401  void HighlightSphere(int highlight);
402 
403  // The representation of the sphere
405 
406  // Do the picking
409  double LastPickPosition[3];
410 
411  // Methods to manipulate the sphere widget
412  void Translate(const double* p1, const double* p2);
413  void Scale(const double* p1, const double* p2, int X, int Y);
414  void PlaceHandle(const double* center, double radius);
415  virtual void SizeHandles();
416 
417  // Method to adapt the center cursor bounds
418  // so it always have the same pixel size on screen
419  virtual void AdaptCenterCursorBounds();
420 
421  // Properties used to control the appearance of selected objects and
422  // the manipulator in general.
428 
429  // Managing the handle
433  void HighlightHandle(int);
435  double HandleDirection[3];
436  double HandlePosition[3];
437 
438  // Manage the handle label
443 
444  // Manage the radial line segment
450 
451  // Managing the center cursor
456 
457 private:
459  void operator=(const vtkSphereRepresentation&) = delete;
460 };
461 
462 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:146
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkSphereRepresentation::SetHandleDirection
void SetHandleDirection(double dx, double dy, double dz)
Set/Get the direction vector of the handle relative to the center of the sphere.
Definition: vtkSphereRepresentation.h:224
vtkWidgetRepresentation.h
vtkSphereRepresentation::SetCenter
void SetCenter(double x, double y, double z)
Definition: vtkSphereRepresentation.h:170
vtkSphereRepresentation::SetRadius
void SetRadius(double r)
Set/Get the radius of sphere.
vtkSphereRepresentation::CenterMapper
vtkPolyDataMapper * CenterMapper
Definition: vtkSphereRepresentation.h:453
vtkSphereRepresentation::SetRepresentationToOff
void SetRepresentationToOff()
Set the representation (i.e., appearance) of the sphere.
Definition: vtkSphereRepresentation.h:147
vtkSphereRepresentation::GetSphere
void GetSphere(vtkSphere *sphere)
Get the spherical implicit function defined by this widget.
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:179
vtkSphereRepresentation::RadialLineProperty
vtkProperty * RadialLineProperty
Definition: vtkSphereRepresentation.h:446
vtkSphereRepresentation::GetCenter
double * GetCenter()
Definition: vtkSphereRepresentation.h:178
vtkSphereRepresentation::PlaceWidget
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkSphereRepresentation::CreateDefaultProperties
void CreateDefaultProperties()
vtkCursor3D
generate a 3D cursor representation
Definition: vtkCursor3D.h:56
vtkSphereRepresentation::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
VTK_SPHERE_WIREFRAME
#define VTK_SPHERE_WIREFRAME
Definition: vtkSphereRepresentation.h:111
vtkSphereRepresentation::vtkSphereRepresentation
vtkSphereRepresentation()
vtkSphereRepresentation::SetXTranslationAxisOn
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkSphereRepresentation.h:375
vtkSphereRepresentation::HandleText
vtkTypeBool HandleText
Definition: vtkSphereRepresentation.h:439
vtkSphereRepresentation::SphereActor
vtkActor * SphereActor
Definition: vtkSphereRepresentation.h:398
vtkSphereRepresentation::GetBounds
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkSphereRepresentation::HandleTextActor
vtkActor2D * HandleTextActor
Definition: vtkSphereRepresentation.h:442
vtkSphereRepresentation
a class defining the representation for the vtkSphereWidget2
Definition: vtkSphereRepresentation.h:115
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:60
vtkSphereRepresentation::RadialLineActor
vtkActor * RadialLineActor
Definition: vtkSphereRepresentation.h:449
vtkX3D::dir
@ dir
Definition: vtkX3D.h:330
VTK_SPHERE_SURFACE
#define VTK_SPHERE_SURFACE
Definition: vtkSphereRepresentation.h:112
vtkSphereRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and to print out the contents of the class.
vtkSphereRepresentation::SphereSource
vtkSphereSource * SphereSource
Definition: vtkSphereRepresentation.h:400
vtkSphereRepresentation::IsTranslationConstrained
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
Definition: vtkSphereRepresentation.h:385
vtkSphereRepresentation::CenterCursor
bool CenterCursor
Definition: vtkSphereRepresentation.h:455
vtkX3D::center
@ center
Definition: vtkX3D.h:236
vtkSphere
implicit function for a sphere
Definition: vtkSphere.h:141
vtkSphereRepresentation::CenterCursorSource
vtkCursor3D * CenterCursorSource
Definition: vtkSphereRepresentation.h:454
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
vtkSphereRepresentation::Representation
int Representation
Definition: vtkSphereRepresentation.h:404
vtkSphereRepresentation::SetThetaResolution
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the theta direction.
Definition: vtkSphereRepresentation.h:155
vtkSphereRepresentation::AdaptCenterCursorBounds
virtual void AdaptCenterCursorBounds()
vtkSphereRepresentation::HandleTextMapper
vtkTextMapper * HandleTextMapper
Definition: vtkSphereRepresentation.h:441
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
vtkSphereRepresentation::BuildRepresentation
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkSphereRepresentation::HandleSource
vtkSphereSource * HandleSource
Definition: vtkSphereRepresentation.h:432
vtkSphereRepresentation::SetHandlePosition
void SetHandlePosition(double x, double y, double z)
Set/Get the position of the handle.
Definition: vtkSphereRepresentation.h:206
vtkSphereRepresentation::SetPhiResolution
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the phi direction.
Definition: vtkSphereRepresentation.h:161
vtkSphereRepresentation::GetRadius
double GetRadius()
Definition: vtkSphereRepresentation.h:186
vtkSphereRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkSphereRepresentation.h:407
vtkSphereRepresentation::Translate
void Translate(const double *p1, const double *p2)
vtkTextMapper
2D text annotation
Definition: vtkTextMapper.h:157
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:48
vtkSphereRepresentation::RadialLineSource
vtkLineSource * RadialLineSource
Definition: vtkSphereRepresentation.h:447
vtkSphereRepresentation::RenderOverlay
int RenderOverlay(vtkViewport *) override
Methods supporting, and required by, the rendering process.
vtkSphereRepresentation::MovingHandle
@ MovingHandle
Definition: vtkSphereRepresentation.h:134
vtkSphereRepresentation::PlaceHandle
void PlaceHandle(const double *center, double radius)
vtkSphereRepresentation::HandleVisibility
vtkTypeBool HandleVisibility
Definition: vtkSphereRepresentation.h:434
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:149
vtkSphereRepresentation::WidgetInteraction
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
VTK_SPHERE_OFF
#define VTK_SPHERE_OFF
Definition: vtkSphereRepresentation.h:110
vtkSphereRepresentation::HandleActor
vtkActor * HandleActor
Definition: vtkSphereRepresentation.h:430
vtkSphereRepresentation::SetRepresentationToWireframe
void SetRepresentationToWireframe()
Set the representation (i.e., appearance) of the sphere.
Definition: vtkSphereRepresentation.h:148
vtkSphereRepresentation::HandleTextProperty
vtkTextProperty * HandleTextProperty
Definition: vtkSphereRepresentation.h:440
vtkSphereRepresentation::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting, and required by, the rendering process.
vtkSphereRepresentation::PlaceWidget
virtual void PlaceWidget(double center[3], double handlePosition[3])
These are methods that satisfy vtkWidgetRepresentation's API.
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
vtkSphereRepresentation::RadialLineMapper
vtkPolyDataMapper * RadialLineMapper
Definition: vtkSphereRepresentation.h:448
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
vtkSphereRepresentation::SetYTranslationAxisOn
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkSphereRepresentation.h:376
vtkSphereRepresentation::GetPolyData
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the sphere.
vtkSphereRepresentation::StartWidgetInteraction
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkSphereRepresentation::SetInteractionState
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkSphereWidget2) or other object.
vtkSphereRepresentation::SetHandleDirection
void SetHandleDirection(double dir[3])
Set/Get the direction vector of the handle relative to the center of the sphere.
vtkSphereSource.h
vtkSphereRepresentation::SetTranslationAxisOff
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
Definition: vtkSphereRepresentation.h:378
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:170
vtkSphereRepresentation::RadialLine
vtkTypeBool RadialLine
Definition: vtkSphereRepresentation.h:445
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkSphereRepresentation::OnSphere
@ OnSphere
Definition: vtkSphereRepresentation.h:135
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:143
vtkSphereRepresentation::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
vtkSphereRepresentation::SetRepresentationToSurface
void SetRepresentationToSurface()
Set the representation (i.e., appearance) of the sphere.
Definition: vtkSphereRepresentation.h:149
vtkSphereRepresentation::SetHandlePosition
void SetHandlePosition(double handle[3])
Set/Get the position of the handle.
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:149
vtkSphereRepresentation::SphereProperty
vtkProperty * SphereProperty
Definition: vtkSphereRepresentation.h:423
vtkSphereRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkSphereRepresentation.h:425
vtkSphereRepresentation::CenterActor
vtkActor * CenterActor
Definition: vtkSphereRepresentation.h:452
vtkSphereRepresentation::New
static vtkSphereRepresentation * New()
Instantiate the class.
vtkSphereRepresentation::HandleMapper
vtkPolyDataMapper * HandleMapper
Definition: vtkSphereRepresentation.h:431
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkSphereRepresentation::Translating
@ Translating
Definition: vtkSphereRepresentation.h:136
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:145
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:171
vtkSphereRepresentation::GetThetaResolution
int GetThetaResolution()
Definition: vtkSphereRepresentation.h:156
vtkSphereRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkSphereRepresentation.h:426
vtkSphereRepresentation::~vtkSphereRepresentation
~vtkSphereRepresentation() override
vtkSphereRepresentation::SetZTranslationAxisOn
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkSphereRepresentation.h:377
vtkSphereRepresentation::SpherePicker
vtkCellPicker * SpherePicker
Definition: vtkSphereRepresentation.h:408
vtkX3D::radius
@ radius
Definition: vtkX3D.h:258
vtkSphereRepresentation::GetPhiResolution
int GetPhiResolution()
Definition: vtkSphereRepresentation.h:162
vtkSphereRepresentation::TranslationAxis
int TranslationAxis
Definition: vtkSphereRepresentation.h:395
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
vtkSphereRepresentation::RegisterPickers
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkSphereRepresentation::Scale
void Scale(const double *p1, const double *p2, int X, int Y)
vtkSphereRepresentation::HighlightSphere
void HighlightSphere(int highlight)
vtkSphereRepresentation::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting, and required by, the rendering process.
vtkSphereRepresentation::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkSphereRepresentation.h:399
vtkSphereRepresentation::ComputeInteractionState
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkSphereRepresentation::HighlightHandle
void HighlightHandle(int)
vtkSphereRepresentation::SelectedSphereProperty
vtkProperty * SelectedSphereProperty
Definition: vtkSphereRepresentation.h:424
vtkSphereRepresentation::SizeHandles
virtual void SizeHandles()
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:151