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) VTK_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,int);
173  vtkGetMacro(AutoLabel,int);
174  vtkBooleanMacro(AutoLabel,int);
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) VTK_OVERRIDE;
199  int RenderOpaqueGeometry(vtkViewport* viewport) VTK_OVERRIDE;
200  int RenderTranslucentPolygonalGeometry(vtkViewport *) VTK_OVERRIDE {return 0;}
202 
206  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
207 
208  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
209  void ShallowCopy(vtkProp *prop) VTK_OVERRIDE;
210 
211 protected:
213  ~vtkLeaderActor2D() VTK_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 
231  int AutoLabel;
232  char *LabelFormat;
233  char *Label;
234  double LabelFactor;
235  vtkTextMapper *LabelMapper;
236  vtkActor2D *LabelActor;
237  vtkTextProperty *LabelTextProperty;
238 
239  int ArrowPlacement;
240  int ArrowStyle;
241  double ArrowLength;
242  double ArrowWidth;
243  double MinimumArrowSize;
244  double MaximumArrowSize;
245 
246  vtkPoints *LeaderPoints;
247  vtkCellArray *LeaderLines;
248  vtkCellArray *LeaderArrows;
249  vtkPolyData *Leader;
250  vtkPolyDataMapper2D *LeaderMapper;
251  vtkActor2D *LeaderActor;
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&) VTK_DELETE_FUNCTION;
261  void operator=(const vtkLeaderActor2D&) VTK_DELETE_FUNCTION;
262 };
263 
264 
265 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
vtkTimeStamp BuildTime
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
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.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
#define VTK_FLOAT_MAX
Definition: vtkType.h:165
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...
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
represent text properties.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.
void SetArrowPlacementToBoth()
Control whether arrow heads are drawn on the leader.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.