Salome HOME
NRI : Correction 1.1a version.
authornri <nri@opencascade.com>
Fri, 16 May 2003 17:03:57 +0000 (17:03 +0000)
committernri <nri@opencascade.com>
Fri, 16 May 2003 17:03:57 +0000 (17:03 +0000)
resources/VISU_en.xml
resources/VISU_fr.xml
src/OBJECT/VISU_Actor.cxx
src/OBJECT/VISU_Actor.h
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Gen_i.hh

index 121d71225c898d138690dd661c66a3966d91fd6f..76f0ffce2e2a96eaa228ef639d0b5ec88f4a6917 100644 (file)
@@ -18,7 +18,7 @@
   <popup-item item-id="199" pos-id="8" label-id="Import table from File" icon-id="" tooltip-id="" toggle-id="" execute-action=""/>
   <popup-item item-id="112" pos-id="8" label-id="Import from File" icon-id="" tooltip-id="" accel-id="Ctrl+I" toggle-id="" execute-action=""/>
   <popup-item item-id="113" pos-id="9" label-id="Explore MED File" icon-id="" tooltip-id="" accel-id="Ctrl+M" toggle-id="" execute-action=""/>
-  <!--popup-item item-id="122" pos-id="10" label-id="Export to File" icon-id="" tooltip-id="" accel-id="Ctrl+E" toggle-id="" execute-action=""/-->
+  <popup-item item-id="122" pos-id="10" label-id="Export to File" icon-id="" tooltip-id="" accel-id="Ctrl+E" toggle-id="" execute-action=""/>
   <separator pos-id="11"/> 
 </menu-item>
   
@@ -86,7 +86,7 @@
   <toolbutton-item item-id="430" pos-id="" label-id="Scaling" icon-id="Visu_scaling.png" tooltip-id="Scaling" accel-id="" toggle-id="" execute-action=""/>
 </toolbar>
 
-<toolbar label-id="Visualization Toolbar">
+<toolbar label-id="Visualization Tollbar">
   <toolbutton-item item-id="4011" pos-id="" label-id="Scalar Map" icon-id="Visu_scalars.png" tooltip-id="Scalar Map" accel-id="" toggle-id="" execute-action=""/>
   <toolbutton-item item-id="4012" pos-id="" label-id="Deformed shape" icon-id="Visu_deformed.png" tooltip-id="Deformed Shape" accel-id="" toggle-id="" execute-action=""/>
   <toolbutton-item item-id="4013" pos-id="" label-id="Vectors" icon-id="Visu_vectors.png" tooltip-id="Vectors" accel-id="" toggle-id="" execute-action=""/>
index 7ff81e2213ac8d706d5881cb5a2717b2c682f08f..90faa06e4e258e98685dbcee6b7adae402690162 100644 (file)
@@ -16,7 +16,7 @@
 <!-- ************************* File  (menubar) ************************************** -->
 <menu-item label-id="File" item-id="1" pos-id="1">
   <popup-item item-id="112" pos-id="8" label-id="Import from File" icon-id="" tooltip-id="" accel-id="Ctrl+I" toggle-id="" execute-action=""/>
-  <!-- popup-item item-id="122" pos-id="9" label-id="Export to File" icon-id="" tooltip-id="" accel-id="Ctrl+E" toggle-id="" execute-action=""/-->
+  <popup-item item-id="122" pos-id="9" label-id="Export to File" icon-id="" tooltip-id="" accel-id="Ctrl+E" toggle-id="" execute-action=""/>
   <separator pos-id="10"/> 
 </menu-item>
   
@@ -83,7 +83,7 @@
   <toolbutton-item item-id="430" pos-id="" label-id="Scaling" icon-id="Visu_scaling.png" tooltip-id="Scaling" accel-id="" toggle-id="" execute-action=""/>
 </toolbar>
 
