00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 #ifndef _PO_PIE_CHART_REP_ 00025 #define _PO_PIE_CHART_REP_ 00026 00027 #include <MeshViz/graph/PoChart.h> 00028 00029 #include <Inventor/fields/SoSFBool.h> 00030 #include <Inventor/fields/SoSFFloat.h> 00031 #include <Inventor/fields/SoMFFloat.h> 00032 #include <Inventor/fields/SoMFShort.h> 00033 #include <Inventor/fields/SoSFString.h> 00034 00035 class SoTranslation ; 00036 class PbMesh1D ; 00037 00101 class PoPieChartRep : public PoChart { 00102 00103 SO_KIT_HEADER(PoPieChartRep) ; 00104 00105 /* Define fields for new parts */ 00106 SO_KIT_CATALOG_ENTRY_HEADER(sliceSep) ; 00107 SO_KIT_CATALOG_ENTRY_HEADER(sliceApp) ; 00108 SO_KIT_CATALOG_ENTRY_HEADER(slice) ; 00109 00110 SO_KIT_CATALOG_ENTRY_HEADER(annotationSep) ; 00111 SO_KIT_CATALOG_ENTRY_HEADER(annotationApp) ; 00112 SO_KIT_CATALOG_ENTRY_HEADER(annotation) ; 00113 00114 SO_KIT_CATALOG_ENTRY_HEADER(annotationLineSep) ; 00115 SO_KIT_CATALOG_ENTRY_HEADER(annotationLineApp) ; 00116 SO_KIT_CATALOG_ENTRY_HEADER(annotationLine) ; 00117 00118 00119 public: 00120 00121 /* Fields */ 00122 00128 SoSFInt32 stringsIndex ; 00129 00134 SoSFFloat radiusMin ; 00135 00139 SoSFFloat radiusMax ; 00140 00145 SoMFShort sliceToTranslateNumber ; 00146 00152 SoMFFloat sliceToTranslateRadius ; 00153 00158 SoSFFloat height ; 00159 00165 SoSFBool isNameVisible ; 00166 00170 SoSFBool isValueVisible ; 00171 00175 SoSFBool isPercentageVisible ; 00176 00181 SoSFFloat annoDistToCenter ; 00182 00187 SoSFFloat annoHeightFromSlice ; 00188 00192 SoSFFloat annoFontSize ; 00193 00197 SoSFBool isAnnoSliceColor ; 00198 00202 PoPieChartRep() ; 00203 00212 SbBool getPickedSliceNumber(const SoPath *path, int &sliceNumber) const ; 00213 00224 void setSliceToTranslate(int sliceNumber, float radius) ; 00225 00231 float getSliceToTranslate(int sliceNumber) const ; 00232 00233 /*----------------------------------------------------------------------------*/ 00234 00235 00236 private: 00237 static void initClass() ; 00238 static void exitClass() ; 00239 00240 private: 00241 struct SliceAttr { 00242 float startAngle ; 00243 float endAngle ; 00244 float value ; 00245 float height ; 00246 SbString nameStr ; 00247 SbString percentageStr ; 00248 SbString valueStr ; 00249 SoMaterial *material ; 00250 SoTranslation *translation ; 00251 } ; 00252 00253 virtual ~PoPieChartRep() ; 00254 // Destructor. 00255 00256 // Overloaded methods 00257 virtual void rebuild() ; 00258 virtual void addElementsAllCaches() ; 00259 virtual void preRebuild() ; 00260 00261 // Methods 00262 virtual void setDefaultOnNonWritingFields() ; 00263 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ; 00264 00265 private: 00266 inline SbBool isAnnoText() const ; 00267 void eraseAllParts() ; 00268 void buildSliceAttrList(const PbMesh1D *mesh1D, float &maxSliceHeight, 00269 SbBool &isConstantHeight) ; 00270 void buildSliceText(int sliceIndex, float maxSliceHeight, SoGroup *annoGroup, 00271 SoGroup *annoLineGroup) ; 00272 00273 // Data 00274 SliceAttr *m_sliceAttrList ; 00275 int m_numSliceAttr ; 00276 00277 // Sensors 00278 FieldSensorList fieldSensorList ; 00279 00280 // List of fields defined in this class 00281 SoFieldList fieldList ; 00282 } ; 00283 00284 /*----------------------------------------------------------------------------*/ 00285 00286 #endif /* _PO_PIE_CHART_REP_ */ 00287 00288