VTK
vtkCurveRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCurveRepresentation
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 =========================================================================*/
27 #ifndef vtkCurveRepresentation_h
28 #define vtkCurveRepresentation_h
29 
30 #include "vtkInteractionWidgetsModule.h" // For export macro
32 
33 class vtkActor;
34 class vtkCellPicker;
35 class vtkDoubleArray;
36 class vtkPlaneSource;
37 class vtkPoints;
38 class vtkPolyData;
39 class vtkProp;
40 class vtkProperty;
41 class vtkSphereSource;
42 class vtkTransform;
43 
44 #define VTK_PROJECTION_YZ 0
45 #define VTK_PROJECTION_XZ 1
46 #define VTK_PROJECTION_XY 2
47 #define VTK_PROJECTION_OBLIQUE 3
49 {
50 public:
52  void PrintSelf(ostream& os, vtkIndent indent);
53 //BTX
54  // Used to manage the InteractionState of the widget
56  Outside=0,
63  Erasing
64  };
65 //ETX
66 
68 
69  vtkSetMacro(InteractionState, int);
71 
73 
79  vtkSetMacro(ProjectToPlane,int);
80  vtkGetMacro(ProjectToPlane,int);
81  vtkBooleanMacro(ProjectToPlane,int);
83 
86  void SetPlaneSource(vtkPlaneSource* plane);
87 
88  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
89  vtkGetMacro(ProjectionNormal,int);
91  { this->SetProjectionNormal(0); }
93  { this->SetProjectionNormal(1); }
95  { this->SetProjectionNormal(2); }
97  { this->SetProjectionNormal(3); }
98 
100 
105  void SetProjectionPosition(double position);
106  vtkGetMacro(ProjectionPosition, double);
108 
113  virtual void GetPolyData(vtkPolyData *pd) = 0;
114 
116 
119  vtkGetObjectMacro(HandleProperty, vtkProperty);
120  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
122 
124 
126  vtkGetObjectMacro(LineProperty, vtkProperty);
127  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
129 
131 
132  virtual void SetNumberOfHandles(int npts) = 0;
133  vtkGetMacro(NumberOfHandles, int);
135 
137 
139  virtual void SetHandlePosition(int handle, double x, double y, double z);
140  virtual void SetHandlePosition(int handle, double xyz[3]);
141  virtual void GetHandlePosition(int handle, double xyz[3]);
142  virtual double* GetHandlePosition(int handle);
143  virtual vtkDoubleArray* GetHandlePositions() = 0;
145 
147 
150  void SetClosed(int closed);
151  vtkGetMacro(Closed,int);
152  vtkBooleanMacro(Closed,int);
154 
158  int IsClosed();
159 
163  virtual double GetSummedLength() = 0;
164 
169  virtual void InitializeHandles(vtkPoints* points) = 0;
170 
172 
175  virtual void BuildRepresentation() = 0;
176  virtual int ComputeInteractionState(int X, int Y, int modify=0);
177  virtual void StartWidgetInteraction(double e[2]);
178  virtual void WidgetInteraction(double e[2]);
179  virtual void EndWidgetInteraction(double e[2]);
180  virtual double *GetBounds();
182 
184 
185  virtual void ReleaseGraphicsResources(vtkWindow*);
186  virtual int RenderOpaqueGeometry(vtkViewport*);
188  virtual int RenderOverlay(vtkViewport*);
189  virtual int HasTranslucentPolygonalGeometry();
191 
194  void SetLineColor(double r, double g, double b);
195 
196 //BTX
197 protected:
200 
201  double LastEventPosition[3];
202  double Bounds[6];
203 
204  // Controlling vars
209 
210  // Projection capabilities
211  void ProjectPointsToPlane();
212  void ProjectPointsToOrthoPlane();
213  void ProjectPointsToObliquePlane();
214 
216  int Closed;
217 
218  // The line segments
220  void HighlightLine(int highlight);
221 
222  // Glyphs representing hot spots (e.g., handles)
225  void Initialize();
226  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
227  virtual void SizeHandles();
228  virtual void InsertHandleOnLine(double* pos) = 0;
229  void EraseHandle(const int&);
230 
231  // Do the picking
234  double LastPickPosition[3];
237 
238  // Register internal Pickers within PickingManager
239  virtual void RegisterPickers();
240 
241  // Methods to manipulate the curve.
242  void MovePoint(double *p1, double *p2);
243  void Scale(double *p1, double *p2, int X, int Y);
244  void Translate(double *p1, double *p2);
245  void Spin(double *p1, double *p2, double *vpn);
246 
247  // Transform the control points (used for spinning)
249 
250  // Properties used to control the appearance of selected objects and
251  // the manipulator in general.
256  void CreateDefaultProperties();
257 
258  // For efficient spinning
259  double Centroid[3];
260  void CalculateCentroid();
261 
262 private:
263  vtkCurveRepresentation(const vtkCurveRepresentation&); // Not implemented.
264  void operator=(const vtkCurveRepresentation&); // Not implemented.
265 //ETX
266 };
267 
268 
269 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkWidgetRepresentation base class for a widget that represents an curve that connects control points...
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
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])
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
dynamic, self-adjusting array of double
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
#define VTKINTERACTIONWIDGETS_EXPORT
create a polygonal sphere centered at the origin
virtual int HasTranslucentPolygonalGeometry()
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void RegisterPickers()
virtual void WidgetInteraction(double newEventPos[2])
create an array of quadrilaterals located in a plane
vtkSphereSource ** HandleGeometry
#define VTK_PROJECTION_OBLIQUE
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
#define VTK_PROJECTION_YZ
void PrintSelf(ostream &os, vtkIndent indent)
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
represent and manipulate 3D points
Definition: vtkPoints.h:38