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