VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/Annotation/vtkCubeAxesActor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCubeAxesActor.h
00005   Language:  C++
00006 
00007 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen
00008 All rights reserve
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00013      PURPOSE.  See the above copyright notice for more information.
00014 =========================================================================*/
00061 #ifndef vtkCubeAxesActor_h
00062 #define vtkCubeAxesActor_h
00063 
00064 #define VTK_FLY_OUTER_EDGES     0
00065 #define VTK_FLY_CLOSEST_TRIAD   1
00066 #define VTK_FLY_FURTHEST_TRIAD  2
00067 #define VTK_FLY_STATIC_TRIAD    3
00068 #define VTK_FLY_STATIC_EDGES    4
00069 
00070 #define VTK_TICKS_INSIDE        0
00071 #define VTK_TICKS_OUTSIDE       1
00072 #define VTK_TICKS_BOTH          2
00073 
00074 #define VTK_GRID_LINES_ALL      0
00075 #define VTK_GRID_LINES_CLOSEST  1
00076 #define VTK_GRID_LINES_FURTHEST 2
00077 
00078 #define NUMBER_OF_ALIGNED_AXIS 4
00079 
00080 #include "vtkRenderingAnnotationModule.h" // For export macro
00081 #include "vtkActor.h"
00082 
00083 class vtkAxisActor;
00084 class vtkCamera;
00085 class vtkTextProperty;
00086 class vtkStringArray;
00087 
00088 class VTKRENDERINGANNOTATION_EXPORT vtkCubeAxesActor : public vtkActor
00089 {
00090 public:
00091   vtkTypeMacro(vtkCubeAxesActor,vtkActor);
00092   void PrintSelf(ostream& os, vtkIndent indent);
00093 
00096   static vtkCubeAxesActor *New();
00097 
00099 
00100   virtual int RenderOpaqueGeometry(vtkViewport*);
00101   virtual int RenderTranslucentGeometry(vtkViewport*);
00102   virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
00103   virtual int RenderOverlay(vtkViewport*);
00104   int HasTranslucentPolygonalGeometry();
00106 
00108 
00109   vtkSetMacro( RebuildAxes, bool );
00110   vtkGetMacro( RebuildAxes, bool );
00112 
00114 
00118   vtkSetVector6Macro(Bounds,double);
00119   vtkGetVector6Macro(Bounds,double);
00121 
00123 
00125   virtual void GetRenderedBounds(double rBounds[6]);
00126   virtual double* GetRenderedBounds();
00128 
00130 
00137   vtkSetVector2Macro( XAxisRange, double );
00138   vtkSetVector2Macro( YAxisRange, double );
00139   vtkSetVector2Macro( ZAxisRange, double );
00140   vtkGetVector2Macro( XAxisRange, double );
00141   vtkGetVector2Macro( YAxisRange, double );
00143 
00144 
00146   vtkStringArray* GetAxisLabels(int axis);
00147   void SetAxisLabels(int axis, vtkStringArray* value);
00149 
00150   vtkGetVector2Macro( ZAxisRange, double );
00151 
00153 
00156   void SetScreenSize(double screenSize);
00157   vtkGetMacro(ScreenSize, double);
00159 
00161 
00163   void SetLabelOffset(double offset);
00164   vtkGetMacro(LabelOffset, double);
00166 
00168 
00170   void SetTitleOffset(double offset);
00171   vtkGetMacro(TitleOffset, double);
00173 
00175 
00177   virtual void SetCamera(vtkCamera*);
00178   vtkGetObjectMacro(Camera,vtkCamera);
00180 
00182 
00185   vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES);
00186   vtkGetMacro(FlyMode, int);
00187   void SetFlyModeToOuterEdges()
00188     {this->SetFlyMode(VTK_FLY_OUTER_EDGES);};
00189   void SetFlyModeToClosestTriad()
00190     {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);};
00191   void SetFlyModeToFurthestTriad()
00192     {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);};
00193   void SetFlyModeToStaticTriad()
00194     {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);};
00195   void SetFlyModeToStaticEdges()
00196     {this->SetFlyMode(VTK_FLY_STATIC_EDGES);};
00198 
00200 
00202   vtkSetStringMacro(XTitle);
00203   vtkGetStringMacro(XTitle);
00204   vtkSetStringMacro(XUnits);
00205   vtkGetStringMacro(XUnits);
00206   vtkSetStringMacro(YTitle);
00207   vtkGetStringMacro(YTitle);
00208   vtkSetStringMacro(YUnits);
00209   vtkGetStringMacro(YUnits);
00210   vtkSetStringMacro(ZTitle);
00211   vtkGetStringMacro(ZTitle);
00212   vtkSetStringMacro(ZUnits);
00213   vtkGetStringMacro(ZUnits);
00215 
00217 
00219   vtkSetStringMacro(XLabelFormat);
00220   vtkGetStringMacro(XLabelFormat);
00221   vtkSetStringMacro(YLabelFormat);
00222   vtkGetStringMacro(YLabelFormat);
00223   vtkSetStringMacro(ZLabelFormat);
00224   vtkGetStringMacro(ZLabelFormat);
00226 
00228 
00231   vtkSetClampMacro(Inertia, int, 1, VTK_INT_MAX);
00232   vtkGetMacro(Inertia, int);
00234 
00236 
00239   vtkSetMacro(CornerOffset, double);
00240   vtkGetMacro(CornerOffset, double);
00242 
00246   void ReleaseGraphicsResources(vtkWindow *);
00247 
00249 
00251   vtkSetMacro( EnableDistanceLOD, int );
00252   vtkGetMacro( EnableDistanceLOD, int );
00254 
00256 
00257   vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 );
00258   vtkGetMacro( DistanceLODThreshold, double);
00260 
00262 
00264   vtkSetMacro( EnableViewAngleLOD, int );
00265   vtkGetMacro( EnableViewAngleLOD, int );
00267 
00269 
00270   vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. );
00271   vtkGetMacro( ViewAngleLODThreshold, double );
00273 
00275 
00276   vtkSetMacro(XAxisVisibility,int);
00277   vtkGetMacro(XAxisVisibility,int);
00278   vtkBooleanMacro(XAxisVisibility,int);
00279   vtkSetMacro(YAxisVisibility,int);
00280   vtkGetMacro(YAxisVisibility,int);
00281   vtkBooleanMacro(YAxisVisibility,int);
00282   vtkSetMacro(ZAxisVisibility,int);
00283   vtkGetMacro(ZAxisVisibility,int);
00284   vtkBooleanMacro(ZAxisVisibility,int);
00286 
00288 
00289   vtkSetMacro(XAxisLabelVisibility,int);
00290   vtkGetMacro(XAxisLabelVisibility,int);
00291   vtkBooleanMacro(XAxisLabelVisibility,int);
00293 
00294   vtkSetMacro(YAxisLabelVisibility,int);
00295   vtkGetMacro(YAxisLabelVisibility,int);
00296   vtkBooleanMacro(YAxisLabelVisibility,int);
00297 
00298   vtkSetMacro(ZAxisLabelVisibility,int);
00299   vtkGetMacro(ZAxisLabelVisibility,int);
00300   vtkBooleanMacro(ZAxisLabelVisibility,int);
00301 
00303 
00304   vtkSetMacro(XAxisTickVisibility,int);
00305   vtkGetMacro(XAxisTickVisibility,int);
00306   vtkBooleanMacro(XAxisTickVisibility,int);
00308 
00309   vtkSetMacro(YAxisTickVisibility,int);
00310   vtkGetMacro(YAxisTickVisibility,int);
00311   vtkBooleanMacro(YAxisTickVisibility,int);
00312 
00313   vtkSetMacro(ZAxisTickVisibility,int);
00314   vtkGetMacro(ZAxisTickVisibility,int);
00315   vtkBooleanMacro(ZAxisTickVisibility,int);
00316 
00318 
00319   vtkSetMacro(XAxisMinorTickVisibility,int);
00320   vtkGetMacro(XAxisMinorTickVisibility,int);
00321   vtkBooleanMacro(XAxisMinorTickVisibility,int);
00323 
00324   vtkSetMacro(YAxisMinorTickVisibility,int);
00325   vtkGetMacro(YAxisMinorTickVisibility,int);
00326   vtkBooleanMacro(YAxisMinorTickVisibility,int);
00327 
00328   vtkSetMacro(ZAxisMinorTickVisibility,int);
00329   vtkGetMacro(ZAxisMinorTickVisibility,int);
00330   vtkBooleanMacro(ZAxisMinorTickVisibility,int);
00331 
00332   vtkSetMacro(DrawXGridlines,int);
00333   vtkGetMacro(DrawXGridlines,int);
00334   vtkBooleanMacro(DrawXGridlines,int);
00335 
00336   vtkSetMacro(DrawYGridlines,int);
00337   vtkGetMacro(DrawYGridlines,int);
00338   vtkBooleanMacro(DrawYGridlines,int);
00339 
00340   vtkSetMacro(DrawZGridlines,int);
00341   vtkGetMacro(DrawZGridlines,int);
00342   vtkBooleanMacro(DrawZGridlines,int);
00343 
00344   vtkSetMacro(DrawXInnerGridlines,int);
00345   vtkGetMacro(DrawXInnerGridlines,int);
00346   vtkBooleanMacro(DrawXInnerGridlines,int);
00347 
00348   vtkSetMacro(DrawYInnerGridlines,int);
00349   vtkGetMacro(DrawYInnerGridlines,int);
00350   vtkBooleanMacro(DrawYInnerGridlines,int);
00351 
00352   vtkSetMacro(DrawZInnerGridlines,int);
00353   vtkGetMacro(DrawZInnerGridlines,int);
00354   vtkBooleanMacro(DrawZInnerGridlines,int);
00355 
00356   vtkSetMacro(DrawXGridpolys,int);
00357   vtkGetMacro(DrawXGridpolys,int);
00358   vtkBooleanMacro(DrawXGridpolys,int);
00359 
00360   vtkSetMacro(DrawYGridpolys,int);
00361   vtkGetMacro(DrawYGridpolys,int);
00362   vtkBooleanMacro(DrawYGridpolys,int);
00363 
00364   vtkSetMacro(DrawZGridpolys,int);
00365   vtkGetMacro(DrawZGridpolys,int);
00366   vtkBooleanMacro(DrawZGridpolys,int);
00367 
00369   vtkTextProperty *GetTitleTextProperty(int);
00370 
00372   vtkTextProperty *GetLabelTextProperty(int);
00373 
00375 
00376   void SetXAxesLinesProperty(vtkProperty *);
00377   vtkProperty* GetXAxesLinesProperty();
00378   void SetYAxesLinesProperty(vtkProperty *);
00379   vtkProperty* GetYAxesLinesProperty();
00380   void SetZAxesLinesProperty(vtkProperty *);
00381   vtkProperty* GetZAxesLinesProperty();
00383 
00385 
00386   void SetXAxesGridlinesProperty(vtkProperty *);
00387   vtkProperty* GetXAxesGridlinesProperty();
00388   void SetYAxesGridlinesProperty(vtkProperty *);
00389   vtkProperty* GetYAxesGridlinesProperty();
00390   void SetZAxesGridlinesProperty(vtkProperty *);
00391   vtkProperty* GetZAxesGridlinesProperty();
00393 
00395 
00396   void SetXAxesInnerGridlinesProperty(vtkProperty *);
00397   vtkProperty* GetXAxesInnerGridlinesProperty();
00398   void SetYAxesInnerGridlinesProperty(vtkProperty *);
00399   vtkProperty* GetYAxesInnerGridlinesProperty();
00400   void SetZAxesInnerGridlinesProperty(vtkProperty *);
00401   vtkProperty* GetZAxesInnerGridlinesProperty();
00403 
00405 
00406   void SetXAxesGridpolysProperty(vtkProperty *);
00407   vtkProperty* GetXAxesGridpolysProperty();
00408   void SetYAxesGridpolysProperty(vtkProperty *);
00409   vtkProperty* GetYAxesGridpolysProperty();
00410   void SetZAxesGridpolysProperty(vtkProperty *);
00411   vtkProperty* GetZAxesGridpolysProperty();
00413 
00415 
00416   vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
00417   vtkGetMacro(TickLocation, int);
00419 
00420   void SetTickLocationToInside(void)
00421     { this->SetTickLocation(VTK_TICKS_INSIDE); };
00422   void SetTickLocationToOutside(void)
00423     { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
00424   void SetTickLocationToBoth(void)
00425     { this->SetTickLocation(VTK_TICKS_BOTH); };
00426 
00427   void SetLabelScaling(bool, int, int, int);
00428 
00430 
00432   void SetUseTextActor3D( int val );
00433   int GetUseTextActor3D();
00435 
00437 
00439   void SetUse2DMode( int val );
00440   int GetUse2DMode();
00442 
00444   void SetSaveTitlePosition( int val );
00445 
00447 
00448   vtkSetVector6Macro(OrientedBounds,double);
00449   vtkGetVector6Macro(OrientedBounds, double);
00451 
00453 
00454   vtkSetMacro(UseOrientedBounds, int);
00455   vtkGetMacro(UseOrientedBounds, int);
00457 
00459 
00460   vtkSetVector3Macro(AxisBaseForX,double);
00461   vtkGetVector3Macro(AxisBaseForX, double);
00463 
00465 
00466   vtkSetVector3Macro(AxisBaseForY,double);
00467   vtkGetVector3Macro(AxisBaseForY, double);
00469 
00471 
00472   vtkSetVector3Macro(AxisBaseForZ,double);
00473   vtkGetVector3Macro(AxisBaseForZ, double);
00475 
00477 
00479   vtkSetVector3Macro(AxisOrigin,double);
00480   vtkGetVector3Macro(AxisOrigin, double);
00482 
00484 
00485   vtkSetMacro(UseAxisOrigin, int);
00486   vtkGetMacro(UseAxisOrigin, int);
00488 
00490 
00491   vtkSetMacro(GridLineLocation,int);
00492   vtkGetMacro(GridLineLocation,int);
00494 
00496 
00499   vtkSetMacro(StickyAxes,int);
00500   vtkGetMacro(StickyAxes,int);
00501   vtkBooleanMacro(StickyAxes,int);
00503 
00505 
00509   vtkSetMacro(CenterStickyAxes,int);
00510   vtkGetMacro(CenterStickyAxes,int);
00511   vtkBooleanMacro(CenterStickyAxes,int);
00513 
00514 protected:
00515   vtkCubeAxesActor();
00516   ~vtkCubeAxesActor();
00517 
00519 
00522   void ComputeStickyAxesBoundingSphere(vtkViewport* viewport, const double bounds[6],
00523                                        double sphereCenter[3], double & sphereRadius);
00525 
00527   void GetViewportLimitedBounds(vtkViewport* viewport, double bounds[6]);
00528 
00530 
00532   static void GetBoundsPointBits(unsigned int pointIndex,
00533                                  unsigned int & xBit,
00534                                  unsigned int & yBit,
00535                                  unsigned int & zBit);
00537 
00539   static void GetBoundsPoint(unsigned int pointIndex, const double bounds[6], double point[3]);
00540 
00541   int LabelExponent(double min, double max);
00542 
00543   int Digits(double min, double max);
00544 
00545   double MaxOf(double, double);
00546   double MaxOf(double, double, double, double);
00547 
00548   double FFix(double);
00549   double FSign(double, double);
00550   int FRound( double fnt );
00551   int GetNumTicks( double range, double fxt);
00552 
00553   void UpdateLabels(vtkAxisActor **axis, int index);
00554 
00555   double Bounds[6]; //Define bounds explicitly
00556 
00557   vtkCamera *Camera;
00558 
00559   int FlyMode;
00560 
00561   // Expose internally closest axis index computation
00562   int FindClosestAxisIndex(double pts[8][3]);
00563 
00564   // Expose internally furthest axis index computation
00565   int FindFurtherstAxisIndex(double pts[8][3]);
00566 
00567   // Expose internally the boundary edge fly mode axis index computation
00568   void FindBoundaryEdge(int &indexOfAxisX, int &indexOfAxisY, int &indexOfAxisZ,
00569                         double pts[8][3]);
00570 
00574   void UpdateGridLineVisibility(int axisIndex);
00575 
00576   // VTK_ALL_GRID_LINES      0
00577   // VTK_CLOSEST_GRID_LINES  1
00578   // VTK_FURTHEST_GRID_LINES 2
00579   int GridLineLocation;
00580 
00582   int StickyAxes;
00583 
00585   int CenterStickyAxes;
00586 
00589   int EnableDistanceLOD;
00590 
00593   double DistanceLODThreshold;
00594 
00597   int EnableViewAngleLOD;
00598 
00601   double ViewAngleLODThreshold;
00602 
00604 
00606   vtkAxisActor *XAxes[NUMBER_OF_ALIGNED_AXIS];
00607   vtkAxisActor *YAxes[NUMBER_OF_ALIGNED_AXIS];
00608   vtkAxisActor *ZAxes[NUMBER_OF_ALIGNED_AXIS];
00610 
00611   bool RebuildAxes;
00612 
00613   char *XTitle;
00614   char *XUnits;
00615   char *YTitle;
00616   char *YUnits;
00617   char *ZTitle;
00618   char *ZUnits;
00619 
00620   char *ActualXLabel;
00621   char *ActualYLabel;
00622   char *ActualZLabel;
00623 
00624   int TickLocation;
00625 
00626   int XAxisVisibility;
00627   int YAxisVisibility;
00628   int ZAxisVisibility;
00629 
00630   int XAxisTickVisibility;
00631   int YAxisTickVisibility;
00632   int ZAxisTickVisibility;
00633 
00634   int XAxisMinorTickVisibility;
00635   int YAxisMinorTickVisibility;
00636   int ZAxisMinorTickVisibility;
00637 
00638   int XAxisLabelVisibility;
00639   int YAxisLabelVisibility;
00640   int ZAxisLabelVisibility;
00641 
00642   int DrawXGridlines;
00643   int DrawYGridlines;
00644   int DrawZGridlines;
00645 
00646   int DrawXInnerGridlines;
00647   int DrawYInnerGridlines;
00648   int DrawZInnerGridlines;
00649 
00650   int DrawXGridpolys;
00651   int DrawYGridpolys;
00652   int DrawZGridpolys;
00653 
00654   char  *XLabelFormat;
00655   char  *YLabelFormat;
00656   char  *ZLabelFormat;
00657 
00658   double CornerOffset;
00659 
00660   int   Inertia;
00661 
00662   int   RenderCount;
00663 
00664   int   InertiaLocs[3];
00665 
00666   int RenderSomething;
00667 
00668   vtkTextProperty* TitleTextProperty[3];
00669   vtkStringArray* AxisLabels[3];
00670 
00671   vtkTextProperty* LabelTextProperty[3];
00672 
00673   vtkProperty  *XAxesLinesProperty;
00674   vtkProperty  *YAxesLinesProperty;
00675   vtkProperty  *ZAxesLinesProperty;
00676   vtkProperty  *XAxesGridlinesProperty;
00677   vtkProperty  *YAxesGridlinesProperty;
00678   vtkProperty  *ZAxesGridlinesProperty;
00679   vtkProperty  *XAxesInnerGridlinesProperty;
00680   vtkProperty  *YAxesInnerGridlinesProperty;
00681   vtkProperty  *ZAxesInnerGridlinesProperty;
00682   vtkProperty  *XAxesGridpolysProperty;
00683   vtkProperty  *YAxesGridpolysProperty;
00684   vtkProperty  *ZAxesGridpolysProperty;
00685 
00686   double RenderedBounds[6];
00687   double OrientedBounds[6];
00688   int UseOrientedBounds;
00689 
00690   double AxisOrigin[3];
00691   int UseAxisOrigin;
00692 
00693   double AxisBaseForX[3];
00694   double AxisBaseForY[3];
00695   double AxisBaseForZ[3];
00696 
00697 private:
00698   vtkCubeAxesActor(const vtkCubeAxesActor&); // Not implemented
00699   void operator=(const vtkCubeAxesActor&); // Not implemented
00700 
00701   vtkSetStringMacro(ActualXLabel);
00702   vtkSetStringMacro(ActualYLabel);
00703   vtkSetStringMacro(ActualZLabel);
00704 
00705   vtkTimeStamp BuildTime;
00706   int LastUseOrientedBounds;
00707   int LastXPow;
00708   int LastYPow;
00709   int LastZPow;
00710 
00711   int UserXPow;
00712   int UserYPow;
00713   int UserZPow;
00714 
00715   bool AutoLabelScaling;
00716 
00717   int LastXAxisDigits;
00718   int LastYAxisDigits;
00719   int LastZAxisDigits;
00720 
00721   double LastXRange[2];
00722   double LastYRange[2];
00723   double LastZRange[2];
00724   double LastBounds[6];
00725 
00726   int    LastFlyMode;
00727 
00728   int   RenderAxesX[NUMBER_OF_ALIGNED_AXIS];
00729   int   RenderAxesY[NUMBER_OF_ALIGNED_AXIS];
00730   int   RenderAxesZ[NUMBER_OF_ALIGNED_AXIS];
00731 
00732   int   NumberOfAxesX;
00733   int   NumberOfAxesY;
00734   int   NumberOfAxesZ;
00735 
00736   bool MustAdjustXValue;
00737   bool MustAdjustYValue;
00738   bool MustAdjustZValue;
00739 
00740   bool ForceXLabelReset;
00741   bool ForceYLabelReset;
00742   bool ForceZLabelReset;
00743 
00744   double XAxisRange[2];
00745   double YAxisRange[2];
00746   double ZAxisRange[2];
00747 
00748   double LabelScale;
00749   double TitleScale;
00750 
00751   double ScreenSize;
00752   double LabelOffset;
00753   double TitleOffset;
00754 
00756 
00758   double MajorStart[3];
00759   double DeltaMajor[3];
00761 
00762   int RenderGeometry(bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility,int (vtkAxisActor::*renderMethod)(vtkViewport*));
00763 
00764   void  TransformBounds(vtkViewport *viewport, const double bounds[6],
00765                         double pts[8][3]);
00766   void  AdjustAxes(double bounds[6],
00767                    double xCoords[NUMBER_OF_ALIGNED_AXIS][6],
00768                    double yCoords[NUMBER_OF_ALIGNED_AXIS][6],
00769                    double zCoords[NUMBER_OF_ALIGNED_AXIS][6],
00770                    double xRange[2], double yRange[2], double zRange[2]);
00771 
00772   bool  ComputeTickSize(double bounds[6]);
00773   void  AdjustValues(const double xRange[2],
00774                      const double yRange[2],
00775                      const double zRange[2]);
00776   void  AdjustRange(const double bounds[6]);
00777   void  BuildAxes(vtkViewport *);
00778   void  DetermineRenderAxes(vtkViewport *);
00779   void  SetNonDependentAttributes(void);
00780   void  BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
00781   void  AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS],
00782       double rangeMin, double rangeMax);
00783 
00784   void    AutoScale(vtkViewport *viewport);
00785   void    AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
00786   double  AutoScale(vtkViewport *viewport, double screenSize, double position[3]);
00787 };
00788 
00789 
00790 #endif