VTK  9.0.3
vtkLeaderActor2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLeaderActor2D.h
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 =========================================================================*/
43 #ifndef vtkLeaderActor2D_h
44 #define vtkLeaderActor2D_h
45 
46 #include "vtkActor2D.h"
47 #include "vtkRenderingAnnotationModule.h" // For export macro
48 
49 class vtkPoints;
50 class vtkCellArray;
51 class vtkPolyData;
53 class vtkTextMapper;
54 class vtkTextProperty;
55 
56 class VTKRENDERINGANNOTATION_EXPORT vtkLeaderActor2D : public vtkActor2D
57 {
58 public:
59  vtkTypeMacro(vtkLeaderActor2D, vtkActor2D);
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
65  static vtkLeaderActor2D* New();
66 
68 
80  vtkSetMacro(Radius, double);
81  vtkGetMacro(Radius, double);
83 
85 
89  vtkSetStringMacro(Label);
90  vtkGetStringMacro(Label);
92 
94 
98  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
100 
102 
106  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
107  vtkGetMacro(LabelFactor, double);
109 
110  // Enums defined to support methods for control of arrow placement and
111  // and appearance of arrow heads.
112  enum
113  {
114  VTK_ARROW_NONE = 0,
117  VTK_ARROW_BOTH
118  };
119  enum
120  {
121  VTK_ARROW_FILLED = 0,
123  VTK_ARROW_HOLLOW
124  };
125 
127 
131  vtkSetClampMacro(ArrowPlacement, int, VTK_ARROW_NONE, VTK_ARROW_BOTH);
132  vtkGetMacro(ArrowPlacement, int);
133  void SetArrowPlacementToNone() { this->SetArrowPlacement(VTK_ARROW_NONE); }
134  void SetArrowPlacementToPoint1() { this->SetArrowPlacement(VTK_ARROW_POINT1); }
135  void SetArrowPlacementToPoint2() { this->SetArrowPlacement(VTK_ARROW_POINT2); }
136  void SetArrowPlacementToBoth() { this->SetArrowPlacement(VTK_ARROW_BOTH); }
138 
140 
145  vtkSetClampMacro(ArrowStyle, int, VTK_ARROW_FILLED, VTK_ARROW_HOLLOW);
146  vtkGetMacro(ArrowStyle, int);
147  void SetArrowStyleToFilled() { this->SetArrowStyle(VTK_ARROW_FILLED); }
148  void SetArrowStyleToOpen() { this->SetArrowStyle(VTK_ARROW_OPEN); }
149  void SetArrowStyleToHollow() { this->SetArrowStyle(VTK_ARROW_HOLLOW); }
151 
153 
157  vtkSetClampMacro(ArrowLength, double, 0.0, 1.0);
158  vtkGetMacro(ArrowLength, double);
159  vtkSetClampMacro(ArrowWidth, double, 0.0, 1.0);
160  vtkGetMacro(ArrowWidth, double);
162 
164 
170  vtkSetClampMacro(MinimumArrowSize, double, 1.0, VTK_FLOAT_MAX);
171  vtkGetMacro(MinimumArrowSize, double);
172  vtkSetClampMacro(MaximumArrowSize, double, 1.0, VTK_FLOAT_MAX);
173  vtkGetMacro(MaximumArrowSize, double);
175 
177 
183  vtkSetMacro(AutoLabel, vtkTypeBool);
184  vtkGetMacro(AutoLabel, vtkTypeBool);
185  vtkBooleanMacro(AutoLabel, vtkTypeBool);
187 
189 
192  vtkSetStringMacro(LabelFormat);
193  vtkGetStringMacro(LabelFormat);
195 
197 
201  vtkGetMacro(Length, double);
202  vtkGetMacro(Angle, double);
204 
206 
209  int RenderOverlay(vtkViewport* viewport) override;
210  int RenderOpaqueGeometry(vtkViewport* viewport) override;
211  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
213 
218 
220  void ShallowCopy(vtkProp* prop) override;
221 
222 protected:
224  ~vtkLeaderActor2D() override;
225 
226  // Internal helper methods
227  virtual void BuildLeader(vtkViewport* viewport);
228  int SetFontSize(vtkViewport* viewport, vtkTextMapper* textMapper, const int* targetSize,
229  double factor, int* stringSize);
231  double xL[3], int stringSize[2], double p1[3], double ray[3], double c1[3], double c2[3]);
232  void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength, double theta,
233  vtkViewport* viewport, int viewportChanged);
234  int InStringBox(double center[3], int stringSize[2], double x[3]);
235 
236  // Characteristics of the leader
237  double Radius;
238  double Length;
239  double Angle;
240 
242  char* LabelFormat;
243  char* Label;
244  double LabelFactor;
248 
251  double ArrowLength;
252  double ArrowWidth;
255 
262 
263  // Internal ivars for tracking whether to rebuild
264  int LastPosition[2];
265  int LastPosition2[2];
266  int LastSize[2];
268 
269 private:
270  vtkLeaderActor2D(const vtkLeaderActor2D&) = delete;
271  void operator=(const vtkLeaderActor2D&) = delete;
272 };
273 
274 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:40
object to represent cell connectivity
Definition: vtkCellArray.h:180
a simple class to control print indentation
Definition: vtkIndent.h:34
create a leader with optional label and arrows
vtkCellArray * LeaderArrows
void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength, double theta, vtkViewport *viewport, int viewportChanged)
vtkActor2D * LabelActor
void SetArrowPlacementToNone()
int InStringBox(double center[3], int stringSize[2], double x[3])
void SetArrowPlacementToBoth()
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkProp.
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the text property of the label.
vtkCellArray * LeaderLines
vtkPoints * LeaderPoints
int SetFontSize(vtkViewport *viewport, vtkTextMapper *textMapper, const int *targetSize, double factor, int *stringSize)
vtkTimeStamp BuildTime
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
vtkPolyDataMapper2D * LeaderMapper
virtual void BuildLeader(vtkViewport *viewport)
int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
~vtkLeaderActor2D() override
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
vtkPolyData * Leader
void SetArrowPlacementToPoint2()
vtkTextProperty * LabelTextProperty
vtkTypeBool AutoLabel
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
int ClipLeader(double xL[3], int stringSize[2], double p1[3], double ray[3], double c1[3], double c2[3])
vtkTextMapper * LabelMapper
void SetArrowPlacementToPoint1()
int RenderOverlay(vtkViewport *viewport) override
Methods required by vtkProp and vtkActor2D superclasses.
vtkActor2D * LeaderActor
static vtkLeaderActor2D * New()
Instantiate object.
represent and manipulate 3D points
Definition: vtkPoints.h:34
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:54
2D text annotation
Definition: vtkTextMapper.h:48
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:33
abstract specification for Viewports
Definition: vtkViewport.h:45
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
@ center
Definition: vtkX3D.h:236
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_FLOAT_MAX
Definition: vtkType.h:163