VTK  9.0.20201029
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 =========================================================================*/
90 #ifndef vtkSplineWidget_h
91 #define vtkSplineWidget_h
92 
93 #include "vtk3DWidget.h"
94 #include "vtkInteractionWidgetsModule.h" // For export macro
95 
96 class vtkActor;
97 class vtkCellPicker;
100 class vtkPlaneSource;
101 class vtkPoints;
102 class vtkPolyData;
103 class vtkProp;
104 class vtkProperty;
105 class vtkSphereSource;
106 class vtkTransform;
107 
108 #define VTK_PROJECTION_YZ 0
109 #define VTK_PROJECTION_XZ 1
110 #define VTK_PROJECTION_XY 2
111 #define VTK_PROJECTION_OBLIQUE 3
112 
113 class VTKINTERACTIONWIDGETS_EXPORT vtkSplineWidget : public vtk3DWidget
114 {
115 public:
119  static vtkSplineWidget* New();
120 
121  vtkTypeMacro(vtkSplineWidget, vtk3DWidget);
122  void PrintSelf(ostream& os, vtkIndent indent) override;
123 
125 
128  void SetEnabled(int) override;
129  void PlaceWidget(double bounds[6]) override;
130  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
132  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
133  {
134  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
135  }
137 
139 
147  vtkSetMacro(ProjectToPlane, vtkTypeBool);
148  vtkGetMacro(ProjectToPlane, vtkTypeBool);
149  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
151 
156  void SetPlaneSource(vtkPlaneSource* plane);
157 
158  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
159  vtkGetMacro(ProjectionNormal, int);
160  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
161  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
162  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
163  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
164 
166 
173  void SetProjectionPosition(double position);
174  vtkGetMacro(ProjectionPosition, double);
176 
184  void GetPolyData(vtkPolyData* pd);
185 
187 
191  virtual void SetHandleProperty(vtkProperty*);
192  vtkGetObjectMacro(HandleProperty, vtkProperty);
193  virtual void SetSelectedHandleProperty(vtkProperty*);
194  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
196 
198 
202  virtual void SetLineProperty(vtkProperty*);
203  vtkGetObjectMacro(LineProperty, vtkProperty);
204  virtual void SetSelectedLineProperty(vtkProperty*);
205  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
207 
209 
212  virtual void SetNumberOfHandles(int npts);
213  vtkGetMacro(NumberOfHandles, int);
215 
217 
221  void SetResolution(int resolution);
222  vtkGetMacro(Resolution, int);
224 
226 
234  virtual void SetParametricSpline(vtkParametricSpline*);
235  vtkGetObjectMacro(ParametricSpline, vtkParametricSpline);
237 
239 
243  void SetHandlePosition(int handle, double x, double y, double z);
244  void SetHandlePosition(int handle, double xyz[3]);
245  void GetHandlePosition(int handle, double xyz[3]);
246  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
248 
250 
257  void SetClosed(vtkTypeBool closed);
258  vtkGetMacro(Closed, vtkTypeBool);
259  vtkBooleanMacro(Closed, vtkTypeBool);
261 
267  int IsClosed();
268 
274  double GetSummedLength();
275 
282  void InitializeHandles(vtkPoints* points);
283 
285 
289  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
290  vtkGetMacro(ProcessEvents, vtkTypeBool);
291  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
293 
294 protected:
295  vtkSplineWidget();
296  ~vtkSplineWidget() override;
297 
298  // Manage the state of the widget
299  int State;
301  {
302  Start = 0,
308  Outside
309  };
310 
311  // handles the events
312  static void ProcessEventsHandler(
313  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
314 
315  // ProcessEventsHandler() dispatches to these methods.
316  void OnLeftButtonDown();
317  void OnLeftButtonUp();
318  void OnMiddleButtonDown();
319  void OnMiddleButtonUp();
320  void OnRightButtonDown();
321  void OnRightButtonUp();
322  void OnMouseMove();
323 
324  // Controlling vars
329 
330  // Projection capabilities
331  void ProjectPointsToPlane();
332  void ProjectPointsToOrthoPlane();
333  void ProjectPointsToObliquePlane();
334 
335  // The spline
340  void BuildRepresentation();
341 
342  // The line segments
344  void HighlightLine(int highlight);
346 
347  // Glyphs representing hot spots (e.g., handles)
350  void Initialize();
351  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
352  void SizeHandles() override;
353  void InsertHandleOnLine(double* pos);
354  void EraseHandle(const int&);
355 
356  // Do the picking
361 
362  // Register internal Pickers within PickingManager
363  void RegisterPickers() override;
364 
365  // Methods to manipulate the spline.
366  void MovePoint(double* p1, double* p2);
367  void Scale(double* p1, double* p2, int X, int Y);
368  void Translate(double* p1, double* p2);
369  void Spin(double* p1, double* p2, double* vpn);
370 
371  // Transform the control points (used for spinning)
373 
374  // Properties used to control the appearance of selected objects and
375  // the manipulator in general.
380  void CreateDefaultProperties();
381 
382  // For efficient spinning
383  double Centroid[3];
384  void CalculateCentroid();
386 
387 private:
388  vtkSplineWidget(const vtkSplineWidget&) = delete;
389  void operator=(const vtkSplineWidget&) = delete;
390 };
391 
392 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkSplineWidget::Scaling
Definition: vtkSplineWidget.h:304
vtkSplineWidget::CurrentHandleIndex
int CurrentHandleIndex
Definition: vtkSplineWidget.h:360
vtkSplineWidget::PlaneSource
vtkPlaneSource * PlaneSource
Definition: vtkSplineWidget.h:328
vtkSplineWidget::Inserting
Definition: vtkSplineWidget.h:306
vtkParametricFunctionSource
tessellate parametric functions
Definition: vtkParametricFunctionSource.h:56
vtkSplineWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkSplineWidget.h:130
vtkX3D::resolution
Definition: vtkX3D.h:472
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkSplineWidget::LinePicker
vtkCellPicker * LinePicker
Definition: vtkSplineWidget.h:358
vtkPlaneSource
create an array of quadrilaterals located in a plane
Definition: vtkPlaneSource.h:54
vtkSplineWidget::SetProjectionNormalToYAxes
void SetProjectionNormalToYAxes()
Definition: vtkSplineWidget.h:161
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkSplineWidget::ParametricFunctionSource
vtkParametricFunctionSource * ParametricFunctionSource
Definition: vtkSplineWidget.h:337
vtk3DWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSplineWidget::Spinning
Definition: vtkSplineWidget.h:305
vtkSplineWidget::WidgetState
WidgetState
Definition: vtkSplineWidget.h:300
vtkSplineWidget::NumberOfHandles
int NumberOfHandles
Definition: vtkSplineWidget.h:338
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkSplineWidget::Closed
vtkTypeBool Closed
Definition: vtkSplineWidget.h:339
vtkParametricSpline
parametric function for 1D interpolating splines
Definition: vtkParametricSpline.h:47
vtkSplineWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkSplineWidget.h:377
vtkX3D::position
Definition: vtkX3D.h:267
vtkX3D::points
Definition: vtkX3D.h:452
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkSplineWidget::Handle
vtkActor ** Handle
Definition: vtkSplineWidget.h:348
vtkSplineWidget::Moving
Definition: vtkSplineWidget.h:303
vtkSplineWidget::LineActor
vtkActor * LineActor
Definition: vtkSplineWidget.h:343
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:41
vtkSplineWidget::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkSplineWidget.h:379
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:79
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSplineWidget::Erasing
Definition: vtkSplineWidget.h:307
vtkSplineWidget::ProcessEvents
vtkTypeBool ProcessEvents
Definition: vtkSplineWidget.h:385
vtkSplineWidget::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkSplineWidget.h:349
vtkSplineWidget::SetProjectionNormalToXAxes
void SetProjectionNormalToXAxes()
Definition: vtkSplineWidget.h:160
vtkSplineWidget::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkSplineWidget.h:359
vtkSplineWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkSplineWidget.h:376
vtkSplineWidget::LineProperty
vtkProperty * LineProperty
Definition: vtkSplineWidget.h:378
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:70
VTK_PROJECTION_OBLIQUE
#define VTK_PROJECTION_OBLIQUE
Definition: vtkSplineWidget.h:111
vtkSplineWidget::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkSplineWidget.h:357
vtkSplineWidget::ParametricSpline
vtkParametricSpline * ParametricSpline
Definition: vtkSplineWidget.h:336
vtkSplineWidget::State
int State
Definition: vtkSplineWidget.h:299
vtkSplineWidget::SetProjectionNormalToZAxes
void SetProjectionNormalToZAxes()
Definition: vtkSplineWidget.h:162
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkSplineWidget::ProjectToPlane
vtkTypeBool ProjectToPlane
Definition: vtkSplineWidget.h:327
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkSplineWidget
3D widget for manipulating a spline
Definition: vtkSplineWidget.h:113
vtkSplineWidget::Resolution
int Resolution
Definition: vtkSplineWidget.h:345
vtk3DWidget::SizeHandles
virtual void SizeHandles()
Definition: vtk3DWidget.h:155
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkSplineWidget::Transform
vtkTransform * Transform
Definition: vtkSplineWidget.h:372
VTK_PROJECTION_YZ
#define VTK_PROJECTION_YZ
Definition: vtkSplineWidget.h:108
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkSplineWidget::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkSplineWidget.h:163
vtkSplineWidget::ProjectionPosition
double ProjectionPosition
Definition: vtkSplineWidget.h:326
vtkSplineWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Definition: vtkSplineWidget.h:131
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkSplineWidget::ProjectionNormal
int ProjectionNormal
Definition: vtkSplineWidget.h:325
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69