00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00072 #ifndef __vtkAxisActor2D_h
00073 #define __vtkAxisActor2D_h
00074
00075 #include "vtkActor2D.h"
00076
00077 class vtkPolyDataMapper2D;
00078 class vtkPolyData;
00079 class vtkTextMapper;
00080 class vtkTextProperty;
00081
00082 #define VTK_MAX_LABELS 25
00083
00084 class VTK_RENDERING_EXPORT vtkAxisActor2D : public vtkActor2D
00085 {
00086 public:
00087 vtkTypeRevisionMacro(vtkAxisActor2D,vtkActor2D);
00088 void PrintSelf(ostream& os, vtkIndent indent);
00089
00091 static vtkAxisActor2D *New();
00092
00094
00096 virtual vtkCoordinate *GetPoint1Coordinate()
00097 { return this->GetPositionCoordinate(); };
00098 virtual void SetPoint1(float x[2]) { this->SetPosition(x); };
00099 virtual void SetPoint1(float x, float y) { this->SetPosition(x,y); };
00100 virtual float *GetPoint1() { return this->GetPosition(); };
00102
00104
00108 virtual vtkCoordinate *GetPoint2Coordinate()
00109 { return this->GetPosition2Coordinate(); };
00110 virtual void SetPoint2(float x[2]) { this->SetPosition2(x); };
00111 virtual void SetPoint2(float x, float y) { this->SetPosition2(x,y); };
00112 virtual float *GetPoint2() { return this->GetPosition2(); };
00114
00116
00118 vtkSetVector2Macro(Range,float);
00119 vtkGetVectorMacro(Range,float,2);
00121
00123
00124 vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
00125 vtkGetMacro(NumberOfLabels, int);
00127
00129
00130 vtkSetStringMacro(LabelFormat);
00131 vtkGetStringMacro(LabelFormat);
00133
00135
00140 vtkSetMacro(AdjustLabels, int);
00141 vtkGetMacro(AdjustLabels, int);
00142 vtkBooleanMacro(AdjustLabels, int);
00143 virtual float *GetAdjustedRange()
00144 {
00145 this->UpdateAdjustedRange();
00146 return this->AdjustedRange;
00147 }
00148 virtual void GetAdjustedRange(float &_arg1, float &_arg2)
00149 {
00150 this->UpdateAdjustedRange();
00151 _arg1 = this->AdjustedRange[0];
00152 _arg2 = this->AdjustedRange[1];
00153 };
00154 virtual void GetAdjustedRange(float _arg[2])
00155 {
00156 this->GetAdjustedRange(_arg[0], _arg[1]);
00157 }
00158 virtual int GetAdjustedNumberOfLabels()
00159 {
00160 this->UpdateAdjustedRange();
00161 return this->AdjustedNumberOfLabels;
00162 }
00164
00166
00167 vtkSetStringMacro(Title);
00168 vtkGetStringMacro(Title);
00170
00172
00173 virtual void SetTitleTextProperty(vtkTextProperty *p);
00174 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00176
00178
00179 virtual void SetLabelTextProperty(vtkTextProperty *p);
00180 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00182
00183 #ifndef VTK_REMOVE_LEGACY_CODE
00184
00185
00190 virtual void SetFontFamily(int val);
00191 virtual int GetFontFamily();
00192 void SetFontFamilyToArial() { this->SetFontFamily(VTK_ARIAL); };
00193 void SetFontFamilyToCourier() { this->SetFontFamily(VTK_COURIER);};
00194 void SetFontFamilyToTimes() { this->SetFontFamily(VTK_TIMES); };
00196 #endif
00197
00198 #ifndef VTK_REMOVE_LEGACY_CODE
00199
00200
00203 virtual void SetBold(int val);
00204 virtual int GetBold();
00205 vtkBooleanMacro(Bold, int);
00207 #endif
00208
00209 #ifndef VTK_REMOVE_LEGACY_CODE
00210
00211
00214 virtual void SetItalic(int val);
00215 virtual int GetItalic();
00216 vtkBooleanMacro(Italic, int);
00218 #endif
00219
00220 #ifndef VTK_REMOVE_LEGACY_CODE
00221
00222
00225 virtual void SetShadow(int val);
00226 virtual int GetShadow();
00227 vtkBooleanMacro(Shadow, int);
00229 #endif
00230
00232
00234 vtkSetClampMacro(TickLength, int, 0, 100);
00235 vtkGetMacro(TickLength, int);
00237
00239
00242 vtkSetClampMacro(TickOffset, int, 0, 100);
00243 vtkGetMacro(TickOffset, int);
00245
00247
00248 vtkSetMacro(AxisVisibility, int);
00249 vtkGetMacro(AxisVisibility, int);
00250 vtkBooleanMacro(AxisVisibility, int);
00252
00254
00255 vtkSetMacro(TickVisibility, int);
00256 vtkGetMacro(TickVisibility, int);
00257 vtkBooleanMacro(TickVisibility, int);
00259
00261
00262 vtkSetMacro(LabelVisibility, int);
00263 vtkGetMacro(LabelVisibility, int);
00264 vtkBooleanMacro(LabelVisibility, int);
00266
00268
00269 vtkSetMacro(TitleVisibility, int);
00270 vtkGetMacro(TitleVisibility, int);
00271 vtkBooleanMacro(TitleVisibility, int);
00273
00275
00278 vtkSetClampMacro(FontFactor, float, 0.1, 2.0);
00279 vtkGetMacro(FontFactor, float);
00281
00283
00285 vtkSetClampMacro(LabelFactor, float, 0.1, 2.0);
00286 vtkGetMacro(LabelFactor, float);
00288
00290
00291 int RenderOverlay(vtkViewport* viewport);
00292 int RenderOpaqueGeometry(vtkViewport* viewport);
00293 int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00295
00299 void ReleaseGraphicsResources(vtkWindow *);
00300
00302
00310 static void ComputeRange(float inRange[2],
00311 float outRange[2],
00312 int inNumTicks,
00313 int &outNumTicks,
00314 float &interval);
00316
00318
00325 static int SetFontSize(vtkViewport *viewport,
00326 vtkTextMapper *textMapper,
00327 int *targetSize,
00328 float factor,
00329 int *stringSize);
00330 static int SetMultipleFontSize(vtkViewport *viewport,
00331 vtkTextMapper **textMappers,
00332 int nbOfMappers,
00333 int *targetSize,
00334 float factor,
00335 int *stringSize);
00337
00339 void ShallowCopy(vtkProp *prop);
00340
00341 protected:
00342 vtkAxisActor2D();
00343 ~vtkAxisActor2D();
00344
00345 vtkTextProperty *TitleTextProperty;
00346 vtkTextProperty *LabelTextProperty;
00347
00348 char *Title;
00349 float Range[2];
00350 int NumberOfLabels;
00351 char *LabelFormat;
00352 int AdjustLabels;
00353 float FontFactor;
00354 float LabelFactor;
00355 int TickLength;
00356 int TickOffset;
00357
00358 float AdjustedRange[2];
00359 int AdjustedNumberOfLabels;
00360 int NumberOfLabelsBuilt;
00361
00362 int AxisVisibility;
00363 int TickVisibility;
00364 int LabelVisibility;
00365 int TitleVisibility;
00366
00367 int LastPosition[2];
00368 int LastPosition2[2];
00369
00370 int LastSize[2];
00371 int LastMaxLabelSize[2];
00372
00373 virtual void BuildAxis(vtkViewport *viewport);
00374 static float ComputeStringOffset(float width, float height, float theta);
00375 static void SetOffsetPosition(float xTick[3], float theta, int stringHeight,
00376 int stringWidth, int offset, vtkActor2D *actor);
00377 virtual void UpdateAdjustedRange();
00378
00379 vtkTextMapper *TitleMapper;
00380 vtkActor2D *TitleActor;
00381
00382 vtkTextMapper **LabelMappers;
00383 vtkActor2D **LabelActors;
00384
00385 vtkPolyData *Axis;
00386 vtkPolyDataMapper2D *AxisMapper;
00387 vtkActor2D *AxisActor;
00388
00389 vtkTimeStamp AdjustedRangeBuildTime;
00390 vtkTimeStamp BuildTime;
00391
00392 private:
00393 vtkAxisActor2D(const vtkAxisActor2D&);
00394 void operator=(const vtkAxisActor2D&);
00395 };
00396
00397
00398 #endif