Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / VISU_I / VISU_Gen_i.cc
index 11ffff01971cb8f75ac337130fd868705091bf2c..d225b3d04f4da5be2ce56f9ee4afc0a7d68694fa 100644 (file)
 #include "VISU_CutLines_i.hh"
 #include "VISU_Vectors_i.hh"
 #include "VISU_StreamLines_i.hh"
+#include "VISU_GaussPoints_i.hh"
+#include "VISU_Plot3D_i.hh"
 #include "VISU_Table_i.hh"
 #include "VISU_TimeAnimation.h"
+#include "VISU_ScalarMapOnDeformedShape_i.hh"
 
 #include "VISU_Actor.h"
 
@@ -52,7 +55,7 @@
 #include "SUIT_Session.h"
 #include "SalomeApp_Study.h"
 #include "SalomeApp_Application.h"
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_SelectionMgr.h"
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewWindow.h"
 #include "SALOME_Event.hxx"
 #include <strstream>
 
 #include "Utils_ExceptHandlers.hxx"
+#include "CASCatch.hxx"
 
 using namespace std;
 
 static QFileInfo aFileInfo;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
+//#define _DEXCEPT_
 #else
 static int MYDEBUG = 0;
 #endif
@@ -106,7 +111,8 @@ extern "C" VISU::VISU_Gen_ptr GetImpl(CORBA::ORB_ptr theORB,
   return aVISU_Gen->_this();
 }
 
