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