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=========================================================================*/
55#ifndef vtkSphereRepresentation_h
56#define vtkSphereRepresentation_h
57
58#include "vtkInteractionWidgetsModule.h" // For export macro
59#include "vtkSphereSource.h" // Needed for fast access to the sphere source
61
62class vtkActor;
64class vtkSphere;
65class vtkSphereSource;
66class vtkCellPicker;
67class vtkProperty;
68class vtkPolyData;
69class vtkPoints;
71class vtkTransform;
72class vtkDoubleArray;
73class vtkMatrix4x4;
74class vtkTextMapper;
75class vtkActor2D;
76class vtkTextProperty;
77class vtkLineSource;
78class vtkCursor3D;
79
80#define VTK_SPHERE_OFF 0
81#define VTK_SPHERE_WIREFRAME 1
82#define VTK_SPHERE_SURFACE 2
83
84class VTKINTERACTIONWIDGETS_EXPORT vtkSphereRepresentation : public vtkWidgetRepresentation
85{
86public:
91
93
97 void PrintSelf(ostream& os, vtkIndent indent) override;
99
100 // Used to manage the state of the widget
101 enum
102 {
103 Outside = 0,
107 Scaling
108 };
109
111
115 vtkSetClampMacro(Representation, int, VTK_SPHERE_OFF, VTK_SPHERE_SURFACE);
116 vtkGetMacro(Representation, int);
117 void SetRepresentationToOff() { this->SetRepresentation(VTK_SPHERE_OFF); }
118 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_SPHERE_WIREFRAME); }
119 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SPHERE_SURFACE); }
121
125 void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
126 int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
127
131 void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
132 int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
133
139 void SetCenter(double c[3]);
140 void SetCenter(double x, double y, double z)
141 {
142 double c[3];
143 c[0] = x;
144 c[1] = y;
145 c[2] = z;
146 this->SetCenter(c);
147 }
148 double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
149 void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
150
155 void SetRadius(double r);
156 double GetRadius() { return this->SphereSource->GetRadius(); }
157
159
165 vtkSetMacro(HandleVisibility, vtkTypeBool);
166 vtkGetMacro(HandleVisibility, vtkTypeBool);
167 vtkBooleanMacro(HandleVisibility, vtkTypeBool);
169
171
175 void SetHandlePosition(double handle[3]);
176 void SetHandlePosition(double x, double y, double z)
177 {
178 double p[3];
179 p[0] = x;
180 p[1] = y;
181 p[2] = z;
182 this->SetHandlePosition(p);
183 }
184 vtkGetVector3Macro(HandlePosition, double);
186
188
193 void SetHandleDirection(double dir[3]);
194 void SetHandleDirection(double dx, double dy, double dz)
195 {
196 double d[3];
197 d[0] = dx;
198 d[1] = dy;
199 d[2] = dz;
200 this->SetHandleDirection(d);
201 }
202 vtkGetVector3Macro(HandleDirection, double);
204
206
213 vtkSetMacro(HandleText, vtkTypeBool);
214 vtkGetMacro(HandleText, vtkTypeBool);
215 vtkBooleanMacro(HandleText, vtkTypeBool);
217
219
223 vtkSetMacro(RadialLine, vtkTypeBool);
224 vtkGetMacro(RadialLine, vtkTypeBool);
225 vtkBooleanMacro(RadialLine, vtkTypeBool);
227
229
233 vtkSetMacro(CenterCursor, bool);
234 vtkGetMacro(CenterCursor, bool);
235 vtkBooleanMacro(CenterCursor, bool);
237
246
253 void GetSphere(vtkSphere* sphere);
254
256
260 vtkGetObjectMacro(SphereProperty, vtkProperty);
261 vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
263
265
270 vtkGetObjectMacro(HandleProperty, vtkProperty);
271 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
273
275
279 vtkGetObjectMacro(HandleTextProperty, vtkTextProperty);
281
283
287 vtkGetObjectMacro(RadialLineProperty, vtkProperty);
289
299 void SetInteractionState(int state);
300
302
307 void PlaceWidget(double bounds[6]) override;
308 virtual void PlaceWidget(double center[3], double handlePosition[3]);
309 void BuildRepresentation() override;
310 int ComputeInteractionState(int X, int Y, int modify = 0) override;
311 void StartWidgetInteraction(double e[2]) override;
312 void WidgetInteraction(double e[2]) override;
313 double* GetBounds() override;
315
317
326
327 /*
328 * Register internal Pickers within PickingManager
329 */
330 void RegisterPickers() override;
331
333
337 vtkGetMacro(TranslationAxis, int);
338 vtkSetClampMacro(TranslationAxis, int, -1, 2);
340
342
345 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
346 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
347 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
348 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
350
352
355 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
357
358protected:
361
362 // Manage how the representation appears
363 double LastEventPosition[3];
364
366
367 // the sphere
371 void HighlightSphere(int highlight);
372
373 // The representation of the sphere
375
376 // Do the picking
379 double LastPickPosition[3];
380
381 // Methods to manipulate the sphere widget
382 void Translate(const double* p1, const double* p2);
383 void Scale(const double* p1, const double* p2, int X, int Y);
384 void PlaceHandle(const double* center, double radius);
385 virtual void SizeHandles();
386
387 // Method to adapt the center cursor bounds
388 // so it always have the same pixel size on screen
390
391 // Properties used to control the appearance of selected objects and
392 // the manipulator in general.
398
399 // Managing the handle
405 double HandleDirection[3];
406 double HandlePosition[3];
407
408 // Manage the handle label
413
414 // Manage the radial line segment
420
421 // Managing the center cursor
426
427private:
429 void operator=(const vtkSphereRepresentation&) = delete;
430};
431
432#endif
a actor that draws 2D data
Definition: vtkActor2D.h:49
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:76
generate a 3D cursor representation
Definition: vtkCursor3D.h:46
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition: vtkIndent.h:43
create a line defined by two end points
Definition: vtkLineSource.h:70
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:45
represent and manipulate 3D points
Definition: vtkPoints.h:43
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
represent surface properties of a geometric object
Definition: vtkProperty.h:71
a class defining the representation for the vtkSphereWidget2
void SetHandleDirection(double dx, double dy, double dz)
Set/Get the direction vector of the handle relative to the center of the sphere.
void SetPhiResolution(int r)
Set/Get the resolution of the sphere in the phi direction.
void SetRepresentationToWireframe()
Set the representation (i.e., appearance) of the sphere.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the sphere.
vtkPolyDataMapper * HandleMapper
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and to print out the contents of the class.
vtkPolyDataMapper * CenterMapper
void SetHandleDirection(double dir[3])
Set/Get the direction vector of the handle relative to the center of the sphere.
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetCenter(double x, double y, double z)
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
static vtkSphereRepresentation * New()
Instantiate the class.
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void SetRepresentationToOff()
Set the representation (i.e., appearance) of the sphere.
virtual void PlaceWidget(double center[3], double handlePosition[3])
These are methods that satisfy vtkWidgetRepresentation's API.
void SetCenter(double c[3])
Set/Get the center position of the sphere.
void PlaceHandle(const double *center, double radius)
vtkPolyDataMapper * RadialLineMapper
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetThetaResolution(int r)
Set/Get the resolution of the sphere in the theta direction.
void SetInteractionState(int state)
The interaction state may be set from a widget (e.g., vtkSphereWidget2) or other object.
void GetSphere(vtkSphere *sphere)
Get the spherical implicit function defined by this widget.
vtkTextProperty * HandleTextProperty
void HighlightSphere(int highlight)
void SetRadius(double r)
Set/Get the radius of sphere.
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
~vtkSphereRepresentation() override
void SetHandlePosition(double x, double y, double z)
Set/Get the position of the handle.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkPolyDataMapper * SphereMapper
int RenderOverlay(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetRepresentationToSurface()
Set the representation (i.e., appearance) of the sphere.
void SetHandlePosition(double handle[3])
Set/Get the position of the handle.
virtual void SizeHandles()
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting, and required by, the rendering process.
void Scale(const double *p1, const double *p2, int X, int Y)
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void AdaptCenterCursorBounds()
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting, and required by, the rendering process.
void Translate(const double *p1, const double *p2)
create a polygonal sphere centered at the origin
implicit function for a sphere
Definition: vtkSphere.h:41
2D text annotation
Definition: vtkTextMapper.h:57
represent text properties.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
abstract specification for Viewports
Definition: vtkViewport.h:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:45
@ dir
Definition: vtkX3D.h:330
@ center
Definition: vtkX3D.h:236
@ radius
Definition: vtkX3D.h:258
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SPHERE_SURFACE
#define VTK_SPHERE_OFF
#define VTK_SPHERE_WIREFRAME
#define VTK_SIZEHINT(...)