VTK
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 =========================================================================*/
81 #ifndef vtkSplineWidget_h
82 #define vtkSplineWidget_h
83 
84 #include "vtkInteractionWidgetsModule.h" // For export macro
85 #include "vtk3DWidget.h"
86 
87 class vtkActor;
88 class vtkCellPicker;
91 class vtkPlaneSource;
92 class vtkPoints;
93 class vtkPolyData;
94 class vtkProp;
95 class vtkProperty;
96 class vtkSphereSource;
97 class vtkTransform;
98 
99 #define VTK_PROJECTION_YZ 0
100 #define VTK_PROJECTION_XZ 1
101 #define VTK_PROJECTION_XY 2
102 #define VTK_PROJECTION_OBLIQUE 3
103 
104 class VTKINTERACTIONWIDGETS_EXPORT vtkSplineWidget : public vtk3DWidget
105 {
106 public:
110  static vtkSplineWidget *New();
111 
113  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
114 
116 
119  void SetEnabled(int) VTK_OVERRIDE;
120  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
121  void PlaceWidget() VTK_OVERRIDE
122  {this->Superclass::PlaceWidget();}
123  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
124  double zmin, double zmax) VTK_OVERRIDE
125  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
127 
129 
137  vtkSetMacro(ProjectToPlane,int);
138  vtkGetMacro(ProjectToPlane,int);
139  vtkBooleanMacro(ProjectToPlane,int);
141 
146  void SetPlaneSource(vtkPlaneSource* plane);
147 
148  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
149  vtkGetMacro(ProjectionNormal,int);
151  { this->SetProjectionNormal(0); }
153  { this->SetProjectionNormal(1); }
155  { this->SetProjectionNormal(2); }
157  { 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);
242 
244 
251  void SetClosed(int closed);
252  vtkGetMacro(Closed,int);
253  vtkBooleanMacro(Closed,int);
255 
261  int IsClosed();
262 
268  double GetSummedLength();
269 
276  void InitializeHandles(vtkPoints* points);
277 
279 
283  vtkSetClampMacro(ProcessEvents, int, 0, 1);
284  vtkGetMacro(ProcessEvents, int);
285  vtkBooleanMacro( ProcessEvents, int );
287 
288 protected:
289  vtkSplineWidget();
290  ~vtkSplineWidget() VTK_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(vtkObject* object,
307  unsigned long event,
308  void* clientdata,
309  void* calldata);
310 
311  // ProcessEventsHandler() dispatches to these methods.
312  void OnLeftButtonDown();
313  void OnLeftButtonUp();
314  void OnMiddleButtonDown();
315  void OnMiddleButtonUp();
316  void OnRightButtonDown();
317  void OnRightButtonUp();
318  void OnMouseMove();
319 
320  // Controlling vars
325 
326  // Projection capabilities
327  void ProjectPointsToPlane();
328  void ProjectPointsToOrthoPlane();
329  void ProjectPointsToObliquePlane();
330 
331  // The spline
335  int Closed;
336  void BuildRepresentation();
337 
338  // The line segments
340  void HighlightLine(int highlight);
342 
343  // Glyphs representing hot spots (e.g., handles)
346  void Initialize();
347  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
348  void SizeHandles() VTK_OVERRIDE;
349  void InsertHandleOnLine(double* pos);
350  void EraseHandle(const int&);
351 
352  // Do the picking
353  vtkCellPicker *HandlePicker;
354  vtkCellPicker *LinePicker;
355  vtkActor *CurrentHandle;
356  int CurrentHandleIndex;
357 
358  // Register internal Pickers within PickingManager
359  void RegisterPickers() VTK_OVERRIDE;
360 
361  // Methods to manipulate the spline.
362  void MovePoint(double *p1, double *p2);
363  void Scale(double *p1, double *p2, int X, int Y);
364  void Translate(double *p1, double *p2);
365  void Spin(double *p1, double *p2, double *vpn);
366 
367  // Transform the control points (used for spinning)
369 
370  // Properties used to control the appearance of selected objects and
371  // the manipulator in general.
372  vtkProperty *HandleProperty;
373  vtkProperty *SelectedHandleProperty;
374  vtkProperty *LineProperty;
375  vtkProperty *SelectedLineProperty;
376  void CreateDefaultProperties();
377 
378  // For efficient spinning
379  double Centroid[3];
380  void CalculateCentroid();
381  int ProcessEvents;
382 
383 private:
384  vtkSplineWidget(const vtkSplineWidget&) VTK_DELETE_FUNCTION;
385  void operator=(const vtkSplineWidget&) VTK_DELETE_FUNCTION;
386 };
387 
388 #endif
vtkSphereSource ** HandleGeometry
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
void SetProjectionNormalToOblique()
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:53
vtkActor * LineActor
represent surface properties of a geometric object
Definition: vtkProperty.h:58
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:79
void SetProjectionNormalToZAxes()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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()
3D widget for manipulating a spline
vtkPlaneSource * PlaneSource
#define VTK_PROJECTION_YZ
create an array of quadrilaterals located in a plane
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkActor ** Handle
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
#define VTK_PROJECTION_OBLIQUE
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkParametricSpline * ParametricSpline
Transform
Definition: ADIOSDefs.h:39
tessellate parametric functions