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 =========================================================================*/
89 #ifndef vtkSplineWidget_h
90 #define vtkSplineWidget_h
91 
92 #include "vtkInteractionWidgetsModule.h" // For export macro
93 #include "vtk3DWidget.h"
94 
95 class vtkActor;
96 class vtkCellPicker;
99 class vtkPlaneSource;
100 class vtkPoints;
101 class vtkPolyData;
102 class vtkProp;
103 class vtkProperty;
104 class vtkSphereSource;
105 class vtkTransform;
106 
107 #define VTK_PROJECTION_YZ 0
108 #define VTK_PROJECTION_XZ 1
109 #define VTK_PROJECTION_XY 2
110 #define VTK_PROJECTION_OBLIQUE 3
111 
113 {
114 public:
116  static vtkSplineWidget *New();
117 
119  void PrintSelf(ostream& os, vtkIndent indent);
120 
122 
123  virtual void SetEnabled(int);
124  virtual void PlaceWidget(double bounds[6]);
125  void PlaceWidget()
126  {this->Superclass::PlaceWidget();}
127  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
128  double zmin, double zmax)
129  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
131 
133 
139  vtkSetMacro(ProjectToPlane,int);
140  vtkGetMacro(ProjectToPlane,int);
141  vtkBooleanMacro(ProjectToPlane,int);
143 
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 
165  void SetProjectionPosition(double position);
166  vtkGetMacro(ProjectionPosition, double);
168 
175  void GetPolyData(vtkPolyData *pd);
176 
178 
181  virtual void SetHandleProperty(vtkProperty*);
182  vtkGetObjectMacro(HandleProperty, vtkProperty);
183  virtual void SetSelectedHandleProperty(vtkProperty*);
184  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
186 
188 
190  virtual void SetLineProperty(vtkProperty*);
191  vtkGetObjectMacro(LineProperty, vtkProperty);
192  virtual void SetSelectedLineProperty(vtkProperty*);
193  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
195 
197 
198  virtual void SetNumberOfHandles(int npts);
199  vtkGetMacro(NumberOfHandles, int);
201 
203 
205  void SetResolution(int resolution);
206  vtkGetMacro(Resolution,int);
208 
210 
216  virtual void SetParametricSpline(vtkParametricSpline*);
217  vtkGetObjectMacro(ParametricSpline,vtkParametricSpline);
219 
221 
223  void SetHandlePosition(int handle, double x, double y, double z);
224  void SetHandlePosition(int handle, double xyz[3]);
225  void GetHandlePosition(int handle, double xyz[3]);
226  double* GetHandlePosition(int handle);
228 
230 
235  void SetClosed(int closed);
236  vtkGetMacro(Closed,int);
237  vtkBooleanMacro(Closed,int);
239 
243  int IsClosed();
244 
248  double GetSummedLength();
249 
254  void InitializeHandles(vtkPoints* points);
255 
257 
259  vtkSetClampMacro(ProcessEvents, int, 0, 1);
260  vtkGetMacro(ProcessEvents, int);
261  vtkBooleanMacro( ProcessEvents, int );
263 
264 protected:
265  vtkSplineWidget();
266  ~vtkSplineWidget();
267 
268  // Manage the state of the widget
269  int State;
271  {
272  Start=0,
278  Outside
279  };
280 
281  //handles the events
282  static void ProcessEventsHandler(vtkObject* object,
283  unsigned long event,
284  void* clientdata,
285  void* calldata);
286 
287  // ProcessEventsHandler() dispatches to these methods.
288  void OnLeftButtonDown();
289  void OnLeftButtonUp();
290  void OnMiddleButtonDown();
291  void OnMiddleButtonUp();
292  void OnRightButtonDown();
293  void OnRightButtonUp();
294  void OnMouseMove();
295 
296  // Controlling vars
301 
302  // Projection capabilities
303  void ProjectPointsToPlane();
304  void ProjectPointsToOrthoPlane();
305  void ProjectPointsToObliquePlane();
306 
307  // The spline
311  int Closed;
312  void BuildRepresentation();
313 
314  // The line segments
316  void HighlightLine(int highlight);
318 
319  // Glyphs representing hot spots (e.g., handles)
322  void Initialize();
323  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
324  virtual void SizeHandles();
325  void InsertHandleOnLine(double* pos);
326  void EraseHandle(const int&);
327 
328  // Do the picking
333 
334  // Register internal Pickers within PickingManager
335  virtual void RegisterPickers();
336 
337  // Methods to manipulate the spline.
338  void MovePoint(double *p1, double *p2);
339  void Scale(double *p1, double *p2, int X, int Y);
340  void Translate(double *p1, double *p2);
341  void Spin(double *p1, double *p2, double *vpn);
342 
343  // Transform the control points (used for spinning)
345 
346  // Properties used to control the appearance of selected objects and
347  // the manipulator in general.
352  void CreateDefaultProperties();
353 
354  // For efficient spinning
355  double Centroid[3];
356  void CalculateCentroid();
358 
359 private:
360  vtkSplineWidget(const vtkSplineWidget&); //Not implemented
361  void operator=(const vtkSplineWidget&); //Not implemented
362 };
363 
364 #endif
vtkSphereSource ** HandleGeometry
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkProperty * SelectedHandleProperty
void SetProjectionNormalToOblique()
vtkParametricFunctionSource * ParametricFunctionSource
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkActor * LineActor
represent surface properties of a geometric object
Definition: vtkProperty.h:63
void SetProjectionNormalToXAxes()
virtual void SetEnabled(int)
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
void SetProjectionNormalToZAxes()
vtkProperty * LineProperty
virtual void RegisterPickers()
vtkTransform * Transform
#define VTKINTERACTIONWIDGETS_EXPORT
create a polygonal sphere centered at the origin
parametric function for 1D interpolating splines
a simple class to control print indentation
Definition: vtkIndent.h:38
void SetProjectionNormalToYAxes()
vtkProperty * HandleProperty
vtkCellPicker * LinePicker
3D widget for manipulating a spline
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
vtkActor * CurrentHandle
vtkPlaneSource * PlaneSource
#define VTK_PROJECTION_YZ
create an array of quadrilaterals located in a plane
vtkActor ** Handle
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
vtkCellPicker * HandlePicker
static vtkObject * New()
vtkProperty * SelectedLineProperty
#define VTK_PROJECTION_OBLIQUE
void PrintSelf(ostream &os, vtkIndent indent)
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:69
virtual void SizeHandles()
Definition: vtk3DWidget.h:145
virtual void PlaceWidget()
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkParametricSpline * ParametricSpline
tessellate parametric functions