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:
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*);
180 
182 
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 
495 protected:
497  ~vtkCubeAxesActor();
498 
499  int LabelExponent(double min, double max);
500 
501  int Digits(double min, double max);
502 
503  double MaxOf(double, double);
504  double MaxOf(double, double, double, double);
505 
506  double FFix(double);
507  double FSign(double, double);
508  int FRound( double fnt );
509  int GetNumTicks( double range, double fxt);
510 
511  void UpdateLabels(vtkAxisActor **axis, int index);
512 
513  double Bounds[6]; //Define bounds explicitly
514 
516 
517  int FlyMode;
518 
519  // Expose internally closest axis index computation
520  int FindClosestAxisIndex(double pts[8][3]);
521 
522  // Expose internally furthest axis index computation
523  int FindFurtherstAxisIndex(double pts[8][3]);
524 
525  // Expose internally the boundary edge fly mode axis index computation
526  void FindBoundaryEdge(int &indexOfAxisX, int &indexOfAxisY, int &indexOfAxisZ,
527  double pts[8][3]);
528 
532  void UpdateGridLineVisibility(int axisIndex);
533 
534  // VTK_ALL_GRID_LINES 0
535  // VTK_CLOSEST_GRID_LINES 1
536  // VTK_FURTHEST_GRID_LINES 2
538 
542 
546 
550 
554 
556 
562 
564 
565  char *XTitle;
566  char *XUnits;
567  char *YTitle;
568  char *YUnits;
569  char *ZTitle;
570  char *ZUnits;
571 
575 
577 
581 
585 
589 
593 
597 
601 
605 
609 
610  double CornerOffset;
611 
612  int Inertia;
613 
615 
616  int InertiaLocs[3];
617 
619 
620  vtkTextProperty* TitleTextProperty[3];
621  vtkStringArray* AxisLabels[3];
622 
623  vtkTextProperty* LabelTextProperty[3];
624 
637 
638  double RenderedBounds[6];
639  double OrientedBounds[6];
641 
642  double AxisOrigin[3];
644 
645  double AxisBaseForX[3];
646  double AxisBaseForY[3];
647  double AxisBaseForZ[3];
648 
649 private:
650  vtkCubeAxesActor(const vtkCubeAxesActor&); // Not implemented
651  void operator=(const vtkCubeAxesActor&); // Not implemented
652 
653  vtkSetStringMacro(ActualXLabel);
654  vtkSetStringMacro(ActualYLabel);
655  vtkSetStringMacro(ActualZLabel);
656 
658  int LastUseOrientedBounds;
659  int LastXPow;
660  int LastYPow;
661  int LastZPow;
662 
663  int UserXPow;
664  int UserYPow;
665  int UserZPow;
666 
667  bool AutoLabelScaling;
668 
669  int LastXAxisDigits;
670  int LastYAxisDigits;
671  int LastZAxisDigits;
672 
673  double LastXRange[2];
674  double LastYRange[2];
675  double LastZRange[2];
676  double LastBounds[6];
677 
678  int LastFlyMode;
679 
680  int RenderAxesX[NUMBER_OF_ALIGNED_AXIS];
681  int RenderAxesY[NUMBER_OF_ALIGNED_AXIS];
682  int RenderAxesZ[NUMBER_OF_ALIGNED_AXIS];
683 
684  int NumberOfAxesX;
685  int NumberOfAxesY;
686  int NumberOfAxesZ;
687 
688  bool MustAdjustXValue;
689  bool MustAdjustYValue;
690  bool MustAdjustZValue;
691 
692  bool ForceXLabelReset;
693  bool ForceYLabelReset;
694  bool ForceZLabelReset;
695 
696  double XAxisRange[2];
697  double YAxisRange[2];
698  double ZAxisRange[2];
699 
700  double LabelScale;
701  double TitleScale;
702 
703  double ScreenSize;
704  double LabelOffset;
705  double TitleOffset;
706 
708 
710  double MajorStart[3];
711  double DeltaMajor[3];
713 
714  int RenderGeometry(bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility,int (vtkAxisActor::*renderMethod)(vtkViewport*));
715 
716  void TransformBounds(vtkViewport *viewport, const double bounds[6],
717  double pts[8][3]);
718  void AdjustAxes(double bounds[6],
719  double xCoords[NUMBER_OF_ALIGNED_AXIS][6],
720  double yCoords[NUMBER_OF_ALIGNED_AXIS][6],
721  double zCoords[NUMBER_OF_ALIGNED_AXIS][6],
722  double xRange[2], double yRange[2], double zRange[2]);
723 
724  bool ComputeTickSize(double bounds[6]);
725  void AdjustValues(const double xRange[2],
726  const double yRange[2],
727  const double zRange[2]);
728  void AdjustRange(const double bounds[6]);
729  void BuildAxes(vtkViewport *);
730  void DetermineRenderAxes(vtkViewport *);
731  void SetNonDependentAttributes(void);
732  void BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
733  void AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS],
734  double rangeMin, double rangeMax);
735 
736  void AutoScale(vtkViewport *viewport);
737  void AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
738  double AutoScale(vtkViewport *viewport, double screenSize, double position[3]);
739 };
740 
741 
742 #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)
GLuint index
Definition: vtkgl.h:11983
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:183
GLintptr offset
Definition: vtkgl.h:11844
#define VTK_INT_MAX
Definition: vtkType.h:131
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
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
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
void SetFlyModeToFurthestTriad()
static vtkActor * New()
#define vtkSetStringMacro(name)
Definition: vtkSetGet.h:94
vtkProperty * XAxesGridpolysProperty
vtkProperty * YAxesLinesProperty
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
void PrintSelf(ostream &os, vtkIndent indent)
#define VTKRENDERINGANNOTATION_EXPORT
create a plot of a bounding box edges -
window superclass for vtkRenderWindow
Definition: vtkWindow.h:33
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
#define vtkGetVector3Macro(name, type)
Definition: vtkSetGet.h:294
vtkProperty * ZAxesGridlinesProperty
#define VTK_FLY_STATIC_TRIAD
#define vtkGetStringMacro(name)
Definition: vtkSetGet.h:120
represent text properties.
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
void SetTickLocationToOutside(void)
#define vtkSetVector6Macro(name, type)
Definition: vtkSetGet.h:350
void SetTickLocationToBoth(void)
vtkProperty * YAxesGridpolysProperty
#define vtkGetVector2Macro(name, type)
Definition: vtkSetGet.h:260
virtual int RenderOpaqueGeometry(vtkViewport *viewport)
virtual int HasTranslucentPolygonalGeometry()
void SetFlyModeToStaticTriad()
vtkProperty * YAxesInnerGridlinesProperty
void ReleaseGraphicsResources(vtkWindow *)
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
#define VTK_TICKS_BOTH
vtkProperty * XAxesGridlinesProperty
void SetFlyModeToClosestTriad()
#define vtkGetVector6Macro(name, type)
Definition: vtkSetGet.h:370
#define vtkSetVector3Macro(name, type)
Definition: vtkSetGet.h:277
GLenum GLint * range
Definition: vtkgl.h:14180
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:244
#define max(a, b)
#define VTK_TICKS_OUTSIDE
vtkProperty * XAxesInnerGridlinesProperty
GLuint GLfloat * val
Definition: vtkgl.h:13789
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69