VTK  9.0.1
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 vtkConeSource;
38 class vtkDoubleArray;
39 class vtkPlaneSource;
40 class vtkPoints;
41 class vtkPolyData;
42 class vtkProp;
43 class vtkProperty;
44 class vtkSphereSource;
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 
72 
75  vtkSetMacro(InteractionState, int);
77 
79 
88  vtkSetMacro(ProjectToPlane, vtkTypeBool);
89  vtkGetMacro(ProjectToPlane, vtkTypeBool);
90  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
92 
97  void SetPlaneSource(vtkPlaneSource* plane);
98 
99  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
100  vtkGetMacro(ProjectionNormal, int);
101  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
102  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
103  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
104  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
105 
107 
114  void SetProjectionPosition(double position);
115  vtkGetMacro(ProjectionPosition, double);
117 
125  virtual void GetPolyData(vtkPolyData* pd) = 0;
126 
128 
132  vtkGetObjectMacro(HandleProperty, vtkProperty);
133  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
135 
137 
141  vtkGetObjectMacro(LineProperty, vtkProperty);
142  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
144 
146 
149  virtual void SetNumberOfHandles(int npts) = 0;
150  vtkGetMacro(NumberOfHandles, int);
152 
154 
158  void SetDirectionalLine(bool val);
159  vtkGetMacro(DirectionalLine, bool);
160  vtkBooleanMacro(DirectionalLine, bool);
162 
164 
168  virtual void SetHandlePosition(int handle, double x, double y, double z);
169  virtual void SetHandlePosition(int handle, double xyz[3]);
170  virtual void GetHandlePosition(int handle, double xyz[3]);
171  virtual double* GetHandlePosition(int handle);
172  virtual vtkDoubleArray* GetHandlePositions() = 0;
174 
176 
181  void SetClosed(vtkTypeBool closed);
182  vtkGetMacro(Closed, vtkTypeBool);
183  vtkBooleanMacro(Closed, vtkTypeBool);
185 
191  vtkTypeBool IsClosed();
192 
198  virtual double GetSummedLength() = 0;
199 
206  virtual void InitializeHandles(vtkPoints* points) = 0;
207 
209 
214  void BuildRepresentation() override = 0;
215  int ComputeInteractionState(int X, int Y, int modify = 0) override;
216  void StartWidgetInteraction(double e[2]) override;
217  void WidgetInteraction(double e[2]) override;
218  void EndWidgetInteraction(double e[2]) override;
219  double* GetBounds() override;
221 
223 
226  void ReleaseGraphicsResources(vtkWindow*) override;
227  int RenderOpaqueGeometry(vtkViewport*) override;
229  int RenderOverlay(vtkViewport*) override;
232 
237  void SetLineColor(double r, double g, double b);
238 
239  /*
240  * Register internal Pickers within PickingManager
241  */
242  void RegisterPickers() override;
243 
245 
250  void SetCurrentHandleIndex(int index);
251  vtkGetMacro(CurrentHandleIndex, int);
253 
255 
259  vtkGetMacro(TranslationAxis, int);
260  vtkSetClampMacro(TranslationAxis, int, -1, 2);
262 
264 
267  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
268  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
269  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
270  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
272 
274 
277  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
279 
280 protected:
282  ~vtkCurveRepresentation() override;
283 
285 
286  double LastEventPosition[3];
287  double Bounds[6];
288 
289  // Controlling vars
294 
295  // Projection capabilities
296  void ProjectPointsToPlane();
297  void ProjectPointsToOrthoPlane();
298  void ProjectPointsToObliquePlane();
299 
302 
303  // The line segments
305  void HighlightLine(int highlight);
306 
307  // Glyphs representing hot spots (e.g., handles)
310  void Initialize();
311  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
312  int GetHandleIndex(vtkProp* prop); // returns handle index or -1 on fail
313  virtual void SizeHandles();
314 
318  virtual int InsertHandleOnLine(double* pos) = 0;
319 
320  virtual void PushHandle(double* pos);
321  void EraseHandle(const int&);
322 
323  // Do the picking
326  double LastPickPosition[3];
330 
331  // Methods to manipulate the curve.
332  void MovePoint(double* p1, double* p2);
333  void Scale(double* p1, double* p2, int X, int Y);
334  void Translate(double* p1, double* p2);
335  void Spin(double* p1, double* p2, double* vpn);
336 
337  // Transform the control points (used for spinning)
339 
340  // Manage how the representation appears
342 
343  // Properties used to control the appearance of selected objects and
344  // the manipulator in general.
349  void CreateDefaultProperties();
350 
351  // For efficient spinning
352  double Centroid[3];
353  void CalculateCentroid();
354 
356 
358  {
359  public:
360  static HandleSource* New();
361 
362  vtkSetMacro(UseSphere, bool);
363  vtkGetMacro(UseSphere, bool);
364  vtkBooleanMacro(UseSphere, bool);
365 
366  vtkSetClampMacro(Radius, double, 0.0, VTK_DOUBLE_MAX);
367  vtkGetMacro(Radius, double);
368 
369  vtkSetVector3Macro(Center, double);
370  vtkGetVectorMacro(Center, double, 3);
371 
372  vtkSetVector3Macro(Direction, double);
373  vtkGetVectorMacro(Direction, double, 3);
374 
375  protected:
376  HandleSource();
377  ~HandleSource() override {}
378  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
379 
380  private:
381  bool UseSphere;
382  // Used by both
383  double Radius;
384  double Center[3];
385  // Cone only
386  double Direction[3];
387  };
388 
389 private:
391  void operator=(const vtkCurveRepresentation&) = delete;
392 };
393 
394 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:135
vtkWidgetRepresentation.h
vtkCurveRepresentation::SetZTranslationAxisOn
void SetZTranslationAxisOn()
Definition: vtkCurveRepresentation.h:269
vtkCurveRepresentation::_InteractionState
_InteractionState
Definition: vtkCurveRepresentation.h:58
vtkCurveRepresentation::NumberOfHandles
int NumberOfHandles
Definition: vtkCurveRepresentation.h:300
vtkCurveRepresentation::SetProjectionNormalToYAxes
void SetProjectionNormalToYAxes()
Definition: vtkCurveRepresentation.h:102
vtkCurveRepresentation::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkCurveRepresentation.h:104
vtkCurveRepresentation::DirectionalLine
bool DirectionalLine
Definition: vtkCurveRepresentation.h:341
VTK_PROJECTION_YZ
#define VTK_PROJECTION_YZ
Definition: vtkCurveRepresentation.h:47
vtkWidgetRepresentation::EndWidgetInteraction
virtual void EndWidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:137
vtkCurveRepresentation::HandleSource
Definition: vtkCurveRepresentation.h:357
vtkCurveRepresentation::LinePicker
vtkCellPicker * LinePicker
Definition: vtkCurveRepresentation.h:325
vtkCurveRepresentation
vtkWidgetRepresentation base class for a widget that represents an curve that connects control points...
Definition: vtkCurveRepresentation.h:51
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkCurveRepresentation::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkCurveRepresentation.h:327
vtkCurveRepresentation::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkCurveRepresentation.h:346
vtkPlaneSource
create an array of quadrilaterals located in a plane
Definition: vtkPlaneSource.h:54
vtkConeSource
generate polygonal cone
Definition: vtkConeSource.h:38
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:59
vtkCurveRepresentation::Closed
vtkTypeBool Closed
Definition: vtkCurveRepresentation.h:301
vtkCurveRepresentation::CurrentHandleIndex
int CurrentHandleIndex
Definition: vtkCurveRepresentation.h:328
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkCurveRepresentation::TranslationAxis
int TranslationAxis
Definition: vtkCurveRepresentation.h:355
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
VTK_PROJECTION_OBLIQUE
#define VTK_PROJECTION_OBLIQUE
Definition: vtkCurveRepresentation.h:50
vtkCurveRepresentation::FirstSelected
bool FirstSelected
Definition: vtkCurveRepresentation.h:329
vtkCurveRepresentation::LineActor
vtkActor * LineActor
Definition: vtkCurveRepresentation.h:304
vtkPolyDataAlgorithm.h
vtkWidgetRepresentation::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:216
vtkWidgetRepresentation::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkWidgetRepresentation.h:213
vtkX3D::position
@ position
Definition: vtkX3D.h:267
vtkCurveRepresentation::HandleSource::~HandleSource
~HandleSource() override
Definition: vtkCurveRepresentation.h:377
vtkX3D::points
@ points
Definition: vtkX3D.h:452
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:136
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:208
vtkCurveRepresentation::ProjectionPosition
double ProjectionPosition
Definition: vtkCurveRepresentation.h:291
vtkCurveRepresentation::SetXTranslationAxisOn
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
Definition: vtkCurveRepresentation.h:267
vtkCurveRepresentation::Spinning
@ Spinning
Definition: vtkCurveRepresentation.h:65
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkCurveRepresentation::IsTranslationConstrained
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
Definition: vtkCurveRepresentation.h:277
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkWidgetRepresentation::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkCurveRepresentation::SetProjectionNormalToZAxes
void SetProjectionNormalToZAxes()
Definition: vtkCurveRepresentation.h:103
vtkCurveRepresentation::Transform
vtkTransform * Transform
Definition: vtkCurveRepresentation.h:338
vtkCurveRepresentation::OnLine
@ OnLine
Definition: vtkCurveRepresentation.h:62
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkCurveRepresentation::HandleProperty
vtkProperty * HandleProperty
Definition: vtkCurveRepresentation.h:345
vtkCurveRepresentation::Inserting
@ Inserting
Definition: vtkCurveRepresentation.h:66
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
vtkCurveRepresentation::Handle
vtkActor ** Handle
Definition: vtkCurveRepresentation.h:308
vtkCurveRepresentation::OnHandle
@ OnHandle
Definition: vtkCurveRepresentation.h:61
vtkWidgetRepresentation::RenderOverlay
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:214
vtkWidgetRepresentation::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:215
vtkCurveRepresentation::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkCurveRepresentation.h:324
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkCurveRepresentation::Moving
@ Moving
Definition: vtkCurveRepresentation.h:63
vtkCurveRepresentation::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkCurveRepresentation.h:348
vtkCurveRepresentation::Scaling
@ Scaling
Definition: vtkCurveRepresentation.h:64
vtkCurveRepresentation::Erasing
@ Erasing
Definition: vtkCurveRepresentation.h:67
vtkCurveRepresentation::HandleGeometry
HandleSource ** HandleGeometry
Definition: vtkCurveRepresentation.h:309
vtkCurveRepresentation::ProjectToPlane
vtkTypeBool ProjectToPlane
Definition: vtkCurveRepresentation.h:292
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkCurveRepresentation::SetYTranslationAxisOn
void SetYTranslationAxisOn()
Definition: vtkCurveRepresentation.h:268
vtkCurveRepresentation::SetTranslationAxisOff
void SetTranslationAxisOff()
Definition: vtkCurveRepresentation.h:270
vtkWidgetRepresentation::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkWidgetRepresentation.h:218
vtkCurveRepresentation::LineProperty
vtkProperty * LineProperty
Definition: vtkCurveRepresentation.h:347
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkCurveRepresentation::SetProjectionNormalToXAxes
void SetProjectionNormalToXAxes()
Definition: vtkCurveRepresentation.h:101
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkCurveRepresentation::PlaneSource
vtkPlaneSource * PlaneSource
Definition: vtkCurveRepresentation.h:293
vtkCurveRepresentation::ProjectionNormal
int ProjectionNormal
Definition: vtkCurveRepresentation.h:290
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41