-<toolbar label-id="Visualisation Toolbar">
+<toolbar label-id="Visualisation Tollbar">
   <toolbutton-item item-id="4011" pos-id="" label-id="Scalar Map" icon-id="Visu_scalars.png" tooltip-id="Scalar Map" accel-id="" toggle-id="" execute-action=""/>
   <toolbutton-item item-id="4012" pos-id="" label-id="Deformed shape" icon-id="Visu_deformed.png" tooltip-id="Deformed Shape" accel-id="" toggle-id="" execute-action=""/>
   <toolbutton-item item-id="4013" pos-id="" label-id="Vectors" icon-id="Visu_vectors.png" tooltip-id="Vectors" accel-id="" toggle-id="" execute-action=""/>
index a94fb9dfb50fa6ac2111aeb5bbb9c76ecdd9fdcb..1d5da42dba28ee0f6b100dc7005c9bda7b82f491 100644 (file)
@@ -21,10 +21,9 @@ VISU_Actor* VISU_Actor::New(){
 VISU_Actor::VISU_Actor(){
   this->Device = vtkActor::New();
 
-  this->EdgeDevice = NULL;
-  //this->EdgeDevice = SALOME_Actor::New();
-  //EdgeDevice->VisibilityOff();
-  //EdgeDevice->PickableOff();
+  this->EdgeDevice = vtkActor::New();
+  EdgeDevice->VisibilityOff();
+  EdgeDevice->PickableOff();
 
   this->DataSource = NULL;
   myScalarBar = NULL;
@@ -49,8 +48,7 @@ VISU_Actor::VISU_Actor(){
 
 VISU_Actor::~VISU_Actor()
 {
-  if (EdgeDevice != NULL)
-    this->EdgeDevice->Delete();  
+  this->EdgeDevice->Delete();  
 }
 
 
index 298f25cbd063c2ac1b13de3070a26b995805a706..437bb776860d71ba8549fa39a7d09e77d02a46e0 100644 (file)
@@ -80,7 +80,7 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor {
   void setPrs3d(VISU::Prs3d_i* thePrs) { Presentation = thePrs; }
     
   vtkDataSet *DataSource;
-  VISU_Actor*   EdgeDevice;
+  vtkActor*   EdgeDevice;
 
   Standard_Boolean IsShrinkable;
   Standard_Boolean IsShrunk;
index 037e0d51558843a0b93a1c8963eed344a942bd7d..0514b6e3b55f90372ec992ab48d012b793241d39 100644 (file)
@@ -17,7 +17,6 @@ using namespace std;
 #include "QAD_Desktop.h"
 #include "QAD_Study.h"
 #include "SALOMEDS_Tool.hxx"
-
 #include <strstream>   
 #include <TCollection_AsciiString.hxx>
 #include <TColStd_SequenceOfAsciiString.hxx>
@@ -42,22 +41,30 @@ static int MYDEBUG = 0;
 //static int IS_LOADED = (cout<<"\n----------------- VisuEngine_factory is loaded -----------------\n", 1);
 extern "C" {
   PortableServer::ObjectId * 
-    VisuEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId,
-                      const char *instanceName, const char *interfaceName) 
-      {
-       if(MYDEBUG) MESSAGE("VisuEngine_factory : "<<interfaceName);
-       VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(orb, poa, contId, instanceName, interfaceName);
-       return pVISU_Gen->getId() ;
-      }
+  VISUEngine_factory(CORBA::ORB_ptr orb,
+                    PortableServer::POA_ptr poa, 
+                    PortableServer::ObjectId * contId,
+                    const char *instanceName, 
+                    const char *interfaceName)
+  {
+    if(MYDEBUG) MESSAGE("VisuEngine_factory : "<<interfaceName);
+    VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(orb, poa, contId, instanceName, interfaceName);
+    return pVISU_Gen->getId() ;
+  }
+
+//    VISU::VISU_Gen_ptr  
+//    GetVisuGen(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex* theMutex){
+//      if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen");
+//      VISU::VISU_Gen_i * aVISU_Gen = new VISU::VISU_Gen_i(orb,poa,theMutex);
+//      return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()); 
+//    }
+
   Engines::Component_ptr  
-    GetVisuGen(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, 
-              SALOME_NamingService* theNamingService, QMutex* theMutex)
-      {
-       if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen");
-       VISU::VISU_Gen_i *aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theNamingService,theMutex);
-       return Engines::Component::_narrow( VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()));
-       //return aVISU_Gen->_this();
-      }
+  GetVisuGen(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex* theMutex){
+    if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen");
+    VISU::VISU_Gen_i * aVISU_Gen = new VISU::VISU_Gen_i(orb,poa,theMutex);
+    return Engines::Component::_narrow( VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()) ); 
+  }
 }
 
 namespace VISU{
@@ -65,10 +72,6 @@ namespace VISU{
   QMutex* Base_i::myMutex = NULL;
   CORBA::ORB_var Base_i::myOrb;
   PortableServer::POA_var Base_i::myPOA;
-  SALOME_NamingService* Base_i::myNamingService;
-  SALOME_LifeCycleCORBA* Base_i::myEnginesLifeCycle;
-  VISU_Gen_i* Base_i::myVisuGenImpl;
-  VISU_Gen_var Base_i::GetVisuGenInter() { return myVisuGenImpl->_this();}
   Base_i::~Base_i() {}
   char* Base_i::GetID(){ 
     //CORBA::Object_var anObject = _this();
@@ -98,16 +101,14 @@ namespace VISU{
   }
   //===========================================================================
   static Storable::TCallbackMap VisuStoreMap;
-  string Storable::ToString(){
+  const char* Storable::ToString(){
     ostrstream strOut;
     Storable::DataToStream( strOut, "myComment", GetComment() );
     ToStream(strOut);
     strOut<<ends;
     if(MYDEBUG) MESSAGE("Storable::ToString - "<<strOut.str());
-    auto_ptr<char> aRet(strOut.str());
-    return aRet.get(); 
+    return strOut.str(); 
   }
-
   void Storable::Registry(const char* theComment, TStorableEngine theEngine)
     throw(std::logic_error&)
       {
@@ -116,7 +117,6 @@ namespace VISU{
          throw std::logic_error("Storable::Registry >> dupliacte registring !!!");
        }
       }
-
   void RegistryStorable() throw(std::logic_error&) {
     //Storable::Registry(View3D_i::myComment.c_str(),&View3DRestore);
     Storable::Registry(Result_i::myComment.c_str(),&ResultRestore);
@@ -132,8 +132,20 @@ namespace VISU{
     Storable::Registry(Container_i::myComment.c_str(),&ContainerRestore);
   }
 
+  SALOMEDS::SObject_ptr Storable::GetResultSO(SALOMEDS::SObject_ptr theSObject) {
+    CORBA::String_var aComponentID(theSObject->GetFatherComponent()->GetID());
+    SALOMEDS::SObject_var aResult = SALOMEDS::SObject::_duplicate(theSObject);
+    CORBA::String_var aFatherID(aResult->GetFather()->GetID());
+    while(strcmp(aComponentID, aFatherID)) {
+      aResult = aResult->GetFather();
+      aFatherID = aResult->GetFather()->GetID();
+      if (strlen(aFatherID) < 3) break;
+    }
+    return aResult._retn();
+  }
+
   void Storable::StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap){
-    if(0 && MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
+    if(MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
     QStringList strList = QStringList::split( ";", theStr, false );
     for ( int i = 0; i < strList.count(); i++ ) {
       QString next = strList[ i ];
@@ -213,7 +225,7 @@ namespace VISU{
 
   //===========================================================================
   PortableServer::Servant GetServant(CORBA::Object_ptr theObject){
-    PortableServer::POA_ptr aPOA = Base_i::GetPOA();
+    PortableServer::POA_var aPOA = GetPOA();
     if(CORBA::is_nil(theObject)) 
       if(MYDEBUG) MESSAGE("GetServant - CORBA::is_nil(theObject)");
     return aPOA->reference_to_servant(theObject);
@@ -222,16 +234,12 @@ namespace VISU{
   CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject){
     SALOMEDS::GenericAttribute_var anAttr;
     CORBA::Object_var anObj;
-    try{
-      if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
-       SALOMEDS::AttributeIOR_var anIOR  = SALOMEDS::AttributeIOR::_narrow(anAttr);
-       CORBA::String_var aValue = anIOR->Value();
-       CORBA::ORB_ptr anORB = Base_i::GetORB();
-       if(strcmp(aValue,"") != 0)
-         anObj = anORB->string_to_object(aValue);
-      }
-    }catch(...){
-      MESSAGE("SObjectToObject - Unknown exception was accured!");
+    if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
+      SALOMEDS::AttributeIOR_var anIOR  = SALOMEDS::AttributeIOR::_narrow(anAttr);
+      CORBA::String_var aValue = anIOR->Value();
+      CORBA::ORB_var anORB = GetORB();
+      if(strcmp(aValue,"") != 0)
+       anObj = anORB->string_to_object(aValue);
     }
     return anObj;
   }
@@ -252,7 +260,7 @@ namespace VISU{
       SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
       aPixmap->SetPixMap( "ICON_OBJBROWSER_Visu" );
       
-      VISU_Gen_var aVisuGen = Base_i::GetVisuGenInter();
+      VISU_Gen_var aVisuGen = GetVisu();
       aStudyBuilder->DefineComponentInstance(aSComponent,aVisuGen);
       if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
       aStudyBuilder->CommitCommand();
@@ -263,7 +271,7 @@ namespace VISU{
   string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
                                   const char* theComment, int IsAllLevels)
     {
-      if(0 && MYDEBUG) MESSAGE("FindEntryWithComment - '"<<theComment<<"'");
+      if(MYDEBUG) MESSAGE("FindEntryWithComment - '"<<theComment<<"'");
       SALOMEDS::ChildIterator_var anIter = 
        theStudyDocument->NewChildIterator(theStudyDocument->FindObjectID(theStartEntry));
       anIter->InitEx(IsAllLevels);
@@ -291,7 +299,7 @@ namespace VISU{
                               const char* thePersistentRef, const char* theComment,
                               CORBA::Boolean theCreateNew)
     {
-      if(0 && MYDEBUG) 
+      if(MYDEBUG) 
        MESSAGE("CreateAttributes - theName = "<<theName<<"; theComment = '"<<theComment<<
                "'; theFatherEntry = "<<theFatherEntry);
       SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
@@ -318,58 +326,23 @@ namespace VISU{
       }
       CORBA::String_var anEntry = newObj->GetID();
       string aRet(anEntry);
-      if(0 && MYDEBUG) MESSAGE("CreateAttributes - anEntry = "<<aRet<<"; IOR = "<<theIOR);
+      if(MYDEBUG) MESSAGE("CreateAttributes - anEntry = "<<aRet<<"; IOR = "<<theIOR);
       return aRet;
     }
   //===========================================================================
+  static CORBA::ORB_var VisuORB;
+  static PortableServer::POA_var VisuPOA;
   static SALOMEDS::SComponent_var VisuSComponent;
   static string VisuTmpDir;
+  static VISU_Gen_i* VisuGen;
   static CORBA::Boolean myIsMultiFile;
-  const CORBA::Boolean IsMultifile() { 
-    return myIsMultiFile;
-  }
-  //===========================================================================
-  VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr orb,
-                        PortableServer::POA_ptr poa,
-                        PortableServer::ObjectId * contId, 
-                        const char *instanceName, 
-                        const char *interfaceName) :
-    Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
-  {
-    if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<myMutex);
-    _thisObj = this ;
-    _id = _poa->activate_object(_thisObj);
-    SALOME_NamingService aNamingService(orb);
-    CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
-    SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
-    //aSession->GetInterface(); 
-    myVisuGen = VISU::VISU_Gen::_narrow( aSession->GetVisuComponent() );
-  }
-
-  VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, 
-                        SALOME_NamingService* theNamingService, QMutex* theMutex) :
-    Engines_Component_i()
-  {
-    if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<theMutex);
-    Mutex mt(theMutex,qApp);
-    Base_i::myMutex = theMutex;
-    Base_i::myOrb = CORBA::ORB::_duplicate(theORB);
-    Base_i::myPOA = PortableServer::POA::_duplicate(thePOA);
-    Base_i::myNamingService = theNamingService;
-    static SALOME_LifeCycleCORBA aEnginesLifeCycle(theNamingService);
-    Base_i::myEnginesLifeCycle = &aEnginesLifeCycle;
-    Base_i::myVisuGenImpl = this;
-    RegistryStorable();
-    if(!QAD_Application::getDesktop()->getActiveStudy())
-      QAD_Application::getDesktop()->createStudy();
-    myStudyDocument = 
-      QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
-    Base_i::myPOA->activate_object(this);
-  }
-
-  VISU_Gen_i::~VISU_Gen_i(){
-    if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
+  CORBA::ORB_var GetORB() { return VisuORB;}
+  PortableServer::POA_var GetPOA() { return VisuPOA;}
+  VISU_Gen_var GetVisu() { 
+    return VISU_Gen::_duplicate(VisuGen->_this());
+    //return VisuGen->_this();
   }
+  const CORBA::Boolean IsMultifile() { return myIsMultiFile;}
   //===========================================================================
   bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
                      const SALOMEDS::TMPFile & theStream,
@@ -397,9 +370,9 @@ namespace VISU{
                                           const char* aLocalPersistentID,
                                           CORBA::Boolean isMultiFile) {
     if(myMutex){
+      Mutex mt(myMutex,qApp);
       CORBA::String_var aString("");
       if(strcmp(aLocalPersistentID,"") != 0) {
-       Mutex mt(myMutex,qApp);
        Storable* aStorable =
          Storable::Create(theSObject,VisuTmpDir.c_str(),aLocalPersistentID);
        if(aStorable != NULL) aString = aStorable->GetID();
@@ -416,8 +389,8 @@ namespace VISU{
     if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - myMutex = "<<myMutex);
     if(myMutex){
       Mutex mt(myMutex,qApp);
-      CORBA::String_var aString = SALOMEDS_Tool::GetTmpDir();
-      TCollection_AsciiString aTmpDir = isMultiFile? (const Standard_CString)theURL: (const Standard_CString)aString.in();
+      TCollection_AsciiString aTmpDir =
+       (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
       if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
       int aCounter = 0;
       TColStd_SequenceOfAsciiString aFileNames;
@@ -428,10 +401,10 @@ namespace VISU{
        CORBA::Object_var anObj = SObjectToObject(gotBranch);
        if(CORBA::is_nil(anObj)) continue;
        Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj));
-       if(pResult && abs(pResult->GetSourceId()) == Result_i::eFile){
+       if(pResult){
          const QFileInfo& aFileInfo = pResult->GetFileInfo();
          QString aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
-         QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
+         QString aFileName = aPrefix + "_" + pResult->GetName();
          static QString aCommand;
          aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
          if(system(aCommand) == -1){
@@ -464,15 +437,15 @@ namespace VISU{
                                           CORBA::Boolean isMultiFile) {
     if(MYDEBUG) MESSAGE("VISU_Gen_i::IORToLocalPersistentID - myMutex = "<<myMutex);
     if(myMutex){
+      Mutex mt(myMutex,qApp);
+      CORBA::ORB_var anORB = GetORB();
       CORBA::String_var aString(IORString);
       if(strcmp(IORString,"") != 0){ 
-       CORBA::ORB_ptr anORB = GetORB();
        CORBA::Object_var anObj = anORB->string_to_object(aString);
        if(!CORBA::is_nil(anObj)){
          Storable* pStorable = dynamic_cast<Storable*>(GetServant(anObj));
          if(pStorable != NULL){
-           Mutex mt(myMutex,qApp);
-           aString = pStorable->ToString().c_str();
+           aString = pStorable->ToString();
            return aString._retn();
          }
        }
@@ -482,6 +455,44 @@ namespace VISU{
     return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile);
   }
 
+  //===========================================================================
+  VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr orb,
+                        PortableServer::POA_ptr poa,
+                        PortableServer::ObjectId * contId, 
+                        const char *instanceName, 
+                        const char *interfaceName) :
+    Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
+  {
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<myMutex);
+    _thisObj = this ;
+    _id = _poa->activate_object(_thisObj);
+    SALOME_NamingService aNamingService(orb);
+    SALOME::Session_var aSession(SALOME::Session::_narrow(aNamingService.Resolve("/Kernel/Session")));
+    //aSession->GetInterface(); 
+    //myVisuGen = aSession->GetVisuGen();
+    myVisuGen = VISU::VISU_Gen::_narrow( aSession->GetVisuComponent() );
+  }
+  VISU_Gen_i::VISU_Gen_i(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex* theMutex) :
+    Engines_Component_i()
+  {
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<theMutex);
+    Base_i::myMutex = theMutex;
+    Base_i::myOrb = CORBA::ORB::_duplicate(orb);
+    Base_i::myPOA = PortableServer::POA::_duplicate(poa);
+    Mutex mt(myMutex,qApp);
+    VisuORB = orb;
+    VisuPOA = poa;
+    VisuGen = this;
+    VisuPOA->activate_object(this);
+    RegistryStorable();
+    if(!QAD_Application::getDesktop()->getActiveStudy())
+      QAD_Application::getDesktop()->createStudy();
+    myStudyDocument = 
+      QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+  }
+  VISU_Gen_i::~VISU_Gen_i(){
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
+  }
   void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
     //if(MYDEBUG) MESSAGE("VISU_Gen_i::SetCurrentStudy : "<<(!theStudy->_is_nil()));
     if(myMutex)
@@ -529,18 +540,42 @@ namespace VISU{
     }
     return myVisuGen->ImportFile(theFileName);
   }
-
-  Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
+  Result_ptr VISU_Gen_i::ImportMed(SALOME_MED::FIELD_ptr theField){
     if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMed : "<<myMutex);
     if(myMutex){
       if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil();
       Mutex mt(myMutex,qApp);
       Result_i* pResult = new Result_i(myStudyDocument);
-      if(pResult->Create(theMedSObject) != NULL) 
+      if(pResult->Create(theField) != NULL) 
+       return Result::_duplicate(pResult->_this());
+      return Result::_nil();
+    }
+    return myVisuGen->ImportMed(theField);
+  }
+  Result_ptr VISU_Gen_i::ImportMedMesh(SALOME_MED::MESH_ptr theMesh){
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMedMesh : "<<myMutex);
+    if(myMutex){
+      if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil();
+      Mutex mt(myMutex,qApp);
+      Result_i* pResult = new Result_i(myStudyDocument);
+      if(pResult->Create(theMesh) != NULL) 
+       return Result::_duplicate(pResult->_this());
+      return Result::_nil();
+    }
+    return myVisuGen->ImportMedMesh(theMesh);
+  }
+  
+  Result_ptr VISU_Gen_i::ImportMedSupport(SALOME_MED::SUPPORT_ptr theSupport){
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMedSupport : "<<myMutex);
+    if(myMutex){
+      if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil();
+      Mutex mt(myMutex,qApp);
+      Result_i* pResult = new Result_i(myStudyDocument);
+      if(pResult->Create(theSupport) != NULL) 
        return Result::_duplicate(pResult->_this());
       return Result::_nil();
     }
-    return myVisuGen->ImportMed(theMedSObject);
+    return myVisuGen->ImportMedSupport(theSupport);
   }
 
   Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity){
@@ -708,7 +743,7 @@ namespace VISU{
     if(myMutex){
       if(myStudyDocument->GetProperties()->IsLocked()) return Curve::_nil();
       Mutex mt(myMutex,qApp);
-      PortableServer::POA_ptr aPOA = GetPOA();
+      PortableServer::POA_var aPOA = GetPOA();
       Table_i* pTable = dynamic_cast<Table_i*>(aPOA->reference_to_servant(theTable));
       Curve_i* aPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow);
       if(aPresent->Create() != NULL) { 
@@ -745,7 +780,7 @@ namespace VISU{
          CORBA::Object_var anObj = SObjectToObject(gotBranch);
          if(CORBA::is_nil(anObj)) continue;
          Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj));
-         if(pResult->GetSourceId() == Result_i::eRestoredFile){ //Try remove its file and directory
+         if(pResult->IsRestored()){ //Try remove its file and directory
            const QFileInfo& aFileInfo = pResult->GetFileInfo();
            static QString aCommand;
            aCommand.sprintf("rm %s",aFileInfo.filePath().latin1());
@@ -779,10 +814,20 @@ namespace VISU{
     if(myMutex){
       Mutex mt(myMutex,qApp);
       SALOMEDS::SObject_var aResultSO;
-      Result_i* aResultObj = dynamic_cast<Result_i*>(GetServant(theObject));
+      PortableServer::POA_var aPOA = GetPOA();
+      Result_i* aResultObj = dynamic_cast<Result_i*>(aPOA->reference_to_servant(theObject));
       if (!aResultObj) return aResultSO._retn();
+
+      CORBA::String_var anEntry;
       const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
-      CORBA::String_var anEntry = aResultObj->Create(aFileInfo.filePath().latin1())->GetID();
+      anEntry = strdup(aResultObj->Create(aFileInfo.filePath().latin1())->GetID());
+//       if (CORBA::is_nil(theSObject)) {
+//     anEntry = strdup(aResultObj->Create(SALOMEDS::SObject::_nil(), theName));
+//       } else {
+//     if (!theSObject->ReferencedObject(aResultSO)) 
+//       THROW_SALOME_CORBA_EXCEPTION("Publish error: bad referenced SObject",SALOME::BAD_PARAM);
+//     anEntry = strdup(aResultObj->Create(aResultSO, (const char *)theName));
+//       }
       aResultSO = theStudy->FindObjectID(anEntry);
       return aResultSO._retn();
     }
@@ -790,32 +835,22 @@ namespace VISU{
   }
     
   CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
-    if(0 && MYDEBUG) MESSAGE("VISU_Gen_i::CanCopy : "<<myMutex);
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::CanCopy : "<<myMutex);
     if(myMutex){
       //Mutex mt(myMutex,qApp);
       SALOMEDS::GenericAttribute_var anAttr;
       if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
       try {
-       SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-       CORBA::String_var aValue = anIOR->Value();
-       if(strcmp(aValue,"") != 0){
-         CORBA::Object_ptr anObj = GetORB()->string_to_object(aValue);
-         if (!CORBA::is_nil(anObj)){
-           Result_var aResultObj = Result::_narrow(anObj);
-           if(!aResultObj->_is_nil()){
-             Result_i* pResult = dynamic_cast<Result_i*>(GetServant(aResultObj));
-             if(pResult != NULL){
-               if(abs(pResult->GetSourceId()) > Result_i::eFile) 
-                 if((pResult->GetFileInfo()).filePath() == "Med") return false;
-               return true;
-             }
-           }
-         }
+       CORBA::Object_var anObj = GetORB()->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+       if (CORBA::is_nil(anObj)) return false;
+       else {
+         Result_var aResultObj = Result::_narrow(anObj);
+         if (aResultObj->_is_nil()) return false;
        }
       } catch (...) {
-       MESSAGE("Unknown exception was accured!");
+       return false;
       }
-      return false;
+      return true;
     }
     return myVisuGen->CanCopy(theObject);
   }
@@ -829,7 +864,7 @@ namespace VISU{
       SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
       SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
 
-      PortableServer::POA_ptr aPOA = GetPOA();
+      PortableServer::POA_var aPOA = GetPOA();
       
       SALOMEDS::GenericAttribute_var anAttr;
       if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL;
@@ -852,20 +887,20 @@ namespace VISU{
       }
       CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir();
 
-      string aStr = pStorable->ToString().c_str();
+      char* aStr = strdup(pStorable->ToString());
       ofstream stmOut2((string(aTmpDir) + string("copy_persistent")).c_str(),ios::out);
       stmOut2<<aStr<<endl;
       stmOut2.close();
 
       Result_i* aResultObj = dynamic_cast<Result_i*>(aPOA->reference_to_servant(aCorbaObj));
       if (aResultObj) {
-       string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_";
+       string aStudyPrefix = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + string("_");
+
        const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
-       aFileName += aFileInfo.fileName().latin1();
        static QString aCommand;
        aCommand.sprintf("cp %s %s",
                         aFileInfo.filePath().latin1(),
-                        (string(aTmpDir) + aFileName).c_str());
+                        (string(aTmpDir)+aStudyPrefix + string(aResultObj->GetName())).c_str());
        if(system(aCommand) == -1) {
          if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand);
          return NULL;
@@ -873,7 +908,7 @@ namespace VISU{
 
        aSeq->length(2);
        aSeq[0] = "copy_persistent";
-       aSeq[1] = aFileName.c_str();
+       aSeq[1] = (aStudyPrefix + string(aResultObj->GetName())).c_str();
       } else {
        aSeq->length(1);
        aSeq[0] = "copy_persistent";
@@ -891,7 +926,7 @@ namespace VISU{
   CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
     // The VISU component can paste only objects copied by VISU component
     // and with the object type = 1
-    if(0 && MYDEBUG) MESSAGE("VISU_Gen_i::CanPaste : "<<myMutex);
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::CanPaste : "<<myMutex);
     if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false;
     return true;
   }
@@ -905,9 +940,14 @@ namespace VISU{
       SALOMEDS::SObject_var aResultSO;
       if (theObjectID != 1) return aResultSO._retn();
       
-      CORBA::String_var aTmpDir = (const char*)SALOMEDS_Tool::GetTmpDir();
+      CORBA::String_var aTmpDir = strdup(SALOMEDS_Tool::GetTmpDir());
       SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
 
+      SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
+      SALOMEDS::Study_var aStudy = theObject->GetStudy();
+      SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+      CORBA::ORB_var anORB = GetORB();
+
       ifstream stmIn((string(aTmpDir) + string("copy_persistent")).c_str());
 //        ifstream stmIn((string(aTmpDir) + string("copy_persistent")).c_str(),ios::in);
       stmIn.seekg(0, ios::end);
@@ -917,28 +957,23 @@ namespace VISU{
       stmIn.read(aString, aLength);
       aString[aLength] = 0;
       myIsMultiFile = true;
-      
-      string aFileName(aTmpDir.in());
-      if(aSeq->length() > 1) aFileName += aSeq[1].in();
-      Storable* aStorable = Storable::Create(theObject,aFileName,aString);
+      Storable* aStorable = Storable::Create(theObject,aTmpDir.in(),aString);
 
       SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames;
       aSeqToRm->length(1);
       aSeqToRm[0] = "copy_persistent";
       SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeqToRm.in(), true);
 
-      SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
-      SALOMEDS::Study_var aStudy = theObject->GetStudy();
-      SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-      CORBA::String_var aComponentID(aComponent->GetID()), aSObjID(theObject->GetID());
-      if (strcmp(aComponentID, aSObjID) == 0) //create the new result SObject
+      CORBA::String_var aComponentIDString(aComponent->GetID());
+      if (strcmp(aComponentIDString, theObject->GetID()) == 0) {
+       // create the new result SObject
        aResultSO = aStudyBuilder->NewObject(aComponent);
-      else 
+      } else {
        aResultSO = SALOMEDS::SObject::_duplicate(theObject);
-      SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
-      SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-      CORBA::String_var anIORValue(aStorable->GetID());
-      anIOR->SetValue(anIORValue);
+      }
+      SALOMEDS::AttributeIOR_var anIOR =
+       SALOMEDS::AttributeIOR::_narrow(aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR"));
+      anIOR->SetValue(aStorable->GetID());
       return aResultSO._retn();
     }
     return myVisuGen->PasteInto(theStream,theObjectID,theObject);
index 3b5e23867ba03d2d5d44769d5e0677faceea4dbf..ab69280b77326b1e595b30ecf2ecff6d4117d5a0 100644 (file)
@@ -24,8 +24,7 @@ namespace VISU{
     VISU_Gen_i();
     VISU_Gen_i(const VISU::VISU_Gen_i &);
   public:
-    VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, 
-              SALOME_NamingService* theNamingService, QMutex* theMutex);
+    VISU_Gen_i(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex* theMutex);
     VISU_Gen_i(CORBA::ORB_ptr orb,
               PortableServer::POA_ptr poa,
               PortableServer::ObjectId * contId, 
@@ -42,7 +41,9 @@ namespace VISU{
 
     //Create Result
     virtual Result_ptr ImportFile(const char* theFileName);
-    virtual Result_ptr ImportMed(SALOMEDS::SObject_ptr theMedSObject);
+    virtual Result_ptr ImportMed(SALOME_MED::FIELD_ptr theField);
+    virtual Result_ptr ImportMedMesh(SALOME_MED::MESH_ptr theMesh);
+    virtual Result_ptr ImportMedSupport(SALOME_MED::SUPPORT_ptr theSupport);
 
     //Create Presentation Of Submeshes
     virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity);