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_PIE_CHART_
00025 #define _PO_PIE_CHART_
00026
00027 #include <Inventor/fields/SoSFEnum.h>
00028 #include <Inventor/fields/SoSFFloat.h>
00029 #include <Inventor/fields/SoMFFloat.h>
00030 #include <Inventor/fields/SoMFString.h>
00031 #include <Inventor/fields/SoSFString.h>
00032 #include <Inventor/fields/SoSFBool.h>
00033 #include <Inventor/fields/SoMFShort.h>
00034 #include <Inventor/fields/SoMFColor.h>
00035
00036 #include <MeshViz/graph/PoGraphMaster.h>
00037 #include <MeshViz/graph/PbMiscTextAttr.h>
00038 #include <MeshViz/graph/PbNumericDisplayFormat.h>
00039
00040 class PiText ;
00041
00137 class PoPieChart : public PoGraphMaster {
00138 SO_KIT_HEADER(PoPieChart) ;
00139
00140
00141 SO_KIT_CATALOG_ENTRY_HEADER(sliceSep) ;
00142 SO_KIT_CATALOG_ENTRY_HEADER(sliceApp) ;
00143 SO_KIT_CATALOG_ENTRY_HEADER(slice) ;
00144
00145 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorderSep) ;
00146 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorderApp) ;
00147 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorder) ;
00148
00149 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxSep) ;
00150 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxApp) ;
00151 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBox) ;
00152
00153 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorderSep) ;
00154 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorderApp) ;
00155 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorder) ;
00156
00157 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotTextSep) ;
00158 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotTextApp) ;
00159 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotText) ;
00160
00161 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValueSep) ;
00162 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValueApp) ;
00163 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValue) ;
00164
00165 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercentSep) ;
00166 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercentApp) ;
00167 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercent) ;
00168
00169 SO_KIT_CATALOG_ENTRY_HEADER(arrowSep) ;
00170 SO_KIT_CATALOG_ENTRY_HEADER(arrowApp) ;
00171 SO_KIT_CATALOG_ENTRY_HEADER(arrow) ;
00172
00173 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxSep) ;
00174 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxApp) ;
00175 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBox) ;
00176
00177 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorderSep) ;
00178 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorderApp) ;
00179 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorder) ;
00180
00181 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotTextSep) ;
00182 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotTextApp) ;
00183 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotText) ;
00184
00185 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValueSep) ;
00186 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValueApp) ;
00187 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValue) ;
00188
00189 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercentSep) ;
00190 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercentApp) ;
00191 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercent) ;
00192
00193
00194 public:
00195
00199 enum IntAnnotPosition {
00203 RADIAL_INT_POS,
00207 HOR_INT_POS
00208 } ;
00209
00213 enum ExtAnnotPosition {
00217 RADIAL_EXT_POS,
00221 HOR_EXT_POS,
00225 HOR_ALIGNED_EXT_POS,
00229 VERT_ALIGNED_EXT_POS,
00233 SQUARE_ALIGNED_EXT_POS
00234 } ;
00235
00239 enum Alignment {
00243 LEFT_ALIGN,
00247 CENTER_ALIGN,
00251 RIGHT_ALIGN,
00255 INWARDS_ALIGN,
00259 OUTWARDS_ALIGN
00260 } ;
00261
00262 #ifdef ABSOLUTE
00263
00264 #undef ABSOLUTE
00265
00266 #endif
00267
00268
00269
00273 enum PercentStatus {
00274 ABSOLUTE,
00275 PERCENTAGE
00276 } ;
00277
00278
00279
00280
00281
00282
00283
00287 SoSFFloat radius ;
00288
00289
00290
00291
00292
00299 SoMFString sliceText ;
00300
00307 SoMFFloat sliceValue ;
00308
00314 SoMFColor sliceColor ;
00315
00316
00317
00318
00319
00323 SoSFEnum intAnnotPosition ;
00324
00328 SoSFEnum intAnnotAlignment ;
00329
00333 SoSFBool intAnnotTextVisibility ;
00334
00338 SoSFBool intAnnotValueVisibility ;
00339
00344 SoSFBool intAnnotPercentVisibility ;
00345
00350 SoSFBool intAnnotAddStringVisibility ;
00351
00355 SoSFString intAnnotAddString ;
00356
00363 SoSFString intAnnotTextFontName ;
00364
00371 SoSFFloat intAnnotTextFontSize ;
00372
00379 SoSFString intAnnotValueFontName ;
00380
00387 SoSFFloat intAnnotValueFontSize ;
00388
00394 SoSFString intAnnotPercentFontName ;
00395
00402 SoSFFloat intAnnotPercentFontSize ;
00403
00410 SoSFFloat intAnnotDistance ;
00411
00412
00413
00414
00415
00419 SoSFEnum extAnnotPosition ;
00420
00424 SoSFEnum extAnnotAlignment ;
00425
00429 SoSFBool extAnnotTextVisibility ;
00430
00434 SoSFBool extAnnotValueVisibility ;
00435
00439 SoSFBool extAnnotPercentVisibility ;
00440
00445 SoSFBool extAnnotAddStringVisibility ;
00446
00450 SoSFString extAnnotAddString ;
00451
00458 SoSFString extAnnotTextFontName ;
00459
00466 SoSFFloat extAnnotTextFontSize ;
00467
00474 SoSFString extAnnotValueFontName ;
00475
00482 SoSFFloat extAnnotValueFontSize ;
00483
00489 SoSFString extAnnotPercentFontName ;
00490
00497 SoSFFloat extAnnotPercentFontSize ;
00498
00504 SoSFFloat extAnnotDistance1 ;
00505
00512 SoSFFloat extAnnotDistance2 ;
00513
00520 SoSFFloat extAnnotDistance3 ;
00521
00522
00523
00524
00525
00529 SoSFBool arrowVisibility ;
00530
00534 SoSFFloat arrowHeight ;
00535
00539 SoSFFloat arrowWidth ;
00540
00541
00542
00543
00544
00549 SoSFBool sliceGroupActive ;
00550
00554 SoSFFloat sliceGroupMinValue ;
00555
00561 SoSFEnum sliceGroupFlagMin ;
00562
00566 SoSFString sliceGroupString ;
00567
00568
00569
00570
00571
00578 SoMFShort sliceToTranslateNumber ;
00579
00584 SoMFFloat sliceToTranslateValue ;
00585
00591 SoSFFloat sliceAngleStep ;
00592
00593
00594
00595
00596
00597
00598
00605 void setMiscTextAttr(PbMiscTextAttr *textAttr) ;
00606
00610 const PbMiscTextAttr *getMiscTextAttr() const ;
00611
00619 void setFormat(PbNumericDisplayFormat *format) ;
00620
00625 const PbNumericDisplayFormat *getFormat() const ;
00626
00636 SbBool getPickedSliceNumber(const SoPath *path, int &sliceNumber) const ;
00637
00647 void setSliceToTranslate(int sliceNumber, float translateValue) ;
00648
00654 float getSliceToTranslate(int sliceNumber) const ;
00655
00656
00657 private:
00658 static void initClass() ;
00659 static void exitClass() ;
00660
00661 private:
00662
00663 struct PieChartAttr {
00664 SbString intTextFontName ;
00665 float intTextFontSize ;
00666
00667 SbString extTextFontName ;
00668 float extTextFontSize ;
00669
00670 SbString intValFontName ;
00671 float intValFontSize ;
00672
00673 SbString extValFontName ;
00674 float extValFontSize ;
00675
00676 SbString intPercentFontName ;
00677 float intPercentFontSize ;
00678
00679 SbString extPercentFontName ;
00680 float extPercentFontSize ;
00681
00682 float intDist ;
00683
00684 float extDist1 ;
00685 float extDist2 ;
00686 float extDist3 ;
00687
00688 float arrowWidth ;
00689 float arrowHeight ;
00690
00691 SbString sliceNames[360] ;
00692
00693 int numSlices ;
00694 int displayedSlicesNum ;
00695 int displayedSlices[360] ;
00696 float slicesPercentages[360] ;
00697 SbString slicesValuesString[360] ;
00698 SbString slicesPercentagesString[360] ;
00699 float slicesValues[360] ;
00700 float slicesTranslation[360] ;
00701
00702 int slicesLowValuesNumbers ;
00703
00704 char endLineChar ;
00705 int lineLength ;
00706 } ;
00707
00708 PieChartAttr m_pieChartAttr ;
00709
00710 enum AnnotPosPieChart {
00711 RIGHT_PIE_CHART,
00712 LEFT_PIE_CHART,
00713 UP_PIE_CHART,
00714 DOWN_PIE_CHART
00715 } ;
00716
00717
00718 PoPieChart(SbBool isDefault=TRUE, float _radius=1., short numSlices=0,
00719 const char **_sliceTexts=NULL, const float *_sliceValues=NULL,
00720 int numSliceColors=0, const SbColor *_sliceColors=NULL) ;
00721
00722 virtual ~PoPieChart() ;
00723
00724
00725 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00726 virtual void setDefaultOnNonWritingFields() ;
00727 virtual void basicObjectChange(PbBase *basicObj) ;
00728
00729
00730 void savePieChartAttr() ;
00731
00732
00733 void computeSlicePartValuesToDisplay() ;
00734
00735
00736
00737 void computeStringsToDisplay(const float *values, int numValues, SbBool isPercentage) ;
00738
00739
00740 void drawInternalAnnotations(const SbVec2f &pieChartCenter, const SbVec2f &pointz) ;
00741
00742
00743 void drawInternalAnnot(int sliceNum, const SbVec2f &annotCenterPoint, const SbVec2f &pointz,
00744 AnnotPosPieChart annotPosPieChart, int nbAnnot, float rotateAnnotAngle,
00745 PiText *intText, PiText *intValue, PiText *intPercent,
00746 SoGroup *intAnnotBoxGroup, SoGroup *intAnnotBoxBorderGroup) ;
00747
00748
00749 void drawExternalAnnotations(const SbVec2f &pieChartCenter, const SbVec2f &pointz) ;
00750
00751
00752 void drawExternalAnnot(int sliceNum, const SbVec3f &arrowStartPoint, const SbVec2f &pointz,
00753 AnnotPosPieChart annotPosPieChart, int nbAnnot, float rotateAnnotAngle,
00754 PiText *extText, PiText *extValue, PiText *extPercent,
00755 SoGroup *extAnnotBoxGroup, SoGroup *extAnnotBoxBorderGroup) ;
00756
00757
00758 void resetAllPart() ;
00759
00760
00761 void computeSliceNames() ;
00762
00763
00764 virtual void addElementsAllCaches() ;
00765 virtual void preRebuild() ;
00766
00767 private:
00768
00769 PbMiscTextAttr *m_miscTextAttr, m_defaultMiscTextAttr ;
00770
00771
00772 PbNumericDisplayFormat *m_numericDisplayFormat, m_defaultNumericDisplayFormat ;
00773
00774
00775 FieldSensorList m_fieldSensorList ;
00776
00777
00778 SoFieldList m_fieldList ;
00779
00780 } ;
00781
00782
00783
00784 #endif
00785
00786