00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00057 #ifndef __vtkAxisActor2D_h
00058 #define __vtkAxisActor2D_h
00059
00060 #include "vtkActor2D.h"
00061
00062 class vtkPolyDataMapper2D;
00063 class vtkPolyData;
00064 class vtkTextMapper;
00065 class vtkTextProperty;
00066
00067 #define VTK_MAX_LABELS 25
00068
00069 class VTK_RENDERING_EXPORT vtkAxisActor2D : public vtkActor2D
00070 {
00071 public:
00072 vtkTypeRevisionMacro(vtkAxisActor2D,vtkActor2D);
00073 void PrintSelf(ostream& os, vtkIndent indent);
00074
00076 static vtkAxisActor2D *New();
00077
00079
00081 virtual vtkCoordinate *GetPoint1Coordinate()
00082 { return this->GetPositionCoordinate(); };
00083 virtual void SetPoint1(double x[2]) { this->SetPosition(x); };
00084 virtual void SetPoint1(double x, double y) { this->SetPosition(x,y); };
00085 virtual double *GetPoint1() { return this->GetPosition(); };
00087
00089
00093 virtual vtkCoordinate *GetPoint2Coordinate()
00094 { return this->GetPosition2Coordinate(); };
00095 virtual void SetPoint2(double x[2]) { this->SetPosition2(x); };
00096 virtual void SetPoint2(double x, double y) { this->SetPosition2(x,y); };
00097 virtual double *GetPoint2() { return this->GetPosition2(); };
00099
00101
00103 vtkSetVector2Macro(Range,double);
00104 vtkGetVectorMacro(Range,double,2);
00106
00108
00109 vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
00110 vtkGetMacro(NumberOfLabels, int);
00112
00114
00115 vtkSetStringMacro(LabelFormat);
00116 vtkGetStringMacro(LabelFormat);
00118
00120
00125 vtkSetMacro(AdjustLabels, int);
00126 vtkGetMacro(AdjustLabels, int);
00127 vtkBooleanMacro(AdjustLabels, int);
00128 virtual double *GetAdjustedRange()
00129 {
00130 this->UpdateAdjustedRange();
00131 return this->AdjustedRange;
00132 }
00133 virtual void GetAdjustedRange(double &_arg1, double &_arg2)
00134 {
00135 this->UpdateAdjustedRange();
00136 _arg1 = this->AdjustedRange[0];
00137 _arg2 = this->AdjustedRange[1];
00138 };
00139 virtual void GetAdjustedRange(double _arg[2])
00140 {
00141 this->GetAdjustedRange(_arg[0], _arg[1]);
00142 }
00143 virtual int GetAdjustedNumberOfLabels()
00144 {
00145 this->UpdateAdjustedRange();
00146 return this->AdjustedNumberOfLabels;
00147 }
00149
00151
00152 vtkSetStringMacro(Title);
00153 vtkGetStringMacro(Title);
00155
00157
00158 virtual void SetTitleTextProperty(vtkTextProperty *p);
00159 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00161
00163
00164 virtual void SetLabelTextProperty(vtkTextProperty *p);
00165 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00167
00169
00171 vtkSetClampMacro(TickLength, int, 0, 100);
00172 vtkGetMacro(TickLength, int);
00174
00176
00179 vtkSetClampMacro(TickOffset, int, 0, 100);
00180 vtkGetMacro(TickOffset, int);
00182
00184
00185 vtkSetMacro(AxisVisibility, int);
00186 vtkGetMacro(AxisVisibility, int);
00187 vtkBooleanMacro(AxisVisibility, int);
00189
00191
00192 vtkSetMacro(TickVisibility, int);
00193 vtkGetMacro(TickVisibility, int);
00194 vtkBooleanMacro(TickVisibility, int);
00196
00198
00199 vtkSetMacro(LabelVisibility, int);
00200 vtkGetMacro(LabelVisibility, int);
00201 vtkBooleanMacro(LabelVisibility, int);
00203
00205
00206 vtkSetMacro(TitleVisibility, int);
00207 vtkGetMacro(TitleVisibility, int);
00208 vtkBooleanMacro(TitleVisibility, int);
00210
00212
00215 vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
00216 vtkGetMacro(FontFactor, double);
00218
00220
00222 vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
00223 vtkGetMacro(LabelFactor, double);
00225
00227
00228 int RenderOverlay(vtkViewport* viewport);
00229 int RenderOpaqueGeometry(vtkViewport* viewport);
00230 int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00232
00236 void ReleaseGraphicsResources(vtkWindow *);
00237
00239
00247 static void ComputeRange(double inRange[2],
00248 double outRange[2],
00249 int inNumTicks,
00250 int &outNumTicks,
00251 double &interval);
00253
00255
00262 static int SetFontSize(vtkViewport *viewport,
00263 vtkTextMapper *textMapper,
00264 int *targetSize,
00265 double factor,
00266 int *stringSize);
00267 static int SetMultipleFontSize(vtkViewport *viewport,
00268 vtkTextMapper **textMappers,
00269 int nbOfMappers,
00270 int *targetSize,
00271 double factor,
00272 int *stringSize);
00274
00276 void ShallowCopy(vtkProp *prop);
00277
00278 protected:
00279 vtkAxisActor2D();
00280 ~vtkAxisActor2D();
00281
00282 vtkTextProperty *TitleTextProperty;
00283 vtkTextProperty *LabelTextProperty;
00284
00285 char *Title;
00286 double Range[2];
00287 int NumberOfLabels;
00288 char *LabelFormat;
00289 int AdjustLabels;
00290 double FontFactor;
00291 double LabelFactor;
00292 int TickLength;
00293 int TickOffset;
00294
00295 double AdjustedRange[2];
00296 int AdjustedNumberOfLabels;
00297 int NumberOfLabelsBuilt;
00298
00299 int AxisVisibility;
00300 int TickVisibility;
00301 int LabelVisibility;
00302 int TitleVisibility;
00303
00304 int LastPosition[2];
00305 int LastPosition2[2];
00306
00307 int LastSize[2];
00308 int LastMaxLabelSize[2];
00309
00310 virtual void BuildAxis(vtkViewport *viewport);
00311 static double ComputeStringOffset(double width, double height, double theta);
00312 static void SetOffsetPosition(double xTick[3], double theta,
00313 int stringHeight, int stringWidth,
00314 int offset, vtkActor2D *actor);
00315 virtual void UpdateAdjustedRange();
00316
00317 vtkTextMapper *TitleMapper;
00318 vtkActor2D *TitleActor;
00319
00320 vtkTextMapper **LabelMappers;
00321 vtkActor2D **LabelActors;
00322
00323 vtkPolyData *Axis;
00324 vtkPolyDataMapper2D *AxisMapper;
00325 vtkActor2D *AxisActor;
00326
00327 vtkTimeStamp AdjustedRangeBuildTime;
00328 vtkTimeStamp BuildTime;
00329
00330 private:
00331 vtkAxisActor2D(const vtkAxisActor2D&);
00332 void operator=(const vtkAxisActor2D&);
00333 };
00334
00335
00336 #endif