-namespace VISU{
+namespace VISU
+{
   static string VisuTmpDir;
 
   static CORBA::Boolean myIsMultiFile;
@@ -185,15 +191,18 @@ namespace VISU{
     Storable::Registry(Result_i::myComment.c_str(),&(Result_i::Restore));
     Storable::Registry(Mesh_i::myComment.c_str(),&(Restore<Mesh_i>));
     Storable::Registry(ScalarMap_i::myComment.c_str(),&(Restore<ScalarMap_i>));
+    Storable::Registry(GaussPoints_i::myComment.c_str(),&(Restore<GaussPoints_i>));
     Storable::Registry(DeformedShape_i::myComment.c_str(),&(Restore<DeformedShape_i>));
     Storable::Registry(CutPlanes_i::myComment.c_str(),&(Restore<CutPlanes_i>));
     Storable::Registry(CutLines_i::myComment.c_str(),&(Restore<CutLines_i>));
     Storable::Registry(IsoSurfaces_i::myComment.c_str(),&(Restore<IsoSurfaces_i>));
     Storable::Registry(StreamLines_i::myComment.c_str(),&(Restore<StreamLines_i>));
+    Storable::Registry(Plot3D_i::myComment.c_str(),&(Restore<Plot3D_i>));
     Storable::Registry(Vectors_i::myComment.c_str(),&(Restore<Vectors_i>));
     Storable::Registry(Table_i::myComment.c_str(),&(Table_i::Restore));
     Storable::Registry(Curve_i::myComment.c_str(),&(Curve_i::Restore));
     Storable::Registry(Container_i::myComment.c_str(),&(Container_i::Restore));
+    Storable::Registry(ScalarMapOnDeformedShape_i::myComment.c_str(),&(Restore<ScalarMapOnDeformedShape_i>));
   }
 
 
@@ -223,6 +232,33 @@ namespace VISU{
       if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : there is no opened study in StudyManager !!!");
   }
 
+  bool
+  CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
+                   const char* theMeshName, 
+                   VISU::Entity theEntity,
+                   const char* theFieldName, 
+                   CORBA::Double theIteration)
+  {
+    CASCatch_TRY{       
+#ifndef _DEXCEPT_
+      try{
+#endif
+       if(theColoredPrs3d->Create(theMeshName,theEntity,theFieldName,int(theIteration)))
+         return true;
+#ifndef _DEXCEPT_
+      }catch(std::exception& exc){
+       INFOS("Follow exception was occured :\n"<<exc.what());
+      }catch(...){
+       INFOS("Unknown exception was occured!");
+      }
+#endif
+    }CASCatch_CATCH(Standard_Failure) {
+      Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+      INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
+    }
+    return false;
+  }
+
   VISU_Gen_i::~VISU_Gen_i(){
     if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
   }
@@ -235,8 +271,8 @@ namespace VISU{
     Mutex mt(myMutex);
     SALOMEDS::Study_var aStudy = theComponent->GetStudy();
     SALOMEDS::StudyBuilder_var  aStudyBuilder = aStudy->NewBuilder();
-    const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str();
-    TCollection_AsciiString aTmpDir(const_cast<char*>(aDir));
+    string aDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
+    TCollection_AsciiString aTmpDir (const_cast<char*>(aDir.c_str()));
     VisuTmpDir = aTmpDir.ToCString();
     SALOMEDS::ListOfFileNames_var aSeq =
       SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(),isMultiFile);
@@ -269,58 +305,69 @@ namespace VISU{
   //===========================================================================
   SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
                                      const char* theURL,
-                                     bool isMultiFile)
+                                     bool theIsMultiFile)
   {
     Mutex mt(myMutex);
-    const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str();
-    TCollection_AsciiString aTmpDir(const_cast<char*>(aDir));
+    string aTmpDir = theURL;
     if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
-    int aCounter = 0;
-    TColStd_SequenceOfAsciiString aFileNames;
-    SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+    
+    typedef std::vector<std::string> TFileNames;
+    TFileNames aFileNames;
+    TFileNames aFiles;
 
-    //CORBA::Boolean anIsValidScript;
-    //Engines::TMPFile_var aDump = DumpPython(aStudy,false,anIsValidScript);
-
-    SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
-    for (; itBig->More(); itBig->Next()) {
-      SALOMEDS::SObject_var gotBranch = itBig->Value();
+    SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+    SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
+    for (; anIter->More(); anIter->Next()) {
+      SALOMEDS::SObject_var gotBranch = anIter->Value();
       CORBA::Object_var anObj = SObjectToObject(gotBranch);
       if(CORBA::is_nil(anObj)) continue;
-      if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
-       switch(pResult->GetCreationId()){
+      if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+       switch(aResult->GetCreationId()){
        case Result_i::eImportFile:
        case Result_i::eCopyAndImportFile: {
-         const QFileInfo& aFileInfo = pResult->GetFileInfo();
-         QString aPrefix("");
-         if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()).c_str();
-         QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
-         static QString aCommand;
-         aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
-
-         int aRes = system(aCommand);
-         if(aRes){
-           if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"<<aCommand);
-           continue;
-         }else
-           if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aCommand = "<<aCommand);
-
-         TCollection_AsciiString aString(strdup(aFileName.latin1()));
-         aFileNames.Append(aString);
+         const QFileInfo& aFileInfo = aResult->GetFileInfo();
+         const std::string& aName = aResult->GetName();
+         std::string aFileName = std::string("_") + aName;
+         std::string aFile = aFileInfo.filePath().latin1();
+         if(theIsMultiFile){
+           aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()) + aFileName;
+
+           std::ostringstream aStream;
+           aStream<<"cp "<<aFile<<" "<<aTmpDir<<aFileName;
+           std::string aCommand = aStream.str();
+           if(system(aCommand.c_str()) != 0){
+             INFOS("VISU_Gen_i::Save - Cann't execute the command :"<<aCommand);
+             continue;
+           }
+         }
+         aFileNames.push_back(aFileName);
+         aFiles.push_back(aFile);
        }}
       }
     }
-    SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
-    if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.Length() - "<<aFileNames.Length());
-    if(aFileNames.Length() > 0){
-      SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
-      aSeq->length(aFileNames.Length());
-      for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--)
-       aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString());
-      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
-      if(!isMultiFile)
-       SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.size() - "<<aFileNames.size());
+
+    SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
+    if(!aFileNames.empty()){
+      aListOfFileNames->length(aFileNames.size());
+      for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--)
+       aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str();
+    }
+
+    SALOMEDS::ListOfFileNames_var aListOfFiles = new SALOMEDS::ListOfFileNames;
+    aListOfFiles->length(aFiles.size());
+    if(!aFiles.empty()){
+      for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--)
+       aListOfFiles[aCounter-1] = aFiles[aCounter-1].c_str();
     }
