VTK
vtkCubeAxesActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCubeAxesActor.h
5  Language: C++
6 
7 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen
8 All rights reserve
9  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notice for more information.
14 =========================================================================*/
56 #ifndef vtkCubeAxesActor_h
57 #define vtkCubeAxesActor_h
58 
59 #include "vtkRenderingAnnotationModule.h" // For export macro
60 #include "vtkActor.h"
61 
62 class vtkAxisActor;
63 class vtkCamera;
64 class vtkTextProperty;
65 class vtkStringArray;
66 
67 class VTKRENDERINGANNOTATION_EXPORT vtkCubeAxesActor : public vtkActor
68 {
69 public:
70  vtkTypeMacro(vtkCubeAxesActor,vtkActor);
71  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
72 
77  static vtkCubeAxesActor *New();
78 
80 
83  int RenderOpaqueGeometry(vtkViewport*) VTK_OVERRIDE;
84  virtual int RenderTranslucentGeometry(vtkViewport*);
86  int RenderOverlay(vtkViewport*) VTK_OVERRIDE;
87  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
89 
91 
94  vtkSetMacro( RebuildAxes, bool );
95  vtkGetMacro( RebuildAxes, bool );
97 
99 
105  vtkSetVector6Macro(Bounds,double);
106  using Superclass::GetBounds;
107  double *GetBounds() VTK_OVERRIDE { return this->Bounds; }
109 
111 
115  virtual void GetRenderedBounds(double rBounds[6]);
116  virtual double* GetRenderedBounds();
118 
120 
128  vtkSetVector2Macro( XAxisRange, double );
129  vtkSetVector2Macro( YAxisRange, double );
130  vtkSetVector2Macro( ZAxisRange, double );
131  vtkGetVector2Macro( XAxisRange, double );
132  vtkGetVector2Macro( YAxisRange, double );
134 
135 
139  vtkStringArray* GetAxisLabels(int axis);
140  void SetAxisLabels(int axis, vtkStringArray* value);
142 
143  vtkGetVector2Macro( ZAxisRange, double );
144 
146 
151  void SetScreenSize(double screenSize);
152  vtkGetMacro(ScreenSize, double);
154 
156 
160  void SetLabelOffset(double offset);
161  vtkGetMacro(LabelOffset, double);
163 
165 
169  void SetTitleOffset(double offset);
170  vtkGetMacro(TitleOffset, double);
172 
174 
178  virtual void SetCamera(vtkCamera*);
179  vtkGetObjectMacro(Camera,vtkCamera);
181 
182  enum FlyMode
183  {
184  VTK_FLY_OUTER_EDGES = 0,
185  VTK_FLY_CLOSEST_TRIAD = 1,
186  VTK_FLY_FURTHEST_TRIAD = 2,
187  VTK_FLY_STATIC_TRIAD = 3,
188  VTK_FLY_STATIC_EDGES = 4
189  };
190 
192 
197  vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES);
198  vtkGetMacro(FlyMode, int);
200  {this->SetFlyMode(VTK_FLY_OUTER_EDGES);};
202  {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);};
204  {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);};
206  {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);};
208  {this->SetFlyMode(VTK_FLY_STATIC_EDGES);};
210 
212 
216  vtkSetStringMacro(XTitle);
217  vtkGetStringMacro(XTitle);
218  vtkSetStringMacro(XUnits);
219  vtkGetStringMacro(XUnits);
220  vtkSetStringMacro(YTitle);
221  vtkGetStringMacro(YTitle);
222  vtkSetStringMacro(YUnits);
223  vtkGetStringMacro(YUnits);
224  vtkSetStringMacro(ZTitle);
225  vtkGetStringMacro(ZTitle);
226  vtkSetStringMacro(ZUnits);
227  vtkGetStringMacro(ZUnits);
229 
231 
235  vtkSetStringMacro(XLabelFormat);
236  vtkGetStringMacro(XLabelFormat);
237  vtkSetStringMacro(YLabelFormat);
238  vtkGetStringMacro(YLabelFormat);
239  vtkSetStringMacro(ZLabelFormat);
240  vtkGetStringMacro(ZLabelFormat);
242 
244 
249  vtkSetClampMacro(Inertia, int, 1, VTK_INT_MAX);
250  vtkGetMacro(Inertia, int);
252 
254 
259  vtkSetMacro(CornerOffset, double);
260  vtkGetMacro(CornerOffset, double);
262 
268  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
269 
271 
274  vtkSetMacro( EnableDistanceLOD, int );
275  vtkGetMacro( EnableDistanceLOD, int );
277 
279 
282  vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 );
283  vtkGetMacro( DistanceLODThreshold, double);
285 
287 
290  vtkSetMacro( EnableViewAngleLOD, int );
291  vtkGetMacro( EnableViewAngleLOD, int );
293 
295 
298  vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. );
299  vtkGetMacro( ViewAngleLODThreshold, double );
301 
303 
306  vtkSetMacro(XAxisVisibility,int);
307  vtkGetMacro(XAxisVisibility,int);
308  vtkBooleanMacro(XAxisVisibility,int);
309  vtkSetMacro(YAxisVisibility,int);
310  vtkGetMacro(YAxisVisibility,int);
311  vtkBooleanMacro(YAxisVisibility,int);
312  vtkSetMacro(ZAxisVisibility,int);
313  vtkGetMacro(ZAxisVisibility,int);
314  vtkBooleanMacro(ZAxisVisibility,int);
316 
318 
321  vtkSetMacro(XAxisLabelVisibility,int);
322  vtkGetMacro(XAxisLabelVisibility,int);
323  vtkBooleanMacro(XAxisLabelVisibility,int);
325 
326  vtkSetMacro(YAxisLabelVisibility,int);
327  vtkGetMacro(YAxisLabelVisibility,int);
328  vtkBooleanMacro(YAxisLabelVisibility,int);
329 
330  vtkSetMacro(ZAxisLabelVisibility,int);
331  vtkGetMacro(ZAxisLabelVisibility,int);
332  vtkBooleanMacro(ZAxisLabelVisibility,int);
333 
335 
338  vtkSetMacro(XAxisTickVisibility,int);
339  vtkGetMacro(XAxisTickVisibility,int);
340  vtkBooleanMacro(XAxisTickVisibility,int);
342 
343  vtkSetMacro(YAxisTickVisibility,int);
344  vtkGetMacro(YAxisTickVisibility,int);
345  vtkBooleanMacro(YAxisTickVisibility,int);
346 
347  vtkSetMacro(ZAxisTickVisibility,int);
348  vtkGetMacro(ZAxisTickVisibility,int);
349  vtkBooleanMacro(ZAxisTickVisibility,int);
350 
352 
355  vtkSetMacro(XAxisMinorTickVisibility,int);
356  vtkGetMacro(XAxisMinorTickVisibility,int);
357  vtkBooleanMacro(XAxisMinorTickVisibility,int);
359 
360  vtkSetMacro(YAxisMinorTickVisibility,int);
361  vtkGetMacro(YAxisMinorTickVisibility,int);
362  vtkBooleanMacro(YAxisMinorTickVisibility,int);
363 
364  vtkSetMacro(ZAxisMinorTickVisibility,int);
365  vtkGetMacro(ZAxisMinorTickVisibility,int);
366  vtkBooleanMacro(ZAxisMinorTickVisibility,int);
367 
368  vtkSetMacro(DrawXGridlines,int);
369  vtkGetMacro(DrawXGridlines,int);
370  vtkBooleanMacro(DrawXGridlines,int);
371 
372  vtkSetMacro(DrawYGridlines,int);
373  vtkGetMacro(DrawYGridlines,int);
374  vtkBooleanMacro(DrawYGridlines,int);
375 
376  vtkSetMacro(DrawZGridlines,int);
377  vtkGetMacro(DrawZGridlines,int);
378  vtkBooleanMacro(DrawZGridlines,int);
379 
380  vtkSetMacro(DrawXInnerGridlines,int);
381  vtkGetMacro(DrawXInnerGridlines,int);
382  vtkBooleanMacro(DrawXInnerGridlines,int);
383 
384  vtkSetMacro(DrawYInnerGridlines,int);
385  vtkGetMacro(DrawYInnerGridlines,int);
386  vtkBooleanMacro(DrawYInnerGridlines,int);
387 
388  vtkSetMacro(DrawZInnerGridlines,int);
389  vtkGetMacro(DrawZInnerGridlines,int);
390  vtkBooleanMacro(DrawZInnerGridlines,int);
391 
392  vtkSetMacro(DrawXGridpolys,int);
393  vtkGetMacro(DrawXGridpolys,int);
394  vtkBooleanMacro(DrawXGridpolys,int);
395 
396  vtkSetMacro(DrawYGridpolys,int);
397  vtkGetMacro(DrawYGridpolys,int);
398  vtkBooleanMacro(DrawYGridpolys,int);
399 
400  vtkSetMacro(DrawZGridpolys,int);
401  vtkGetMacro(DrawZGridpolys,int);
402  vtkBooleanMacro(DrawZGridpolys,int);
403 
407  vtkTextProperty *GetTitleTextProperty(int);
408 
412  vtkTextProperty *GetLabelTextProperty(int);
413 
415 
418  void SetXAxesLinesProperty(vtkProperty *);
419  vtkProperty* GetXAxesLinesProperty();
420  void SetYAxesLinesProperty(vtkProperty *);
421  vtkProperty* GetYAxesLinesProperty();
422  void SetZAxesLinesProperty(vtkProperty *);
423  vtkProperty* GetZAxesLinesProperty();
425 
427 
430  void SetXAxesGridlinesProperty(vtkProperty *);
431  vtkProperty* GetXAxesGridlinesProperty();
432  void SetYAxesGridlinesProperty(vtkProperty *);
433  vtkProperty* GetYAxesGridlinesProperty();
434  void SetZAxesGridlinesProperty(vtkProperty *);
435  vtkProperty* GetZAxesGridlinesProperty();
437 
439 
442  void SetXAxesInnerGridlinesProperty(vtkProperty *);
443  vtkProperty* GetXAxesInnerGridlinesProperty();
444  void SetYAxesInnerGridlinesProperty(vtkProperty *);
445  vtkProperty* GetYAxesInnerGridlinesProperty();
446  void SetZAxesInnerGridlinesProperty(vtkProperty *);
447  vtkProperty* GetZAxesInnerGridlinesProperty();
449 
451 
454  void SetXAxesGridpolysProperty(vtkProperty *);
455  vtkProperty* GetXAxesGridpolysProperty();
456  void SetYAxesGridpolysProperty(vtkProperty *);
457  vtkProperty* GetYAxesGridpolysProperty();
458  void SetZAxesGridpolysProperty(vtkProperty *);
459  vtkProperty* GetZAxesGridpolysProperty();
461 
463  {
464  VTK_TICKS_INSIDE = 0,
465  VTK_TICKS_OUTSIDE = 1,
466  VTK_TICKS_BOTH = 2
467  };
468 
470 
473  vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
474  vtkGetMacro(TickLocation, int);
476 
478  { this->SetTickLocation(VTK_TICKS_INSIDE); };
480  { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
482  { this->SetTickLocation(VTK_TICKS_BOTH); };
483 
484  void SetLabelScaling(bool, int, int, int);
485 
487 
492  void SetUseTextActor3D( int val );
493  int GetUseTextActor3D();
495 
497 
501  void SetUse2DMode( int val );
502  int GetUse2DMode();
504 
508  void SetSaveTitlePosition( int val );
509 
511 
514  vtkSetVector6Macro(OrientedBounds,double);
515  vtkGetVector6Macro(OrientedBounds, double);
517 
519 
522  vtkSetMacro(UseOrientedBounds, int);
523  vtkGetMacro(UseOrientedBounds, int);
525 
527 
530  vtkSetVector3Macro(AxisBaseForX,double);
531  vtkGetVector3Macro(AxisBaseForX, double);
533 
535 
538  vtkSetVector3Macro(AxisBaseForY,double);
539  vtkGetVector3Macro(AxisBaseForY, double);
541 
543 
546  vtkSetVector3Macro(AxisBaseForZ,double);
547  vtkGetVector3Macro(AxisBaseForZ, double);
549 
551 
555  vtkSetVector3Macro(AxisOrigin,double);
556  vtkGetVector3Macro(AxisOrigin, double);
558 
560 
563  vtkSetMacro(UseAxisOrigin, int);
564  vtkGetMacro(UseAxisOrigin, int);
566 
568 
571  vtkSetMacro(GridLineLocation,int);
572  vtkGetMacro(GridLineLocation,int);
574 
576 
581  vtkSetMacro(StickyAxes,int);
582  vtkGetMacro(StickyAxes,int);
583  vtkBooleanMacro(StickyAxes,int);
585 
587 
594  vtkSetMacro(CenterStickyAxes,int);
595  vtkGetMacro(CenterStickyAxes,int);
596  vtkBooleanMacro(CenterStickyAxes,int);
598 
600  {
601  VTK_GRID_LINES_ALL = 0,
602  VTK_GRID_LINES_CLOSEST = 1,
603  VTK_GRID_LINES_FURTHEST = 2
604  };
605 
606 protected:
608  ~vtkCubeAxesActor() VTK_OVERRIDE;
609 
615  void ComputeStickyAxesBoundingSphere(vtkViewport* viewport, const double bounds[6],
616  double sphereCenter[3], double & sphereRadius);
617 
621  void GetViewportLimitedBounds(vtkViewport* viewport, double bounds[6]);
622 
627  static void GetBoundsPointBits(unsigned int pointIndex,
628  unsigned int & xBit,
629  unsigned int & yBit,
630  unsigned int & zBit);
631 
635  static void GetBoundsPoint(unsigned int pointIndex, const double bounds[6], double point[3]);
636 
637  int LabelExponent(double min, double max);
638 
639  int Digits(double min, double max);
640 
641  double MaxOf(double, double);
642  double MaxOf(double, double, double, double);
643 
644  double FFix(double);
645  double FSign(double, double);
646  int FRound( double fnt );
647  int GetNumTicks( double range, double fxt);
648 
649  void UpdateLabels(vtkAxisActor **axis, int index);
650 
651  vtkCamera *Camera;
652 
653  int FlyMode;
654 
655  // Expose internally closest axis index computation
656  int FindClosestAxisIndex(double pts[8][3]);
657 
658  // Expose internally furthest axis index computation
659  int FindFurtherstAxisIndex(double pts[8][3]);
660 
661  // Expose internally the boundary edge fly mode axis index computation
662  void FindBoundaryEdge(int &indexOfAxisX, int &indexOfAxisY, int &indexOfAxisZ,
663  double pts[8][3]);
664 
670  void UpdateGridLineVisibility(int axisIndex);
671 
672  // VTK_ALL_GRID_LINES 0
673  // VTK_CLOSEST_GRID_LINES 1
674  // VTK_FURTHEST_GRID_LINES 2
675  int GridLineLocation;
676 
680  int StickyAxes;
681 
685  int CenterStickyAxes;
686 
691  int EnableDistanceLOD;
692 
697  double DistanceLODThreshold;
698 
703  int EnableViewAngleLOD;
704 
709  double ViewAngleLODThreshold;
710 
712  {
713  NUMBER_OF_ALIGNED_AXIS = 4
714  };
715 
717 
721  vtkAxisActor *XAxes[NUMBER_OF_ALIGNED_AXIS];
722  vtkAxisActor *YAxes[NUMBER_OF_ALIGNED_AXIS];
723  vtkAxisActor *ZAxes[NUMBER_OF_ALIGNED_AXIS];
725 
727 
728  char *XTitle;
729  char *XUnits;
730  char *YTitle;
731  char *YUnits;
732  char *ZTitle;
733  char *ZUnits;
734 
738 
740 
744 
748 
752 
756 
760 
764 
768 
772 
773  double CornerOffset;
774 
775  int Inertia;
776 
778 
779  int InertiaLocs[3];
780 
782 
783  vtkTextProperty* TitleTextProperty[3];
784  vtkStringArray* AxisLabels[3];
785 
786  vtkTextProperty* LabelTextProperty[3];
787 
800 
801  double RenderedBounds[6];
802  double OrientedBounds[6];
804 
805  double AxisOrigin[3];
807 
808  double AxisBaseForX[3];
809  double AxisBaseForY[3];
810  double AxisBaseForZ[3];
811 
812 private:
813  vtkCubeAxesActor(const vtkCubeAxesActor&) VTK_DELETE_FUNCTION;
814  void operator=(const vtkCubeAxesActor&) VTK_DELETE_FUNCTION;
815 
816  vtkSetStringMacro(ActualXLabel);
817  vtkSetStringMacro(ActualYLabel);
818  vtkSetStringMacro(ActualZLabel);
819 
821  int LastUseOrientedBounds;
822  int LastXPow;
823  int LastYPow;
824  int LastZPow;
825 
826  int UserXPow;
827  int UserYPow;
828  int UserZPow;
829 
830  bool AutoLabelScaling;
831 
832  int LastXAxisDigits;
833  int LastYAxisDigits;
834  int LastZAxisDigits;
835 
836  double LastXRange[2];
837  double LastYRange[2];
838  double LastZRange[2];
839  double LastBounds[6];
840 
841  int LastFlyMode;
842 
843  int RenderAxesX[NUMBER_OF_ALIGNED_AXIS];
844  int RenderAxesY[NUMBER_OF_ALIGNED_AXIS];
845  int RenderAxesZ[NUMBER_OF_ALIGNED_AXIS];
846 
847  int NumberOfAxesX;
848  int NumberOfAxesY;
849  int NumberOfAxesZ;
850 
851  bool MustAdjustXValue;
852  bool MustAdjustYValue;
853  bool MustAdjustZValue;
854 
855  bool ForceXLabelReset;
856  bool ForceYLabelReset;
857  bool ForceZLabelReset;
858 
859  double XAxisRange[2];
860  double YAxisRange[2];
861  double ZAxisRange[2];
862 
863  double LabelScale;
864  double TitleScale;
865 
866  double ScreenSize;
867  double LabelOffset;
868  double TitleOffset;
869 
871 
875  double MajorStart[3];
876  double DeltaMajor[3];
878 
879  int RenderGeometry(bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility,int (vtkAxisActor::*renderMethod)(vtkViewport*));
880 
881  void TransformBounds(vtkViewport *viewport, const double bounds[6],
882  double pts[8][3]);
883  void AdjustAxes(double bounds[6],
884  double xCoords[NUMBER_OF_ALIGNED_AXIS][6],
885  double yCoords[NUMBER_OF_ALIGNED_AXIS][6],
886  double zCoords[NUMBER_OF_ALIGNED_AXIS][6],
887  double xRange[2], double yRange[2], double zRange[2]);
888 
889  bool ComputeTickSize(double bounds[6]);
890  void AdjustValues(const double xRange[2],
891  const double yRange[2],
892  const double zRange[2]);
893  void AdjustRange(const double bounds[6]);
894  void BuildAxes(vtkViewport *);
895  void DetermineRenderAxes(vtkViewport *);
896  void SetNonDependentAttributes(void);
897  void BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
898  void AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS],
899  double rangeMin, double rangeMax);
900 
901  void AutoScale(vtkViewport *viewport);
902  void AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
903  double AutoScale(vtkViewport *viewport, double screenSize, double position[3]);
904 };
905 
906 
907 #endif
vtkTimeStamp BuildTime
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
void SetFlyModeToStaticEdges()
Specify a mode to control how the axes are drawn: either static, closest triad, furthest triad or out...
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:58
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:222
int HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
#define VTK_INT_MAX
Definition: vtkType.h:157
record modification and/or execution time
Definition: vtkTimeStamp.h:32
Create an axis with tick marks and labels.
Definition: vtkAxisActor.h:71
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkProperty * YAxesGridlinesProperty
vtkProperty * ZAxesLinesProperty
a vtkAbstractArray subclass for strings
void SetTickLocationToInside(void)
void SetFlyModeToFurthestTriad()
Specify a mode to control how the axes are drawn: either static, closest triad, furthest triad or out...
static vtkActor * New()
Creates an actor with the following defaults: origin(0,0,0) position=(0,0,0) scale=(1,1,1) visibility=1 pickable=1 dragable=1 orientation=(0,0,0).
vtkProperty * XAxesGridpolysProperty
vtkProperty * YAxesLinesProperty
void SetFlyModeToOuterEdges()
Specify a mode to control how the axes are drawn: either static, closest triad, furthest triad or out...
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
create a plot of a bounding box edges - used for navigation
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkProperty * XAxesLinesProperty
vtkProperty * ZAxesInnerGridlinesProperty
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkProperty * ZAxesGridpolysProperty
a virtual camera for 3D rendering
Definition: vtkCamera.h:44
double Bounds[6]
Definition: vtkProp3D.h:358
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkProperty * ZAxesGridlinesProperty
represent text properties.
void SetTickLocationToOutside(void)
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetTickLocationToBoth(void)
vtkProperty * YAxesGridpolysProperty
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
Support the standard render methods.
void SetFlyModeToStaticTriad()
Specify a mode to control how the axes are drawn: either static, closest triad, furthest triad or out...
vtkProperty * YAxesInnerGridlinesProperty
vtkProperty * XAxesGridlinesProperty
void SetFlyModeToClosestTriad()
Specify a mode to control how the axes are drawn: either static, closest triad, furthest triad or out...
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
#define max(a, b)
vtkProperty * XAxesInnerGridlinesProperty