VTK  9.0.1
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 =========================================================================*/
46 #ifndef vtkSphereRepresentation_h
47 #define vtkSphereRepresentation_h
48 
49 #include "vtkInteractionWidgetsModule.h" // For export macro
50 #include "vtkSphereSource.h" // Needed for fast access to the sphere source
52 
53 class vtkActor;
54 class vtkPolyDataMapper;
55 class vtkSphere;
56 class vtkSphereSource;
57 class vtkCellPicker;
58 class vtkProperty;
59 class vtkPolyData;
60 class vtkPoints;
62 class vtkTransform;
63 class vtkDoubleArray;
64 class vtkMatrix4x4;
65 class vtkTextMapper;
66 class vtkActor2D;
67 class vtkTextProperty;
68 class vtkLineSource;
69 class vtkCursor3D;
70 
71 #define VTK_SPHERE_OFF 0
72 #define VTK_SPHERE_WIREFRAME 1
73 #define VTK_SPHERE_SURFACE 2
74 
75 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereRepresentation : public vtkWidgetRepresentation
76 {
77 public:
81  static vtkSphereRepresentation* New();
82 
84 
88  void PrintSelf(ostream& os, vtkIndent indent) override;
90 
91  // Used to manage the state of the widget
92  enum
93  {
94  Outside = 0,
98  Scaling
99  };
100 
102 
106  vtkSetClampMacro(Representation, int, VTK_SPHERE_OFF, VTK_SPHERE_SURFACE);
107  vtkGetMacro(Representation, int);
108  void SetRepresentationToOff() { this->SetRepresentation(VTK_SPHERE_OFF); }
109  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_SPHERE_WIREFRAME); }
110  void SetRepresentationToSurface() { this->SetRepresentation(VTK_SPHERE_SURFACE); }
112 
116  void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
117  int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
118 
122  void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
123  int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
124 
130  void SetCenter(double c[3]);
131  void SetCenter(double x, double y, double z)
132  {
133  double c[3];
134  c[0] = x;
135  c[1] = y;
136  c[2] = z;
137  this->SetCenter(c);
138  }
139  double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
140  void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
141 
146  void SetRadius(double r);
147  double GetRadius() { return this->SphereSource->GetRadius(); }
148 
150 
156  vtkSetMacro(HandleVisibility, vtkTypeBool);
157  vtkGetMacro(HandleVisibility, vtkTypeBool);
158  vtkBooleanMacro(HandleVisibility, vtkTypeBool);
160 
162 
166  void SetHandlePosition(double handle[3]);
167  void SetHandlePosition(double x, double y, double z)
168  {
169  double p[3];
170  p[0] = x;
171  p[1] = y;
172  p[2] = z;
173  this->SetHandlePosition(p);
174  }
175  vtkGetVector3Macro(HandlePosition, double);
177 
179 
184  void SetHandleDirection(double dir[3]);
185  void SetHandleDirection(double dx, double dy, double dz)
186  {
187  double d[3];
188  d[0] = dx;
189  d[1] = dy;
190  d[2] = dz;
191  this->SetHandleDirection(d);
192  }
193  vtkGetVector3Macro(HandleDirection, double);
195 
197 
204  vtkSetMacro(HandleText, vtkTypeBool);
205  vtkGetMacro(HandleText, vtkTypeBool);
206  vtkBooleanMacro(HandleText, vtkTypeBool);
208 
210 
214  vtkSetMacro(RadialLine, vtkTypeBool);
215  vtkGetMacro(RadialLine, vtkTypeBool);
216  vtkBooleanMacro(RadialLine, vtkTypeBool);
218 
220 
224  vtkSetMacro(CenterCursor, bool);
225  vtkGetMacro(CenterCursor, bool);
226  vtkBooleanMacro(CenterCursor, bool);
228 
236  void GetPolyData(vtkPolyData* pd);
237 
244  void GetSphere(vtkSphere* sphere);
245 
247 
251  vtkGetObjectMacro(SphereProperty, vtkProperty);
252  vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
254 
256 
261  vtkGetObjectMacro(HandleProperty, vtkProperty);
262  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
264 
266 
270  vtkGetObjectMacro(HandleTextProperty, vtkTextProperty);
272 
274 
278  vtkGetObjectMacro(RadialLineProperty, vtkProperty);
280 
290  void SetInteractionState(int state);
291 
293 
298  void PlaceWidget(double bounds[6]) override;
299  virtual void PlaceWidget(double center[3], double handlePosition[3]);
300  void BuildRepresentation() override;
301  int ComputeInteractionState(int X, int Y, int modify = 0) override;
302  void StartWidgetInteraction(double e[2]) override;
303  void WidgetInteraction(double e[2]) override;
304  double* GetBounds() override;
306 
308 
311  void ReleaseGraphicsResources(vtkWindow*) override;
312  int RenderOpaqueGeometry(vtkViewport*) override;
314  int RenderOverlay(vtkViewport*) override;
317 
318  /*
319  * Register internal Pickers within PickingManager
320  */
321  void RegisterPickers() override;
322 
324 
328  vtkGetMacro(TranslationAxis, int);
329  vtkSetClampMacro(TranslationAxis, int, -1, 2);
331 
333 
336  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
337  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
338  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
339  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
341 
343 
346  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
348 
349 protected:
351  ~vtkSphereRepresentation() override;
352 
353  // Manage how the representation appears
354  double LastEventPosition[3];
355 
357 
358  // the sphere
362  void HighlightSphere(int highlight);
363 
364  // The representation of the sphere
366 
367  // Do the picking
370  double LastPickPosition[3];
371 
372  // Methods to manipulate the sphere widget
373  void Translate(const double* p1, const double* p2);
374  void Scale(const double* p1, const double* p2, int X, int Y);
375  void PlaceHandle(const double* center, double radius);
376  virtual void SizeHandles();
377 
378  // Method to adapt the center cursor bounds
379  // so it always have the same pixel size on screen
380  virtual void AdaptCenterCursorBounds();
381 
382  // Properties used to control the appearance of selected objects and
383  // the manipulator in general.
388  void CreateDefaultProperties();
389 
390  // Managing the handle
394  void HighlightHandle(int);
396  double HandleDirection[3];
397  double HandlePosition[3];
398 
399  // Manage the handle label
404 
405  // Manage the radial line segment
411 
412  // Managing the center cursor
417 
418 private:
420  void operator=(const vtkSphereRepresentation&) = delete;
421 };
422 
423 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkSphereRepresentation::SetHandleDirection
void SetHandleDirection(double dx, double dy, double dz)
Definition: vtkSphereRepresentation.h:185
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:135
vtkWidgetRepresentation.h
vtkSphereRepresentation::SetCenter
void SetCenter(double x, double y, double z)
Definition: vtkSphereRepresentation.h:131
vtkSphereRepresentation::CenterMapper
vtkPolyDataMapper * CenterMapper
Definition: vtkSphereRepresentation.h:414
vtkSphereRepresentation::SetRepresentationToOff
void SetRepresentationToOff()
Definition: vtkSphereRepresentation.h:108
vtkSphereRepresentation::GetCenter
void GetCenter(double xyz[3])
Definition: vtkSphereRepresentation.h:140
vtkSphereRepresentation::OnSphere
@ OnSphere
Definition: vtkSphereRepresentation.h:96
vtkSphereRepresentation::RadialLineProperty
vtkProperty * RadialLineProperty
Definition: vtkSphereRepresentation.h:407
vtkSphereRepresentation::GetCenter
double * GetCenter()
Definition: vtkSphereRepresentation.h:139
vtkCursor3D
generate a 3D cursor representation
Definition: vtkCursor3D.h:36
VTK_SPHERE_WIREFRAME
#define VTK_SPHERE_WIREFRAME
Definition: vtkSphereRepresentation.h:72
vtkSphereRepresentation::SetXTranslationAxisOn
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkSphereRepresentation.h:336
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkSphereRepresentation::HandleText
vtkTypeBool HandleText
Definition: vtkSphereRepresentation.h:400
vtkSphereRepresentation::SphereActor
vtkActor * SphereActor
Definition: vtkSphereRepresentation.h:359
vtkSphereRepresentation::HandleTextActor
vtkActor2D * HandleTextActor
Definition: vtkSphereRepresentation.h:403
vtkSphereRepresentation
a class defining the representation for the vtkSphereWidget2
Definition: vtkSphereRepresentation.h:75
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:59
vtkSphereRepresentation::RadialLineActor
vtkActor * RadialLineActor
Definition: vtkSphereRepresentation.h:410
vtkX3D::dir
@ dir
Definition: vtkX3D.h:330
vtkSphereRepresentation::Translating
@ Translating
Definition: vtkSphereRepresentation.h:97
VTK_SPHERE_SURFACE
#define VTK_SPHERE_SURFACE
Definition: vtkSphereRepresentation.h:73
vtkSphereRepresentation::SphereSource
vtkSphereSource * SphereSource
Definition: vtkSphereRepresentation.h:361
vtkSphereRepresentation::IsTranslationConstrained
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
Definition: vtkSphereRepresentation.h:346
vtkSphereRepresentation::CenterCursor
bool CenterCursor
Definition: vtkSphereRepresentation.h:416
vtkX3D::center
@ center
Definition: vtkX3D.h:236
vtkSphere
implicit function for a sphere
Definition: vtkSphere.h:31
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkSphereRepresentation::CenterCursorSource
vtkCursor3D * CenterCursorSource
Definition: vtkSphereRepresentation.h:415
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkSphereRepresentation::Representation
int Representation
Definition: vtkSphereRepresentation.h:365
vtkSphereRepresentation::SetThetaResolution
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the theta direction.
Definition: vtkSphereRepresentation.h:116
vtkSphereRepresentation::MovingHandle
@ MovingHandle
Definition: vtkSphereRepresentation.h:95
vtkSphereRepresentation::HandleTextMapper
vtkTextMapper * HandleTextMapper
Definition: vtkSphereRepresentation.h:402
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkSphereRepresentation::HandleSource
vtkSphereSource * HandleSource
Definition: vtkSphereRepresentation.h:393
vtkSphereRepresentation::SetHandlePosition
void SetHandlePosition(double x, double y, double z)
Definition: vtkSphereRepresentation.h:167
vtkWidgetRepresentation::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:216
vtkSphereRepresentation::SetPhiResolution
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the phi direction.
Definition: vtkSphereRepresentation.h:122
vtkWidgetRepresentation::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkWidgetRepresentation.h:213
vtkSphereRepresentation::GetRadius
double GetRadius()
Definition: vtkSphereRepresentation.h:147
vtkSphereRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkSphereRepresentation.h:368
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:136
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:208
vtkTextMapper
2D text annotation
Definition: vtkTextMapper.h:47
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkSphereRepresentation::RadialLineSource
vtkLineSource * RadialLineSource
Definition: vtkSphereRepresentation.h:408
vtkSphereRepresentation::HandleVisibility
vtkTypeBool HandleVisibility
Definition: vtkSphereRepresentation.h:395
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
VTK_SPHERE_OFF
#define VTK_SPHERE_OFF
Definition: vtkSphereRepresentation.h:71
vtkSphereRepresentation::HandleActor
vtkActor * HandleActor
Definition: vtkSphereRepresentation.h:391
vtkSphereRepresentation::SetRepresentationToWireframe
void SetRepresentationToWireframe()
Definition: vtkSphereRepresentation.h:109
vtkSphereRepresentation::HandleTextProperty
vtkTextProperty * HandleTextProperty
Definition: vtkSphereRepresentation.h:401
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkSphereRepresentation::RadialLineMapper
vtkPolyDataMapper * RadialLineMapper
Definition: vtkSphereRepresentation.h:409
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkWidgetRepresentation::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkSphereRepresentation::SetYTranslationAxisOn
void SetYTranslationAxisOn()
Definition: vtkSphereRepresentation.h:337
vtkSphereSource.h
vtkSphereRepresentation::SetTranslationAxisOff
void SetTranslationAxisOff()
Definition: vtkSphereRepresentation.h:339
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:60
vtkSphereRepresentation::RadialLine
vtkTypeBool RadialLine
Definition: vtkSphereRepresentation.h:406
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:33
vtkWidgetRepresentation::PlaceWidget
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
Definition: vtkWidgetRepresentation.h:134
vtkSphereRepresentation::SetRepresentationToSurface
void SetRepresentationToSurface()
Definition: vtkSphereRepresentation.h:110
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:39
vtkSphereRepresentation::SphereProperty
vtkProperty * SphereProperty
Definition: vtkSphereRepresentation.h:384
vtkWidgetRepresentation::RenderOverlay
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:214
vtkWidgetRepresentation::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:215
vtkSphereRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkSphereRepresentation.h:386
vtkSphereRepresentation::CenterActor
vtkActor * CenterActor
Definition: vtkSphereRepresentation.h:413
vtkSphereRepresentation::HandleMapper
vtkPolyDataMapper * HandleMapper
Definition: vtkSphereRepresentation.h:392
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkSphereRepresentation::GetThetaResolution
int GetThetaResolution()
Definition: vtkSphereRepresentation.h:117
vtkSphereRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkSphereRepresentation.h:387
vtkWidgetRepresentation::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkWidgetRepresentation.h:218
vtkSphereRepresentation::SetZTranslationAxisOn
void SetZTranslationAxisOn()
Definition: vtkSphereRepresentation.h:338
vtkSphereRepresentation::SpherePicker
vtkCellPicker * SpherePicker
Definition: vtkSphereRepresentation.h:369
vtkX3D::radius
@ radius
Definition: vtkX3D.h:258
vtkSphereRepresentation::GetPhiResolution
int GetPhiResolution()
Definition: vtkSphereRepresentation.h:123
vtkSphereRepresentation::TranslationAxis
int TranslationAxis
Definition: vtkSphereRepresentation.h:356
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkSphereRepresentation::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkSphereRepresentation.h:360
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSphereRepresentation::SelectedSphereProperty
vtkProperty * SelectedSphereProperty
Definition: vtkSphereRepresentation.h:385
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41