+
+    SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
+    if(theIsMultiFile)
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aListOfFiles.in(), theIsMultiFile);
+    else
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFiles.in(), aListOfFileNames.in());
+
     return aStreamFile._retn();
   }
 
@@ -329,8 +376,8 @@ namespace VISU{
                                           bool isMultiFile)
   {
     Mutex mt(myMutex);
-    const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str();
-    TCollection_AsciiString aTmpDir(const_cast<char*>(aDir));
+    string aDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
+    TCollection_AsciiString aTmpDir (const_cast<char*>(aDir.c_str()));
     if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
     int aCounter = 0;
     TColStd_SequenceOfAsciiString aFileNames;
@@ -404,41 +451,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<SUIT_Application> anApplications = aSession->applications();
+         QPtrListIterator<SUIT_Application> 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<SalomeApp_Study*>(aSStudy)) {
+                if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+                 if(MYDEBUG) 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<SalomeApp_Application*>(aFirstApp);
+           anApp->onLoadDoc(myStudyName.c_str());
+         }
+       }
+    };
+
     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());
+      if(MYDEBUG) 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<SUIT_Application> anApplications = aSession->applications();
-      QPtrListIterator<SUIT_Application> 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<SalomeApp_Study*>(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<SalomeApp_Application*>(aFirstApp);
-       anApp->onLoadDoc(aName.in());
-      }
+      ProcessVoidEvent(new TEvent(aStudyName));
     } else {
-      MESSAGE("VISU_Gen_i::SetCurrentStudy : CORBA::is_nil(theStudy)");
+      INFOS("CORBA::is_nil(theStudy)");
     }
   }
 
@@ -482,6 +542,23 @@ namespace VISU{
     }
   }
 
+  Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
+    if(myStudyDocument->GetProperties()->IsLocked())
+      return Result::_nil();
+    Mutex mt(myMutex);
+    aFileInfo.setFile(theFileName);
+    Result_i* pResult = new Result_i(myStudyDocument,
+                                    Result_i::eFile,
+                                    Result_i::eImportFile,
+                                    false);
+    if(pResult->Create(theFileName) != NULL)
+      return pResult->_this();
+    else{
+      pResult->_remove_ref();
+      return VISU::Result::_nil();
+    }
+  }
+
   Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
     if(myStudyDocument->GetProperties()->IsLocked())
       return Result::_nil();
@@ -496,36 +573,117 @@ 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();
     }
   }
 
+  void VISU_Gen_i::RenameMeshInStudy(Result_ptr theResult,
+                                    string     theMeshName,
+                                    int        theEntity,      // -1 for group indication
+                                    string     theSubMeshName, // Family or Group name
+                                    string     theNewName)
+  {
+    if (myStudyDocument->GetProperties()->IsLocked()) return;
+    Mutex mt(myMutex);
+
+    Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in());
+    if (!pResult) return;
+
+    QString aComment;
+    VISU::VISUType aType;
+    if (theEntity >= 0)
+      if (theSubMeshName == "")
+       aType = VISU::TENTITY;
+      else
+       aType = VISU::TFAMILY;
+    else
+      aType = VISU::TGROUP;
+
+    switch (aType) {
+    case VISU::TENTITY:
+      aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
+                      VISU::TENTITY, theMeshName.c_str(), theEntity);
+      break;
+    case VISU::TFAMILY:
+      aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
+                      VISU::TFAMILY, theMeshName.c_str(), theEntity, theSubMeshName.c_str());
+      break;
+    case VISU::TGROUP:
+      aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s",
+                      VISU::TGROUP, theMeshName.c_str(), theSubMeshName.c_str());
+      break;
+    }
+
+    string aResultEntry = pResult->GetEntry();
+    string anEntry = pResult->GetEntry(aComment.latin1());
+    if (anEntry == "") return;
+
+    SALOMEDS::SObject_ptr aSObject = myStudyDocument->FindObjectID(anEntry.c_str());
+
+    SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
+    aStudyBuilder->NewCommand(); // There is a transaction
+
+    SALOMEDS::GenericAttribute_var anAttr =
+      aStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName");
+    SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr);
+    aNameAttr->SetValue(theNewName.c_str());
+
+    aStudyBuilder->CommitCommand();
+  }
+
+  void VISU_Gen_i::RenameEntityInStudy(Result_ptr   theResult,
+                                      const char*  theMeshName,
+                                      VISU::Entity theEntity,
+                                      const char*  theNewName)
+  {
+    RenameMeshInStudy(theResult, theMeshName, (int)theEntity, "", theNewName);
+  }
+
+  void VISU_Gen_i::RenameFamilyInStudy(Result_ptr   theResult,
+                                      const char*  theMeshName,
+                                      VISU::Entity theEntity,
+                                      const char*  theFamilyName,
+                                      const char*  theNewName)
+  {
+    RenameMeshInStudy(theResult, theMeshName, (int)theEntity, theFamilyName, theNewName);
+  }
+
+  void VISU_Gen_i::RenameGroupInStudy(Result_ptr  theResult,
+                                     const char* theMeshName,
+                                     const char* theGroupName,
+                                     const char* theNewName)
+  {
+    RenameMeshInStudy(theResult, theMeshName, -1, theGroupName, theNewName);
+  }
+
   Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
                                    const char* theMeshName,
                                    VISU::Entity theEntity)
