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 
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 
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);
174 
176 
181  void SetClosed(vtkTypeBool closed);
182  vtkGetMacro(Closed, vtkTypeBool);
183  vtkBooleanMacro(Closed, vtkTypeBool);
185 
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 
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 
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:
283 
284  class HandleSource;
285 
286  double LastEventPosition[3];
287  double Bounds[6];
288 
289  // Controlling vars
294 
295  // Projection capabilities
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.
350 
351  // For efficient spinning
352  double Centroid[3];
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:
377  ~HandleSource() 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
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
generate polygonal cone
Definition: vtkConeSource.h:39
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkWidgetRepresentation base class for a widget that represents an curve that connects control points...
void SetDirectionalLine(bool val)
Sets the representation to be a directional curve with the end represented as a cone.
void EraseHandle(const int &)
virtual void PushHandle(double *pos)
void Translate(double *p1, double *p2)
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
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.
int GetHandleIndex(vtkProp *prop)
virtual double GetSummedLength()=0
Get the approximate vs.
virtual vtkDoubleArray * GetHandlePositions()=0
void Scale(double *p1, double *p2, int X, int Y)
~vtkCurveRepresentation() override
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
virtual double * GetHandlePosition(int handle)
void WidgetInteraction(double e[2]) override
void EndWidgetInteraction(double e[2]) override
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
Get the bounds for this Prop as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
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 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
int HighlightHandle(vtkProp *prop)
void BuildRepresentation() override=0
These are methods that satisfy vtkWidgetRepresentation's API.
int ComputeInteractionState(int X, int Y, int modify=0) override
int RenderOpaqueGeometry(vtkViewport *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
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 HighlightLine(int highlight)
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
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
virtual void GetHandlePosition(int handle, double xyz[3])
virtual void GetPolyData(vtkPolyData *pd)=0
Grab the polydata (including points) that defines the interpolating curve.
void MovePoint(double *p1, double *p2)
virtual void SizeHandles()
virtual void SetHandlePosition(int handle, double xyz[3])
void SetCurrentHandleIndex(int index)
Get/Set the current handle index.
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:34
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
represent surface properties of a geometric object
Definition: vtkProperty.h:62
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
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:35
@ points
Definition: vtkX3D.h:452
@ position
Definition: vtkX3D.h:267
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_PROJECTION_YZ
#define VTK_PROJECTION_OBLIQUE
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165