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
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...
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
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:66
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
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
dynamic, self-adjusting array of double
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
create a polygonal sphere centered at the origin
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual void WidgetInteraction(double newEventPos[2])
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
create an array of quadrilaterals located in a plane
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
vtkSphereSource ** HandleGeometry
#define VTK_PROJECTION_OBLIQUE
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
#define VTK_PROJECTION_YZ
represent and manipulate 3D points
Definition: vtkPoints.h:39