@@ -590,6 +748,15 @@ namespace VISU{
     return Prs3dOnField<VISU::ScalarMap_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn();
   }
 
+  GaussPoints_ptr VISU_Gen_i::GaussPointsOnField(Result_ptr theResult,
+                                                const char* theMeshName,
+                                                VISU::Entity theEntity,
+                                                const char* theFieldName,
+                                                CORBA::Double theIteration)
+  {
+    return Prs3dOnField<VISU::GaussPoints_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn();
+  }
+
   DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult,
                                                     const char* theMeshName,
                                                     VISU::Entity theEntity,
@@ -599,6 +766,15 @@ namespace VISU{
     return Prs3dOnField<VISU::DeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
   }
 
+  ScalarMapOnDeformedShape_ptr VISU_Gen_i::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
+                                                                          const char* theMeshName,
+                                                                          VISU::Entity theEntity,
+                                                                          const char* theFieldName,
+                                                                          CORBA::Double theIteration)
+  {
+    return Prs3dOnField<VISU::ScalarMapOnDeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+  }
+  
   Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult,
                                         const char* theMeshName,
                                         VISU::Entity theEntity,
@@ -626,6 +802,15 @@ namespace VISU{
     return Prs3dOnField<VISU::StreamLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
   }
 
+  Plot3D_ptr VISU_Gen_i::Plot3DOnField(Result_ptr theResult,
+                                      const char* theMeshName,
+                                      VISU::Entity theEntity,
+                                      const char* theFieldName,
+                                      CORBA::Double theIteration)
+  {
+    return Prs3dOnField<VISU::Plot3D_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+  }
+
   CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult,
                                             const char* theMeshName,
                                             VISU::Entity theEntity,
@@ -698,145 +883,14 @@ namespace VISU{
       return VISU::Animation::_nil();
   }
 
