VTK  9.2.6
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=========================================================================*/
58#ifndef vtkSphereRepresentation_h
59#define vtkSphereRepresentation_h
60
61#include "vtkInteractionWidgetsModule.h" // For export macro
62#include "vtkSphereSource.h" // Needed for fast access to the sphere source
64
65class vtkActor;
67class vtkSphere;
68class vtkSphereSource;
69class vtkCellPicker;
70class vtkProperty;
71class vtkPolyData;
72class vtkPoints;
74class vtkTransform;
75class vtkDoubleArray;
76class vtkMatrix4x4;
77class vtkTextMapper;
78class vtkActor2D;
79class vtkTextProperty;
80class vtkLineSource;
81class vtkCursor3D;
82
83#define VTK_SPHERE_OFF 0
84#define VTK_SPHERE_WIREFRAME 1
85#define VTK_SPHERE_SURFACE 2
86
87class VTKINTERACTIONWIDGETS_EXPORT vtkSphereRepresentation : public vtkWidgetRepresentation
88{
89public:
94
96
100 void PrintSelf(ostream& os, vtkIndent indent) override;
102
103 // Used to manage the state of the widget
104 enum
105 {
106 Outside = 0,
110 Scaling
111 };
112
114
118 vtkSetClampMacro(Representation, int, VTK_SPHERE_OFF, VTK_SPHERE_SURFACE);
119 vtkGetMacro(Representation, int);
120 void SetRepresentationToOff() { this->SetRepresentation(VTK_SPHERE_OFF); }
121 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_SPHERE_WIREFRAME); }
122 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SPHERE_SURFACE); }
124
128 void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
129 int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
130
134 void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
135 int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
136
142 void SetCenter(double c[3]);
143 void SetCenter(double x, double y, double z)
144 {
145 double c[3];
146 c[0] = x;
147 c[1] = y;
148 c[2] = z;
149 this->SetCenter(c);
150 }
151 double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
152 void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
153
158 void SetRadius(double r);
159 double GetRadius() { return this->SphereSource->GetRadius(); }
160
162
168 vtkSetMacro(HandleVisibility, vtkTypeBool);
169 vtkGetMacro(HandleVisibility, vtkTypeBool);
170 vtkBooleanMacro(HandleVisibility, vtkTypeBool);
172
174
178 void SetHandlePosition(double handle[3]);
179 void SetHandlePosition(double x, double y, double z)
180 {
181 double p[3];
182 p[0] = x;
183 p[1] = y;
184 p[2] = z;
185 this->SetHandlePosition(p);
186 }
187 vtkGetVector3Macro(HandlePosition, double);
189
191
196 void SetHandleDirection(double dir[3]);
197 void SetHandleDirection(double dx, double dy, double dz)
198 {
199 double d[3];
200 d[0] = dx;
201 d[1] = dy;
202 d[2] = dz;
203 this->SetHandleDirection(d);
204 }
205 vtkGetVector3Macro(HandleDirection, double);
207
209
216 vtkSetMacro(HandleText, vtkTypeBool);
217 vtkGetMacro(HandleText, vtkTypeBool);
218 vtkBooleanMacro(HandleText, vtkTypeBool);
220
222
226 vtkSetMacro(RadialLine, vtkTypeBool);
227 vtkGetMacro(RadialLine, vtkTypeBool);
228 vtkBooleanMacro(RadialLine, vtkTypeBool);
230
232
236 vtkSetMacro(CenterCursor, bool);
237 vtkGetMacro(CenterCursor, bool);
238 vtkBooleanMacro(CenterCursor, bool);
240
249
256 void GetSphere(vtkSphere* sphere);
257
259
263 vtkGetObjectMacro(SphereProperty, vtkProperty);
264 vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
266
268
273 vtkGetObjectMacro(HandleProperty, vtkProperty);
274 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
276
278
282 vtkGetObjectMacro(HandleTextProperty, vtkTextProperty);
284
286
290 vtkGetObjectMacro(RadialLineProperty, vtkProperty);
292
302 void SetInteractionState(int state);
303
305
310 void PlaceWidget(double bounds[6]) override;
311 virtual void PlaceWidget(double center[3], double handlePosition[3]);
312 void BuildRepresentation() override;
313 int ComputeInteractionState(int X, int Y, int modify = 0) override;
314 void StartWidgetInteraction(double e[2]) override;
315 void WidgetInteraction(double e[2]) override;
316 double* GetBounds() override;
318
320
329
330 /*
331 * Register internal Pickers within PickingManager
332 */
333 void RegisterPickers() override;
334
336
340 vtkGetMacro(TranslationAxis, int);
341 vtkSetClampMacro(TranslationAxis, int, -1, 2);
343
345
348 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
349 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
350 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
351 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
353
355
358 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
360
361protected:
364
365 // Manage how the representation appears
366 double LastEventPosition[3];
367
369
370 // the sphere
374 void HighlightSphere(int highlight);
375
376 // The representation of the sphere
378
379 // Do the picking
382 double LastPickPosition[3];
383
384 // Methods to manipulate the sphere widget
385 void Translate(const double* p1, const double* p2);
386 void Scale(const double* p1, const double* p2, int X, int Y);
387 void PlaceHandle(const double* center, double radius);
388 virtual void SizeHandles();
389
390 // Method to adapt the center cursor bounds
391 // so it always have the same pixel size on screen
393
394 // Properties used to control the appearance of selected objects and
395 // the manipulator in general.
401
402 // Managing the handle
408 double HandleDirection[3];
409 double HandlePosition[3];
410
411 // Manage the handle label
416
417 // Manage the radial line segment
423
424 // Managing the center cursor
429
430private:
432 void operator=(const vtkSphereRepresentation&) = delete;
433};
434
435#endif
a actor that draws 2D data
Definition vtkActor2D.h:55
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:61
ray-cast cell picker for all kinds of Prop3Ds
generate a 3D cursor representation
Definition vtkCursor3D.h:49
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:49
create a line defined by two end points
represent and manipulate 4x4 transformation matrices
represent and manipulate 3D points
Definition vtkPoints.h:49
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
represent surface properties of a geometric object
Definition vtkProperty.h:77
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.
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.
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.
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.
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:44
2D text annotation
represent text properties.
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:69
#define VTK_SPHERE_SURFACE
#define VTK_SPHERE_OFF
#define VTK_SPHERE_WIREFRAME
#define VTK_SIZEHINT(...)