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) override;
54 
55  // Used to manage the InteractionState of the widget
57  Outside=0,
65  Pushing
66  };
67 
69 
72  vtkSetMacro(InteractionState, int);
74 
76 
85  vtkSetMacro(ProjectToPlane,vtkTypeBool);
86  vtkGetMacro(ProjectToPlane,vtkTypeBool);
87  vtkBooleanMacro(ProjectToPlane,vtkTypeBool);
89 
94  void SetPlaneSource(vtkPlaneSource* plane);
95 
96  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
97  vtkGetMacro(ProjectionNormal,int);
99  { this->SetProjectionNormal(0); }
101  { this->SetProjectionNormal(1); }
103  { this->SetProjectionNormal(2); }
105  { this->SetProjectionNormal(3); }
106 
108 
115  void SetProjectionPosition(double position);
116  vtkGetMacro(ProjectionPosition, double);
118 
126  virtual void GetPolyData(vtkPolyData *pd) = 0;
127 
129 
133  vtkGetObjectMacro(HandleProperty, vtkProperty);
134  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
136 
138 
142  vtkGetObjectMacro(LineProperty, vtkProperty);
143  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
145 
147 
150  virtual void SetNumberOfHandles(int npts) = 0;
151  vtkGetMacro(NumberOfHandles, int);
153 
155 
159  virtual void SetHandlePosition(int handle, double x, double y, double z);
160  virtual void SetHandlePosition(int handle, double xyz[3]);
161  virtual void GetHandlePosition(int handle, double xyz[3]);
162  virtual double* GetHandlePosition(int handle);
163  virtual vtkDoubleArray* GetHandlePositions() = 0;
165 
167 
172  void SetClosed(vtkTypeBool closed);
173  vtkGetMacro(Closed,vtkTypeBool);
174  vtkBooleanMacro(Closed,vtkTypeBool);
176 
182  vtkTypeBool IsClosed();
183 
189  virtual double GetSummedLength() = 0;
190 
197  virtual void InitializeHandles(vtkPoints* points) = 0;
198 
200 
205  void BuildRepresentation() override = 0;
206  int ComputeInteractionState(int X, int Y, int modify=0) override;
207  void StartWidgetInteraction(double e[2]) override;
208  void WidgetInteraction(double e[2]) override;
209  void EndWidgetInteraction(double e[2]) override;
210  double *GetBounds() override;
212 
214 
217  void ReleaseGraphicsResources(vtkWindow*) override;
218  int RenderOpaqueGeometry(vtkViewport*) override;
220  int RenderOverlay(vtkViewport*) override;
223 
228  void SetLineColor(double r, double g, double b);
229 
230  /*
231  * Register internal Pickers within PickingManager
232  */
233  void RegisterPickers() override;
234 
235 protected:
237  ~vtkCurveRepresentation() override;
238 
239  double LastEventPosition[3];
240  double Bounds[6];
241 
242  // Controlling vars
247 
248  // Projection capabilities
249  void ProjectPointsToPlane();
250  void ProjectPointsToOrthoPlane();
251  void ProjectPointsToObliquePlane();
252 
255 
256  // The line segments
258  void HighlightLine(int highlight);
259 
260  // Glyphs representing hot spots (e.g., handles)
263  void Initialize();
264  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
265  virtual void SizeHandles();
266  virtual void InsertHandleOnLine(double* pos) = 0;
267  virtual void PushHandle(double* pos);
268  void EraseHandle(const int&);
269 
270  // Do the picking
273  double LastPickPosition[3];
277 
278  // Methods to manipulate the curve.
279  void MovePoint(double *p1, double *p2);
280  void Scale(double *p1, double *p2, int X, int Y);
281  void Translate(double *p1, double *p2);
282  void Spin(double *p1, double *p2, double *vpn);
283 
284  // Transform the control points (used for spinning)
286 
287  // Properties used to control the appearance of selected objects and
288  // the manipulator in general.
293  void CreateDefaultProperties();
294 
295  // For efficient spinning
296  double Centroid[3];
297  void CalculateCentroid();
298 
299 private:
301  void operator=(const vtkCurveRepresentation&) = delete;
302 
303 };
304 
305 
306 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:136
vtkWidgetRepresentation.h
vtkCurveRepresentation::_InteractionState
_InteractionState
Definition: vtkCurveRepresentation.h:56
vtkCurveRepresentation::NumberOfHandles
int NumberOfHandles
Definition: vtkCurveRepresentation.h:253
vtkCurveRepresentation::SetProjectionNormalToYAxes
void SetProjectionNormalToYAxes()
Definition: vtkCurveRepresentation.h:100
vtkCurveRepresentation::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkCurveRepresentation.h:104
VTK_PROJECTION_YZ
#define VTK_PROJECTION_YZ
Definition: vtkCurveRepresentation.h:45
vtkWidgetRepresentation::EndWidgetInteraction
virtual void EndWidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:138
vtkCurveRepresentation::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkCurveRepresentation.h:262
vtkCurveRepresentation::LinePicker
vtkCellPicker * LinePicker
Definition: vtkCurveRepresentation.h:272
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:274
vtkCurveRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkCurveRepresentation.h:290
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:60
vtkCurveRepresentation::Closed
vtkTypeBool Closed
Definition: vtkCurveRepresentation.h:254
vtkCurveRepresentation::CurrentHandleIndex
int CurrentHandleIndex
Definition: vtkCurveRepresentation.h:275
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
VTK_PROJECTION_OBLIQUE
#define VTK_PROJECTION_OBLIQUE
Definition: vtkCurveRepresentation.h:48
vtkCurveRepresentation::FirstSelected
bool FirstSelected
Definition: vtkCurveRepresentation.h:276
vtkCurveRepresentation::LineActor
vtkActor * LineActor
Definition: vtkCurveRepresentation.h:257
vtkWidgetRepresentation::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:223
vtkWidgetRepresentation::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkWidgetRepresentation.h:220
vtkX3D::position
Definition: vtkX3D.h:261
vtkX3D::points
Definition: vtkX3D.h:446
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:137
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:215
vtkCurveRepresentation::ProjectionPosition
double ProjectionPosition
Definition: vtkCurveRepresentation.h:244
vtkCurveRepresentation::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.
vtkCurveRepresentation::SetProjectionNormalToZAxes
void SetProjectionNormalToZAxes()
Definition: vtkCurveRepresentation.h:102
vtkCurveRepresentation::Transform
vtkTransform * Transform
Definition: vtkCurveRepresentation.h:285
vtkCurveRepresentation::OnLine
Definition: vtkCurveRepresentation.h:59
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkCurveRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkCurveRepresentation.h:289
vtkCurveRepresentation::Inserting
Definition: vtkCurveRepresentation.h:63
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkCurveRepresentation::Handle
vtkActor ** Handle
Definition: vtkCurveRepresentation.h:261
vtkCurveRepresentation::OnHandle
Definition: vtkCurveRepresentation.h:58
vtkWidgetRepresentation::RenderOverlay
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:221
vtkWidgetRepresentation::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:222
vtkCurveRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkCurveRepresentation.h:271
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkCurveRepresentation::Moving
Definition: vtkCurveRepresentation.h:60
vtkCurveRepresentation::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkCurveRepresentation.h:292
vtkCurveRepresentation::Scaling
Definition: vtkCurveRepresentation.h:61
vtkCurveRepresentation::Erasing
Definition: vtkCurveRepresentation.h:64
vtkCurveRepresentation::ProjectToPlane
vtkTypeBool ProjectToPlane
Definition: vtkCurveRepresentation.h:245
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:41
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:66
vtkWidgetRepresentation::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkWidgetRepresentation.h:225
vtkCurveRepresentation::LineProperty
vtkProperty * LineProperty
Definition: vtkCurveRepresentation.h:291
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkCurveRepresentation::SetProjectionNormalToXAxes
void SetProjectionNormalToXAxes()
Definition: vtkCurveRepresentation.h:98
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkCurveRepresentation::PlaneSource
vtkPlaneSource * PlaneSource
Definition: vtkCurveRepresentation.h:246
vtkCurveRepresentation::ProjectionNormal
int ProjectionNormal
Definition: vtkCurveRepresentation.h:243
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.