-  void DeletePrs3d (Prs3d_ptr thePrs3d)
-  {
-    Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in());
-    if (!aPrs3d)
-      return;
-
-    // 1. Find appropriate application (code like in VISU_ViewManager_i.cxx)
-    SALOMEDS::Study_var myStudyDocument = aPrs3d->GetStudyDocument();
-    SalomeApp_Application* anApp = NULL;
-    CORBA::String_var studyName = myStudyDocument->Name();
-    std::string aStudyName = studyName.in();
-    SUIT_Session* aSession = SUIT_Session::session();
-    QPtrList<SUIT_Application> anApplications = aSession->applications();
-    QPtrListIterator<SUIT_Application> anIter (anApplications);
-    while (SUIT_Application* aSUITApp = anIter.current()) {
-      ++anIter;
-      if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
-        if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
-          if (_PTR(Study) aCStudy = aStudy->studyDS()) {
-            if (aStudyName == aCStudy->Name()) {
-              anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
-             break;
-           }
-         }
-       }
-      }
-    }
-    if (!anApp)
-      return;
-
-    // 2. Remove corresponding IO from selection
-    SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
-    CORBA::String_var anEntry = aSObject->GetID();
-
-    SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
-    SALOME_ListIO aListIO, aNewListIO;
-    aSelectionMgr->selectedObjects(aListIO);
-
-    for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
-      if (it.Value()->hasEntry()) {
-        std::string aCurEntry (it.Value()->getEntry());
-        if (aCurEntry != anEntry) {
-          aNewListIO.Append(it.Value());
-        }
-      }
-    }
-
-    aSelectionMgr->setSelectedObjects(aNewListIO);
-
-    // 3. Remove Actors
-    ViewManagerList aViewManagerList;
-    anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
-    QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
-    for (; anVMIter.current(); ++anVMIter) {
-      SUIT_ViewManager* aViewManager = anVMIter.current();
-      QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
-      for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
-       if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
-         if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
-            //VISU_Actor* anActor = aVISUViewManager->GetActor(aPrs3d, vw);
-            VISU_Actor* anActor = NULL;
-            vtkActorCollection *anActColl = vw->getRenderer()->GetActors();
-           anActColl->InitTraversal();
-            vtkActor *aVTKActor = anActColl->GetNextActor();
-           for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) {
-              if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(aVTKActor)) {
-               if (aPrs3d == anVISUActor->GetPrs3d()) {
-                 anActor = anVISUActor->GetParent();
-                }
-              }
-            }
-            if (anActor) {
-             vw->RemoveActor(anActor);
-             anActor->Delete();
-            }
-          }
-        }
-      }
-    }
-
-    aPrs3d->RemoveFromStudy();
-    aPrs3d->Destroy();
-
-    //jfa tmp:theModule->updateObjBrowser(); //update Object browser
-  }
-
   void VISU_Gen_i::DeleteResult (Result_ptr theResult)
   {
-    class TEvent: public SALOME_Event {
-      Result_ptr myResult;
-    public:
-      TEvent(Result_ptr theResult): myResult(theResult) {}
-      virtual void Execute(){
-       if (Result_i* aResult = dynamic_cast<Result_i*>(GetServant(myResult).in())) {
-         SALOMEDS::SObject_var aSObject = aResult->GetSObject();
-         SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
-         SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(aSObject);
-         for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
-           SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
-           CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
-           if(CORBA::is_nil(aChildObj)) continue;
-           VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
-           if(CORBA::is_nil(aPrs3d)) continue;
-           VISU::DeletePrs3d(aPrs3d);
-         }
-
-         aResult->RemoveFromStudy();
-         aResult->Destroy();
-
-         //jfa tmp:if (QAD_Desktop* aDesktop = QAD_Application::getDesktop())
-         //jfa tmp:  if (QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
-         //jfa tmp:    aStudy->updateObjBrowser(); //update Object browser
-       }
-      }
-    };
-
-    if (myStudyDocument->GetProperties()->IsLocked())
-      return;
-    Mutex mt(myMutex); // jfa ???
-
-    ProcessVoidEvent(new TEvent(theResult));
+    theResult->RemoveFromStudy();
   }
 
   void VISU_Gen_i::DeletePrs3d (Prs3d_ptr thePrs3d)
   {
-    class TEvent: public SALOME_Event {
-      Prs3d_ptr myPrs3d;
-    public:
-      TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {}
-      virtual void Execute() {
-       VISU::DeletePrs3d(myPrs3d);
-      }
-    };
-
-    if (myStudyDocument->GetProperties()->IsLocked())
-      return;
-    Mutex mt(myMutex); // jfa ???
-
-    ProcessVoidEvent(new TEvent(thePrs3d));
+    thePrs3d->RemoveFromStudy();
   }
 
   void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
@@ -1031,5 +1085,4 @@ namespace VISU{
     anIOR->SetValue(anIORValue);
     return aResultSO._retn();
   }
-
 }