VTK  9.3.20240423
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
75#ifndef vtkSplineWidget_h
76#define vtkSplineWidget_h
77
78#include "vtk3DWidget.h"
79#include "vtkInteractionWidgetsModule.h" // For export macro
80
81VTK_ABI_NAMESPACE_BEGIN
82class vtkActor;
83class vtkCellPicker;
86class vtkPlaneSource;
87class vtkPoints;
88class vtkPolyData;
89class vtkProp;
90class vtkProperty;
91class vtkSphereSource;
92class vtkTransform;
93
94#define VTK_PROJECTION_YZ 0
95#define VTK_PROJECTION_XZ 1
96#define VTK_PROJECTION_XY 2
97#define VTK_PROJECTION_OBLIQUE 3
98
99class VTKINTERACTIONWIDGETS_EXPORT vtkSplineWidget : public vtk3DWidget
100{
101public:
106
108 void PrintSelf(ostream& os, vtkIndent indent) override;
109
111
114 void SetEnabled(int) override;
115 void PlaceWidget(double bounds[6]) override;
116 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
118 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
119 {
120 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
121 }
123
125
133 vtkSetMacro(ProjectToPlane, vtkTypeBool);
134 vtkGetMacro(ProjectToPlane, vtkTypeBool);
135 vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
137
143
144 vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
145 vtkGetMacro(ProjectionNormal, int);
146 void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
147 void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
148 void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
149 void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
150
152
159 void SetProjectionPosition(double position);
160 vtkGetMacro(ProjectionPosition, double);
162
171
173
178 vtkGetObjectMacro(HandleProperty, vtkProperty);
180 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
182
184
189 vtkGetObjectMacro(LineProperty, vtkProperty);
191 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
193
195
198 virtual void SetNumberOfHandles(int npts);
199 vtkGetMacro(NumberOfHandles, int);
201
203
207 void SetResolution(int resolution);
208 vtkGetMacro(Resolution, int);
210
212
221 vtkGetObjectMacro(ParametricSpline, vtkParametricSpline);
223
225
229 void SetHandlePosition(int handle, double x, double y, double z);
230 void SetHandlePosition(int handle, double xyz[3]);
231 void GetHandlePosition(int handle, double xyz[3]);
232 double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
234
236
243 void SetClosed(vtkTypeBool closed);
244 vtkGetMacro(Closed, vtkTypeBool);
245 vtkBooleanMacro(Closed, vtkTypeBool);
247
253 int IsClosed();
254
261
269
271
275 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
276 vtkGetMacro(ProcessEvents, vtkTypeBool);
277 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
279
280protected:
283
284 // Manage the state of the widget
285 int State;
287 {
288 Start = 0,
294 Outside
295 };
296
297 // handles the events
299 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
300
301 // ProcessEventsHandler() dispatches to these methods.
309
310 // Controlling vars
315
316 // Projection capabilities
320
321 // The spline
327
328 // The line segments
330 void HighlightLine(int highlight);
332
333 // Glyphs representing hot spots (e.g., handles)
337 int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
338 void SizeHandles() override;
339 void InsertHandleOnLine(double* pos);
340 void EraseHandle(const int&);
341
342 // Do the picking
347
348 // Register internal Pickers within PickingManager
349 void RegisterPickers() override;
350
351 // Methods to manipulate the spline.
352 void MovePoint(double* p1, double* p2);
353 void Scale(double* p1, double* p2, int X, int Y);
354 void Translate(double* p1, double* p2);
355 void Spin(double* p1, double* p2, double* vpn);
356
357 // Transform the control points (used for spinning)
359
360 // Properties used to control the appearance of selected objects and
361 // the manipulator in general.
367
368 // For efficient spinning
369 double Centroid[3];
372
373private:
374 vtkSplineWidget(const vtkSplineWidget&) = delete;
375 void operator=(const vtkSplineWidget&) = delete;
376};
377
378VTK_ABI_NAMESPACE_END
379#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
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:139
concrete dataset represents vertices, lines, polygons, and triangle strips
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
represent surface properties of a geometric object
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(...)