VTK  9.1.0
vtkSplineWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSplineWidget.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 =========================================================================*/
87 #ifndef vtkSplineWidget_h
88 #define vtkSplineWidget_h
89 
90 #include "vtk3DWidget.h"
91 #include "vtkInteractionWidgetsModule.h" // For export macro
92 
93 class vtkActor;
94 class vtkCellPicker;
97 class vtkPlaneSource;
98 class vtkPoints;
99 class vtkPolyData;
100 class vtkProp;
101 class vtkProperty;
102 class vtkSphereSource;
103 class vtkTransform;
104 
105 #define VTK_PROJECTION_YZ 0
106 #define VTK_PROJECTION_XZ 1
107 #define VTK_PROJECTION_XY 2
108 #define VTK_PROJECTION_OBLIQUE 3
109 
110 class VTKINTERACTIONWIDGETS_EXPORT vtkSplineWidget : public vtk3DWidget
111 {
112 public:
116  static vtkSplineWidget* New();
117 
118  vtkTypeMacro(vtkSplineWidget, vtk3DWidget);
119  void PrintSelf(ostream& os, vtkIndent indent) override;
120 
122 
125  void SetEnabled(int) override;
126  void PlaceWidget(double bounds[6]) override;
127  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
129  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
130  {
131  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
132  }
134 
136 
144  vtkSetMacro(ProjectToPlane, vtkTypeBool);
145  vtkGetMacro(ProjectToPlane, vtkTypeBool);
146  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
148 
154 
155  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
156  vtkGetMacro(ProjectionNormal, int);
157  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
158  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
159  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
160  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
161 
163 
171  vtkGetMacro(ProjectionPosition, double);
173 
182 
184 
189  vtkGetObjectMacro(HandleProperty, vtkProperty);
191  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
193 
195 
199  virtual void SetLineProperty(vtkProperty*);
200  vtkGetObjectMacro(LineProperty, vtkProperty);
202  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
204 
206 
209  virtual void SetNumberOfHandles(int npts);
210  vtkGetMacro(NumberOfHandles, int);
212 
214 
219  vtkGetMacro(Resolution, int);
221 
223 
232  vtkGetObjectMacro(ParametricSpline, vtkParametricSpline);
234 
236 
240  void SetHandlePosition(int handle, double x, double y, double z);
241  void SetHandlePosition(int handle, double xyz[3]);
242  void GetHandlePosition(int handle, double xyz[3]);
243  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
245 
247 
254  void SetClosed(vtkTypeBool closed);
255  vtkGetMacro(Closed, vtkTypeBool);
256  vtkBooleanMacro(Closed, vtkTypeBool);
258 
264  int IsClosed();
265 
271  double GetSummedLength();
272 
280 
282 
286  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
287  vtkGetMacro(ProcessEvents, vtkTypeBool);
288  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
290 
291 protected:
293  ~vtkSplineWidget() override;
294 
295  // Manage the state of the widget
296  int State;
298  {
299  Start = 0,
305  Outside
306  };
307 
308  // handles the events
309  static void ProcessEventsHandler(
310  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
311 
312  // ProcessEventsHandler() dispatches to these methods.
319  void OnMouseMove();
320 
321  // Controlling vars
326 
327  // Projection capabilities
331 
332  // The spline
338 
339  // The line segments
341  void HighlightLine(int highlight);
343 
344  // Glyphs representing hot spots (e.g., handles)
347  void Initialize();
348  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
349  void SizeHandles() override;
350  void InsertHandleOnLine(double* pos);
351  void EraseHandle(const int&);
352 
353  // Do the picking
358 
359  // Register internal Pickers within PickingManager
360  void RegisterPickers() override;
361 
362  // Methods to manipulate the spline.
363  void MovePoint(double* p1, double* p2);
364  void Scale(double* p1, double* p2, int X, int Y);
365  void Translate(double* p1, double* p2);
366  void Spin(double* p1, double* p2, double* vpn);
367 
368  // Transform the control points (used for spinning)
370 
371  // Properties used to control the appearance of selected objects and
372  // the manipulator in general.
378 
379  // For efficient spinning
380  double Centroid[3];
383 
384 private:
385  vtkSplineWidget(const vtkSplineWidget&) = delete;
386  void operator=(const vtkSplineWidget&) = delete;
387 };
388 
389 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
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:34
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:62
create a polygonal sphere centered at the origin
3D widget for manipulating a spline
vtkProperty * LineProperty
vtkActor ** Handle
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()
static vtkSplineWidget * New()
Instantiate the object.
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.
double * GetHandlePosition(int handle)
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.
vtkTypeBool Closed
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()
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)
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.
vtkActor * LineActor
~vtkSplineWidget() override
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
@ resolution
Definition: vtkX3D.h:472
@ points
Definition: vtkX3D.h:452
@ position
Definition: vtkX3D.h:267
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_PROJECTION_YZ
#define VTK_PROJECTION_OBLIQUE
#define VTK_SIZEHINT(...)