VTK
dox/Hybrid/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 =========================================================================*/
00059 #ifndef __vtkCubeAxesActor_h
00060 #define __vtkCubeAxesActor_h
00061 
00062 #define VTK_FLY_OUTER_EDGES     0
00063 #define VTK_FLY_CLOSEST_TRIAD   1
00064 #define VTK_FLY_FURTHEST_TRIAD  2
00065 #define VTK_FLY_STATIC_TRIAD    3
00066 #define VTK_FLY_STATIC_EDGES    4
00067 
00068 #define VTK_TICKS_INSIDE        0
00069 #define VTK_TICKS_OUTSIDE       1
00070 #define VTK_TICKS_BOTH          2
00071 
00072 #define NUMBER_OF_ALIGNED_AXIS 4
00073 
00074 #include "vtkActor.h"
00075 
00076 class vtkAxisActor;
00077 class vtkCamera;
00078 class vtkTextProperty;
00079 
00080 class VTK_HYBRID_EXPORT vtkCubeAxesActor : public vtkActor
00081 {
00082 public:
00083   vtkTypeMacro(vtkCubeAxesActor,vtkActor);
00084   void PrintSelf(ostream& os, vtkIndent indent);
00085 
00088   static vtkCubeAxesActor *New();
00089 
00091 
00092   virtual int RenderOpaqueGeometry(vtkViewport*);
00093   virtual int RenderTranslucentGeometry(vtkViewport*);
00094   virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
00095   virtual int RenderOverlay(vtkViewport*);
00096   int HasTranslucentPolygonalGeometry();
00098 
00100 
00101   vtkSetMacro( RebuildAxes, bool );
00102   vtkGetMacro( RebuildAxes, bool );
00104 
00106 
00110   vtkSetVector6Macro(Bounds,double);
00111   double *GetBounds();
00112   void GetBounds(double& xmin, double& xmax, double& ymin, double& ymax,
00113                  double& zmin, double& zmax);
00114   void GetBounds(double bounds[6]);
00116 
00118 
00125   vtkSetVector2Macro( XAxisRange, double );
00126   vtkSetVector2Macro( YAxisRange, double );
00127   vtkSetVector2Macro( ZAxisRange, double );
00128   vtkGetVector2Macro( XAxisRange, double );
00129   vtkGetVector2Macro( YAxisRange, double );
00130   vtkGetVector2Macro( ZAxisRange, double );
00132 
00134 
00137   void SetScreenSize(double screenSize);
00138   vtkGetMacro(ScreenSize, double);
00140 
00142 
00144   virtual void SetCamera(vtkCamera*);
00145   vtkGetObjectMacro(Camera,vtkCamera);
00147 
00149 
00152   vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES);
00153   vtkGetMacro(FlyMode, int);
00154   void SetFlyModeToOuterEdges()
00155     {this->SetFlyMode(VTK_FLY_OUTER_EDGES);};
00156   void SetFlyModeToClosestTriad()
00157     {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);};
00158   void SetFlyModeToFurthestTriad()
00159     {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);};
00160   void SetFlyModeToStaticTriad()
00161     {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);};
00162   void SetFlyModeToStaticEdges()
00163     {this->SetFlyMode(VTK_FLY_STATIC_EDGES);};
00165 
00167 
00169   vtkSetStringMacro(XTitle);
00170   vtkGetStringMacro(XTitle);
00171   vtkSetStringMacro(XUnits);
00172   vtkGetStringMacro(XUnits);
00173   vtkSetStringMacro(YTitle);
00174   vtkGetStringMacro(YTitle);
00175   vtkSetStringMacro(YUnits);
00176   vtkGetStringMacro(YUnits);
00177   vtkSetStringMacro(ZTitle);
00178   vtkGetStringMacro(ZTitle);
00179   vtkSetStringMacro(ZUnits);
00180   vtkGetStringMacro(ZUnits);
00182 
00184 
00186   vtkSetStringMacro(XLabelFormat);
00187   vtkGetStringMacro(XLabelFormat);
00188   vtkSetStringMacro(YLabelFormat);
00189   vtkGetStringMacro(YLabelFormat);
00190   vtkSetStringMacro(ZLabelFormat);
00191   vtkGetStringMacro(ZLabelFormat);
00193 
00195 
00198   vtkSetClampMacro(Inertia, int, 1, VTK_LARGE_INTEGER);
00199   vtkGetMacro(Inertia, int);
00201 
00203 
00206   vtkSetMacro(CornerOffset, double);
00207   vtkGetMacro(CornerOffset, double);
00209 
00213   void ReleaseGraphicsResources(vtkWindow *);
00214 
00216 
00218   vtkSetMacro( EnableDistanceLOD, int );
00219   vtkGetMacro( EnableDistanceLOD, int );
00221   
00223 
00224   vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 );
00225   vtkGetMacro( DistanceLODThreshold, double);
00227 
00229 
00231   vtkSetMacro( EnableViewAngleLOD, int );
00232   vtkGetMacro( EnableViewAngleLOD, int );
00234   
00236 
00237   vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. );
00238   vtkGetMacro( ViewAngleLODThreshold, double );
00240 
00242 
00243   vtkSetMacro(XAxisVisibility,int);
00244   vtkGetMacro(XAxisVisibility,int);
00245   vtkBooleanMacro(XAxisVisibility,int);
00246   vtkSetMacro(YAxisVisibility,int);
00247   vtkGetMacro(YAxisVisibility,int);
00248   vtkBooleanMacro(YAxisVisibility,int);
00249   vtkSetMacro(ZAxisVisibility,int);
00250   vtkGetMacro(ZAxisVisibility,int);
00251   vtkBooleanMacro(ZAxisVisibility,int);
00253 
00255 
00256   vtkSetMacro(XAxisLabelVisibility,int);
00257   vtkGetMacro(XAxisLabelVisibility,int);
00258   vtkBooleanMacro(XAxisLabelVisibility,int);
00260 
00261   vtkSetMacro(YAxisLabelVisibility,int);
00262   vtkGetMacro(YAxisLabelVisibility,int);
00263   vtkBooleanMacro(YAxisLabelVisibility,int);
00264 
00265   vtkSetMacro(ZAxisLabelVisibility,int);
00266   vtkGetMacro(ZAxisLabelVisibility,int);
00267   vtkBooleanMacro(ZAxisLabelVisibility,int);
00268 
00270 
00271   vtkSetMacro(XAxisTickVisibility,int);
00272   vtkGetMacro(XAxisTickVisibility,int);
00273   vtkBooleanMacro(XAxisTickVisibility,int);
00275 
00276   vtkSetMacro(YAxisTickVisibility,int);
00277   vtkGetMacro(YAxisTickVisibility,int);
00278   vtkBooleanMacro(YAxisTickVisibility,int);
00279 
00280   vtkSetMacro(ZAxisTickVisibility,int);
00281   vtkGetMacro(ZAxisTickVisibility,int);
00282   vtkBooleanMacro(ZAxisTickVisibility,int);
00283 
00285 
00286   vtkSetMacro(XAxisMinorTickVisibility,int);
00287   vtkGetMacro(XAxisMinorTickVisibility,int);
00288   vtkBooleanMacro(XAxisMinorTickVisibility,int);
00290 
00291   vtkSetMacro(YAxisMinorTickVisibility,int);
00292   vtkGetMacro(YAxisMinorTickVisibility,int);
00293   vtkBooleanMacro(YAxisMinorTickVisibility,int);
00294 
00295   vtkSetMacro(ZAxisMinorTickVisibility,int);
00296   vtkGetMacro(ZAxisMinorTickVisibility,int);
00297   vtkBooleanMacro(ZAxisMinorTickVisibility,int);
00298 
00299   vtkSetMacro(DrawXGridlines,int);
00300   vtkGetMacro(DrawXGridlines,int);
00301   vtkBooleanMacro(DrawXGridlines,int);
00302 
00303   vtkSetMacro(DrawYGridlines,int);
00304   vtkGetMacro(DrawYGridlines,int);
00305   vtkBooleanMacro(DrawYGridlines,int);
00306 
00307   vtkSetMacro(DrawZGridlines,int);
00308   vtkGetMacro(DrawZGridlines,int);
00309   vtkBooleanMacro(DrawZGridlines,int);
00310 
00311   vtkSetMacro(DrawXInnerGridlines,int);
00312   vtkGetMacro(DrawXInnerGridlines,int);
00313   vtkBooleanMacro(DrawXInnerGridlines,int);
00314 
00315   vtkSetMacro(DrawYInnerGridlines,int);
00316   vtkGetMacro(DrawYInnerGridlines,int);
00317   vtkBooleanMacro(DrawYInnerGridlines,int);
00318 
00319   vtkSetMacro(DrawZInnerGridlines,int);
00320   vtkGetMacro(DrawZInnerGridlines,int);
00321   vtkBooleanMacro(DrawZInnerGridlines,int);
00322 
00323   vtkSetMacro(DrawXGridpolys,int);
00324   vtkGetMacro(DrawXGridpolys,int);
00325   vtkBooleanMacro(DrawXGridpolys,int);
00326 
00327   vtkSetMacro(DrawYGridpolys,int);
00328   vtkGetMacro(DrawYGridpolys,int);
00329   vtkBooleanMacro(DrawYGridpolys,int);
00330 
00331   vtkSetMacro(DrawZGridpolys,int);
00332   vtkGetMacro(DrawZGridpolys,int);
00333   vtkBooleanMacro(DrawZGridpolys,int);
00334 
00336   vtkTextProperty *GetTitleTextProperty(int);
00337 
00339   vtkTextProperty *GetLabelTextProperty(int);
00340 
00342 
00343   void SetXAxesLinesProperty(vtkProperty *);
00344   vtkProperty* GetXAxesLinesProperty();
00345   void SetYAxesLinesProperty(vtkProperty *);
00346   vtkProperty* GetYAxesLinesProperty();
00347   void SetZAxesLinesProperty(vtkProperty *);
00348   vtkProperty* GetZAxesLinesProperty();
00350 
00352 
00353   void SetXAxesGridlinesProperty(vtkProperty *);
00354   vtkProperty* GetXAxesGridlinesProperty();
00355   void SetYAxesGridlinesProperty(vtkProperty *);
00356   vtkProperty* GetYAxesGridlinesProperty();
00357   void SetZAxesGridlinesProperty(vtkProperty *);
00358   vtkProperty* GetZAxesGridlinesProperty();
00360  
00362 
00363   void SetXAxesInnerGridlinesProperty(vtkProperty *);
00364   vtkProperty* GetXAxesInnerGridlinesProperty();
00365   void SetYAxesInnerGridlinesProperty(vtkProperty *);
00366   vtkProperty* GetYAxesInnerGridlinesProperty();
00367   void SetZAxesInnerGridlinesProperty(vtkProperty *);
00368   vtkProperty* GetZAxesInnerGridlinesProperty();
00370 
00372 
00373   void SetXAxesGridpolysProperty(vtkProperty *);
00374   vtkProperty* GetXAxesGridpolysProperty();
00375   void SetYAxesGridpolysProperty(vtkProperty *);
00376   vtkProperty* GetYAxesGridpolysProperty();
00377   void SetZAxesGridpolysProperty(vtkProperty *);
00378   vtkProperty* GetZAxesGridpolysProperty();
00380 
00382 
00383   vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
00384   vtkGetMacro(TickLocation, int);
00386 
00387   void SetTickLocationToInside(void)
00388     { this->SetTickLocation(VTK_TICKS_INSIDE); };
00389   void SetTickLocationToOutside(void)
00390     { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
00391   void SetTickLocationToBoth(void)
00392     { this->SetTickLocation(VTK_TICKS_BOTH); };
00393 
00394   void SetLabelScaling(bool, int, int, int);
00395 
00397 
00399   void SetUse2DMode( int val );
00400   int GetUse2DMode();
00402 
00404   void SetSaveTitlePosition( int val );
00405       
00406 protected:
00407   vtkCubeAxesActor();
00408   ~vtkCubeAxesActor();
00409 
00410   int LabelExponent(double min, double max);
00411 
00412   int Digits(double min, double max);
00413 
00414   double MaxOf(double, double);
00415   double MaxOf(double, double, double, double);
00416 
00417   double FFix(double);
00418   double FSign(double, double);
00419 
00420   void UpdateLabels(vtkAxisActor **axis, int index);
00421 
00422   double Bounds[6]; //Define bounds explicitly
00423 
00424   vtkCamera *Camera;
00425 
00426   int FlyMode;
00427 
00430   int EnableDistanceLOD;
00431 
00434   double DistanceLODThreshold;
00435 
00438   int EnableViewAngleLOD;
00439 
00442   double ViewAngleLODThreshold;
00443 
00445 
00447   vtkAxisActor *XAxes[NUMBER_OF_ALIGNED_AXIS];
00448   vtkAxisActor *YAxes[NUMBER_OF_ALIGNED_AXIS];
00449   vtkAxisActor *ZAxes[NUMBER_OF_ALIGNED_AXIS];
00451 
00452   bool RebuildAxes;
00453 
00454   char *XTitle;
00455   char *XUnits;
00456   char *YTitle;
00457   char *YUnits;
00458   char *ZTitle;
00459   char *ZUnits;
00460 
00461   char *ActualXLabel;
00462   char *ActualYLabel;
00463   char *ActualZLabel;
00464 
00465   int TickLocation;
00466 
00467   int XAxisVisibility;
00468   int YAxisVisibility;
00469   int ZAxisVisibility;
00470 
00471   int XAxisTickVisibility;
00472   int YAxisTickVisibility;
00473   int ZAxisTickVisibility;
00474 
00475   int XAxisMinorTickVisibility;
00476   int YAxisMinorTickVisibility;
00477   int ZAxisMinorTickVisibility;
00478 
00479   int XAxisLabelVisibility;
00480   int YAxisLabelVisibility;
00481   int ZAxisLabelVisibility;
00482 
00483   int DrawXGridlines;
00484   int DrawYGridlines;
00485   int DrawZGridlines;
00486 
00487   int DrawXInnerGridlines;
00488   int DrawYInnerGridlines;
00489   int DrawZInnerGridlines;
00490 
00491   int DrawXGridpolys;
00492   int DrawYGridpolys;
00493   int DrawZGridpolys;
00494 
00495   char  *XLabelFormat;
00496   char  *YLabelFormat;
00497   char  *ZLabelFormat;
00498 
00499   double CornerOffset;
00500 
00501   int   Inertia;
00502 
00503   int   RenderCount;
00504 
00505   int   InertiaLocs[3];
00506 
00507   int RenderSomething;
00508 
00509   double LabelScreenOffset;
00510   double TitleScreenOffset;
00511 
00512   vtkTextProperty* TitleTextProperty[3];
00513   vtkTextProperty* LabelTextProperty[3];
00514 
00515   vtkProperty  *XAxesLinesProperty;
00516   vtkProperty  *YAxesLinesProperty;
00517   vtkProperty  *ZAxesLinesProperty;
00518   vtkProperty  *XAxesGridlinesProperty;
00519   vtkProperty  *YAxesGridlinesProperty;
00520   vtkProperty  *ZAxesGridlinesProperty;
00521   vtkProperty  *XAxesInnerGridlinesProperty;
00522   vtkProperty  *YAxesInnerGridlinesProperty;
00523   vtkProperty  *ZAxesInnerGridlinesProperty;
00524   vtkProperty  *XAxesGridpolysProperty;
00525   vtkProperty  *YAxesGridpolysProperty;
00526   vtkProperty  *ZAxesGridpolysProperty;
00527 
00528 private:
00529   vtkCubeAxesActor(const vtkCubeAxesActor&); // Not implemented
00530   void operator=(const vtkCubeAxesActor&); // Not implemented
00531 
00532   vtkSetStringMacro(ActualXLabel);
00533   vtkSetStringMacro(ActualYLabel);
00534   vtkSetStringMacro(ActualZLabel);
00535 
00536   vtkTimeStamp BuildTime;
00537   int LastXPow;
00538   int LastYPow;
00539   int LastZPow;
00540 
00541   int UserXPow;
00542   int UserYPow;
00543   int UserZPow;
00544 
00545   bool AutoLabelScaling;
00546 
00547   int LastXAxisDigits;
00548   int LastYAxisDigits;
00549   int LastZAxisDigits;
00550 
00551   double LastXRange[2];
00552   double LastYRange[2];
00553   double LastZRange[2];
00554 
00555   int    LastFlyMode;
00556 
00557   int   RenderAxesX[NUMBER_OF_ALIGNED_AXIS];
00558   int   RenderAxesY[NUMBER_OF_ALIGNED_AXIS];
00559   int   RenderAxesZ[NUMBER_OF_ALIGNED_AXIS];
00560 
00561   int   NumberOfAxesX;
00562   int   NumberOfAxesY;
00563   int   NumberOfAxesZ;
00564 
00565   bool MustAdjustXValue;
00566   bool MustAdjustYValue;
00567   bool MustAdjustZValue;
00568 
00569   bool ForceXLabelReset;
00570   bool ForceYLabelReset;
00571   bool ForceZLabelReset;
00572 
00573   double XAxisRange[2];
00574   double YAxisRange[2];
00575   double ZAxisRange[2];
00576 
00577   double LabelScale;
00578   double TitleScale;
00579 
00580   double ScreenSize;
00581 
00583 
00585   double MajorStart[3];
00586   double DeltaMajor[3];
00588 
00589   void  TransformBounds(vtkViewport *viewport, const double bounds[6],
00590                         double pts[8][3]);
00591   void  AdjustAxes(double bounds[6],
00592                    double xCoords[NUMBER_OF_ALIGNED_AXIS][6],
00593                    double yCoords[NUMBER_OF_ALIGNED_AXIS][6],
00594                    double zCoords[NUMBER_OF_ALIGNED_AXIS][6],
00595                    double xRange[2], double yRange[2], double zRange[2]);
00596 
00597   bool  ComputeTickSize(double bounds[6]);
00598   void  AdjustValues(const double xRange[2],
00599                      const double yRange[2],
00600                      const double zRange[2]);
00601   void  AdjustRange(const double bounds[6]);
00602   void  BuildAxes(vtkViewport *);
00603   void  DetermineRenderAxes(vtkViewport *);
00604   void  SetNonDependentAttributes(void);
00605   void  BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
00606   void  AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS],
00607       double rangeMin, double rangeMax);
00608 
00609   void    AutoScale(vtkViewport *viewport);
00610   void    AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
00611   double  AutoScale(vtkViewport *viewport, double screenSize, double position[3]);
00612 };
00613 
00614 
00615 #endif