VTK  9.2.20221001
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 =========================================================================*/
46 #ifndef vtkLeaderActor2D_h
47 #define vtkLeaderActor2D_h
48 
49 #include "vtkActor2D.h"
50 #include "vtkRenderingAnnotationModule.h" // For export macro
51 
52 VTK_ABI_NAMESPACE_BEGIN
53 class vtkPoints;
54 class vtkCellArray;
55 class vtkPolyData;
57 class vtkTextMapper;
58 class vtkTextProperty;
59 
60 class VTKRENDERINGANNOTATION_EXPORT vtkLeaderActor2D : public vtkActor2D
61 {
62 public:
63  vtkTypeMacro(vtkLeaderActor2D, vtkActor2D);
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
69  static vtkLeaderActor2D* New();
70 
72 
84  vtkSetMacro(Radius, double);
85  vtkGetMacro(Radius, double);
87 
89 
93  vtkSetStringMacro(Label);
94  vtkGetStringMacro(Label);
96 
98 
102  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
104 
106 
110  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
111  vtkGetMacro(LabelFactor, double);
113 
114  // Enums defined to support methods for control of arrow placement and
115  // and appearance of arrow heads.
116  enum
117  {
118  VTK_ARROW_NONE = 0,
121  VTK_ARROW_BOTH
122  };
123  enum
124  {
125  VTK_ARROW_FILLED = 0,
127  VTK_ARROW_HOLLOW
128  };
129 
131 
135  vtkSetClampMacro(ArrowPlacement, int, VTK_ARROW_NONE, VTK_ARROW_BOTH);
136  vtkGetMacro(ArrowPlacement, int);
137  void SetArrowPlacementToNone() { this->SetArrowPlacement(VTK_ARROW_NONE); }
138  void SetArrowPlacementToPoint1() { this->SetArrowPlacement(VTK_ARROW_POINT1); }
139  void SetArrowPlacementToPoint2() { this->SetArrowPlacement(VTK_ARROW_POINT2); }
140  void SetArrowPlacementToBoth() { this->SetArrowPlacement(VTK_ARROW_BOTH); }
142 
144 
149  vtkSetClampMacro(ArrowStyle, int, VTK_ARROW_FILLED, VTK_ARROW_HOLLOW);
150  vtkGetMacro(ArrowStyle, int);
151  void SetArrowStyleToFilled() { this->SetArrowStyle(VTK_ARROW_FILLED); }
152  void SetArrowStyleToOpen() { this->SetArrowStyle(VTK_ARROW_OPEN); }
153  void SetArrowStyleToHollow() { this->SetArrowStyle(VTK_ARROW_HOLLOW); }
155 
157 
161  vtkSetClampMacro(ArrowLength, double, 0.0, 1.0);
162  vtkGetMacro(ArrowLength, double);
163  vtkSetClampMacro(ArrowWidth, double, 0.0, 1.0);
164  vtkGetMacro(ArrowWidth, double);
166 
168 
174  vtkSetClampMacro(MinimumArrowSize, double, 1.0, VTK_FLOAT_MAX);
175  vtkGetMacro(MinimumArrowSize, double);
176  vtkSetClampMacro(MaximumArrowSize, double, 1.0, VTK_FLOAT_MAX);
177  vtkGetMacro(MaximumArrowSize, double);
179 
181 
187  vtkSetMacro(AutoLabel, vtkTypeBool);
188  vtkGetMacro(AutoLabel, vtkTypeBool);
189  vtkBooleanMacro(AutoLabel, vtkTypeBool);
191 
193 
196  vtkSetStringMacro(LabelFormat);
197  vtkGetStringMacro(LabelFormat);
199 
201 
205  vtkGetMacro(Length, double);
206  vtkGetMacro(Angle, double);
208 
210 
213  int RenderOverlay(vtkViewport* viewport) override;
214  int RenderOpaqueGeometry(vtkViewport* viewport) override;
215  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
217 
222 
224  void ShallowCopy(vtkProp* prop) override;
225 
227 
232  vtkSetMacro(UseFontSizeFromProperty, vtkTypeBool);
233  vtkGetMacro(UseFontSizeFromProperty, vtkTypeBool);
234  vtkBooleanMacro(UseFontSizeFromProperty, vtkTypeBool);
236 
237 protected:
239  ~vtkLeaderActor2D() override;
240 
241  // Internal helper methods
242  virtual void BuildLeader(vtkViewport* viewport);
243  int SetFontSize(vtkViewport* viewport, vtkTextMapper* textMapper, const int* targetSize,
244  double factor, int* stringSize);
246  double xL[3], int stringSize[2], double p1[3], double ray[3], double c1[3], double c2[3]);
247  void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength, double theta,
248  vtkViewport* viewport, int viewportChanged);
249  int InStringBox(double center[3], int stringSize[2], double x[3]);
250 
251  // Characteristics of the leader
252  double Radius;
253  double Length;
254  double Angle;
255 
257  char* LabelFormat;
258  char* Label;
259  double LabelFactor;
263 
265 
268  double ArrowLength;
269  double ArrowWidth;
272 
279 
280  // Internal ivars for tracking whether to rebuild
281  int LastPosition[2];
282  int LastPosition2[2];
283  int LastSize[2];
285 
286 private:
287  vtkLeaderActor2D(const vtkLeaderActor2D&) = delete;
288  void operator=(const vtkLeaderActor2D&) = delete;
289 };
290 
291 VTK_ABI_NAMESPACE_END
292 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:156
object to represent cell connectivity
Definition: vtkCellArray.h:297
a simple class to control print indentation
Definition: vtkIndent.h:120
create a leader with optional label and arrows
vtkCellArray * LeaderArrows
void SetArrowStyleToOpen()
Control the appearance of the arrow heads.
void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength, double theta, vtkViewport *viewport, int viewportChanged)
vtkActor2D * LabelActor
void SetArrowPlacementToNone()
Control whether arrow heads are drawn on the leader.
int InStringBox(double center[3], int stringSize[2], double x[3])
void SetArrowPlacementToBoth()
Control whether arrow heads are drawn on the leader.
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.
void SetArrowStyleToHollow()
Control the appearance of the arrow heads.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
void SetArrowStyleToFilled()
Control the appearance of the arrow heads.
vtkPolyDataMapper2D * LeaderMapper
virtual void BuildLeader(vtkViewport *viewport)
int RenderOpaqueGeometry(vtkViewport *viewport) override
Methods required by vtkProp and vtkActor2D superclasses.
~vtkLeaderActor2D() override
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods required by vtkProp and vtkActor2D superclasses.
vtkPolyData * Leader
void SetArrowPlacementToPoint2()
Control whether arrow heads are drawn on the leader.
vtkTextProperty * LabelTextProperty
vtkTypeBool AutoLabel
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
vtkTypeBool UseFontSizeFromProperty
int ClipLeader(double xL[3], int stringSize[2], double p1[3], double ray[3], double c1[3], double c2[3])
vtkTextMapper * LabelMapper
void SetArrowPlacementToPoint1()
Control whether arrow heads are drawn on the leader.
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:150
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:201
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:77
2D text annotation
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:56
abstract specification for Viewports
Definition: vtkViewport.h:57
window superclass for vtkRenderWindow
Definition: vtkWindow.h:40
@ center
Definition: vtkX3D.h:242
int vtkTypeBool
Definition: vtkABI.h:71
#define VTK_FLOAT_MAX
Definition: vtkType.h:163