VTK  9.3.0
vtkSplineWidget.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
72#ifndef vtkSplineWidget_h
73#define vtkSplineWidget_h
74
75#include "vtk3DWidget.h"
76#include "vtkInteractionWidgetsModule.h" // For export macro
77
78VTK_ABI_NAMESPACE_BEGIN
79class vtkActor;
80class vtkCellPicker;
83class vtkPlaneSource;
84class vtkPoints;
85class vtkPolyData;
86class vtkProp;
87class vtkProperty;
88class vtkSphereSource;
89class vtkTransform;
90
91#define VTK_PROJECTION_YZ 0
92#define VTK_PROJECTION_XZ 1
93#define VTK_PROJECTION_XY 2
94#define VTK_PROJECTION_OBLIQUE 3
95
96class VTKINTERACTIONWIDGETS_EXPORT vtkSplineWidget : public vtk3DWidget
97{
98public:
103
105 void PrintSelf(ostream& os, vtkIndent indent) override;
106
108
111 void SetEnabled(int) override;
112 void PlaceWidget(double bounds[6]) override;
113 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
115 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
116 {
117 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
118 }
120
122
130 vtkSetMacro(ProjectToPlane, vtkTypeBool);
131 vtkGetMacro(ProjectToPlane, vtkTypeBool);
132 vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
134
140
141 vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
142 vtkGetMacro(ProjectionNormal, int);
143 void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
144 void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
145 void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
146 void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
147
149
156 void SetProjectionPosition(double position);
157 vtkGetMacro(ProjectionPosition, double);
159
168
170
175 vtkGetObjectMacro(HandleProperty, vtkProperty);
177 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
179
181
186 vtkGetObjectMacro(LineProperty, vtkProperty);
188 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
190
192
195 virtual void SetNumberOfHandles(int npts);
196 vtkGetMacro(NumberOfHandles, int);
198
200
204 void SetResolution(int resolution);
205 vtkGetMacro(Resolution, int);
207
209
218 vtkGetObjectMacro(ParametricSpline, vtkParametricSpline);
220
222
226 void SetHandlePosition(int handle, double x, double y, double z);
227 void SetHandlePosition(int handle, double xyz[3]);
228 void GetHandlePosition(int handle, double xyz[3]);
229 double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
231
233
240 void SetClosed(vtkTypeBool closed);
241 vtkGetMacro(Closed, vtkTypeBool);
242 vtkBooleanMacro(Closed, vtkTypeBool);
244
250 int IsClosed();
251
258
266
268
272 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
273 vtkGetMacro(ProcessEvents, vtkTypeBool);
274 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
276
277protected:
280
281 // Manage the state of the widget
282 int State;
284 {
285 Start = 0,
291 Outside
292 };
293
294 // handles the events
296 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
297
298 // ProcessEventsHandler() dispatches to these methods.
306
307 // Controlling vars
312
313 // Projection capabilities
317
318 // The spline
324
325 // The line segments
327 void HighlightLine(int highlight);
329
330 // Glyphs representing hot spots (e.g., handles)
334 int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
335 void SizeHandles() override;
336 void InsertHandleOnLine(double* pos);
337 void EraseHandle(const int&);
338
339 // Do the picking
344
345 // Register internal Pickers within PickingManager
346 void RegisterPickers() override;
347
348 // Methods to manipulate the spline.
349 void MovePoint(double* p1, double* p2);
350 void Scale(double* p1, double* p2, int X, int Y);
351 void Translate(double* p1, double* p2);
352 void Spin(double* p1, double* p2, double* vpn);
353
354 // Transform the control points (used for spinning)
356
357 // Properties used to control the appearance of selected objects and
358 // the manipulator in general.
364
365 // For efficient spinning
366 double Centroid[3];
369
370private:
371 vtkSplineWidget(const vtkSplineWidget&) = delete;
372 void operator=(const vtkSplineWidget&) = delete;
373};
374
375VTK_ABI_NAMESPACE_END
376#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:57
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:29
abstract base class for most VTK objects
Definition vtkObject.h:49
tessellate parametric functions
parametric function for 1D interpolating splines
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition vtkPoints.h:29
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:80
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
represent surface properties of a geometric object
Definition vtkProperty.h:57
create a polygonal sphere centered at the origin
3D widget for manipulating a spline
vtkProperty * LineProperty
void EraseHandle(const int &)
vtkProperty * HandleProperty
void GetHandlePosition(int handle, double xyz[3])
Set/Get the position of the spline handles.
void SetHandlePosition(int handle, double x, double y, double z)
Set/Get the position of the spline handles.
void SetProjectionNormalToZAxes()
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
void SizeHandles() override
void OnRightButtonDown()
vtkProperty * SelectedHandleProperty
vtkSphereSource ** HandleGeometry
void PlaceWidget() override
Methods that satisfy the superclass' API.
void Spin(double *p1, double *p2, double *vpn)
void SetProjectionPosition(double position)
Set the position of spline handles and points in terms of a plane's position.
void OnRightButtonUp()
virtual void SetNumberOfHandles(int npts)
Set/Get the number of handles for this widget.
int HighlightHandle(vtkProp *prop)
virtual void SetSelectedLineProperty(vtkProperty *)
Set/Get the line properties.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the spline.
void CreateDefaultProperties()
void CalculateCentroid()
void SetResolution(int resolution)
Set/Get the number of line segments representing the spline for this widget.
vtkActor * CurrentHandle
void SetHandlePosition(int handle, double xyz[3])
Set/Get the position of the spline handles.
void MovePoint(double *p1, double *p2)
vtkTypeBool ProcessEvents
void Scale(double *p1, double *p2, int X, int Y)
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
void OnLeftButtonUp()
void InsertHandleOnLine(double *pos)
vtkParametricSpline * ParametricSpline
double GetSummedLength()
Get the approximate vs.
void SetProjectionNormalToXAxes()
void InitializeHandles(vtkPoints *points)
Convenience method to allocate and set the handles from a vtkPoints instance.
vtkCellPicker * LinePicker
vtkProperty * SelectedLineProperty
void ProjectPointsToOrthoPlane()
void SetProjectionNormalToYAxes()
vtkPlaneSource * PlaneSource
virtual void SetParametricSpline(vtkParametricSpline *)
Set the parametric spline object.
vtkTypeBool ProjectToPlane
vtkParametricFunctionSource * ParametricFunctionSource
vtkTransform * Transform
virtual void SetLineProperty(vtkProperty *)
Set/Get the line properties.
virtual void SetHandleProperty(vtkProperty *)
Set/Get the handle properties (the spheres are the handles).
void BuildRepresentation()
void SetProjectionNormalToOblique()
static void ProcessEventsHandler(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void SetClosed(vtkTypeBool closed)
Control whether the spline is open or closed.
void ProjectPointsToObliquePlane()
static vtkSplineWidget * New()
Instantiate the object.
void Translate(double *p1, double *p2)
void OnLeftButtonDown()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ProjectPointsToPlane()
void OnMiddleButtonUp()
void OnMiddleButtonDown()
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void HighlightLine(int highlight)
double * GetHandlePosition(int handle)
Set/Get the position of the spline handles.
vtkCellPicker * HandlePicker
virtual void SetSelectedHandleProperty(vtkProperty *)
Set/Get the handle properties (the spheres are the handles).
void SetPlaneSource(vtkPlaneSource *plane)
Set up a reference to a vtkPlaneSource that could be from another widget object, e....
int IsClosed()
Convenience method to determine whether the spline is closed in a geometric sense.
~vtkSplineWidget() override
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_PROJECTION_YZ
#define VTK_PROJECTION_OBLIQUE
#define VTK_SIZEHINT(...)