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 =========================================================================*/
58 #ifndef vtkAxisActor2D_h
59 #define vtkAxisActor2D_h
60 
61 #include "vtkRenderingAnnotationModule.h" // For export macro
62 #include "vtkActor2D.h"
63 
65 class vtkPolyData;
66 class vtkTextMapper;
67 class vtkTextProperty;
68 
69 class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor2D : public vtkActor2D
70 {
71 public:
72  vtkTypeMacro(vtkAxisActor2D,vtkActor2D);
73  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
78  static vtkAxisActor2D *New();
79 
81 
86  { return this->GetPositionCoordinate(); };
87  virtual void SetPoint1(double x[2]) { this->SetPosition(x); };
88  virtual void SetPoint1(double x, double y) { this->SetPosition(x,y); };
89  virtual double *GetPoint1() { return this->GetPosition(); };
91 
93 
100  { return this->GetPosition2Coordinate(); };
101  virtual void SetPoint2(double x[2]) { this->SetPosition2(x); };
102  virtual void SetPoint2(double x, double y) { this->SetPosition2(x,y); };
103  virtual double *GetPoint2() { return this->GetPosition2(); };
105 
107 
111  vtkSetVector2Macro(Range,double);
112  vtkGetVectorMacro(Range,double,2);
114 
116 
121  vtkSetMacro(RulerMode,vtkTypeBool);
122  vtkGetMacro(RulerMode,vtkTypeBool);
123  vtkBooleanMacro(RulerMode,vtkTypeBool);
125 
127 
131  vtkSetClampMacro(RulerDistance,double,0,VTK_FLOAT_MAX);
132  vtkGetMacro(RulerDistance,double);
134 
135  enum LabelMax
136  {
137  VTK_MAX_LABELS = 25
138  };
139 
141 
146  vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
147  vtkGetMacro(NumberOfLabels, int);
149 
151 
155  vtkSetStringMacro(LabelFormat);
156  vtkGetStringMacro(LabelFormat);
158 
160 
168  vtkSetMacro(AdjustLabels, vtkTypeBool);
169  vtkGetMacro(AdjustLabels, vtkTypeBool);
170  vtkBooleanMacro(AdjustLabels, vtkTypeBool);
171  virtual double *GetAdjustedRange()
172  {
173  this->UpdateAdjustedRange();
174  return this->AdjustedRange;
175  }
176  virtual void GetAdjustedRange(double &_arg1, double &_arg2)
177  {
178  this->UpdateAdjustedRange();
179  _arg1 = this->AdjustedRange[0];
180  _arg2 = this->AdjustedRange[1];
181  };
182  virtual void GetAdjustedRange(double _arg[2])
183  {
184  this->GetAdjustedRange(_arg[0], _arg[1]);
185  }
187  {
188  this->UpdateAdjustedRange();
189  return this->AdjustedNumberOfLabels;
190  }
192 
194 
197  vtkSetStringMacro(Title);
198  vtkGetStringMacro(Title);
200 
202 
205  virtual void SetTitleTextProperty(vtkTextProperty *p);
206  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
208 
210 
213  virtual void SetLabelTextProperty(vtkTextProperty *p);
214  vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
216 
218 
222  vtkSetClampMacro(TickLength, int, 0, 100);
223  vtkGetMacro(TickLength, int);
225 
227 
231  vtkSetClampMacro(NumberOfMinorTicks, int, 0, 20);
232  vtkGetMacro(NumberOfMinorTicks, int);
234 
236 
240  vtkSetClampMacro(MinorTickLength, int, 0, 100);
241  vtkGetMacro(MinorTickLength, int);
243 
245 
250  vtkSetClampMacro(TickOffset, int, 0, 100);
251  vtkGetMacro(TickOffset, int);
253 
255 
258  vtkSetMacro(AxisVisibility, vtkTypeBool);
259  vtkGetMacro(AxisVisibility, vtkTypeBool);
260  vtkBooleanMacro(AxisVisibility, vtkTypeBool);
262 
264 
267  vtkSetMacro(TickVisibility, vtkTypeBool);
268  vtkGetMacro(TickVisibility, vtkTypeBool);
269  vtkBooleanMacro(TickVisibility, vtkTypeBool);
271 
273 
276  vtkSetMacro(LabelVisibility, vtkTypeBool);
277  vtkGetMacro(LabelVisibility, vtkTypeBool);
278  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
280 
282 
285  vtkSetMacro(TitleVisibility, vtkTypeBool);
286  vtkGetMacro(TitleVisibility, vtkTypeBool);
287  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
289 
291 
295  vtkSetMacro(TitlePosition, double);
296  vtkGetMacro(TitlePosition, double);
298 
300 
305  vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
306  vtkGetMacro(FontFactor, double);
308 
310 
314  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
315  vtkGetMacro(LabelFactor, double);
317 
319 
322  int RenderOverlay(vtkViewport* viewport) override;
323  int RenderOpaqueGeometry(vtkViewport* viewport) override;
326 
330  int HasTranslucentPolygonalGeometry() override;
331 
337  void ReleaseGraphicsResources(vtkWindow *) override;
338 
349  static void ComputeRange(double inRange[2],
350  double outRange[2],
351  int inNumTicks,
352  int &outNumTicks,
353  double &interval);
354 
363  static int SetMultipleFontSize(vtkViewport *viewport,
364  vtkTextMapper **textMappers,
365  int nbOfMappers,
366  int *targetSize,
367  double factor,
368  int *stringSize);
369 
371 
375  vtkSetMacro(SizeFontRelativeToAxis,vtkTypeBool);
376  vtkGetMacro(SizeFontRelativeToAxis,vtkTypeBool);
377  vtkBooleanMacro(SizeFontRelativeToAxis,vtkTypeBool);
379 
381 
386  vtkSetMacro(UseFontSizeFromProperty,vtkTypeBool);
387  vtkGetMacro(UseFontSizeFromProperty,vtkTypeBool);
388  vtkBooleanMacro(UseFontSizeFromProperty,vtkTypeBool);
390 
394  void ShallowCopy(vtkProp *prop) override;
395 
396 protected:
397  vtkAxisActor2D();
398  ~vtkAxisActor2D() override;
399 
402 
403  char *Title;
404  double Range[2];
409  char *LabelFormat;
411  double FontFactor;
412  double LabelFactor;
417 
418  double AdjustedRange[2];
421 
426 
427  int LastPosition[2];
428  int LastPosition2[2];
429 
430  int LastSize[2];
431  int LastMaxLabelSize[2];
432 
435 
436  virtual void BuildAxis(vtkViewport *viewport);
437  static double ComputeStringOffset(double width, double height, double theta);
438  static void SetOffsetPosition(double xTick[3], double theta,
439  int stringWidth, int stringHeight,
440  int offset, vtkActor2D *actor);
441  virtual void UpdateAdjustedRange();
442 
445 
448 
452 
455 
456 private:
457  vtkAxisActor2D(const vtkAxisActor2D&) = delete;
458  void operator=(const vtkAxisActor2D&) = delete;
459 };
460 
461 
462 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
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:44
virtual double * GetPoint1()
Specify the position of the first point defining the axis.
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
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:79
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:47
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:34
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:33
vtkTypeBool LabelVisibility
int HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
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:75
vtkTypeBool AxisVisibility
virtual void SetPoint1(double x[2])
Specify the position of the first point defining the axis.
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