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 =========================================================================*/
58 #ifndef vtkCubeAxesActor_h
59 #define vtkCubeAxesActor_h
60 
61 #define VTK_FLY_OUTER_EDGES 0
62 #define VTK_FLY_CLOSEST_TRIAD 1
63 #define VTK_FLY_FURTHEST_TRIAD 2
64 #define VTK_FLY_STATIC_TRIAD 3
65 #define VTK_FLY_STATIC_EDGES 4
66 
67 #define VTK_TICKS_INSIDE 0
68 #define VTK_TICKS_OUTSIDE 1
69 #define VTK_TICKS_BOTH 2
70 
71 #define VTK_GRID_LINES_ALL 0
72 #define VTK_GRID_LINES_CLOSEST 1
73 #define VTK_GRID_LINES_FURTHEST 2
74 
75 #define NUMBER_OF_ALIGNED_AXIS 4
76 
77 #include "vtkRenderingAnnotationModule.h" // For export macro
78 #include "vtkActor.h"
79 
80 class vtkAxisActor;
81 class vtkCamera;
82 class vtkTextProperty;
83 class vtkStringArray;
84 
86 {
87 public:
88  vtkTypeMacro(vtkCubeAxesActor,vtkActor);
89  void PrintSelf(ostream& os, vtkIndent indent);
90 
93  static vtkCubeAxesActor *New();
94 
96 
97  virtual int RenderOpaqueGeometry(vtkViewport*);
98  virtual int RenderTranslucentGeometry(vtkViewport*);
100  virtual int RenderOverlay(vtkViewport*);
103 
105 
106  vtkSetMacro( RebuildAxes, bool );
107  vtkGetMacro( RebuildAxes, bool );
109 
111 
115  vtkSetVector6Macro(Bounds,double);
116  vtkGetVector6Macro(Bounds,double);
118 
120 
122  virtual void GetRenderedBounds(double rBounds[6]);
123  virtual double* GetRenderedBounds();
125 
127 
134  vtkSetVector2Macro( XAxisRange, double );
135  vtkSetVector2Macro( YAxisRange, double );
136  vtkSetVector2Macro( ZAxisRange, double );
137  vtkGetVector2Macro( XAxisRange, double );
138  vtkGetVector2Macro( YAxisRange, double );
140 
141 
143  vtkStringArray* GetAxisLabels(int axis);
144  void SetAxisLabels(int axis, vtkStringArray* value);
146 
147  vtkGetVector2Macro( ZAxisRange, double );
148 
150 
153  void SetScreenSize(double screenSize);
154  vtkGetMacro(ScreenSize, double);
156 
158 
160  void SetLabelOffset(double offset);
161  vtkGetMacro(LabelOffset, double);
163 
165 
167  void SetTitleOffset(double offset);
168  vtkGetMacro(TitleOffset, double);
170 
172 
174  virtual void SetCamera(vtkCamera*);
175  vtkGetObjectMacro(Camera,vtkCamera);
177 
179 
182  vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES);
183  vtkGetMacro(FlyMode, int);
185  {this->SetFlyMode(VTK_FLY_OUTER_EDGES);};
187  {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);};
189  {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);};
191  {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);};
193  {this->SetFlyMode(VTK_FLY_STATIC_EDGES);};
195 
197 
199  vtkSetStringMacro(XTitle);
200  vtkGetStringMacro(XTitle);
201  vtkSetStringMacro(XUnits);
202  vtkGetStringMacro(XUnits);
203  vtkSetStringMacro(YTitle);
204  vtkGetStringMacro(YTitle);
205  vtkSetStringMacro(YUnits);
206  vtkGetStringMacro(YUnits);
207  vtkSetStringMacro(ZTitle);
208  vtkGetStringMacro(ZTitle);
209  vtkSetStringMacro(ZUnits);
210  vtkGetStringMacro(ZUnits);
212 
214 
216  vtkSetStringMacro(XLabelFormat);
217  vtkGetStringMacro(XLabelFormat);
218  vtkSetStringMacro(YLabelFormat);
219  vtkGetStringMacro(YLabelFormat);
220  vtkSetStringMacro(ZLabelFormat);
221  vtkGetStringMacro(ZLabelFormat);
223 
225 
228  vtkSetClampMacro(Inertia, int, 1, VTK_INT_MAX);
229  vtkGetMacro(Inertia, int);
231 
233 
236  vtkSetMacro(CornerOffset, double);
237  vtkGetMacro(CornerOffset, double);
239 
244 
246 
248  vtkSetMacro( EnableDistanceLOD, int );
249  vtkGetMacro( EnableDistanceLOD, int );
251 
253 
254  vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 );
255  vtkGetMacro( DistanceLODThreshold, double);
257 
259 
261  vtkSetMacro( EnableViewAngleLOD, int );
262  vtkGetMacro( EnableViewAngleLOD, int );
264 
266 
267  vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. );
268  vtkGetMacro( ViewAngleLODThreshold, double );
270 
272 
273  vtkSetMacro(XAxisVisibility,int);
274  vtkGetMacro(XAxisVisibility,int);
275  vtkBooleanMacro(XAxisVisibility,int);
276  vtkSetMacro(YAxisVisibility,int);
277  vtkGetMacro(YAxisVisibility,int);
278  vtkBooleanMacro(YAxisVisibility,int);
279  vtkSetMacro(ZAxisVisibility,int);
280  vtkGetMacro(ZAxisVisibility,int);
281  vtkBooleanMacro(ZAxisVisibility,int);
283 
285 
286  vtkSetMacro(XAxisLabelVisibility,int);
287  vtkGetMacro(XAxisLabelVisibility,int);
288  vtkBooleanMacro(XAxisLabelVisibility,int);
290 
291  vtkSetMacro(YAxisLabelVisibility,int);
292  vtkGetMacro(YAxisLabelVisibility,int);
293  vtkBooleanMacro(YAxisLabelVisibility,int);
294 
295  vtkSetMacro(ZAxisLabelVisibility,int);
296  vtkGetMacro(ZAxisLabelVisibility,int);
297  vtkBooleanMacro(ZAxisLabelVisibility,int);
298 
300 
301  vtkSetMacro(XAxisTickVisibility,int);
302  vtkGetMacro(XAxisTickVisibility,int);
303  vtkBooleanMacro(XAxisTickVisibility,int);
305 
306  vtkSetMacro(YAxisTickVisibility,int);
307  vtkGetMacro(YAxisTickVisibility,int);
308  vtkBooleanMacro(YAxisTickVisibility,int);
309 
310  vtkSetMacro(ZAxisTickVisibility,int);
311  vtkGetMacro(ZAxisTickVisibility,int);
312  vtkBooleanMacro(ZAxisTickVisibility,int);
313 
315 
316  vtkSetMacro(XAxisMinorTickVisibility,int);
317  vtkGetMacro(XAxisMinorTickVisibility,int);
318  vtkBooleanMacro(XAxisMinorTickVisibility,int);
320 
321  vtkSetMacro(YAxisMinorTickVisibility,int);
322  vtkGetMacro(YAxisMinorTickVisibility,int);
323  vtkBooleanMacro(YAxisMinorTickVisibility,int);
324 
325  vtkSetMacro(ZAxisMinorTickVisibility,int);
326  vtkGetMacro(ZAxisMinorTickVisibility,int);
327  vtkBooleanMacro(ZAxisMinorTickVisibility,int);
328 
329  vtkSetMacro(DrawXGridlines,int);
330  vtkGetMacro(DrawXGridlines,int);
331  vtkBooleanMacro(DrawXGridlines,int);
332 
333  vtkSetMacro(DrawYGridlines,int);
334  vtkGetMacro(DrawYGridlines,int);
335  vtkBooleanMacro(DrawYGridlines,int);
336 
337  vtkSetMacro(DrawZGridlines,int);
338  vtkGetMacro(DrawZGridlines,int);
339  vtkBooleanMacro(DrawZGridlines,int);
340 
341  vtkSetMacro(DrawXInnerGridlines,int);
342  vtkGetMacro(DrawXInnerGridlines,int);
343  vtkBooleanMacro(DrawXInnerGridlines,int);
344 
345  vtkSetMacro(DrawYInnerGridlines,int);
346  vtkGetMacro(DrawYInnerGridlines,int);
347  vtkBooleanMacro(DrawYInnerGridlines,int);
348 
349  vtkSetMacro(DrawZInnerGridlines,int);
350  vtkGetMacro(DrawZInnerGridlines,int);
351  vtkBooleanMacro(DrawZInnerGridlines,int);
352 
353  vtkSetMacro(DrawXGridpolys,int);
354  vtkGetMacro(DrawXGridpolys,int);
355  vtkBooleanMacro(DrawXGridpolys,int);
356 
357  vtkSetMacro(DrawYGridpolys,int);
358  vtkGetMacro(DrawYGridpolys,int);
359  vtkBooleanMacro(DrawYGridpolys,int);
360 
361  vtkSetMacro(DrawZGridpolys,int);
362  vtkGetMacro(DrawZGridpolys,int);
363  vtkBooleanMacro(DrawZGridpolys,int);
364 
366  vtkTextProperty *GetTitleTextProperty(int);
367 
369  vtkTextProperty *GetLabelTextProperty(int);
370 
372 
373  void SetXAxesLinesProperty(vtkProperty *);
374  vtkProperty* GetXAxesLinesProperty();
375  void SetYAxesLinesProperty(vtkProperty *);
376  vtkProperty* GetYAxesLinesProperty();
377  void SetZAxesLinesProperty(vtkProperty *);
378  vtkProperty* GetZAxesLinesProperty();
380 
382 
383  void SetXAxesGridlinesProperty(vtkProperty *);
384  vtkProperty* GetXAxesGridlinesProperty();
385  void SetYAxesGridlinesProperty(vtkProperty *);
386  vtkProperty* GetYAxesGridlinesProperty();
387  void SetZAxesGridlinesProperty(vtkProperty *);
388  vtkProperty* GetZAxesGridlinesProperty();
390 
392 
393  void SetXAxesInnerGridlinesProperty(vtkProperty *);
394  vtkProperty* GetXAxesInnerGridlinesProperty();
395  void SetYAxesInnerGridlinesProperty(vtkProperty *);
396  vtkProperty* GetYAxesInnerGridlinesProperty();
397  void SetZAxesInnerGridlinesProperty(vtkProperty *);
398  vtkProperty* GetZAxesInnerGridlinesProperty();
400 
402 
403  void SetXAxesGridpolysProperty(vtkProperty *);
404  vtkProperty* GetXAxesGridpolysProperty();
405  void SetYAxesGridpolysProperty(vtkProperty *);
406  vtkProperty* GetYAxesGridpolysProperty();
407  void SetZAxesGridpolysProperty(vtkProperty *);
408  vtkProperty* GetZAxesGridpolysProperty();
410 
412 
413  vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
414  vtkGetMacro(TickLocation, int);
416 
418  { this->SetTickLocation(VTK_TICKS_INSIDE); };
420  { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
422  { this->SetTickLocation(VTK_TICKS_BOTH); };
423 
424  void SetLabelScaling(bool, int, int, int);
425 
427 
429  void SetUseTextActor3D( int val );
430  int GetUseTextActor3D();
432 
434 
436  void SetUse2DMode( int val );
437  int GetUse2DMode();
439 
441  void SetSaveTitlePosition( int val );
442 
444 
445  vtkSetVector6Macro(OrientedBounds,double);
446  vtkGetVector6Macro(OrientedBounds, double);
448 
450 
451  vtkSetMacro(UseOrientedBounds, int);
452  vtkGetMacro(UseOrientedBounds, int);
454 
456 
457  vtkSetVector3Macro(AxisBaseForX,double);
458  vtkGetVector3Macro(AxisBaseForX, double);
460 
462 
463  vtkSetVector3Macro(AxisBaseForY,double);
464  vtkGetVector3Macro(AxisBaseForY, double);
466 
468 
469  vtkSetVector3Macro(AxisBaseForZ,double);
470  vtkGetVector3Macro(AxisBaseForZ, double);
472 
474 
476  vtkSetVector3Macro(AxisOrigin,double);
477  vtkGetVector3Macro(AxisOrigin, double);
479 
481 
482  vtkSetMacro(UseAxisOrigin, int);
483  vtkGetMacro(UseAxisOrigin, int);
485 
487 
488  vtkSetMacro(GridLineLocation,int);
489  vtkGetMacro(GridLineLocation,int);
491 
493 
496  vtkSetMacro(StickyAxes,int);
497  vtkGetMacro(StickyAxes,int);
498  vtkBooleanMacro(StickyAxes,int);
500 
502 
506  vtkSetMacro(CenterStickyAxes,int);
507  vtkGetMacro(CenterStickyAxes,int);
508  vtkBooleanMacro(CenterStickyAxes,int);
510 
511 protected:
513  ~vtkCubeAxesActor();
514 
516 
519  void ComputeStickyAxesBoundingSphere(vtkViewport* viewport, const double bounds[6],
520  double sphereCenter[3], double & sphereRadius);
522 
524  void GetViewportLimitedBounds(vtkViewport* viewport, double bounds[6]);
525 
527 
529  static void GetBoundsPointBits(unsigned int pointIndex,
530  unsigned int & xBit,
531  unsigned int & yBit,
532  unsigned int & zBit);
534 
536  static void GetBoundsPoint(unsigned int pointIndex, const double bounds[6], double point[3]);
537 
538  int LabelExponent(double min, double max);
539 
540  int Digits(double min, double max);
541 
542  double MaxOf(double, double);
543  double MaxOf(double, double, double, double);
544 
545  double FFix(double);
546  double FSign(double, double);
547  int FRound( double fnt );
548  int GetNumTicks( double range, double fxt);
549 
550  void UpdateLabels(vtkAxisActor **axis, int index);
551 
552  double Bounds[6]; //Define bounds explicitly
553 
555 
556  int FlyMode;
557 
558  // Expose internally closest axis index computation
559  int FindClosestAxisIndex(double pts[8][3]);
560 
561  // Expose internally furthest axis index computation
562  int FindFurtherstAxisIndex(double pts[8][3]);
563 
564  // Expose internally the boundary edge fly mode axis index computation
565  void FindBoundaryEdge(int &indexOfAxisX, int &indexOfAxisY, int &indexOfAxisZ,
566  double pts[8][3]);
567 
571  void UpdateGridLineVisibility(int axisIndex);
572 
573  // VTK_ALL_GRID_LINES 0
574  // VTK_CLOSEST_GRID_LINES 1
575  // VTK_FURTHEST_GRID_LINES 2
577 
580 
583 
587 
591 
595 
599 
601 
607 
609 
610  char *XTitle;
611  char *XUnits;
612  char *YTitle;
613  char *YUnits;
614  char *ZTitle;
615  char *ZUnits;
616 
620 
622 
626 
630 
634 
638 
642 
646 
650 
654 
655  double CornerOffset;
656 
657  int Inertia;
658 
660 
661  int InertiaLocs[3];
662 
664 
665  vtkTextProperty* TitleTextProperty[3];
666  vtkStringArray* AxisLabels[3];
667 
668  vtkTextProperty* LabelTextProperty[3];
669 
682 
683  double RenderedBounds[6];
684  double OrientedBounds[6];
686 
687  double AxisOrigin[3];
689 
690  double AxisBaseForX[3];
691  double AxisBaseForY[3];
692  double AxisBaseForZ[3];
693 
694 private:
695  vtkCubeAxesActor(const vtkCubeAxesActor&); // Not implemented
696  void operator=(const vtkCubeAxesActor&); // Not implemented
697 
698  vtkSetStringMacro(ActualXLabel);
699  vtkSetStringMacro(ActualYLabel);
700  vtkSetStringMacro(ActualZLabel);
701 
703  int LastUseOrientedBounds;
704  int LastXPow;
705  int LastYPow;
706  int LastZPow;
707 
708  int UserXPow;
709  int UserYPow;
710  int UserZPow;
711 
712  bool AutoLabelScaling;
713 
714  int LastXAxisDigits;
715  int LastYAxisDigits;
716  int LastZAxisDigits;
717 
718  double LastXRange[2];
719  double LastYRange[2];
720  double LastZRange[2];
721  double LastBounds[6];
722 
723  int LastFlyMode;
724 
725  int RenderAxesX[NUMBER_OF_ALIGNED_AXIS];
726  int RenderAxesY[NUMBER_OF_ALIGNED_AXIS];
727  int RenderAxesZ[NUMBER_OF_ALIGNED_AXIS];
728 
729  int NumberOfAxesX;
730  int NumberOfAxesY;
731  int NumberOfAxesZ;
732 
733  bool MustAdjustXValue;
734  bool MustAdjustYValue;
735  bool MustAdjustZValue;
736 
737  bool ForceXLabelReset;
738  bool ForceYLabelReset;
739  bool ForceZLabelReset;
740 
741  double XAxisRange[2];
742  double YAxisRange[2];
743  double ZAxisRange[2];
744 
745  double LabelScale;
746  double TitleScale;
747 
748  double ScreenSize;
749  double LabelOffset;
750  double TitleOffset;
751 
753 
755  double MajorStart[3];
756  double DeltaMajor[3];
758 
759  int RenderGeometry(bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility,int (vtkAxisActor::*renderMethod)(vtkViewport*));
760 
761  void TransformBounds(vtkViewport *viewport, const double bounds[6],
762  double pts[8][3]);
763  void AdjustAxes(double bounds[6],
764  double xCoords[NUMBER_OF_ALIGNED_AXIS][6],
765  double yCoords[NUMBER_OF_ALIGNED_AXIS][6],
766  double zCoords[NUMBER_OF_ALIGNED_AXIS][6],
767  double xRange[2], double yRange[2], double zRange[2]);
768 
769  bool ComputeTickSize(double bounds[6]);
770  void AdjustValues(const double xRange[2],
771  const double yRange[2],
772  const double zRange[2]);
773  void AdjustRange(const double bounds[6]);
774  void BuildAxes(vtkViewport *);
775  void DetermineRenderAxes(vtkViewport *);
776  void SetNonDependentAttributes(void);
777  void BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
778  void AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS],
779  double rangeMin, double rangeMax);
780 
781  void AutoScale(vtkViewport *viewport);
782  void AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
783  double AutoScale(vtkViewport *viewport, double screenSize, double position[3]);
784 };
785 
786 
787 #endif
#define VTK_FLY_CLOSEST_TRIAD
#define NUMBER_OF_ALIGNED_AXIS
vtkTimeStamp BuildTime
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
void SetFlyModeToStaticEdges()
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport)
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:63
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:204
#define VTK_INT_MAX
Definition: vtkType.h:130
record modification and/or execution time
Definition: vtkTimeStamp.h:34
Create an axis with tick marks and labels.
Definition: vtkAxisActor.h:90
#define VTK_FLY_STATIC_EDGES
vtkProperty * YAxesGridlinesProperty
vtkProperty * ZAxesLinesProperty
a vtkAbstractArray subclass for strings
void SetTickLocationToInside(void)
#define VTK_FLY_FURTHEST_TRIAD
void SetFlyModeToFurthestTriad()
static vtkActor * New()
vtkProperty * XAxesGridpolysProperty
vtkProperty * YAxesLinesProperty
void PrintSelf(ostream &os, vtkIndent indent)
#define VTKRENDERINGANNOTATION_EXPORT
create a plot of a bounding box edges - used for navigation
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
vtkProperty * XAxesLinesProperty
vtkProperty * ZAxesInnerGridlinesProperty
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkProperty * ZAxesGridpolysProperty
a virtual camera for 3D rendering
Definition: vtkCamera.h:49
#define VTK_FLY_OUTER_EDGES
#define VTK_TICKS_INSIDE
vtkProperty * ZAxesGridlinesProperty
#define VTK_FLY_STATIC_TRIAD
represent text properties.
void SetTickLocationToOutside(void)
void SetTickLocationToBoth(void)
vtkProperty * YAxesGridpolysProperty
virtual int RenderOpaqueGeometry(vtkViewport *viewport)
virtual int HasTranslucentPolygonalGeometry()
void SetFlyModeToStaticTriad()
vtkProperty * YAxesInnerGridlinesProperty
void ReleaseGraphicsResources(vtkWindow *)
#define VTK_TICKS_BOTH
vtkProperty * XAxesGridlinesProperty
void SetFlyModeToClosestTriad()
#define max(a, b)
#define VTK_TICKS_OUTSIDE
vtkProperty * XAxesInnerGridlinesProperty