]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESHGUI/SMESHGUI_Swig.cxx
Salome HOME
fix vector definition by 2 points
[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       if(SUIT_ResourceMgr* aResMgr = SMESHGUI::resourceMgr())
335         aResMgr->loadLanguage( QString::null, "en" );
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   };
384
385   MESSAGE("Init");
386
387   ProcessVoidEvent(new TEvent(theStudyID,
388                               myStudy,
389                               myStudyBuilder,
390                               mySComponentMesh));
391 }
392
393
394 //===============================================================
395 SMESH_Swig::~SMESH_Swig()
396 {
397   MESSAGE("Destructeur");
398 }
399
400
401 //===============================================================
402 const char* 
403 SMESH_Swig::AddNewMesh(const char* theIOR)
404 {
405   MESSAGE("AddNewMesh");
406
407   // VSR: added temporarily - to be removed - objects are published automatically by engine
408   SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(theIOR);
409   if(aSObject->_is_nil()){
410     //Find or Create Hypothesis root
411     GetHypothesisRoot(mySComponentMesh,myStudyBuilder);
412     GetAlgorithmsRoot(mySComponentMesh,myStudyBuilder);
413     
414     // Add New Mesh
415     aSObject = myStudyBuilder->NewObject(mySComponentMesh);
416     SALOMEDS::GenericAttribute_var anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributePixMap");
417     SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
418     aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
419     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
420     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
421     anIOR->SetValue(theIOR);
422   }
423
424   CORBA::String_var anEntry = aSObject->GetID();
425
426   return anEntry._retn();
427 }
428
429
430 //===============================================================
431 const char* 
432 SMESH_Swig::AddNewHypothesis(const char* theIOR)
433 {
434
435   MESSAGE("AddNewHypothesis");
436   
437   SALOMEDS::SObject_var aSObject = ::AddHypothesis(theIOR,
438                                                    mySComponentMesh,
439                                                    myStudyBuilder);
440   CORBA::String_var anEntry = aSObject->GetID();
441   return anEntry._retn();
442 }
443   
444
445 //===============================================================
446 const char* 
447 SMESH_Swig::AddNewAlgorithms(const char* theIOR)
448 {
449   MESSAGE("AddNewAlgorithms");
450   
451   SALOMEDS::SObject_var aSObject = ::AddAlgorithms(theIOR,
452                                                    mySComponentMesh,
453                                                    myStudyBuilder);
454   CORBA::String_var anEntry = aSObject->GetID();
455   return anEntry._retn();
456 }
457
458
459 //===============================================================
460 void 
461 SMESH_Swig::SetShape(const char* theShapeEntry, 
462                      const char* theMeshEntry)
463 {
464   SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID( theMeshEntry );
465   SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID( theShapeEntry );
466   
467   if(!aMeshSO->_is_nil() && !aGeomShapeSO->_is_nil()){
468     SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObjectToTag(aMeshSO,Tag_RefOnShape);
469     myStudyBuilder->Addreference(aSObject,aGeomShapeSO);
470   }
471 }
472
473
474 //===============================================================
475 void 
476 SMESH_Swig::SetHypothesis(const char* theMeshOrSubMeshEntry, 
477                           const char* theDomainEntry)
478 {
479   ::SetHypothesis(theMeshOrSubMeshEntry,
480                   theDomainEntry,
481                   myStudy,
482                   myStudyBuilder);
483 }
484
485
486 //===============================================================
487 void 
488 SMESH_Swig::SetAlgorithms(const char* theMeshOrSubMeshEntry, 
489                           const char* theDomainEntry)
490 {
491   ::SetAlgorithms(theMeshOrSubMeshEntry,
492                   theDomainEntry,
493                   myStudy,
494                   myStudyBuilder);
495 }
496
497
498 //===============================================================
499 void
500 SMESH_Swig::UnSetHypothesis(const char* theDomainEntry)
501 {
502   SALOMEDS::SObject_var aDomainSO = myStudy->FindObjectID(theDomainEntry);
503   if(!aDomainSO->_is_nil())
504     myStudyBuilder->RemoveObject(aDomainSO);
505 }
506
507 const char* 
508 SMESH_Swig::AddSubMesh(const char* theMeshEntry, 
509                        const char* theSubMeshIOR, 
510                        int theShapeType)
511 {
512   SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(theMeshEntry);
513   if(!aMeshSO->_is_nil()){
514     long aShapeTag;
515     QString aSubMeshName;
516     switch(theShapeType){
517     case TopAbs_SOLID:
518       aShapeTag = Tag_SubMeshOnSolid;
519       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnSolid");
520       break;
521     case TopAbs_FACE:
522       aShapeTag = Tag_SubMeshOnFace;
523       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnFace");
524       break;
525     case TopAbs_EDGE:
526       aShapeTag = Tag_SubMeshOnEdge;
527       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnEdge");
528       break;
529     case TopAbs_VERTEX:
530       aShapeTag = Tag_SubMeshOnVertex;
531       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnVertex");
532       break;
533     default:
534       aShapeTag = Tag_SubMeshOnCompound;
535       aSubMeshName = QObject::tr("SMESH_MEN_SubMeshesOnCompound");      
536     }
537       
538     SALOMEDS::SObject_var aSubMeshesRoot;
539     SALOMEDS::GenericAttribute_var anAttr;
540     if(!aMeshSO->FindSubObject(aShapeTag,aSubMeshesRoot)){
541       aSubMeshesRoot = myStudyBuilder->NewObjectToTag(aMeshSO,aShapeTag);
542       anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeName");
543       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
544       aName->SetValue(aSubMeshName.latin1());
545       anAttr = myStudyBuilder->FindOrCreateAttribute(aSubMeshesRoot,"AttributeSelectable");
546       SALOMEDS::AttributeSelectable_var aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
547       aSelAttr->SetSelectable(false);
548     }
549
550     SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObject(aSubMeshesRoot);
551     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
552     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
553     anIOR->SetValue(theSubMeshIOR);
554
555     CORBA::String_var aString = aSObject->GetID();
556     return aString._retn();
557   }
558
559   return "";
560 }
561
562 const char* 
563 SMESH_Swig::AddSubMeshOnShape(const char* theMeshEntry, 
564                               const char* theGeomShapeEntry, 
565                               const char* theSubMeshIOR, 
566                               int ShapeType)
567 {
568   SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID(theGeomShapeEntry);
569   if(!aGeomShapeSO->_is_nil()){
570     const char * aSubMeshEntry = AddSubMesh(theMeshEntry,theSubMeshIOR,ShapeType);
571     SALOMEDS::SObject_var aSubMeshSO = myStudy->FindObjectID(aSubMeshEntry);
572     if(!aSubMeshSO->_is_nil()){
573       SetShape(theGeomShapeEntry,aSubMeshEntry);
574       CORBA::String_var aString = aSubMeshSO->GetID();
575       return aString._retn();
576     }
577   }
578
579   return "";
580 }
581
582 void SMESH_Swig::CreateAndDisplayActor( const char* Mesh_Entry )
583 {
584   //  SMESH_Actor* Mesh = smeshGUI->ReadScript(aM);
585 }
586
587 void
588 SMESH_Swig::SetName(const char* theEntry, 
589                     const char* theName)
590 {
591   SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(theEntry);
592   SALOMEDS::GenericAttribute_var anAttr;
593   SALOMEDS::AttributeName_var aName;
594   if(!aSObject->_is_nil()){
595     anAttr = myStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName");
596     aName = SALOMEDS::AttributeName::_narrow(anAttr);
597     aName->SetValue(theName);
598   }
599 }
600
601 //================================================================================
602 /*!
603  * \brief Set mesh icon according to compute status
604   * \param Mesh_Entry - entry of a mesh
605   * \param isComputed - is mesh computed or not
606  */
607 //================================================================================
608
609 void SMESH_Swig::SetMeshIcon(const char* theMeshEntry, 
610                              const bool theIsComputed)
611 {
612   SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(theMeshEntry);
613   if(!aMeshSO->_is_nil())
614     if(_PTR(SObject) aMesh = ClientFactory::SObject(aMeshSO))
615       SMESH::ModifiedMesh(aMesh,theIsComputed);
616 }