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 private:
00334
00335 virtual void GLRender(SoGLRenderAction *action);
00336
00337 private:
00338
00339 struct FieldSensorList {
00340 int numSensors ;
00341 SoFieldSensor **sensors ;
00342 } ;
00343
00344
00345
00346
00347
00348 PoBase(SoCallbackCB *actionCallback=NULL) ;
00349 virtual ~PoBase() ;
00350
00351
00352 virtual void setDefaultOnNonWritingFields() ;
00353 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00354
00355
00356 virtual void copyContents(const SoFieldContainer *fromFC,
00357 SbBool copyConnections);
00358
00359
00360 void changeConnection(PbBase *oldObj, PbBase *newObj) ;
00361
00362
00363 virtual void manageBasicObjectChange(PbBase *basicObj, PbBase **obj) ;
00364
00365
00366 SbBool isFieldHasChanged(const SoField *field) ;
00367
00368
00369 SbBool isAnyFieldsHasChanged()
00370 { return m_someFieldsHasChanged ; }
00371
00372
00373 void emptyListFieldsChanged() { m_listFieldsChanged.truncate(0) ; }
00374
00375
00376 void setListFieldsDefault(const SoFieldList &fieldLst) ;
00377
00378
00379 void setDomainTransform(PbDomain *domain) ;
00380
00381
00382 SbBool isDomainTransformEnabled() const
00383 { return m_isDomainTrans ; }
00384
00385
00386 void setDomainUsedForRebuild(SbBool flag)
00387 { m_isDomUseForRebuild = flag ; }
00388
00389
00390 SbBool isDomainUsedForRebuild() const
00391 { return m_isDomUseForRebuild ; }
00392
00393
00394 virtual void preRebuild() ;
00395
00396
00397 virtual void postRebuild() ;
00398
00399
00400 void setLightModel(SoLightModel::Model model) ;
00401
00402
00403 void setDrawStyleAK(const SbString& partName, SoDrawStyle::Style style=SoDrawStyle::LINES) ;
00404
00405
00406
00407 void storeFieldsChanged(SbBool store)
00408 { needToStoreFieldsChanged = store ; }
00409
00410
00411
00412
00413 void createFieldSensorList(int numFields, FieldSensorList *sensorList) ;
00414 void deleteFieldSensorList(FieldSensorList *sensorList) ;
00415 void attachFieldSensorList(const FieldSensorList &sensorList,
00416 const SoFieldList &fieldList) ;
00417 void detachFieldSensorList(const FieldSensorList &sensorList) ;
00418 static void fieldSensorCB(void *data, SoSensor *sensor) ;
00419
00420
00421 void setState(SoAction *action) ;
00422 SoState* getState() const ;
00423
00424
00425
00426 SbBool isStateValid() const
00427 { return m_isStateValid ; }
00428
00429
00430
00431 template<typename T>
00432 void addElementCache()
00433 {
00434 if(isStateValid() && !isCacheValid())
00435 m_cache->addElement(getState()->template getConstElement<T>());
00436 }
00437
00438
00439
00440
00441 void rebuildCache(SoCache **cache) ;
00442
00443
00444
00445
00446 virtual void addElementsAllCaches() ;
00447
00448
00449
00450
00451
00452
00453 void setCacheAlwaysRebuild(SbBool flag)
00454 { m_isCacheAlwaysRebuild = flag ; }
00455 SbBool isCacheAlwaysRebuild() const
00456 { return m_isCacheAlwaysRebuild ; }
00457
00458
00459
00460 SbBool isCacheValid() const
00461 { return m_isCacheValid ; }
00462
00463
00464 SoFieldList m_listFieldsChanged ;
00465 SbBool needToStoreFieldsChanged ;
00466
00467
00468 SbBool m_isStateValid ;
00469
00470 private:
00471
00472 UpdateMethodType m_updateMethodType ;
00473 SbBool m_hasBeenModified ;
00474 SbBool m_isObjBuilt ;
00475 SbBool m_isDomainTrans ;
00476 SbBool m_isDomUseForRebuild ;
00477 SbBool m_someFieldsHasChanged ;
00478 PbDomain *m_domain, m_defaultDomain ;
00479 SoCallbackCB *m_actionCallback ;
00480
00481 SbBool m_hasBeenBuilt ;
00482
00483
00484
00485
00486
00487 SbBool m_isCacheAlwaysRebuild ;
00488
00489
00490 SoState *m_currentState ;
00491
00492
00493 SoCache *m_cache ;
00494
00495
00496 SoCache *m_domainCache ;
00497
00498
00499 SbBool m_isCacheValid ;
00500
00501
00502 SoWriteAction *m_currentWriteAction ;
00503
00504 PoRebuildCB *m_preRebuildCB, *m_postRebuildCB ;
00505 void *m_preRebuildData, *m_postRebuildData ;
00506
00507
00508 static NodeWriteFormat m_nodeWriteFormat ;
00509 static TextType m_textType ;
00510 static SbBool m_isVRML2Mode ;
00511
00512
00513 static void catchActionCB(void *, SoAction *) ;
00514 static void catchActionLevel2CB(void *, SoAction *) ;
00515
00516
00517 static int s_initRefCount;
00518
00519 static SbString s_soLdmValuationAction;
00520 } ;
00521
00522
00523 #endif
00524
00525