VTK  9.3.1
vtkCurveRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
18 #ifndef vtkCurveRepresentation_h
19 #define vtkCurveRepresentation_h
20 
21 #include "vtkInteractionWidgetsModule.h" // For export macro
22 #include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
23 #include "vtkPolyDataAlgorithm.h" // needed for vtkPolyDataAlgorithm
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkActor;
28 class vtkCellPicker;
29 class vtkDoubleArray;
30 class vtkHandleSource;
31 class vtkPlaneSource;
32 class vtkPoints;
33 class vtkPolyData;
34 class vtkProp;
35 class vtkProperty;
36 class vtkTransform;
37 
38 #define VTK_PROJECTION_YZ 0
39 #define VTK_PROJECTION_XZ 1
40 #define VTK_PROJECTION_XY 2
41 #define VTK_PROJECTION_OBLIQUE 3
42 class VTKINTERACTIONWIDGETS_EXPORT vtkCurveRepresentation : public vtkWidgetRepresentation
43 {
44 public:
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
48  // Used to manage the InteractionState of the widget
50  {
51  Outside = 0,
59  Pushing
60  };
61 #if !defined(VTK_LEGACY_REMOVE)
62  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
64 #endif
65 
67 
70  vtkSetMacro(InteractionState, int);
72 
74 
83  vtkSetMacro(ProjectToPlane, vtkTypeBool);
84  vtkGetMacro(ProjectToPlane, vtkTypeBool);
85  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
87 
92  void SetPlaneSource(vtkPlaneSource* plane);
93 
94  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
95  vtkGetMacro(ProjectionNormal, int);
96  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
97  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
98  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
99  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
100 
102 
109  void SetProjectionPosition(double position);
110  vtkGetMacro(ProjectionPosition, double);
112 
120  virtual void GetPolyData(vtkPolyData* pd) = 0;
121 
123 
127  vtkGetObjectMacro(HandleProperty, vtkProperty);
128  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
130 
132 
136  vtkGetObjectMacro(LineProperty, vtkProperty);
137  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
139 
141 
144  virtual void SetNumberOfHandles(int npts) = 0;
145  vtkGetMacro(NumberOfHandles, int);
147 
149 
154  virtual void SetDirectional(bool val);
155  vtkGetMacro(Directional, bool);
156  vtkBooleanMacro(Directional, bool);
158 
160 
164  virtual void SetHandlePosition(int handle, double x, double y, double z);
165  virtual void SetHandlePosition(int handle, double xyz[3]);
166  virtual void GetHandlePosition(int handle, double xyz[3]);
167  virtual double* GetHandlePosition(int handle);
168  virtual vtkDoubleArray* GetHandlePositions() = 0;
170 
172 
177  void SetClosed(vtkTypeBool closed);
178  vtkGetMacro(Closed, vtkTypeBool);
179  vtkBooleanMacro(Closed, vtkTypeBool);
181 
187  vtkTypeBool IsClosed();
188 
194  virtual double GetSummedLength() = 0;
195 
202  virtual void InitializeHandles(vtkPoints* points) = 0;
203 
205 
210  void BuildRepresentation() override = 0;
211  int ComputeInteractionState(int X, int Y, int modify = 0) override;
212  void StartWidgetInteraction(double e[2]) override;
213  void WidgetInteraction(double e[2]) override;
214  void EndWidgetInteraction(double e[2]) override;
215  double* GetBounds() override;
217 
219 
222  void ReleaseGraphicsResources(vtkWindow*) override;
223  int RenderOpaqueGeometry(vtkViewport*) override;
225  int RenderOverlay(vtkViewport*) override;
228 
233  void SetLineColor(double r, double g, double b);
234 
236 
239  void SetInteractionColor(double, double, double);
240  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
241  void SetForegroundColor(double, double, double);
242  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
244 
245  /*
246  * Register internal Pickers within PickingManager
247  */
248  void RegisterPickers() override;
249 
251 
256  void SetCurrentHandleIndex(int index);
257  vtkGetMacro(CurrentHandleIndex, int);
259 
261 
265  vtkGetMacro(TranslationAxis, int);
266  vtkSetClampMacro(TranslationAxis, int, -1, 2);
268 
270 
273  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
274  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
275  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
276  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
278 
280 
283  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
285 
293  void GetActors(vtkPropCollection*) override;
294 
295 protected:
297  ~vtkCurveRepresentation() override;
298 
299  double LastEventPosition[3];
300  double Bounds[6];
301 
302  // Controlling vars
307 
308  // Projection capabilities
309  void ProjectPointsToPlane();
310  void ProjectPointsToOrthoPlane();
311  void ProjectPointsToObliquePlane();
312 
313  int NumberOfHandles = 0;
315 
316  // The line segments
318  void HighlightLine(int highlight);
319  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
320 
321  // accessors to glyphs representing hot spots (e.g., handles)
322  virtual vtkActor* GetHandleActor(int index) = 0;
323  virtual vtkHandleSource* GetHandleSource(int index) = 0;
324 
328  virtual int GetHandleIndex(vtkProp* prop) = 0;
329  virtual void SizeHandles();
330 
334  virtual int InsertHandleOnLine(double* pos) = 0;
335 
336  virtual void PushHandle(double* pos);
337  virtual void EraseHandle(const int&);
338 
339  // Do the picking
342  double LastPickPosition[3];
346 
347  // Methods to manipulate the curve.
348  void MovePoint(double* p1, double* p2);
349  void Scale(double* p1, double* p2, int X, int Y);
350  void Translate(double* p1, double* p2);
351  void Spin(double* p1, double* p2, double* vpn);
352 
353  // Transform the control points (used for spinning)
355 
356  // Manage how the representation appears
357  bool Directional = false;
358 
359  // Properties used to control the appearance of selected objects and
360  // the manipulator in general.
365  void CreateDefaultProperties();
366 
367  // For efficient spinning
368  double Centroid[3];
369  void CalculateCentroid();
370 
372 
373 private:
375  void operator=(const vtkCurveRepresentation&) = delete;
376 };
377 VTK_ABI_NAMESPACE_END
378 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
base class for a widget that represents a 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.
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:56
virtual void StartWidgetInteraction(double eventPos[2])
#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:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
a simple class to control print indentation
Definition: vtkIndent.h:28
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
void SetInteractionColor(double c[3])
Set the color when unselected and selected.
create an array of quadrilaterals located in a plane
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
#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:61
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
#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...
void SetForegroundColor(double c[3])
Set the color when unselected and selected.
represent and manipulate 3D points
Definition: vtkPoints.h:28