VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkCubeAxesActor.h 00005 Language: C++ 00006 00007 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserve 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 =========================================================================*/ 00061 #ifndef __vtkCubeAxesActor_h 00062 #define __vtkCubeAxesActor_h 00063 00064 #define VTK_FLY_OUTER_EDGES 0 00065 #define VTK_FLY_CLOSEST_TRIAD 1 00066 #define VTK_FLY_FURTHEST_TRIAD 2 00067 #define VTK_FLY_STATIC_TRIAD 3 00068 #define VTK_FLY_STATIC_EDGES 4 00069 00070 #define VTK_TICKS_INSIDE 0 00071 #define VTK_TICKS_OUTSIDE 1 00072 #define VTK_TICKS_BOTH 2 00073 00074 #define VTK_GRID_LINES_ALL 0 00075 #define VTK_GRID_LINES_CLOSEST 1 00076 #define VTK_GRID_LINES_FURTHEST 2 00077 00078 #define NUMBER_OF_ALIGNED_AXIS 4 00079 00080 #include "vtkRenderingAnnotationModule.h" // For export macro 00081 #include "vtkActor.h" 00082 00083 class vtkAxisActor; 00084 class vtkCamera; 00085 class vtkTextProperty; 00086 class vtkStringArray; 00087 00088 class VTKRENDERINGANNOTATION_EXPORT vtkCubeAxesActor : public vtkActor 00089 { 00090 public: 00091 vtkTypeMacro(vtkCubeAxesActor,vtkActor); 00092 void PrintSelf(ostream& os, vtkIndent indent); 00093 00096 static vtkCubeAxesActor *New(); 00097 00099 00100 virtual int RenderOpaqueGeometry(vtkViewport*); 00101 virtual int RenderTranslucentGeometry(vtkViewport*); 00102 virtual int RenderTranslucentPolygonalGeometry(vtkViewport*); 00103 virtual int RenderOverlay(vtkViewport*); 00104 int HasTranslucentPolygonalGeometry(); 00106 00108 00109 vtkSetMacro( RebuildAxes, bool ); 00110 vtkGetMacro( RebuildAxes, bool ); 00112 00114 00118 vtkSetVector6Macro(Bounds,double); 00119 vtkGetVector6Macro(Bounds,double); 00121 00123 00125 virtual void GetRenderedBounds(double rBounds[6]); 00126 virtual double* GetRenderedBounds(); 00128 00130 00137 vtkSetVector2Macro( XAxisRange, double ); 00138 vtkSetVector2Macro( YAxisRange, double ); 00139 vtkSetVector2Macro( ZAxisRange, double ); 00140 vtkGetVector2Macro( XAxisRange, double ); 00141 vtkGetVector2Macro( YAxisRange, double ); 00143 00144 00146 vtkStringArray* GetAxisLabels(int axis); 00147 void SetAxisLabels(int axis, vtkStringArray* value); 00149 00150 vtkGetVector2Macro( ZAxisRange, double ); 00151 00153 00156 void SetScreenSize(double screenSize); 00157 vtkGetMacro(ScreenSize, double); 00159 00161 00163 void SetLabelOffset(double offset); 00164 vtkGetMacro(LabelOffset, double); 00166 00168 00170 void SetTitleOffset(double offset); 00171 vtkGetMacro(TitleOffset, double); 00173 00175 00177 virtual void SetCamera(vtkCamera*); 00178 vtkGetObjectMacro(Camera,vtkCamera); 00180 00182 00185 vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES); 00186 vtkGetMacro(FlyMode, int); 00187 void SetFlyModeToOuterEdges() 00188 {this->SetFlyMode(VTK_FLY_OUTER_EDGES);}; 00189 void SetFlyModeToClosestTriad() 00190 {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);}; 00191 void SetFlyModeToFurthestTriad() 00192 {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);}; 00193 void SetFlyModeToStaticTriad() 00194 {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);}; 00195 void SetFlyModeToStaticEdges() 00196 {this->SetFlyMode(VTK_FLY_STATIC_EDGES);}; 00198 00200 00202 vtkSetStringMacro(XTitle); 00203 vtkGetStringMacro(XTitle); 00204 vtkSetStringMacro(XUnits); 00205 vtkGetStringMacro(XUnits); 00206 vtkSetStringMacro(YTitle); 00207 vtkGetStringMacro(YTitle); 00208 vtkSetStringMacro(YUnits); 00209 vtkGetStringMacro(YUnits); 00210 vtkSetStringMacro(ZTitle); 00211 vtkGetStringMacro(ZTitle); 00212 vtkSetStringMacro(ZUnits); 00213 vtkGetStringMacro(ZUnits); 00215 00217 00219 vtkSetStringMacro(XLabelFormat); 00220 vtkGetStringMacro(XLabelFormat); 00221 vtkSetStringMacro(YLabelFormat); 00222 vtkGetStringMacro(YLabelFormat); 00223 vtkSetStringMacro(ZLabelFormat); 00224 vtkGetStringMacro(ZLabelFormat); 00226 00228 00231 vtkSetClampMacro(Inertia, int, 1, VTK_INT_MAX); 00232 vtkGetMacro(Inertia, int); 00234 00236 00239 vtkSetMacro(CornerOffset, double); 00240 vtkGetMacro(CornerOffset, double); 00242 00246 void ReleaseGraphicsResources(vtkWindow *); 00247 00249 00251 vtkSetMacro( EnableDistanceLOD, int ); 00252 vtkGetMacro( EnableDistanceLOD, int ); 00254 00256 00257 vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 ); 00258 vtkGetMacro( DistanceLODThreshold, double); 00260 00262 00264 vtkSetMacro( EnableViewAngleLOD, int ); 00265 vtkGetMacro( EnableViewAngleLOD, int ); 00267 00269 00270 vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. ); 00271 vtkGetMacro( ViewAngleLODThreshold, double ); 00273 00275 00276 vtkSetMacro(XAxisVisibility,int); 00277 vtkGetMacro(XAxisVisibility,int); 00278 vtkBooleanMacro(XAxisVisibility,int); 00279 vtkSetMacro(YAxisVisibility,int); 00280 vtkGetMacro(YAxisVisibility,int); 00281 vtkBooleanMacro(YAxisVisibility,int); 00282 vtkSetMacro(ZAxisVisibility,int); 00283 vtkGetMacro(ZAxisVisibility,int); 00284 vtkBooleanMacro(ZAxisVisibility,int); 00286 00288 00289 vtkSetMacro(XAxisLabelVisibility,int); 00290 vtkGetMacro(XAxisLabelVisibility,int); 00291 vtkBooleanMacro(XAxisLabelVisibility,int); 00293 00294 vtkSetMacro(YAxisLabelVisibility,int); 00295 vtkGetMacro(YAxisLabelVisibility,int); 00296 vtkBooleanMacro(YAxisLabelVisibility,int); 00297 00298 vtkSetMacro(ZAxisLabelVisibility,int); 00299 vtkGetMacro(ZAxisLabelVisibility,int); 00300 vtkBooleanMacro(ZAxisLabelVisibility,int); 00301 00303 00304 vtkSetMacro(XAxisTickVisibility,int); 00305 vtkGetMacro(XAxisTickVisibility,int); 00306 vtkBooleanMacro(XAxisTickVisibility,int); 00308 00309 vtkSetMacro(YAxisTickVisibility,int); 00310 vtkGetMacro(YAxisTickVisibility,int); 00311 vtkBooleanMacro(YAxisTickVisibility,int); 00312 00313 vtkSetMacro(ZAxisTickVisibility,int); 00314 vtkGetMacro(ZAxisTickVisibility,int); 00315 vtkBooleanMacro(ZAxisTickVisibility,int); 00316 00318 00319 vtkSetMacro(XAxisMinorTickVisibility,int); 00320 vtkGetMacro(XAxisMinorTickVisibility,int); 00321 vtkBooleanMacro(XAxisMinorTickVisibility,int); 00323 00324 vtkSetMacro(YAxisMinorTickVisibility,int); 00325 vtkGetMacro(YAxisMinorTickVisibility,int); 00326 vtkBooleanMacro(YAxisMinorTickVisibility,int); 00327 00328 vtkSetMacro(ZAxisMinorTickVisibility,int); 00329 vtkGetMacro(ZAxisMinorTickVisibility,int); 00330 vtkBooleanMacro(ZAxisMinorTickVisibility,int); 00331 00332 vtkSetMacro(DrawXGridlines,int); 00333 vtkGetMacro(DrawXGridlines,int); 00334 vtkBooleanMacro(DrawXGridlines,int); 00335 00336 vtkSetMacro(DrawYGridlines,int); 00337 vtkGetMacro(DrawYGridlines,int); 00338 vtkBooleanMacro(DrawYGridlines,int); 00339 00340 vtkSetMacro(DrawZGridlines,int); 00341 vtkGetMacro(DrawZGridlines,int); 00342 vtkBooleanMacro(DrawZGridlines,int); 00343 00344 vtkSetMacro(DrawXInnerGridlines,int); 00345 vtkGetMacro(DrawXInnerGridlines,int); 00346 vtkBooleanMacro(DrawXInnerGridlines,int); 00347 00348 vtkSetMacro(DrawYInnerGridlines,int); 00349 vtkGetMacro(DrawYInnerGridlines,int); 00350 vtkBooleanMacro(DrawYInnerGridlines,int); 00351 00352 vtkSetMacro(DrawZInnerGridlines,int); 00353 vtkGetMacro(DrawZInnerGridlines,int); 00354 vtkBooleanMacro(DrawZInnerGridlines,int); 00355 00356 vtkSetMacro(DrawXGridpolys,int); 00357 vtkGetMacro(DrawXGridpolys,int); 00358 vtkBooleanMacro(DrawXGridpolys,int); 00359 00360 vtkSetMacro(DrawYGridpolys,int); 00361 vtkGetMacro(DrawYGridpolys,int); 00362 vtkBooleanMacro(DrawYGridpolys,int); 00363 00364 vtkSetMacro(DrawZGridpolys,int); 00365 vtkGetMacro(DrawZGridpolys,int); 00366 vtkBooleanMacro(DrawZGridpolys,int); 00367 00369 vtkTextProperty *GetTitleTextProperty(int); 00370 00372 vtkTextProperty *GetLabelTextProperty(int); 00373 00375 00376 void SetXAxesLinesProperty(vtkProperty *); 00377 vtkProperty* GetXAxesLinesProperty(); 00378 void SetYAxesLinesProperty(vtkProperty *); 00379 vtkProperty* GetYAxesLinesProperty(); 00380 void SetZAxesLinesProperty(vtkProperty *); 00381 vtkProperty* GetZAxesLinesProperty(); 00383 00385 00386 void SetXAxesGridlinesProperty(vtkProperty *); 00387 vtkProperty* GetXAxesGridlinesProperty(); 00388 void SetYAxesGridlinesProperty(vtkProperty *); 00389 vtkProperty* GetYAxesGridlinesProperty(); 00390 void SetZAxesGridlinesProperty(vtkProperty *); 00391 vtkProperty* GetZAxesGridlinesProperty(); 00393 00395 00396 void SetXAxesInnerGridlinesProperty(vtkProperty *); 00397 vtkProperty* GetXAxesInnerGridlinesProperty(); 00398 void SetYAxesInnerGridlinesProperty(vtkProperty *); 00399 vtkProperty* GetYAxesInnerGridlinesProperty(); 00400 void SetZAxesInnerGridlinesProperty(vtkProperty *); 00401 vtkProperty* GetZAxesInnerGridlinesProperty(); 00403 00405 00406 void SetXAxesGridpolysProperty(vtkProperty *); 00407 vtkProperty* GetXAxesGridpolysProperty(); 00408 void SetYAxesGridpolysProperty(vtkProperty *); 00409 vtkProperty* GetYAxesGridpolysProperty(); 00410 void SetZAxesGridpolysProperty(vtkProperty *); 00411 vtkProperty* GetZAxesGridpolysProperty(); 00413 00415 00416 vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH); 00417 vtkGetMacro(TickLocation, int); 00419 00420 void SetTickLocationToInside(void) 00421 { this->SetTickLocation(VTK_TICKS_INSIDE); }; 00422 void SetTickLocationToOutside(void) 00423 { this->SetTickLocation(VTK_TICKS_OUTSIDE); }; 00424 void SetTickLocationToBoth(void) 00425 { this->SetTickLocation(VTK_TICKS_BOTH); }; 00426 00427 void SetLabelScaling(bool, int, int, int); 00428 00430 00432 void SetUseTextActor3D( int val ); 00433 int GetUseTextActor3D(); 00435 00437 00439 void SetUse2DMode( int val ); 00440 int GetUse2DMode(); 00442 00444 void SetSaveTitlePosition( int val ); 00445 00447 00448 vtkSetVector6Macro(OrientedBounds,double); 00449 vtkGetVector6Macro(OrientedBounds, double); 00451 00453 00454 vtkSetMacro(UseOrientedBounds, int); 00455 vtkGetMacro(UseOrientedBounds, int); 00457 00459 00460 vtkSetVector3Macro(AxisBaseForX,double); 00461 vtkGetVector3Macro(AxisBaseForX, double); 00463 00465 00466 vtkSetVector3Macro(AxisBaseForY,double); 00467 vtkGetVector3Macro(AxisBaseForY, double); 00469 00471 00472 vtkSetVector3Macro(AxisBaseForZ,double); 00473 vtkGetVector3Macro(AxisBaseForZ, double); 00475 00477 00479 vtkSetVector3Macro(AxisOrigin,double); 00480 vtkGetVector3Macro(AxisOrigin, double); 00482 00484 00485 vtkSetMacro(UseAxisOrigin, int); 00486 vtkGetMacro(UseAxisOrigin, int); 00488 00490 00491 vtkSetMacro(GridLineLocation,int); 00492 vtkGetMacro(GridLineLocation,int); 00494 00495 protected: 00496 vtkCubeAxesActor(); 00497 ~vtkCubeAxesActor(); 00498 00499 int LabelExponent(double min, double max); 00500 00501 int Digits(double min, double max); 00502 00503 double MaxOf(double, double); 00504 double MaxOf(double, double, double, double); 00505 00506 double FFix(double); 00507 double FSign(double, double); 00508 int FRound( double fnt ); 00509 int GetNumTicks( double range, double fxt); 00510 00511 void UpdateLabels(vtkAxisActor **axis, int index); 00512 00513 double Bounds[6]; //Define bounds explicitly 00514 00515 vtkCamera *Camera; 00516 00517 int FlyMode; 00518 00519 // Expose internally closest axis index computation 00520 int FindClosestAxisIndex(double pts[8][3]); 00521 00522 // Expose internally furthest axis index computation 00523 int FindFurtherstAxisIndex(double pts[8][3]); 00524 00525 // Expose internally the boundary edge fly mode axis index computation 00526 void FindBoundaryEdge(int &indexOfAxisX, int &indexOfAxisY, int &indexOfAxisZ, 00527 double pts[8][3]); 00528 00532 void UpdateGridLineVisibility(int axisIndex); 00533 00534 // VTK_ALL_GRID_LINES 0 00535 // VTK_CLOSEST_GRID_LINES 1 00536 // VTK_FURTHEST_GRID_LINES 2 00537 int GridLineLocation; 00538 00541 int EnableDistanceLOD; 00542 00545 double DistanceLODThreshold; 00546 00549 int EnableViewAngleLOD; 00550 00553 double ViewAngleLODThreshold; 00554 00556 00558 vtkAxisActor *XAxes[NUMBER_OF_ALIGNED_AXIS]; 00559 vtkAxisActor *YAxes[NUMBER_OF_ALIGNED_AXIS]; 00560 vtkAxisActor *ZAxes[NUMBER_OF_ALIGNED_AXIS]; 00562 00563 bool RebuildAxes; 00564 00565 char *XTitle; 00566 char *XUnits; 00567 char *YTitle; 00568 char *YUnits; 00569 char *ZTitle; 00570 char *ZUnits; 00571 00572 char *ActualXLabel; 00573 char *ActualYLabel; 00574 char *ActualZLabel; 00575 00576 int TickLocation; 00577 00578 int XAxisVisibility; 00579 int YAxisVisibility; 00580 int ZAxisVisibility; 00581 00582 int XAxisTickVisibility; 00583 int YAxisTickVisibility; 00584 int ZAxisTickVisibility; 00585 00586 int XAxisMinorTickVisibility; 00587 int YAxisMinorTickVisibility; 00588 int ZAxisMinorTickVisibility; 00589 00590 int XAxisLabelVisibility; 00591 int YAxisLabelVisibility; 00592 int ZAxisLabelVisibility; 00593 00594 int DrawXGridlines; 00595 int DrawYGridlines; 00596 int DrawZGridlines; 00597 00598 int DrawXInnerGridlines; 00599 int DrawYInnerGridlines; 00600 int DrawZInnerGridlines; 00601 00602 int DrawXGridpolys; 00603 int DrawYGridpolys; 00604 int DrawZGridpolys; 00605 00606 char *XLabelFormat; 00607 char *YLabelFormat; 00608 char *ZLabelFormat; 00609 00610 double CornerOffset; 00611 00612 int Inertia; 00613 00614 int RenderCount; 00615 00616 int InertiaLocs[3]; 00617 00618 int RenderSomething; 00619 00620 vtkTextProperty* TitleTextProperty[3]; 00621 vtkStringArray* AxisLabels[3]; 00622 00623 vtkTextProperty* LabelTextProperty[3]; 00624 00625 vtkProperty *XAxesLinesProperty; 00626 vtkProperty *YAxesLinesProperty; 00627 vtkProperty *ZAxesLinesProperty; 00628 vtkProperty *XAxesGridlinesProperty; 00629 vtkProperty *YAxesGridlinesProperty; 00630 vtkProperty *ZAxesGridlinesProperty; 00631 vtkProperty *XAxesInnerGridlinesProperty; 00632 vtkProperty *YAxesInnerGridlinesProperty; 00633 vtkProperty *ZAxesInnerGridlinesProperty; 00634 vtkProperty *XAxesGridpolysProperty; 00635 vtkProperty *YAxesGridpolysProperty; 00636 vtkProperty *ZAxesGridpolysProperty; 00637 00638 double RenderedBounds[6]; 00639 double OrientedBounds[6]; 00640 int UseOrientedBounds; 00641 00642 double AxisOrigin[3]; 00643 int UseAxisOrigin; 00644 00645 double AxisBaseForX[3]; 00646 double AxisBaseForY[3]; 00647 double AxisBaseForZ[3]; 00648 00649 private: 00650 vtkCubeAxesActor(const vtkCubeAxesActor&); // Not implemented 00651 void operator=(const vtkCubeAxesActor&); // Not implemented 00652 00653 vtkSetStringMacro(ActualXLabel); 00654 vtkSetStringMacro(ActualYLabel); 00655 vtkSetStringMacro(ActualZLabel); 00656 00657 vtkTimeStamp BuildTime; 00658 int LastUseOrientedBounds; 00659 int LastXPow; 00660 int LastYPow; 00661 int LastZPow; 00662 00663 int UserXPow; 00664 int UserYPow; 00665 int UserZPow; 00666 00667 bool AutoLabelScaling; 00668 00669 int LastXAxisDigits; 00670 int LastYAxisDigits; 00671 int LastZAxisDigits; 00672 00673 double LastXRange[2]; 00674 double LastYRange[2]; 00675 double LastZRange[2]; 00676 double LastBounds[6]; 00677 00678 int LastFlyMode; 00679 00680 int RenderAxesX[NUMBER_OF_ALIGNED_AXIS]; 00681 int RenderAxesY[NUMBER_OF_ALIGNED_AXIS]; 00682 int RenderAxesZ[NUMBER_OF_ALIGNED_AXIS]; 00683 00684 int NumberOfAxesX; 00685 int NumberOfAxesY; 00686 int NumberOfAxesZ; 00687 00688 bool MustAdjustXValue; 00689 bool MustAdjustYValue; 00690 bool MustAdjustZValue; 00691 00692 bool ForceXLabelReset; 00693 bool ForceYLabelReset; 00694 bool ForceZLabelReset; 00695 00696 double XAxisRange[2]; 00697 double YAxisRange[2]; 00698 double ZAxisRange[2]; 00699 00700 double LabelScale; 00701 double TitleScale; 00702 00703 double ScreenSize; 00704 double LabelOffset; 00705 double TitleOffset; 00706 00708 00710 double MajorStart[3]; 00711 double DeltaMajor[3]; 00713 00714 int RenderGeometry(bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility,int (vtkAxisActor::*renderMethod)(vtkViewport*)); 00715 00716 void TransformBounds(vtkViewport *viewport, const double bounds[6], 00717 double pts[8][3]); 00718 void AdjustAxes(double bounds[6], 00719 double xCoords[NUMBER_OF_ALIGNED_AXIS][6], 00720 double yCoords[NUMBER_OF_ALIGNED_AXIS][6], 00721 double zCoords[NUMBER_OF_ALIGNED_AXIS][6], 00722 double xRange[2], double yRange[2], double zRange[2]); 00723 00724 bool ComputeTickSize(double bounds[6]); 00725 void AdjustValues(const double xRange[2], 00726 const double yRange[2], 00727 const double zRange[2]); 00728 void AdjustRange(const double bounds[6]); 00729 void BuildAxes(vtkViewport *); 00730 void DetermineRenderAxes(vtkViewport *); 00731 void SetNonDependentAttributes(void); 00732 void BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]); 00733 void AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS], 00734 double rangeMin, double rangeMax); 00735 00736 void AutoScale(vtkViewport *viewport); 00737 void AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]); 00738 double AutoScale(vtkViewport *viewport, double screenSize, double position[3]); 00739 }; 00740 00741 00742 #endif