Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
PoPieChart.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24#ifndef _PO_PIE_CHART_
25#define _PO_PIE_CHART_
26
27#include <Inventor/fields/SoSFEnum.h>
28#include <Inventor/fields/SoSFFloat.h>
29#include <Inventor/fields/SoMFFloat.h>
30#include <Inventor/fields/SoMFString.h>
31#include <Inventor/fields/SoSFString.h>
32#include <Inventor/fields/SoSFBool.h>
33#include <Inventor/fields/SoMFShort.h>
34#include <Inventor/fields/SoMFColor.h>
35
36#include <MeshViz/graph/PoGraphMaster.h>
37#include <MeshViz/graph/PbMiscTextAttr.h>
38#include <MeshViz/graph/PbNumericDisplayFormat.h>
39
40class PiText ;
41
136class PoPieChart : public PoGraphMaster {
137 SO_KIT_HEADER(PoPieChart) ;
138
139 /* Define fields for new parts */
140 SO_KIT_CATALOG_ENTRY_HEADER(sliceSep) ;
141 SO_KIT_CATALOG_ENTRY_HEADER(sliceApp) ;
142 SO_KIT_CATALOG_ENTRY_HEADER(slice) ;
143
144 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorderSep) ;
145 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorderApp) ;
146 SO_KIT_CATALOG_ENTRY_HEADER(sliceBorder) ;
147
148 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxSep) ;
149 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxApp) ;
150 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBox) ;
151
152 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorderSep) ;
153 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorderApp) ;
154 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotBoxBorder) ;
155
156 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotTextSep) ;
157 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotTextApp) ;
158 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotText) ;
159
160 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValueSep) ;
161 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValueApp) ;
162 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotValue) ;
163
164 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercentSep) ;
165 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercentApp) ;
166 SO_KIT_CATALOG_ENTRY_HEADER(extAnnotPercent) ;
167
168 SO_KIT_CATALOG_ENTRY_HEADER(arrowSep) ;
169 SO_KIT_CATALOG_ENTRY_HEADER(arrowApp) ;
170 SO_KIT_CATALOG_ENTRY_HEADER(arrow) ;
171
172 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxSep) ;
173 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxApp) ;
174 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBox) ;
175
176 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorderSep) ;
177 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorderApp) ;
178 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotBoxBorder) ;
179
180 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotTextSep) ;
181 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotTextApp) ;
182 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotText) ;
183
184 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValueSep) ;
185 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValueApp) ;
186 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotValue) ;
187
188 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercentSep) ;
189 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercentApp) ;
190 SO_KIT_CATALOG_ENTRY_HEADER(intAnnotPercent) ;
191
192
193 public:
194
208
234
260
261#ifdef ABSOLUTE
262
263#undef ABSOLUTE
264
265#endif
266
267
268
276
277
278
279
280
281 /* Fields */
282
287
288
289
290 /* Slice attributes */
291
299
307
314
315
316
317 /* Internal annotation attributes */
318
323
328
333
338
344
350
355
363
371
379
387
394
402
410
411
412
413 /* External annotation attributes */
414
419
424
429
434
439
445
450
458
466
474
482
489
497
504
512
520
521
522
523 /* Arrow attributes */
524
529
534
539
540
541
542 /* Small value regrouping attributes */
543
549
554
561
566
567
568
569 /* Slices to translate attributes */
570
578
584
591
592
593
594
595
596 /* Methods */
597
605
610
619
625
635 SbBool getPickedSliceNumber(const SoPath *path, int &sliceNumber) const ;
636
646 void setSliceToTranslate(int sliceNumber, float translateValue) ;
647
653 float getSliceToTranslate(int sliceNumber) const ;
654
655 /*----------------------------------------------------------------------------*/
656 private:
657 static void initClass() ;
658 static void exitClass() ;
659
660 private:
661 // Computed by GraphMaster attributes
662 struct PieChartAttr {
663 SbString intTextFontName ;
664 float intTextFontSize ;
665
666 SbString extTextFontName ;
667 float extTextFontSize ;
668
669 SbString intValFontName ;
670 float intValFontSize ;
671
672 SbString extValFontName ;
673 float extValFontSize ;
674
675 SbString intPercentFontName ;
676 float intPercentFontSize ;
677
678 SbString extPercentFontName ;
679 float extPercentFontSize ;
680
681 float intDist ;
682
683 float extDist1 ;
684 float extDist2 ;
685 float extDist3 ;
686
687 float arrowWidth ;
688 float arrowHeight ;
689
690 SbString sliceNames[360] ;
691
692 int numSlices ;
693 int displayedSlicesNum ;
694 int displayedSlices[360] ;
695 float slicesPercentages[360] ;
696 SbString slicesValuesString[360] ;
697 SbString slicesPercentagesString[360] ;
698 float slicesValues[360] ;
699 float slicesTranslation[360] ;
700
701 int slicesLowValuesNumbers ;
702
703 char endLineChar ;
704 int lineLength ;
705 } ;
706
707 PieChartAttr m_pieChartAttr ;
708
709 enum AnnotPosPieChart { // Position of an annotation relative to the Pie Chart
710 RIGHT_PIE_CHART,
711 LEFT_PIE_CHART,
712 UP_PIE_CHART,
713 DOWN_PIE_CHART
714 } ;
715
716 // Constructors
717 PoPieChart(SbBool isDefault=TRUE, float _radius=1., short numSlices=0,
718 const char **_sliceTexts=NULL, const float *_sliceValues=NULL,
719 int numSliceColors=0, const SbColor *_sliceColors=NULL) ;
720 // Destructor
721 virtual ~PoPieChart() ;
722
723 // Methods
724 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
725 virtual void setDefaultOnNonWritingFields() ;
726 virtual void basicObjectChange(PbBase *basicObj) ;
727
728 // Save all pie chart attributes which can be modified by MeshViz.
729 void savePieChartAttr() ;
730
731 // Compute slice part values to display.
732 void computeSlicePartValuesToDisplay() ;
733
734 // Compute percentage or value (following isPercentage flag)
735 // strings to display with the request numeric display format.
736 void computeStringsToDisplay(const float *values, int numValues, SbBool isPercentage) ;
737
738 // Draw internal annotations
739 void drawInternalAnnotations(const SbVec2f &pieChartCenter, const SbVec2f &pointz) ;
740
741 // Draw an internal annotation
742 void drawInternalAnnot(int sliceNum, const SbVec2f &annotCenterPoint, const SbVec2f &pointz,
743 AnnotPosPieChart annotPosPieChart, int nbAnnot, float rotateAnnotAngle,
744 PiText *intText, PiText *intValue, PiText *intPercent,
745 SoGroup *intAnnotBoxGroup, SoGroup *intAnnotBoxBorderGroup) ;
746
747 // Draw external annotations
748 void drawExternalAnnotations(const SbVec2f &pieChartCenter, const SbVec2f &pointz) ;
749
750 // Draw an external annotation
751 void drawExternalAnnot(int sliceNum, const SbVec3f &arrowStartPoint, const SbVec2f &pointz,
752 AnnotPosPieChart annotPosPieChart, int nbAnnot, float rotateAnnotAngle,
753 PiText *extText, PiText *extValue, PiText *extPercent,
754 SoGroup *extAnnotBoxGroup, SoGroup *extAnnotBoxBorderGroup) ;
755
756 // Set all part to NULL
757 void resetAllPart() ;
758
759 // Compute slice names
760 void computeSliceNames() ;
761
762 // Overloaded methods
763 virtual void addElementsAllCaches() ;
764 virtual void preRebuild() ;
765
766 private:
767 // Miscellaneous text attributes
768 PbMiscTextAttr *m_miscTextAttr, m_defaultMiscTextAttr ;
769
770 // Numeric Display format
771 PbNumericDisplayFormat *m_numericDisplayFormat, m_defaultNumericDisplayFormat ;
772
773 // Sensors
774 FieldSensorList m_fieldSensorList ;
775
776 // List of fields defined in this class
777 SoFieldList m_fieldList ;
778
779} ;
780
781/*----------------------------------------------------------------------------*/
782
783#endif /* _PO_PIE_CHART_ */
784
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract class for all b...
Definition PbBase.h:49
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Class to define a numeri...
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Class to define a numeri...
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract base class for ...
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract class for pie c...
Definition PoPieChart.h:136
const PbMiscTextAttr * getMiscTextAttr() const
Gets a reference to a PbMiscTextAttr for miscellaneous text attributes.
void setSliceToTranslate(int sliceNumber, float translateValue)
Convenience methods to set the fields sliceToTranslateNumber and sliceToTranslateValue.
SoSFBool arrowVisibility
Visibility of the arrow.
Definition PoPieChart.h:528
SoSFFloat sliceAngleStep
Slice are approximated by a polygon, that is a sequence of straight line segments.
Definition PoPieChart.h:590
SoSFFloat arrowHeight
Height of the arrow.
Definition PoPieChart.h:533
SoSFString extAnnotPercentFontName
Exterior percentage font name.
Definition PoPieChart.h:488
SoSFFloat extAnnotDistance3
Distance from the middle of the arrow to the start of the arrow.
Definition PoPieChart.h:519
SoSFString extAnnotTextFontName
Exterior text (texts of sliceText field) font name.
Definition PoPieChart.h:457
SoMFFloat sliceToTranslateValue
Translation values along the bisectors of the slices.
Definition PoPieChart.h:583
SoSFFloat arrowWidth
Width of the arrow.
Definition PoPieChart.h:538
SoSFFloat extAnnotDistance2
Distance from the end of the arrow to the middle of the arrow.
Definition PoPieChart.h:511
SoSFFloat intAnnotTextFontSize
Font size of interior texts (texts of sliceText field).
Definition PoPieChart.h:370
const PbNumericDisplayFormat * getFormat() const
Gets a reference to a PbNumericDisplayFormat object for the numerical display format of values of the...
Alignment
Type of annotation alignment.
Definition PoPieChart.h:238
@ INWARDS_ALIGN
Annotations are aligned inward the pie chart.
Definition PoPieChart.h:254
@ LEFT_ALIGN
Annotations are aligned on the left of the annotation box.
Definition PoPieChart.h:242
@ RIGHT_ALIGN
Annotations are aligned on the right of the annotation box.
Definition PoPieChart.h:250
@ OUTWARDS_ALIGN
Annotations are aligned outward the pie chart.
Definition PoPieChart.h:258
@ CENTER_ALIGN
Annotations are aligned on the center of the annotation box.
Definition PoPieChart.h:246
void setMiscTextAttr(PbMiscTextAttr *textAttr)
Sets a reference to a PbMiscTextAttr for miscellaneous text attributes.
SoSFEnum intAnnotPosition
Interior annotation position.
Definition PoPieChart.h:322
SoSFString intAnnotValueFontName
Interior value (values of sliceValue field) font name.
Definition PoPieChart.h:378
SoSFBool intAnnotPercentVisibility
Interior percent visibility (percent are computed from sliceValue field)
Definition PoPieChart.h:343
SoSFFloat extAnnotPercentFontSize
Font size of exterior percentages.
Definition PoPieChart.h:496
ExtAnnotPosition
Type of external annotation position.
Definition PoPieChart.h:212
@ SQUARE_ALIGNED_EXT_POS
Exterior annotations are aligned on a square.
Definition PoPieChart.h:232
@ HOR_EXT_POS
Exterior annotations are horizontal.
Definition PoPieChart.h:220
@ RADIAL_EXT_POS
Exterior annotations are radial to the slices.
Definition PoPieChart.h:216
@ VERT_ALIGNED_EXT_POS
Exterior annotations are vertically aligned.
Definition PoPieChart.h:228
@ HOR_ALIGNED_EXT_POS
Exterior annotations are horizontally aligned.
Definition PoPieChart.h:224
SbBool getPickedSliceNumber(const SoPath *path, int &sliceNumber) const
Allow the user to retreive the slice number (sliceNumber argument) which has been picked from a picke...
SoSFFloat intAnnotDistance
Distance from the pie chart center to the interior annotation box center.
Definition PoPieChart.h:409
SoSFFloat extAnnotDistance1
Distance from the pie chart center to the end of the arrow.
Definition PoPieChart.h:503
SoSFBool intAnnotValueVisibility
Interior value visibility (values of sliceValue field).
Definition PoPieChart.h:337
SoSFFloat extAnnotTextFontSize
Font size of exterior texts (texts of sliceText field).
Definition PoPieChart.h:465
SoSFBool intAnnotAddStringVisibility
Specify the visibility of a string concatenated with the interior values (if they are visible).
Definition PoPieChart.h:349
SoSFBool extAnnotPercentVisibility
Exterior percent visibility (percent are computed from sliceValue field)
Definition PoPieChart.h:438
SoSFString intAnnotTextFontName
Interior text (texts of sliceText field) font name.
Definition PoPieChart.h:362
SoSFString sliceGroupString
String for the regrouping slice.
Definition PoPieChart.h:565
SoMFString sliceText
Text associated to each slice of the pie chart.
Definition PoPieChart.h:298
IntAnnotPosition
Type of internal annotation position.
Definition PoPieChart.h:198
@ RADIAL_INT_POS
Interior annotations are radial to the slices.
Definition PoPieChart.h:202
@ HOR_INT_POS
Interior annotations are horizontal.
Definition PoPieChart.h:206
SoSFEnum extAnnotAlignment
Exterior annotation alignment.
Definition PoPieChart.h:423
SoSFBool intAnnotTextVisibility
Interior text visibility (texts of sliceText field).
Definition PoPieChart.h:332
SoSFFloat intAnnotValueFontSize
Font size of interior values (values of sliceValue field).
Definition PoPieChart.h:386
SoSFBool extAnnotTextVisibility
Exterior text visibility (texts of sliceText field).
Definition PoPieChart.h:428
SoSFFloat radius
Radius of the pie chart.
Definition PoPieChart.h:286
SoSFString intAnnotAddString
String concatened with interior values.
Definition PoPieChart.h:354
SoMFFloat sliceValue
Value associated to each slice of the pie chart.
Definition PoPieChart.h:306
SoSFFloat intAnnotPercentFontSize
Font size of interior percentages.
Definition PoPieChart.h:401
SoSFBool extAnnotAddStringVisibility
Specify the visibility of a string concatenated with the exterior values (if they are visible).
Definition PoPieChart.h:444
SoSFFloat extAnnotValueFontSize
Font size of exterior values (values of sliceValue field).
Definition PoPieChart.h:481
SoSFString extAnnotValueFontName
Exterior value (values of sliceValue field) font name.
Definition PoPieChart.h:473
SoSFString extAnnotAddString
String concatened with exterior values.
Definition PoPieChart.h:449
SoSFBool extAnnotValueVisibility
Exterior value visibility (values of sliceValue field).
Definition PoPieChart.h:433
SoMFShort sliceToTranslateNumber
Numbers (slice numbers begin at 0) of the slices to translate.
Definition PoPieChart.h:577
SoSFEnum extAnnotPosition
Exterior annotation position.
Definition PoPieChart.h:418
SoSFString intAnnotPercentFontName
Interior percentage font name.
Definition PoPieChart.h:393
float getSliceToTranslate(int sliceNumber) const
Gets the current translation of a slice.
SoSFEnum sliceGroupFlagMin
Indicate if the value sliceGroupMinValue is interpreted as percentage (PERCENTAGE) or not (ABSOLUTE).
Definition PoPieChart.h:560
SoSFFloat sliceGroupMinValue
Threshold underneath the slice are regrouped.
Definition PoPieChart.h:553
SoSFBool sliceGroupActive
Activate or Deactivate the regrouping of small values.
Definition PoPieChart.h:548
SoMFColor sliceColor
Color associated to each slice of the pie chart.
Definition PoPieChart.h:313
SoSFEnum intAnnotAlignment
Interior annotation alignment.
Definition PoPieChart.h:327
void setFormat(PbNumericDisplayFormat *format)
Sets a reference to a PbNumericDisplayFormat object for the numerical display format of values of the...
PercentStatus
Type of threshold for the grouping slice.
Definition PoPieChart.h:272
Color vector class.
Definition SbColor.h:82
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:76
3D vector class.
Definition SbVec.h:932
Maintains a list of pointers to fields.
Definition SoFieldList.h:72
Base class for all group nodes.
Definition SoGroup.h:122
Multiple-value field containing any number of RGB colors stored as three floats.
Definition SoMFColor.h:98
Multiple-value field containing any number of floating point values.
Definition SoMFFloat.h:90
Multiple-value field containing any number of short integers.
Definition SoMFShort.h:89
Multiple-value field containing any number of strings.
Definition SoMFString.h:116
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Field containing a single Boolean value.
Definition SoSFBool.h:79
Field containing an enumerated value.
Definition SoSFEnum.h:89
Field containing a floating-point value.
Definition SoSFFloat.h:78
Field containing a string.
Definition SoSFString.h:117
int SbBool
Boolean type.
Definition SbBase.h:87