VTK
vtkAxisActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkAxisActor.h
5 Language: C++
6 
7 Copyright (c) 1993-2000 Ken Martin, Will Schroeder, Bill Lorensen
8 All rights reserved.
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12 =========================================================================*/
56 #ifndef vtkAxisActor_h
57 #define vtkAxisActor_h
58 
59 #include "vtkRenderingAnnotationModule.h" // For export macro
60 #include "vtkActor.h"
61 
62 #define VTK_MAX_LABELS 200
63 #define VTK_MAX_TICKS 1000
64 
65 #define VTK_AXIS_TYPE_X 0
66 #define VTK_AXIS_TYPE_Y 1
67 #define VTK_AXIS_TYPE_Z 2
68 
69 #define VTK_TICKS_INSIDE 0
70 #define VTK_TICKS_OUTSIDE 1
71 #define VTK_TICKS_BOTH 2
72 
73 #define VTK_AXIS_POS_MINMIN 0
74 #define VTK_AXIS_POS_MINMAX 1
75 #define VTK_AXIS_POS_MAXMAX 2
76 #define VTK_AXIS_POS_MAXMIN 3
77 
78 class vtkAxisFollower;
79 class vtkCamera;
80 class vtkCoordinate;
81 class vtkFollower;
82 class vtkPoints;
83 class vtkPolyData;
84 class vtkPolyDataMapper;
86 class vtkProperty2D;
87 class vtkStringArray;
88 class vtkTextActor;
89 class vtkTextActor3D;
90 class vtkTextProperty;
91 class vtkVectorText;
92 
94 {
95  public:
96  vtkTypeMacro(vtkAxisActor,vtkActor);
97  void PrintSelf(ostream& os, vtkIndent indent);
98 
100  static vtkAxisActor *New();
101 
103 
104  virtual vtkCoordinate *GetPoint1Coordinate();
105  virtual void SetPoint1(double x[3])
106  { this->SetPoint1(x[0], x[1], x[2]); }
107  virtual void SetPoint1(double x, double y, double z);
108  virtual double *GetPoint1();
110 
112 
113  virtual vtkCoordinate *GetPoint2Coordinate();
114  virtual void SetPoint2(double x[3])
115  { this->SetPoint2(x[0], x[1], x[2]); }
116  virtual void SetPoint2(double x, double y, double z);
117  virtual double *GetPoint2();
119 
121 
123  vtkSetVector2Macro(Range,double);
124  vtkGetVectorMacro(Range,double,2);
126 
128 
130  void SetBounds(const double bounds[6]);
131  void SetBounds(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
132  double *GetBounds(void);
133  void GetBounds(double bounds[6]);
135 
137 
138  vtkSetStringMacro(LabelFormat);
139  vtkGetStringMacro(LabelFormat);
141 
143 
147  vtkSetMacro(UseTextActor3D, int);
148  vtkGetMacro(UseTextActor3D, int);
150 
152 
153  vtkSetMacro(MinorTicksVisible, int);
154  vtkGetMacro(MinorTicksVisible, int);
155  vtkBooleanMacro(MinorTicksVisible, int);
157 
159 
160  void SetTitle(const char *t);
161  vtkGetStringMacro(Title);
163 
165 
166  vtkSetMacro(MajorTickSize, double);
167  vtkGetMacro(MajorTickSize, double);
169 
171 
172  vtkSetMacro(MinorTickSize, double);
173  vtkGetMacro(MinorTickSize, double);
175 
177 
178  vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
179  vtkGetMacro(TickLocation, int);
181 
183  { this->SetTickLocation(VTK_TICKS_INSIDE); };
185  { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
187  { this->SetTickLocation(VTK_TICKS_BOTH); };
188 
190 
191  vtkSetMacro(AxisVisibility, int);
192  vtkGetMacro(AxisVisibility, int);
193  vtkBooleanMacro(AxisVisibility, int);
195 
197 
198  vtkSetMacro(TickVisibility, int);
199  vtkGetMacro(TickVisibility, int);
200  vtkBooleanMacro(TickVisibility, int);
202 
204 
205  vtkSetMacro(LabelVisibility, int);
206  vtkGetMacro(LabelVisibility, int);
207  vtkBooleanMacro(LabelVisibility, int);
209 
211 
212  vtkSetMacro(TitleVisibility, int);
213  vtkGetMacro(TitleVisibility, int);
214  vtkBooleanMacro(TitleVisibility, int);
216 
218 
219  virtual void SetTitleTextProperty(vtkTextProperty *p);
220  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
222 
224 
225  virtual void SetLabelTextProperty(vtkTextProperty *p);
226  vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
228 
230 
231  void SetAxisLinesProperty(vtkProperty *);
232  vtkProperty* GetAxisLinesProperty();
234 
236 
237  void SetGridlinesProperty(vtkProperty *);
238  vtkProperty* GetGridlinesProperty();
240 
242 
243  void SetInnerGridlinesProperty(vtkProperty *);
244  vtkProperty* GetInnerGridlinesProperty();
246 
248 
249  void SetGridpolysProperty(vtkProperty *);
250  vtkProperty* GetGridpolysProperty();
252 
254 
255  vtkSetMacro(DrawGridlines, int);
256  vtkGetMacro(DrawGridlines, int);
257  vtkBooleanMacro(DrawGridlines, int);
259 
261 
264  vtkSetMacro(DrawGridlinesOnly, int);
265  vtkGetMacro(DrawGridlinesOnly, int);
266  vtkBooleanMacro(DrawGridlinesOnly, int);
268 
269  vtkSetMacro(DrawGridlinesLocation, int);
270  vtkGetMacro(DrawGridlinesLocation, int);
271 
273 
274  vtkSetMacro(DrawInnerGridlines, int);
275  vtkGetMacro(DrawInnerGridlines, int);
276  vtkBooleanMacro(DrawInnerGridlines, int);
278 
280 
281  vtkSetMacro(GridlineXLength, double);
282  vtkGetMacro(GridlineXLength, double);
283  vtkSetMacro(GridlineYLength, double);
284  vtkGetMacro(GridlineYLength, double);
285  vtkSetMacro(GridlineZLength, double);
286  vtkGetMacro(GridlineZLength, double);
288 
290 
291  vtkSetMacro(DrawGridpolys, int);
292  vtkGetMacro(DrawGridpolys, int);
293  vtkBooleanMacro(DrawGridpolys, int);
295 
297 
298  vtkSetClampMacro(AxisType, int, VTK_AXIS_TYPE_X, VTK_AXIS_TYPE_Z);
299  vtkGetMacro(AxisType, int);
300  void SetAxisTypeToX(void) { this->SetAxisType(VTK_AXIS_TYPE_X); };
301  void SetAxisTypeToY(void) { this->SetAxisType(VTK_AXIS_TYPE_Y); };
302  void SetAxisTypeToZ(void) { this->SetAxisType(VTK_AXIS_TYPE_Z); };
304 
306 
311  vtkSetClampMacro(AxisPosition, int, VTK_AXIS_POS_MINMIN, VTK_AXIS_POS_MAXMIN);
312  vtkGetMacro(AxisPosition, int);
314 
316  { this->SetAxisPosition(VTK_AXIS_POS_MINMIN); };
318  { this->SetAxisPosition(VTK_AXIS_POS_MINMAX); };
320  { this->SetAxisPosition(VTK_AXIS_POS_MAXMAX); };
322  { this->SetAxisPosition(VTK_AXIS_POS_MAXMIN); };
323 
325 
327  virtual void SetCamera(vtkCamera*);
328  vtkGetObjectMacro(Camera, vtkCamera);
330 
332 
333  virtual int RenderOpaqueGeometry(vtkViewport* viewport);
334  virtual int RenderTranslucentGeometry(vtkViewport* viewport);
335  virtual int RenderTranslucentPolygonalGeometry(vtkViewport* viewport);
336  virtual int RenderOverlay(vtkViewport* viewport);
339 
344 
345 //BTX
346  double ComputeMaxLabelLength(const double [3]);
347  double ComputeTitleLength(const double [3]);
348 //ETX
349  void SetLabelScale(const double scale);
350  void SetLabelScale(int labelIndex, const double scale);
351  void SetTitleScale(const double scale);
352 
354 
356  vtkSetMacro(MinorStart, double);
357  vtkGetMacro(MinorStart, double);
358  double GetMajorStart(int axis);
359  void SetMajorStart(int axis,double value);
360  //vtkSetMacro(MajorStart, double);
361  //vtkGetMacro(MajorStart, double);
362  vtkSetMacro(DeltaMinor, double);
363  vtkGetMacro(DeltaMinor, double);
364  double GetDeltaMajor(int axis);
365  void SetDeltaMajor(int axis,double value);
366  //vtkSetMacro(DeltaMajor, double);
367  //vtkGetMacro(DeltaMajor, double);
369 
371 
375  vtkSetMacro(MinorRangeStart, double);
376  vtkGetMacro(MinorRangeStart, double);
377  vtkSetMacro(MajorRangeStart, double);
378  vtkGetMacro(MajorRangeStart, double);
379  vtkSetMacro(DeltaRangeMinor, double);
380  vtkGetMacro(DeltaRangeMinor, double);
381  vtkSetMacro(DeltaRangeMajor, double);
382  vtkGetMacro(DeltaRangeMajor, double);
384 
385 //BTX
386  void SetLabels(vtkStringArray *labels);
387 //ETX
388 
389  void BuildAxis(vtkViewport *viewport, bool);
390 
391 //BTX
393 
394  vtkGetObjectMacro(TitleActor, vtkAxisFollower);
396 
398 
400  {
401  return this->LabelActors;
402  }
404 
406 
407  vtkGetObjectMacro(TitleProp3D, vtkProp3DAxisFollower);
409 
411 
413  {
414  return this->LabelProps3D;
415  }
416 //ETX
418 
420 
422  vtkGetMacro(NumberOfLabelsBuilt, int);
424 
426 
427  vtkSetMacro(CalculateTitleOffset, int);
428  vtkGetMacro(CalculateTitleOffset, int);
429  vtkBooleanMacro(CalculateTitleOffset, int);
431 
433 
434  vtkSetMacro(CalculateLabelOffset, int);
435  vtkGetMacro(CalculateLabelOffset, int);
436  vtkBooleanMacro(CalculateLabelOffset, int);
438 
440 
441  vtkSetMacro(Use2DMode, int);
442  vtkGetMacro(Use2DMode, int);
444 
446 
447  vtkSetMacro(VerticalOffsetXTitle2D, double);
448  vtkGetMacro(VerticalOffsetXTitle2D, double);
450 
452 
453  vtkSetMacro(HorizontalOffsetYTitle2D, double);
454  vtkGetMacro(HorizontalOffsetYTitle2D, double);
456 
458 
459  vtkSetMacro(SaveTitlePosition, int);
460  vtkGetMacro(SaveTitlePosition, int);
462 
464 
465  vtkSetVector3Macro(AxisBaseForX, double);
466  vtkGetVector3Macro(AxisBaseForX, double);
468 
470 
471  vtkSetVector3Macro(AxisBaseForY, double);
472  vtkGetVector3Macro(AxisBaseForY, double);
474 
476 
477  vtkSetVector3Macro(AxisBaseForZ, double);
478  vtkGetVector3Macro(AxisBaseForZ, double);
480 
482 
483  vtkSetMacro(AxisOnOrigin,int);
484  vtkGetMacro(AxisOnOrigin,int);
486 
488 
489  vtkSetMacro(LabelOffset, double);
490  vtkGetMacro(LabelOffset, double);
491  vtkSetMacro(TitleOffset, double);
492  vtkGetMacro(TitleOffset, double);
493  vtkSetMacro(ScreenSize, double);
494  vtkGetMacro(ScreenSize, double);
496 
497  protected:
498  vtkAxisActor();
499  ~vtkAxisActor();
500 
501  char *Title;
502  double Range[2];
503  double LastRange[2];
504  char *LabelFormat;
510 
514  int DrawGridlinesLocation; // 0: all | 1: closest | 2: farest
515  int LastDrawGridlinesLocation; // 0: all | 1: closest | 2: farest
519 
522 
525 
531 
532  int AxisType;
534  double Bounds[6];
535 
536  double AxisBaseForX[3];
537  double AxisBaseForY[3];
538  double AxisBaseForZ[3];
539 
540  private:
541  vtkAxisActor(const vtkAxisActor&); // Not implemented
542  void operator=(const vtkAxisActor&); // Not implemented
543 
544  void TransformBounds(vtkViewport *, double bnds[6]);
545 
546  void BuildLabels(vtkViewport *, bool);
547  void BuildLabels2D(vtkViewport *, bool);
548  void SetLabelPositions(vtkViewport *, bool);
549  void SetLabelPositions2D(vtkViewport *, bool);
550 
551  void BuildTitle(bool);
552  void BuildTitle2D(vtkViewport *viewport, bool);
553 
554  void SetAxisPointsAndLines(void);
555  bool BuildTickPoints(double p1[3], double p2[3], bool force);
556 
557  bool TickVisibilityChanged(void);
558  vtkProperty *NewTitleProperty();
559  vtkProperty2D *NewTitleProperty2D();
560  vtkProperty *NewLabelProperty();
561 
562  bool BoundsDisplayCoordinateChanged(vtkViewport *viewport);
563 
564  vtkCoordinate *Point1Coordinate;
565  vtkCoordinate *Point2Coordinate;
566 
567  double MajorTickSize;
568  double MinorTickSize;
569 
570  // For each axis (for the inner gridline generation)
571  double MajorStart[3];
572  double DeltaMajor[3];
573  double MinorStart;
574  double DeltaMinor;
575 
576  // For the ticks, w.r.t to the set range
577  double MajorRangeStart;
578  double MinorRangeStart;
579  double DeltaRangeMinor;
580  double DeltaRangeMajor;
581 
582  int LastAxisPosition;
583  int LastAxisType;
584  int LastTickLocation;
585  double LastLabelStart;
586 
587  vtkPoints *MinorTickPts;
588  vtkPoints *MajorTickPts;
589  vtkPoints *GridlinePts;
590  vtkPoints *InnerGridlinePts;
591  vtkPoints *GridpolyPts;
592 
593  vtkVectorText *TitleVector;
594  vtkPolyDataMapper *TitleMapper;
595  vtkAxisFollower *TitleActor;
596  vtkTextActor *TitleActor2D;
597  vtkProp3DAxisFollower *TitleProp3D;
598  vtkTextActor3D *TitleActor3D;
599  vtkTextProperty *TitleTextProperty;
600 
601  vtkVectorText **LabelVectors;
602  vtkPolyDataMapper **LabelMappers;
603  vtkAxisFollower **LabelActors;
604  vtkProp3DAxisFollower **LabelProps3D;
605  vtkTextActor **LabelActors2D;
606  vtkTextActor3D **LabelActors3D;
607  vtkTextProperty *LabelTextProperty;
608 
609  vtkPolyData *AxisLines;
610  vtkPolyDataMapper *AxisLinesMapper;
611  vtkActor *AxisLinesActor;
612  vtkPolyData *Gridlines;
613  vtkPolyDataMapper *GridlinesMapper;
614  vtkActor *GridlinesActor;
615  vtkPolyData *InnerGridlines;
616  vtkPolyDataMapper *InnerGridlinesMapper;
617  vtkActor *InnerGridlinesActor;
618  vtkPolyData *Gridpolys;
619  vtkPolyDataMapper *GridpolysMapper;
620  vtkActor *GridpolysActor;
621 
622  vtkCamera *Camera;
624  vtkTimeStamp BuildTickPointsTime;
625  vtkTimeStamp BoundsTime;
626  vtkTimeStamp LabelBuildTime;
627  vtkTimeStamp TitleTextTime;
628 
629  int AxisOnOrigin;
630 
631  int AxisHasZeroLength;
632 
633  int CalculateTitleOffset;
634  int CalculateLabelOffset;
635 
637  int Use2DMode;
638 
641  double VerticalOffsetXTitle2D;
642 
645  double HorizontalOffsetYTitle2D;
646 
651  int SaveTitlePosition;
652 
654  double TitleConstantPosition[2];
655 
657  bool NeedBuild2D;
658 
659  double LastMinDisplayCoordinate[3];
660  double LastMaxDisplayCoordinate[3];
661 
663 
664  double ScreenSize;
665  double LabelOffset;
666  double TitleOffset;
667 };
669 
670 #endif
#define VTK_AXIS_TYPE_X
Definition: vtkAxisActor.h:65
virtual void SetPoint1(double x[3])
Definition: vtkAxisActor.h:105
double GridlineXLength
Definition: vtkAxisActor.h:516
vtkTimeStamp BuildTime
int DrawGridlinesOnly
Definition: vtkAxisActor.h:512
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
#define VTK_TICKS_OUTSIDE
Definition: vtkAxisActor.h:70
void SetAxisTypeToY(void)
Definition: vtkAxisActor.h:301
int LastMinorTicksVisible
Definition: vtkAxisActor.h:508
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport)
#define VTK_AXIS_POS_MAXMAX
Definition: vtkAxisActor.h:75
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:63
int LastDrawGridpolys
Definition: vtkAxisActor.h:524
int LastDrawInnerGridlines
Definition: vtkAxisActor.h:521
virtual void SetPoint2(double x[3])
Definition: vtkAxisActor.h:114
#define VTK_AXIS_TYPE_Z
Definition: vtkAxisActor.h:67
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:204
double GridlineZLength
Definition: vtkAxisActor.h:518
record modification and/or execution time
Definition: vtkTimeStamp.h:34
Create an axis with tick marks and labels.
Definition: vtkAxisActor.h:93
vtkProp3DAxisFollower ** GetLabelProps3D()
Definition: vtkAxisActor.h:412
a vtkAbstractArray subclass for strings
int LastDrawGridlines
Definition: vtkAxisActor.h:513
void SetTickLocationToInside(void)
Definition: vtkAxisActor.h:182
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
static vtkActor * New()
void PrintSelf(ostream &os, vtkIndent indent)
#define VTKRENDERINGANNOTATION_EXPORT
double GridlineYLength
Definition: vtkAxisActor.h:517
int DrawGridlinesLocation
Definition: vtkAxisActor.h:514
void SetAxisPositionToMaxMin(void)
Definition: vtkAxisActor.h:321
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
void SetAxisTypeToX(void)
Definition: vtkAxisActor.h:300
An actor that displays text. Scaled or unscaled.
Definition: vtkTextActor.h:54
a simple class to control print indentation
Definition: vtkIndent.h:38
a virtual camera for 3D rendering
Definition: vtkCamera.h:48
void SetAxisPositionToMaxMax(void)
Definition: vtkAxisActor.h:319
vtkAxisFollower ** GetLabelActors()
Definition: vtkAxisActor.h:399
void SetTickLocationToBoth(void)
Definition: vtkAxisActor.h:186
#define VTK_AXIS_POS_MAXMIN
Definition: vtkAxisActor.h:76
int LastTickVisibility
Definition: vtkAxisActor.h:528
#define VTK_TICKS_BOTH
Definition: vtkAxisActor.h:71
An actor that displays text.
#define VTK_AXIS_TYPE_Y
Definition: vtkAxisActor.h:66
int NumberOfLabelsBuilt
Definition: vtkAxisActor.h:506
represent text properties.
char * LabelFormat
Definition: vtkAxisActor.h:504
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems ...
Definition: vtkCoordinate.h:69
a subclass of vtkFollower that ensures that data is always parallel to the axis defined by a vtkAxisA...
double * GetBounds()
void SetAxisPositionToMinMax(void)
Definition: vtkAxisActor.h:317
map vtkPolyData to graphics primitives
void SetAxisPositionToMinMin(void)
Definition: vtkAxisActor.h:315
#define VTK_AXIS_POS_MINMAX
Definition: vtkAxisActor.h:74
a subclass of actor that always faces the camera
Definition: vtkFollower.h:45
virtual int RenderOpaqueGeometry(vtkViewport *viewport)
a subclass of vtkProp3DFollower that ensures that data is always parallel to the axis defined by a vt...
virtual int HasTranslucentPolygonalGeometry()
int MinorTicksVisible
Definition: vtkAxisActor.h:507
#define VTK_TICKS_INSIDE
Definition: vtkAxisActor.h:69
int LastDrawGridlinesLocation
Definition: vtkAxisActor.h:515
void ReleaseGraphicsResources(vtkWindow *)
represent surface properties of a 2D image
Definition: vtkProperty2D.h:39
void SetAxisTypeToZ(void)
Definition: vtkAxisActor.h:302
void SetTickLocationToOutside(void)
Definition: vtkAxisActor.h:184
#define VTK_AXIS_POS_MINMIN
Definition: vtkAxisActor.h:73
represent and manipulate 3D points
Definition: vtkPoints.h:38
int DrawInnerGridlines
Definition: vtkAxisActor.h:520
create polygonal text
Definition: vtkVectorText.h:46