VTK
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 "vtkRenderingAnnotationModule.h" // For export macro
50 #include "vtkActor2D.h"
51 
52 class vtkPoints;
53 class vtkCellArray;
54 class vtkPolyData;
56 class vtkTextMapper;
57 class vtkTextProperty;
58 
59 class VTKRENDERINGANNOTATION_EXPORT vtkLeaderActor2D : public vtkActor2D
60 {
61 public:
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
68  static vtkLeaderActor2D *New();
69 
71 
83  vtkSetMacro(Radius,double);
84  vtkGetMacro(Radius,double);
86 
88 
92  vtkSetStringMacro(Label);
93  vtkGetStringMacro(Label);
95 
97 
100  virtual void SetLabelTextProperty(vtkTextProperty *p);
101  vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
103 
105 
109  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
110  vtkGetMacro(LabelFactor, double);
112 
113  // Enums defined to support methods for control of arrow placement and
114  // and appearance of arrow heads.
115  enum {VTK_ARROW_NONE=0,VTK_ARROW_POINT1,VTK_ARROW_POINT2,VTK_ARROW_BOTH};
116  enum {VTK_ARROW_FILLED=0,VTK_ARROW_OPEN,VTK_ARROW_HOLLOW};
117 
119 
123  vtkSetClampMacro(ArrowPlacement,int,VTK_ARROW_NONE,VTK_ARROW_BOTH);
124  vtkGetMacro(ArrowPlacement,int);
125  void SetArrowPlacementToNone() {this->SetArrowPlacement(VTK_ARROW_NONE);}
126  void SetArrowPlacementToPoint1() {this->SetArrowPlacement(VTK_ARROW_POINT1);}
127  void SetArrowPlacementToPoint2() {this->SetArrowPlacement(VTK_ARROW_POINT2);}
128  void SetArrowPlacementToBoth() {this->SetArrowPlacement(VTK_ARROW_BOTH);}
130 
132 
137  vtkSetClampMacro(ArrowStyle,int,VTK_ARROW_FILLED,VTK_ARROW_HOLLOW);
138  vtkGetMacro(ArrowStyle,int);
139  void SetArrowStyleToFilled() {this->SetArrowStyle(VTK_ARROW_FILLED);}
140  void SetArrowStyleToOpen() {this->SetArrowStyle(VTK_ARROW_OPEN);}
141  void SetArrowStyleToHollow() {this->SetArrowStyle(VTK_ARROW_HOLLOW);}
143 
145 
149  vtkSetClampMacro(ArrowLength,double,0.0,1.0);
150  vtkGetMacro(ArrowLength,double);
151  vtkSetClampMacro(ArrowWidth,double,0.0,1.0);
152  vtkGetMacro(ArrowWidth,double);
154 
156 
162  vtkSetClampMacro(MinimumArrowSize,double,1.0,VTK_FLOAT_MAX);
163  vtkGetMacro(MinimumArrowSize,double);
164  vtkSetClampMacro(MaximumArrowSize,double,1.0,VTK_FLOAT_MAX);
165  vtkGetMacro(MaximumArrowSize,double);
167 
169 
175  vtkSetMacro(AutoLabel,vtkTypeBool);
176  vtkGetMacro(AutoLabel,vtkTypeBool);
177  vtkBooleanMacro(AutoLabel,vtkTypeBool);
179 
181 
184  vtkSetStringMacro(LabelFormat);
185  vtkGetStringMacro(LabelFormat);
187 
189 
193  vtkGetMacro(Length,double);
194  vtkGetMacro(Angle,double);
196 
198 
201  int RenderOverlay(vtkViewport* viewport) override;
202  int RenderOpaqueGeometry(vtkViewport* viewport) override;
205 
210 
211  void ReleaseGraphicsResources(vtkWindow *) override;
212  void ShallowCopy(vtkProp *prop) override;
213 
214 protected:
216  ~vtkLeaderActor2D() override;
217 
218  // Internal helper methods
219  virtual void BuildLeader(vtkViewport *viewport);
220  int SetFontSize(vtkViewport *viewport, vtkTextMapper *textMapper,
221  int *targetSize, double factor, int *stringSize);
222  int ClipLeader(double xL[3], int stringSize[2], double p1[3], double ray[3],
223  double c1[3], double c2[3]);
224  void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength,
225  double theta, vtkViewport *viewport, int viewportChanged);
226  int InStringBox(double center[3], int stringSize[2], double x[3]);
227 
228 
229  // Characteristics of the leader
230  double Radius;
231  double Length;
232  double Angle;
233 
235  char *LabelFormat;
236  char *Label;
237  double LabelFactor;
241 
244  double ArrowLength;
245  double ArrowWidth;
248 
255 
256  // Internal ivars for tracking whether to rebuild
257  int LastPosition[2];
258  int LastPosition2[2];
259  int LastSize[2];
261 
262 private:
263  vtkLeaderActor2D(const vtkLeaderActor2D&) = delete;
264  void operator=(const vtkLeaderActor2D&) = delete;
265 };
266 
267 
268 #endif
vtkCellArray * LeaderArrows
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkActor2D * LeaderActor
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
vtkTextProperty * LabelTextProperty
vtkPoints * LeaderPoints
abstract specification for Viewports
Definition: vtkViewport.h:47
void SetArrowStyleToFilled()
Control the appearance of the arrow heads.
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
void SetArrowStyleToHollow()
Control the appearance of the arrow heads.
vtkTypeBool AutoLabel
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
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:53
void SetArrowPlacementToNone()
Control whether arrow heads are drawn on the leader.
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
#define VTK_FLOAT_MAX
Definition: vtkType.h:167
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:39
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 HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
object to represent cell connectivity
Definition: vtkCellArray.h:50
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.
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:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.