VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkAxisActor.h 00005 Language: C++ 00006 00007 Copyright (c) 1993-2000 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 =========================================================================*/ 00056 #ifndef __vtkAxisActor_h 00057 #define __vtkAxisActor_h 00058 00059 #include "vtkRenderingAnnotationModule.h" // For export macro 00060 #include "vtkActor.h" 00061 00062 #define VTK_MAX_LABELS 200 00063 #define VTK_MAX_TICKS 1000 00064 00065 #define VTK_AXIS_TYPE_X 0 00066 #define VTK_AXIS_TYPE_Y 1 00067 #define VTK_AXIS_TYPE_Z 2 00068 00069 #define VTK_TICKS_INSIDE 0 00070 #define VTK_TICKS_OUTSIDE 1 00071 #define VTK_TICKS_BOTH 2 00072 00073 #define VTK_AXIS_POS_MINMIN 0 00074 #define VTK_AXIS_POS_MINMAX 1 00075 #define VTK_AXIS_POS_MAXMAX 2 00076 #define VTK_AXIS_POS_MAXMIN 3 00077 00078 class vtkAxisFollower; 00079 class vtkCamera; 00080 class vtkCoordinate; 00081 class vtkFollower; 00082 class vtkPoints; 00083 class vtkPolyData; 00084 class vtkPolyDataMapper; 00085 class vtkProp3DAxisFollower; 00086 class vtkProperty2D; 00087 class vtkStringArray; 00088 class vtkTextActor; 00089 class vtkTextActor3D; 00090 class vtkTextProperty; 00091 class vtkVectorText; 00092 00093 class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor : public vtkActor 00094 { 00095 public: 00096 vtkTypeMacro(vtkAxisActor,vtkActor); 00097 void PrintSelf(ostream& os, vtkIndent indent); 00098 00100 static vtkAxisActor *New(); 00101 00103 00104 virtual vtkCoordinate *GetPoint1Coordinate(); 00105 virtual void SetPoint1(double x[3]) 00106 { this->SetPoint1(x[0], x[1], x[2]); } 00107 virtual void SetPoint1(double x, double y, double z); 00108 virtual double *GetPoint1(); 00110 00112 00113 virtual vtkCoordinate *GetPoint2Coordinate(); 00114 virtual void SetPoint2(double x[3]) 00115 { this->SetPoint2(x[0], x[1], x[2]); } 00116 virtual void SetPoint2(double x, double y, double z); 00117 virtual double *GetPoint2(); 00119 00121 00123 vtkSetVector2Macro(Range,double); 00124 vtkGetVectorMacro(Range,double,2); 00126 00128 00130 void SetBounds(const double bounds[6]); 00131 void SetBounds(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); 00132 double *GetBounds(void); 00133 void GetBounds(double bounds[6]); 00135 00137 00138 vtkSetStringMacro(LabelFormat); 00139 vtkGetStringMacro(LabelFormat); 00141 00143 00147 vtkSetMacro(UseTextActor3D, int); 00148 vtkGetMacro(UseTextActor3D, int); 00150 00152 00153 vtkSetMacro(MinorTicksVisible, int); 00154 vtkGetMacro(MinorTicksVisible, int); 00155 vtkBooleanMacro(MinorTicksVisible, int); 00157 00159 00160 void SetTitle(const char *t); 00161 vtkGetStringMacro(Title); 00163 00165 00166 vtkSetMacro(MajorTickSize, double); 00167 vtkGetMacro(MajorTickSize, double); 00169 00171 00172 vtkSetMacro(MinorTickSize, double); 00173 vtkGetMacro(MinorTickSize, double); 00175 00177 00178 vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH); 00179 vtkGetMacro(TickLocation, int); 00181 00182 void SetTickLocationToInside(void) 00183 { this->SetTickLocation(VTK_TICKS_INSIDE); }; 00184 void SetTickLocationToOutside(void) 00185 { this->SetTickLocation(VTK_TICKS_OUTSIDE); }; 00186 void SetTickLocationToBoth(void) 00187 { this->SetTickLocation(VTK_TICKS_BOTH); }; 00188 00190 00191 vtkSetMacro(AxisVisibility, int); 00192 vtkGetMacro(AxisVisibility, int); 00193 vtkBooleanMacro(AxisVisibility, int); 00195 00197 00198 vtkSetMacro(TickVisibility, int); 00199 vtkGetMacro(TickVisibility, int); 00200 vtkBooleanMacro(TickVisibility, int); 00202 00204 00205 vtkSetMacro(LabelVisibility, int); 00206 vtkGetMacro(LabelVisibility, int); 00207 vtkBooleanMacro(LabelVisibility, int); 00209 00211 00212 vtkSetMacro(TitleVisibility, int); 00213 vtkGetMacro(TitleVisibility, int); 00214 vtkBooleanMacro(TitleVisibility, int); 00216 00218 00219 virtual void SetTitleTextProperty(vtkTextProperty *p); 00220 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); 00222 00224 00225 virtual void SetLabelTextProperty(vtkTextProperty *p); 00226 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); 00228 00230 00231 void SetAxisLinesProperty(vtkProperty *); 00232 vtkProperty* GetAxisLinesProperty(); 00234 00236 00237 void SetGridlinesProperty(vtkProperty *); 00238 vtkProperty* GetGridlinesProperty(); 00240 00242 00243 void SetInnerGridlinesProperty(vtkProperty *); 00244 vtkProperty* GetInnerGridlinesProperty(); 00246 00248 00249 void SetGridpolysProperty(vtkProperty *); 00250 vtkProperty* GetGridpolysProperty(); 00252 00254 00255 vtkSetMacro(DrawGridlines, int); 00256 vtkGetMacro(DrawGridlines, int); 00257 vtkBooleanMacro(DrawGridlines, int); 00259 00261 00264 vtkSetMacro(DrawGridlinesOnly, int); 00265 vtkGetMacro(DrawGridlinesOnly, int); 00266 vtkBooleanMacro(DrawGridlinesOnly, int); 00268 00269 vtkSetMacro(DrawGridlinesLocation, int); 00270 vtkGetMacro(DrawGridlinesLocation, int); 00271 00273 00274 vtkSetMacro(DrawInnerGridlines, int); 00275 vtkGetMacro(DrawInnerGridlines, int); 00276 vtkBooleanMacro(DrawInnerGridlines, int); 00278 00280 00281 vtkSetMacro(GridlineXLength, double); 00282 vtkGetMacro(GridlineXLength, double); 00283 vtkSetMacro(GridlineYLength, double); 00284 vtkGetMacro(GridlineYLength, double); 00285 vtkSetMacro(GridlineZLength, double); 00286 vtkGetMacro(GridlineZLength, double); 00288 00290 00291 vtkSetMacro(DrawGridpolys, int); 00292 vtkGetMacro(DrawGridpolys, int); 00293 vtkBooleanMacro(DrawGridpolys, int); 00295 00297 00298 vtkSetClampMacro(AxisType, int, VTK_AXIS_TYPE_X, VTK_AXIS_TYPE_Z); 00299 vtkGetMacro(AxisType, int); 00300 void SetAxisTypeToX(void) { this->SetAxisType(VTK_AXIS_TYPE_X); }; 00301 void SetAxisTypeToY(void) { this->SetAxisType(VTK_AXIS_TYPE_Y); }; 00302 void SetAxisTypeToZ(void) { this->SetAxisType(VTK_AXIS_TYPE_Z); }; 00304 00306 00311 vtkSetClampMacro(AxisPosition, int, VTK_AXIS_POS_MINMIN, VTK_AXIS_POS_MAXMIN); 00312 vtkGetMacro(AxisPosition, int); 00314 00315 void SetAxisPositionToMinMin(void) 00316 { this->SetAxisPosition(VTK_AXIS_POS_MINMIN); }; 00317 void SetAxisPositionToMinMax(void) 00318 { this->SetAxisPosition(VTK_AXIS_POS_MINMAX); }; 00319 void SetAxisPositionToMaxMax(void) 00320 { this->SetAxisPosition(VTK_AXIS_POS_MAXMAX); }; 00321 void SetAxisPositionToMaxMin(void) 00322 { this->SetAxisPosition(VTK_AXIS_POS_MAXMIN); }; 00323 00325 00327 virtual void SetCamera(vtkCamera*); 00328 vtkGetObjectMacro(Camera, vtkCamera); 00330 00332 00333 virtual int RenderOpaqueGeometry(vtkViewport* viewport); 00334 virtual int RenderTranslucentGeometry(vtkViewport* viewport); 00335 virtual int RenderTranslucentPolygonalGeometry(vtkViewport* viewport); 00336 virtual int RenderOverlay(vtkViewport* viewport); 00337 int HasTranslucentPolygonalGeometry(); 00339 00343 void ReleaseGraphicsResources(vtkWindow *); 00344 00345 //BTX 00346 double ComputeMaxLabelLength(const double [3]); 00347 double ComputeTitleLength(const double [3]); 00348 //ETX 00349 void SetLabelScale(const double scale); 00350 void SetLabelScale(int labelIndex, const double scale); 00351 void SetTitleScale(const double scale); 00352 00354 00356 vtkSetMacro(MinorStart, double); 00357 vtkGetMacro(MinorStart, double); 00358 double GetMajorStart(int axis); 00359 void SetMajorStart(int axis,double value); 00360 //vtkSetMacro(MajorStart, double); 00361 //vtkGetMacro(MajorStart, double); 00362 vtkSetMacro(DeltaMinor, double); 00363 vtkGetMacro(DeltaMinor, double); 00364 double GetDeltaMajor(int axis); 00365 void SetDeltaMajor(int axis,double value); 00366 //vtkSetMacro(DeltaMajor, double); 00367 //vtkGetMacro(DeltaMajor, double); 00369 00371 00375 vtkSetMacro(MinorRangeStart, double); 00376 vtkGetMacro(MinorRangeStart, double); 00377 vtkSetMacro(MajorRangeStart, double); 00378 vtkGetMacro(MajorRangeStart, double); 00379 vtkSetMacro(DeltaRangeMinor, double); 00380 vtkGetMacro(DeltaRangeMinor, double); 00381 vtkSetMacro(DeltaRangeMajor, double); 00382 vtkGetMacro(DeltaRangeMajor, double); 00384 00385 //BTX 00386 void SetLabels(vtkStringArray *labels); 00387 //ETX 00388 00389 void BuildAxis(vtkViewport *viewport, bool); 00390 00391 //BTX 00393 00394 vtkGetObjectMacro(TitleActor, vtkAxisFollower); 00396 00398 00399 inline vtkAxisFollower** GetLabelActors() 00400 { 00401 return this->LabelActors; 00402 } 00404 00406 00407 vtkGetObjectMacro(TitleProp3D, vtkProp3DAxisFollower); 00409 00411 00412 inline vtkProp3DAxisFollower** GetLabelProps3D() 00413 { 00414 return this->LabelProps3D; 00415 } 00416 //ETX 00418 00420 00422 vtkGetMacro(NumberOfLabelsBuilt, int); 00424 00426 00427 vtkSetMacro(CalculateTitleOffset, int); 00428 vtkGetMacro(CalculateTitleOffset, int); 00429 vtkBooleanMacro(CalculateTitleOffset, int); 00431 00433 00434 vtkSetMacro(CalculateLabelOffset, int); 00435 vtkGetMacro(CalculateLabelOffset, int); 00436 vtkBooleanMacro(CalculateLabelOffset, int); 00438 00440 00441 vtkSetMacro(Use2DMode, int); 00442 vtkGetMacro(Use2DMode, int); 00444 00446 00447 vtkSetMacro(VerticalOffsetXTitle2D, double); 00448 vtkGetMacro(VerticalOffsetXTitle2D, double); 00450 00452 00453 vtkSetMacro(HorizontalOffsetYTitle2D, double); 00454 vtkGetMacro(HorizontalOffsetYTitle2D, double); 00456 00458 00459 vtkSetMacro(SaveTitlePosition, int); 00460 vtkGetMacro(SaveTitlePosition, int); 00462 00464 00465 vtkSetVector3Macro(AxisBaseForX, double); 00466 vtkGetVector3Macro(AxisBaseForX, double); 00468 00470 00471 vtkSetVector3Macro(AxisBaseForY, double); 00472 vtkGetVector3Macro(AxisBaseForY, double); 00474 00476 00477 vtkSetVector3Macro(AxisBaseForZ, double); 00478 vtkGetVector3Macro(AxisBaseForZ, double); 00480 00482 00483 vtkSetMacro(AxisOnOrigin,int); 00484 vtkGetMacro(AxisOnOrigin,int); 00486 00488 00489 vtkSetMacro(LabelOffset, double); 00490 vtkGetMacro(LabelOffset, double); 00491 vtkSetMacro(TitleOffset, double); 00492 vtkGetMacro(TitleOffset, double); 00493 vtkSetMacro(ScreenSize, double); 00494 vtkGetMacro(ScreenSize, double); 00496 00497 protected: 00498 vtkAxisActor(); 00499 ~vtkAxisActor(); 00500 00501 char *Title; 00502 double Range[2]; 00503 double LastRange[2]; 00504 char *LabelFormat; 00505 int UseTextActor3D; 00506 int NumberOfLabelsBuilt; 00507 int MinorTicksVisible; 00508 int LastMinorTicksVisible; 00509 int TickLocation; 00510 00511 int DrawGridlines; 00512 int DrawGridlinesOnly; 00513 int LastDrawGridlines; 00514 int DrawGridlinesLocation; // 0: all | 1: closest | 2: farest 00515 int LastDrawGridlinesLocation; // 0: all | 1: closest | 2: farest 00516 double GridlineXLength; 00517 double GridlineYLength; 00518 double GridlineZLength; 00519 00520 int DrawInnerGridlines; 00521 int LastDrawInnerGridlines; 00522 00523 int DrawGridpolys; 00524 int LastDrawGridpolys; 00525 00526 int AxisVisibility; 00527 int TickVisibility; 00528 int LastTickVisibility; 00529 int LabelVisibility; 00530 int TitleVisibility; 00531 00532 int AxisType; 00533 int AxisPosition; 00534 double Bounds[6]; 00535 00536 double AxisBaseForX[3]; 00537 double AxisBaseForY[3]; 00538 double AxisBaseForZ[3]; 00539 00540 private: 00541 vtkAxisActor(const vtkAxisActor&); // Not implemented 00542 void operator=(const vtkAxisActor&); // Not implemented 00543 00544 void TransformBounds(vtkViewport *, double bnds[6]); 00545 00546 void BuildLabels(vtkViewport *, bool); 00547 void BuildLabels2D(vtkViewport *, bool); 00548 void SetLabelPositions(vtkViewport *, bool); 00549 void SetLabelPositions2D(vtkViewport *, bool); 00550 00551 void BuildTitle(bool); 00552 void BuildTitle2D(vtkViewport *viewport, bool); 00553 00554 void SetAxisPointsAndLines(void); 00555 bool BuildTickPoints(double p1[3], double p2[3], bool force); 00556 00557 bool TickVisibilityChanged(void); 00558 vtkProperty *NewTitleProperty(); 00559 vtkProperty2D *NewTitleProperty2D(); 00560 vtkProperty *NewLabelProperty(); 00561 00562 bool BoundsDisplayCoordinateChanged(vtkViewport *viewport); 00563 00564 vtkCoordinate *Point1Coordinate; 00565 vtkCoordinate *Point2Coordinate; 00566 00567 double MajorTickSize; 00568 double MinorTickSize; 00569 00570 // For each axis (for the inner gridline generation) 00571 double MajorStart[3]; 00572 double DeltaMajor[3]; 00573 double MinorStart; 00574 double DeltaMinor; 00575 00576 // For the ticks, w.r.t to the set range 00577 double MajorRangeStart; 00578 double MinorRangeStart; 00579 double DeltaRangeMinor; 00580 double DeltaRangeMajor; 00581 00582 int LastAxisPosition; 00583 int LastAxisType; 00584 int LastTickLocation; 00585 double LastLabelStart; 00586 00587 vtkPoints *MinorTickPts; 00588 vtkPoints *MajorTickPts; 00589 vtkPoints *GridlinePts; 00590 vtkPoints *InnerGridlinePts; 00591 vtkPoints *GridpolyPts; 00592 00593 vtkVectorText *TitleVector; 00594 vtkPolyDataMapper *TitleMapper; 00595 vtkAxisFollower *TitleActor; 00596 vtkTextActor *TitleActor2D; 00597 vtkProp3DAxisFollower *TitleProp3D; 00598 vtkTextActor3D *TitleActor3D; 00599 vtkTextProperty *TitleTextProperty; 00600 00601 vtkVectorText **LabelVectors; 00602 vtkPolyDataMapper **LabelMappers; 00603 vtkAxisFollower **LabelActors; 00604 vtkProp3DAxisFollower **LabelProps3D; 00605 vtkTextActor **LabelActors2D; 00606 vtkTextActor3D **LabelActors3D; 00607 vtkTextProperty *LabelTextProperty; 00608 00609 vtkPolyData *AxisLines; 00610 vtkPolyDataMapper *AxisLinesMapper; 00611 vtkActor *AxisLinesActor; 00612 vtkPolyData *Gridlines; 00613 vtkPolyDataMapper *GridlinesMapper; 00614 vtkActor *GridlinesActor; 00615 vtkPolyData *InnerGridlines; 00616 vtkPolyDataMapper *InnerGridlinesMapper; 00617 vtkActor *InnerGridlinesActor; 00618 vtkPolyData *Gridpolys; 00619 vtkPolyDataMapper *GridpolysMapper; 00620 vtkActor *GridpolysActor; 00621 00622 vtkCamera *Camera; 00623 vtkTimeStamp BuildTime; 00624 vtkTimeStamp BuildTickPointsTime; 00625 vtkTimeStamp BoundsTime; 00626 vtkTimeStamp LabelBuildTime; 00627 vtkTimeStamp TitleTextTime; 00628 00629 int AxisOnOrigin; 00630 00631 int AxisHasZeroLength; 00632 00633 int CalculateTitleOffset; 00634 int CalculateLabelOffset; 00635 00637 int Use2DMode; 00638 00641 double VerticalOffsetXTitle2D; 00642 00645 double HorizontalOffsetYTitle2D; 00646 00651 int SaveTitlePosition; 00652 00654 double TitleConstantPosition[2]; 00655 00657 bool NeedBuild2D; 00658 00659 double LastMinDisplayCoordinate[3]; 00660 double LastMaxDisplayCoordinate[3]; 00661 00663 00664 double ScreenSize; 00665 double LabelOffset; 00666 double TitleOffset; 00667 }; 00669 00670 #endif