From: apo Date: Wed, 1 Aug 2007 09:38:18 +0000 (+0000) Subject: To use Modified method of SUIT_Study to notify about implict modification in SALOMEDS... X-Git-Tag: mergeto_BR_Dev_For_4_0_30Aug07~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=20d70b8932a58d864e739cba008b731071ddfdf9;p=modules%2Fvisu.git To use Modified method of SUIT_Study to notify about implict modification in SALOMEDS::Study --- diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 312941a4..8e7eb323 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -709,19 +709,24 @@ namespace VISU //--------------------------------------------------------------- struct TGetStudyEvent: public SALOME_Event { - int myStudyId; + SALOMEDS::Study_var myStudy; - typedef _PTR(Study) TResult; + typedef SalomeApp_Study* TResult; TResult myResult; - TGetStudyEvent(int theStudyId): - myStudyId(theStudyId) + TGetStudyEvent(SALOMEDS::Study_ptr theStudy): + myStudy(SALOMEDS::Study::_duplicate(theStudy)), + myResult(NULL) {} virtual void Execute() { + if(CORBA::is_nil(myStudy)) + return; + + int aStudyId = myStudy->StudyId(); SUIT_Session* aSession = SUIT_Session::session(); QPtrList anApplications = aSession->applications(); QPtrListIterator anIter (anApplications); @@ -730,8 +735,8 @@ namespace VISU if (SUIT_Study* aSStudy = anApp->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { - if (myStudyId == aCStudy->StudyId()) { - myResult = aCStudy; + if (aStudyId == aCStudy->StudyId()) { + myResult = aStudy; break; } } @@ -742,11 +747,22 @@ namespace VISU }; + //--------------------------------------------------------------- + SalomeApp_Study* + GetGUIStudy(SALOMEDS::Study_ptr theStudy) + { + return ProcessEvent(new TGetStudyEvent(theStudy)); + } + + //--------------------------------------------------------------- _PTR(Study) - GetStudy(SALOMEDS::Study_var theStudy) + GetStudy(SALOMEDS::Study_ptr theStudy) { - return ProcessEvent(new TGetStudyEvent(theStudy->StudyId())); + if(SalomeApp_Study* aStudy = ProcessEvent(new TGetStudyEvent(theStudy))) + return aStudy->studyDS(); + + return _PTR(Study)(); } @@ -762,12 +778,11 @@ namespace VISU //--------------------------------------------------------------- _PTR(SObject) - GetClientSObject( SALOMEDS::SObject_var obj, - _PTR(Study) study ) + GetClientSObject(SALOMEDS::SObject_ptr theSObject, + _PTR(Study) theStudy) { - CORBA::String_var anEntry = obj->GetID(); - return study->FindObjectID( anEntry.in() ); - + CORBA::String_var anEntry = theSObject->GetID(); + return theStudy->FindObjectID( anEntry.in() ); } diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index 6c16eda2..94f11eec 100644 --- a/src/VISU_I/VISUConfig.hh +++ b/src/VISU_I/VISUConfig.hh @@ -63,6 +63,8 @@ class SUIT_Session; class SUIT_ResourceMgr; +class SalomeApp_Study; + namespace VISU { @@ -313,15 +315,20 @@ namespace VISU VISU_I_EXPORT _PTR(SObject) - GetClientSObject(SALOMEDS::SObject_var, _PTR(Study)); + GetClientSObject(SALOMEDS::SObject_ptr theSObject, + _PTR(Study) theStudy); VISU_I_EXPORT SALOMEDS::Study_var - GetDSStudy(_PTR(Study)); + GetDSStudy(_PTR(Study) theStudy); + + VISU_I_EXPORT + SalomeApp_Study* + GetGUIStudy(SALOMEDS::Study_ptr theStudy); VISU_I_EXPORT _PTR(Study) - GetStudy(SALOMEDS::Study_var); + GetStudy(SALOMEDS::Study_ptr theStudy); VISU_I_EXPORT void diff --git a/src/VISU_I/VISU_Prs3dUtils.cc b/src/VISU_I/VISU_Prs3dUtils.cc index feb2bd40..abd189da 100644 --- a/src/VISU_I/VISU_Prs3dUtils.cc +++ b/src/VISU_I/VISU_Prs3dUtils.cc @@ -25,7 +25,8 @@ // Module : VISU #include "VISU_Prs3dUtils.hh" -#include "VISU_PipeLine.hxx" +#include "SalomeApp_Study.h" +#include "SALOME_Event.hxx" namespace VISU @@ -43,13 +44,32 @@ namespace VISU TSetModified ::~TSetModified() { - if(myPrs3d->GetActorEntry() == "") - return; + struct TEvent: public SALOME_Event + { + VISU::TSetModified* mySetModified; + TEvent(VISU::TSetModified* theSetModified): + mySetModified(theSetModified) + {} + + virtual + void + Execute() + { + VISU::Prs3d_i* aPrs3d = mySetModified->myPrs3d; - if(myPrs3d->GetMTime() > this->GetMTime()){ - SALOMEDS::Study_var aStudy = myPrs3d->GetStudyDocument(); - aStudy->Modified(); - } + if(!aPrs3d || aPrs3d->GetActorEntry() == "") + return; + + if(aPrs3d->GetMTime() > mySetModified->GetMTime()){ + if(SalomeApp_Study* aStudy = aPrs3d->GetGUIStudy()){ + aPrs3d->GetStudyDocument()->Modified(); + aStudy->Modified(); + } + } + } + }; + + ProcessVoidEvent(new TEvent(this)); } diff --git a/src/VISU_I/VISU_PrsObject_i.cc b/src/VISU_I/VISU_PrsObject_i.cc index a87ca5e8..b6ab264c 100644 --- a/src/VISU_I/VISU_PrsObject_i.cc +++ b/src/VISU_I/VISU_PrsObject_i.cc @@ -56,9 +56,9 @@ VISU::RemovableObject_i { myName = theName; if(theIsUpdateStudyAttr){ - SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(GetEntry().c_str()); + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(GetEntry().c_str()); if(!aSObject->_is_nil()){ - SALOMEDS::StudyBuilder_var aBuilder = myStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aBuilder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute( aSObject, "AttributeName" ); SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr ); aNameAttr->SetValue( theName.c_str() ); @@ -81,7 +81,16 @@ SALOMEDS::Study_var VISU::RemovableObject_i ::GetStudyDocument() const { - return myStudy; + return myStudyDocument; +} + + +//--------------------------------------------------------------- +SalomeApp_Study* +VISU::RemovableObject_i +::GetGUIStudy() const +{ + return myGUIStudy; } @@ -90,7 +99,8 @@ void VISU::RemovableObject_i ::SetStudyDocument(SALOMEDS::Study_ptr theStudy) { - myStudy = SALOMEDS::Study::_duplicate(theStudy); + myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); + myGUIStudy = VISU::GetGUIStudy(theStudy); } @@ -100,7 +110,7 @@ VISU::RemovableObject_i ::GetEntry() { CORBA::String_var anIOR = GetID(); - SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(anIOR.in()); + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectIOR(anIOR.in()); CORBA::String_var anEntry(""); if(!CORBA::is_nil(aSObject.in())) anEntry = aSObject->GetID(); diff --git a/src/VISU_I/VISU_PrsObject_i.hh b/src/VISU_I/VISU_PrsObject_i.hh index 3fe23554..08e95ef8 100644 --- a/src/VISU_I/VISU_PrsObject_i.hh +++ b/src/VISU_I/VISU_PrsObject_i.hh @@ -44,6 +44,9 @@ namespace VISU SALOMEDS::Study_var GetStudyDocument() const; + SalomeApp_Study* + GetGUIStudy() const; + virtual std::string GetEntry(); @@ -65,7 +68,8 @@ namespace VISU private: std::string myName; - SALOMEDS::Study_var myStudy; + SalomeApp_Study* myGUIStudy; + SALOMEDS::Study_var myStudyDocument; RemovableObject_i(const RemovableObject_i&); };