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) VTK_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,int);
122  vtkGetMacro(RulerMode,int);
123  vtkBooleanMacro(RulerMode,int);
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, int);
169  vtkGetMacro(AdjustLabels, int);
170  vtkBooleanMacro(AdjustLabels, int);
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, int);
259  vtkGetMacro(AxisVisibility, int);
260  vtkBooleanMacro(AxisVisibility, int);
262 
264 
267  vtkSetMacro(TickVisibility, int);
268  vtkGetMacro(TickVisibility, int);
269  vtkBooleanMacro(TickVisibility, int);
271 
273 
276  vtkSetMacro(LabelVisibility, int);
277  vtkGetMacro(LabelVisibility, int);
278  vtkBooleanMacro(LabelVisibility, int);
280 
282 
285  vtkSetMacro(TitleVisibility, int);
286  vtkGetMacro(TitleVisibility, int);
287  vtkBooleanMacro(TitleVisibility, int);
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) VTK_OVERRIDE;
323  int RenderOpaqueGeometry(vtkViewport* viewport) VTK_OVERRIDE;
324  int RenderTranslucentPolygonalGeometry(vtkViewport *) VTK_OVERRIDE {return 0;}
326 
330  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
331 
337  void ReleaseGraphicsResources(vtkWindow *) VTK_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,int);
376  vtkGetMacro(SizeFontRelativeToAxis,int);
377  vtkBooleanMacro(SizeFontRelativeToAxis,int);
379 
383  void ShallowCopy(vtkProp *prop) VTK_OVERRIDE;
384 
385 protected:
386  vtkAxisActor2D();
387  ~vtkAxisActor2D() VTK_OVERRIDE;
388 
391 
392  char *Title;
393  double Range[2];
398  char *LabelFormat;
400  double FontFactor;
401  double LabelFactor;
406 
407  double AdjustedRange[2];
410 
415 
416  int LastPosition[2];
417  int LastPosition2[2];
418 
419  int LastSize[2];
420  int LastMaxLabelSize[2];
421 
423 
424  virtual void BuildAxis(vtkViewport *viewport);
425  static double ComputeStringOffset(double width, double height, double theta);
426  static void SetOffsetPosition(double xTick[3], double theta,
427  int stringWidth, int stringHeight,
428  int offset, vtkActor2D *actor);
429  virtual void UpdateAdjustedRange();
430 
433 
436 
440 
443 
444 private:
445  vtkAxisActor2D(const vtkAxisActor2D&) VTK_DELETE_FUNCTION;
446  void operator=(const vtkAxisActor2D&) VTK_DELETE_FUNCTION;
447 };
448 
449 
450 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
virtual void GetAdjustedRange(double _arg[2])
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
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.
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 ...
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:165
vtkPolyDataMapper2D * AxisMapper
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
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.
virtual float * GetPosition()
Get the PositionCoordinate instance of vtkCoordinate.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
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:72
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.