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
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 
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*);
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
249  void HighlightLine(int highlight);
251 
252  // Glyphs representing hot spots (e.g., handles)
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
264  double LastPickPosition[3];
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.
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 
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
vtkWidgetRepresentation for a spline.
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
GLboolean GLboolean GLboolean b
Definition: vtkgl.h:12312
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:63
virtual void StartWidgetInteraction(double eventPos[2])
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
#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:83
#define VTK_PROJECTION_YZ
GLdouble GLdouble GLdouble r
Definition: vtkgl.h:11610
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract class defines interface between the widget and widget representation classes ...
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
virtual void BuildRepresentation()=0
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
dynamic, self-adjusting array of double
GLdouble GLdouble z
Definition: vtkgl.h:11754
window superclass for vtkRenderWindow
Definition: vtkWindow.h:33
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
#define VTKINTERACTIONWIDGETS_EXPORT
create a polygonal sphere centered at the origin
parametric function for 1D interpolating splines
virtual int HasTranslucentPolygonalGeometry()
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void RegisterPickers()
virtual void WidgetInteraction(double newEventPos[2])
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
create an array of quadrilaterals located in a plane
vtkParametricFunctionSource * ParametricFunctionSource
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
GLsizei const GLfloat * points
Definition: vtkgl.h:14786
GLboolean GLboolean g
Definition: vtkgl.h:12312
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
void PrintSelf(ostream &os, vtkIndent indent)
vtkParametricSpline * ParametricSpline
static vtkObject * New()
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
represent and manipulate 3D points
Definition: vtkPoints.h:39
tessellate parametric functions
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69