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
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:130
vtkWidgetRepresentation.h
vtkCurveRepresentation::_InteractionState
_InteractionState
Definition: vtkCurveRepresentation.h:56
vtkCurveRepresentation::NumberOfHandles
int NumberOfHandles
Definition: vtkCurveRepresentation.h:247
vtkCurveRepresentation::SetProjectionNormalToYAxes
void SetProjectionNormalToYAxes()
Definition: vtkCurveRepresentation.h:99
vtkCurveRepresentation::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkCurveRepresentation.h:103
VTK_PROJECTION_YZ
#define VTK_PROJECTION_YZ
Definition: vtkCurveRepresentation.h:45
vtkWidgetRepresentation::EndWidgetInteraction
virtual void EndWidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:132
vtkCurveRepresentation::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkCurveRepresentation.h:256
vtkCurveRepresentation::LinePicker
vtkCellPicker * LinePicker
Definition: vtkCurveRepresentation.h:265
vtkCurveRepresentation
vtkWidgetRepresentation base class for a widget that represents an curve that connects control points...
Definition: vtkCurveRepresentation.h:49
vtkCurveRepresentation::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkCurveRepresentation.h:267
vtkCurveRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkCurveRepresentation.h:285
vtkPlaneSource
create an array of quadrilaterals located in a plane
Definition: vtkPlaneSource.h:60
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:54
vtkCurveRepresentation::CurrentHandleIndex
int CurrentHandleIndex
Definition: vtkCurveRepresentation.h:268
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkCurveRepresentation::Closed
int Closed
Definition: vtkCurveRepresentation.h:248
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
VTK_PROJECTION_OBLIQUE
#define VTK_PROJECTION_OBLIQUE
Definition: vtkCurveRepresentation.h:48
vtkCurveRepresentation::LineActor
vtkActor * LineActor
Definition: vtkCurveRepresentation.h:251
vtkWidgetRepresentation::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkWidgetRepresentation.h:186
vtkWidgetRepresentation::GetBounds
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:181
vtkX3D::position
@ position
Definition: vtkX3D.h:261
vtkX3D::points
@ points
Definition: vtkX3D.h:446
vtkWidgetRepresentation::HasTranslucentPolygonalGeometry
virtual int HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkWidgetRepresentation.h:191
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:131
vtkCurveRepresentation::ProjectionPosition
double ProjectionPosition
Definition: vtkCurveRepresentation.h:238
vtkCurveRepresentation::Spinning
@ Spinning
Definition: vtkCurveRepresentation.h:62
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:46
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkWidgetRepresentation::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkWidgetRepresentation::RenderOpaqueGeometry
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:188
vtkCurveRepresentation::SetProjectionNormalToZAxes
void SetProjectionNormalToZAxes()
Definition: vtkCurveRepresentation.h:101
vtkCurveRepresentation::Transform
vtkTransform * Transform
Definition: vtkCurveRepresentation.h:280
vtkCurveRepresentation::ProjectToPlane
int ProjectToPlane
Definition: vtkCurveRepresentation.h:239
vtkCurveRepresentation::OnLine
@ OnLine
Definition: vtkCurveRepresentation.h:59
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkCurveRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkCurveRepresentation.h:284
vtkCurveRepresentation::Inserting
@ Inserting
Definition: vtkCurveRepresentation.h:63
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
vtkCurveRepresentation::Handle
vtkActor ** Handle
Definition: vtkCurveRepresentation.h:255
vtkCurveRepresentation::OnHandle
@ OnHandle
Definition: vtkCurveRepresentation.h:58
vtkCurveRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkCurveRepresentation.h:264
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkCurveRepresentation::Moving
@ Moving
Definition: vtkCurveRepresentation.h:60
vtkCurveRepresentation::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkCurveRepresentation.h:287
vtkCurveRepresentation::Scaling
@ Scaling
Definition: vtkCurveRepresentation.h:61
vtkWidgetRepresentation::RenderTranslucentPolygonalGeometry
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:189
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:41
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:64
vtkWidgetRepresentation::RenderOverlay
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:187
vtkCurveRepresentation::LineProperty
vtkProperty * LineProperty
Definition: vtkCurveRepresentation.h:286
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkCurveRepresentation::SetProjectionNormalToXAxes
void SetProjectionNormalToXAxes()
Definition: vtkCurveRepresentation.h:97
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkCurveRepresentation::PlaneSource
vtkPlaneSource * PlaneSource
Definition: vtkCurveRepresentation.h:240
vtkCurveRepresentation::ProjectionNormal
int ProjectionNormal
Definition: vtkCurveRepresentation.h:237