VTK  9.7.1
vtkLeaderActor2D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
34 #ifndef vtkLeaderActor2D_h
35 #define vtkLeaderActor2D_h
36 
37 #include "vtkActor2D.h"
38 #include "vtkRenderingAnnotationModule.h" // For export macro
39 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkPoints;
43 class vtkCellArray;
44 class vtkPolyData;
46 class vtkTextMapper;
47 class vtkTextProperty;
48 
49 class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkLeaderActor2D : public vtkActor2D
50 {
51 public:
52  vtkTypeMacro(vtkLeaderActor2D, vtkActor2D);
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
58  static vtkLeaderActor2D* New();
59 
61 
73  vtkSetMacro(Radius, double);
74  vtkGetMacro(Radius, double);
76 
78 
82  vtkSetStringMacro(Label);
83  vtkGetStringMacro(Label);
85 
87 
90  virtual void SetLabelTextProperty(vtkTextProperty* p);
91  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
93 
95 
99  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
100  vtkGetMacro(LabelFactor, double);
102 
103  // Enums defined to support methods for control of arrow placement and
104  // and appearance of arrow heads.
105  enum
106  {
107  VTK_ARROW_NONE = 0,
110  VTK_ARROW_BOTH
111  };
112  enum
113  {
114  VTK_ARROW_FILLED = 0,
116  VTK_ARROW_HOLLOW
117  };
118 
120 
124  vtkSetClampMacro(ArrowPlacement, int, VTK_ARROW_NONE, VTK_ARROW_BOTH);
125  vtkGetMacro(ArrowPlacement, int);
126  void SetArrowPlacementToNone() { this->SetArrowPlacement(VTK_ARROW_NONE); }
127  void SetArrowPlacementToPoint1() { this->SetArrowPlacement(VTK_ARROW_POINT1); }
128  void SetArrowPlacementToPoint2() { this->SetArrowPlacement(VTK_ARROW_POINT2); }
129  void SetArrowPlacementToBoth() { this->SetArrowPlacement(VTK_ARROW_BOTH); }
131 
133 
138  vtkSetClampMacro(ArrowStyle, int, VTK_ARROW_FILLED, VTK_ARROW_HOLLOW);
139  vtkGetMacro(ArrowStyle, int);
140  void SetArrowStyleToFilled() { this->SetArrowStyle(VTK_ARROW_FILLED); }
141  void SetArrowStyleToOpen() { this->SetArrowStyle(VTK_ARROW_OPEN); }
142  void SetArrowStyleToHollow() { this->SetArrowStyle(VTK_ARROW_HOLLOW); }
144 
146 
150  vtkSetClampMacro(ArrowLength, double, 0.0, 1.0);
151  vtkGetMacro(ArrowLength, double);
152  vtkSetClampMacro(ArrowWidth, double, 0.0, 1.0);
153  vtkGetMacro(ArrowWidth, double);
155 
157 
163  vtkSetClampMacro(MinimumArrowSize, double, 1.0, VTK_FLOAT_MAX);
164  vtkGetMacro(MinimumArrowSize, double);
165  vtkSetClampMacro(MaximumArrowSize, double, 1.0, VTK_FLOAT_MAX);
166  vtkGetMacro(MaximumArrowSize, double);
168 
170 
176  vtkSetMacro(AutoLabel, vtkTypeBool);
177  vtkGetMacro(AutoLabel, vtkTypeBool);
178  vtkBooleanMacro(AutoLabel, vtkTypeBool);
180 
182 
185  vtkSetStringMacro(LabelFormat);
186  vtkGetStringMacro(LabelFormat);
188 
190 
194  vtkGetMacro(Length, double);
195  vtkGetMacro(Angle, double);
197 
199 
202  int RenderOverlay(vtkViewport* viewport) override;
203  int RenderOpaqueGeometry(vtkViewport* viewport) override;
204  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
206 
211 
212  void ReleaseGraphicsResources(vtkWindow*) override;
213  void ShallowCopy(vtkProp* prop) override;
214 
216 
221  vtkSetMacro(UseFontSizeFromProperty, vtkTypeBool);
222  vtkGetMacro(UseFontSizeFromProperty, vtkTypeBool);
223  vtkBooleanMacro(UseFontSizeFromProperty, vtkTypeBool);
225 
226 protected:
228  ~vtkLeaderActor2D() override;
229 
230  // Internal helper methods
231  virtual void BuildLeader(vtkViewport* viewport);
232  int SetFontSize(vtkViewport* viewport, vtkTextMapper* textMapper, const int* targetSize,
233  double factor, int* stringSize);
234  int ClipLeader(
235  double xL[3], int stringSize[2], double p1[3], double ray[3], double c1[3], double c2[3]);
236  void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength, double theta,
237  vtkViewport* viewport, int viewportChanged);
238  int InStringBox(double center[3], int stringSize[2], double x[3]);
239 
240  // Characteristics of the leader
241  double Radius;
242  double Length;
243  double Angle;
244 
246  char* LabelFormat;
247  char* Label;
248  double LabelFactor;
252 
254 
257  double ArrowLength;
258  double ArrowWidth;
261 
268 
269  // Internal ivars for tracking whether to rebuild
270  int LastPosition[2];
271  int LastPosition2[2];
272  int LastSize[2];
274 
275 private:
276  vtkLeaderActor2D(const vtkLeaderActor2D&) = delete;
277  void operator=(const vtkLeaderActor2D&) = delete;
278 };
279 
280 VTK_ABI_NAMESPACE_END
281 #endif
vtkCellArray * LeaderArrows
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
vtkActor2D * LeaderActor
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
vtkTextProperty * LabelTextProperty
vtkPoints * LeaderPoints
abstract specification for Viewports
Definition: vtkViewport.h:46
void SetArrowStyleToFilled()
Control the appearance of the arrow heads.
a actor that draws 2D data
Definition: vtkActor2D.h:35
record modification and/or execution time
Definition: vtkTimeStamp.h:24
void SetArrowStyleToHollow()
Control the appearance of the arrow heads.
vtkTypeBool AutoLabel
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkActor2D.
void SetArrowPlacementToPoint1()
Control whether arrow heads are drawn on the leader.
2D text annotation
Definition: vtkTextMapper.h:39
void SetArrowPlacementToNone()
Control whether arrow heads are drawn on the leader.
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
#define VTK_FLOAT_MAX
Definition: vtkType.h:200
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
vtkPolyData * Leader
a simple class to control print indentation
Definition: vtkIndent.h:28
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods required by vtkProp and vtkActor2D superclasses.
create a leader with optional label and arrows
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
vtkCellArray * LeaderLines
represent text properties.
vtkTypeBool UseFontSizeFromProperty
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
object to represent cell connectivity
Definition: vtkCellArray.h:177
void SetArrowStyleToOpen()
Control the appearance of the arrow heads.
void SetArrowPlacementToPoint2()
Control whether arrow heads are drawn on the leader.
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
#define VTK_MARSHALAUTO
vtkActor2D * LabelActor
void SetArrowPlacementToBoth()
Control whether arrow heads are drawn on the leader.
vtkPolyDataMapper2D * LeaderMapper
vtkTextMapper * LabelMapper
vtkTimeStamp BuildTime
draw vtkPolyData onto the image plane
represent and manipulate 3D points
Definition: vtkPoints.h:30
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.