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 =========================================================================*/
00052 #ifndef __vtkCubeAxesActor_h
00053 #define __vtkCubeAxesActor_h
00054 
00055 #define VTK_FLY_OUTER_EDGES     0
00056 #define VTK_FLY_CLOSEST_TRIAD   1
00057 #define VTK_FLY_FURTHEST_TRIAD  2
00058 #define VTK_FLY_STATIC_TRIAD    3
00059 #define VTK_FLY_STATIC_EDGES    4
00060 
00061 #define VTK_TICKS_INSIDE        0
00062 #define VTK_TICKS_OUTSIDE       1
00063 #define VTK_TICKS_BOTH          2
00064 
00065 #include "vtkActor.h"
00066 
00067 class vtkAxisActor;
00068 class vtkCamera;
00069 
00070 class VTK_HYBRID_EXPORT vtkCubeAxesActor : public vtkActor
00071 {
00072 public:
00073   vtkTypeMacro(vtkCubeAxesActor,vtkActor);
00074   void PrintSelf(ostream& os, vtkIndent indent);
00075 
00078   static vtkCubeAxesActor *New();
00079 
00081 
00082   virtual int RenderOpaqueGeometry(vtkViewport*);
00083   virtual int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00085 
00087 
00091   vtkSetVector6Macro(Bounds,double);
00092   double *GetBounds();
00093   void GetBounds(double& xmin, double& xmax, double& ymin, double& ymax,
00094                  double& zmin, double& zmax);
00095   void GetBounds(double bounds[6]);
00097 
00099 
00106   vtkSetVector2Macro( XAxisRange, double );
00107   vtkSetVector2Macro( YAxisRange, double );
00108   vtkSetVector2Macro( ZAxisRange, double );
00109   vtkGetVector2Macro( XAxisRange, double );
00110   vtkGetVector2Macro( YAxisRange, double );
00111   vtkGetVector2Macro( ZAxisRange, double );
00113 
00115 
00117   virtual void SetCamera(vtkCamera*);
00118   vtkGetObjectMacro(Camera,vtkCamera);
00120 
00122 
00125   vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES);
00126   vtkGetMacro(FlyMode, int);
00127   void SetFlyModeToOuterEdges()
00128     {this->SetFlyMode(VTK_FLY_OUTER_EDGES);};
00129   void SetFlyModeToClosestTriad()
00130     {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);};
00131   void SetFlyModeToFurthestTriad()
00132     {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);};
00133   void SetFlyModeToStaticTriad()
00134     {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);};
00135   void SetFlyModeToStaticEdges()
00136     {this->SetFlyMode(VTK_FLY_STATIC_EDGES);};
00138 
00140 
00142   vtkSetStringMacro(XTitle);
00143   vtkGetStringMacro(XTitle);
00144   vtkSetStringMacro(XUnits);
00145   vtkGetStringMacro(XUnits);
00146   vtkSetStringMacro(YTitle);
00147   vtkGetStringMacro(YTitle);
00148   vtkSetStringMacro(YUnits);
00149   vtkGetStringMacro(YUnits);
00150   vtkSetStringMacro(ZTitle);
00151   vtkGetStringMacro(ZTitle);
00152   vtkSetStringMacro(ZUnits);
00153   vtkGetStringMacro(ZUnits);
00155 
00157 
00159   vtkSetStringMacro(XLabelFormat);
00160   vtkGetStringMacro(XLabelFormat);
00161   vtkSetStringMacro(YLabelFormat);
00162   vtkGetStringMacro(YLabelFormat);
00163   vtkSetStringMacro(ZLabelFormat);
00164   vtkGetStringMacro(ZLabelFormat);
00166 
00168 
00171   vtkSetClampMacro(Inertia, int, 1, VTK_LARGE_INTEGER);
00172   vtkGetMacro(Inertia, int);
00174 
00176 
00179   vtkSetMacro(CornerOffset, double);
00180   vtkGetMacro(CornerOffset, double);
00182 
00186   void ReleaseGraphicsResources(vtkWindow *);
00187 
00189 
00190   vtkSetMacro(XAxisVisibility,int);
00191   vtkGetMacro(XAxisVisibility,int);
00192   vtkBooleanMacro(XAxisVisibility,int);
00193   vtkSetMacro(YAxisVisibility,int);
00194   vtkGetMacro(YAxisVisibility,int);
00195   vtkBooleanMacro(YAxisVisibility,int);
00196   vtkSetMacro(ZAxisVisibility,int);
00197   vtkGetMacro(ZAxisVisibility,int);
00198   vtkBooleanMacro(ZAxisVisibility,int);
00200 
00202 
00203   vtkSetMacro(XAxisLabelVisibility,int);
00204   vtkGetMacro(XAxisLabelVisibility,int);
00205   vtkBooleanMacro(XAxisLabelVisibility,int);
00207 
00208   vtkSetMacro(YAxisLabelVisibility,int);
00209   vtkGetMacro(YAxisLabelVisibility,int);
00210   vtkBooleanMacro(YAxisLabelVisibility,int);
00211 
00212   vtkSetMacro(ZAxisLabelVisibility,int);
00213   vtkGetMacro(ZAxisLabelVisibility,int);
00214   vtkBooleanMacro(ZAxisLabelVisibility,int);
00215 
00217 
00218   vtkSetMacro(XAxisTickVisibility,int);
00219   vtkGetMacro(XAxisTickVisibility,int);
00220   vtkBooleanMacro(XAxisTickVisibility,int);
00222 
00223   vtkSetMacro(YAxisTickVisibility,int);
00224   vtkGetMacro(YAxisTickVisibility,int);
00225   vtkBooleanMacro(YAxisTickVisibility,int);
00226 
00227   vtkSetMacro(ZAxisTickVisibility,int);
00228   vtkGetMacro(ZAxisTickVisibility,int);
00229   vtkBooleanMacro(ZAxisTickVisibility,int);
00230 
00232 
00233   vtkSetMacro(XAxisMinorTickVisibility,int);
00234   vtkGetMacro(XAxisMinorTickVisibility,int);
00235   vtkBooleanMacro(XAxisMinorTickVisibility,int);
00237 
00238   vtkSetMacro(YAxisMinorTickVisibility,int);
00239   vtkGetMacro(YAxisMinorTickVisibility,int);
00240   vtkBooleanMacro(YAxisMinorTickVisibility,int);
00241 
00242   vtkSetMacro(ZAxisMinorTickVisibility,int);
00243   vtkGetMacro(ZAxisMinorTickVisibility,int);
00244   vtkBooleanMacro(ZAxisMinorTickVisibility,int);
00245 
00246   vtkSetMacro(DrawXGridlines,int);
00247   vtkGetMacro(DrawXGridlines,int);
00248   vtkBooleanMacro(DrawXGridlines,int);
00249 
00250   vtkSetMacro(DrawYGridlines,int);
00251   vtkGetMacro(DrawYGridlines,int);
00252   vtkBooleanMacro(DrawYGridlines,int);
00253 
00254   vtkSetMacro(DrawZGridlines,int);
00255   vtkGetMacro(DrawZGridlines,int);
00256   vtkBooleanMacro(DrawZGridlines,int);
00257 
00259 
00260   vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
00261   vtkGetMacro(TickLocation, int);
00263 
00264   void SetTickLocationToInside(void)
00265     { this->SetTickLocation(VTK_TICKS_INSIDE); };
00266   void SetTickLocationToOutside(void)
00267     { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
00268   void SetTickLocationToBoth(void)
00269     { this->SetTickLocation(VTK_TICKS_BOTH); };
00270 
00271   void SetLabelScaling(bool, int, int, int);
00273   void ShallowCopy(vtkCubeAxesActor *actor);
00274 
00275 protected:
00276   vtkCubeAxesActor();
00277   ~vtkCubeAxesActor();
00278 
00279   int LabelExponent(double min, double max);
00280   int Digits(double min, double max);
00281   double MaxOf(double, double);
00282   double MaxOf(double, double, double, double);
00283   double FFix(double);
00284   double FSign(double, double);
00285 
00286   double       Bounds[6]; //Define bounds explicitly
00287 
00288   vtkCamera *Camera;
00289   int FlyMode;
00290 
00291   // to control all axes
00292   // [0] always for 'Major' axis during non-static fly modes.
00293   vtkAxisActor *XAxes[4];
00294   vtkAxisActor *YAxes[4];
00295   vtkAxisActor *ZAxes[4];
00296 
00297   char *XTitle;
00298   char *XUnits;
00299   char *YTitle;
00300   char *YUnits;
00301   char *ZTitle;
00302   char *ZUnits;
00303 
00304   char *ActualXLabel;
00305   char *ActualYLabel;
00306   char *ActualZLabel;
00307 
00308   int TickLocation;
00309 
00310   int XAxisVisibility;
00311   int YAxisVisibility;
00312   int ZAxisVisibility;
00313 
00314   int XAxisTickVisibility;
00315   int YAxisTickVisibility;
00316   int ZAxisTickVisibility;
00317 
00318   int XAxisMinorTickVisibility;
00319   int YAxisMinorTickVisibility;
00320   int ZAxisMinorTickVisibility;
00321 
00322   int XAxisLabelVisibility;
00323   int YAxisLabelVisibility;
00324   int ZAxisLabelVisibility;
00325 
00326   int DrawXGridlines;
00327   int DrawYGridlines;
00328   int DrawZGridlines;
00329 
00330   char  *XLabelFormat;
00331   char  *YLabelFormat;
00332   char  *ZLabelFormat;
00333   double CornerOffset;
00334   int   Inertia;
00335   int   RenderCount;
00336   int   InertiaLocs[3];
00337 
00338   int RenderSomething;
00339 
00340 private:
00341   vtkCubeAxesActor(const vtkCubeAxesActor&); // Not implemented
00342   void operator=(const vtkCubeAxesActor&); // Not implemented
00343 
00344   vtkSetStringMacro(ActualXLabel);
00345   vtkSetStringMacro(ActualYLabel);
00346   vtkSetStringMacro(ActualZLabel);
00347 
00348   vtkTimeStamp BuildTime;
00349   int LastXPow;
00350   int LastYPow;
00351   int LastZPow;
00352   int UserXPow;
00353   int UserYPow;
00354   int UserZPow;
00355   bool AutoLabelScaling;
00356   int LastXAxisDigits;
00357   int LastYAxisDigits;
00358   int LastZAxisDigits;
00359   double LastXRange[2];
00360   double LastYRange[2];
00361   double LastZRange[2];
00362   int   LastFlyMode;
00363 
00364   int   RenderAxesX[4];
00365   int   RenderAxesY[4];
00366   int   RenderAxesZ[4];
00367   int   NumberOfAxesX;
00368   int   NumberOfAxesY;
00369   int   NumberOfAxesZ;
00370 
00371   bool MustAdjustXValue;
00372   bool MustAdjustYValue;
00373   bool MustAdjustZValue;
00374   bool ForceXLabelReset;
00375   bool ForceYLabelReset;
00376   bool ForceZLabelReset;
00377 
00378   double XAxisRange[2];
00379   double YAxisRange[2];
00380   double ZAxisRange[2];
00381 
00382   // various helper methods
00383   void  TransformBounds(vtkViewport *viewport, const double bounds[6],
00384                         double pts[8][3]);
00385   void  AdjustAxes(double bounds[6],
00386                    double xCoords[4][6], double yCoords[4][6],
00387                    double zCoords[4][6],
00388                    double xRange[2], double yRange[2], double zRange[2]);
00389 
00390   bool  ComputeTickSize(double bounds[6]);
00391   void  AdjustValues(const double xRange[2],
00392                      const double yRange[2],
00393                      const double zRange[2]);
00394   void  AdjustRange(const double bounds[6]);
00395   void  BuildAxes(vtkViewport *);
00396   void  DetermineRenderAxes(vtkViewport *);
00397   void  SetNonDependentAttributes(void);
00398   void  BuildLabels(vtkAxisActor *axes[4]);
00399   void  AdjustTicksComputeRange(vtkAxisActor *axes[4],
00400       double rangeMin, double rangeMax);
00401 
00402   // hide the superclass' ShallowCopy() from the user and the compiler.
00403   void ShallowCopy(vtkProp *prop) { this->vtkProp::ShallowCopy( prop ); };
00404 };
00405 
00406 
00407 #endif