VTK  9.2.6
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
32 #include "vtkInteractionWidgetsModule.h" // For export macro
33 #include "vtkPolyDataAlgorithm.h" // needed for vtkPolyDataAlgorithm
35 
36 class vtkActor;
37 class vtkCellPicker;
38 class vtkDoubleArray;
39 class vtkHandleSource;
40 class vtkPlaneSource;
41 class vtkPoints;
42 class vtkPolyData;
43 class vtkProp;
44 class vtkProperty;
45 class vtkTransform;
46 
47 #define VTK_PROJECTION_YZ 0
48 #define VTK_PROJECTION_XZ 1
49 #define VTK_PROJECTION_XY 2
50 #define VTK_PROJECTION_OBLIQUE 3
51 class VTKINTERACTIONWIDGETS_EXPORT vtkCurveRepresentation : public vtkWidgetRepresentation
52 {
53 public:
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
57  // Used to manage the InteractionState of the widget
59  {
60  Outside = 0,
68  Pushing
69  };
70 #if !defined(VTK_LEGACY_REMOVE)
71  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
73 #endif
74 
76 
79  vtkSetMacro(InteractionState, int);
81 
83 
92  vtkSetMacro(ProjectToPlane, vtkTypeBool);
93  vtkGetMacro(ProjectToPlane, vtkTypeBool);
94  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
96 
101  void SetPlaneSource(vtkPlaneSource* plane);
102 
103  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
104  vtkGetMacro(ProjectionNormal, int);
105  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
106  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
107  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
108  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
109 
111 
118  void SetProjectionPosition(double position);
119  vtkGetMacro(ProjectionPosition, double);
121 
129  virtual void GetPolyData(vtkPolyData* pd) = 0;
130 
132 
136  vtkGetObjectMacro(HandleProperty, vtkProperty);
137  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
139 
141 
145  vtkGetObjectMacro(LineProperty, vtkProperty);
146  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
148 
150 
153  virtual void SetNumberOfHandles(int npts) = 0;
154  vtkGetMacro(NumberOfHandles, int);
156 
158 
161  VTK_DEPRECATED_IN_9_1_0("renamed to SetDirectional")
162  virtual void SetDirectionalLine(bool val);
163  VTK_DEPRECATED_IN_9_1_0("renamed to GetDirectional")
164  virtual bool GetDirectionalLine();
165  VTK_DEPRECATED_IN_9_1_0("renamed to DirectionalOn")
166  virtual void DirectionalLineOn();
167  VTK_DEPRECATED_IN_9_1_0("renamed to DirectionalOff")
168  virtual void DirectionalLineOff();
170 
172 
177  virtual void SetDirectional(bool val);
178  vtkGetMacro(Directional, bool);
179  vtkBooleanMacro(Directional, bool);
181 
183 
187  virtual void SetHandlePosition(int handle, double x, double y, double z);
188  virtual void SetHandlePosition(int handle, double xyz[3]);
189  virtual void GetHandlePosition(int handle, double xyz[3]);
190  virtual double* GetHandlePosition(int handle);
191  virtual vtkDoubleArray* GetHandlePositions() = 0;
193 
195 
200  void SetClosed(vtkTypeBool closed);
201  vtkGetMacro(Closed, vtkTypeBool);
202  vtkBooleanMacro(Closed, vtkTypeBool);
204 
210  vtkTypeBool IsClosed();
211 
217  virtual double GetSummedLength() = 0;
218 
225  virtual void InitializeHandles(vtkPoints* points) = 0;
226 
228 
233  void BuildRepresentation() override = 0;
234  int ComputeInteractionState(int X, int Y, int modify = 0) override;
235  void StartWidgetInteraction(double e[2]) override;
236  void WidgetInteraction(double e[2]) override;
237  void EndWidgetInteraction(double e[2]) override;
238  double* GetBounds() override;
240 
242 
245  void ReleaseGraphicsResources(vtkWindow*) override;
246  int RenderOpaqueGeometry(vtkViewport*) override;
247  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
248  int RenderOverlay(vtkViewport*) override;
249  vtkTypeBool HasTranslucentPolygonalGeometry() override;
251 
256  void SetLineColor(double r, double g, double b);
257 
258  /*
259  * Register internal Pickers within PickingManager
260  */
261  void RegisterPickers() override;
262 
264 
269  void SetCurrentHandleIndex(int index);
270  vtkGetMacro(CurrentHandleIndex, int);
272 
274 
278  vtkGetMacro(TranslationAxis, int);
279  vtkSetClampMacro(TranslationAxis, int, -1, 2);
281 
283 
286  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
287  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
288  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
289  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
291 
293 
296  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
298 
306  void GetActors(vtkPropCollection*) override;
307 
308 protected:
310  ~vtkCurveRepresentation() override;
311 
312  double LastEventPosition[3];
313  double Bounds[6];
314 
315  // Controlling vars
320 
321  // Projection capabilities
322  void ProjectPointsToPlane();
323  void ProjectPointsToOrthoPlane();
324  void ProjectPointsToObliquePlane();
325 
326  int NumberOfHandles = 0;
328 
329  // The line segments
331  void HighlightLine(int highlight);
332  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
333 
334  // accessors to glyphs representing hot spots (e.g., handles)
335  virtual vtkActor* GetHandleActor(int index) = 0;
336  virtual vtkHandleSource* GetHandleSource(int index) = 0;
337 
341  virtual int GetHandleIndex(vtkProp* prop) = 0;
342  virtual void SizeHandles();
343 
347  virtual int InsertHandleOnLine(double* pos) = 0;
348 
349  virtual void PushHandle(double* pos);
350  virtual void EraseHandle(const int&);
351 
352  // Do the picking
355  double LastPickPosition[3];
359 
360  // Methods to manipulate the curve.
361  void MovePoint(double* p1, double* p2);
362  void Scale(double* p1, double* p2, int X, int Y);
363  void Translate(double* p1, double* p2);
364  void Spin(double* p1, double* p2, double* vpn);
365 
366  // Transform the control points (used for spinning)
368 
369  // Manage how the representation appears
370  bool Directional = false;
371 
372  // Properties used to control the appearance of selected objects and
373  // the manipulator in general.
378  void CreateDefaultProperties();
379 
380  // For efficient spinning
381  double Centroid[3];
382  void CalculateCentroid();
383 
385 
386 private:
388  void operator=(const vtkCurveRepresentation&) = delete;
389 };
390 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkWidgetRepresentation base class for a widget that represents an curve that connects control points...
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
#define VTK_DEPRECATED_IN_9_1_0(reason)
void GetBounds(T a, double bds[6])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract specification for Viewports
Definition: vtkViewport.h:55
represent surface properties of a geometric object
Definition: vtkProperty.h:67
#define VTK_DEPRECATED_IN_9_2_0(reason)
interface that can be inherited to define handler sources for any kind of interaction.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
abstract class defines interface between the widget and widget representation classes ...
dynamic, self-adjusting array of double
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
a simple class to control print indentation
Definition: vtkIndent.h:39
create an array of quadrilaterals located in a plane
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
#define VTK_PROJECTION_OBLIQUE
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:72
#define VTK_PROJECTION_YZ
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes...
represent and manipulate 3D points
Definition: vtkPoints.h:39