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 =========================================================================*/
59 #ifndef vtkCubeAxesActor_h
60 #define vtkCubeAxesActor_h
61 
62 #include "vtkRenderingAnnotationModule.h" // For export macro
63 #include "vtkActor.h"
64 
65 class vtkAxisActor;
66 class vtkCamera;
67 class vtkTextProperty;
68 class vtkStringArray;
69 
70 class VTKRENDERINGANNOTATION_EXPORT vtkCubeAxesActor : public vtkActor
71 {
72 public:
73  vtkTypeMacro(vtkCubeAxesActor,vtkActor);
74  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
75 
80  static vtkCubeAxesActor *New();
81 
83 
86  int RenderOpaqueGeometry(vtkViewport*) VTK_OVERRIDE;
87  virtual int RenderTranslucentGeometry(vtkViewport*);
89  int RenderOverlay(vtkViewport*) VTK_OVERRIDE;
90  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
92 
94 
97  vtkSetMacro( RebuildAxes, bool );
98  vtkGetMacro( RebuildAxes, bool );
100 
102 
108  vtkSetVector6Macro(Bounds,double);
109  using Superclass::GetBounds;
110  double *GetBounds() VTK_OVERRIDE { return this->Bounds; }
112 
114 
118  virtual void GetRenderedBounds(double rBounds[6]);
119  virtual double* GetRenderedBounds();
121 
123 
131  vtkSetVector2Macro( XAxisRange, double );
132  vtkSetVector2Macro( YAxisRange, double );
133  vtkSetVector2Macro( ZAxisRange, double );
134  vtkGetVector2Macro( XAxisRange, double );
135  vtkGetVector2Macro( YAxisRange, double );
137 
138 
142  vtkStringArray* GetAxisLabels(int axis);
143  void SetAxisLabels(int axis, vtkStringArray* value);
145 
146  vtkGetVector2Macro( ZAxisRange, double );
147 
149 
154  void SetScreenSize(double screenSize);
155  vtkGetMacro(ScreenSize, double);
157 
159 
163  void SetLabelOffset(double offset);
164  vtkGetMacro(LabelOffset, double);
166 
168 
172  void SetTitleOffset(double offset);
173  vtkGetMacro(TitleOffset, double);
175 
177 
181  virtual void SetCamera(vtkCamera*);
182  vtkGetObjectMacro(Camera,vtkCamera);
184 
185  enum FlyMode
186  {
187  VTK_FLY_OUTER_EDGES = 0,
188  VTK_FLY_CLOSEST_TRIAD = 1,
189  VTK_FLY_FURTHEST_TRIAD = 2,
190  VTK_FLY_STATIC_TRIAD = 3,
191  VTK_FLY_STATIC_EDGES = 4
192  };
193 
195 
200  vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES);
201  vtkGetMacro(FlyMode, int);
203  {this->SetFlyMode(VTK_FLY_OUTER_EDGES);};
205  {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);};
207  {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);};
209  {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);};
211  {this->SetFlyMode(VTK_FLY_STATIC_EDGES);};
213 
215 
219  vtkSetStringMacro(XTitle);
220  vtkGetStringMacro(XTitle);
221  vtkSetStringMacro(XUnits);
222  vtkGetStringMacro(XUnits);
223  vtkSetStringMacro(YTitle);
224  vtkGetStringMacro(YTitle);
225  vtkSetStringMacro(YUnits);
226  vtkGetStringMacro(YUnits);
227  vtkSetStringMacro(ZTitle);
228  vtkGetStringMacro(ZTitle);
229  vtkSetStringMacro(ZUnits);
230  vtkGetStringMacro(ZUnits);
232 
234 
238  vtkSetStringMacro(XLabelFormat);
239  vtkGetStringMacro(XLabelFormat);
240  vtkSetStringMacro(YLabelFormat);
241  vtkGetStringMacro(YLabelFormat);
242  vtkSetStringMacro(ZLabelFormat);
243  vtkGetStringMacro(ZLabelFormat);
245 
247 
252  vtkSetClampMacro(Inertia, int, 1, VTK_INT_MAX);
253  vtkGetMacro(Inertia, int);
255 
257 
262  vtkSetMacro(CornerOffset, double);
263  vtkGetMacro(CornerOffset, double);
265 
271  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
272 
274 
277  vtkSetMacro( EnableDistanceLOD, int );
278  vtkGetMacro( EnableDistanceLOD, int );
280 
282 
285  vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 );
286  vtkGetMacro( DistanceLODThreshold, double);
288 
290 
293  vtkSetMacro( EnableViewAngleLOD, int );
294  vtkGetMacro( EnableViewAngleLOD, int );
296 
298 
301  vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. );
302  vtkGetMacro( ViewAngleLODThreshold, double );
304 
306 
309  vtkSetMacro(XAxisVisibility,int);
310  vtkGetMacro(XAxisVisibility,int);
311  vtkBooleanMacro(XAxisVisibility,int);
312  vtkSetMacro(YAxisVisibility,int);
313  vtkGetMacro(YAxisVisibility,int);
314  vtkBooleanMacro(YAxisVisibility,int);
315  vtkSetMacro(ZAxisVisibility,int);
316  vtkGetMacro(ZAxisVisibility,int);
317  vtkBooleanMacro(ZAxisVisibility,int);
319 
321 
324  vtkSetMacro(XAxisLabelVisibility,int);
325  vtkGetMacro(XAxisLabelVisibility,int);
326  vtkBooleanMacro(XAxisLabelVisibility,int);
328 
329  vtkSetMacro(YAxisLabelVisibility,int);
330  vtkGetMacro(YAxisLabelVisibility,int);
331  vtkBooleanMacro(YAxisLabelVisibility,int);
332 
333  vtkSetMacro(ZAxisLabelVisibility,int);
334  vtkGetMacro(ZAxisLabelVisibility,int);
335  vtkBooleanMacro(ZAxisLabelVisibility,int);
336 
338 
341  vtkSetMacro(XAxisTickVisibility,int);
342  vtkGetMacro(XAxisTickVisibility,int);
343  vtkBooleanMacro(XAxisTickVisibility,int);
345 
346  vtkSetMacro(YAxisTickVisibility,int);
347  vtkGetMacro(YAxisTickVisibility,int);
348  vtkBooleanMacro(YAxisTickVisibility,int);
349 
350  vtkSetMacro(ZAxisTickVisibility,int);
351  vtkGetMacro(ZAxisTickVisibility,int);
352  vtkBooleanMacro(ZAxisTickVisibility,int);
353 
355 
358  vtkSetMacro(XAxisMinorTickVisibility,int);
359  vtkGetMacro(XAxisMinorTickVisibility,int);
360  vtkBooleanMacro(XAxisMinorTickVisibility,int);
362 
363  vtkSetMacro(YAxisMinorTickVisibility,int);
364  vtkGetMacro(YAxisMinorTickVisibility,int);
365  vtkBooleanMacro(YAxisMinorTickVisibility,int);
366 
367  vtkSetMacro(ZAxisMinorTickVisibility,int);
368  vtkGetMacro(ZAxisMinorTickVisibility,int);
369  vtkBooleanMacro(ZAxisMinorTickVisibility,int);
370 
371  vtkSetMacro(DrawXGridlines,int);
372  vtkGetMacro(DrawXGridlines,int);
373  vtkBooleanMacro(DrawXGridlines,int);
374 
375  vtkSetMacro(DrawYGridlines,int);
376  vtkGetMacro(DrawYGridlines,int);
377  vtkBooleanMacro(DrawYGridlines,int);
378 
379  vtkSetMacro(DrawZGridlines,int);
380  vtkGetMacro(DrawZGridlines,int);
381  vtkBooleanMacro(DrawZGridlines,int);
382 
383  vtkSetMacro(DrawXInnerGridlines,int);
384  vtkGetMacro(DrawXInnerGridlines,int);
385  vtkBooleanMacro(DrawXInnerGridlines,int);
386 
387  vtkSetMacro(DrawYInnerGridlines,int);
388  vtkGetMacro(DrawYInnerGridlines,int);
389  vtkBooleanMacro(DrawYInnerGridlines,int);
390 
391  vtkSetMacro(DrawZInnerGridlines,int);
392  vtkGetMacro(DrawZInnerGridlines,int);
393  vtkBooleanMacro(DrawZInnerGridlines,int);
394 
395  vtkSetMacro(DrawXGridpolys,int);
396  vtkGetMacro(DrawXGridpolys,int);
397  vtkBooleanMacro(DrawXGridpolys,int);
398 
399  vtkSetMacro(DrawYGridpolys,int);
400  vtkGetMacro(DrawYGridpolys,int);
401  vtkBooleanMacro(DrawYGridpolys,int);
402 
403  vtkSetMacro(DrawZGridpolys,int);
404  vtkGetMacro(DrawZGridpolys,int);
405  vtkBooleanMacro(DrawZGridpolys,int);
406 
410  vtkTextProperty *GetTitleTextProperty(int);
411 
415  vtkTextProperty *GetLabelTextProperty(int);
416 
418 
421  void SetXAxesLinesProperty(vtkProperty *);
422  vtkProperty* GetXAxesLinesProperty();
423  void SetYAxesLinesProperty(vtkProperty *);
424  vtkProperty* GetYAxesLinesProperty();
425  void SetZAxesLinesProperty(vtkProperty *);
426  vtkProperty* GetZAxesLinesProperty();
428 
430 
433  void SetXAxesGridlinesProperty(vtkProperty *);
434  vtkProperty* GetXAxesGridlinesProperty();
435  void SetYAxesGridlinesProperty(vtkProperty *);
436  vtkProperty* GetYAxesGridlinesProperty();
437  void SetZAxesGridlinesProperty(vtkProperty *);
438  vtkProperty* GetZAxesGridlinesProperty();
440 
442 
445  void SetXAxesInnerGridlinesProperty(vtkProperty *);
446  vtkProperty* GetXAxesInnerGridlinesProperty();
447  void SetYAxesInnerGridlinesProperty(vtkProperty *);
448  vtkProperty* GetYAxesInnerGridlinesProperty();
449  void SetZAxesInnerGridlinesProperty(vtkProperty *);
450  vtkProperty* GetZAxesInnerGridlinesProperty();
452 
454 
457  void SetXAxesGridpolysProperty(vtkProperty *);
458  vtkProperty* GetXAxesGridpolysProperty();
459  void SetYAxesGridpolysProperty(vtkProperty *);
460  vtkProperty* GetYAxesGridpolysProperty();
461  void SetZAxesGridpolysProperty(vtkProperty *);
462  vtkProperty* GetZAxesGridpolysProperty();
464 
466  {
467  VTK_TICKS_INSIDE = 0,
468  VTK_TICKS_OUTSIDE = 1,
469  VTK_TICKS_BOTH = 2
470  };
471 
473 
476  vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
477  vtkGetMacro(TickLocation, int);
479 
481  { this->SetTickLocation(VTK_TICKS_INSIDE); };
483  { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
485  { this->SetTickLocation(VTK_TICKS_BOTH); };
486 
487  void SetLabelScaling(bool, int, int, int);
488 
490 
495  void SetUseTextActor3D( int val );
496  int GetUseTextActor3D();
498 
500 
504  void SetUse2DMode( int val );
505  int GetUse2DMode();
507 
511  void SetSaveTitlePosition( int val );
512 
514 
517  vtkSetVector6Macro(OrientedBounds,double);
518  vtkGetVector6Macro(OrientedBounds, double);
520 
522 
525  vtkSetMacro(UseOrientedBounds, int);
526  vtkGetMacro(UseOrientedBounds, int);
528 
530 
533  vtkSetVector3Macro(AxisBaseForX,double);
534  vtkGetVector3Macro(AxisBaseForX, double);
536 
538 
541  vtkSetVector3Macro(AxisBaseForY,double);
542  vtkGetVector3Macro(AxisBaseForY, double);
544 
546 
549  vtkSetVector3Macro(AxisBaseForZ,double);
550  vtkGetVector3Macro(AxisBaseForZ, double);
552 
554 
558  vtkSetVector3Macro(AxisOrigin,double);
559  vtkGetVector3Macro(AxisOrigin, double);
561 
563 
566  vtkSetMacro(UseAxisOrigin, int);
567  vtkGetMacro(UseAxisOrigin, int);
569 
571 
574  vtkSetMacro(GridLineLocation,int);
575  vtkGetMacro(GridLineLocation,int);
577 
579 
584  vtkSetMacro(StickyAxes,int);
585  vtkGetMacro(StickyAxes,int);
586  vtkBooleanMacro(StickyAxes,int);
588 
590 
597  vtkSetMacro(CenterStickyAxes,int);
598  vtkGetMacro(CenterStickyAxes,int);
599  vtkBooleanMacro(CenterStickyAxes,int);
601 
603  {
604  VTK_GRID_LINES_ALL = 0,
605  VTK_GRID_LINES_CLOSEST = 1,
606  VTK_GRID_LINES_FURTHEST = 2
607  };
608 
609 protected:
611  ~vtkCubeAxesActor() VTK_OVERRIDE;
612 
618  void ComputeStickyAxesBoundingSphere(vtkViewport* viewport, const double bounds[6],
619  double sphereCenter[3], double & sphereRadius);
620 
624  void GetViewportLimitedBounds(vtkViewport* viewport, double bounds[6]);
625 
630  static void GetBoundsPointBits(unsigned int pointIndex,
631  unsigned int & xBit,
632  unsigned int & yBit,
633  unsigned int & zBit);
634 
638  static void GetBoundsPoint(unsigned int pointIndex, const double bounds[6], double point[3]);
639 
640  int LabelExponent(double min, double max);
641 
642  int Digits(double min, double max);
643 
644  double MaxOf(double, double);
645  double MaxOf(double, double, double, double);
646 
647  double FFix(double);
648  double FSign(double, double);
649  int FRound( double fnt );
650  int GetNumTicks( double range, double fxt);
651 
652  void UpdateLabels(vtkAxisActor **axis, int index);
653 
654  vtkCamera *Camera;
655 
656  int FlyMode;
657 
658  // Expose internally closest axis index computation
659  int FindClosestAxisIndex(double pts[8][3]);
660 
661  // Expose internally furthest axis index computation
662  int FindFurtherstAxisIndex(double pts[8][3]);
663 
664  // Expose internally the boundary edge fly mode axis index computation
665  void FindBoundaryEdge(int &indexOfAxisX, int &indexOfAxisY, int &indexOfAxisZ,
666  double pts[8][3]);
667 
673  void UpdateGridLineVisibility(int axisIndex);
674 
675  // VTK_ALL_GRID_LINES 0
676  // VTK_CLOSEST_GRID_LINES 1
677  // VTK_FURTHEST_GRID_LINES 2
678  int GridLineLocation;
679 
683  int StickyAxes;
684 
688  int CenterStickyAxes;
689 
694  int EnableDistanceLOD;
695 
700  double DistanceLODThreshold;
701 
706  int EnableViewAngleLOD;
707 
712  double ViewAngleLODThreshold;
713 
715  {
716  NUMBER_OF_ALIGNED_AXIS = 4
717  };
718 
720 
724  vtkAxisActor *XAxes[NUMBER_OF_ALIGNED_AXIS];
725  vtkAxisActor *YAxes[NUMBER_OF_ALIGNED_AXIS];
726  vtkAxisActor *ZAxes[NUMBER_OF_ALIGNED_AXIS];
728 
730 
731  char *XTitle;
732  char *XUnits;
733  char *YTitle;
734  char *YUnits;
735  char *ZTitle;
736  char *ZUnits;
737 
741 
743 
747 
751 
755 
759 
763 
767 
771 
775 
776  double CornerOffset;
777 
778  int Inertia;
779 
781 
782  int InertiaLocs[3];
783 
785 
786  vtkTextProperty* TitleTextProperty[3];
787  vtkStringArray* AxisLabels[3];
788 
789  vtkTextProperty* LabelTextProperty[3];
790 
803 
804  double RenderedBounds[6];
805  double OrientedBounds[6];
807 
808  double AxisOrigin[3];
810 
811  double AxisBaseForX[3];
812  double AxisBaseForY[3];
813  double AxisBaseForZ[3];
814 
815 private:
816  vtkCubeAxesActor(const vtkCubeAxesActor&) VTK_DELETE_FUNCTION;
817  void operator=(const vtkCubeAxesActor&) VTK_DELETE_FUNCTION;
818 
819  vtkSetStringMacro(ActualXLabel);
820  vtkSetStringMacro(ActualYLabel);
821  vtkSetStringMacro(ActualZLabel);
822 
824  int LastUseOrientedBounds;
825  int LastXPow;
826  int LastYPow;
827  int LastZPow;
828 
829  int UserXPow;
830  int UserYPow;
831  int UserZPow;
832 
833  bool AutoLabelScaling;
834 
835  int LastXAxisDigits;
836  int LastYAxisDigits;
837  int LastZAxisDigits;
838 
839  double LastXRange[2];
840  double LastYRange[2];
841  double LastZRange[2];
842  double LastBounds[6];
843 
844  int LastFlyMode;
845 
846  int RenderAxesX[NUMBER_OF_ALIGNED_AXIS];
847  int RenderAxesY[NUMBER_OF_ALIGNED_AXIS];
848  int RenderAxesZ[NUMBER_OF_ALIGNED_AXIS];
849 
850  int NumberOfAxesX;
851  int NumberOfAxesY;
852  int NumberOfAxesZ;
853 
854  bool MustAdjustXValue;
855  bool MustAdjustYValue;
856  bool MustAdjustZValue;
857 
858  bool ForceXLabelReset;
859  bool ForceYLabelReset;
860  bool ForceZLabelReset;
861 
862  double XAxisRange[2];
863  double YAxisRange[2];
864  double ZAxisRange[2];
865 
866  double LabelScale;
867  double TitleScale;
868 
869  double ScreenSize;
870  double LabelOffset;
871  double TitleOffset;
872 
874 
878  double MajorStart[3];
879  double DeltaMajor[3];
881 
882  int RenderGeometry(bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility,int (vtkAxisActor::*renderMethod)(vtkViewport*));
883 
884  void TransformBounds(vtkViewport *viewport, const double bounds[6],
885  double pts[8][3]);
886  void AdjustAxes(double bounds[6],
887  double xCoords[NUMBER_OF_ALIGNED_AXIS][6],
888  double yCoords[NUMBER_OF_ALIGNED_AXIS][6],
889  double zCoords[NUMBER_OF_ALIGNED_AXIS][6],
890  double xRange[2], double yRange[2], double zRange[2]);
891 
892  bool ComputeTickSize(double bounds[6]);
893  void AdjustValues(const double xRange[2],
894  const double yRange[2],
895  const double zRange[2]);
896  void AdjustRange(const double bounds[6]);
897  void BuildAxes(vtkViewport *);
898  void DetermineRenderAxes(vtkViewport *);
899  void SetNonDependentAttributes(void);
900  void BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
901  void AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS],
902  double rangeMin, double rangeMax);
903 
904  void AutoScale(vtkViewport *viewport);
905  void AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
906  double AutoScale(vtkViewport *viewport, double screenSize, double position[3]);
907 };
908 
909 
910 #endif
vtkTimeStamp BuildTime
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
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:47
represent surface properties of a geometric object
Definition: vtkProperty.h:64
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:228
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:35
Create an axis with tick marks and labels.
Definition: vtkAxisActor.h:74
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:37
vtkProperty * XAxesLinesProperty
vtkProperty * ZAxesInnerGridlinesProperty
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkProperty * ZAxesGridpolysProperty
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
double Bounds[6]
Definition: vtkProp3D.h:361
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