VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
33 #include "vtkInteractionWidgetsModule.h" // For export macro
35 
36 class vtkActor;
37 class vtkCellPicker;
38 class vtkDoubleArray;
41 class vtkPlaneSource;
42 class vtkPoints;
43 class vtkPolyData;
44 class vtkProp;
45 class vtkProperty;
46 class vtkSphereSource;
47 class vtkTransform;
48 
49 #define VTK_PROJECTION_YZ 0
50 #define VTK_PROJECTION_XZ 1
51 #define VTK_PROJECTION_XY 2
52 #define VTK_PROJECTION_OBLIQUE 3
53 class VTKINTERACTIONWIDGETS_EXPORT vtkSplineRepresentation : public vtkWidgetRepresentation
54 {
55 public:
56  static vtkSplineRepresentation* New();
58  void PrintSelf(ostream& os, vtkIndent indent);
59 //BTX
60  // Used to manage the InteractionState of the widget
62  Outside=0,
69  Erasing
70  };
71 //ETX
72 
73  vtkSetMacro(InteractionState, int);
74 
76 
83  vtkSetMacro(ProjectToPlane,int);
84  vtkGetMacro(ProjectToPlane,int);
85  vtkBooleanMacro(ProjectToPlane,int);
87 
90  void SetPlaneSource(vtkPlaneSource* plane);
91 
92  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
93  vtkGetMacro(ProjectionNormal,int);
95  { this->SetProjectionNormal(0); }
97  { this->SetProjectionNormal(1); }
99  { this->SetProjectionNormal(2); }
101  { this->SetProjectionNormal(3); }
102 
104 
109  void SetProjectionPosition(double position);
110  vtkGetMacro(ProjectionPosition, double);
112 
119  void GetPolyData(vtkPolyData *pd);
120 
122 
125  vtkGetObjectMacro(HandleProperty, vtkProperty);
126  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
128 
130 
132  vtkGetObjectMacro(LineProperty, vtkProperty);
133  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
135 
137 
138  virtual void SetNumberOfHandles(int npts);
139  vtkGetMacro(NumberOfHandles, int);
141 
143 
145  void SetResolution(int resolution);
146  vtkGetMacro(Resolution,int);
148 
150 
156  virtual void SetParametricSpline(vtkParametricSpline*);
157  vtkGetObjectMacro(ParametricSpline,vtkParametricSpline);
159 
161 
163  void SetHandlePosition(int handle, double x, double y, double z);
164  void SetHandlePosition(int handle, double xyz[3]);
165  void GetHandlePosition(int handle, double xyz[3]);
166  double* GetHandlePosition(int handle);
167  vtkDoubleArray* GetHandlePositions();
169 
171 
176  void SetClosed(int closed);
177  vtkGetMacro(Closed,int);
178  vtkBooleanMacro(Closed,int);
180 
184  int IsClosed();
185 
189  double GetSummedLength();
190 
195  void InitializeHandles(vtkPoints* points);
196 
198 
201  virtual void BuildRepresentation();
202  virtual int ComputeInteractionState(int X, int Y, int modify=0);
203  virtual void StartWidgetInteraction(double e[2]);
204  virtual void WidgetInteraction(double e[2]);
205  virtual void EndWidgetInteraction(double e[2]);
206  virtual double *GetBounds();
208 
210 
211  virtual void ReleaseGraphicsResources(vtkWindow*);
212  virtual int RenderOpaqueGeometry(vtkViewport*);
213  virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
214  virtual int RenderOverlay(vtkViewport*);
215  virtual int HasTranslucentPolygonalGeometry();
217 
220  void SetLineColor(double r, double g, double b);
221 
222 //BTX
223 protected:
226 
227  double LastEventPosition[3];
228  double Bounds[6];
229 
230  // Controlling vars
235 
236  // Projection capabilities
237  void ProjectPointsToPlane();
238  void ProjectPointsToOrthoPlane();
239  void ProjectPointsToObliquePlane();
240 
241  // The spline
245  int Closed;
246 
247  // The line segments
248  vtkActor *LineActor;
249  void HighlightLine(int highlight);
251 
252  // Glyphs representing hot spots (e.g., handles)
253  vtkActor **Handle;
255  void Initialize();
256  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
257  virtual void SizeHandles();
258  void InsertHandleOnLine(double* pos);
259  void EraseHandle(const int&);
260 
261  // Do the picking
262  vtkCellPicker *HandlePicker;
263  vtkCellPicker *LinePicker;
264  double LastPickPosition[3];
265  vtkActor *CurrentHandle;
267 
268  // Register internal Pickers within PickingManager
269  virtual void RegisterPickers();
270 
271  // Methods to manipulate the spline.
272  void MovePoint(double *p1, double *p2);
273  void Scale(double *p1, double *p2, int X, int Y);
274  void Translate(double *p1, double *p2);
275  void Spin(double *p1, double *p2, double *vpn);
276 
277  // Transform the control points (used for spinning)
279 
280  // Properties used to control the appearance of selected objects and
281  // the manipulator in general.
282  vtkProperty *HandleProperty;
284  vtkProperty *LineProperty;
285  vtkProperty *SelectedLineProperty;
286  void CreateDefaultProperties();
287 
288  // For efficient spinning
289  double Centroid[3];
290  void CalculateCentroid();
291 
292 private:
293  vtkSplineRepresentation(const vtkSplineRepresentation&); // Not implemented.
294  void operator=(const vtkSplineRepresentation&); // Not implemented.
295 //ETX
296 };
297 
298 #endif
299 
300 
vtkWidgetRepresentation for a spline.
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
virtual void EndWidgetInteraction(double newEventPos[2])
virtual int ComputeInteractionState(int X, int Y, int modify=0)
virtual void StartWidgetInteraction(double eventPos[2])
#define VTK_PROJECTION_OBLIQUE
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:82
#define VTK_PROJECTION_YZ
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
create a polygonal sphere centered at the origin
parametric function for 1D interpolating splines
virtual int HasTranslucentPolygonalGeometry()
virtual void RegisterPickers()
virtual void WidgetInteraction(double newEventPos[2])
create an array of quadrilaterals located in a plane
vtkParametricFunctionSource * ParametricFunctionSource
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
void PrintSelf(ostream &os, vtkIndent indent)
vtkParametricSpline * ParametricSpline
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
tessellate parametric functions