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 =========================================================================*/
43 #ifndef vtkLeaderActor2D_h
44 #define vtkLeaderActor2D_h
45 
46 #include "vtkRenderingAnnotationModule.h" // For export macro
47 #include "vtkActor2D.h"
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:
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 
97  virtual void SetLabelTextProperty(vtkTextProperty *p);
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 {VTK_ARROW_NONE=0,VTK_ARROW_POINT1,VTK_ARROW_POINT2,VTK_ARROW_BOTH};
113  enum {VTK_ARROW_FILLED=0,VTK_ARROW_OPEN,VTK_ARROW_HOLLOW};
114 
116 
120  vtkSetClampMacro(ArrowPlacement,int,VTK_ARROW_NONE,VTK_ARROW_BOTH);
121  vtkGetMacro(ArrowPlacement,int);
122  void SetArrowPlacementToNone() {this->SetArrowPlacement(VTK_ARROW_NONE);}
123  void SetArrowPlacementToPoint1() {this->SetArrowPlacement(VTK_ARROW_POINT1);}
124  void SetArrowPlacementToPoint2() {this->SetArrowPlacement(VTK_ARROW_POINT2);}
125  void SetArrowPlacementToBoth() {this->SetArrowPlacement(VTK_ARROW_BOTH);}
127 
129 
134  vtkSetClampMacro(ArrowStyle,int,VTK_ARROW_FILLED,VTK_ARROW_HOLLOW);
135  vtkGetMacro(ArrowStyle,int);
136  void SetArrowStyleToFilled() {this->SetArrowStyle(VTK_ARROW_FILLED);}
137  void SetArrowStyleToOpen() {this->SetArrowStyle(VTK_ARROW_OPEN);}
138  void SetArrowStyleToHollow() {this->SetArrowStyle(VTK_ARROW_HOLLOW);}
140 
142 
146  vtkSetClampMacro(ArrowLength,double,0.0,1.0);
147  vtkGetMacro(ArrowLength,double);
148  vtkSetClampMacro(ArrowWidth,double,0.0,1.0);
149  vtkGetMacro(ArrowWidth,double);
151 
153 
159  vtkSetClampMacro(MinimumArrowSize,double,1.0,VTK_FLOAT_MAX);
160  vtkGetMacro(MinimumArrowSize,double);
161  vtkSetClampMacro(MaximumArrowSize,double,1.0,VTK_FLOAT_MAX);
162  vtkGetMacro(MaximumArrowSize,double);
164 
166 
172  vtkSetMacro(AutoLabel,vtkTypeBool);
173  vtkGetMacro(AutoLabel,vtkTypeBool);
174  vtkBooleanMacro(AutoLabel,vtkTypeBool);
176 
178 
181  vtkSetStringMacro(LabelFormat);
182  vtkGetStringMacro(LabelFormat);
184 
186 
190  vtkGetMacro(Length,double);
191  vtkGetMacro(Angle,double);
193 
195 
198  int RenderOverlay(vtkViewport* viewport) override;
199  int RenderOpaqueGeometry(vtkViewport* viewport) override;
202 
206  int HasTranslucentPolygonalGeometry() override;
207 
208  void ReleaseGraphicsResources(vtkWindow *) override;
209  void ShallowCopy(vtkProp *prop) override;
210 
211 protected:
213  ~vtkLeaderActor2D() override;
214 
215  // Internal helper methods
216  virtual void BuildLeader(vtkViewport *viewport);
217  int SetFontSize(vtkViewport *viewport, vtkTextMapper *textMapper,
218  int *targetSize, double factor, int *stringSize);
219  int ClipLeader(double xL[3], int stringSize[2], double p1[3], double ray[3],
220  double c1[3], double c2[3]);
221  void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength,
222  double theta, vtkViewport *viewport, int viewportChanged);
223  int InStringBox(double center[3], int stringSize[2], double x[3]);
224 
225 
226  // Characteristics of the leader
227  double Radius;
228  double Length;
229  double Angle;
230 
232  char *LabelFormat;
233  char *Label;
234  double LabelFactor;
238 
241  double ArrowLength;
242  double ArrowWidth;
245 
252 
253  // Internal ivars for tracking whether to rebuild
254  int LastPosition[2];
255  int LastPosition2[2];
256  int LastSize[2];
258 
259 private:
260  vtkLeaderActor2D(const vtkLeaderActor2D&) = delete;
261  void operator=(const vtkLeaderActor2D&) = delete;
262 };
263 
264 
265 #endif
vtkCellArray * LeaderArrows
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkActor2D * LeaderActor
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
vtkTextProperty * LabelTextProperty
vtkPoints * LeaderPoints
abstract specification for Viewports
Definition: vtkViewport.h:44
void SetArrowStyleToFilled()
Control the appearance of the arrow heads.
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
void SetArrowStyleToHollow()
Control the appearance of the arrow heads.
vtkTypeBool AutoLabel
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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:47
void SetArrowPlacementToNone()
Control whether arrow heads are drawn on the leader.
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
#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:33
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods required by vtkProp and vtkActor2D superclasses.
int HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
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.
object to represent cell connectivity
Definition: vtkCellArray.h:44
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:33
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.