00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _PO_AXIS_
00025 #define _PO_AXIS_
00026
00027 #include <Inventor/fields/SoSFEnum.h>
00028 #include <Inventor/fields/SoSFFloat.h>
00029 #include <Inventor/fields/SoSFString.h>
00030 #include <Inventor/fields/SoSFUShort.h>
00031 #include <Inventor/fields/SoSFBool.h>
00032
00033 #include <MeshViz/graph/PoBaseAxis.h>
00034 #include <MeshViz/graph/PbMiscTextAttr.h>
00035
00036 #include <Inventor/STL/vector>
00037
00038 class PiText ;
00039
00040
00058 class PoAxis : public PoBaseAxis {
00059
00060 SO_KIT_HEADER(PoAxis) ;
00061
00062
00063 SO_KIT_CATALOG_ENTRY_HEADER(transform) ;
00064
00065 SO_KIT_CATALOG_ENTRY_HEADER(bodySep) ;
00066 SO_KIT_CATALOG_ENTRY_HEADER(bodyApp) ;
00067 SO_KIT_CATALOG_ENTRY_HEADER(body) ;
00068
00069 SO_KIT_CATALOG_ENTRY_HEADER(arrowSep) ;
00070 SO_KIT_CATALOG_ENTRY_HEADER(arrowApp) ;
00071 SO_KIT_CATALOG_ENTRY_HEADER(arrow) ;
00072
00073 SO_KIT_CATALOG_ENTRY_HEADER(titleSep) ;
00074 SO_KIT_CATALOG_ENTRY_HEADER(titleApp) ;
00075 SO_KIT_CATALOG_ENTRY_HEADER(title) ;
00076
00077 SO_KIT_CATALOG_ENTRY_HEADER(subGradTickSep) ;
00078 SO_KIT_CATALOG_ENTRY_HEADER(subGradTickApp) ;
00079 SO_KIT_CATALOG_ENTRY_HEADER(subGradTick) ;
00080
00081 SO_KIT_CATALOG_ENTRY_HEADER(subGradGridSep) ;
00082 SO_KIT_CATALOG_ENTRY_HEADER(subGradGridApp) ;
00083 SO_KIT_CATALOG_ENTRY_HEADER(subGradGrid) ;
00084
00085 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTickSep) ;
00086 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTickApp) ;
00087 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTick) ;
00088
00089 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGridSep) ;
00090 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGridApp) ;
00091 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGrid) ;
00092
00093 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTextSep) ;
00094 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTextApp) ;
00095 SO_KIT_CATALOG_ENTRY_HEADER(mainGradText) ;
00096
00097
00098 public:
00099
00107 enum Visibility {
00111 VISIBILITY_OFF,
00115 VISIBILITY_ON,
00119 VISIBILITY_DEPEND
00120 } ;
00121
00122
00123
00127 enum TextPath {
00131 PATH_RIGHT,
00135 PATH_LEFT,
00139 PATH_UP,
00143 PATH_DOWN,
00147 PATH_DEPEND
00148 } ;
00149
00150
00151
00155 enum GradPosition {
00159 GRAD_ABOVE,
00163 GRAD_BELOW,
00167 GRAD_DEPEND
00168 } ;
00169
00170
00171
00175 enum MarginType {
00179 REL_MARGIN,
00183 FIXED_MARGIN
00184 } ;
00185
00186
00187
00191 enum TickPosition {
00195 TICK_GRAD_SIDE,
00199 TICK_GRAD_OTHER_SIDE,
00203 TICK_ACROSS_AXIS
00204 } ;
00205
00206
00207
00211 enum TitlePosition {
00215 TITLE_MIDDLE,
00219 TITLE_END,
00223 TITLE_DEPEND
00224 } ;
00225
00226
00227
00231 enum TickSubDef {
00235 NUM_SUB_TICK,
00239 PERIOD_MAIN_TICK
00240 } ;
00241
00242
00243
00247 enum AxisReverse {
00251 AXIS_NO_REVERSE,
00255 AXIS_REVERSE,
00259 AXIS_REVERSE_DEPEND
00260 } ;
00261
00262
00263
00264
00265
00266
00267
00268
00269
00274 SoSFEnum gradVisibility ;
00275
00280 SoSFEnum gradPosition ;
00281
00286 SoSFEnum gradPath ;
00287
00294 SoSFString gradFontName ;
00295
00305 SoSFFloat gradFontSize ;
00306
00314 SoSFFloat gradDistAxis ;
00315
00320 SoSFBool gradAddStringVisibility ;
00321
00326 SoSFString gradAddString ;
00327
00328
00329
00330
00331
00336 SoSFEnum marginType ;
00337
00342 SoSFFloat marginStart ;
00343
00348 SoSFFloat marginEnd ;
00349
00350
00351
00352
00353
00358 SoSFEnum titleVisibility ;
00359
00364 SoSFEnum titlePosition ;
00365
00370 SoSFEnum titlePath ;
00371
00377 SoSFString titleFontName ;
00378
00386 SoSFFloat titleFontSize ;
00387
00393 SoSFFloat titleDistAxis ;
00394
00399 SoSFString titleString ;
00400
00401
00402
00403
00404
00409 SoSFEnum gridVisibility ;
00410
00415 SoSFFloat gridLengthGradSide ;
00416
00421 SoSFFloat gridLengthGradOtherSide ;
00422
00423
00424
00425
00426
00431 SoSFEnum arrowVisibility ;
00432
00438 SoSFFloat arrowHeight ;
00439
00445 SoSFFloat arrowLength ;
00446
00447
00448
00449
00450
00455 SoSFEnum tickVisibility ;
00456
00461 SoSFEnum tickPosition ;
00462
00469 SoSFFloat tickMainLength ;
00470
00477 SoSFFloat tickSubLength ;
00478
00485 SoSFEnum tickSubDef ;
00486
00492 SoSFUShort tickNumOrPeriod ;
00493
00498 SoSFUShort tickFirstGrad ;
00499
00504 SoSFUShort tickLastGrad ;
00505
00510 SoSFEnum reverseFlag ;
00511
00512
00513
00514
00515
00516
00517
00524 void setMiscTextAttr(PbMiscTextAttr *textAttr) ;
00525
00529 const PbMiscTextAttr *getMiscTextAttr() const ;
00530
00531
00532
00538 void getGrad(Visibility &visibility, GradPosition &position, TextPath &path,
00539 SbString &fontName, float &fontSize, float &distAxis, SbBool
00540 &addStringVisibility, SbString &addString) const ;
00541
00547 void getMargin(MarginType &type, float &start, float &end) const ;
00548
00554 void getTitle(Visibility &visibility, TitlePosition &position, TextPath
00555 &path,SbString &fontName, float &fontSize, float &distAxis,
00556 SbString &string) const ;
00557
00563 void getGrid(Visibility &visibility, float &lengthGradSide, float
00564 &lengthGradOtherSide) const ;
00565
00571 void getArrow(Visibility &visibility, float &height, float &length) const ;
00572
00578 void getTick(Visibility &visibility, TickPosition &position, float &mainLength,
00579 float &subLength, TickSubDef &def, unsigned short &numOrPeriod,
00580 unsigned short &firstGrad, unsigned short &lastGrad) const ;
00581
00586 AxisReverse getReverseFlag() const ;
00587
00588
00589 private:
00590 static void initClass() ;
00591 static void exitClass() ;
00592
00593 struct GradAttr {
00594 Visibility visibility ;
00595 GradPosition position ;
00596 TextPath path ;
00597 float fontSize ;
00598 SbString fontName ;
00599 float distAxis ;
00600 } ;
00601
00602
00603
00604 struct MarginAttr {
00605 MarginType type ;
00606 float start ;
00607 float end ;
00608 } ;
00609
00610
00611 struct TitleAttr {
00612 Visibility visibility ;
00613 TitlePosition position ;
00614 TextPath path ;
00615 float fontSize ;
00616 SbString fontName ;
00617 float distAxis ;
00618 } ;
00619
00620
00621 struct GridAttr {
00622 Visibility visibility ;
00623 float lenGradSide ;
00624 float lenGradOtherSide ;
00625 } ;
00626
00627
00628 struct ArrowAttr {
00629 Visibility visibility ;
00630 float height ;
00631 float length ;
00632 } ;
00633
00634
00635 struct TickAttr {
00636 Visibility visibility ;
00637 TickPosition position ;
00638 float mainLength ;
00639 float subLength ;
00640 TickSubDef subDef ;
00641 int numOrPeriod ;
00642 int firstGrad ;
00643 int lastGrad ;
00644 } ;
00645
00646
00647 struct MiscAttr {
00648 float deltaX ;
00649 float deltaY ;
00650 Plimit limit ;
00651 char endLineChar ;
00652 int lineLength ;
00653 std::vector<float> mainGradCoords;
00654 std::vector<float> subGradCoords;
00655 } ;
00656
00657 enum Plane {
00658 XY,
00659 XZ,
00660 YX,
00661 YZ,
00662 ZX,
00663 ZY
00664 } ;
00665
00666
00667
00668 int getMainGradCoords(const float* &coords) const ;
00669
00670
00671
00672 int getSubGradCoords(const float* &coords) const ;
00673
00674 private:
00675
00676 PoAxis() ;
00677
00678 virtual ~PoAxis() ;
00679
00680
00681 struct AxisAttr {
00682 GradAttr grad ;
00683 MarginAttr margin ;
00684 TitleAttr title ;
00685 GridAttr grid ;
00686 ArrowAttr arrow ;
00687 TickAttr tick ;
00688 AxisReverse reverseFlag ;
00689 MiscAttr misc ;
00690 } ;
00691
00692
00693 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00694 virtual void setDefaultOnNonWritingFields() ;
00695
00696
00697 virtual void basicObjectChange(PbBase *basicObj) ;
00698
00699
00700 virtual void saveAxisAttr() ;
00701
00702
00703 virtual void setDefaultAttr(Plane plane = XY) ;
00704
00705
00706 virtual void computeGradLimit(float xOrig, float xExtr, float &xmOrig, float &xmExtr) ;
00707
00708
00709 virtual void computeTickLen(size_t numGrad, float &mainTickLen, float &secdTickLen) ;
00710
00711
00712 virtual void buildArrow(float orig, float extr, SoGroup *group) ;
00713
00714
00715 virtual void buildTick(const std::vector<float>& xGrad, float tickLen,
00716 SoGroup *group) ;
00717
00718
00719 virtual void buildGridLines(const std::vector<float>& xGrad, SoGroup *group) ;
00720
00721
00722 void buildTitle(float xOrig, float xExtr, SoGroup *group) ;
00723
00724
00725
00726 virtual void buildGrads(const std::vector<float>& xGrad, const char **gradStr,
00727 SoGroup *group) ;
00728
00729
00730
00731 void buildMultFactorAtExtr(int tenPower, float xOrig, float xExtr, float &distAxis,
00732 SoGroup *group) ;
00733
00734
00735
00736 void computeGradList(float xOrig, float xExtr, float step, size_t numAllGrad,
00737 const char** allGradStr, const std::vector<float>& allGradX,
00738 char **mainGradStr,
00739 std::vector<float> &mainGradX, std::vector<float> &secondaryGradX) ;
00740
00741
00742 static char **allocGradString(size_t numStr) ;
00743
00744
00745 virtual void addElementsAllCaches() ;
00746 virtual void preRebuild() ;
00747
00748
00749
00750
00751 enum LogGradType {
00752 TDECIMAL_TYPE,
00753 TDIGIT_TYPE,
00754 TPOWER_TYPE
00755 } ;
00756
00757 struct SecondaryLogGrad
00758 {
00759 float coord;
00760 int powerOfTen;
00761 int decade;
00762 };
00763
00764
00765 static void convertLogGradToStr(SbBool isMainGrad, LogGradType grad_type, int grad,
00766 int ten_pow, char *string1, char *string2) ;
00767
00768
00769 static void computeLogGradMinDist(const std::vector<float>& mainGradX,
00770 const std::vector<float>& secdGradX,
00771 float &min_grad_dist);
00772
00773
00774 static void computeDecadeGradList(size_t numMainGrad, int **decades,
00775 size_t &numDecades) ;
00776
00777
00778 void computeLogGradWidth(const char *str, const char *tenPowStr,
00779 float fontSize, float &width) ;
00780
00781
00782 void computeLogGradsMaxWidth(const char **strs, const char **tenPowStrs,
00783 size_t numStr, float fontSize, float &width,
00784 int &indexMaxWidth) ;
00785
00786
00787 void drawLogGrad(float pyAtMax, float pyAtMin, float fontSize,
00788 LogGradType gradType, const std::vector<float>& gradX,
00789 const char **gradStr, const char **tenPowStr,
00790 SoGroup *group) ;
00791
00792 static char *PStringToConcat ;
00793 static PiText *PLogGradText ;
00794
00795
00796
00797
00798 AxisAttr axisAttr ;
00799
00800 private:
00801
00802 void buildTitleP(SbBool isTitleBuild, float xOrig, float xExtr,
00803 SoGroup *group, Plimit &limit) ;
00804
00805
00806 PbMiscTextAttr *m_miscTextAttr, m_defaultMiscTextAttr ;
00807
00808
00809 FieldSensorList fieldSensorList ;
00810
00811
00812 SoFieldList fieldList ;
00813
00814 } ;
00815
00816
00817
00818 #endif
00819
00820