00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00048 #ifndef __vtkAxisActor_h
00049 #define __vtkAxisActor_h
00050
00051 #include "vtkActor.h"
00052
00053 #define VTK_MAX_LABELS 200
00054 #define VTK_MAX_TICKS 1000
00055
00056 #define VTK_AXIS_TYPE_X 0
00057 #define VTK_AXIS_TYPE_Y 1
00058 #define VTK_AXIS_TYPE_Z 2
00059
00060 #define VTK_TICKS_INSIDE 0
00061 #define VTK_TICKS_OUTSIDE 1
00062 #define VTK_TICKS_BOTH 2
00063
00064 #define VTK_AXIS_POS_MINMIN 0
00065 #define VTK_AXIS_POS_MINMAX 1
00066 #define VTK_AXIS_POS_MAXMAX 2
00067 #define VTK_AXIS_POS_MAXMIN 3
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 class vtkCamera;
00079 class vtkCoordinate;
00080 class vtkFollower;
00081 class vtkPoints;
00082 class vtkPolyData;
00083 class vtkPolyDataMapper;
00084 class vtkStringArray;
00085 class vtkVectorText;
00086
00087 class VTK_HYBRID_EXPORT vtkAxisActor : public vtkActor
00088 {
00089 public:
00090 vtkTypeMacro(vtkAxisActor,vtkActor);
00091 void PrintSelf(ostream& os, vtkIndent indent);
00092
00094 static vtkAxisActor *New();
00095
00097
00098 virtual vtkCoordinate *GetPoint1Coordinate();
00099 virtual void SetPoint1(double x[3])
00100 { this->SetPoint1(x[0], x[1], x[2]); }
00101 virtual void SetPoint1(double x, double y, double z);
00102 virtual double *GetPoint1();
00104
00106
00107 virtual vtkCoordinate *GetPoint2Coordinate();
00108 virtual void SetPoint2(double x[3])
00109 { this->SetPoint2(x[0], x[1], x[2]); }
00110 virtual void SetPoint2(double x, double y, double z);
00111 virtual double *GetPoint2();
00113
00115
00117 vtkSetVector2Macro(Range,double);
00118 vtkGetVectorMacro(Range,double,2);
00120
00122
00124 void SetBounds(double bounds[6]);
00125 double *GetBounds(void);
00126 void GetBounds(double bounds[6]);
00128
00130
00131 vtkSetStringMacro(LabelFormat);
00132 vtkGetStringMacro(LabelFormat);
00134
00136
00137 vtkSetMacro(MinorTicksVisible, int);
00138 vtkGetMacro(MinorTicksVisible, int);
00139 vtkBooleanMacro(MinorTicksVisible, int);
00141
00142
00144
00145 void SetTitle(const char *t);
00146 vtkGetStringMacro(Title);
00148
00150
00151 vtkSetMacro(MajorTickSize, double);
00152 vtkGetMacro(MajorTickSize, double);
00154
00156
00157 vtkSetMacro(MinorTickSize, double);
00158 vtkGetMacro(MinorTickSize, double);
00160
00162
00163 vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
00164 vtkGetMacro(TickLocation, int);
00166
00167 void SetTickLocationToInside(void)
00168 { this->SetTickLocation(VTK_TICKS_INSIDE); };
00169 void SetTickLocationToOutside(void)
00170 { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
00171 void SetTickLocationToBoth(void)
00172 { this->SetTickLocation(VTK_TICKS_BOTH); };
00173
00175
00176 vtkSetMacro(AxisVisibility, int);
00177 vtkGetMacro(AxisVisibility, int);
00178 vtkBooleanMacro(AxisVisibility, int);
00180
00182
00183 vtkSetMacro(TickVisibility, int);
00184 vtkGetMacro(TickVisibility, int);
00185 vtkBooleanMacro(TickVisibility, int);
00187
00189
00190 vtkSetMacro(LabelVisibility, int);
00191 vtkGetMacro(LabelVisibility, int);
00192 vtkBooleanMacro(LabelVisibility, int);
00194
00196
00197 vtkSetMacro(TitleVisibility, int);
00198 vtkGetMacro(TitleVisibility, int);
00199 vtkBooleanMacro(TitleVisibility, int);
00201
00203
00204 vtkSetMacro(DrawGridlines, int);
00205 vtkGetMacro(DrawGridlines, int);
00206 vtkBooleanMacro(DrawGridlines, int);
00208
00210
00211 vtkSetMacro(GridlineXLength, double);
00212 vtkGetMacro(GridlineXLength, double);
00213 vtkSetMacro(GridlineYLength, double);
00214 vtkGetMacro(GridlineYLength, double);
00215 vtkSetMacro(GridlineZLength, double);
00216 vtkGetMacro(GridlineZLength, double);
00218
00220
00221 vtkSetClampMacro(AxisType, int, VTK_AXIS_TYPE_X, VTK_AXIS_TYPE_Z);
00222 vtkGetMacro(AxisType, int);
00223 void SetAxisTypeToX(void) { this->SetAxisType(VTK_AXIS_TYPE_X); };
00224 void SetAxisTypeToY(void) { this->SetAxisType(VTK_AXIS_TYPE_Y); };
00225 void SetAxisTypeToZ(void) { this->SetAxisType(VTK_AXIS_TYPE_Z); };
00227
00229
00234 vtkSetClampMacro(AxisPosition, int, VTK_AXIS_POS_MINMIN, VTK_AXIS_POS_MAXMIN);
00235 vtkGetMacro(AxisPosition, int);
00237
00238 void SetAxisPositionToMinMin(void)
00239 { this->SetAxisPosition(VTK_AXIS_POS_MINMIN); };
00240 void SetAxisPositionToMinMax(void)
00241 { this->SetAxisPosition(VTK_AXIS_POS_MINMAX); };
00242 void SetAxisPositionToMaxMax(void)
00243 { this->SetAxisPosition(VTK_AXIS_POS_MAXMAX); };
00244 void SetAxisPositionToMaxMin(void)
00245 { this->SetAxisPosition(VTK_AXIS_POS_MAXMIN); };
00246
00248
00250 virtual void SetCamera(vtkCamera*);
00251 vtkGetObjectMacro(Camera, vtkCamera);
00253
00255
00256 virtual int RenderOpaqueGeometry(vtkViewport* viewport);
00257 virtual int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00259
00263 void ReleaseGraphicsResources(vtkWindow *);
00264
00266 void ShallowCopy(vtkProp *prop);
00267
00268
00269 double ComputeMaxLabelLength(const double [3]);
00270 double ComputeTitleLength(const double [3]);
00271
00272 void SetLabelScale(const double);
00273 void SetTitleScale(const double);
00274
00275
00277
00279 vtkSetMacro(MinorStart, double);
00280 vtkGetMacro(MinorStart, double);
00281 vtkSetMacro(MajorStart, double);
00282 vtkGetMacro(MajorStart, double);
00283 vtkSetMacro(DeltaMinor, double);
00284 vtkGetMacro(DeltaMinor, double);
00285 vtkSetMacro(DeltaMajor, double);
00286 vtkGetMacro(DeltaMajor, double);
00288
00289
00290 void SetLabels(vtkStringArray *labels);
00291
00292
00293 void BuildAxis(vtkViewport *viewport, bool);
00294
00295 protected:
00296 vtkAxisActor();
00297 ~vtkAxisActor();
00298
00299 char *Title;
00300 double Range[2];
00301 double LastRange[2];
00302 char *LabelFormat;
00303 int NumberOfLabelsBuilt;
00304 int MinorTicksVisible;
00305 int LastMinorTicksVisible;
00306 int TickLocation;
00307
00308 int DrawGridlines;
00309 int LastDrawGridlines;
00310 double GridlineXLength;
00311 double GridlineYLength;
00312 double GridlineZLength;
00313
00314 int AxisVisibility;
00315 int TickVisibility;
00316 int LastTickVisibility;
00317 int LabelVisibility;
00318 int TitleVisibility;
00319
00320 int AxisType;
00321 int AxisPosition;
00322 double Bounds[6];
00323
00324 private:
00325 vtkAxisActor(const vtkAxisActor&);
00326 void operator=(const vtkAxisActor&);
00327
00328 void TransformBounds(vtkViewport *, double bnds[6]);
00329
00330 void BuildLabels(vtkViewport *, bool);
00331 void SetLabelPositions(vtkViewport *, bool);
00332
00333 void BuildTitle(bool);
00334
00335 void SetAxisPointsAndLines(void);
00336 bool BuildTickPointsForXType(double p1[3], double p2[3], bool);
00337 bool BuildTickPointsForYType(double p1[3], double p2[3], bool);
00338 bool BuildTickPointsForZType(double p1[3], double p2[3], bool);
00339
00340 bool TickVisibilityChanged(void);
00341
00342 vtkCoordinate *Point1Coordinate;
00343 vtkCoordinate *Point2Coordinate;
00344
00345 double MajorTickSize;
00346 double MinorTickSize;
00347
00348 double MajorStart;
00349 double MinorStart;
00350
00351 double DeltaMinor;
00352 double DeltaMajor;
00353
00354 int LastAxisPosition;
00355 int LastAxisType;
00356 int LastTickLocation;
00357 double LastLabelStart;
00358
00359 vtkPoints *MinorTickPts;
00360 vtkPoints *MajorTickPts;
00361 vtkPoints *GridlinePts;
00362
00363 vtkVectorText *TitleVector;
00364 vtkPolyDataMapper *TitleMapper;
00365 vtkFollower *TitleActor;
00366
00367 vtkVectorText **LabelVectors;
00368 vtkPolyDataMapper **LabelMappers;
00369 vtkFollower **LabelActors;
00370
00371 vtkPolyData *Axis;
00372 vtkPolyDataMapper *AxisMapper;
00373 vtkActor *AxisActor;
00374
00375 vtkCamera *Camera;
00376 vtkTimeStamp BuildTime;
00377 vtkTimeStamp BoundsTime;
00378 vtkTimeStamp LabelBuildTime;
00379 vtkTimeStamp TitleTextTime;
00380
00381 int AxisHasZeroLength;
00382 };
00383
00384
00385 #endif