]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESHGUI/SMESHGUI_Swig.cxx
Salome HOME
PAL12662: salome_test.py execution crashes Salome on some stations.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Swig.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SMESH_Swig.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESHGUI_Swig.hxx"
30
31 #include "Utils_ORB_INIT.hxx"
32 #include "Utils_SINGLETON.hxx"
33
34 #include "SMESHGUI.h"
35 #include "SMESHGUI_Utils.h"
36 #include "SMESHGUI_GEOMGenUtils.h"
37
38 // SALOME Includes
39 #include "SUIT_ResourceMgr.h"
40 #include "SUIT_Session.h"
41
42 #include "SALOME_Event.hxx"
43 #include "SALOME_NamingService.hxx"
44 #include "SalomeApp_Application.h"
45 #include "SALOMEDSClient_ClientFactory.hxx"
46
47 #include "utilities.h"
48
49 // Open CASCADE Includes
50 #include <TopoDS.hxx>
51
52 // QT Includes
53 #include <qapplication.h>
54
55 // IDL Headers
56 #include <SALOMEconfig.h>
57 #include CORBA_SERVER_HEADER(SMESH_Gen)
58 #include CORBA_SERVER_HEADER(SMESH_Mesh)
59 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
60
61 using namespace std;
62
63 static CORBA::ORB_var anORB;
64
65 // Tags definition 
66 static long Tag_HypothesisRoot = 1;
67 static long Tag_AlgorithmsRoot = 2;
68   
69 static long Tag_RefOnShape = 1;
70 static long Tag_RefOnAppliedHypothesis = 2;
71 static long Tag_RefOnAppliedAlgorithms = 3;
72
73 static long Tag_SubMeshOnVertex = 4;
74 static long Tag_SubMeshOnEdge = 5;
75 static long Tag_SubMeshOnFace = 6;
76 static long Tag_SubMeshOnSolid = 7;
77 static long Tag_SubMeshOnCompound  = 8;
78
79 namespace
80 {
81   //---------------------------------------------------------------
82   inline
83   CORBA::Object_var
84   StringToObject(const std::string& theIOR)
85   {
86     return anORB->string_to_object(theIOR.c_str());
87   }
88
89
90   //---------------------------------------------------------------
91   inline
92   SALOMEDS::SObject_var
93   GetDomainRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
94                 const SALOMEDS::StudyBuilder_var& theStudyBuilder,
95                 CORBA::Long theDomainRootTag,
96                 const QString& theName,
97                 const QString& thePixmap)
98   {
99     SALOMEDS::SObject_var aDomainRoot;
100     if (!theSComponentMesh->FindSubObject(theDomainRootTag,aDomainRoot)) {
101       aDomainRoot = theStudyBuilder->NewObjectToTag(theSComponentMesh,theDomainRootTag);
102       SALOMEDS::GenericAttribute_var anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributeName");
103       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
104       aName->SetValue(theName.latin1());
105       anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributePixMap");
106       SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
107       aPixmap->SetPixMap(thePixmap.latin1());
108       anAttr = theStudyBuilder->FindOrCreateAttribute(aDomainRoot,"AttributeSelectable");
109       SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
110       aSelAttr->SetSelectable(false);
111     }
112
113     return aDomainRoot;
114   }
115
116
117   //---------------------------------------------------------------
118   inline
119   SALOMEDS::SObject_var
120   GetHypothesisRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
121                     const SALOMEDS::StudyBuilder_var& theStudyBuilder)
122   {
123     return GetDomainRoot(theSComponentMesh,
124                          theStudyBuilder,
125                          Tag_HypothesisRoot,
126                          QObject::tr("SMESH_MEN_HYPOTHESIS"),
127                          "ICON_SMESH_TREE_HYPO");
128   }
129   
130
131   //---------------------------------------------------------------
132   inline
133   SALOMEDS::SObject_var
134   GetAlgorithmsRoot(const SALOMEDS::SComponent_var& theSComponentMesh,
135                     const SALOMEDS::StudyBuilder_var& theStudyBuilder)
136   {
137     return GetDomainRoot(theSComponentMesh,
138                          theStudyBuilder,
139                          Tag_AlgorithmsRoot,
140                          QObject::tr("SMESH_MEN_ALGORITHMS"),
141                          "ICON_SMESH_TREE_ALGO");
142   }
143
144
145   //---------------------------------------------------------------
146   inline
147   SALOMEDS::SObject_var
148   AddToDomain(const std::string& theIOR,
149               const SALOMEDS::SComponent_var& theSComponentMesh,
150               const SALOMEDS::StudyBuilder_var& theStudyBuilder,
151               CORBA::Long theDomainRootTag,
152               const QString& theDomainName,
153               const QString& theDomainPixmap)
154   {
155     SALOMEDS::SObject_var aDomain = GetDomainRoot(theSComponentMesh,
156                                                   theStudyBuilder,
157                                                   Tag_AlgorithmsRoot,
158                                                   theDomainName,
159                                                   theDomainPixmap);
160     // Add New Hypothesis
161     SALOMEDS::SObject_var aSObject = theStudyBuilder->NewObject(aDomain);
162     SALOMEDS::GenericAttribute_var anAttr = theStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
163     SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
164     CORBA::Object_var anObject = StringToObject(theIOR);
165     SMESH::SMESH_Hypothesis_var aDomainItem = SMESH::SMESH_Hypothesis::_narrow(anObject.in());
166     CORBA::String_var aType = aDomainItem->GetName();
167     QString aPixmapName = theDomainPixmap + "_" + aType.in();
168     aPixmap->SetPixMap(aPixmapName.latin1());
169     anAttr = theStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
170     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
171     anIOR->SetValue(theIOR.c_str());
172     
173     return aSObject;
174   }
175
176
177   //---------------------------------------------------------------
178   SALOMEDS::SObject_var
179   AddHypothesis(const std::string& theIOR,
180                 const SALOMEDS::SComponent_var& theSComponentMesh,
181                 const SALOMEDS::StudyBuilder_var& theStudyBuilder)
182   {
183     return AddToDomain(theIOR,
184                        theSComponentMesh,
185                        theStudyBuilder,
186                        Tag_HypothesisRoot,
187                        QObject::tr("SMESH_MEN_HYPOTHESIS"),
188                        "ICON_SMESH_TREE_HYPO");
189   }
190
191
192   //---------------------------------------------------------------
193   SALOMEDS::SObject_var
194   AddAlgorithms(const std::string& theIOR,
195                 const SALOMEDS::SComponent_var& theSComponentMesh,
196                 const SALOMEDS::StudyBuilder_var& theStudyBuilder)
197   {
198     return AddToDomain(theIOR,
199                        theSComponentMesh,
200                        theStudyBuilder,
201                        Tag_AlgorithmsRoot,
202                        QObject::tr("SMESH_MEN_ALGORITHMS"),
203                        "ICON_SMESH_TREE_ALGO");
204   }
205
206
207   //---------------------------------------------------------------
208   void
209   SetDomain(const char* theMeshOrSubMeshEntry, 
210             const char* theDomainEntry,
211             const SALOMEDS::Study_var& theStudy,
212             const SALOMEDS::StudyBuilder_var& theStudyBuilder,
213             long theRefOnAppliedDomainTag,
214             const QString& theAppliedDomainMEN,
215             const QString& theAppliedDomainICON)
216   {
217     SALOMEDS::SObject_var aMeshOrSubMeshSO = theStudy->FindObjectID(theMeshOrSubMeshEntry);
218     SALOMEDS::SObject_var aHypothesisSO = theStudy->FindObjectID(theDomainEntry);
219
220     if(!aMeshOrSubMeshSO->_is_nil() && !aHypothesisSO->_is_nil()){
221       //Find or Create Applied Hypothesis root
222       SALOMEDS::SObject_var anAppliedDomainSO;
223       if(!aMeshOrSubMeshSO->FindSubObject(theRefOnAppliedDomainTag,anAppliedDomainSO)){
224         anAppliedDomainSO = theStudyBuilder->NewObjectToTag(aMeshOrSubMeshSO,theRefOnAppliedDomainTag);
225         SALOMEDS::GenericAttribute_var anAttr = 
226           theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributeName");
227         SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
228         aName->SetValue(theAppliedDomainMEN.latin1());
229         anAttr = theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributeSelectable");
230         SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
231         aSelAttr->SetSelectable(false);
232         anAttr = theStudyBuilder->FindOrCreateAttribute(anAppliedDomainSO,"AttributePixMap");
233         SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
234         aPixmap->SetPixMap(theAppliedDomainICON.latin1());
235       }
236       SALOMEDS::SObject_var aSObject = theStudyBuilder->NewObject(anAppliedDomainSO);
237       theStudyBuilder->Addreference(aSObject,aHypothesisSO);
238     }
239   }
240
241
242   //---------------------------------------------------------------
243   void
244   SetHypothesis(const char* theMeshOrSubMeshEntry, 
245                 const char* theDomainEntry,
246                 const SALOMEDS::Study_var& theStudy,
247                 const SALOMEDS::StudyBuilder_var& theStudyBuilder)
248   {
249     SetDomain(theMeshOrSubMeshEntry,
250               theDomainEntry,
251               theStudy,
252               theStudyBuilder,
253               Tag_RefOnAppliedHypothesis,
254               QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS"),
255               "ICON_SMESH_TREE_HYPO");
256   }
257
258
259   //---------------------------------------------------------------
260   void
261   SetAlgorithms(const char* theMeshOrSubMeshEntry, 
262                 const char* theDomainEntry,
263                 const SALOMEDS::Study_var& theStudy,
264                 const SALOMEDS::StudyBuilder_var& theStudyBuilder)
265   {
266     SetDomain(theMeshOrSubMeshEntry,
267               theDomainEntry,
268               theStudy,
269               theStudyBuilder,
270               Tag_RefOnAppliedAlgorithms,
271               QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS"),
272               "ICON_SMESH_TREE_ALGO");
273   }
274 }
275
276
277 //===============================================================
278 SMESH_Swig::SMESH_Swig()
279 {
280   class TEvent: public SALOME_Event
281   {
282     CORBA::ORB_var& myORB;
283   public:
284
285     TEvent(CORBA::ORB_var& theORB):
286       myORB(theORB)
287     {}
288
289     virtual
290     void
291     Execute()
292     {
293       try {
294         ORB_INIT &anORBInit = *SINGLETON_<ORB_INIT>::Instance();
295         ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
296         myORB = anORBInit( 0 , 0 );
297       } catch (...) {
298         INFOS("internal error : orb not found");
299       }
300     }
301   };
302
303   MESSAGE("Constructeur");
304
305   if(CORBA::is_nil(anORB))
306     ProcessVoidEvent(new TEvent(anORB));
307
308   ASSERT(!CORBA::is_nil(anORB));
309 }
310
311
312 //===============================================================
313 void
314 SMESH_Swig::Init(int theStudyID)
315 {
316   class TEvent: public SALOME_Event
317   {
318     int myStudyID;
319     SALOMEDS::Study_var& myStudy;
320     SALOMEDS::StudyBuilder_var& myStudyBuilder;
321     SALOMEDS::SComponent_var& mySComponentMesh;
322   public:
323     TEvent(int theStudyID,
324            SALOMEDS::Study_var& theStudy,
325            SALOMEDS::StudyBuilder_var& theStudyBuilder,
326            SALOMEDS::SComponent_var& theSComponentMesh):
327       myStudyID(theStudyID),
328       myStudy(theStudy),
329       myStudyBuilder(theStudyBuilder),
330       mySComponentMesh(theSComponentMesh)
331     {}
332
333     virtual
334     void
335     Execute()
336     {
337       SUIT_Session* aSession = SUIT_Session::session();
338       SUIT_Application* anApplication = aSession->activeApplication();
339       SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
340
341       SALOME_NamingService* aNamingService = anApp->namingService();
342       CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
343       SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
344       myStudy = aStudyMgr->GetStudyByID(myStudyID);
345
346       SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
347       aSMESHGen->SetCurrentStudy( myStudy.in() ); 
348
349       myStudyBuilder = myStudy->NewBuilder();
350
351       SALOMEDS::GenericAttribute_var anAttr;
352       SALOMEDS::AttributeName_var    aName;
353       SALOMEDS::AttributePixMap_var  aPixmap;
354
355       SALOMEDS::SComponent_var aSComponent = myStudy->FindComponent("SMESH");
356       if(aSComponent->_is_nil()){
357         bool aLocked = myStudy->GetProperties()->IsLocked();
358         if (aLocked) 
359           myStudy->GetProperties()->SetLocked(false);
360         
361         aSComponent = myStudyBuilder->NewComponent("SMESH");
362         anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributeName");
363         aName = SALOMEDS::AttributeName::_narrow(anAttr);
364
365         SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); //SRN: BugID IPAL9186, load a SMESH gui if it hasn't been loaded
366         if(!aSMESHGUI){
367           CAM_Module* aModule = anApp->module("Mesh");
368           if(!aModule) 
369               aModule = anApp->loadModule("Mesh");
370           aSMESHGUI = dynamic_cast<SMESHGUI*>(aModule); 
371         } //SRN: BugID IPAL9186: end of a fix
372         aName->SetValue(aSMESHGUI->moduleName());
373         anAttr = myStudyBuilder->FindOrCreateAttribute(aSComponent,"AttributePixMap");
374         aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
375         aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
376         myStudyBuilder->DefineComponentInstance(aSComponent,aSMESHGen);
377         if(aLocked) 
378           myStudy->GetProperties()->SetLocked(true);
379       }
380
381       mySComponentMesh = SALOMEDS::SComponent::_narrow(aSComponent);
382
383       qApp->processEvents(); // Workaround for bug 12662
384     }
385   };
386
387   MESSAGE("Init");
388
389   ProcessVoidEvent(new TEvent(theStudyID,
390                               myStudy,
391                               myStudyBuilder,
392                               mySComponentMesh));
393 }
394
395
396 //===============================================================
397 SMESH_Swig::~SMESH_Swig()
398 {
399   MESSAGE("Destructeur");
400 }
401
402
403 //===============================================================
404 const char* 
405 SMESH_Swig::AddNewMesh(const char* theIOR)
406 {
407   MESSAGE("AddNewMesh");
408
409   // VSR: added temporarily - to be removed - objects are published automatically by engine
410   SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(theIOR);
411   if(aSObject->_is_nil()){
412     //Find or Create Hypothesis root
413     GetHypothesisRoot(mySComponentMesh,myStudyBuilder);
414     GetAlgorithmsRoot(mySComponentMesh,myStudyBuilder);
415     
416     // Add New Mesh
417     aSObject = myStudyBuilder->NewObject(mySComponentMesh);
418     SALOMEDS::GenericAttribute_var anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
419     SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
420     aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
421     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
422     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
423     anIOR->SetValue(theIOR);
424   }
425
426   CORBA::String_var anEntry = aSObject->GetID();
427
428   return anEntry._retn();
429 }
430
431
432 //===============================================================
433 const char* 
434 SMESH_Swig::AddNewHypothesis(const char* theIOR)
435 {
436
437   MESSAGE("AddNewHypothesis");
438   
439   SALOMEDS::SObject_var aSObject = ::AddHypothesis(theIOR,
440                                                    mySComponentMesh,
441                                                    myStudyBuilder);
442   CORBA::String_var anEntry = aSObject->GetID();
443   return anEntry._retn();
444 }
445
446
447 //===============================================================
448 const char* 
449 SMESH_Swig::AddNewAlgorithms(const char* theIOR)
450 {
451   MESSAGE("AddNewAlgorithms");
452   
453   SALOMEDS::SObject_var aSObject = ::AddAlgorithms(theIOR,
454                                                    mySComponentMesh,
455                                                    myStudyBuilder);
456   CORBA::String_var anEntry = aSObject->GetID();
457   return anEntry._retn();
458 }
459
460
461 //===============================================================
462 void 
463 SMESH_Swig::SetShape(const char* theShapeEntry, 
464                      const char* theMeshEntry)
465 {
466   SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID( theMeshEntry );
467   SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID( theShapeEntry );
468   
469   if(!aMeshSO->_is_nil() && !aGeomShapeSO->_is_nil()){
470     SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObjectToTag(aMeshSO,Tag_RefOnShape);
471     myStudyBuilder->Addreference(aSObject,aGeomShapeSO);
472   }
473 }
474
475
476 //===============================================================
477 void 
478 SMESH_Swig::SetHypothesis(const char* theMeshOrSubMeshEntry, 
479                           const char* theDomainEntry)
480 {
481   ::SetHypothesis(theMeshOrSubMeshEntry,
482                   theDomainEntry,
483                   myStudy,
484                   myStudyBuilder);
485 }
486
487
488 //===============================================================
489 void 
490 SMESH_Swig::SetAlgorithms(const char* theMeshOrSubMeshEntry, 
491                           const char* theDomainEntry)
492 {
493   ::SetAlgorithms(theMeshOrSubMeshEntry,
494                   theDomainEntry,
495                   myStudy,
496                   myStudyBuilder);
497 }
498
499
500 //===============================================================
501 void
502 SMESH_Swig::UnSetHypothesis(const char* theDomainEntry)
503 {
504   SALOMEDS::SObject_var aDomainSO = myStudy->FindObjectID(theDomainEntry);
505   if(!aDomainSO->_is_nil())
506     myStudyBuilder->RemoveObject(aDomainSO);
507 }
508
509 const char* 
510 SMESH_Swig::AddSubMesh(const char* theMeshEntry, 
511                        const char* theSubMeshIOR, 
512                        int theShapeType)
513 {
514   SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(theMeshEntry);
515   if(!aMeshSO->_is_nil()){
516     long aShapeTag;
517     QString aSubMeshName;
518     switch(theShapeType){
519     case TopAbs_SOLID:
520       aShapeTag = Tag_SubMeshOnSolid;
521       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnSolid");
522       break;
523     case TopAbs_FACE:
524       aShapeTag = Tag_SubMeshOnFace;
525       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnFace");
526       break;
527     case TopAbs_EDGE:
528       aShapeTag = Tag_SubMeshOnEdge;
529       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnEdge");
530       break;
531     case TopAbs_VERTEX:
532       aShapeTag = Tag_SubMeshOnVertex;
533       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnVertex");
534       break;
535     default:
536       aShapeTag = Tag_SubMeshOnCompound;
537       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnCompound");      
538     }
539       
540     SALOMEDS::SObject_var aSubMeshesRoot;
541     SALOMEDS::GenericAttribute_var anAttr;
542     if(!aMeshSO->FindSubObject(aShapeTag,aSubMeshesRoot)){
543       aSubMeshesRoot = myStudyBuilder->NewObjectToTag(aMeshSO,aShapeTag);
544       anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeName");
545       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
546       aName->SetValue(aSubMeshName.latin1());
547       anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeSelectable");
548       SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
549       aSelAttr->SetSelectable(false);
550     }
551
552     SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObject(aSubMeshesRoot);
553     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
554     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
555     anIOR->SetValue(theSubMeshIOR);
556
557     CORBA::String_var aString = aSObject->GetID();
558     return aString._retn();
559   }
560
561   return "";
562 }
563
564 const char* 
565 SMESH_Swig::AddSubMeshOnShape(const char* theMeshEntry, 
566                               const char* theGeomShapeEntry, 
567                               const char* theSubMeshIOR, 
568                               int ShapeType)
569 {
570   SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID(theGeomShapeEntry);
571   if(!aGeomShapeSO->_is_nil()){
572     const char * aSubMeshEntry = AddSubMesh(theMeshEntry,theSubMeshIOR,ShapeType);
573     SALOMEDS::SObject_var aSubMeshSO = myStudy->FindObjectID(aSubMeshEntry);
574     if(!aSubMeshSO->_is_nil()){
575       SetShape(theGeomShapeEntry,aSubMeshEntry);
576       CORBA::String_var aString = aSubMeshSO->GetID();
577       return aString._retn();
578     }
579   }
580
581   return "";
582 }
583
584 void SMESH_Swig::CreateAndDisplayActor( const char* Mesh_Entry )
585 {
586   //  SMESH_Actor* Mesh = smeshGUI->ReadScript(aM);
587 }
588
589 void
590 SMESH_Swig::SetName(const char* theEntry, 
591                     const char* theName)
592 {
593   SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(theEntry);
594   SALOMEDS::GenericAttribute_var anAttr;
595   SALOMEDS::AttributeName_var aName;
596   if(!aSObject->_is_nil()){
597     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName");
598     aName = SALOMEDS::AttributeName::_narrow(anAttr);
599     aName->SetValue(theName);
600   }
601 }
602
603 //================================================================================
604 /*!
605  * \brief Set mesh icon according to compute status
606   * \param Mesh_Entry - entry of a mesh
607   * \param isComputed - is mesh computed or not
608  */
609 //================================================================================
610
611 void SMESH_Swig::SetMeshIcon(const char* theMeshEntry, 
612                              const bool theIsComputed)
613 {
614   class TEvent: public SALOME_Event
615   {
616     SALOMEDS::Study_var myStudy;
617     std::string myMeshEntry;
618     bool myIsComputed;
619   public:
620     TEvent(const SALOMEDS::Study_var& theStudy,
621            const std::string& theMeshEntry,
622            const bool theIsComputed):
623       myStudy(theStudy),
624       myMeshEntry(theMeshEntry),
625       myIsComputed(theIsComputed)
626     {}
627
628     virtual
629     void
630     Execute()
631     {
632       SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(myMeshEntry.c_str());
633       if(!aMeshSO->_is_nil())
634         if(_PTR(SObject) aMesh = ClientFactory::SObject(aMeshSO))
635           SMESH::ModifiedMesh(aMesh,myIsComputed);
636     }
637   };
638
639   ProcessVoidEvent(new TEvent(myStudy,
640                               theMeshEntry,
641                               theIsComputed));
642 }