Back to index

salome-smesh  6.5.0
libSMESH_Swig.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // SMESH SMESH : GUI for SMESH component
00021 // File   : libSMESH_Swig.cxx
00022 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
00023 // SMESH includes
00024 //
00025 #include "libSMESH_Swig.h"
00026 
00027 #include <SMESHGUI.h>
00028 #include <SMESHGUI_Utils.h>
00029 #include <SMESHGUI_Displayer.h>
00030 
00031 // SALOME KERNEL includes
00032 #include <Utils_ORB_INIT.hxx>
00033 #include <Utils_SINGLETON.hxx>
00034 #include <SALOMEDSClient_ClientFactory.hxx>
00035 
00036 #include <utilities.h>
00037 
00038 // SALOME GUI includes
00039 #include <SUIT_Session.h>
00040 #include <VTKViewer_ViewModel.h>
00041 #include <SALOME_Event.h>
00042 #include <SalomeApp_Application.h>
00043 
00044 // OCCT includes
00045 #include <TopAbs.hxx>
00046 
00047 // Qt includes
00048 #include <QApplication>
00049 
00050 // IDL includes
00051 #include <SALOMEconfig.h>
00052 #include CORBA_SERVER_HEADER(SMESH_Gen)
00053 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
00054 
00055 static CORBA::ORB_var anORB;
00056 
00057 namespace
00058 {
00059   //---------------------------------------------------------------
00060   inline
00061   CORBA::Object_var
00062   StringToObject(const std::string& theIOR)
00063   {
00064     return anORB->string_to_object(theIOR.c_str());
00065   }
00066 
00067 
00068   //---------------------------------------------------------------
00069   inline
00070   SALOMEDS::SObject_var
00071   GetDomainRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
00072                 const SALOMEDS::StudyBuilder_var& theStudyBuilder,
00073                 CORBA::Long theDomainRootTag,
00074                 const QString& theName,
00075                 const QString& thePixmap)
00076   {
00077     SALOMEDS::SObject_var aDomainRoot;
00078     if (!theSComponentMesh->FindSubObject(theDomainRootTag,aDomainRoot)) {
00079       aDomainRoot = theStudyBuilder->NewObjectToTag(theSComponentMesh,theDomainRootTag);
00080       SALOMEDS::GenericAttribute_var anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributeName");
00081       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
00082       aName->SetValue(theName.toLatin1().data());
00083       anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributePixMap");
00084       SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
00085       aPixmap->SetPixMap(thePixmap.toLatin1().data());
00086       anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributeSelectable");
00087       SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
00088       aSelAttr->SetSelectable(false);
00089     }
00090 
00091     return aDomainRoot;
00092   }
00093 
00094 
00095   //---------------------------------------------------------------
00096   inline
00097   SALOMEDS::SObject_var
00098   GetHypothesisRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
00099                     const SALOMEDS::StudyBuilder_var& theStudyBuilder)
00100   {
00101     return GetDomainRoot(theSComponentMesh,
00102                          theStudyBuilder,
00103                          SMESH::Tag_HypothesisRoot,
00104                          QObject::tr("SMESH_MEN_HYPOTHESIS"),
00105                          "ICON_SMESH_TREE_HYPO");
00106   }
00107 
00108 
00109   //---------------------------------------------------------------
00110   inline
00111   SALOMEDS::SObject_var
00112   GetAlgorithmsRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
00113                     const SALOMEDS::StudyBuilder_var& theStudyBuilder)
00114   {
00115     return GetDomainRoot(theSComponentMesh,
00116                          theStudyBuilder,
00117                          SMESH::Tag_AlgorithmsRoot,
00118                          QObject::tr("SMESH_MEN_ALGORITHMS"),
00119                          "ICON_SMESH_TREE_ALGO");
00120   }
00121 
00122 
00123   //---------------------------------------------------------------
00124   inline
00125   SALOMEDS::SObject_var
00126   AddToDomain(const std::string& theIOR,
00127               const SALOMEDS::SComponent_var& theSComponentMesh,
00128               const SALOMEDS::StudyBuilder_var& theStudyBuilder,
00129               CORBA::Long theDomainRootTag,
00130               const QString& theDomainName,
00131               const QString& theDomainPixmap)
00132   {
00133     SALOMEDS::SObject_var aDomain = GetDomainRoot(theSComponentMesh,
00134                                                   theStudyBuilder,
00135                                                   SMESH::Tag_AlgorithmsRoot,
00136                                                   theDomainName,
00137                                                   theDomainPixmap);
00138     // Add New Hypothesis
00139     SALOMEDS::SObject_var aSObject = theStudyBuilder->NewObject(aDomain);
00140     SALOMEDS::GenericAttribute_var anAttr = theStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
00141     SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
00142     CORBA::Object_var anObject = StringToObject(theIOR);
00143     SMESH::SMESH_Hypothesis_var aDomainItem = SMESH::SMESH_Hypothesis::_narrow(anObject.in());
00144     CORBA::String_var aType = aDomainItem->GetName();
00145     QString aPixmapName = theDomainPixmap + "_" + aType.in();
00146     aPixmap->SetPixMap(aPixmapName.toLatin1().data());
00147     anAttr = theStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
00148     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
00149     anIOR->SetValue(theIOR.c_str());
00150 
00151     return aSObject;
00152   }
00153 
00154 
00155   //---------------------------------------------------------------
00156   SALOMEDS::SObject_var
00157   AddHypothesis(const std::string& theIOR,
00158                 const SALOMEDS::SComponent_var& theSComponentMesh,
00159                 const SALOMEDS::StudyBuilder_var& theStudyBuilder)
00160   {
00161     return AddToDomain(theIOR,
00162                        theSComponentMesh,
00163                        theStudyBuilder,
00164                        SMESH::Tag_HypothesisRoot,
00165                        QObject::tr("SMESH_MEN_HYPOTHESIS"),
00166                        "ICON_SMESH_TREE_HYPO");
00167   }
00168 
00169 
00170   //---------------------------------------------------------------
00171   SALOMEDS::SObject_var
00172   AddAlgorithms(const std::string& theIOR,
00173                 const SALOMEDS::SComponent_var& theSComponentMesh,
00174                 const SALOMEDS::StudyBuilder_var& theStudyBuilder)
00175   {
00176     return AddToDomain(theIOR,
00177                        theSComponentMesh,
00178                        theStudyBuilder,
00179                        SMESH::Tag_AlgorithmsRoot,
00180                        QObject::tr("SMESH_MEN_ALGORITHMS"),
00181                        "ICON_SMESH_TREE_ALGO");
00182   }
00183 
00184 
00185   //---------------------------------------------------------------
00186   void
00187   SetDomain(const char* theMeshOrSubMeshEntry,
00188             const char* theDomainEntry,
00189             const SALOMEDS::Study_var& theStudy,
00190             const SALOMEDS::StudyBuilder_var& theStudyBuilder,
00191             long theRefOnAppliedDomainTag,
00192             const QString& theAppliedDomainMEN,
00193             const QString& theAppliedDomainICON)
00194   {
00195     SALOMEDS::SObject_var aMeshOrSubMeshSO = theStudy->FindObjectID(theMeshOrSubMeshEntry);
00196     SALOMEDS::SObject_var aHypothesisSO = theStudy->FindObjectID(theDomainEntry);
00197 
00198     if(!aMeshOrSubMeshSO->_is_nil() && !aHypothesisSO->_is_nil()){
00199       //Find or Create Applied Hypothesis root
00200       SALOMEDS::SObject_var anAppliedDomainSO;
00201       if(!aMeshOrSubMeshSO->FindSubObject(theRefOnAppliedDomainTag,anAppliedDomainSO)){
00202         anAppliedDomainSO = theStudyBuilder->NewObjectToTag(aMeshOrSubMeshSO,theRefOnAppliedDomainTag);
00203         SALOMEDS::GenericAttribute_var anAttr =
00204           theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributeName");
00205         SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
00206         aName->SetValue(theAppliedDomainMEN.toLatin1().data());
00207         anAttr = theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributeSelectable");
00208         SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
00209         aSelAttr->SetSelectable(false);
00210         anAttr = theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributePixMap");
00211         SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
00212         aPixmap->SetPixMap(theAppliedDomainICON.toLatin1().data());
00213       }
00214       SALOMEDS::SObject_var aSObject = theStudyBuilder->NewObject(anAppliedDomainSO);
00215       theStudyBuilder->Addreference(aSObject,aHypothesisSO);
00216     }
00217   }
00218 
00219 
00220   //---------------------------------------------------------------
00221   void
00222   SetHypothesis(const char* theMeshOrSubMeshEntry,
00223                 const char* theDomainEntry,
00224                 const SALOMEDS::Study_var& theStudy,
00225                 const SALOMEDS::StudyBuilder_var& theStudyBuilder)
00226   {
00227     SetDomain(theMeshOrSubMeshEntry,
00228               theDomainEntry,
00229               theStudy,
00230               theStudyBuilder,
00231               SMESH::Tag_RefOnAppliedHypothesis,
00232               QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS"),
00233               "ICON_SMESH_TREE_HYPO");
00234   }
00235 
00236 
00237   //---------------------------------------------------------------
00238   void
00239   SetAlgorithms(const char* theMeshOrSubMeshEntry,
00240                 const char* theDomainEntry,
00241                 const SALOMEDS::Study_var& theStudy,
00242                 const SALOMEDS::StudyBuilder_var& theStudyBuilder)
00243   {
00244     SetDomain(theMeshOrSubMeshEntry,
00245               theDomainEntry,
00246               theStudy,
00247               theStudyBuilder,
00248               SMESH::Tag_RefOnAppliedAlgorithms,
00249               QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS"),
00250               "ICON_SMESH_TREE_ALGO");
00251   }
00252 }
00253 
00254 
00255 //===============================================================
00256 SMESH_Swig::SMESH_Swig()
00257 {
00258   class TEvent: public SALOME_Event
00259   {
00260     CORBA::ORB_var& myORB;
00261   public:
00262 
00263     TEvent(CORBA::ORB_var& theORB):
00264       myORB(theORB)
00265     {}
00266 
00267     virtual
00268     void
00269     Execute()
00270     {
00271       try {
00272         ORB_INIT &anORBInit = *SINGLETON_<ORB_INIT>::Instance();
00273         ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
00274         myORB = anORBInit( 0, 0 );
00275       } catch (...) {
00276         INFOS("internal error : orb not found");
00277       }
00278     }
00279   };
00280 
00281   MESSAGE("Constructeur");
00282 
00283   if(CORBA::is_nil(anORB))
00284     ProcessVoidEvent(new TEvent(anORB));
00285 
00286   ASSERT(!CORBA::is_nil(anORB));
00287 }
00288 
00289 
00290 //===============================================================
00291 void
00292 SMESH_Swig::Init(int theStudyID)
00293 {
00294   class TEvent: public SALOME_Event
00295   {
00296     int myStudyID;
00297     SALOMEDS::Study_var& myStudy;
00298     SALOMEDS::StudyBuilder_var& myStudyBuilder;
00299     SALOMEDS::SComponent_var& mySComponentMesh;
00300   public:
00301     TEvent(int theStudyID,
00302            SALOMEDS::Study_var& theStudy,
00303            SALOMEDS::StudyBuilder_var& theStudyBuilder,
00304            SALOMEDS::SComponent_var& theSComponentMesh):
00305       myStudyID(theStudyID),
00306       myStudy(theStudy),
00307       myStudyBuilder(theStudyBuilder),
00308       mySComponentMesh(theSComponentMesh)
00309     {}
00310 
00311     virtual
00312     void
00313     Execute()
00314     {
00315       SUIT_Session* aSession = SUIT_Session::session();
00316       SUIT_Application* anApplication = aSession->activeApplication();
00317       SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
00318 
00319       SALOME_NamingService* aNamingService = anApp->namingService();
00320       CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
00321       SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
00322       myStudy = aStudyMgr->GetStudyByID(myStudyID);
00323 
00324       SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
00325       aSMESHGen->SetCurrentStudy( myStudy.in() );
00326 
00327       myStudyBuilder = myStudy->NewBuilder();
00328 
00329       SALOMEDS::GenericAttribute_var anAttr;
00330       SALOMEDS::AttributeName_var    aName;
00331       SALOMEDS::AttributePixMap_var  aPixmap;
00332 
00333       SALOMEDS::SComponent_var aSComponent = myStudy->FindComponent("SMESH");
00334       if(aSComponent->_is_nil()){
00335         bool aLocked = myStudy->GetProperties()->IsLocked();
00336         if (aLocked)
00337           myStudy->GetProperties()->SetLocked(false);
00338         
00339         aSComponent = myStudyBuilder->NewComponent("SMESH");
00340         anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributeName");
00341         aName = SALOMEDS::AttributeName::_narrow(anAttr);
00342 
00343         SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); //SRN: BugID IPAL9186, load a SMESH gui if it hasn't been loaded
00344         if (!aSMESHGUI){
00345           CAM_Module* aModule = anApp->module("Mesh");
00346           if(!aModule)
00347               aModule = anApp->loadModule("Mesh");
00348           aSMESHGUI = dynamic_cast<SMESHGUI*>(aModule);
00349         } //SRN: BugID IPAL9186: end of a fix
00350         aName->SetValue(aSMESHGUI->moduleName().toLatin1().data());
00351         anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributePixMap");
00352         aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
00353         aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
00354         myStudyBuilder->DefineComponentInstance(aSComponent,aSMESHGen);
00355         if (aLocked)
00356           myStudy->GetProperties()->SetLocked(true);
00357       }
00358 
00359       mySComponentMesh = SALOMEDS::SComponent::_narrow(aSComponent);
00360 
00361       qApp->processEvents(); // Workaround for bug 12662
00362     }
00363   };
00364 
00365   MESSAGE("Init");
00366 
00367   ProcessVoidEvent(new TEvent(theStudyID,
00368                               myStudy,
00369                               myStudyBuilder,
00370                               mySComponentMesh));
00371 }
00372 
00373 
00374 //===============================================================
00375 SMESH_Swig::~SMESH_Swig()
00376 {
00377   MESSAGE("Destructeur");
00378 }
00379 
00380 
00381 //===============================================================
00382 const char* SMESH_Swig::AddNewMesh(const char* theIOR)
00383 {
00384   MESSAGE("AddNewMesh");
00385 
00386   // VSR: added temporarily - to be removed - objects are published automatically by engine
00387   SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(theIOR);
00388   if (aSObject->_is_nil()){
00389     //Find or Create Hypothesis root
00390     GetHypothesisRoot(mySComponentMesh,myStudyBuilder);
00391     GetAlgorithmsRoot(mySComponentMesh,myStudyBuilder);
00392 
00393     // Add New Mesh
00394     aSObject = myStudyBuilder->NewObject(mySComponentMesh);
00395     SALOMEDS::GenericAttribute_var anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
00396     SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
00397     aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
00398     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
00399     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
00400     anIOR->SetValue(theIOR);
00401   }
00402 
00403   CORBA::String_var anEntry = aSObject->GetID();
00404 
00405   return anEntry._retn();
00406 }
00407 
00408 
00409 //===============================================================
00410 const char* SMESH_Swig::AddNewHypothesis(const char* theIOR)
00411 {
00412   MESSAGE("AddNewHypothesis");
00413 
00414   SALOMEDS::SObject_var aSObject = ::AddHypothesis(theIOR,
00415                                                    mySComponentMesh,
00416                                                    myStudyBuilder);
00417   CORBA::String_var anEntry = aSObject->GetID();
00418   return anEntry._retn();
00419 }
00420 
00421 
00422 //===============================================================
00423 const char* SMESH_Swig::AddNewAlgorithms(const char* theIOR)
00424 {
00425   MESSAGE("AddNewAlgorithms");
00426 
00427   SALOMEDS::SObject_var aSObject = ::AddAlgorithms(theIOR,
00428                                                    mySComponentMesh,
00429                                                    myStudyBuilder);
00430   CORBA::String_var anEntry = aSObject->GetID();
00431   return anEntry._retn();
00432 }
00433 
00434 
00435 //===============================================================
00436 void SMESH_Swig::SetShape(const char* theShapeEntry,
00437                           const char* theMeshEntry)
00438 {
00439   SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID( theMeshEntry );
00440   SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID( theShapeEntry );
00441 
00442   if(!aMeshSO->_is_nil() && !aGeomShapeSO->_is_nil()){
00443     SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObjectToTag(aMeshSO, SMESH::Tag_RefOnShape);
00444     myStudyBuilder->Addreference(aSObject,aGeomShapeSO);
00445   }
00446 }
00447 
00448 
00449 //===============================================================
00450 void SMESH_Swig::SetHypothesis(const char* theMeshOrSubMeshEntry,
00451                                const char* theDomainEntry)
00452 {
00453   ::SetHypothesis(theMeshOrSubMeshEntry,
00454                   theDomainEntry,
00455                   myStudy,
00456                   myStudyBuilder);
00457 }
00458 
00459 
00460 //===============================================================
00461 void SMESH_Swig::SetAlgorithms(const char* theMeshOrSubMeshEntry,
00462                                const char* theDomainEntry)
00463 {
00464   ::SetAlgorithms(theMeshOrSubMeshEntry,
00465                   theDomainEntry,
00466                   myStudy,
00467                   myStudyBuilder);
00468 }
00469 
00470 
00471 //===============================================================
00472 void
00473 SMESH_Swig::UnSetHypothesis(const char* theDomainEntry)
00474 {
00475   SALOMEDS::SObject_var aDomainSO = myStudy->FindObjectID(theDomainEntry);
00476   if(!aDomainSO->_is_nil())
00477     myStudyBuilder->RemoveObject(aDomainSO);
00478 }
00479 
00480 const char* SMESH_Swig::AddSubMesh(const char* theMeshEntry,
00481                                    const char* theSubMeshIOR,
00482                                    int theShapeType)
00483 {
00484   SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(theMeshEntry);
00485   if(!aMeshSO->_is_nil()){
00486     long aShapeTag;
00487     QString aSubMeshName;
00488     switch(theShapeType){
00489     case TopAbs_SOLID:
00490       aShapeTag = SMESH::Tag_SubMeshOnSolid;
00491       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnSolid");
00492       break;
00493     case TopAbs_FACE:
00494       aShapeTag = SMESH::Tag_SubMeshOnFace;
00495       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnFace");
00496       break;
00497     case TopAbs_EDGE:
00498       aShapeTag = SMESH::Tag_SubMeshOnEdge;
00499       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnEdge");
00500       break;
00501     case TopAbs_VERTEX:
00502       aShapeTag = SMESH::Tag_SubMeshOnVertex;
00503       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnVertex");
00504       break;
00505     default:
00506       aShapeTag = SMESH::Tag_SubMeshOnCompound;
00507       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnCompound");
00508     }
00509 
00510     SALOMEDS::SObject_var aSubMeshesRoot;
00511     SALOMEDS::GenericAttribute_var anAttr;
00512     if(!aMeshSO->FindSubObject(aShapeTag,aSubMeshesRoot)){
00513       aSubMeshesRoot = myStudyBuilder->NewObjectToTag(aMeshSO,aShapeTag);
00514       anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeName");
00515       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
00516       aName->SetValue(aSubMeshName.toLatin1().data());
00517       anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeSelectable");
00518       SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
00519       aSelAttr->SetSelectable(false);
00520     }
00521 
00522     SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObject(aSubMeshesRoot);
00523     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
00524     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
00525     anIOR->SetValue(theSubMeshIOR);
00526 
00527     CORBA::String_var aString = aSObject->GetID();
00528     return aString._retn();
00529   }
00530 
00531   return "";
00532 }
00533 
00534 const char* SMESH_Swig::AddSubMeshOnShape(const char* theMeshEntry,
00535                                           const char* theGeomShapeEntry,
00536                                           const char* theSubMeshIOR,
00537                                           int ShapeType)
00538 {
00539   SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID(theGeomShapeEntry);
00540   if(!aGeomShapeSO->_is_nil()){
00541     const char * aSubMeshEntry = AddSubMesh(theMeshEntry,theSubMeshIOR,ShapeType);
00542     SALOMEDS::SObject_var aSubMeshSO = myStudy->FindObjectID(aSubMeshEntry);
00543     if(!aSubMeshSO->_is_nil()){
00544       SetShape(theGeomShapeEntry,aSubMeshEntry);
00545       CORBA::String_var aString = aSubMeshSO->GetID();
00546       return aString._retn();
00547     }
00548   }
00549 
00550   return "";
00551 }
00552 
00553 void SMESH_Swig::CreateAndDisplayActor( const char* Mesh_Entry )
00554 {
00555   //  SMESH_Actor* Mesh = smeshGUI->ReadScript(aM);
00556   class TEvent: public SALOME_Event
00557   {
00558   private:
00559     const char* _entry;
00560   public:
00561     TEvent(const char* Mesh_Entry) {
00562       _entry = Mesh_Entry;
00563     }
00564     virtual void Execute() {
00565       //SMESH::UpdateView(SMESH::eDisplay, _entry);
00566       SUIT_Session* aSession = SUIT_Session::session();
00567       SUIT_Application* anApplication = aSession->activeApplication();
00568       SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
00569       /*SUIT_ViewManager* vman = */anApp->getViewManager(VTKViewer_Viewer::Type(),true);
00570       SMESHGUI_Displayer* aDisp = new SMESHGUI_Displayer(anApp);
00571       aDisp->Display(_entry,1);
00572     }
00573   };
00574 
00575   ProcessVoidEvent(new TEvent(Mesh_Entry));
00576 }
00577 
00578 void SMESH_Swig::SetName(const char* theEntry,
00579                          const char* theName)
00580 {
00581   SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(theEntry);
00582   SALOMEDS::GenericAttribute_var anAttr;
00583   SALOMEDS::AttributeName_var aName;
00584   if(!aSObject->_is_nil()){
00585     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName");
00586     aName = SALOMEDS::AttributeName::_narrow(anAttr);
00587     aName->SetValue(theName);
00588   }
00589 }
00590 
00591 //================================================================================
00597 //================================================================================
00598 
00599 void SMESH_Swig::SetMeshIcon(const char* theMeshEntry,
00600                              const bool theIsComputed,
00601                              const bool isEmpty)
00602 {
00603   class TEvent: public SALOME_Event
00604   {
00605     SALOMEDS::Study_var myStudy;
00606     std::string myMeshEntry;
00607     bool myIsComputed, myIsEmpty;
00608   public:
00609     TEvent(const SALOMEDS::Study_var& theStudy,
00610            const std::string& theMeshEntry,
00611            const bool theIsComputed,
00612            const bool isEmpty):
00613       myStudy(theStudy),
00614       myMeshEntry(theMeshEntry),
00615       myIsComputed(theIsComputed),
00616       myIsEmpty(isEmpty)
00617     {}
00618 
00619     virtual
00620     void
00621     Execute()
00622     {
00623       SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(myMeshEntry.c_str());
00624       if(!aMeshSO->_is_nil())
00625         if(_PTR(SObject) aMesh = ClientFactory::SObject(aMeshSO))
00626           SMESH::ModifiedMesh(aMesh,myIsComputed,myIsEmpty);
00627     }
00628   };
00629 
00630   ProcessVoidEvent(new TEvent(myStudy,
00631                               theMeshEntry,
00632                               theIsComputed,
00633                               isEmpty));
00634 }