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=========================================================================*/
88#ifndef vtkSphereRepresentation_h
89#define vtkSphereRepresentation_h
90
91#include "vtkInteractionWidgetsModule.h" // For export macro
92#include "vtkSphereSource.h" // Needed for fast access to the sphere source
94
95class vtkActor;
97class vtkSphere;
98class vtkSphereSource;
99class vtkCellPicker;
100class vtkProperty;
101class vtkPolyData;
102class vtkPoints;
104class vtkTransform;
105class vtkDoubleArray;
106class vtkMatrix4x4;
107class vtkTextMapper;
108class vtkActor2D;
109class vtkTextProperty;
110class vtkLineSource;
111class vtkCursor3D;
112
113#define VTK_SPHERE_OFF 0
114#define VTK_SPHERE_WIREFRAME 1
115#define VTK_SPHERE_SURFACE 2
116
117class VTKINTERACTIONWIDGETS_EXPORT vtkSphereRepresentation : public vtkWidgetRepresentation
118{
119public:
124
126
130 void PrintSelf(ostream& os, vtkIndent indent) override;
132
133 // Used to manage the state of the widget
134 enum
135 {
136 Outside = 0,
140 Scaling
141 };
142
144
148 vtkSetClampMacro(Representation, int, VTK_SPHERE_OFF, VTK_SPHERE_SURFACE);
149 vtkGetMacro(Representation, int);
150 void SetRepresentationToOff() { this->SetRepresentation(VTK_SPHERE_OFF); }
151 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_SPHERE_WIREFRAME); }
152 void SetRepresentationToSurface() { this->SetRepresentation(VTK_SPHERE_SURFACE); }
154
158 void SetThetaResolution(int r) { this->SphereSource->SetThetaResolution(r); }
159 int GetThetaResolution() { return this->SphereSource->GetThetaResolution(); }
160
164 void SetPhiResolution(int r) { this->SphereSource->SetPhiResolution(r); }
165 int GetPhiResolution() { return this->SphereSource->GetPhiResolution(); }
166
172 void SetCenter(double c[3]);
173 void SetCenter(double x, double y, double z)
174 {
175 double c[3];
176 c[0] = x;
177 c[1] = y;
178 c[2] = z;
179 this->SetCenter(c);
180 }
181 double* GetCenter() VTK_SIZEHINT(3) { return this->SphereSource->GetCenter(); }
182 void GetCenter(double xyz[3]) { this->SphereSource->GetCenter(xyz); }
183
188 void SetRadius(double r);
189 double GetRadius() { return this->SphereSource->GetRadius(); }
190
192
198 vtkSetMacro(HandleVisibility, vtkTypeBool);
199 vtkGetMacro(HandleVisibility, vtkTypeBool);
200 vtkBooleanMacro(HandleVisibility, vtkTypeBool);
202
204
208 void SetHandlePosition(double handle[3]);
209 void SetHandlePosition(double x, double y, double z)
210 {
211 double p[3];
212 p[0] = x;
213 p[1] = y;
214 p[2] = z;
215 this->SetHandlePosition(p);
216 }
217 vtkGetVector3Macro(HandlePosition, double);
219
221
226 void SetHandleDirection(double dir[3]);
227 void SetHandleDirection(double dx, double dy, double dz)
228 {
229 double d[3];
230 d[0] = dx;
231 d[1] = dy;
232 d[2] = dz;
233 this->SetHandleDirection(d);
234 }
235 vtkGetVector3Macro(HandleDirection, double);
237
239
246 vtkSetMacro(HandleText, vtkTypeBool);
247 vtkGetMacro(HandleText, vtkTypeBool);
248 vtkBooleanMacro(HandleText, vtkTypeBool);
250
252
256 vtkSetMacro(RadialLine, vtkTypeBool);
257 vtkGetMacro(RadialLine, vtkTypeBool);
258 vtkBooleanMacro(RadialLine, vtkTypeBool);
260
262
266 vtkSetMacro(CenterCursor, bool);
267 vtkGetMacro(CenterCursor, bool);
268 vtkBooleanMacro(CenterCursor, bool);
270
279
286 void GetSphere(vtkSphere* sphere);
287
289
293 vtkGetObjectMacro(SphereProperty, vtkProperty);
294 vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
296
298
303 vtkGetObjectMacro(HandleProperty, vtkProperty);
304 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
306
308
312 vtkGetObjectMacro(HandleTextProperty, vtkTextProperty);
314
316
320 vtkGetObjectMacro(RadialLineProperty, vtkProperty);
322
332 void SetInteractionState(int state);
333
335
340 void PlaceWidget(double bounds[6]) override;
341 virtual void PlaceWidget(double center[3], double handlePosition[3]);
342 void BuildRepresentation() override;
343 int ComputeInteractionState(int X, int Y, int modify = 0) override;
344 void StartWidgetInteraction(double e[2]) override;
345 void WidgetInteraction(double e[2]) override;
346 double* GetBounds() override;
348
350
359
360 /*
361 * Register internal Pickers within PickingManager
362 */
363 void RegisterPickers() override;
364
366
370 vtkGetMacro(TranslationAxis, int);
371 vtkSetClampMacro(TranslationAxis, int, -1, 2);
373
375
378 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
379 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
380 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
381 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
383
385
388 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
390
391protected:
394
395 // Manage how the representation appears
396 double LastEventPosition[3];
397
399
400 // the sphere
404 void HighlightSphere(int highlight);
405
406 // The representation of the sphere
408
409 // Do the picking
412 double LastPickPosition[3];
413
414 // Methods to manipulate the sphere widget
415 void Translate(const double* p1, const double* p2);
416 void Scale(const double* p1, const double* p2, int X, int Y);
417 void PlaceHandle(const double* center, double radius);
418 virtual void SizeHandles();
419
420 // Method to adapt the center cursor bounds
421 // so it always have the same pixel size on screen
423
424 // Properties used to control the appearance of selected objects and
425 // the manipulator in general.
431
432 // Managing the handle
438 double HandleDirection[3];
439 double HandlePosition[3];
440
441 // Manage the handle label
446
447 // Manage the radial line segment
453
454 // Managing the center cursor
459
460private:
462 void operator=(const vtkSphereRepresentation&) = delete;
463};
464
465#endif
a actor that draws 2D data
Definition: vtkActor2D.h:155
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:161
ray-cast cell picker for all kinds of Prop3Ds
generate a 3D cursor representation
Definition: vtkCursor3D.h:59
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition: vtkIndent.h:119
create a line defined by two end points
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:151
represent and manipulate 3D points
Definition: vtkPoints.h:149
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:200
represent surface properties of a geometric object
Definition: vtkProperty.h:177
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:144
2D text annotation
represent text properties.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:170
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:39
@ 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(...)