VTK
|
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 "vtkRenderingAnnotationModule.h" // For export macro 00064 #include "vtkActor2D.h" 00065 00066 class vtkPolyDataMapper2D; 00067 class vtkPolyData; 00068 class vtkTextMapper; 00069 class vtkTextProperty; 00070 00071 #define VTK_MAX_LABELS 25 00072 00073 class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor2D : public vtkActor2D 00074 { 00075 public: 00076 vtkTypeMacro(vtkAxisActor2D,vtkActor2D); 00077 void PrintSelf(ostream& os, vtkIndent indent); 00078 00080 static vtkAxisActor2D *New(); 00081 00083 00085 virtual vtkCoordinate *GetPoint1Coordinate() 00086 { return this->GetPositionCoordinate(); }; 00087 virtual void SetPoint1(double x[2]) { this->SetPosition(x); }; 00088 virtual void SetPoint1(double x, double y) { this->SetPosition(x,y); }; 00089 virtual double *GetPoint1() { return this->GetPosition(); }; 00091 00093 00097 virtual vtkCoordinate *GetPoint2Coordinate() 00098 { return this->GetPosition2Coordinate(); }; 00099 virtual void SetPoint2(double x[2]) { this->SetPosition2(x); }; 00100 virtual void SetPoint2(double x, double y) { this->SetPosition2(x,y); }; 00101 virtual double *GetPoint2() { return this->GetPosition2(); }; 00103 00105 00107 vtkSetVector2Macro(Range,double); 00108 vtkGetVectorMacro(Range,double,2); 00110 00112 00115 vtkSetMacro(RulerMode,int); 00116 vtkGetMacro(RulerMode,int); 00117 vtkBooleanMacro(RulerMode,int); 00119 00121 00123 vtkSetClampMacro(RulerDistance,double,0,VTK_FLOAT_MAX); 00124 vtkGetMacro(RulerDistance,double); 00126 00128 00131 vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS); 00132 vtkGetMacro(NumberOfLabels, int); 00134 00136 00137 vtkSetStringMacro(LabelFormat); 00138 vtkGetStringMacro(LabelFormat); 00140 00142 00148 vtkSetMacro(AdjustLabels, int); 00149 vtkGetMacro(AdjustLabels, int); 00150 vtkBooleanMacro(AdjustLabels, int); 00151 virtual double *GetAdjustedRange() 00152 { 00153 this->UpdateAdjustedRange(); 00154 return this->AdjustedRange; 00155 } 00156 virtual void GetAdjustedRange(double &_arg1, double &_arg2) 00157 { 00158 this->UpdateAdjustedRange(); 00159 _arg1 = this->AdjustedRange[0]; 00160 _arg2 = this->AdjustedRange[1]; 00161 }; 00162 virtual void GetAdjustedRange(double _arg[2]) 00163 { 00164 this->GetAdjustedRange(_arg[0], _arg[1]); 00165 } 00166 virtual int GetAdjustedNumberOfLabels() 00167 { 00168 this->UpdateAdjustedRange(); 00169 return this->AdjustedNumberOfLabels; 00170 } 00172 00174 00175 vtkSetStringMacro(Title); 00176 vtkGetStringMacro(Title); 00178 00180 00181 virtual void SetTitleTextProperty(vtkTextProperty *p); 00182 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); 00184 00186 00187 virtual void SetLabelTextProperty(vtkTextProperty *p); 00188 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); 00190 00192 00194 vtkSetClampMacro(TickLength, int, 0, 100); 00195 vtkGetMacro(TickLength, int); 00197 00199 00201 vtkSetClampMacro(NumberOfMinorTicks, int, 0, 20); 00202 vtkGetMacro(NumberOfMinorTicks, int); 00204 00206 00208 vtkSetClampMacro(MinorTickLength, int, 0, 100); 00209 vtkGetMacro(MinorTickLength, int); 00211 00213 00216 vtkSetClampMacro(TickOffset, int, 0, 100); 00217 vtkGetMacro(TickOffset, int); 00219 00221 00222 vtkSetMacro(AxisVisibility, int); 00223 vtkGetMacro(AxisVisibility, int); 00224 vtkBooleanMacro(AxisVisibility, int); 00226 00228 00229 vtkSetMacro(TickVisibility, int); 00230 vtkGetMacro(TickVisibility, int); 00231 vtkBooleanMacro(TickVisibility, int); 00233 00235 00236 vtkSetMacro(LabelVisibility, int); 00237 vtkGetMacro(LabelVisibility, int); 00238 vtkBooleanMacro(LabelVisibility, int); 00240 00242 00243 vtkSetMacro(TitleVisibility, int); 00244 vtkGetMacro(TitleVisibility, int); 00245 vtkBooleanMacro(TitleVisibility, int); 00247 00249 00251 vtkSetMacro(TitlePosition, double); 00252 vtkGetMacro(TitlePosition, double); 00254 00256 00259 vtkSetClampMacro(FontFactor, double, 0.1, 2.0); 00260 vtkGetMacro(FontFactor, double); 00262 00264 00266 vtkSetClampMacro(LabelFactor, double, 0.1, 2.0); 00267 vtkGetMacro(LabelFactor, double); 00269 00271 00272 int RenderOverlay(vtkViewport* viewport); 00273 int RenderOpaqueGeometry(vtkViewport* viewport); 00274 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) {return 0;} 00276 00278 virtual int HasTranslucentPolygonalGeometry(); 00279 00283 void ReleaseGraphicsResources(vtkWindow *); 00284 00286 00294 static void ComputeRange(double inRange[2], 00295 double outRange[2], 00296 int inNumTicks, 00297 int &outNumTicks, 00298 double &interval); 00300 00302 00309 static int SetMultipleFontSize(vtkViewport *viewport, 00310 vtkTextMapper **textMappers, 00311 int nbOfMappers, 00312 int *targetSize, 00313 double factor, 00314 int *stringSize); 00316 00318 00321 vtkSetMacro(SizeFontRelativeToAxis,int); 00322 vtkGetMacro(SizeFontRelativeToAxis,int); 00323 vtkBooleanMacro(SizeFontRelativeToAxis,int); 00325 00327 void ShallowCopy(vtkProp *prop); 00328 00329 protected: 00330 vtkAxisActor2D(); 00331 ~vtkAxisActor2D(); 00332 00333 vtkTextProperty *TitleTextProperty; 00334 vtkTextProperty *LabelTextProperty; 00335 00336 char *Title; 00337 double Range[2]; 00338 double TitlePosition; 00339 int RulerMode; 00340 double RulerDistance; 00341 int NumberOfLabels; 00342 char *LabelFormat; 00343 int AdjustLabels; 00344 double FontFactor; 00345 double LabelFactor; 00346 int TickLength; 00347 int MinorTickLength; 00348 int TickOffset; 00349 int NumberOfMinorTicks; 00350 00351 double AdjustedRange[2]; 00352 int AdjustedNumberOfLabels; 00353 int NumberOfLabelsBuilt; 00354 00355 int AxisVisibility; 00356 int TickVisibility; 00357 int LabelVisibility; 00358 int TitleVisibility; 00359 00360 int LastPosition[2]; 00361 int LastPosition2[2]; 00362 00363 int LastSize[2]; 00364 int LastMaxLabelSize[2]; 00365 00366 int SizeFontRelativeToAxis; 00367 00368 virtual void BuildAxis(vtkViewport *viewport); 00369 static double ComputeStringOffset(double width, double height, double theta); 00370 static void SetOffsetPosition(double xTick[3], double theta, 00371 int stringHeight, int stringWidth, 00372 int offset, vtkActor2D *actor); 00373 virtual void UpdateAdjustedRange(); 00374 00375 vtkTextMapper *TitleMapper; 00376 vtkActor2D *TitleActor; 00377 00378 vtkTextMapper **LabelMappers; 00379 vtkActor2D **LabelActors; 00380 00381 vtkPolyData *Axis; 00382 vtkPolyDataMapper2D *AxisMapper; 00383 vtkActor2D *AxisActor; 00384 00385 vtkTimeStamp AdjustedRangeBuildTime; 00386 vtkTimeStamp BuildTime; 00387 00388 private: 00389 vtkAxisActor2D(const vtkAxisActor2D&); // Not implemented. 00390 void operator=(const vtkAxisActor2D&); // Not implemented. 00391 }; 00392 00393 00394 #endif