X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISU_I%2FVISU_Gen_i.cc;h=d71de33b3c930fdeab493ec47a6b08a681e2eb22;hb=9560b540f09562b08da956cb0988791d36a41d33;hp=11ffff01971cb8f75ac337130fd868705091bf2c;hpb=22270d5d7b703fee59bd48ce61a73eaa05f124d9;p=modules%2Fvisu.git diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 11ffff01..d71de33b 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -404,41 +404,54 @@ namespace VISU{ return Base_i::GetID(); } - void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy) + void VISU_Gen_i::SetCurrentStudy (SALOMEDS::Study_ptr theStudy) { + class TEvent: public SALOME_Event { + std::string myStudyName; + public: + TEvent(const std::string theStudyName):myStudyName(theStudyName) + {} + virtual void Execute() + { + bool isActive = false; + SUIT_Session* aSession = SUIT_Session::session(); + QPtrList anApplications = aSession->applications(); + QPtrListIterator anIter (anApplications); + SUIT_Application* aFirstApp = anIter.current(); + while (SUIT_Application* anApp = anIter.current()) { + ++anIter; + if (SUIT_Study* aSStudy = anApp->activeStudy()) { + if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { + if (_PTR(Study) aCStudy = aStudy->studyDS()) { + MESSAGE("There is an application with active study : StudyId = " + << aCStudy->StudyId() << "; Name = '" << aCStudy->Name() << "'"); + if (myStudyName == aCStudy->Name()) { + isActive = true; + break; + } + } + } + } + } + if (!isActive) { + MESSAGE("!!! anApp->onLoadDoc(myStudyName) !!!"); + // Has to be loaded in an empty or in a new application + SalomeApp_Application* anApp = dynamic_cast(aFirstApp); + anApp->onLoadDoc(myStudyName); + } + } + }; + if (!CORBA::is_nil(theStudy)) { CORBA::String_var aName = theStudy->Name(); - QString aStudyName (aName.in()); - MESSAGE("VISU_Gen_i::SetCurrentStudy - StudyId = " << - theStudy->StudyId() << "; Name = '" << aName.in() << "'"); + std::string aStudyName (aName.in()); + MESSAGE("StudyId = " << theStudy->StudyId() << "; Name = '" << aName.in() << "'"); myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); - MESSAGE("Find application for study : " << aName.in()); - bool isActive = false; - SUIT_Session* aSession = SUIT_Session::session(); - QPtrList anApplications = aSession->applications(); - QPtrListIterator anIter (anApplications); - SUIT_Application* aFirstApp = anIter.current(); - while (SUIT_Application* anApp = anIter.current()) { - ++anIter; - if (SUIT_Study* aSStudy = anApp->activeStudy()) { - if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { - MESSAGE("There is an application with active study : " << aStudy->studyName()); - if (aStudyName == aStudy->studyName()) { - isActive = true; - break; - } - } - } - } - if (!isActive) { - // Has to be loaded in an empty or in a new application - SalomeApp_Application* anApp = dynamic_cast(aFirstApp); - anApp->onLoadDoc(aName.in()); - } + ProcessVoidEvent(new TEvent(aStudyName)); } else { - MESSAGE("VISU_Gen_i::SetCurrentStudy : CORBA::is_nil(theStudy)"); + MESSAGE("CORBA::is_nil(theStudy)"); } } @@ -496,31 +509,33 @@ namespace VISU{ return aResult._retn(); } - Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){ - if(myStudyDocument->GetProperties()->IsLocked()) + Result_ptr VISU_Gen_i::ImportMed (SALOMEDS::SObject_ptr theMedSObject) + { + if (myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); Mutex mt(myMutex); Result_i* pResult = new Result_i(myStudyDocument, Result_i::eComponent, Result_i::eImportMed); - if(pResult->Create(theMedSObject) != NULL) + if (pResult->Create(theMedSObject) != NULL) { return pResult->_this(); - else{ + } else { pResult->_remove_ref(); return VISU::Result::_nil(); } } - Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){ - if(myStudyDocument->GetProperties()->IsLocked()) + Result_ptr VISU_Gen_i::ImportMedField (SALOME_MED::FIELD_ptr theField) + { + if (myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); Mutex mt(myMutex); Result_i* pResult = new Result_i(myStudyDocument, Result_i::eComponent, Result_i::eImportMedField); - if(pResult->Create(theField) != NULL) + if (pResult->Create(theField) != NULL) { return pResult->_this(); - else{ + } else { pResult->_remove_ref(); return VISU::Result::_nil(); } @@ -739,7 +754,7 @@ namespace VISU{ for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) { if (it.Value()->hasEntry()) { std::string aCurEntry (it.Value()->getEntry()); - if (aCurEntry != anEntry) { + if (aCurEntry != std::string( anEntry.in() ) ) { aNewListIO.Append(it.Value()); } } @@ -1031,5 +1046,4 @@ namespace VISU{ anIOR->SetValue(anIORValue); return aResultSO._retn(); } - }