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 =========================================================================*/
61 #ifndef vtkCubeAxesActor_h
62 #define vtkCubeAxesActor_h
63 
64 #define VTK_FLY_OUTER_EDGES 0
65 #define VTK_FLY_CLOSEST_TRIAD 1
66 #define VTK_FLY_FURTHEST_TRIAD 2
67 #define VTK_FLY_STATIC_TRIAD 3
68 #define VTK_FLY_STATIC_EDGES 4
69 
70 #define VTK_TICKS_INSIDE 0
71 #define VTK_TICKS_OUTSIDE 1
72 #define VTK_TICKS_BOTH 2
73 
74 #define VTK_GRID_LINES_ALL 0
75 #define VTK_GRID_LINES_CLOSEST 1
76 #define VTK_GRID_LINES_FURTHEST 2
77 
78 #define NUMBER_OF_ALIGNED_AXIS 4
79 
80 #include "vtkRenderingAnnotationModule.h" // For export macro
81 #include "vtkActor.h"
82 
83 class vtkAxisActor;
84 class vtkCamera;
85 class vtkTextProperty;
86 class vtkStringArray;
87 
89 {
90 public:
91  vtkTypeMacro(vtkCubeAxesActor,vtkActor);
92  void PrintSelf(ostream& os, vtkIndent indent);
93 
96  static vtkCubeAxesActor *New();
97 
99 
100  virtual int RenderOpaqueGeometry(vtkViewport*);
101  virtual int RenderTranslucentGeometry(vtkViewport*);
103  virtual int RenderOverlay(vtkViewport*);
106 
108 
109  vtkSetMacro( RebuildAxes, bool );
110  vtkGetMacro( RebuildAxes, bool );
112 
114 
118  vtkSetVector6Macro(Bounds,double);
119  vtkGetVector6Macro(Bounds,double);
121 
123 
125  virtual void GetRenderedBounds(double rBounds[6]);
126  virtual double* GetRenderedBounds();
128 
130 
137  vtkSetVector2Macro( XAxisRange, double );
138  vtkSetVector2Macro( YAxisRange, double );
139  vtkSetVector2Macro( ZAxisRange, double );
140  vtkGetVector2Macro( XAxisRange, double );
141  vtkGetVector2Macro( YAxisRange, double );
143 
144 
146  vtkStringArray* GetAxisLabels(int axis);
147  void SetAxisLabels(int axis, vtkStringArray* value);
149 
150  vtkGetVector2Macro( ZAxisRange, double );
151 
153 
156  void SetScreenSize(double screenSize);
157  vtkGetMacro(ScreenSize, double);
159 
161 
163  void SetLabelOffset(double offset);
164  vtkGetMacro(LabelOffset, double);
166 
168 
170  void SetTitleOffset(double offset);
171  vtkGetMacro(TitleOffset, double);
173 
175 
177  virtual void SetCamera(vtkCamera*);
178  vtkGetObjectMacro(Camera,vtkCamera);
180 
182 
185  vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES);
186  vtkGetMacro(FlyMode, int);
188  {this->SetFlyMode(VTK_FLY_OUTER_EDGES);};
190  {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);};
192  {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);};
194  {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);};
196  {this->SetFlyMode(VTK_FLY_STATIC_EDGES);};
198 
200 
202  vtkSetStringMacro(XTitle);
203  vtkGetStringMacro(XTitle);
204  vtkSetStringMacro(XUnits);
205  vtkGetStringMacro(XUnits);
206  vtkSetStringMacro(YTitle);
207  vtkGetStringMacro(YTitle);
208  vtkSetStringMacro(YUnits);
209  vtkGetStringMacro(YUnits);
210  vtkSetStringMacro(ZTitle);
211  vtkGetStringMacro(ZTitle);
212  vtkSetStringMacro(ZUnits);
213  vtkGetStringMacro(ZUnits);
215 
217 
219  vtkSetStringMacro(XLabelFormat);
220  vtkGetStringMacro(XLabelFormat);
221  vtkSetStringMacro(YLabelFormat);
222  vtkGetStringMacro(YLabelFormat);
223  vtkSetStringMacro(ZLabelFormat);
224  vtkGetStringMacro(ZLabelFormat);
226 
228 
231  vtkSetClampMacro(Inertia, int, 1, VTK_INT_MAX);
232  vtkGetMacro(Inertia, int);
234 
236 
239  vtkSetMacro(CornerOffset, double);
240  vtkGetMacro(CornerOffset, double);
242 
247 
249 
251  vtkSetMacro( EnableDistanceLOD, int );
252  vtkGetMacro( EnableDistanceLOD, int );
254 
256 
257  vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 );
258  vtkGetMacro( DistanceLODThreshold, double);
260 
262 
264  vtkSetMacro( EnableViewAngleLOD, int );
265  vtkGetMacro( EnableViewAngleLOD, int );
267 
269 
270  vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. );
271  vtkGetMacro( ViewAngleLODThreshold, double );
273 
275 
276  vtkSetMacro(XAxisVisibility,int);
277  vtkGetMacro(XAxisVisibility,int);
278  vtkBooleanMacro(XAxisVisibility,int);
279  vtkSetMacro(YAxisVisibility,int);
280  vtkGetMacro(YAxisVisibility,int);
281  vtkBooleanMacro(YAxisVisibility,int);
282  vtkSetMacro(ZAxisVisibility,int);
283  vtkGetMacro(ZAxisVisibility,int);
284  vtkBooleanMacro(ZAxisVisibility,int);
286 
288 
289  vtkSetMacro(XAxisLabelVisibility,int);
290  vtkGetMacro(XAxisLabelVisibility,int);
291  vtkBooleanMacro(XAxisLabelVisibility,int);
293 
294  vtkSetMacro(YAxisLabelVisibility,int);
295  vtkGetMacro(YAxisLabelVisibility,int);
296  vtkBooleanMacro(YAxisLabelVisibility,int);
297 
298  vtkSetMacro(ZAxisLabelVisibility,int);
299  vtkGetMacro(ZAxisLabelVisibility,int);
300  vtkBooleanMacro(ZAxisLabelVisibility,int);
301 
303 
304  vtkSetMacro(XAxisTickVisibility,int);
305  vtkGetMacro(XAxisTickVisibility,int);
306  vtkBooleanMacro(XAxisTickVisibility,int);
308 
309  vtkSetMacro(YAxisTickVisibility,int);
310  vtkGetMacro(YAxisTickVisibility,int);
311  vtkBooleanMacro(YAxisTickVisibility,int);
312 
313  vtkSetMacro(ZAxisTickVisibility,int);
314  vtkGetMacro(ZAxisTickVisibility,int);
315  vtkBooleanMacro(ZAxisTickVisibility,int);
316 
318 
319  vtkSetMacro(XAxisMinorTickVisibility,int);
320  vtkGetMacro(XAxisMinorTickVisibility,int);
321  vtkBooleanMacro(XAxisMinorTickVisibility,int);
323 
324  vtkSetMacro(YAxisMinorTickVisibility,int);
325  vtkGetMacro(YAxisMinorTickVisibility,int);
326  vtkBooleanMacro(YAxisMinorTickVisibility,int);
327 
328  vtkSetMacro(ZAxisMinorTickVisibility,int);
329  vtkGetMacro(ZAxisMinorTickVisibility,int);
330  vtkBooleanMacro(ZAxisMinorTickVisibility,int);
331 
332  vtkSetMacro(DrawXGridlines,int);
333  vtkGetMacro(DrawXGridlines,int);
334  vtkBooleanMacro(DrawXGridlines,int);
335 
336  vtkSetMacro(DrawYGridlines,int);
337  vtkGetMacro(DrawYGridlines,int);
338  vtkBooleanMacro(DrawYGridlines,int);
339 
340  vtkSetMacro(DrawZGridlines,int);
341  vtkGetMacro(DrawZGridlines,int);
342  vtkBooleanMacro(DrawZGridlines,int);
343 
344  vtkSetMacro(DrawXInnerGridlines,int);
345  vtkGetMacro(DrawXInnerGridlines,int);
346  vtkBooleanMacro(DrawXInnerGridlines,int);
347 
348  vtkSetMacro(DrawYInnerGridlines,int);
349  vtkGetMacro(DrawYInnerGridlines,int);
350  vtkBooleanMacro(DrawYInnerGridlines,int);
351 
352  vtkSetMacro(DrawZInnerGridlines,int);
353  vtkGetMacro(DrawZInnerGridlines,int);
354  vtkBooleanMacro(DrawZInnerGridlines,int);
355 
356  vtkSetMacro(DrawXGridpolys,int);
357  vtkGetMacro(DrawXGridpolys,int);
358  vtkBooleanMacro(DrawXGridpolys,int);
359 
360  vtkSetMacro(DrawYGridpolys,int);
361  vtkGetMacro(DrawYGridpolys,int);
362  vtkBooleanMacro(DrawYGridpolys,int);
363 
364  vtkSetMacro(DrawZGridpolys,int);
365  vtkGetMacro(DrawZGridpolys,int);
366  vtkBooleanMacro(DrawZGridpolys,int);
367 
369  vtkTextProperty *GetTitleTextProperty(int);
370 
372  vtkTextProperty *GetLabelTextProperty(int);
373 
375 
376  void SetXAxesLinesProperty(vtkProperty *);
377  vtkProperty* GetXAxesLinesProperty();
378  void SetYAxesLinesProperty(vtkProperty *);
379  vtkProperty* GetYAxesLinesProperty();
380  void SetZAxesLinesProperty(vtkProperty *);
381  vtkProperty* GetZAxesLinesProperty();
383 
385 
386  void SetXAxesGridlinesProperty(vtkProperty *);
387  vtkProperty* GetXAxesGridlinesProperty();
388  void SetYAxesGridlinesProperty(vtkProperty *);
389  vtkProperty* GetYAxesGridlinesProperty();
390  void SetZAxesGridlinesProperty(vtkProperty *);
391  vtkProperty* GetZAxesGridlinesProperty();
393 
395 
396  void SetXAxesInnerGridlinesProperty(vtkProperty *);
397  vtkProperty* GetXAxesInnerGridlinesProperty();
398  void SetYAxesInnerGridlinesProperty(vtkProperty *);
399  vtkProperty* GetYAxesInnerGridlinesProperty();
400  void SetZAxesInnerGridlinesProperty(vtkProperty *);
401  vtkProperty* GetZAxesInnerGridlinesProperty();
403 
405 
406  void SetXAxesGridpolysProperty(vtkProperty *);
407  vtkProperty* GetXAxesGridpolysProperty();
408  void SetYAxesGridpolysProperty(vtkProperty *);
409  vtkProperty* GetYAxesGridpolysProperty();
410  void SetZAxesGridpolysProperty(vtkProperty *);
411  vtkProperty* GetZAxesGridpolysProperty();
413 
415 
416  vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
417  vtkGetMacro(TickLocation, int);
419 
421  { this->SetTickLocation(VTK_TICKS_INSIDE); };
423  { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
425  { this->SetTickLocation(VTK_TICKS_BOTH); };
426 
427  void SetLabelScaling(bool, int, int, int);
428 
430 
432  void SetUseTextActor3D( int val );
433  int GetUseTextActor3D();
435 
437 
439  void SetUse2DMode( int val );
440  int GetUse2DMode();
442 
444  void SetSaveTitlePosition( int val );
445 
447 
448  vtkSetVector6Macro(OrientedBounds,double);
449  vtkGetVector6Macro(OrientedBounds, double);
451 
453 
454  vtkSetMacro(UseOrientedBounds, int);
455  vtkGetMacro(UseOrientedBounds, int);
457 
459 
460  vtkSetVector3Macro(AxisBaseForX,double);
461  vtkGetVector3Macro(AxisBaseForX, double);
463 
465 
466  vtkSetVector3Macro(AxisBaseForY,double);
467  vtkGetVector3Macro(AxisBaseForY, double);
469 
471 
472  vtkSetVector3Macro(AxisBaseForZ,double);
473  vtkGetVector3Macro(AxisBaseForZ, double);
475 
477 
479  vtkSetVector3Macro(AxisOrigin,double);
480  vtkGetVector3Macro(AxisOrigin, double);
482 
484 
485  vtkSetMacro(UseAxisOrigin, int);
486  vtkGetMacro(UseAxisOrigin, int);
488 
490 
491  vtkSetMacro(GridLineLocation,int);
492  vtkGetMacro(GridLineLocation,int);
494 
496 
499  vtkSetMacro(StickyAxes,int);
500  vtkGetMacro(StickyAxes,int);
501  vtkBooleanMacro(StickyAxes,int);
503 
505 
509  vtkSetMacro(CenterStickyAxes,int);
510  vtkGetMacro(CenterStickyAxes,int);
511  vtkBooleanMacro(CenterStickyAxes,int);
513 
514 protected:
516  ~vtkCubeAxesActor();
517 
519 
522  void ComputeStickyAxesBoundingSphere(vtkViewport* viewport, const double bounds[6],
523  double sphereCenter[3], double & sphereRadius);
525 
527  void GetViewportLimitedBounds(vtkViewport* viewport, double bounds[6]);
528 
530 
532  static void GetBoundsPointBits(unsigned int pointIndex,
533  unsigned int & xBit,
534  unsigned int & yBit,
535  unsigned int & zBit);
537 
539  static void GetBoundsPoint(unsigned int pointIndex, const double bounds[6], double point[3]);
540 
541  int LabelExponent(double min, double max);
542 
543  int Digits(double min, double max);
544 
545  double MaxOf(double, double);
546  double MaxOf(double, double, double, double);
547 
548  double FFix(double);
549  double FSign(double, double);
550  int FRound( double fnt );
551  int GetNumTicks( double range, double fxt);
552 
553  void UpdateLabels(vtkAxisActor **axis, int index);
554 
555  double Bounds[6]; //Define bounds explicitly
556 
558 
559  int FlyMode;
560 
561  // Expose internally closest axis index computation
562  int FindClosestAxisIndex(double pts[8][3]);
563 
564  // Expose internally furthest axis index computation
565  int FindFurtherstAxisIndex(double pts[8][3]);
566 
567  // Expose internally the boundary edge fly mode axis index computation
568  void FindBoundaryEdge(int &indexOfAxisX, int &indexOfAxisY, int &indexOfAxisZ,
569  double pts[8][3]);
570 
574  void UpdateGridLineVisibility(int axisIndex);
575 
576  // VTK_ALL_GRID_LINES 0
577  // VTK_CLOSEST_GRID_LINES 1
578  // VTK_FURTHEST_GRID_LINES 2
580 
583 
586 
590 
594 
598 
602 
604 
610 
612 
613  char *XTitle;
614  char *XUnits;
615  char *YTitle;
616  char *YUnits;
617  char *ZTitle;
618  char *ZUnits;
619 
623 
625 
629 
633 
637 
641 
645 
649 
653 
657 
658  double CornerOffset;
659 
660  int Inertia;
661 
663 
664  int InertiaLocs[3];
665 
667 
668  vtkTextProperty* TitleTextProperty[3];
669  vtkStringArray* AxisLabels[3];
670 
671  vtkTextProperty* LabelTextProperty[3];
672 
685 
686  double RenderedBounds[6];
687  double OrientedBounds[6];
689 
690  double AxisOrigin[3];
692 
693  double AxisBaseForX[3];
694  double AxisBaseForY[3];
695  double AxisBaseForZ[3];
696 
697 private:
698  vtkCubeAxesActor(const vtkCubeAxesActor&); // Not implemented
699  void operator=(const vtkCubeAxesActor&); // Not implemented
700 
701  vtkSetStringMacro(ActualXLabel);
702  vtkSetStringMacro(ActualYLabel);
703  vtkSetStringMacro(ActualZLabel);
704 
706  int LastUseOrientedBounds;
707  int LastXPow;
708  int LastYPow;
709  int LastZPow;
710 
711  int UserXPow;
712  int UserYPow;
713  int UserZPow;
714 
715  bool AutoLabelScaling;
716 
717  int LastXAxisDigits;
718  int LastYAxisDigits;
719  int LastZAxisDigits;
720 
721  double LastXRange[2];
722  double LastYRange[2];
723  double LastZRange[2];
724  double LastBounds[6];
725 
726  int LastFlyMode;
727 
728  int RenderAxesX[NUMBER_OF_ALIGNED_AXIS];
729  int RenderAxesY[NUMBER_OF_ALIGNED_AXIS];
730  int RenderAxesZ[NUMBER_OF_ALIGNED_AXIS];
731 
732  int NumberOfAxesX;
733  int NumberOfAxesY;
734  int NumberOfAxesZ;
735 
736  bool MustAdjustXValue;
737  bool MustAdjustYValue;
738  bool MustAdjustZValue;
739 
740  bool ForceXLabelReset;
741  bool ForceYLabelReset;
742  bool ForceZLabelReset;
743 
744  double XAxisRange[2];
745  double YAxisRange[2];
746  double ZAxisRange[2];
747 
748  double LabelScale;
749  double TitleScale;
750 
751  double ScreenSize;
752  double LabelOffset;
753  double TitleOffset;
754 
756 
758  double MajorStart[3];
759  double DeltaMajor[3];
761 
762  int RenderGeometry(bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility,int (vtkAxisActor::*renderMethod)(vtkViewport*));
763 
764  void TransformBounds(vtkViewport *viewport, const double bounds[6],
765  double pts[8][3]);
766  void AdjustAxes(double bounds[6],
767  double xCoords[NUMBER_OF_ALIGNED_AXIS][6],
768  double yCoords[NUMBER_OF_ALIGNED_AXIS][6],
769  double zCoords[NUMBER_OF_ALIGNED_AXIS][6],
770  double xRange[2], double yRange[2], double zRange[2]);
771 
772  bool ComputeTickSize(double bounds[6]);
773  void AdjustValues(const double xRange[2],
774  const double yRange[2],
775  const double zRange[2]);
776  void AdjustRange(const double bounds[6]);
777  void BuildAxes(vtkViewport *);
778  void DetermineRenderAxes(vtkViewport *);
779  void SetNonDependentAttributes(void);
780  void BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
781  void AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS],
782  double rangeMin, double rangeMax);
783 
784  void AutoScale(vtkViewport *viewport);
785  void AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
786  double AutoScale(vtkViewport *viewport, double screenSize, double position[3]);
787 };
788 
789 
790 #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:132
record modification and/or execution time
Definition: vtkTimeStamp.h:34
Create an axis with tick marks and labels.
Definition: vtkAxisActor.h:93
#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 -
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:48
#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