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 =========================================================================*/
93 #ifndef __vtkSplineWidget_h
94 #define __vtkSplineWidget_h
95 
96 #include "vtk3DWidget.h"
97 
98 class vtkActor;
99 class vtkCellPicker;
100 class vtkParametricSpline;
102 class vtkPlaneSource;
103 class vtkPoints;
104 class vtkPolyData;
105 class vtkProp;
106 class vtkProperty;
107 class vtkSphereSource;
108 class vtkTransform;
109 
110 #define VTK_PROJECTION_YZ 0
111 #define VTK_PROJECTION_XZ 1
112 #define VTK_PROJECTION_XY 2
113 #define VTK_PROJECTION_OBLIQUE 3
114 
116 {
117 public:
119  static vtkSplineWidget *New();
120 
122  void PrintSelf(ostream& os, vtkIndent indent);
123 
125 
126  virtual void SetEnabled(int);
127  virtual void PlaceWidget(double bounds[6]);
128  void PlaceWidget()
129  {this->Superclass::PlaceWidget();}
130  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
131  double zmin, double zmax)
132  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
134 
136 
142  vtkSetMacro(ProjectToPlane,int);
143  vtkGetMacro(ProjectToPlane,int);
144  vtkBooleanMacro(ProjectToPlane,int);
146 
149  void SetPlaneSource(vtkPlaneSource* plane);
150 
151  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
152  vtkGetMacro(ProjectionNormal,int);
154  { this->SetProjectionNormal(0); }
156  { this->SetProjectionNormal(1); }
158  { this->SetProjectionNormal(2); }
160  { this->SetProjectionNormal(3); }
161 
163 
168  void SetProjectionPosition(double position);
169  vtkGetMacro(ProjectionPosition, double);
171 
178  void GetPolyData(vtkPolyData *pd);
179 
181 
184  virtual void SetHandleProperty(vtkProperty*);
185  vtkGetObjectMacro(HandleProperty, vtkProperty);
186  virtual void SetSelectedHandleProperty(vtkProperty*);
187  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
189 
191 
193  virtual void SetLineProperty(vtkProperty*);
194  vtkGetObjectMacro(LineProperty, vtkProperty);
195  virtual void SetSelectedLineProperty(vtkProperty*);
196  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
198 
200 
201  virtual void SetNumberOfHandles(int npts);
202  vtkGetMacro(NumberOfHandles, int);
204 
206 
208  void SetResolution(int resolution);
209  vtkGetMacro(Resolution,int);
211 
213 
219  virtual void SetParametricSpline(vtkParametricSpline*);
220  vtkGetObjectMacro(ParametricSpline,vtkParametricSpline);
222 
224 
226  void SetHandlePosition(int handle, double x, double y, double z);
227  void SetHandlePosition(int handle, double xyz[3]);
228  void GetHandlePosition(int handle, double xyz[3]);
229  double* GetHandlePosition(int handle);
231 
233 
238  void SetClosed(int closed);
239  vtkGetMacro(Closed,int);
240  vtkBooleanMacro(Closed,int);
242 
246  int IsClosed();
247 
251  double GetSummedLength();
252 
257  void InitializeHandles(vtkPoints* points);
258 
260 
262  vtkSetClampMacro(ProcessEvents, int, 0, 1);
263  vtkGetMacro(ProcessEvents, int);
264  vtkBooleanMacro( ProcessEvents, int );
266 
267 protected:
268  vtkSplineWidget();
269  ~vtkSplineWidget();
270 
271 //BTX - manage the state of the widget
272  int State;
274  {
275  Start=0,
281  Outside
282  };
283 //ETX
284 
285  //handles the events
286  static void ProcessEventsHandler(vtkObject* object,
287  unsigned long event,
288  void* clientdata,
289  void* calldata);
290 
291  // ProcessEventsHandler() dispatches to these methods.
292  void OnLeftButtonDown();
293  void OnLeftButtonUp();
294  void OnMiddleButtonDown();
295  void OnMiddleButtonUp();
296  void OnRightButtonDown();
297  void OnRightButtonUp();
298  void OnMouseMove();
299 
300  // Controlling vars
305 
306  // Projection capabilities
307  void ProjectPointsToPlane();
308  void ProjectPointsToOrthoPlane();
309  void ProjectPointsToObliquePlane();
310 
311  // The spline
315  int Closed;
316  void BuildRepresentation();
317 
318  // The line segments
320  void HighlightLine(int highlight);
322 
323  // Glyphs representing hot spots (e.g., handles)
326  void Initialize();
327  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
328  virtual void SizeHandles();
329  void InsertHandleOnLine(double* pos);
330  void EraseHandle(const int&);
331 
332  // Do the picking
337 
338  // Methods to manipulate the spline.
339  void MovePoint(double *p1, double *p2);
340  void Scale(double *p1, double *p2, int X, int Y);
341  void Translate(double *p1, double *p2);
342  void Spin(double *p1, double *p2, double *vpn);
343 
344  // Transform the control points (used for spinning)
346 
347  // Properties used to control the appearance of selected objects and
348  // the manipulator in general.
353  void CreateDefaultProperties();
354 
355  // For efficient spinning
356  double Centroid[3];
357  void CalculateCentroid();
359 
360 private:
361  vtkSplineWidget(const vtkSplineWidget&); //Not implemented
362  void operator=(const vtkSplineWidget&); //Not implemented
363 };
364 
365 #endif