Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
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 
00015 =========================================================================*/
00059 #ifndef __vtkAxisActor2D_h
00060 #define __vtkAxisActor2D_h
00061 
00062 #include "vtkActor2D.h"
00063 
00064 class vtkPolyDataMapper2D;
00065 class vtkPolyData;
00066 class vtkTextMapper;
00067 class vtkTextProperty;
00068 
00069 #define VTK_MAX_LABELS 25
00070 
00071 class VTK_RENDERING_EXPORT vtkAxisActor2D : public vtkActor2D
00072 {
00073 public:
00074   vtkTypeRevisionMacro(vtkAxisActor2D,vtkActor2D);
00075   void PrintSelf(ostream& os, vtkIndent indent);
00076 
00078   static vtkAxisActor2D *New();
00079 
00081 
00083   virtual vtkCoordinate *GetPoint1Coordinate() 
00084     { return this->GetPositionCoordinate(); };
00085   virtual void SetPoint1(float x[2]) { this->SetPosition(x); };
00086   virtual void SetPoint1(float x, float y) { this->SetPosition(x,y); };
00087   virtual float *GetPoint1() { return this->GetPosition(); };
00089 
00091 
00095   virtual vtkCoordinate *GetPoint2Coordinate() 
00096     { return this->GetPosition2Coordinate(); };
00097   virtual void SetPoint2(float x[2]) { this->SetPosition2(x); };
00098   virtual void SetPoint2(float x, float y) { this->SetPosition2(x,y); };
00099   virtual float *GetPoint2() { return this->GetPosition2(); };
00101 
00103 
00105   vtkSetVector2Macro(Range,float);
00106   vtkGetVectorMacro(Range,float,2);
00108 
00110 
00111   vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
00112   vtkGetMacro(NumberOfLabels, int);
00114   
00116 
00117   vtkSetStringMacro(LabelFormat);
00118   vtkGetStringMacro(LabelFormat);
00120 
00122 
00127   vtkSetMacro(AdjustLabels, int);
00128   vtkGetMacro(AdjustLabels, int);
00129   vtkBooleanMacro(AdjustLabels, int);
00130   virtual float *GetAdjustedRange()
00131     { 
00132       this->UpdateAdjustedRange();
00133       return this->AdjustedRange; 
00134     }
00135   virtual void GetAdjustedRange(float &_arg1, float &_arg2)
00136     { 
00137       this->UpdateAdjustedRange();
00138       _arg1 = this->AdjustedRange[0];
00139       _arg2 = this->AdjustedRange[1];
00140     }; 
00141   virtual void GetAdjustedRange(float _arg[2]) 
00142     { 
00143       this->GetAdjustedRange(_arg[0], _arg[1]);
00144     } 
00145   virtual int GetAdjustedNumberOfLabels()
00146     {
00147       this->UpdateAdjustedRange();
00148       return this->AdjustedNumberOfLabels; 
00149     }
00151 
00153 
00154   vtkSetStringMacro(Title);
00155   vtkGetStringMacro(Title);
00157 
00159 
00160   virtual void SetTitleTextProperty(vtkTextProperty *p);
00161   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00163   
00165 
00166   virtual void SetLabelTextProperty(vtkTextProperty *p);
00167   vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00169       
00170 #ifndef VTK_REMOVE_LEGACY_CODE
00171 
00172 
00177   virtual void SetFontFamily(int val);
00178   virtual int GetFontFamily();
00179   void SetFontFamilyToArial()   { this->SetFontFamily(VTK_ARIAL);  };
00180   void SetFontFamilyToCourier() { this->SetFontFamily(VTK_COURIER);};
00181   void SetFontFamilyToTimes()   { this->SetFontFamily(VTK_TIMES);  };
00183 #endif
00184 
00185 #ifndef VTK_REMOVE_LEGACY_CODE
00186 
00187 
00190   virtual void SetBold(int val);
00191   virtual int GetBold();
00192   vtkBooleanMacro(Bold, int);
00194 #endif
00195 
00196 #ifndef VTK_REMOVE_LEGACY_CODE
00197 
00198 
00201   virtual void SetItalic(int val);
00202   virtual int GetItalic();
00203   vtkBooleanMacro(Italic, int);
00205 #endif
00206 
00207 #ifndef VTK_REMOVE_LEGACY_CODE
00208 
00209 
00212   virtual void SetShadow(int val);
00213   virtual int GetShadow();
00214   vtkBooleanMacro(Shadow, int);
00216 #endif
00217   
00219 
00221   vtkSetClampMacro(TickLength, int, 0, 100);
00222   vtkGetMacro(TickLength, int);
00224   
00226 
00229   vtkSetClampMacro(TickOffset, int, 0, 100);
00230   vtkGetMacro(TickOffset, int);
00232   
00234 
00235   vtkSetMacro(AxisVisibility, int);
00236   vtkGetMacro(AxisVisibility, int);
00237   vtkBooleanMacro(AxisVisibility, int);
00239 
00241 
00242   vtkSetMacro(TickVisibility, int);
00243   vtkGetMacro(TickVisibility, int);
00244   vtkBooleanMacro(TickVisibility, int);
00246 
00248 
00249   vtkSetMacro(LabelVisibility, int);
00250   vtkGetMacro(LabelVisibility, int);
00251   vtkBooleanMacro(LabelVisibility, int);
00253 
00255 
00256   vtkSetMacro(TitleVisibility, int);
00257   vtkGetMacro(TitleVisibility, int);
00258   vtkBooleanMacro(TitleVisibility, int);
00260 
00262 
00265   vtkSetClampMacro(FontFactor, float, 0.1, 2.0);
00266   vtkGetMacro(FontFactor, float);
00268 
00270 
00272   vtkSetClampMacro(LabelFactor, float, 0.1, 2.0);
00273   vtkGetMacro(LabelFactor, float);
00275 
00277 
00278   int RenderOverlay(vtkViewport* viewport);
00279   int RenderOpaqueGeometry(vtkViewport* viewport);
00280   int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00282 
00286   void ReleaseGraphicsResources(vtkWindow *);
00287 
00289 
00297   static void ComputeRange(float inRange[2], 
00298                            float outRange[2],
00299                            int inNumTicks, 
00300                            int &outNumTicks, 
00301                            float &interval);
00303 
00305 
00312   static int SetFontSize(vtkViewport *viewport, 
00313                          vtkTextMapper *textMapper, 
00314                          int *targetSize, 
00315                          float factor, 
00316                          int *stringSize);
00317   static int SetMultipleFontSize(vtkViewport *viewport, 
00318                                  vtkTextMapper **textMappers, 
00319                                  int nbOfMappers, 
00320                                  int *targetSize,
00321                                  float factor, 
00322                                  int *stringSize);
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   float Range[2];
00337   int   NumberOfLabels;
00338   char  *LabelFormat;
00339   int   AdjustLabels;
00340   float FontFactor;
00341   float LabelFactor;
00342   int   TickLength;
00343   int   TickOffset;
00344 
00345   float AdjustedRange[2];
00346   int   AdjustedNumberOfLabels;
00347   int   NumberOfLabelsBuilt;
00348 
00349   int   AxisVisibility;
00350   int   TickVisibility;
00351   int   LabelVisibility;
00352   int   TitleVisibility;
00353   
00354   int   LastPosition[2];
00355   int   LastPosition2[2];
00356   
00357   int   LastSize[2];
00358   int   LastMaxLabelSize[2];
00359   
00360   virtual void BuildAxis(vtkViewport *viewport);
00361   static float ComputeStringOffset(float width, float height, float theta);
00362   static void SetOffsetPosition(float xTick[3], float theta, int stringHeight,
00363                                 int stringWidth, int offset, vtkActor2D *actor);
00364   virtual void UpdateAdjustedRange();
00365 
00366   vtkTextMapper *TitleMapper;
00367   vtkActor2D    *TitleActor;
00368 
00369   vtkTextMapper **LabelMappers;
00370   vtkActor2D    **LabelActors;
00371 
00372   vtkPolyData         *Axis;
00373   vtkPolyDataMapper2D *AxisMapper;
00374   vtkActor2D          *AxisActor;
00375 
00376   vtkTimeStamp  AdjustedRangeBuildTime;
00377   vtkTimeStamp  BuildTime;
00378 
00379 private:
00380   vtkAxisActor2D(const vtkAxisActor2D&);  // Not implemented.
00381   void operator=(const vtkAxisActor2D&);  // Not implemented.
00382 };
00383 
00384 
00385 #endif