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_BASE_
00025 #define  _PO_BASE_
00026 
00027 class    PbBase ;
00028 class    SoAction ;
00029 class    SoFieldSensor ;
00030 class    PbDataMapping ;
00031 class    SoMaterial;
00032 class    SoMaterialBinding;
00033 class    SoQuadMesh;
00034 class    SoIndexedTriangleStripSet;
00035 class    SoIndexedFaceSet;
00036 class    SoIndexedLineSet;
00037 class    SoLineSet;
00038 class    SoCache ;
00039 class    SoShape;
00040 
00041 #include <MeshViz/PoMeshViz.h>
00042 #include <MeshViz/PbBasic.h>
00043 #include <MeshViz/graph/PbDomain.h>
00044 
00045 #include <Inventor/nodekits/SoBaseKit.h>
00046 #include <Inventor/nodekits/SoAppearanceKit.h>
00047 #include <Inventor/nodes/SoLightModel.h>
00048 #include <Inventor/nodes/SoDrawStyle.h>
00049 #include <Inventor/nodes/SoCallback.h>
00050 #include <Inventor/caches/SoCache.h>
00051 
00052 #define PO_KIT_ADD_FIELD(_fieldName,_defValue,_fieldList)\
00053         _fieldList.append(&_fieldName) ;\
00054         SO_KIT_ADD_FIELD(_fieldName, _defValue) ;
00055 
00074 class  PoBase : public SoBaseKit {
00075 
00076   SO_KIT_ABSTRACT_HEADER(PoBase) ;
00077 
00078   SO_KIT_CATALOG_ENTRY_HEADER(catchActionCallback) ;
00079   SO_KIT_CATALOG_ENTRY_HEADER(alternateRep)   ;
00080   SO_KIT_CATALOG_ENTRY_HEADER(catchActionLevel2Callback) ;
00081   SO_KIT_CATALOG_ENTRY_HEADER(appearance)   ;
00082   SO_KIT_CATALOG_ENTRY_HEADER(domainTransform)   ;
00083 
00084 
00085  public:
00086 
00087 
00088 
00092   enum UpdateMethodType {
00096     UPDATE_METHOD_IMMEDIATE,
00100     UPDATE_METHOD_ON_ACTION
00101   } ;
00102 
00106   enum NodeWriteFormat {
00110     FOLD_NODE_WRITE_FORMAT,
00114     UNFOLD_NODE_WRITE_FORMAT
00115   } ;
00116 
00120   enum TextType {
00121     SO_TEXT3,
00122     SO_ANNO_TEXT3
00123   } ;
00124 
00125 
00129   typedef void PoRebuildCB(void *userData, PoBase *base) ;
00130 
00143   void setUpdateMethod(UpdateMethodType type) { m_updateMethodType = type ; }
00144 
00148   UpdateMethodType getUpdateMethod() const    { return m_updateMethodType ; }
00149 
00163   static void setNodeWriteFormat(NodeWriteFormat format);
00164 
00168   static NodeWriteFormat getNodeWriteFormat();
00169 
00176   void setDomain(PbDomain *dom) ;
00177 
00182   const PbDomain* getDomain() const ;
00183 
00187   void touchKit() ;
00188 
00192   SbBool isModified() const { return m_hasBeenModified ; }
00193 
00197   SbBool isBuilt() const
00198     { return m_isObjBuilt ; }
00199 
00211   virtual void  rebuild() {} ;
00212 
00218   void addPreRebuildCallback(PoRebuildCB *cb, void *data)  ;
00219 
00225   void addPostRebuildCallback(PoRebuildCB *cb, void *data) ;
00226 
00227 
00233   void removePreRebuildCallback(PoRebuildCB *cb, void *data=NULL)  ;
00234 
00240   void removePostRebuildCallback(PoRebuildCB *cb, void *data) ;
00241 
00252   static void setTextType(TextType type) ;
00253 
00257   static TextType getTextType();
00258 
00276   static void   setVRML2Mode(SbBool flag) ;
00277 
00281   static SbBool isVRML2Mode() ;
00282 
00286   virtual SoNode *copy(SbBool copyConnections = FALSE) const ;
00287 
00291   virtual SbBool affectsState() const ;
00292 
00293   
00294  private:
00295 
00301   static void init() ;
00302     static void finish() ;
00303   static bool isInitialized();
00304 
00305   static void initClass() ;
00306     static void exitClass() ;
00307 
00308   
00309   virtual void write(SoWriteAction *action) ;
00310 
00311   
00312   virtual void basicObjectChange(PbBase *basicObj) ;
00313 
00314   
00315   void enableDomainTransform(SbBool flag)
00316     { m_isDomainTrans = flag ; }
00317 
00318   SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00319                                SoGroup *group);
00320   SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00321                                SoQuadMesh *shape, SoGroup *father_of_shape, int child_index);
00322   SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00323                                SoIndexedTriangleStripSet *shape, SoGroup *father_of_shape, int child_index);
00324   SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00325                                SoIndexedFaceSet *shape, SoGroup *father_of_shape, int child_index);
00326   SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00327                                SoIndexedLineSet *shape, SoGroup *father_of_shape, int child_index);
00328   SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00329                                SoLineSet *shape, SoGroup *father_of_shape, int child_index);
00330 
00331   void setStateValid( bool isStateValid )
00332   {
00333     m_isStateValid = isStateValid;
00334   }
00335 
00336   
00337   void     setState( SoAction* action );
00338   SoState* getState() const;
00339 
00340   private:
00341   
00342   virtual void        GLRender(SoGLRenderAction *action);
00343 
00344  private:
00345   
00346   struct FieldSensorList {
00347     int           numSensors ;
00348     SoFieldSensor **sensors ;
00349   } ;
00350 
00351   
00352   
00353   
00354   
00355   PoBase(SoCallbackCB *actionCallback=NULL) ;
00356   virtual ~PoBase() ;
00357 
00358   
00359   virtual void  setDefaultOnNonWritingFields() ;
00360   virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00361 
00362    
00363   virtual void        copyContents(const SoFieldContainer *fromFC,
00364                                    SbBool copyConnections);
00365 
00366   
00367   void changeConnection(PbBase *oldObj, PbBase *newObj) ;
00368 
00369   
00370   virtual void manageBasicObjectChange(PbBase *basicObj, PbBase **obj) ;
00371 
00372   
00373   SbBool isFieldHasChanged(const SoField *field) ;
00374 
00375   
00376   SbBool isAnyFieldsHasChanged()
00377     { return m_someFieldsHasChanged ; }
00378 
00379   
00380   void emptyListFieldsChanged() { m_listFieldsChanged.truncate(0) ; }
00381 
00382   
00383   void setListFieldsDefault(const SoFieldList &fieldLst) ;
00384 
00385   
00386   void setDomainTransform(PbDomain *domain) ;
00387 
00388   
00389   SbBool isDomainTransformEnabled() const
00390     { return m_isDomainTrans ; }
00391 
00392   
00393   void setDomainUsedForRebuild(SbBool flag)
00394     { m_isDomUseForRebuild = flag ; }
00395 
00396   
00397   SbBool isDomainUsedForRebuild() const
00398     { return m_isDomUseForRebuild ; }
00399 
00400   
00401   virtual void preRebuild() ;
00402 
00403   
00404   virtual void postRebuild() ;
00405 
00406   
00407   void setLightModel(SoLightModel::Model model) ;
00408 
00409   
00410   void setDrawStyleAK(const SbString& partName, SoDrawStyle::Style style=SoDrawStyle::LINES) ;
00411 
00412   
00413   
00414   void storeFieldsChanged(SbBool store)
00415     { needToStoreFieldsChanged = store ; }
00416 
00417   
00418   
00419   
00420   void createFieldSensorList(int numFields, FieldSensorList *sensorList) ;
00421   void deleteFieldSensorList(FieldSensorList *sensorList) ;
00422   void attachFieldSensorList(const FieldSensorList &sensorList,
00423                              const SoFieldList &fieldList) ;
00424   void detachFieldSensorList(const FieldSensorList &sensorList) ;
00425   static void fieldSensorCB(void *data, SoSensor *sensor) ;
00426 
00427   
00428   
00429   SbBool isStateValid() const
00430     { return m_isStateValid ; }
00431 
00432   
00433   
00434   template<typename T>
00435   void addElementCache()
00436   {
00437     if(isStateValid() && !isCacheValid())
00438       m_cache->addElement(getState()->template getConstElement<T>());
00439   }
00440 
00441 
00442   
00443   
00444   void rebuildCache(SoCache **cache) ;
00445 
00446   
00447   
00448   
00449   virtual void addElementsAllCaches() ;
00450 
00451   
00452   
00453   
00454   
00455   
00456   void setCacheAlwaysRebuild(SbBool flag)
00457     { m_isCacheAlwaysRebuild = flag ; }
00458   SbBool isCacheAlwaysRebuild() const
00459     { return m_isCacheAlwaysRebuild ; }
00460 
00461 
00462   
00463   SbBool isCacheValid() const
00464     { return m_isCacheValid ; }
00465 
00466   
00467   SoFieldList      m_listFieldsChanged ;
00468   SbBool           needToStoreFieldsChanged ;
00469 
00470   
00471   SbBool           m_isStateValid ;
00472 
00473  private:
00474   
00475   UpdateMethodType m_updateMethodType ;
00476   SbBool           m_hasBeenModified ;
00477   SbBool           m_isObjBuilt ;
00478   SbBool           m_isDomainTrans ;
00479   SbBool           m_isDomUseForRebuild ;
00480   SbBool           m_someFieldsHasChanged ;
00481   PbDomain         *m_domain, m_defaultDomain ;
00482   SoCallbackCB     *m_actionCallback ;
00483 
00484   SbBool           m_hasBeenBuilt ;
00485 
00486   
00487   
00488   
00489   
00490   SbBool           m_isCacheAlwaysRebuild ;
00491 
00492   
00493   SoState          *m_currentState ;
00494 
00495   
00496   SoCache          *m_cache ;
00497 
00498   
00499   SoCache          *m_domainCache ;
00500 
00501   
00502   SbBool           m_isCacheValid ;
00503 
00504   
00505   SoWriteAction    *m_currentWriteAction ;
00506 
00507   PoRebuildCB      *m_preRebuildCB, *m_postRebuildCB ;
00508   void             *m_preRebuildData, *m_postRebuildData ;
00509 
00510   
00511   SbBox3f m_domainBoxCache;
00512   PbDomain::TransformType m_domainTransformTypeCache;
00513 
00514   
00515   static NodeWriteFormat m_nodeWriteFormat ;
00516   static TextType        m_textType ;
00517   static SbBool          m_isVRML2Mode ;
00518 
00519   
00520   static void catchActionCB(void *, SoAction *) ;
00521   static void catchActionLevel2CB(void *, SoAction *) ;
00522 
00523   
00524   static int s_initRefCount;
00525 
00526   static SbString s_soLdmValuationAction;
00527 } ;
00528 
00529 
00530 #endif 
00531 
00532