VTK  9.0.1
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 =========================================================================*/
84 #ifndef vtkSplineWidget_h
85 #define vtkSplineWidget_h
86 
87 #include "vtk3DWidget.h"
88 #include "vtkInteractionWidgetsModule.h" // For export macro
89 
90 class vtkActor;
91 class vtkCellPicker;
94 class vtkPlaneSource;
95 class vtkPoints;
96 class vtkPolyData;
97 class vtkProp;
98 class vtkProperty;
99 class vtkSphereSource;
100 class vtkTransform;
101 
102 #define VTK_PROJECTION_YZ 0
103 #define VTK_PROJECTION_XZ 1
104 #define VTK_PROJECTION_XY 2
105 #define VTK_PROJECTION_OBLIQUE 3
106 
107 class VTKINTERACTIONWIDGETS_EXPORT vtkSplineWidget : public vtk3DWidget
108 {
109 public:
113  static vtkSplineWidget* New();
114 
115  vtkTypeMacro(vtkSplineWidget, vtk3DWidget);
116  void PrintSelf(ostream& os, vtkIndent indent) override;
117 
119 
122  void SetEnabled(int) override;
123  void PlaceWidget(double bounds[6]) override;
124  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
126  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
127  {
128  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
129  }
131 
133 
141  vtkSetMacro(ProjectToPlane, vtkTypeBool);
142  vtkGetMacro(ProjectToPlane, vtkTypeBool);
143  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
145 
150  void SetPlaneSource(vtkPlaneSource* plane);
151 
152  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
153  vtkGetMacro(ProjectionNormal, int);
154  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
155  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
156  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
157  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
158 
160 
167  void SetProjectionPosition(double position);
168  vtkGetMacro(ProjectionPosition, double);
170 
178  void GetPolyData(vtkPolyData* pd);
179 
181 
185  virtual void SetHandleProperty(vtkProperty*);
186  vtkGetObjectMacro(HandleProperty, vtkProperty);
187  virtual void SetSelectedHandleProperty(vtkProperty*);
188  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
190 
192 
196  virtual void SetLineProperty(vtkProperty*);
197  vtkGetObjectMacro(LineProperty, vtkProperty);
198  virtual void SetSelectedLineProperty(vtkProperty*);
199  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
201 
203 
206  virtual void SetNumberOfHandles(int npts);
207  vtkGetMacro(NumberOfHandles, int);
209 
211 
215  void SetResolution(int resolution);
216  vtkGetMacro(Resolution, int);
218 
220 
228  virtual void SetParametricSpline(vtkParametricSpline*);
229  vtkGetObjectMacro(ParametricSpline, vtkParametricSpline);
231 
233 
237  void SetHandlePosition(int handle, double x, double y, double z);
238  void SetHandlePosition(int handle, double xyz[3]);
239  void GetHandlePosition(int handle, double xyz[3]);
240  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
242 
244 
251  void SetClosed(vtkTypeBool closed);
252  vtkGetMacro(Closed, vtkTypeBool);
253  vtkBooleanMacro(Closed, vtkTypeBool);
255 
261  int IsClosed();
262 
268  double GetSummedLength();
269 
276  void InitializeHandles(vtkPoints* points);
277 
279 
283  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
284  vtkGetMacro(ProcessEvents, vtkTypeBool);
285  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
287 
288 protected:
289  vtkSplineWidget();
290  ~vtkSplineWidget() override;
291 
292  // Manage the state of the widget
293  int State;
295  {
296  Start = 0,
302  Outside
303  };
304 
305  // handles the events
306  static void ProcessEventsHandler(
307  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
308 
309  // ProcessEventsHandler() dispatches to these methods.
310  void OnLeftButtonDown();
311  void OnLeftButtonUp();
312  void OnMiddleButtonDown();
313  void OnMiddleButtonUp();
314  void OnRightButtonDown();
315  void OnRightButtonUp();
316  void OnMouseMove();
317 
318  // Controlling vars
323 
324  // Projection capabilities
325  void ProjectPointsToPlane();
326  void ProjectPointsToOrthoPlane();
327  void ProjectPointsToObliquePlane();
328 
329  // The spline
334  void BuildRepresentation();
335 
336  // The line segments
338  void HighlightLine(int highlight);
340 
341  // Glyphs representing hot spots (e.g., handles)
344  void Initialize();
345  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
346  void SizeHandles() override;
347  void InsertHandleOnLine(double* pos);
348  void EraseHandle(const int&);
349 
350  // Do the picking
355 
356  // Register internal Pickers within PickingManager
357  void RegisterPickers() override;
358 
359  // Methods to manipulate the spline.
360  void MovePoint(double* p1, double* p2);
361  void Scale(double* p1, double* p2, int X, int Y);
362  void Translate(double* p1, double* p2);
363  void Spin(double* p1, double* p2, double* vpn);
364 
365  // Transform the control points (used for spinning)
367 
368  // Properties used to control the appearance of selected objects and
369  // the manipulator in general.
374  void CreateDefaultProperties();
375 
376  // For efficient spinning
377  double Centroid[3];
378  void CalculateCentroid();
380 
381 private:
382  vtkSplineWidget(const vtkSplineWidget&) = delete;
383  void operator=(const vtkSplineWidget&) = delete;
384 };
385 
386 #endif
vtkSphereSource ** HandleGeometry
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkProperty * SelectedHandleProperty
void SetProjectionNormalToOblique()
vtkTypeBool ProjectToPlane
vtkParametricFunctionSource * ParametricFunctionSource
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:56
vtkActor * LineActor
represent surface properties of a geometric object
Definition: vtkProperty.h:61
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:54
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
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:33
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:66
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:33
vtkParametricSpline * ParametricSpline
tessellate parametric functions