From 5ec17c314ef7141a712e6b04653225446d743c57 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 26 Jan 2011 12:02:38 +0000 Subject: [PATCH] Move WITH_SALOMEDS_OBSERVER definition to configure.ac (to have it in the single place) --- configure.ac | 2 + src/SalomeApp/SalomeApp_Application.cxx | 3 - src/SalomeApp/SalomeApp_DataModel.cxx | 3 - src/SalomeApp/SalomeApp_Study.cxx | 110 ++++++++++++------------ 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/configure.ac b/configure.ac index dac158ee4..737fc0075 100644 --- a/configure.ac +++ b/configure.ac @@ -587,6 +587,8 @@ if test "$DISABLE_PYCONSOLE" = "no" ; then AC_DEFINE(SUIT_ENABLE_PYTHON) fi +dnl Build with GUI observers feature +AC_DEFINE(WITH_SALOMEDS_OBSERVER) echo echo --------------------------------------------- diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 51f08e2fd..35fd12d3c 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -97,9 +97,6 @@ #include -//To activate update of Object Browser with SALOMEDS::Observer uncomment following line -#define WITH_SALOMEDS_OBSERVER - /*!Internal class that updates object browser item properties */ // temporary commented /*class SalomeApp_Updater : public OB_Updater diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 0de502175..34c0192d4 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -38,9 +38,6 @@ #include #include CORBA_SERVER_HEADER(SALOME_Exception) -//To activate update of Object Browser with SALOMEDS::Observer uncomment following line -#define WITH_SALOMEDS_OBSERVER - typedef _PTR(SObject) kerPtr; typedef SUIT_DataObject* suitPtr; diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 74b9808cb..ee458a24b 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -47,12 +47,12 @@ using namespace std; -//To activate update of Object Browser with SALOMEDS::Observer uncomment following line -#define WITH_SALOMEDS_OBSERVER - class SalomeApp_Study::Observer_i : public virtual POA_SALOMEDS::Observer { - public: + typedef std::map EntryMap; + typedef std::map::iterator EntryMapIter; + +public: Observer_i(_PTR(Study) aStudyDS, SalomeApp_Study* aStudy) { @@ -63,46 +63,48 @@ class SalomeApp_Study::Observer_i : public virtual POA_SALOMEDS::Observer virtual void notifyObserverID(const char* theID, CORBA::Long event) { + // MESSAGE("notifyObserverID: theID:" << theID << " event:" << event); + SalomeApp_DataObject* suit_obj; - if (event == 1) // add sobject + if ( event == 1 ) // add sobject { - std::map::iterator it0 = entry2SuitObject.find(theID); - if (it0 != entry2SuitObject.end()) + EntryMapIter it = entry2SuitObject.find( theID ); + if ( it != entry2SuitObject.end() ) { - std::cerr << "entry " << theID << " is already added. Problem ??" << std::endl; + MESSAGE("Entry " << theID << " is already added. Problem ??"); return; } + _PTR(SObject) obj = myStudyDS->FindObjectID( theID ); std::string entry_str = theID; - int last2Pnt_pos = entry_str.rfind(":"); - std::string parent_id=entry_str.substr(0,last2Pnt_pos); - std::string pos_in_parent=entry_str.substr(last2Pnt_pos+1); - int tag=atoi(pos_in_parent.c_str()); + int last2Pnt_pos = entry_str.rfind( ":" ); + std::string parent_id = entry_str.substr( 0, last2Pnt_pos ); + int tag = atoi( entry_str.substr( last2Pnt_pos+1 ).c_str() ); - if(parent_id.length() == 3 ) + if ( parent_id.length() == 3 ) // "0:1" - root item? { - //It's probably a SComponent - _PTR(SComponent) aSComp=obj->GetFatherComponent(); - if( aSComp->GetID() == entry_str ) - suit_obj=new SalomeApp_ModuleObject(aSComp,0); + // It's probably a SComponent + _PTR(SComponent) aSComp = obj->GetFatherComponent(); + if ( aSComp->GetID() == entry_str ) + suit_obj = new SalomeApp_ModuleObject( aSComp ); else - suit_obj=new SalomeApp_DataObject(obj,0); + suit_obj = new SalomeApp_DataObject( obj ); } else { - suit_obj=new SalomeApp_DataObject(obj,0); + suit_obj = new SalomeApp_DataObject( obj ); } - std::map::iterator it=entry2SuitObject.find(parent_id); - if (it != entry2SuitObject.end()) + it = entry2SuitObject.find( parent_id ); + if ( it != entry2SuitObject.end() ) { - SalomeApp_DataObject* father=it->second; - father->insertChildAtTag(suit_obj,tag); + SalomeApp_DataObject* father = it->second; + father->insertChildAtTag( suit_obj, tag ); } else { - if(parent_id.length() == 3 ) + if ( parent_id.length() == 3 ) // "0:1" - root item? { // This should be for a module SUIT_DataObject* father=myStudy->root(); @@ -110,47 +112,49 @@ class SalomeApp_Study::Observer_i : public virtual POA_SALOMEDS::Observer } else { + MESSAGE("SHOULD NEGER GET HERE!!!"); + //Try to find the SalomeApp_DataObject object parent - std::string root_id=parent_id.substr(0,4); - std::string obj_id=parent_id.substr(4); + std::string root_id = parent_id.substr( 0, 4 ); + std::string obj_id = parent_id.substr( 4 ); std::string anID; - string::size_type debut =0; + string::size_type debut = 0; string::size_type fin; - SalomeApp_DataObject* anObj=dynamic_cast(myStudy->root()); - while(1) + SalomeApp_DataObject* anObj = dynamic_cast( myStudy->root() ); + while ( 1 ) { - fin=obj_id.find_first_of(':',debut); - if(fin == std::string::npos) + fin = obj_id.find_first_of( ':', debut ); + if ( fin == std::string::npos ) { //last id - anObj = dynamic_cast(anObj->childObject(atoi(obj_id.substr(debut).c_str())-1)); - entry2SuitObject[parent_id]=anObj; + anObj = dynamic_cast( anObj->childObject( atoi( obj_id.substr( debut ).c_str() )-1 ) ); + entry2SuitObject[parent_id] = anObj; break; } - anID=root_id+obj_id.substr(0,fin); - std::map::iterator it2=entry2SuitObject.find(anID); - if (it2 == entry2SuitObject.end()) + anID = root_id + obj_id.substr( 0, fin ); + EntryMapIter it2 = entry2SuitObject.find( anID ); + if ( it2 == entry2SuitObject.end() ) { //the ID is not known in entry2SuitObject - anObj = dynamic_cast(anObj->childObject(atoi(obj_id.substr(debut,fin-debut).c_str())-1)); - entry2SuitObject[anID]=anObj; + anObj = dynamic_cast( anObj->childObject( atoi( obj_id.substr( debut, fin-debut ).c_str() )-1 ) ); + entry2SuitObject[anID] = anObj; } else - anObj= it2->second; - debut=fin+1; + anObj = it2->second; + debut = fin+1; } - anObj->insertChildAtTag(suit_obj,tag); + anObj->insertChildAtTag( suit_obj, tag ); } } - entry2SuitObject[theID]=suit_obj; + entry2SuitObject[theID] = suit_obj; } - else if (event == 2) // remove sobject + else if ( event == 2 ) // remove sobject { - std::map::iterator it=entry2SuitObject.find(theID); - if (it != entry2SuitObject.end()) + EntryMapIter it = entry2SuitObject.find( theID ); + if ( it != entry2SuitObject.end() ) { - suit_obj= it->second; + suit_obj = it->second; // VSR: object is not removed, since SALOMEDS::SObject is not actually removed, only its attributes are cleared; // thus, the object can be later reused suit_obj->updateItem(); @@ -161,15 +165,15 @@ class SalomeApp_Study::Observer_i : public virtual POA_SALOMEDS::Observer } else { - MESSAGE("Want to remove an unknown object" << theID); + MESSAGE("Want to remove an unknown object" << theID); } } - else if (event == 0) //modify sobject + else if ( event == 0 ) //modify sobject { - std::map::iterator it=entry2SuitObject.find(theID); - if (it != entry2SuitObject.end()) + EntryMapIter it = entry2SuitObject.find( theID ); + if ( it != entry2SuitObject.end() ) { - suit_obj= it->second; + suit_obj = it->second; suit_obj->updateItem(); } else @@ -217,9 +221,9 @@ private: } private: - _PTR(Study) myStudyDS; + _PTR(Study) myStudyDS; SalomeApp_Study* myStudy; - std::map entry2SuitObject; + EntryMap entry2SuitObject; }; -- 2.39.2