]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To use Modified method of SUIT_Study to notify about implict modification in SALOMEDS...
authorapo <apo@opencascade.com>
Wed, 1 Aug 2007 09:38:18 +0000 (09:38 +0000)
committerapo <apo@opencascade.com>
Wed, 1 Aug 2007 09:38:18 +0000 (09:38 +0000)
src/VISU_I/VISUConfig.cc
src/VISU_I/VISUConfig.hh
src/VISU_I/VISU_Prs3dUtils.cc
src/VISU_I/VISU_PrsObject_i.cc
src/VISU_I/VISU_PrsObject_i.hh

index 312941a4fbd8283f9467e4bd929b3b79cb30200e..8e7eb323ce746bf1eece1932abb5c8dff843551c 100644 (file)
@@ -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<SUIT_Application> anApplications = aSession->applications();
       QPtrListIterator<SUIT_Application> anIter (anApplications);
@@ -730,8 +735,8 @@ namespace VISU
        if (SUIT_Study* aSStudy = anApp->activeStudy()) {
          if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(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() );
   }
 
 
index 6c16eda2864464369ab62ca6192371950f2d09e8..94f11eec775381df17bdcca49bcf3a855833112e 100644 (file)
@@ -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
index feb2bd401ab265ed23ca68d0e52d918de97ba8a4..abd189da42fecffba2325366cc79e23622fc1826 100644 (file)
@@ -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));
   }
 
 
index a87ca5e855b5b81855bfa99bf0e505d9ce050305..b6ab264c9c54cb23f7b0dc44a290db18743717d1 100644 (file)
@@ -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();
index 3fe235541cd18578be18a53368a1d62fa4958756..08e95ef88c44db04086e7027d1ecc05217fe6db3 100644 (file)
@@ -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&);
   };