VTK
dox/Rendering/vtkAxisActor2D.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkAxisActor2D.h
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 =========================================================================*/
00060 #ifndef __vtkAxisActor2D_h
00061 #define __vtkAxisActor2D_h
00062 
00063 #include "vtkActor2D.h"
00064 
00065 class vtkPolyDataMapper2D;
00066 class vtkPolyData;
00067 class vtkTextMapper;
00068 class vtkTextProperty;
00069 
00070 #define VTK_MAX_LABELS 25
00071 
00072 class VTK_RENDERING_EXPORT vtkAxisActor2D : public vtkActor2D
00073 {
00074 public:
00075   vtkTypeMacro(vtkAxisActor2D,vtkActor2D);
00076   void PrintSelf(ostream& os, vtkIndent indent);
00077 
00079   static vtkAxisActor2D *New();
00080 
00082 
00084   virtual vtkCoordinate *GetPoint1Coordinate()
00085     { return this->GetPositionCoordinate(); };
00086   virtual void SetPoint1(double x[2]) { this->SetPosition(x); };
00087   virtual void SetPoint1(double x, double y) { this->SetPosition(x,y); };
00088   virtual double *GetPoint1() { return this->GetPosition(); };
00090 
00092 
00096   virtual vtkCoordinate *GetPoint2Coordinate()
00097     { return this->GetPosition2Coordinate(); };
00098   virtual void SetPoint2(double x[2]) { this->SetPosition2(x); };
00099   virtual void SetPoint2(double x, double y) { this->SetPosition2(x,y); };
00100   virtual double *GetPoint2() { return this->GetPosition2(); };
00102 
00104 
00106   vtkSetVector2Macro(Range,double);
00107   vtkGetVectorMacro(Range,double,2);
00109 
00111 
00114   vtkSetMacro(RulerMode,int);
00115   vtkGetMacro(RulerMode,int);
00116   vtkBooleanMacro(RulerMode,int);
00118 
00120 
00122   vtkSetClampMacro(RulerDistance,double,0,VTK_LARGE_FLOAT);
00123   vtkGetMacro(RulerDistance,double);
00125 
00127 
00130   vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
00131   vtkGetMacro(NumberOfLabels, int);
00133 
00135 
00136   vtkSetStringMacro(LabelFormat);
00137   vtkGetStringMacro(LabelFormat);
00139 
00141 
00147   vtkSetMacro(AdjustLabels, int);
00148   vtkGetMacro(AdjustLabels, int);
00149   vtkBooleanMacro(AdjustLabels, int);
00150   virtual double *GetAdjustedRange()
00151     {
00152       this->UpdateAdjustedRange();
00153       return this->AdjustedRange;
00154     }
00155   virtual void GetAdjustedRange(double &_arg1, double &_arg2)
00156     {
00157       this->UpdateAdjustedRange();
00158       _arg1 = this->AdjustedRange[0];
00159       _arg2 = this->AdjustedRange[1];
00160     };
00161   virtual void GetAdjustedRange(double _arg[2])
00162     {
00163       this->GetAdjustedRange(_arg[0], _arg[1]);
00164     }
00165   virtual int GetAdjustedNumberOfLabels()
00166     {
00167       this->UpdateAdjustedRange();
00168       return this->AdjustedNumberOfLabels;
00169     }
00171 
00173 
00174   vtkSetStringMacro(Title);
00175   vtkGetStringMacro(Title);
00177 
00179 
00180   virtual void SetTitleTextProperty(vtkTextProperty *p);
00181   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00183 
00185 
00186   virtual void SetLabelTextProperty(vtkTextProperty *p);
00187   vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00189 
00191 
00193   vtkSetClampMacro(TickLength, int, 0, 100);
00194   vtkGetMacro(TickLength, int);
00196 
00198 
00200   vtkSetClampMacro(NumberOfMinorTicks, int, 0, 20);
00201   vtkGetMacro(NumberOfMinorTicks, int);
00203 
00205 
00207   vtkSetClampMacro(MinorTickLength, int, 0, 100);
00208   vtkGetMacro(MinorTickLength, int);
00210 
00212 
00215   vtkSetClampMacro(TickOffset, int, 0, 100);
00216   vtkGetMacro(TickOffset, int);
00218 
00220 
00221   vtkSetMacro(AxisVisibility, int);
00222   vtkGetMacro(AxisVisibility, int);
00223   vtkBooleanMacro(AxisVisibility, int);
00225 
00227 
00228   vtkSetMacro(TickVisibility, int);
00229   vtkGetMacro(TickVisibility, int);
00230   vtkBooleanMacro(TickVisibility, int);
00232 
00234 
00235   vtkSetMacro(LabelVisibility, int);
00236   vtkGetMacro(LabelVisibility, int);
00237   vtkBooleanMacro(LabelVisibility, int);
00239 
00241 
00242   vtkSetMacro(TitleVisibility, int);
00243   vtkGetMacro(TitleVisibility, int);
00244   vtkBooleanMacro(TitleVisibility, int);
00246 
00248 
00250   vtkSetMacro(TitlePosition, double);
00251   vtkGetMacro(TitlePosition, double);
00253 
00255 
00258   vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
00259   vtkGetMacro(FontFactor, double);
00261 
00263 
00265   vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
00266   vtkGetMacro(LabelFactor, double);
00268 
00270 
00271   int RenderOverlay(vtkViewport* viewport);
00272   int RenderOpaqueGeometry(vtkViewport* viewport);
00273   virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) {return 0;}
00275 
00277   virtual int HasTranslucentPolygonalGeometry();
00278 
00282   void ReleaseGraphicsResources(vtkWindow *);
00283 
00285 
00293   static void ComputeRange(double inRange[2],
00294                            double outRange[2],
00295                            int inNumTicks,
00296                            int &outNumTicks,
00297                            double &interval);
00299 
00301 
00308   static int SetMultipleFontSize(vtkViewport *viewport,
00309                                  vtkTextMapper **textMappers,
00310                                  int nbOfMappers,
00311                                  int *targetSize,
00312                                  double factor,
00313                                  int *stringSize);
00315 
00317 
00320   vtkSetMacro(SizeFontRelativeToAxis,int);
00321   vtkGetMacro(SizeFontRelativeToAxis,int);
00322   vtkBooleanMacro(SizeFontRelativeToAxis,int);
00324 
00326   void ShallowCopy(vtkProp *prop);
00327 
00328 protected:
00329   vtkAxisActor2D();
00330   ~vtkAxisActor2D();
00331 
00332   vtkTextProperty *TitleTextProperty;
00333   vtkTextProperty *LabelTextProperty;
00334 
00335   char  *Title;
00336   double Range[2];
00337   double TitlePosition;
00338   int    RulerMode;
00339   double RulerDistance;
00340   int   NumberOfLabels;
00341   char  *LabelFormat;
00342   int   AdjustLabels;
00343   double FontFactor;
00344   double LabelFactor;
00345   int   TickLength;
00346   int   MinorTickLength;
00347   int   TickOffset;
00348   int NumberOfMinorTicks;
00349 
00350   double AdjustedRange[2];
00351   int   AdjustedNumberOfLabels;
00352   int   NumberOfLabelsBuilt;
00353 
00354   int   AxisVisibility;
00355   int   TickVisibility;
00356   int   LabelVisibility;
00357   int   TitleVisibility;
00358 
00359   int   LastPosition[2];
00360   int   LastPosition2[2];
00361 
00362   int   LastSize[2];
00363   int   LastMaxLabelSize[2];
00364 
00365   int  SizeFontRelativeToAxis;
00366 
00367   virtual void BuildAxis(vtkViewport *viewport);
00368   static double ComputeStringOffset(double width, double height, double theta);
00369   static void SetOffsetPosition(double xTick[3], double theta,
00370                                 int stringHeight, int stringWidth,
00371                                 int offset, vtkActor2D *actor);
00372   virtual void UpdateAdjustedRange();
00373 
00374   vtkTextMapper *TitleMapper;
00375   vtkActor2D    *TitleActor;
00376 
00377   vtkTextMapper **LabelMappers;
00378   vtkActor2D    **LabelActors;
00379 
00380   vtkPolyData         *Axis;
00381   vtkPolyDataMapper2D *AxisMapper;
00382   vtkActor2D          *AxisActor;
00383 
00384   vtkTimeStamp  AdjustedRangeBuildTime;
00385   vtkTimeStamp  BuildTime;
00386 
00387 private:
00388   vtkAxisActor2D(const vtkAxisActor2D&);  // Not implemented.
00389   void operator=(const vtkAxisActor2D&);  // Not implemented.
00390 };
00391 
00392 
00393 #endif