Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/med.git] / src / MEDGUI / MedGUI.cxx
1 //  MED MEDGUI : MED component GUI implemetation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : MedGUI.cxx
25 //  Module : MED
26
27 #include "MedGUI.h"
28
29 // SALOME Includes
30 #include "Utils_ORB_INIT.hxx"
31 #include "Utils_SINGLETON.hxx"
32 #include "utilities.h"
33
34 #include <SALOME_LifeCycleCORBA.hxx>
35 #include <SALOME_InteractiveObject.hxx>
36 #include <SALOME_ListIO.hxx>
37 #include <SalomeApp_Tools.h>
38
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_Tools.h>
41 #include <SUIT_FileDlg.h>
42 #include <SUIT_ResourceMgr.h>
43
44 #include <CAM_Application.h>
45 #include <SalomeApp_Application.h>
46 #include <SalomeApp_DataModel.h>
47 #include <SalomeApp_Study.h>
48 #include <SALOMEDSClient_Study.hxx>
49 #include <SALOMEDSClient_SObject.hxx>
50
51 #include <LightApp_SelectionMgr.h>
52
53 #include <OB_Browser.h>
54
55 //#include "SMESH_TypeFilter.hxx"
56
57 #include <MedGUI_Selection.h>
58
59 // QT Includes
60 #include <qinputdialog.h>
61
62 //VRV: porting on Qt 3.0.5
63 #if QT_VERSION >= 0x030005
64 #include <qlineedit.h>
65 #endif
66 //VRV: porting on Qt 3.0.5
67
68 using namespace std;
69
70 static CORBA::ORB_var   _orb;
71
72 //=============================================================================
73 /*!
74  *
75  */
76 //=============================================================================
77 MedGUI::MedGUI() :
78   SalomeApp_Module( "MED" )
79 {}
80
81 //=============================================================================
82 /*!
83  *
84  */
85 //=============================================================================
86 void MedGUI::createPopupItem( const int id,
87                               const QString& clients,
88                               const QString& types,
89                               const QString& theRule,
90                               const int pId )
91 {
92   int parentId = pId;
93   if( pId!=-1 )
94     parentId = popupMgr()->actionId( action( pId ) );
95
96   if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
97     popupMgr()->insert( action( id ), parentId, 0 );
98
99   QChar lc = QtxPopupMgr::Selection::defEquality();
100   QString rule = "(%1)";
101   if( !types.isEmpty() )
102     rule += " and (%2) and (%3)";
103
104   rule = rule.arg( QString( "client in {%1}" ).arg( clients ) );
105
106   if( !types.isEmpty() )
107   {
108     rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
109     rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
110   }
111   rule += theRule;
112   popupMgr()->setRule( action( id ), rule, true );
113 }
114
115 void MedGUI::createMedAction( const int id, const QString& po_id, const QString& icon_id )
116 {
117   QWidget* parent = application()->desktop();
118   SUIT_ResourceMgr* mgr = application()->resourceMgr();
119
120   QPixmap pix; QIconSet icon;
121   if( !icon_id.isEmpty() )
122     pix = mgr->loadPixmap( "MED", tr( icon_id ) );
123 //   else
124 //     pix = mgr->loadPixmap( "MED", tr( QString( "ICO_" )+po_id ) );
125
126   if ( !pix.isNull() )
127     icon = QIconSet( pix );
128
129   createAction( id, tr( "TOP_" + po_id ), icon, tr( "MEN_" + po_id ), tr( "STB_" + po_id ), 0, parent, false, this, SLOT( onGUIEvent() ) );
130 }
131
132 //=============================================================================
133 /*!
134  *
135  */
136 //=============================================================================
137 void MedGUI::initialize( CAM_Application* app )
138 {
139   SalomeApp_Module::initialize( app );
140
141   QWidget* parent = application()->desktop();
142
143   createMedAction( 931, "MESHSEL" );
144   createMedAction( 932, "FIELDSEL" );
145   createMedAction( 933, "EXPLORE" );
146   createMedAction( 934, "DUMPMESH" );
147   createMedAction( 935, "DUMPSUBMESH" );
148 //   createMedAction( 8031, "POPUPTEST" );
149 //   createMedAction( 9002, "ERASE" );
150 //   createMedAction( 9003, "DISPLAY" );
151   createMedAction( 4031, "MESHSEL", "ICO_TB_MESHSEL" );
152   createMedAction( 4032, "FIELDSEL", "ICO_TB_FIELDSEL" );
153   createMedAction( 4033, "EXPLORE", "ICO_TB_EXPLORE" );
154
155   int MedId = createMenu( tr( "MED" ), -1, 50, 10 );
156   createMenu( separator(), MedId, 10 );
157   createMenu( 931, MedId, 11 );
158   createMenu( 932, MedId, 11 );
159   createMenu( 933, MedId, 11 );
160   createMenu( 934, MedId, 11 );
161   createMenu( 935, MedId, 11 );
162
163   int medTb = createTool( tr( "TB_MED" ) );
164   createTool( 4031, medTb );
165   createTool( 4032, medTb );
166   createTool( 4033, medTb );
167
168 //   QString OB = "'ObjectBrowser'",
169 //           View = QString("'%1'").arg( "VTKViewer" /* SVTK_Viewer::Type()*/ );
170
171 //   createPopupItem( 8031, View, "", "" );
172 //   createPopupItem( 9002, OB, "", "" );
173 //   createPopupItem( 903,  OB, "", "" );
174 }
175
176 void MedGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
177 {
178   MedGUI_Selection sel;
179   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
180   if( app )
181   {
182     sel.init( client, app->selectionMgr() );
183     popupMgr()->updatePopup( menu, &sel );
184   }
185 }
186
187 QString MedGUI::engineIOR() const
188 {
189   QString anIOR( "" );
190   SALOME_MED::MED_Gen_ptr aMedGen = InitMedGen();
191   if ( !CORBA::is_nil( aMedGen) )
192   {
193     CORBA::String_var objStr = getApp()->orb()->object_to_string( aMedGen );
194     anIOR = QString( objStr.in() );
195   }
196   return anIOR;
197 }
198
199 void MedGUI::windows( QMap<int, int>& mappa ) const
200 {
201   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
202   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
203 }
204
205
206 //=============================================================================
207 /*!
208  *
209  */
210 //=============================================================================
211 void MedGUI::onGUIEvent()
212 {
213   const QObject* obj = sender();
214   if ( !obj || !obj->inherits( "QAction" ) )
215     return;
216   int id = actionId((QAction*)obj);
217   if ( id != -1 )
218     OnGUIEvent( id );
219 }
220
221 //=============================================================================
222 /*!
223  *
224  */
225 //=============================================================================
226 void MedGUI::EmitSignalCloseAllDialogs()
227 {
228   emit SignalCloseAllDialogs();
229 }
230
231 //=============================================================================
232 /*!
233  *
234  */
235 //=============================================================================
236 bool MedGUI::deactivateModule( SUIT_Study* study )
237 {
238   setMenuShown( false );
239   setToolShown( false );
240
241   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
242              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
243
244   EmitSignalCloseAllDialogs();
245
246   return SalomeApp_Module::deactivateModule( study );
247 }
248
249 //=============================================================================
250 /*!
251  *
252  */
253 //=============================================================================
254 bool MedGUI::activateModule( SUIT_Study* study )
255 {
256   bool res = SalomeApp_Module::activateModule( study );
257
258   setMenuShown( true );
259   setToolShown( true );
260
261   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
262           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
263   return res;
264 }
265
266 //=============================================================================
267 /*!
268  *
269  */
270 //=============================================================================
271 void MedGUI::onWindowActivated( SUIT_ViewWindow* )
272 {
273 }
274
275 //=============================================================================
276 /*!
277  *
278  */
279 //=============================================================================
280 bool MedGUI::OnGUIEvent (int theCommandID)
281 {
282   setOrb();
283
284   SalomeApp_Study* myActiveStudy = dynamic_cast< SalomeApp_Study* >( application()->activeStudy() );
285   if( !myActiveStudy )
286     return false;
287
288   _PTR(Study) aStudy = myActiveStudy->studyDS();
289   //SALOME_NamingService* myNameService = parent->getNameService();
290
291   QString file;
292   QStringList filtersList ;
293
294   filtersList.append( tr("MED_MEN_IMPORT_MED") );
295   filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
296
297   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
298   if( !app )
299     return false;
300
301   switch (theCommandID)
302     {
303     case 4031:
304     case 9031:
305     case 931:
306       {
307         MESSAGE("command " << theCommandID << " activated");
308
309         QString myStudyName = myActiveStudy->studyName();
310         bool ok=FALSE;
311 //      int myStudyId = myActiveStudy->id();
312
313         // load MED engine
314         SALOME_MED::MED_Gen_ptr medgen = InitMedGen();
315
316         // Selection du Fichier
317         file = SUIT_FileDlg::getFileName(application()->desktop(),
318                                         "",
319                                         filtersList,
320                                         tr("MED_MEN_IMPORT"),
321                                         true);
322
323         // Selection du Maillage
324         if (!file.isEmpty() )
325           {
326             SCRUTE(file);
327             QString meshName;
328             meshName = QInputDialog::getText( QString( tr("MED_INF_MESHNAME") ),
329                                               QString::null,
330                                               //VRV: porting on Qt 3.0.5
331 #if QT_VERSION >= 0x030005
332                                               QLineEdit::Normal,
333 #endif
334                                               //VRV: porting on Qt 3.0.5
335                                               QString::null, &ok);
336             if ( ! meshName.isEmpty())
337               {
338                   try
339                     {
340                       medgen->readMeshInFile(file.latin1(),myStudyName,meshName);
341                       if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) {
342                         SUIT_MessageBox::warn1 (application()->desktop(),
343                                                QObject::tr("WRN_WARNING"),
344                                                QObject::tr("WRN_STUDY_LOCKED"),
345                                                QObject::tr("BUT_OK"));
346                       }
347                     }
348                   catch (const SALOME::SALOME_Exception & S_ex)
349                     {
350                       SalomeApp_Tools::QtCatchCorbaException(S_ex);
351                     }
352                 }
353                 updateObjBrowser();
354           }
355         break;
356       }
357     case 4032:
358     case 9032:
359     case 932:
360       {
361         MESSAGE("command " << theCommandID << " activated");
362
363         QString myStudyName = myActiveStudy->studyName();
364         bool ok=FALSE;
365 //      int myStudyId = myActiveStudy->id();
366
367         // load MED engine
368         SALOME_MED::MED_Gen_ptr medgen = InitMedGen();
369
370         // Selection du Fichier
371         file = SUIT_FileDlg::getFileName(application()->desktop(),
372                                         "",
373                                         filtersList,
374                                         tr("MED_MEN_IMPORT"),
375                                         true);
376
377         // Selection du Maillage
378         if (!file.isEmpty() )
379           {
380             SCRUTE(file);
381             QString fieldName;
382             fieldName = QInputDialog::getText(
383                                               QString( tr("MED_INF_FIELDNAME") ), QString::null,
384                                               //VRV: porting on Qt 3.0.5
385 #if QT_VERSION >= 0x030005
386                                               QLineEdit::Normal,
387 #endif
388                                               //VRV: porting on Qt 3.0.5
389                                               QString::null, &ok);
390             if ( ! fieldName.isEmpty())
391               {
392                 try
393                   {
394                     medgen->readFieldInFile(file.latin1(),myStudyName,fieldName,-1,-1);
395                     if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) {
396                       SUIT_MessageBox::warn1 (application()->desktop(),
397                                              QObject::tr("WRN_WARNING"),
398                                              QObject::tr("WRN_STUDY_LOCKED"),
399                                              QObject::tr("BUT_OK"));
400                     }
401                   }
402                 catch (const SALOME::SALOME_Exception & S_ex)
403                   {
404                     SalomeApp_Tools::QtCatchCorbaException(S_ex);
405                   }
406                 updateObjBrowser ();
407               }
408           }
409         break;
410       }
411     case 4033:
412     case 933:
413       {
414         MESSAGE("command " << theCommandID << " activated");
415
416         QString myStudyName = myActiveStudy->studyName();
417 //      int myStudyId = myActiveStudy->id();
418
419         // load MED engine
420         SALOME_MED::MED_Gen_ptr medgen = InitMedGen();
421
422         // Selection du Fichier
423         file = SUIT_FileDlg::getFileName(application()->desktop(),
424                                         "",
425                                         filtersList,
426                                         tr("MED_MEN_IMPORT"),
427                                         true);
428         if (!file.isEmpty() )
429           {
430             SCRUTE(file);
431             try
432               {
433 //              medgen->readStructFile(file.latin1(),myStudyName);
434                 medgen->readStructFileWithFieldType(file.latin1(),myStudyName);
435
436                 MESSAGE("Ouais on est la !!!!");
437
438                 if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) {
439
440                   MESSAGE("Ouais on est la 1 !!!!");
441
442                   SUIT_MessageBox::warn1 (application()->desktop(),
443                                           QObject::tr("WRN_WARNING"),
444                                           QObject::tr("WRN_STUDY_LOCKED"),
445                                           QObject::tr("BUT_OK"));
446                 }
447               }
448             catch (const SALOME::SALOME_Exception & S_ex)
449               {
450                 MESSAGE("Ouais on est la 2 !!!!");
451
452                 SalomeApp_Tools::QtCatchCorbaException(S_ex);
453               }
454
455             MESSAGE("Ouais on est la 3 !!!!");
456
457             updateObjBrowser ();
458           }
459         break;
460       }
461
462     case 934:
463       {
464         //Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter( MESH );
465
466         SALOME_ListIO list;
467         SalomeApp_Application* app = getApp();
468         LightApp_SelectionMgr* mgr = app ? app->selectionMgr() : NULL;
469         if( mgr )
470           mgr->selectedObjects( list );
471         //Sel->AddFilter(aMeshFilter) ;
472
473         int nbSel = list.Extent();
474         if ( nbSel == 1 )
475           {
476             //      SMESH::SMESH_Mesh_var aM;
477             SALOME_MED::MESH_var aMesh;
478             Handle(SALOME_InteractiveObject) IObject = list.First();
479             if ( IObject->hasEntry() )
480               {
481                 _PTR(SObject) aMorSM = aStudy->FindObjectID( IObject->getEntry() );
482                 if ( aMorSM )
483                   {
484                     _PTR(GenericAttribute) anAttr;
485                     _PTR(AttributeIOR)     anIOR;
486                     if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
487                       {
488                         anIOR = anAttr;
489                         aMesh = SALOME_MED::MESH::_narrow( _orb->string_to_object(anIOR->Value().c_str()) );
490                         if ( aMesh->_is_nil() )
491                           {
492                             //                              aM = SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value()));
493                             //                              if ( aM->_is_nil() )
494                             //                                {
495                             //                                  QAD_MessageBox::warn1
496                             //                                    ( QAD_Application::getDesktop(),
497                             //                                      tr ("MED_WRN_WARNING"),
498                             //                                      tr ("MED_INF_NOTIMPL"),
499                             //                                      tr ("MED_BUT_OK") );
500                             //                                  break;
501                             //                                }
502                             //                              aMesh = aM->GetMEDMesh();
503                             if ( aMesh->_is_nil() )
504                               {
505                                 SUIT_MessageBox::warn1
506                                   ( application()->desktop(),
507                                     tr ("MED_WRN_WARNING"),
508                                     tr ("MED_INF_NOTIMPL"),
509                                     tr ("MED_BUT_OK") );
510                                 break;
511                               }
512                           }
513                         DumpMesh( aMesh );
514                         //Sel->ClearFilters() ;
515                       }
516                     else
517                       {
518                         SUIT_MessageBox::warn1
519                           ( application()->desktop(),
520                             tr ("MED_WRN_WARNING"),
521                             tr ("MED_INF_NOIOR"),
522                             tr ("MED_BUT_OK") );
523                         break;
524                       }
525                   }
526               }
527           }
528         break;
529       }
530
531     case 935:
532       {
533         //Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter( SUBMESH );
534
535         SALOME_ListIO list;
536         SalomeApp_Application* app = getApp();
537         LightApp_SelectionMgr* mgr = app ? app->selectionMgr() : NULL;
538         if( mgr )
539           mgr->selectedObjects( list );
540
541         //Sel->AddFilter(aSubMeshFilter) ;
542
543         int nbSel = list.Extent();
544         if ( nbSel == 1 )
545           {
546             //      SMESH::SMESH_subMesh_var aSubM;
547             SALOME_MED::FAMILY_var aFam;
548             Handle(SALOME_InteractiveObject) IObject = list.First();
549             if ( IObject->hasEntry() )
550               {
551                 _PTR(SObject) aMorSM = aStudy->FindObjectID( IObject->getEntry() );
552                 if ( aMorSM )
553                   {
554                     _PTR(GenericAttribute) anAttr;
555                     _PTR(AttributeIOR)     anIOR;
556                     if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
557                       {
558                         anIOR = anAttr;
559                         //                      aSubM = SMESH::SMESH_subMesh::_narrow( _orb->string_to_object(anIOR->Value()) );
560                         //                      if ( aSubM->_is_nil() )
561                         //                        {
562                         //                          aFam=SALOME_MED::FAMILY::_narrow( _orb->string_to_object(anIOR->Value()));
563                         //                          if ( aFam->_is_nil() )
564                         //                            {
565                         //                              QAD_MessageBox::warn1
566                         //                                ( QAD_Application::getDesktop(),
567                         //                                  tr ("MED_WRN_WARNING"),
568                         //                                  tr ("MED_INF_NOTIMPL"),
569                         //                                  tr ("MED_BUT_OK") );
570                         //                              break;
571                         //                            }
572                         //                          DumpSubMesh( aFam );
573                         //    }
574                         //                      else
575                         //                        {
576                         //                          DumpSubMesh( aSubM );
577                         //Sel->ClearFilters() ;
578                         //       }
579                       }
580                     else
581                       {
582                         SUIT_MessageBox::warn1
583                           ( application()->desktop(),
584                             tr ("MED_WRN_WARNING"),
585                             tr ("MED_INFNOIOR"),
586                             tr ("MED_BUT_OK") );
587                         break;
588                       }
589                   }
590               }
591           }
592         break;
593       }
594     }
595
596   app->updateActions(); //SRN: To update a Save button in the toolbar
597
598   return true;
599 }
600
601
602 //=============================================================================
603 /*!
604  *
605  */
606 //=============================================================================
607 bool MedGUI::OnMousePress (QMouseEvent* pe ,
608                            SUIT_ViewWindow* wnd )
609 {
610   MESSAGE("MedGUI::OnMousePress");
611   return true;
612 }
613
614 //=============================================================================
615 /*!
616  *
617  */
618 //=============================================================================
619 bool MedGUI::OnMouseMove (QMouseEvent* pe ,
620                           SUIT_ViewWindow* wnd )
621 {
622   //   MESSAGE("MedGUI::OnMouseMouve");
623   return true;
624 }
625
626 //=============================================================================
627 /*!
628  *
629  */
630 //=============================================================================
631 bool MedGUI::OnKeyPress (QKeyEvent* pe,
632                          SUIT_ViewWindow* wnd)
633 {
634   MESSAGE("MedGUI::OnKeyPress");
635   return true;
636 }
637
638 //=============================================================================
639 /*!
640  *
641  */
642 //=============================================================================
643 /*bool MedGUI::SetSettings ()
644 {
645   MESSAGE("MedGUI::SetSettings");
646   return true;
647 }*/
648
649 //=============================================================================
650 /*!
651  *
652  */
653 //=============================================================================
654 /*bool MedGUI::CustomPopup ( QPopupMenu* popup,
655                            const QString & theContext,
656                            const QString & theParent,
657                            const QString & theObject )
658 {
659   MESSAGE("MedGUI::CustomPopup");
660   popup->clear();
661   return true;
662 }*/
663
664 //=============================================================================
665 /*!
666  *
667  */
668 //=============================================================================
669 /*bool MedGUI::ActiveStudyChanged()
670 {
671   return true;
672 }*/
673
674 //=============================================================================
675 /*!
676  *
677  */
678 //=============================================================================
679 /*void MedGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
680 {
681   theObject = "";
682   theContext = "";
683 }
684 */
685 //=============================================================================
686 /*!
687  *
688  */
689 //=============================================================================
690 bool MedGUI::DumpMesh( SALOME_MED::MESH_var MEDMesh)
691 {
692
693   if ( MEDMesh->_is_nil() )
694     {
695       return false;
696     }
697
698   //SALOME_MED::MESH_var MEDMesh = aMesh->GetMEDMesh();
699   string name = MEDMesh->getName();
700   SCRUTE(name);
701
702   int dim = MEDMesh->getMeshDimension();
703   SCRUTE(dim);
704   int dim2 = MEDMesh->getSpaceDimension();
705   SCRUTE(dim2);
706
707   int k = MEDMesh->getNumberOfNodes() ;
708   SCRUTE(k);
709   SALOME_MED::double_array_var coords = MEDMesh->getCoordinates( SALOME_MED::MED_FULL_INTERLACE );
710   int i = 0;
711   int lu = 0;
712   while (lu < k ) {
713     if (dim2==3)
714       {
715         MESSAGE ( " Coordinates  X = " << coords[i] << " Y = " << coords[i+1] << " Z = " << coords[i+2] );
716         i = i + 3; // Only for triangles
717       }
718     else
719       {
720         MESSAGE ( " Coordinates  X = " << coords[i] << " Y = " << coords[i+1] );
721         i = i + 2;
722       }
723     lu=lu+1;
724   }
725
726   int nbfam=MEDMesh->getNumberOfFamilies(SALOME_MED::MED_NODE);
727   SCRUTE(nbfam);
728   SALOME_MED::Family_array_var Families=MEDMesh->getFamilies(SALOME_MED::MED_NODE) ;
729
730   for (k=0;  k < nbfam; k++) {
731     SCRUTE(k);
732     string nomFam=Families[k]->getName();
733     SCRUTE(nomFam);
734     int identfam=Families[k]->getIdentifier();
735     SCRUTE(identfam);
736     int nbelemnts=Families[k]->getNumberOfElements(SALOME_MED::MED_NONE);
737     SCRUTE(nbelemnts);
738     SALOME_MED::long_array_var tabnoeuds=Families[k]->getNumber(SALOME_MED::MED_NONE);
739     for (int l=0;l<(int)tabnoeuds->length();l++)
740       SCRUTE(tabnoeuds[l]);
741   }
742
743   //     int famIdent = 1;
744   //     SALOME_MED::FAMILY_ptr Family=MEDMesh->getFamily(SALOME_MED::MED_NODE,1) ;
745   //     MESSAGE("ici");
746   //     string nomFam=Family->getName();
747   //     SCRUTE(nomFam);
748   //     int identfam=Family->getIdentifier();
749   //     SCRUTE(identfam);
750   //     SALOME_MED::long_array_var tabnoeuds=Family->getNumber(SALOME_MED::MED_NONE);
751   //     for (int l=0;l<tabnoeuds->length();l++)
752   //       SCRUTE(tabnoeuds[l]);
753
754   return true;
755 }
756
757 //=============================================================================
758 /*!
759  *
760  */
761 //=============================================================================
762 //  bool MedGUI::DumpSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh )
763 //  {
764 //    if ( aSubMesh->_is_nil() )
765 //      return false;
766
767 //    SALOME_MED::FAMILY_var Fam = aSubMesh->GetFamily();
768 //    if ( Fam->_is_nil() )
769 //      return false;
770
771 //    SALOME_MED::long_array_var tabnoeuds=Fam->getNumber(SALOME_MED::MED_NONE);
772 //    for (int l=0;l<tabnoeuds->length();l++)
773 //      SCRUTE(tabnoeuds[l]);
774
775 //    return true;
776 //  }
777 //=============================================================================
778 /*!
779  *
780  */
781 //=============================================================================
782 bool MedGUI::DumpSubMesh( SALOME_MED::FAMILY_var Fam )
783 {
784
785   if ( Fam->_is_nil() )
786     return false;
787
788   SALOME_MED::long_array_var tabnoeuds=Fam->getNumber(SALOME_MED::MED_NONE);
789   for (int l=0;l<(int)tabnoeuds->length();l++)
790     SCRUTE(tabnoeuds[l]);
791
792   return true;
793 }
794
795 //=============================================================================
796 /*!
797  *
798  */
799 //=============================================================================
800 SALOME_MED::MED_Gen_ptr MedGUI::InitMedGen() const
801 {
802   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
803   Engines::Component_var comp =
804     SALOME_LifeCycleCORBA(app->namingService()).FindOrLoad_Component( "FactoryServer", "MED" );
805
806   MESSAGE("_________________________________________");
807   SALOME_MED::MED_Gen_var clr = SALOME_MED::MED_Gen::_narrow(comp);
808   ASSERT(!CORBA::is_nil(clr));
809   return clr._retn();
810 }
811
812 //=============================================================================
813 /*!
814  *
815  */
816 //=============================================================================
817 void MedGUI::setOrb()
818 {
819   try {
820     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
821     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
822     _orb = init( 0 , 0 );
823   } catch (...) {
824     INFOS("internal error : orb not found");
825     _orb = 0;
826   }
827   ASSERT(! CORBA::is_nil(_orb));
828 }
829
830 extern "C" {
831   Standard_EXPORT CAM_Module* createModule() {
832     return new MedGUI();
833   }
834 }