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 =========================================================================*/
28 #ifndef vtkCurveRepresentation_h
29 #define vtkCurveRepresentation_h
30 
31 #include "vtkInteractionWidgetsModule.h" // For export macro
33 
34 class vtkActor;
35 class vtkCellPicker;
36 class vtkDoubleArray;
37 class vtkPlaneSource;
38 class vtkPoints;
39 class vtkPolyData;
40 class vtkProp;
41 class vtkProperty;
42 class vtkSphereSource;
43 class vtkTransform;
44 
45 #define VTK_PROJECTION_YZ 0
46 #define VTK_PROJECTION_XZ 1
47 #define VTK_PROJECTION_XY 2
48 #define VTK_PROJECTION_OBLIQUE 3
49 class VTKINTERACTIONWIDGETS_EXPORT vtkCurveRepresentation : public vtkWidgetRepresentation
50 {
51 public:
53  void PrintSelf(ostream& os, vtkIndent indent);
54 
55  // Used to manage the InteractionState of the widget
57  Outside=0,
64  Erasing
65  };
66 
68 
71  vtkSetMacro(InteractionState, int);
73 
75 
84  vtkSetMacro(ProjectToPlane,int);
85  vtkGetMacro(ProjectToPlane,int);
86  vtkBooleanMacro(ProjectToPlane,int);
88 
93  void SetPlaneSource(vtkPlaneSource* plane);
94 
95  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
96  vtkGetMacro(ProjectionNormal,int);
98  { this->SetProjectionNormal(0); }
100  { this->SetProjectionNormal(1); }
102  { this->SetProjectionNormal(2); }
104  { this->SetProjectionNormal(3); }
105 
107 
114  void SetProjectionPosition(double position);
115  vtkGetMacro(ProjectionPosition, double);
117 
125  virtual void GetPolyData(vtkPolyData *pd) = 0;
126 
128 
132  vtkGetObjectMacro(HandleProperty, vtkProperty);
133  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
135 
137 
141  vtkGetObjectMacro(LineProperty, vtkProperty);
142  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
144 
146 
149  virtual void SetNumberOfHandles(int npts) = 0;
150  vtkGetMacro(NumberOfHandles, int);
152 
154 
158  virtual void SetHandlePosition(int handle, double x, double y, double z);
159  virtual void SetHandlePosition(int handle, double xyz[3]);
160  virtual void GetHandlePosition(int handle, double xyz[3]);
161  virtual double* GetHandlePosition(int handle);
162  virtual vtkDoubleArray* GetHandlePositions() = 0;
164 
166 
171  void SetClosed(int closed);
172  vtkGetMacro(Closed,int);
173  vtkBooleanMacro(Closed,int);
175 
181  int IsClosed();
182 
188  virtual double GetSummedLength() = 0;
189 
196  virtual void InitializeHandles(vtkPoints* points) = 0;
197 
199 
204  virtual void BuildRepresentation() = 0;
205  virtual int ComputeInteractionState(int X, int Y, int modify=0);
206  virtual void StartWidgetInteraction(double e[2]);
207  virtual void WidgetInteraction(double e[2]);
208  virtual void EndWidgetInteraction(double e[2]);
209  virtual double *GetBounds();
211 
213 
216  virtual void ReleaseGraphicsResources(vtkWindow*);
217  virtual int RenderOpaqueGeometry(vtkViewport*);
219  virtual int RenderOverlay(vtkViewport*);
220  virtual int HasTranslucentPolygonalGeometry();
222 
227  void SetLineColor(double r, double g, double b);
228 
229 protected:
232 
233  double LastEventPosition[3];
234  double Bounds[6];
235 
236  // Controlling vars
241 
242  // Projection capabilities
243  void ProjectPointsToPlane();
244  void ProjectPointsToOrthoPlane();
245  void ProjectPointsToObliquePlane();
246 
248  int Closed;
249 
250  // The line segments
252  void HighlightLine(int highlight);
253 
254  // Glyphs representing hot spots (e.g., handles)
257  void Initialize();
258  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
259  virtual void SizeHandles();
260  virtual void InsertHandleOnLine(double* pos) = 0;
261  void EraseHandle(const int&);
262 
263  // Do the picking
266  double LastPickPosition[3];
269 
270  // Register internal Pickers within PickingManager
271  virtual void RegisterPickers();
272 
273  // Methods to manipulate the curve.
274  void MovePoint(double *p1, double *p2);
275  void Scale(double *p1, double *p2, int X, int Y);
276  void Translate(double *p1, double *p2);
277  void Spin(double *p1, double *p2, double *vpn);
278 
279  // Transform the control points (used for spinning)
281 
282  // Properties used to control the appearance of selected objects and
283  // the manipulator in general.
288  void CreateDefaultProperties();
289 
290  // For efficient spinning
291  double Centroid[3];
292  void CalculateCentroid();
293 
294 private:
295  vtkCurveRepresentation(const vtkCurveRepresentation&) VTK_DELETE_FUNCTION;
296  void operator=(const vtkCurveRepresentation&) VTK_DELETE_FUNCTION;
297 
298 };
299 
300 
301 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
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:51
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:47
represent surface properties of a geometric object
Definition: vtkProperty.h:64
virtual void StartWidgetInteraction(double eventPos[2])
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
dynamic, self-adjusting array of double
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
create a polygonal sphere centered at the origin
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
virtual int HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
virtual void WidgetInteraction(double newEventPos[2])
create an array of quadrilaterals located in a plane
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkSphereSource ** HandleGeometry
#define VTK_PROJECTION_OBLIQUE
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
#define VTK_PROJECTION_YZ
void PrintSelf(ostream &os, vtkIndent indent)
Standard methods for instances of this class.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
represent and manipulate 3D points
Definition: vtkPoints.h:39