VTK  9.2.6
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 
153  void SetPlaneSource(vtkPlaneSource* plane);
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 
170  void SetProjectionPosition(double position);
171  vtkGetMacro(ProjectionPosition, double);
173 
181  void GetPolyData(vtkPolyData* pd);
182 
184 
188  virtual void SetHandleProperty(vtkProperty*);
189  vtkGetObjectMacro(HandleProperty, vtkProperty);
190  virtual void SetSelectedHandleProperty(vtkProperty*);
191  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
193 
195 
199  virtual void SetLineProperty(vtkProperty*);
200  vtkGetObjectMacro(LineProperty, vtkProperty);
201  virtual void SetSelectedLineProperty(vtkProperty*);
202  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
204 
206 
209  virtual void SetNumberOfHandles(int npts);
210  vtkGetMacro(NumberOfHandles, int);
212 
214 
218  void SetResolution(int resolution);
219  vtkGetMacro(Resolution, int);
221 
223 
231  virtual void SetParametricSpline(vtkParametricSpline*);
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 
279  void InitializeHandles(vtkPoints* points);
280 
282 
286  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
287  vtkGetMacro(ProcessEvents, vtkTypeBool);
288  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
290 
291 protected:
292  vtkSplineWidget();
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.
313  void OnLeftButtonDown();
314  void OnLeftButtonUp();
315  void OnMiddleButtonDown();
316  void OnMiddleButtonUp();
317  void OnRightButtonDown();
318  void OnRightButtonUp();
319  void OnMouseMove();
320 
321  // Controlling vars
326 
327  // Projection capabilities
328  void ProjectPointsToPlane();
329  void ProjectPointsToOrthoPlane();
330  void ProjectPointsToObliquePlane();
331 
332  // The spline
337  void BuildRepresentation();
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.
377  void CreateDefaultProperties();
378 
379  // For efficient spinning
380  double Centroid[3];
381  void CalculateCentroid();
383 
384 private:
385  vtkSplineWidget(const vtkSplineWidget&) = delete;
386  void operator=(const vtkSplineWidget&) = delete;
387 };
388 
389 #endif
vtkSphereSource ** HandleGeometry
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkProperty * SelectedHandleProperty
void SetProjectionNormalToOblique()
vtkTypeBool ProjectToPlane
vtkParametricFunctionSource * ParametricFunctionSource
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkActor * LineActor
represent surface properties of a geometric object
Definition: vtkProperty.h:67
void PlaceWidget() override
Methods that satisfy the superclass' API.
void SetProjectionNormalToXAxes()
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
void SetProjectionNormalToZAxes()
vtkTypeBool Closed
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkProperty * LineProperty
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkTransform * Transform
int vtkTypeBool
Definition: vtkABI.h:69
create a polygonal sphere centered at the origin
parametric function for 1D interpolating splines
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetProjectionNormalToYAxes()
vtkProperty * HandleProperty
vtkCellPicker * LinePicker
3D widget for manipulating a spline
vtkActor * CurrentHandle
vtkPlaneSource * PlaneSource
#define VTK_PROJECTION_YZ
#define VTK_SIZEHINT(...)
create an array of quadrilaterals located in a plane
vtkActor ** Handle
vtkTypeBool ProcessEvents
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:72
vtkCellPicker * HandlePicker
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkProperty * SelectedLineProperty
#define VTK_PROJECTION_OBLIQUE
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:70
virtual void SizeHandles()
Definition: vtk3DWidget.h:155
virtual void PlaceWidget()
This method is used to initially place the widget.
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkParametricSpline * ParametricSpline
tessellate parametric functions