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
00136 class PoPieChart : public PoGraphMaster {
00137 SO_KIT_HEADER(PoPieChart) ;
00138
00139
00140 SO_KIT_CATALOG_ENTRY_HEADER(sliceSep) ;
00141 SO_KIT_CATALOG_ENTRY_HEADER(sliceApp) ;
00142 SO_KIT_CATALOG_ENTRY_HEADER(slice) ;
00143
00144 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorderSep) ;
00145 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorderApp) ;
00146 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorder) ;
00147
00148 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxSep) ;
00149 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxApp) ;
00150 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBox) ;
00151
00152 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorderSep) ;
00153 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorderApp) ;
00154 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorder) ;
00155
00156 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotTextSep) ;
00157 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotTextApp) ;
00158 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotText) ;
00159
00160 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValueSep) ;
00161 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValueApp) ;
00162 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValue) ;
00163
00164 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercentSep) ;
00165 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercentApp) ;
00166 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercent) ;
00167
00168 SO_KIT_CATALOG_ENTRY_HEADER(arrowSep) ;
00169 SO_KIT_CATALOG_ENTRY_HEADER(arrowApp) ;
00170 SO_KIT_CATALOG_ENTRY_HEADER(arrow) ;
00171
00172 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxSep) ;
00173 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxApp) ;
00174 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBox) ;
00175
00176 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorderSep) ;
00177 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorderApp) ;
00178 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorder) ;
00179
00180 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotTextSep) ;
00181 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotTextApp) ;
00182 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotText) ;
00183
00184 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValueSep) ;
00185 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValueApp) ;
00186 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValue) ;
00187
00188 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercentSep) ;
00189 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercentApp) ;
00190 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercent) ;
00191
00192
00193 public:
00194
00198 enum IntAnnotPosition {
00202 RADIAL_INT_POS,
00206 HOR_INT_POS
00207 } ;
00208
00212 enum ExtAnnotPosition {
00216 RADIAL_EXT_POS,
00220 HOR_EXT_POS,
00224 HOR_ALIGNED_EXT_POS,
00228 VERT_ALIGNED_EXT_POS,
00232 SQUARE_ALIGNED_EXT_POS
00233 } ;
00234
00238 enum Alignment {
00242 LEFT_ALIGN,
00246 CENTER_ALIGN,
00250 RIGHT_ALIGN,
00254 INWARDS_ALIGN,
00258 OUTWARDS_ALIGN
00259 } ;
00260
00261 #ifdef ABSOLUTE
00262
00263 #undef ABSOLUTE
00264
00265 #endif
00266
00267
00268
00272 enum PercentStatus {
00273 ABSOLUTE,
00274 PERCENTAGE
00275 } ;
00276
00277
00278
00279
00280
00281
00282
00286 SoSFFloat radius ;
00287
00288
00289
00290
00291
00298 SoMFString sliceText ;
00299
00306 SoMFFloat sliceValue ;
00307
00313 SoMFColor sliceColor ;
00314
00315
00316
00317
00318
00322 SoSFEnum intAnnotPosition ;
00323
00327 SoSFEnum intAnnotAlignment ;
00328
00332 SoSFBool intAnnotTextVisibility ;
00333
00337 SoSFBool intAnnotValueVisibility ;
00338
00343 SoSFBool intAnnotPercentVisibility ;
00344
00349 SoSFBool intAnnotAddStringVisibility ;
00350
00354 SoSFString intAnnotAddString ;
00355
00362 SoSFString intAnnotTextFontName ;
00363
00370 SoSFFloat intAnnotTextFontSize ;
00371
00378 SoSFString intAnnotValueFontName ;
00379
00386 SoSFFloat intAnnotValueFontSize ;
00387
00393 SoSFString intAnnotPercentFontName ;
00394
00401 SoSFFloat intAnnotPercentFontSize ;
00402
00409 SoSFFloat intAnnotDistance ;
00410
00411
00412
00413
00414
00418 SoSFEnum extAnnotPosition ;
00419
00423 SoSFEnum extAnnotAlignment ;
00424
00428 SoSFBool extAnnotTextVisibility ;
00429
00433 SoSFBool extAnnotValueVisibility ;
00434
00438 SoSFBool extAnnotPercentVisibility ;
00439
00444 SoSFBool extAnnotAddStringVisibility ;
00445
00449 SoSFString extAnnotAddString ;
00450
00457 SoSFString extAnnotTextFontName ;
00458
00465 SoSFFloat extAnnotTextFontSize ;
00466
00473 SoSFString extAnnotValueFontName ;
00474
00481 SoSFFloat extAnnotValueFontSize ;
00482
00488 SoSFString extAnnotPercentFontName ;
00489
00496 SoSFFloat extAnnotPercentFontSize ;
00497
00503 SoSFFloat extAnnotDistance1 ;
00504
00511 SoSFFloat extAnnotDistance2 ;
00512
00519 SoSFFloat extAnnotDistance3 ;
00520
00521
00522
00523
00524
00528 SoSFBool arrowVisibility ;
00529
00533 SoSFFloat arrowHeight ;
00534
00538 SoSFFloat arrowWidth ;
00539
00540
00541
00542
00543
00548 SoSFBool sliceGroupActive ;
00549
00553 SoSFFloat sliceGroupMinValue ;
00554
00560 SoSFEnum sliceGroupFlagMin ;
00561
00565 SoSFString sliceGroupString ;
00566
00567
00568
00569
00570
00577 SoMFShort sliceToTranslateNumber ;
00578
00583 SoMFFloat sliceToTranslateValue ;
00584
00590 SoSFFloat sliceAngleStep ;
00591
00592
00593
00594
00595
00596
00597
00604 void setMiscTextAttr(PbMiscTextAttr *textAttr) ;
00605
00609 const PbMiscTextAttr *getMiscTextAttr() const ;
00610
00618 void setFormat(PbNumericDisplayFormat *format) ;
00619
00624 const PbNumericDisplayFormat *getFormat() const ;
00625
00635 SbBool getPickedSliceNumber(const SoPath *path, int &sliceNumber) const ;
00636
00646 void setSliceToTranslate(int sliceNumber, float translateValue) ;
00647
00653 float getSliceToTranslate(int sliceNumber) const ;
00654
00655
00656 private:
00657 static void initClass() ;
00658 static void exitClass() ;
00659
00660 private:
00661
00662 struct PieChartAttr {
00663 SbString intTextFontName ;
00664 float intTextFontSize ;
00665
00666 SbString extTextFontName ;
00667 float extTextFontSize ;
00668
00669 SbString intValFontName ;
00670 float intValFontSize ;
00671
00672 SbString extValFontName ;
00673 float extValFontSize ;
00674
00675 SbString intPercentFontName ;
00676 float intPercentFontSize ;
00677
00678 SbString extPercentFontName ;
00679 float extPercentFontSize ;
00680
00681 float intDist ;
00682
00683 float extDist1 ;
00684 float extDist2 ;
00685 float extDist3 ;
00686
00687 float arrowWidth ;
00688 float arrowHeight ;
00689
00690 SbString sliceNames[360] ;
00691
00692 int numSlices ;
00693 int displayedSlicesNum ;
00694 int displayedSlices[360] ;
00695 float slicesPercentages[360] ;
00696 SbString slicesValuesString[360] ;
00697 SbString slicesPercentagesString[360] ;
00698 float slicesValues[360] ;
00699 float slicesTranslation[360] ;
00700
00701 int slicesLowValuesNumbers ;
00702
00703 char endLineChar ;
00704 int lineLength ;
00705 } ;
00706
00707 PieChartAttr m_pieChartAttr ;
00708
00709 enum AnnotPosPieChart {
00710 RIGHT_PIE_CHART,
00711 LEFT_PIE_CHART,
00712 UP_PIE_CHART,
00713 DOWN_PIE_CHART
00714 } ;
00715
00716
00717 PoPieChart(SbBool isDefault=TRUE, float _radius=1., short numSlices=0,
00718 const char **_sliceTexts=NULL, const float *_sliceValues=NULL,
00719 int numSliceColors=0, const SbColor *_sliceColors=NULL) ;
00720
00721 virtual ~PoPieChart() ;
00722
00723
00724 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00725 virtual void setDefaultOnNonWritingFields() ;
00726 virtual void basicObjectChange(PbBase *basicObj) ;
00727
00728
00729 void savePieChartAttr() ;
00730
00731
00732 void computeSlicePartValuesToDisplay() ;
00733
00734
00735
00736 void computeStringsToDisplay(const float *values, int numValues, SbBool isPercentage) ;
00737
00738
00739 void drawInternalAnnotations(const SbVec2f &pieChartCenter, const SbVec2f &pointz) ;
00740
00741
00742 void drawInternalAnnot(int sliceNum, const SbVec2f &annotCenterPoint, const SbVec2f &pointz,
00743 AnnotPosPieChart annotPosPieChart, int nbAnnot, float rotateAnnotAngle,
00744 PiText *intText, PiText *intValue, PiText *intPercent,
00745 SoGroup *intAnnotBoxGroup, SoGroup *intAnnotBoxBorderGroup) ;
00746
00747
00748 void drawExternalAnnotations(const SbVec2f &pieChartCenter, const SbVec2f &pointz) ;
00749
00750
00751 void drawExternalAnnot(int sliceNum, const SbVec3f &arrowStartPoint, const SbVec2f &pointz,
00752 AnnotPosPieChart annotPosPieChart, int nbAnnot, float rotateAnnotAngle,
00753 PiText *extText, PiText *extValue, PiText *extPercent,
00754 SoGroup *extAnnotBoxGroup, SoGroup *extAnnotBoxBorderGroup) ;
00755
00756
00757 void resetAllPart() ;
00758
00759
00760 void computeSliceNames() ;
00761
00762
00763 virtual void addElementsAllCaches() ;
00764 virtual void preRebuild() ;
00765
00766 private:
00767
00768 PbMiscTextAttr *m_miscTextAttr, m_defaultMiscTextAttr ;
00769
00770
00771 PbNumericDisplayFormat *m_numericDisplayFormat, m_defaultNumericDisplayFormat ;
00772
00773
00774 FieldSensorList m_fieldSensorList ;
00775
00776
00777 SoFieldList m_fieldList ;
00778
00779 } ;
00780
00781
00782
00783 #endif
00784
00785