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
00075 class PoBase : public SoBaseKit {
00076
00077 SO_KIT_ABSTRACT_HEADER(PoBase) ;
00078
00079 SO_KIT_CATALOG_ENTRY_HEADER(catchActionCallback) ;
00080 SO_KIT_CATALOG_ENTRY_HEADER(alternateRep) ;
00081 SO_KIT_CATALOG_ENTRY_HEADER(catchActionLevel2Callback) ;
00082 SO_KIT_CATALOG_ENTRY_HEADER(appearance) ;
00083 SO_KIT_CATALOG_ENTRY_HEADER(domainTransform) ;
00084
00085
00086 public:
00087
00088
00089
00093 enum UpdateMethodType {
00097 UPDATE_METHOD_IMMEDIATE,
00101 UPDATE_METHOD_ON_ACTION
00102 } ;
00103
00107 enum NodeWriteFormat {
00111 FOLD_NODE_WRITE_FORMAT,
00115 UNFOLD_NODE_WRITE_FORMAT
00116 } ;
00117
00121 enum TextType {
00122 SO_TEXT3,
00123 SO_ANNO_TEXT3
00124 } ;
00125
00126
00130 typedef void PoRebuildCB(void *userData, PoBase *base) ;
00131
00144 void setUpdateMethod(UpdateMethodType type) { m_updateMethodType = type ; }
00145
00149 UpdateMethodType getUpdateMethod() const { return m_updateMethodType ; }
00150
00165 static void setNodeWriteFormat(NodeWriteFormat format);
00166
00170 static NodeWriteFormat getNodeWriteFormat();
00171
00178 void setDomain(PbDomain *dom) ;
00179
00184 const PbDomain* getDomain() const ;
00185
00189 void touchKit() ;
00190
00194 SbBool isModified() const { return m_hasBeenModified ; }
00195
00199 SbBool isBuilt() const
00200 { return m_isObjBuilt ; }
00201
00213 virtual void rebuild() {} ;
00214
00220 void addPreRebuildCallback(PoRebuildCB *cb, void *data) ;
00221
00227 void addPostRebuildCallback(PoRebuildCB *cb, void *data) ;
00228
00229
00235 void removePreRebuildCallback(PoRebuildCB *cb, void *data=NULL) ;
00236
00242 void removePostRebuildCallback(PoRebuildCB *cb, void *data) ;
00243
00254 static void setTextType(TextType type) ;
00255
00259 static TextType getTextType();
00260
00278 static void setVRML2Mode(SbBool flag) ;
00279
00283 static SbBool isVRML2Mode() ;
00284
00288 virtual SoNode *copy(SbBool copyConnections = FALSE) const ;
00289
00293 virtual SbBool affectsState() const ;
00294
00295
00296 private:
00297
00303 static void init() ;
00304 static void finish() ;
00305 static bool isInitialized();
00306
00307 static void initClass() ;
00308 static void exitClass() ;
00309
00310
00311 virtual void write(SoWriteAction *action) ;
00312
00313
00314 virtual void basicObjectChange(PbBase *basicObj) ;
00315
00316
00317 void enableDomainTransform(SbBool flag)
00318 { m_isDomainTrans = flag ; }
00319
00320 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00321 SoGroup *group);
00322 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00323 SoQuadMesh *shape, SoGroup *father_of_shape, int child_index);
00324 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00325 SoIndexedTriangleStripSet *shape, SoGroup *father_of_shape, int child_index);
00326 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00327 SoIndexedFaceSet *shape, SoGroup *father_of_shape, int child_index);
00328 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00329 SoIndexedLineSet *shape, SoGroup *father_of_shape, int child_index);
00330 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
00331 SoLineSet *shape, SoGroup *father_of_shape, int child_index);
00332
00333 void setStateValid( bool isStateValid )
00334 {
00335 m_isStateValid = isStateValid;
00336 }
00337
00338
00339 void setState( SoAction* action );
00340 SoState* getState() const;
00341
00342 private:
00343
00344 virtual void GLRender(SoGLRenderAction *action);
00345
00346 private:
00347
00348 struct FieldSensorList {
00349 int numSensors ;
00350 SoFieldSensor **sensors ;
00351 } ;
00352
00353
00354
00355
00356
00357 PoBase(SoCallbackCB *actionCallback=NULL) ;
00358 virtual ~PoBase() ;
00359
00360
00361 virtual void setDefaultOnNonWritingFields() ;
00362 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00363
00364
00365 virtual void copyContents(const SoFieldContainer *fromFC,
00366 SbBool copyConnections);
00367
00368
00369 void changeConnection(PbBase *oldObj, PbBase *newObj) ;
00370
00371
00372 virtual void manageBasicObjectChange(PbBase *basicObj, PbBase **obj) ;
00373
00374
00375 SbBool isFieldHasChanged(const SoField *field) ;
00376
00377
00378 SbBool isAnyFieldsHasChanged()
00379 { return m_someFieldsHasChanged ; }
00380
00381
00382 void emptyListFieldsChanged() { m_listFieldsChanged.truncate(0) ; }
00383
00384
00385 void setListFieldsDefault(const SoFieldList &fieldLst) ;
00386
00387
00388 void setDomainTransform(PbDomain *domain) ;
00389
00390
00391 SbBool isDomainTransformEnabled() const
00392 { return m_isDomainTrans ; }
00393
00394
00395 void setDomainUsedForRebuild(SbBool flag)
00396 { m_isDomUseForRebuild = flag ; }
00397
00398
00399 SbBool isDomainUsedForRebuild() const
00400 { return m_isDomUseForRebuild ; }
00401
00402
00403 virtual void preRebuild() ;
00404
00405
00406 virtual void postRebuild() ;
00407
00408
00409 void setLightModel(SoLightModel::Model model) ;
00410
00411
00412 void setDrawStyleAK(const SbString& partName, SoDrawStyle::Style style=SoDrawStyle::LINES) ;
00413
00414
00415
00416 void storeFieldsChanged(SbBool store)
00417 { needToStoreFieldsChanged = store ; }
00418
00419
00420
00421
00422 void createFieldSensorList(int numFields, FieldSensorList *sensorList) ;
00423 void deleteFieldSensorList(FieldSensorList *sensorList) ;
00424 void attachFieldSensorList(const FieldSensorList &sensorList,
00425 const SoFieldList &fieldList) ;
00426 void detachFieldSensorList(const FieldSensorList &sensorList) ;
00427 static void fieldSensorCB(void *data, SoSensor *sensor) ;
00428
00429
00430
00431 SbBool isStateValid() const
00432 { return m_isStateValid ; }
00433
00434
00435
00436 template<typename T>
00437 void addElementCache()
00438 {
00439 if(isStateValid() && !isCacheValid())
00440 m_cache->addElement(getState()->template getConstElement<T>());
00441 }
00442
00443
00444
00445
00446 void rebuildCache(SoCache **cache) ;
00447
00448
00449
00450
00451 virtual void addElementsAllCaches() ;
00452
00453
00454
00455
00456
00457
00458 void setCacheAlwaysRebuild(SbBool flag)
00459 { m_isCacheAlwaysRebuild = flag ; }
00460 SbBool isCacheAlwaysRebuild() const
00461 { return m_isCacheAlwaysRebuild ; }
00462
00463
00464
00465 SbBool isCacheValid() const
00466 { return m_isCacheValid ; }
00467
00468
00469 SoFieldList m_listFieldsChanged ;
00470 SbBool needToStoreFieldsChanged ;
00471
00472
00473 SbBool m_isStateValid ;
00474
00475 private:
00476
00477 UpdateMethodType m_updateMethodType ;
00478 SbBool m_hasBeenModified ;
00479 SbBool m_isObjBuilt ;
00480 SbBool m_isDomainTrans ;
00481 SbBool m_isDomUseForRebuild ;
00482 SbBool m_someFieldsHasChanged ;
00483 PbDomain *m_domain, m_defaultDomain ;
00484 SoCallbackCB *m_actionCallback ;
00485
00486 SbBool m_hasBeenBuilt ;
00487
00488
00489
00490
00491
00492 SbBool m_isCacheAlwaysRebuild ;
00493
00494
00495 SoState *m_currentState ;
00496
00497
00498 SoCache *m_cache ;
00499
00500
00501 SoCache *m_domainCache ;
00502
00503
00504 SbBool m_isCacheValid ;
00505
00506
00507 SoWriteAction *m_currentWriteAction ;
00508
00509 PoRebuildCB *m_preRebuildCB, *m_postRebuildCB ;
00510 void *m_preRebuildData, *m_postRebuildData ;
00511
00512
00513 static NodeWriteFormat m_nodeWriteFormat ;
00514 static TextType m_textType ;
00515 static SbBool m_isVRML2Mode ;
00516
00517
00518 static void catchActionCB(void *, SoAction *) ;
00519 static void catchActionLevel2CB(void *, SoAction *) ;
00520
00521
00522 static int s_initRefCount;
00523
00524 static SbString s_soLdmValuationAction;
00525 } ;
00526
00527
00528 #endif
00529
00530