VTK
vtkSplineRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSplineRepresentation.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 =========================================================================*/
30 #ifndef __vtkSplineRepresentation_h
31 #define __vtkSplineRepresentation_h
32 
34 
35 class vtkActor;
36 class vtkCellPicker;
37 class vtkDoubleArray;
40 class vtkPlaneSource;
41 class vtkPoints;
42 class vtkPolyData;
43 class vtkProp;
44 class vtkProperty;
45 class vtkSphereSource;
46 class vtkTransform;
47 
48 #define VTK_PROJECTION_YZ 0
49 #define VTK_PROJECTION_XZ 1
50 #define VTK_PROJECTION_XY 2
51 #define VTK_PROJECTION_OBLIQUE 3
53 {
54 public:
55  static vtkSplineRepresentation* New();
57  void PrintSelf(ostream& os, vtkIndent indent);
58 //BTX
59  // Used to manage the InteractionState of the widget
61  Outside=0,
68  Erasing
69  };
70 //ETX
71 
72  vtkSetMacro(InteractionState, int);
73 
75 
82  vtkSetMacro(ProjectToPlane,int);
83  vtkGetMacro(ProjectToPlane,int);
84  vtkBooleanMacro(ProjectToPlane,int);
86 
89  void SetPlaneSource(vtkPlaneSource* plane);
90 
91  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
92  vtkGetMacro(ProjectionNormal,int);
94  { this->SetProjectionNormal(0); }
96  { this->SetProjectionNormal(1); }
98  { this->SetProjectionNormal(2); }
100  { this->SetProjectionNormal(3); }
101 
103 
108  void SetProjectionPosition(double position);
109  vtkGetMacro(ProjectionPosition, double);
111 
118  void GetPolyData(vtkPolyData *pd);
119 
121 
124  vtkGetObjectMacro(HandleProperty, vtkProperty);
125  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
127 
129 
131  vtkGetObjectMacro(LineProperty, vtkProperty);
132  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
134 
136 
137  virtual void SetNumberOfHandles(int npts);
138  vtkGetMacro(NumberOfHandles, int);
140 
142 
144  void SetResolution(int resolution);
145  vtkGetMacro(Resolution,int);
147 
149 
155  virtual void SetParametricSpline(vtkParametricSpline*);
156  vtkGetObjectMacro(ParametricSpline,vtkParametricSpline);
158 
160 
162  void SetHandlePosition(int handle, double x, double y, double z);
163  void SetHandlePosition(int handle, double xyz[3]);
164  void GetHandlePosition(int handle, double xyz[3]);
165  double* GetHandlePosition(int handle);
166  vtkDoubleArray* GetHandlePositions();
168 
170 
175  void SetClosed(int closed);
176  vtkGetMacro(Closed,int);
177  vtkBooleanMacro(Closed,int);
179 
183  int IsClosed();
184 
188  double GetSummedLength();
189 
194  void InitializeHandles(vtkPoints* points);
195 
197 
200  virtual void BuildRepresentation();
201  virtual int ComputeInteractionState(int X, int Y, int modify=0);
202  virtual void StartWidgetInteraction(double e[2]);
203  virtual void WidgetInteraction(double e[2]);
204  virtual void EndWidgetInteraction(double e[2]);
205  virtual double *GetBounds();
207 
209 
210  virtual void ReleaseGraphicsResources(vtkWindow*);
211  virtual int RenderOpaqueGeometry(vtkViewport*);
213  virtual int RenderOverlay(vtkViewport*);
214  virtual int HasTranslucentPolygonalGeometry();
216 
219  void SetLineColor(double r, double g, double b);
220 
221 //BTX
222 protected:
225 
226  double LastEventPosition[3];
227  double Bounds[6];
228 
229  // Controlling vars
234 
235  // Projection capabilities
236  void ProjectPointsToPlane();
237  void ProjectPointsToOrthoPlane();
238  void ProjectPointsToObliquePlane();
239 
240  // The spline
244  int Closed;
245 
246  // The line segments
248  void HighlightLine(int highlight);
250 
251  // Glyphs representing hot spots (e.g., handles)
254  void Initialize();
255  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
256  virtual void SizeHandles();
257  void InsertHandleOnLine(double* pos);
258  void EraseHandle(const int&);
259 
260  // Do the picking
263  double LastPickPosition[3];
266 
267  // Methods to manipulate the spline.
268  void MovePoint(double *p1, double *p2);
269  void Scale(double *p1, double *p2, int X, int Y);
270  void Translate(double *p1, double *p2);
271  void Spin(double *p1, double *p2, double *vpn);
272 
273  // Transform the control points (used for spinning)
275 
276  // Properties used to control the appearance of selected objects and
277  // the manipulator in general.
282  void CreateDefaultProperties();
283 
284  // For efficient spinning
285  double Centroid[3];
286  void CalculateCentroid();
287 
288 private:
289  vtkSplineRepresentation(const vtkSplineRepresentation&); // Not implemented.
290  void operator=(const vtkSplineRepresentation&); // Not implemented.
291 //ETX
292 };
293 
294 #endif
295 
296