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