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 =========================================================================*/
53 #ifndef vtkAxisActor_h
54 #define vtkAxisActor_h
55 
56 #include "vtkRenderingAnnotationModule.h" // For export macro
57 #include "vtkActor.h"
58 
59 #define VTK_MAX_LABELS 200
60 #define VTK_MAX_TICKS 1000
61 
62 #define VTK_AXIS_TYPE_X 0
63 #define VTK_AXIS_TYPE_Y 1
64 #define VTK_AXIS_TYPE_Z 2
65 
66 #define VTK_TICKS_INSIDE 0
67 #define VTK_TICKS_OUTSIDE 1
68 #define VTK_TICKS_BOTH 2
69 
70 #define VTK_AXIS_POS_MINMIN 0
71 #define VTK_AXIS_POS_MINMAX 1
72 #define VTK_AXIS_POS_MAXMAX 2
73 #define VTK_AXIS_POS_MAXMIN 3
74 
75 class vtkAxisFollower;
76 class vtkCamera;
77 class vtkCoordinate;
78 class vtkFollower;
79 class vtkPoints;
80 class vtkPolyData;
81 class vtkPolyDataMapper;
83 class vtkProperty2D;
84 class vtkStringArray;
85 class vtkTextActor;
86 class vtkTextActor3D;
87 class vtkTextProperty;
88 class vtkVectorText;
89 
91 {
92  public:
93  vtkTypeMacro(vtkAxisActor,vtkActor);
94  void PrintSelf(ostream& os, vtkIndent indent);
95 
97  static vtkAxisActor *New();
98 
100 
101  virtual vtkCoordinate *GetPoint1Coordinate();
102  virtual void SetPoint1(double x[3])
103  { this->SetPoint1(x[0], x[1], x[2]); }
104  virtual void SetPoint1(double x, double y, double z);
105  virtual double *GetPoint1();
107 
109 
110  virtual vtkCoordinate *GetPoint2Coordinate();
111  virtual void SetPoint2(double x[3])
112  { this->SetPoint2(x[0], x[1], x[2]); }
113  virtual void SetPoint2(double x, double y, double z);
114  virtual double *GetPoint2();
116 
118 
120  vtkSetVector2Macro(Range,double);
121  vtkGetVectorMacro(Range,double,2);
123 
125 
127  void SetBounds(const double bounds[6]);
128  void SetBounds(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
129  double *GetBounds(void);
130  void GetBounds(double bounds[6]);
132 
134 
135  vtkSetStringMacro(LabelFormat);
136  vtkGetStringMacro(LabelFormat);
138 
140 
144  vtkSetMacro(UseTextActor3D, int);
145  vtkGetMacro(UseTextActor3D, int);
147 
149 
150  vtkSetMacro(MinorTicksVisible, int);
151  vtkGetMacro(MinorTicksVisible, int);
152  vtkBooleanMacro(MinorTicksVisible, int);
154 
156 
157  void SetTitle(const char *t);
158  vtkGetStringMacro(Title);
160 
162 
163  vtkSetMacro(MajorTickSize, double);
164  vtkGetMacro(MajorTickSize, double);
166 
168 
169  vtkSetMacro(MinorTickSize, double);
170  vtkGetMacro(MinorTickSize, double);
172 
174 
175  vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
176  vtkGetMacro(TickLocation, int);
178 
180  { this->SetTickLocation(VTK_TICKS_INSIDE); };
182  { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
184  { this->SetTickLocation(VTK_TICKS_BOTH); };
185 
187 
188  vtkSetMacro(AxisVisibility, int);
189  vtkGetMacro(AxisVisibility, int);
190  vtkBooleanMacro(AxisVisibility, int);
192 
194 
195  vtkSetMacro(TickVisibility, int);
196  vtkGetMacro(TickVisibility, int);
197  vtkBooleanMacro(TickVisibility, int);
199 
201 
202  vtkSetMacro(LabelVisibility, int);
203  vtkGetMacro(LabelVisibility, int);
204  vtkBooleanMacro(LabelVisibility, int);
206 
208 
209  vtkSetMacro(TitleVisibility, int);
210  vtkGetMacro(TitleVisibility, int);
211  vtkBooleanMacro(TitleVisibility, int);
213 
215 
216  virtual void SetTitleTextProperty(vtkTextProperty *p);
217  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
219 
221 
222  virtual void SetLabelTextProperty(vtkTextProperty *p);
223  vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
225 
227 
228  void SetAxisLinesProperty(vtkProperty *);
229  vtkProperty* GetAxisLinesProperty();
231 
233 
234  void SetGridlinesProperty(vtkProperty *);
235  vtkProperty* GetGridlinesProperty();
237 
239 
240  void SetInnerGridlinesProperty(vtkProperty *);
241  vtkProperty* GetInnerGridlinesProperty();
243 
245 
246  void SetGridpolysProperty(vtkProperty *);
247  vtkProperty* GetGridpolysProperty();
249 
251 
252  vtkSetMacro(DrawGridlines, int);
253  vtkGetMacro(DrawGridlines, int);
254  vtkBooleanMacro(DrawGridlines, int);
256 
258 
261  vtkSetMacro(DrawGridlinesOnly, int);
262  vtkGetMacro(DrawGridlinesOnly, int);
263  vtkBooleanMacro(DrawGridlinesOnly, int);
265 
266  vtkSetMacro(DrawGridlinesLocation, int);
267  vtkGetMacro(DrawGridlinesLocation, int);
268 
270 
271  vtkSetMacro(DrawInnerGridlines, int);
272  vtkGetMacro(DrawInnerGridlines, int);
273  vtkBooleanMacro(DrawInnerGridlines, int);
275 
277 
278  vtkSetMacro(GridlineXLength, double);
279  vtkGetMacro(GridlineXLength, double);
280  vtkSetMacro(GridlineYLength, double);
281  vtkGetMacro(GridlineYLength, double);
282  vtkSetMacro(GridlineZLength, double);
283  vtkGetMacro(GridlineZLength, double);
285 
287 
288  vtkSetMacro(DrawGridpolys, int);
289  vtkGetMacro(DrawGridpolys, int);
290  vtkBooleanMacro(DrawGridpolys, int);
292 
294 
295  vtkSetClampMacro(AxisType, int, VTK_AXIS_TYPE_X, VTK_AXIS_TYPE_Z);
296  vtkGetMacro(AxisType, int);
297  void SetAxisTypeToX(void) { this->SetAxisType(VTK_AXIS_TYPE_X); };
298  void SetAxisTypeToY(void) { this->SetAxisType(VTK_AXIS_TYPE_Y); };
299  void SetAxisTypeToZ(void) { this->SetAxisType(VTK_AXIS_TYPE_Z); };
301 
303 
308  vtkSetClampMacro(AxisPosition, int, VTK_AXIS_POS_MINMIN, VTK_AXIS_POS_MAXMIN);
309  vtkGetMacro(AxisPosition, int);
311 
313  { this->SetAxisPosition(VTK_AXIS_POS_MINMIN); };
315  { this->SetAxisPosition(VTK_AXIS_POS_MINMAX); };
317  { this->SetAxisPosition(VTK_AXIS_POS_MAXMAX); };
319  { this->SetAxisPosition(VTK_AXIS_POS_MAXMIN); };
320 
322 
324  virtual void SetCamera(vtkCamera*);
325  vtkGetObjectMacro(Camera, vtkCamera);
327 
329 
330  virtual int RenderOpaqueGeometry(vtkViewport* viewport);
331  virtual int RenderTranslucentGeometry(vtkViewport* viewport);
332  virtual int RenderTranslucentPolygonalGeometry(vtkViewport* viewport);
333  virtual int RenderOverlay(vtkViewport* viewport);
336 
341 
342 //BTX
343  double ComputeMaxLabelLength(const double [3]);
344  double ComputeTitleLength(const double [3]);
345 //ETX
346  void SetLabelScale(const double scale);
347  void SetLabelScale(int labelIndex, const double scale);
348  void SetTitleScale(const double scale);
349 
351 
353  vtkSetMacro(MinorStart, double);
354  vtkGetMacro(MinorStart, double);
355  double GetMajorStart(int axis);
356  void SetMajorStart(int axis,double value);
357  //vtkSetMacro(MajorStart, double);
358  //vtkGetMacro(MajorStart, double);
359  vtkSetMacro(DeltaMinor, double);
360  vtkGetMacro(DeltaMinor, double);
361  double GetDeltaMajor(int axis);
362  void SetDeltaMajor(int axis,double value);
363  //vtkSetMacro(DeltaMajor, double);
364  //vtkGetMacro(DeltaMajor, double);
366 
368 
372  vtkSetMacro(MinorRangeStart, double);
373  vtkGetMacro(MinorRangeStart, double);
374  vtkSetMacro(MajorRangeStart, double);
375  vtkGetMacro(MajorRangeStart, double);
376  vtkSetMacro(DeltaRangeMinor, double);
377  vtkGetMacro(DeltaRangeMinor, double);
378  vtkSetMacro(DeltaRangeMajor, double);
379  vtkGetMacro(DeltaRangeMajor, double);
381 
382 //BTX
383  void SetLabels(vtkStringArray *labels);
384 //ETX
385 
386  void BuildAxis(vtkViewport *viewport, bool);
387 
388 //BTX
390 
391  vtkGetObjectMacro(TitleActor, vtkAxisFollower);
393 
395 
397  {
398  return this->LabelActors;
399  }
401 
403 
404  vtkGetObjectMacro(TitleProp3D, vtkProp3DAxisFollower);
406 
408 
410  {
411  return this->LabelProps3D;
412  }
413 //ETX
415 
417 
419  vtkGetMacro(NumberOfLabelsBuilt, int);
421 
423 
424  vtkSetMacro(CalculateTitleOffset, int);
425  vtkGetMacro(CalculateTitleOffset, int);
426  vtkBooleanMacro(CalculateTitleOffset, int);
428 
430 
431  vtkSetMacro(CalculateLabelOffset, int);
432  vtkGetMacro(CalculateLabelOffset, int);
433  vtkBooleanMacro(CalculateLabelOffset, int);
435 
437 
438  vtkSetMacro(Use2DMode, int);
439  vtkGetMacro(Use2DMode, int);
441 
443 
444  vtkSetMacro(VerticalOffsetXTitle2D, double);
445  vtkGetMacro(VerticalOffsetXTitle2D, double);
447 
449 
450  vtkSetMacro(HorizontalOffsetYTitle2D, double);
451  vtkGetMacro(HorizontalOffsetYTitle2D, double);
453 
455 
456  vtkSetMacro(SaveTitlePosition, int);
457  vtkGetMacro(SaveTitlePosition, int);
459 
461 
462  vtkSetVector3Macro(AxisBaseForX, double);
463  vtkGetVector3Macro(AxisBaseForX, double);
465 
467 
468  vtkSetVector3Macro(AxisBaseForY, double);
469  vtkGetVector3Macro(AxisBaseForY, double);
471 
473 
474  vtkSetVector3Macro(AxisBaseForZ, double);
475  vtkGetVector3Macro(AxisBaseForZ, double);
477 
479 
480  vtkSetMacro(AxisOnOrigin,int);
481  vtkGetMacro(AxisOnOrigin,int);
483 
485 
486  vtkSetMacro(LabelOffset, double);
487  vtkGetMacro(LabelOffset, double);
488  vtkSetMacro(TitleOffset, double);
489  vtkGetMacro(TitleOffset, double);
490  vtkSetMacro(ScreenSize, double);
491  vtkGetMacro(ScreenSize, double);
493 
494  protected:
495  vtkAxisActor();
496  ~vtkAxisActor();
497 
498  char *Title;
499  double Range[2];
500  double LastRange[2];
501  char *LabelFormat;
507 
511  int DrawGridlinesLocation; // 0: all | 1: closest | 2: farest
512  int LastDrawGridlinesLocation; // 0: all | 1: closest | 2: farest
516 
519 
522 
528 
529  int AxisType;
531  double Bounds[6];
532 
533  double AxisBaseForX[3];
534  double AxisBaseForY[3];
535  double AxisBaseForZ[3];
536 
537  private:
538  vtkAxisActor(const vtkAxisActor&); // Not implemented
539  void operator=(const vtkAxisActor&); // Not implemented
540 
541  void TransformBounds(vtkViewport *, double bnds[6]);
542 
543  void BuildLabels(vtkViewport *, bool);
544  void BuildLabels2D(vtkViewport *, bool);
545  void SetLabelPositions(vtkViewport *, bool);
546  void SetLabelPositions2D(vtkViewport *, bool);
547 
548  void BuildTitle(bool);
549  void BuildTitle2D(vtkViewport *viewport, bool);
550 
551  void SetAxisPointsAndLines(void);
552  bool BuildTickPoints(double p1[3], double p2[3], bool force);
553 
554  bool TickVisibilityChanged(void);
555  vtkProperty *NewTitleProperty();
556  vtkProperty2D *NewTitleProperty2D();
557  vtkProperty *NewLabelProperty();
558 
559  bool BoundsDisplayCoordinateChanged(vtkViewport *viewport);
560 
561  vtkCoordinate *Point1Coordinate;
562  vtkCoordinate *Point2Coordinate;
563 
564  double MajorTickSize;
565  double MinorTickSize;
566 
567  // For each axis (for the inner gridline generation)
568  double MajorStart[3];
569  double DeltaMajor[3];
570  double MinorStart;
571  double DeltaMinor;
572 
573  // For the ticks, w.r.t to the set range
574  double MajorRangeStart;
575  double MinorRangeStart;
576  double DeltaRangeMinor;
577  double DeltaRangeMajor;
578 
579  int LastAxisPosition;
580  int LastAxisType;
581  int LastTickLocation;
582  double LastLabelStart;
583 
584  vtkPoints *MinorTickPts;
585  vtkPoints *MajorTickPts;
586  vtkPoints *GridlinePts;
587  vtkPoints *InnerGridlinePts;
588  vtkPoints *GridpolyPts;
589 
590  vtkVectorText *TitleVector;
591  vtkPolyDataMapper *TitleMapper;
592  vtkAxisFollower *TitleActor;
593  vtkTextActor *TitleActor2D;
594  vtkProp3DAxisFollower *TitleProp3D;
595  vtkTextActor3D *TitleActor3D;
596  vtkTextProperty *TitleTextProperty;
597 
598  vtkVectorText **LabelVectors;
599  vtkPolyDataMapper **LabelMappers;
600  vtkAxisFollower **LabelActors;
601  vtkProp3DAxisFollower **LabelProps3D;
602  vtkTextActor **LabelActors2D;
603  vtkTextActor3D **LabelActors3D;
604  vtkTextProperty *LabelTextProperty;
605 
606  vtkPolyData *AxisLines;
607  vtkPolyDataMapper *AxisLinesMapper;
608  vtkActor *AxisLinesActor;
609  vtkPolyData *Gridlines;
610  vtkPolyDataMapper *GridlinesMapper;
611  vtkActor *GridlinesActor;
612  vtkPolyData *InnerGridlines;
613  vtkPolyDataMapper *InnerGridlinesMapper;
614  vtkActor *InnerGridlinesActor;
615  vtkPolyData *Gridpolys;
616  vtkPolyDataMapper *GridpolysMapper;
617  vtkActor *GridpolysActor;
618 
619  vtkCamera *Camera;
621  vtkTimeStamp BuildTickPointsTime;
622  vtkTimeStamp BoundsTime;
623  vtkTimeStamp LabelBuildTime;
624  vtkTimeStamp TitleTextTime;
625 
626  int AxisOnOrigin;
627 
628  int AxisHasZeroLength;
629 
630  int CalculateTitleOffset;
631  int CalculateLabelOffset;
632 
634  int Use2DMode;
635 
638  double VerticalOffsetXTitle2D;
639 
642  double HorizontalOffsetYTitle2D;
643 
648  int SaveTitlePosition;
649 
651  double TitleConstantPosition[2];
652 
654  bool NeedBuild2D;
655 
656  double LastMinDisplayCoordinate[3];
657  double LastMaxDisplayCoordinate[3];
658 
660 
661  double ScreenSize;
662  double LabelOffset;
663  double TitleOffset;
664 };
666 
667 #endif
#define VTK_AXIS_TYPE_X
Definition: vtkAxisActor.h:62
virtual void SetPoint1(double x[3])
Definition: vtkAxisActor.h:102
double GridlineXLength
Definition: vtkAxisActor.h:513
vtkTimeStamp BuildTime
int DrawGridlinesOnly
Definition: vtkAxisActor.h:509
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
#define VTK_TICKS_OUTSIDE
Definition: vtkAxisActor.h:67
void SetAxisTypeToY(void)
Definition: vtkAxisActor.h:298
int LastMinorTicksVisible
Definition: vtkAxisActor.h:505
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport)
#define VTK_AXIS_POS_MAXMAX
Definition: vtkAxisActor.h:72
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:63
int LastDrawGridpolys
Definition: vtkAxisActor.h:521
int LastDrawInnerGridlines
Definition: vtkAxisActor.h:518
virtual void SetPoint2(double x[3])
Definition: vtkAxisActor.h:111
#define VTK_AXIS_TYPE_Z
Definition: vtkAxisActor.h:64
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:204
double GridlineZLength
Definition: vtkAxisActor.h:515
record modification and/or execution time
Definition: vtkTimeStamp.h:34
Create an axis with tick marks and labels.
Definition: vtkAxisActor.h:90
vtkProp3DAxisFollower ** GetLabelProps3D()
Definition: vtkAxisActor.h:409
a vtkAbstractArray subclass for strings
int LastDrawGridlines
Definition: vtkAxisActor.h:510
void SetTickLocationToInside(void)
Definition: vtkAxisActor.h:179
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
static vtkActor * New()
void PrintSelf(ostream &os, vtkIndent indent)
#define VTKRENDERINGANNOTATION_EXPORT
double GridlineYLength
Definition: vtkAxisActor.h:514
int DrawGridlinesLocation
Definition: vtkAxisActor.h:511
void SetAxisPositionToMaxMin(void)
Definition: vtkAxisActor.h:318
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
void SetAxisTypeToX(void)
Definition: vtkAxisActor.h:297
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:49
void SetAxisPositionToMaxMax(void)
Definition: vtkAxisActor.h:316
vtkAxisFollower ** GetLabelActors()
Definition: vtkAxisActor.h:396
void SetTickLocationToBoth(void)
Definition: vtkAxisActor.h:183
#define VTK_AXIS_POS_MAXMIN
Definition: vtkAxisActor.h:73
int LastTickVisibility
Definition: vtkAxisActor.h:525
#define VTK_TICKS_BOTH
Definition: vtkAxisActor.h:68
An actor that displays text.
#define VTK_AXIS_TYPE_Y
Definition: vtkAxisActor.h:63
int NumberOfLabelsBuilt
Definition: vtkAxisActor.h:503
represent text properties.
char * LabelFormat
Definition: vtkAxisActor.h:501
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:314
map vtkPolyData to graphics primitives
void SetAxisPositionToMinMin(void)
Definition: vtkAxisActor.h:312
#define VTK_AXIS_POS_MINMAX
Definition: vtkAxisActor.h:71
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:504
#define VTK_TICKS_INSIDE
Definition: vtkAxisActor.h:66
int LastDrawGridlinesLocation
Definition: vtkAxisActor.h:512
void ReleaseGraphicsResources(vtkWindow *)
represent surface properties of a 2D image
Definition: vtkProperty2D.h:39
void SetAxisTypeToZ(void)
Definition: vtkAxisActor.h:299
void SetTickLocationToOutside(void)
Definition: vtkAxisActor.h:181
#define VTK_AXIS_POS_MINMIN
Definition: vtkAxisActor.h:70
represent and manipulate 3D points
Definition: vtkPoints.h:38
int DrawInnerGridlines
Definition: vtkAxisActor.h:517
create polygonal text
Definition: vtkVectorText.h:46