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