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
00104 class PoAxis : public PoBaseAxis {
00105
00106 SO_KIT_HEADER(PoAxis) ;
00107
00108
00109 SO_KIT_CATALOG_ENTRY_HEADER(transform) ;
00110
00111 SO_KIT_CATALOG_ENTRY_HEADER(bodySep) ;
00112 SO_KIT_CATALOG_ENTRY_HEADER(bodyApp) ;
00113 SO_KIT_CATALOG_ENTRY_HEADER(body) ;
00114
00115 SO_KIT_CATALOG_ENTRY_HEADER(arrowSep) ;
00116 SO_KIT_CATALOG_ENTRY_HEADER(arrowApp) ;
00117 SO_KIT_CATALOG_ENTRY_HEADER(arrow) ;
00118
00119 SO_KIT_CATALOG_ENTRY_HEADER(titleSep) ;
00120 SO_KIT_CATALOG_ENTRY_HEADER(titleApp) ;
00121 SO_KIT_CATALOG_ENTRY_HEADER(title) ;
00122
00123 SO_KIT_CATALOG_ENTRY_HEADER(subGradTickSep) ;
00124 SO_KIT_CATALOG_ENTRY_HEADER(subGradTickApp) ;
00125 SO_KIT_CATALOG_ENTRY_HEADER(subGradTick) ;
00126
00127 SO_KIT_CATALOG_ENTRY_HEADER(subGradGridSep) ;
00128 SO_KIT_CATALOG_ENTRY_HEADER(subGradGridApp) ;
00129 SO_KIT_CATALOG_ENTRY_HEADER(subGradGrid) ;
00130
00131 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTickSep) ;
00132 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTickApp) ;
00133 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTick) ;
00134
00135 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGridSep) ;
00136 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGridApp) ;
00137 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGrid) ;
00138
00139 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTextSep) ;
00140 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTextApp) ;
00141 SO_KIT_CATALOG_ENTRY_HEADER(mainGradText) ;
00142
00143
00144 public:
00145
00153 enum Visibility {
00157 VISIBILITY_OFF,
00161 VISIBILITY_ON,
00165 VISIBILITY_DEPEND
00166 } ;
00167
00168
00169
00173 enum TextPath {
00177 PATH_RIGHT,
00181 PATH_LEFT,
00185 PATH_UP,
00189 PATH_DOWN,
00193 PATH_DEPEND
00194 } ;
00195
00196
00197
00201 enum GradPosition {
00205 GRAD_ABOVE,
00209 GRAD_BELOW,
00213 GRAD_DEPEND
00214 } ;
00215
00216
00217
00221 enum MarginType {
00225 REL_MARGIN,
00229 FIXED_MARGIN
00230 } ;
00231
00232
00233
00237 enum TickPosition {
00241 TICK_GRAD_SIDE,
00245 TICK_GRAD_OTHER_SIDE,
00249 TICK_ACROSS_AXIS
00250 } ;
00251
00252
00253
00257 enum TitlePosition {
00261 TITLE_MIDDLE,
00265 TITLE_END,
00269 TITLE_DEPEND
00270 } ;
00271
00272
00273
00277 enum TickSubDef {
00281 NUM_SUB_TICK,
00285 PERIOD_MAIN_TICK
00286 } ;
00287
00288
00289
00293 enum AxisReverse {
00297 AXIS_NO_REVERSE,
00301 AXIS_REVERSE,
00305 AXIS_REVERSE_DEPEND
00306 } ;
00307
00308
00309
00310
00311
00312
00313
00314
00315
00320 SoSFEnum gradVisibility ;
00321
00326 SoSFEnum gradPosition ;
00327
00332 SoSFEnum gradPath ;
00333
00340 SoSFString gradFontName ;
00341
00351 SoSFFloat gradFontSize ;
00352
00360 SoSFFloat gradDistAxis ;
00361
00366 SoSFBool gradAddStringVisibility ;
00367
00372 SoSFString gradAddString ;
00373
00374
00375
00376
00377
00382 SoSFEnum marginType ;
00383
00388 SoSFFloat marginStart ;
00389
00394 SoSFFloat marginEnd ;
00395
00396
00397
00398
00399
00404 SoSFEnum titleVisibility ;
00405
00410 SoSFEnum titlePosition ;
00411
00416 SoSFEnum titlePath ;
00417
00423 SoSFString titleFontName ;
00424
00432 SoSFFloat titleFontSize ;
00433
00439 SoSFFloat titleDistAxis ;
00440
00445 SoSFString titleString ;
00446
00447
00448
00449
00450
00455 SoSFEnum gridVisibility ;
00456
00461 SoSFFloat gridLengthGradSide ;
00462
00467 SoSFFloat gridLengthGradOtherSide ;
00468
00469
00470
00471
00472
00477 SoSFEnum arrowVisibility ;
00478
00484 SoSFFloat arrowHeight ;
00485
00491 SoSFFloat arrowLength ;
00492
00493
00494
00495
00496
00501 SoSFEnum tickVisibility ;
00502
00507 SoSFEnum tickPosition ;
00508
00515 SoSFFloat tickMainLength ;
00516
00523 SoSFFloat tickSubLength ;
00524
00531 SoSFEnum tickSubDef ;
00532
00538 SoSFUShort tickNumOrPeriod ;
00539
00544 SoSFUShort tickFirstGrad ;
00545
00550 SoSFUShort tickLastGrad ;
00551
00556 SoSFEnum reverseFlag ;
00557
00558
00559
00560
00561
00562
00563
00570 void setMiscTextAttr(PbMiscTextAttr *textAttr) ;
00571
00575 const PbMiscTextAttr *getMiscTextAttr() const ;
00576
00577
00578
00584 void getGrad(Visibility &visibility, GradPosition &position, TextPath &path,
00585 SbString &fontName, float &fontSize, float &distAxis, SbBool
00586 &addStringVisibility, SbString &addString) const ;
00587
00593 void getMargin(MarginType &type, float &start, float &end) const ;
00594
00600 void getTitle(Visibility &visibility, TitlePosition &position, TextPath
00601 &path,SbString &fontName, float &fontSize, float &distAxis,
00602 SbString &string) const ;
00603
00609 void getGrid(Visibility &visibility, float &lengthGradSide, float
00610 &lengthGradOtherSide) const ;
00611
00617 void getArrow(Visibility &visibility, float &height, float &length) const ;
00618
00624 void getTick(Visibility &visibility, TickPosition &position, float &mainLength,
00625 float &subLength, TickSubDef &def, unsigned short &numOrPeriod,
00626 unsigned short &firstGrad, unsigned short &lastGrad) const ;
00627
00632 AxisReverse getReverseFlag() const ;
00633
00634
00635 private:
00636 static void initClass() ;
00637 static void exitClass() ;
00638
00639 struct GradAttr {
00640 Visibility visibility ;
00641 GradPosition position ;
00642 TextPath path ;
00643 float fontSize ;
00644 SbString fontName ;
00645 float distAxis ;
00646 } ;
00647
00648
00649
00650 struct MarginAttr {
00651 MarginType type ;
00652 float start ;
00653 float end ;
00654 } ;
00655
00656
00657 struct TitleAttr {
00658 Visibility visibility ;
00659 TitlePosition position ;
00660 TextPath path ;
00661 float fontSize ;
00662 SbString fontName ;
00663 float distAxis ;
00664 } ;
00665
00666
00667 struct GridAttr {
00668 Visibility visibility ;
00669 float lenGradSide ;
00670 float lenGradOtherSide ;
00671 } ;
00672
00673
00674 struct ArrowAttr {
00675 Visibility visibility ;
00676 float height ;
00677 float length ;
00678 } ;
00679
00680
00681 struct TickAttr {
00682 Visibility visibility ;
00683 TickPosition position ;
00684 float mainLength ;
00685 float subLength ;
00686 TickSubDef subDef ;
00687 int numOrPeriod ;
00688 int firstGrad ;
00689 int lastGrad ;
00690 } ;
00691
00692
00693 struct MiscAttr {
00694 float deltaX ;
00695 float deltaY ;
00696 Plimit limit ;
00697 char endLineChar ;
00698 int lineLength ;
00699 std::vector<float> mainGradCoords;
00700 std::vector<float> subGradCoords;
00701 } ;
00702
00703 enum Plane {
00704 XY,
00705 XZ,
00706 YX,
00707 YZ,
00708 ZX,
00709 ZY
00710 } ;
00711
00712
00713
00714 int getMainGradCoords(const float* &coords) const ;
00715
00716
00717
00718 int getSubGradCoords(const float* &coords) const ;
00719
00720 private:
00721
00722 PoAxis() ;
00723
00724 virtual ~PoAxis() ;
00725
00726
00727 struct AxisAttr {
00728 GradAttr grad ;
00729 MarginAttr margin ;
00730 TitleAttr title ;
00731 GridAttr grid ;
00732 ArrowAttr arrow ;
00733 TickAttr tick ;
00734 AxisReverse reverseFlag ;
00735 MiscAttr misc ;
00736 } ;
00737
00738
00739 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00740 virtual void setDefaultOnNonWritingFields() ;
00741
00742
00743 virtual void basicObjectChange(PbBase *basicObj) ;
00744
00745
00746 virtual void saveAxisAttr() ;
00747
00748
00749 virtual void setDefaultAttr(Plane plane = XY) ;
00750
00751
00752 virtual void computeGradLimit(float xOrig, float xExtr, float &xmOrig, float &xmExtr) ;
00753
00754
00755 virtual void computeTickLen(size_t numGrad, float &mainTickLen, float &secdTickLen) ;
00756
00757
00758 virtual void buildArrow(float orig, float extr, SoGroup *group) ;
00759
00760
00761 virtual void buildTick(const std::vector<float>& xGrad, float tickLen,
00762 SoGroup *group) ;
00763
00764
00765 virtual void buildGridLines(const std::vector<float>& xGrad, SoGroup *group) ;
00766
00767
00768 void buildTitle(float xOrig, float xExtr, SoGroup *group) ;
00769
00770
00771
00772 virtual void buildGrads(const std::vector<float>& xGrad, const char **gradStr,
00773 SoGroup *group) ;
00774
00775
00776
00777 void buildMultFactorAtExtr(int tenPower, float xOrig, float xExtr, float &distAxis,
00778 SoGroup *group) ;
00779
00780
00781
00782 void computeGradList(float xOrig, float xExtr, float step, size_t numAllGrad,
00783 const char** allGradStr, const std::vector<float>& allGradX,
00784 char **mainGradStr,
00785 std::vector<float> &mainGradX, std::vector<float> &secondaryGradX) ;
00786
00787
00788 static char **allocGradString(size_t numStr) ;
00789
00790
00791 virtual void addElementsAllCaches() ;
00792 virtual void preRebuild() ;
00793
00794
00795
00796
00797 enum LogGradType {
00798 TDECIMAL_TYPE,
00799 TDIGIT_TYPE,
00800 TPOWER_TYPE
00801 } ;
00802
00803 struct SecondaryLogGrad
00804 {
00805 float coord;
00806 int powerOfTen;
00807 int decade;
00808 };
00809
00810
00811 static void convertLogGradToStr(SbBool isMainGrad, LogGradType grad_type, int grad,
00812 int ten_pow, char *string1, char *string2) ;
00813
00814
00815 static void computeLogGradMinDist(const std::vector<float>& mainGradX,
00816 const std::vector<float>& secdGradX,
00817 float &min_grad_dist);
00818
00819
00820 static void computeDecadeGradList(size_t numMainGrad, int **decades,
00821 size_t &numDecades) ;
00822
00823
00824 void computeLogGradWidth(const char *str, const char *tenPowStr,
00825 float fontSize, float &width) ;
00826
00827
00828 void computeLogGradsMaxWidth(const char **strs, const char **tenPowStrs,
00829 size_t numStr, float fontSize, float &width,
00830 int &indexMaxWidth) ;
00831
00832
00833 void drawLogGrad(float pyAtMax, float pyAtMin, float fontSize,
00834 LogGradType gradType, const std::vector<float>& gradX,
00835 const char **gradStr, const char **tenPowStr,
00836 SoGroup *group) ;
00837
00838 static char *PStringToConcat ;
00839 static PiText *PLogGradText ;
00840
00841
00842
00843
00844 AxisAttr axisAttr ;
00845
00846 private:
00847
00848 void buildTitleP(SbBool isTitleBuild, float xOrig, float xExtr,
00849 SoGroup *group, Plimit &limit) ;
00850
00851
00852 PbMiscTextAttr *m_miscTextAttr, m_defaultMiscTextAttr ;
00853
00854
00855 FieldSensorList fieldSensorList ;
00856
00857
00858 SoFieldList fieldList ;
00859
00860 } ;
00861
00862
00863
00864 #endif
00865
00866