VTK  9.3.0
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 
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 
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);
170 
172 
177  void SetClosed(vtkTypeBool closed);
178  vtkGetMacro(Closed, vtkTypeBool);
179  vtkBooleanMacro(Closed, vtkTypeBool);
181 
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 
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 
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:
298 
299  double LastEventPosition[3];
300  double Bounds[6];
301 
302  // Controlling vars
307 
308  // Projection capabilities
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;
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.
366 
367  // For efficient spinning
368  double Centroid[3];
370 
372 
373 private:
375  void operator=(const vtkCurveRepresentation&) = delete;
376 };
377 VTK_ABI_NAMESPACE_END
378 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
base class for a widget that represents a curve that connects control points.
void SetForegroundColor(double, double, double)
Set the color when unselected and selected.
virtual void PushHandle(double *pos)
void Translate(double *p1, double *p2)
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
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 RegisterPickers() override
Register internal Pickers in the Picking Manager.
virtual double GetSummedLength()=0
Get the approximate vs.
virtual vtkDoubleArray * GetHandlePositions()=0
Set/Get the position of the handles.
void SetInteractionColor(double c[3])
Set the color when unselected and selected.
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
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting, and required by, the rendering process.
virtual double * GetHandlePosition(int handle)
Set/Get the position of the handles.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation API.
void EndWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation API.
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetForegroundColor(double c[3])
Set the color when unselected and selected.
vtkTypeBool IsClosed()
Convenience method to determine whether the curve is closed in a geometric sense.
void Spin(double *p1, double *p2, double *vpn)
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation API.
void SetClosed(vtkTypeBool closed)
Control whether the curve is open or closed.
virtual void SetNumberOfHandles(int npts)=0
Set/Get the number of handles for this widget.
void SetInteractionColor(double, double, double)
Set the color when unselected and selected.
void SetLineColor(double r, double g, double b)
Convenience method to set the line color.
void ProjectPointsToObliquePlane()
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting, and required by, the rendering process.
int RenderOverlay(vtkViewport *) override
Methods supporting, and required by, the rendering process.
int HighlightHandle(vtkProp *prop)
void BuildRepresentation() override=0
These are methods that satisfy vtkWidgetRepresentation API.
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation API.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting, and required by, the rendering process.
void SetPlaneSource(vtkPlaneSource *plane)
Set up a reference to a vtkPlaneSource that could be from another widget object, e....
virtual void InitializeHandles(vtkPoints *points)=0
Convenience method to allocate and set the handles from a vtkPoints instance.
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual vtkHandleSource * GetHandleSource(int index)=0
void HighlightLine(int highlight)
virtual void SetDirectional(bool val)
Set the representation to be directional or not.
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void SetHandlePosition(int handle, double x, double y, double z)
Set/Get the position of the handles.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation API.
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
void GetActors(vtkPropCollection *) override
Methods to make this class behave as a vtkProp.
virtual void GetHandlePosition(int handle, double xyz[3])
Set/Get the position of the handles.
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 void SetHandlePosition(int handle, double xyz[3])
Set/Get the position of the handles.
virtual int GetHandleIndex(vtkProp *prop)=0
returns handle index or -1 on fail
void SetCurrentHandleIndex(int index)
Get/Set the current handle index.
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:29
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:29
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:80
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:57
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
abstract specification for Viewports
Definition: vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
@ points
Definition: vtkX3D.h:446
@ position
Definition: vtkX3D.h:261
@ index
Definition: vtkX3D.h:246
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_PROJECTION_YZ
#define VTK_PROJECTION_OBLIQUE
#define VTK_DEPRECATED_IN_9_2_0(reason)