Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkAxisActor2D.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkAxisActor2D.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00070 #ifndef __vtkAxisActor2D_h
00071 #define __vtkAxisActor2D_h
00072 
00073 #include "vtkActor2D.h"
00074 
00075 class vtkPolyDataMapper2D;
00076 class vtkPolyData;
00077 class vtkTextMapper;
00078 class vtkTextProperty;
00079 
00080 #define VTK_MAX_LABELS 25
00081 
00082 class VTK_RENDERING_EXPORT vtkAxisActor2D : public vtkActor2D
00083 {
00084 public:
00085   vtkTypeRevisionMacro(vtkAxisActor2D,vtkActor2D);
00086   void PrintSelf(ostream& os, vtkIndent indent);
00087 
00089   static vtkAxisActor2D *New();
00090 
00092 
00094   virtual vtkCoordinate *GetPoint1Coordinate() 
00095     { return this->GetPositionCoordinate(); };
00096   virtual void SetPoint1(double x[2]) { this->SetPosition(x); };
00097   virtual void SetPoint1(double x, double y) { this->SetPosition(x,y); };
00098   virtual double *GetPoint1() { return this->GetPosition(); };
00100 
00102 
00106   virtual vtkCoordinate *GetPoint2Coordinate() 
00107     { return this->GetPosition2Coordinate(); };
00108   virtual void SetPoint2(double x[2]) { this->SetPosition2(x); };
00109   virtual void SetPoint2(double x, double y) { this->SetPosition2(x,y); };
00110   virtual double *GetPoint2() { return this->GetPosition2(); };
00112 
00114 
00116   vtkSetVector2Macro(Range,double);
00117   vtkGetVectorMacro(Range,double,2);
00119 
00121 
00122   vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
00123   vtkGetMacro(NumberOfLabels, int);
00125   
00127 
00128   vtkSetStringMacro(LabelFormat);
00129   vtkGetStringMacro(LabelFormat);
00131 
00133 
00138   vtkSetMacro(AdjustLabels, int);
00139   vtkGetMacro(AdjustLabels, int);
00140   vtkBooleanMacro(AdjustLabels, int);
00141   virtual double *GetAdjustedRange()
00142     { 
00143       this->UpdateAdjustedRange();
00144       return this->AdjustedRange; 
00145     }
00146   virtual void GetAdjustedRange(double &_arg1, double &_arg2)
00147     { 
00148       this->UpdateAdjustedRange();
00149       _arg1 = this->AdjustedRange[0];
00150       _arg2 = this->AdjustedRange[1];
00151     }; 
00152   virtual void GetAdjustedRange(double _arg[2]) 
00153     { 
00154       this->GetAdjustedRange(_arg[0], _arg[1]);
00155     } 
00156   virtual int GetAdjustedNumberOfLabels()
00157     {
00158       this->UpdateAdjustedRange();
00159       return this->AdjustedNumberOfLabels; 
00160     }
00162 
00164 
00165   vtkSetStringMacro(Title);
00166   vtkGetStringMacro(Title);
00168 
00170 
00171   virtual void SetTitleTextProperty(vtkTextProperty *p);
00172   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00174   
00176 
00177   virtual void SetLabelTextProperty(vtkTextProperty *p);
00178   vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00180       
00182 
00184   vtkSetClampMacro(TickLength, int, 0, 100);
00185   vtkGetMacro(TickLength, int);
00187   
00189 
00192   vtkSetClampMacro(TickOffset, int, 0, 100);
00193   vtkGetMacro(TickOffset, int);
00195   
00197 
00198   vtkSetMacro(AxisVisibility, int);
00199   vtkGetMacro(AxisVisibility, int);
00200   vtkBooleanMacro(AxisVisibility, int);
00202 
00204 
00205   vtkSetMacro(TickVisibility, int);
00206   vtkGetMacro(TickVisibility, int);
00207   vtkBooleanMacro(TickVisibility, int);
00209 
00211 
00212   vtkSetMacro(LabelVisibility, int);
00213   vtkGetMacro(LabelVisibility, int);
00214   vtkBooleanMacro(LabelVisibility, int);
00216 
00218 
00219   vtkSetMacro(TitleVisibility, int);
00220   vtkGetMacro(TitleVisibility, int);
00221   vtkBooleanMacro(TitleVisibility, int);
00223 
00225 
00228   vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
00229   vtkGetMacro(FontFactor, double);
00231 
00233 
00235   vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
00236   vtkGetMacro(LabelFactor, double);
00238 
00240 
00241   int RenderOverlay(vtkViewport* viewport);
00242   int RenderOpaqueGeometry(vtkViewport* viewport);
00243   int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00245 
00249   void ReleaseGraphicsResources(vtkWindow *);
00250 
00252 
00260   static void ComputeRange(double inRange[2], 
00261                            double outRange[2],
00262                            int inNumTicks, 
00263                            int &outNumTicks, 
00264                            double &interval);
00266 
00268 
00275   static int SetFontSize(vtkViewport *viewport, 
00276                          vtkTextMapper *textMapper, 
00277                          int *targetSize, 
00278                          double factor, 
00279                          int *stringSize);
00280   static int SetMultipleFontSize(vtkViewport *viewport, 
00281                                  vtkTextMapper **textMappers, 
00282                                  int nbOfMappers, 
00283                                  int *targetSize,
00284                                  double factor, 
00285                                  int *stringSize);
00287 
00289   void ShallowCopy(vtkProp *prop);
00290 
00291 protected:
00292   vtkAxisActor2D();
00293   ~vtkAxisActor2D();
00294 
00295   vtkTextProperty *TitleTextProperty;
00296   vtkTextProperty *LabelTextProperty;
00297 
00298   char  *Title;
00299   double Range[2];
00300   int   NumberOfLabels;
00301   char  *LabelFormat;
00302   int   AdjustLabels;
00303   double FontFactor;
00304   double LabelFactor;
00305   int   TickLength;
00306   int   TickOffset;
00307 
00308   double AdjustedRange[2];
00309   int   AdjustedNumberOfLabels;
00310   int   NumberOfLabelsBuilt;
00311 
00312   int   AxisVisibility;
00313   int   TickVisibility;
00314   int   LabelVisibility;
00315   int   TitleVisibility;
00316   
00317   int   LastPosition[2];
00318   int   LastPosition2[2];
00319   
00320   int   LastSize[2];
00321   int   LastMaxLabelSize[2];
00322   
00323   virtual void BuildAxis(vtkViewport *viewport);
00324   static double ComputeStringOffset(double width, double height, double theta);
00325   static void SetOffsetPosition(double xTick[3], double theta, 
00326                                 int stringHeight, int stringWidth, 
00327                                 int offset, vtkActor2D *actor);
00328   virtual void UpdateAdjustedRange();
00329   
00330   vtkTextMapper *TitleMapper;
00331   vtkActor2D    *TitleActor;
00332 
00333   vtkTextMapper **LabelMappers;
00334   vtkActor2D    **LabelActors;
00335 
00336   vtkPolyData         *Axis;
00337   vtkPolyDataMapper2D *AxisMapper;
00338   vtkActor2D          *AxisActor;
00339 
00340   vtkTimeStamp  AdjustedRangeBuildTime;
00341   vtkTimeStamp  BuildTime;
00342 
00343 private:
00344   vtkAxisActor2D(const vtkAxisActor2D&);  // Not implemented.
00345   void operator=(const vtkAxisActor2D&);  // Not implemented.
00346 };
00347 
00348 
00349 #endif