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