VTK
vtkAxisActor2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAxisActor2D.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 =========================================================================*/
61 #ifndef vtkAxisActor2D_h
62 #define vtkAxisActor2D_h
63 
64 #include "vtkRenderingAnnotationModule.h" // For export macro
65 #include "vtkActor2D.h"
66 
68 class vtkPolyData;
69 class vtkTextMapper;
70 class vtkTextProperty;
71 
72 class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor2D : public vtkActor2D
73 {
74 public:
75  vtkTypeMacro(vtkAxisActor2D,vtkActor2D);
76  void PrintSelf(ostream& os, vtkIndent indent) override;
77 
81  static vtkAxisActor2D *New();
82 
84 
89  { return this->GetPositionCoordinate(); };
90  virtual void SetPoint1(double x[2]) { this->SetPosition(x); };
91  virtual void SetPoint1(double x, double y) { this->SetPosition(x,y); };
92  virtual double *GetPoint1() { return this->GetPosition(); };
94 
96 
103  { return this->GetPosition2Coordinate(); };
104  virtual void SetPoint2(double x[2]) { this->SetPosition2(x); };
105  virtual void SetPoint2(double x, double y) { this->SetPosition2(x,y); };
106  virtual double *GetPoint2() { return this->GetPosition2(); };
108 
110 
114  vtkSetVector2Macro(Range,double);
115  vtkGetVectorMacro(Range,double,2);
117 
119 
124  vtkSetMacro(RulerMode,vtkTypeBool);
125  vtkGetMacro(RulerMode,vtkTypeBool);
126  vtkBooleanMacro(RulerMode,vtkTypeBool);
128 
130 
134  vtkSetClampMacro(RulerDistance,double,0,VTK_FLOAT_MAX);
135  vtkGetMacro(RulerDistance,double);
137 
138  enum LabelMax
139  {
140  VTK_MAX_LABELS = 25
141  };
142 
144 
149  vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
150  vtkGetMacro(NumberOfLabels, int);
152 
154 
158  vtkSetStringMacro(LabelFormat);
159  vtkGetStringMacro(LabelFormat);
161 
163 
171  vtkSetMacro(AdjustLabels, vtkTypeBool);
172  vtkGetMacro(AdjustLabels, vtkTypeBool);
173  vtkBooleanMacro(AdjustLabels, vtkTypeBool);
174  virtual double *GetAdjustedRange()
175  {
176  this->UpdateAdjustedRange();
177  return this->AdjustedRange;
178  }
179  virtual void GetAdjustedRange(double &_arg1, double &_arg2)
180  {
181  this->UpdateAdjustedRange();
182  _arg1 = this->AdjustedRange[0];
183  _arg2 = this->AdjustedRange[1];
184  };
185  virtual void GetAdjustedRange(double _arg[2])
186  {
187  this->GetAdjustedRange(_arg[0], _arg[1]);
188  }
190  {
191  this->UpdateAdjustedRange();
192  return this->AdjustedNumberOfLabels;
193  }
195 
197 
200  vtkSetStringMacro(Title);
201  vtkGetStringMacro(Title);
203 
205 
208  virtual void SetTitleTextProperty(vtkTextProperty *p);
209  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
211 
213 
216  virtual void SetLabelTextProperty(vtkTextProperty *p);
217  vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
219 
221 
225  vtkSetClampMacro(TickLength, int, 0, 100);
226  vtkGetMacro(TickLength, int);
228 
230 
234  vtkSetClampMacro(NumberOfMinorTicks, int, 0, 20);
235  vtkGetMacro(NumberOfMinorTicks, int);
237 
239 
243  vtkSetClampMacro(MinorTickLength, int, 0, 100);
244  vtkGetMacro(MinorTickLength, int);
246 
248 
253  vtkSetClampMacro(TickOffset, int, 0, 100);
254  vtkGetMacro(TickOffset, int);
256 
258 
261  vtkSetMacro(AxisVisibility, vtkTypeBool);
262  vtkGetMacro(AxisVisibility, vtkTypeBool);
263  vtkBooleanMacro(AxisVisibility, vtkTypeBool);
265 
267 
270  vtkSetMacro(TickVisibility, vtkTypeBool);
271  vtkGetMacro(TickVisibility, vtkTypeBool);
272  vtkBooleanMacro(TickVisibility, vtkTypeBool);
274 
276 
279  vtkSetMacro(LabelVisibility, vtkTypeBool);
280  vtkGetMacro(LabelVisibility, vtkTypeBool);
281  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
283 
285 
288  vtkSetMacro(TitleVisibility, vtkTypeBool);
289  vtkGetMacro(TitleVisibility, vtkTypeBool);
290  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
292 
294 
298  vtkSetMacro(TitlePosition, double);
299  vtkGetMacro(TitlePosition, double);
301 
303 
308  vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
309  vtkGetMacro(FontFactor, double);
311 
313 
317  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
318  vtkGetMacro(LabelFactor, double);
320 
322 
325  int RenderOverlay(vtkViewport* viewport) override;
326  int RenderOpaqueGeometry(vtkViewport* viewport) override;
329 
334 
340  void ReleaseGraphicsResources(vtkWindow *) override;
341 
352  static void ComputeRange(double inRange[2],
353  double outRange[2],
354  int inNumTicks,
355  int &outNumTicks,
356  double &interval);
357 
366  static int SetMultipleFontSize(vtkViewport *viewport,
367  vtkTextMapper **textMappers,
368  int nbOfMappers,
369  int *targetSize,
370  double factor,
371  int *stringSize);
372 
374 
378  vtkSetMacro(SizeFontRelativeToAxis,vtkTypeBool);
379  vtkGetMacro(SizeFontRelativeToAxis,vtkTypeBool);
380  vtkBooleanMacro(SizeFontRelativeToAxis,vtkTypeBool);
382 
384 
389  vtkSetMacro(UseFontSizeFromProperty,vtkTypeBool);
390  vtkGetMacro(UseFontSizeFromProperty,vtkTypeBool);
391  vtkBooleanMacro(UseFontSizeFromProperty,vtkTypeBool);
393 
397  void ShallowCopy(vtkProp *prop) override;
398 
399 protected:
400  vtkAxisActor2D();
401  ~vtkAxisActor2D() override;
402 
405 
406  char *Title;
407  double Range[2];
412  char *LabelFormat;
414  double FontFactor;
415  double LabelFactor;
420 
421  double AdjustedRange[2];
424 
429 
430  int LastPosition[2];
431  int LastPosition2[2];
432 
433  int LastSize[2];
434  int LastMaxLabelSize[2];
435 
438 
439  virtual void BuildAxis(vtkViewport *viewport);
440  static double ComputeStringOffset(double width, double height, double theta);
441  static void SetOffsetPosition(double xTick[3], double theta,
442  int stringWidth, int stringHeight,
443  int offset, vtkActor2D *actor);
444  virtual void UpdateAdjustedRange();
445 
448 
451 
455 
458 
459 private:
460  vtkAxisActor2D(const vtkAxisActor2D&) = delete;
461  void operator=(const vtkAxisActor2D&) = delete;
462 };
463 
464 
465 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
virtual void GetAdjustedRange(double _arg[2])
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
vtkTypeBool RulerMode
virtual void SetPosition(float x[2])
Get the PositionCoordinate instance of vtkCoordinate.
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
vtkActor2D * TitleActor
abstract specification for Viewports
Definition: vtkViewport.h:47
virtual double * GetPoint1()
Specify the position of the first point defining the axis.
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkActor2D ** LabelActors
virtual vtkCoordinate * GetPositionCoordinate()
Get the PositionCoordinate instance of vtkCoordinate.
Create an axis with tick marks and labels.
vtkTextProperty * TitleTextProperty
virtual void SetPoint1(double x, double y)
Specify the position of the first point defining the axis.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkActor2D.
vtkActor2D * AxisActor
virtual void SetPoint2(double x, double y)
Specify the position of the second point defining the axis.
virtual float * GetPosition2()
Access the Position2 instance variable.
vtkTypeBool TickVisibility
2D text annotation
Definition: vtkTextMapper.h:53
virtual vtkCoordinate * GetPoint2Coordinate()
Specify the position of the second point defining the axis.
virtual void GetAdjustedRange(double &_arg1, double &_arg2)
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
int vtkTypeBool
Definition: vtkABI.h:69
virtual vtkCoordinate * GetPoint1Coordinate()
Specify the position of the first point defining the axis.
vtkPolyData * Axis
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
virtual double * GetAdjustedRange()
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
vtkTimeStamp AdjustedRangeBuildTime
#define VTK_FLOAT_MAX
Definition: vtkType.h:167
vtkPolyDataMapper2D * AxisMapper
vtkTypeBool TitleVisibility
virtual double * GetPoint2()
Specify the position of the second point defining the axis.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTypeBool LabelVisibility
vtkTextMapper * TitleMapper
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
vtkTextMapper ** LabelMappers
virtual void SetPosition2(float x[2])
Access the Position2 instance variable.
vtkTypeBool UseFontSizeFromProperty
virtual float * GetPosition()
Get the PositionCoordinate instance of vtkCoordinate.
virtual void SetPoint2(double x[2])
Specify the position of the second point defining the axis.
virtual vtkCoordinate * GetPosition2Coordinate()
Access the Position2 instance variable.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the axis.
represent text properties.
vtkTextProperty * LabelTextProperty
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems ...
Definition: vtkCoordinate.h:81
vtkTypeBool AxisVisibility
virtual void SetPoint1(double x[2])
Specify the position of the first point defining the axis.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
virtual int GetAdjustedNumberOfLabels()
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
vtkTimeStamp BuildTime
draw vtkPolyData onto the image plane
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeBool AdjustLabels