VTK  9.1.0
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
32 #include "vtkPolyDataAlgorithm.h" // needed for vtkPolyDataAlgorithm
34 
35 class vtkActor;
36 class vtkCellPicker;
37 class vtkDoubleArray;
38 class vtkHandleSource;
39 class vtkPlaneSource;
40 class vtkPoints;
41 class vtkPolyData;
42 class vtkProp;
43 class vtkProperty;
44 class vtkTransform;
45 
46 #define VTK_PROJECTION_YZ 0
47 #define VTK_PROJECTION_XZ 1
48 #define VTK_PROJECTION_XY 2
49 #define VTK_PROJECTION_OBLIQUE 3
50 class VTKINTERACTIONWIDGETS_EXPORT vtkCurveRepresentation : public vtkWidgetRepresentation
51 {
52 public:
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
56  // Used to manage the InteractionState of the widget
58  {
59  Outside = 0,
67  Pushing
68  };
69 
71 
74  vtkSetMacro(InteractionState, int);
76 
78 
87  vtkSetMacro(ProjectToPlane, vtkTypeBool);
88  vtkGetMacro(ProjectToPlane, vtkTypeBool);
89  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
91 
97 
98  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
99  vtkGetMacro(ProjectionNormal, int);
100  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
101  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
102  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
103  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
104 
106 
114  vtkGetMacro(ProjectionPosition, double);
116 
124  virtual void GetPolyData(vtkPolyData* pd) = 0;
125 
127 
131  vtkGetObjectMacro(HandleProperty, vtkProperty);
132  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
134 
136 
140  vtkGetObjectMacro(LineProperty, vtkProperty);
141  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
143 
145 
148  virtual void SetNumberOfHandles(int npts) = 0;
149  vtkGetMacro(NumberOfHandles, int);
151 
153 
156  VTK_DEPRECATED_IN_9_1_0("renamed to SetDirectional")
157  virtual void SetDirectionalLine(bool val);
158  VTK_DEPRECATED_IN_9_1_0("renamed to GetDirectional")
159  virtual bool GetDirectionalLine();
160  VTK_DEPRECATED_IN_9_1_0("renamed to DirectionalOn")
161  virtual void DirectionalLineOn();
162  VTK_DEPRECATED_IN_9_1_0("renamed to DirectionalOff")
163  virtual void DirectionalLineOff();
165 
167 
172  virtual void SetDirectional(bool val);
173  vtkGetMacro(Directional, bool);
174  vtkBooleanMacro(Directional, bool);
176 
178 
182  virtual void SetHandlePosition(int handle, double x, double y, double z);
183  virtual void SetHandlePosition(int handle, double xyz[3]);
184  virtual void GetHandlePosition(int handle, double xyz[3]);
185  virtual double* GetHandlePosition(int handle);
186  virtual vtkDoubleArray* GetHandlePositions() = 0;
188 
190 
195  void SetClosed(vtkTypeBool closed);
196  vtkGetMacro(Closed, vtkTypeBool);
197  vtkBooleanMacro(Closed, vtkTypeBool);
199 
205  vtkTypeBool IsClosed();
206 
212  virtual double GetSummedLength() = 0;
213 
220  virtual void InitializeHandles(vtkPoints* points) = 0;
221 
223 
228  void BuildRepresentation() override = 0;
229  int ComputeInteractionState(int X, int Y, int modify = 0) override;
230  void StartWidgetInteraction(double e[2]) override;
231  void WidgetInteraction(double e[2]) override;
232  void EndWidgetInteraction(double e[2]) override;
233  double* GetBounds() override;
235 
237 
240  void ReleaseGraphicsResources(vtkWindow*) override;
241  int RenderOpaqueGeometry(vtkViewport*) override;
242  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
243  int RenderOverlay(vtkViewport*) override;
244  vtkTypeBool HasTranslucentPolygonalGeometry() override;
246 
251  void SetLineColor(double r, double g, double b);
252 
253  /*
254  * Register internal Pickers within PickingManager
255  */
256  void RegisterPickers() override;
257 
259 
264  void SetCurrentHandleIndex(int index);
265  vtkGetMacro(CurrentHandleIndex, int);
267 
269 
273  vtkGetMacro(TranslationAxis, int);
274  vtkSetClampMacro(TranslationAxis, int, -1, 2);
276 
278 
281  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
282  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
283  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
284  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
286 
288 
291  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
293 
294 protected:
297 
298  double LastEventPosition[3];
299  double Bounds[6];
300 
301  // Controlling vars
306 
307  // Projection capabilities
311 
312  int NumberOfHandles = 0;
314 
315  // The line segments
317  void HighlightLine(int highlight);
318  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
319 
320  // accessors to glyphs representing hot spots (e.g., handles)
321  virtual vtkActor* GetHandleActor(int index) = 0;
323 
327  virtual int GetHandleIndex(vtkProp* prop) = 0;
328  virtual void SizeHandles();
329 
333  virtual int InsertHandleOnLine(double* pos) = 0;
334 
335  virtual void PushHandle(double* pos);
336  virtual void EraseHandle(const int&);
337 
338  // Do the picking
341  double LastPickPosition[3];
345 
346  // Methods to manipulate the curve.
347  void MovePoint(double* p1, double* p2);
348  void Scale(double* p1, double* p2, int X, int Y);
349  void Translate(double* p1, double* p2);
350  void Spin(double* p1, double* p2, double* vpn);
351 
352  // Transform the control points (used for spinning)
354 
355  // Manage how the representation appears
356  bool Directional = false;
357 
358  // Properties used to control the appearance of selected objects and
359  // the manipulator in general.
365 
366  // For efficient spinning
367  double Centroid[3];
369 
371 
372 private:
374  void operator=(const vtkCurveRepresentation&) = delete;
375 };
376 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
vtkWidgetRepresentation base class for a widget that represents an curve that connects control points...
virtual void PushHandle(double *pos)
void Translate(double *p1, double *p2)
void SetProjectionPosition(double position)
Set the position of poly line handles and points in terms of a plane's position.
virtual int InsertHandleOnLine(double *pos)=0
Returns the position of insertion or -1 on fail.
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
virtual vtkActor * GetHandleActor(int index)=0
void Scale(double *p1, double *p2, int X, int Y)
~vtkCurveRepresentation() override
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void Spin(double *p1, double *p2, double *vpn)
virtual void SetNumberOfHandles(int npts)=0
Set/Get the number of handles for this widget.
void ProjectPointsToObliquePlane()
int HighlightHandle(vtkProp *prop)
void SetPlaneSource(vtkPlaneSource *plane)
Set up a reference to a vtkPlaneSource that could be from another widget object, e....
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual vtkHandleSource * GetHandleSource(int index)=0
void HighlightLine(int highlight)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
virtual void GetPolyData(vtkPolyData *pd)=0
Grab the polydata (including points) that defines the interpolating curve.
virtual void EraseHandle(const int &)
void MovePoint(double *p1, double *p2)
virtual void SizeHandles()
virtual int GetHandleIndex(vtkProp *prop)=0
returns handle index or -1 on fail
dynamic, self-adjusting array of double
interface that can be inherited to define handler sources for any kind of interaction.
a simple class to control print indentation
Definition: vtkIndent.h:34
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:34
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:62
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
abstract specification for Viewports
Definition: vtkViewport.h:47
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
void GetBounds(T a, double bds[6])
@ points
Definition: vtkX3D.h:452
@ position
Definition: vtkX3D.h:267
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_PROJECTION_YZ
#define VTK_PROJECTION_OBLIQUE
#define VTK_DEPRECATED_IN_9_1_0(reason)