VTK  9.2.5
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
36class vtkActor;
37class vtkCellPicker;
38class vtkDoubleArray;
39class vtkHandleSource;
40class vtkPlaneSource;
41class vtkPoints;
42class vtkPolyData;
43class vtkProp;
44class vtkProperty;
45class 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
51class VTKINTERACTIONWIDGETS_EXPORT vtkCurveRepresentation : public vtkWidgetRepresentation
52{
53public:
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
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
307
308protected:
311
312 double LastEventPosition[3];
313 double Bounds[6];
314
315 // Controlling vars
320
321 // Projection capabilities
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.
379
380 // For efficient spinning
381 double Centroid[3];
383
385
386private:
388 void operator=(const vtkCurveRepresentation&) = delete;
389};
390#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:73
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.
virtual vtkHandleSource * GetHandleSource(int index)=0
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.
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.
void GetActors(vtkPropCollection *) override
Methods to make this class behave as a vtkProp.
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:40
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:40
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:91
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:68
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
abstract specification for Viewports
Definition: vtkViewport.h:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_PROJECTION_YZ
#define VTK_PROJECTION_OBLIQUE
#define VTK_DEPRECATED_IN_9_1_0(reason)
#define VTK_DEPRECATED_IN_9_2_0(reason)