Salome HOME
Merge from BR_imps_2013 14/01/2014
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshDlg.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_MeshDlg.cxx
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
26 // SMESH includes
27 //
28 #include "SMESHGUI_MeshDlg.h"
29
30 // SALOME GUI includes
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33
34 // Qt includes
35 #include <QVBoxLayout>
36 #include <QGridLayout>
37 #include <QLabel>
38 #include <QTabWidget>
39 #include <QGroupBox>
40 #include <QToolButton>
41 #include <QComboBox>
42 #include <QMenu>
43 #include <QCursor>
44 #include <QPushButton>
45
46 #define SPACING 6
47 #define MARGIN  11
48
49 /*!
50  * \brief Tab for tab widget containing controls for definition of 
51  * algorithms and hypotheses
52 */ 
53
54 //================================================================================
55 /*!
56  * \brief Constructor
57   * \param theParent - Parent widget for this tab
58  * 
59  * Makes tab's look and feel
60  */
61 //================================================================================ 
62 SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
63   : QFrame( theParent )
64 {
65   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
66   QIcon aCreateIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO" ) ) );
67   QIcon aEditIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO_EDIT" ) ) );
68   
69   // Algorifm
70   QLabel* anAlgoLbl = new QLabel( tr( "ALGORITHM" ), this );
71   myHyp[ Algo ] = new QComboBox( this );
72   
73   // Hypothesis
74   QLabel* aHypLbl = new QLabel( tr( "HYPOTHESIS" ), this );
75   myHyp[ MainHyp ] = new QComboBox( this );
76   myHyp[ MainHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
77   myCreateHyp[ MainHyp ] = new QToolButton( this );
78   myCreateHyp[ MainHyp ]->setIcon( aCreateIcon );
79   myEditHyp[ MainHyp ] = new QToolButton( this );
80   myEditHyp[ MainHyp ]->setIcon( aEditIcon );
81   
82   // Line
83   QFrame* aLine = new QFrame( this );
84   aLine->setFrameStyle( QFrame::HLine | QFrame::Sunken );
85   
86   // Add. hypothesis
87   QLabel* anAddHypLbl = new QLabel( tr( "ADD_HYPOTHESIS" ), this );
88   myHyp[ AddHyp ] = new QComboBox( this );
89   myHyp[ AddHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
90   myCreateHyp[ AddHyp ] = new QToolButton( this );
91   myCreateHyp[ AddHyp ]->setIcon( aCreateIcon );
92   myEditHyp[ AddHyp ] = new QToolButton( this );
93   myEditHyp[ AddHyp ]->setIcon( aEditIcon );
94   
95   // Fill layout
96   QGridLayout* aLay = new QGridLayout( this );
97   aLay->setMargin( MARGIN );
98   aLay->setSpacing( SPACING );
99
100   aLay->addWidget( anAlgoLbl, 0, 0 );
101   aLay->addWidget( myHyp[ Algo ], 0, 1 );
102   aLay->addWidget( aHypLbl, 1, 0 );
103   aLay->addWidget( myHyp[ MainHyp ], 1, 1 );
104   aLay->addWidget( myCreateHyp[ MainHyp ], 1, 2 );
105   aLay->addWidget( myEditHyp[ MainHyp ], 1, 3 );
106   aLay->addWidget( aLine, 2, 0, 1, 4 );
107   aLay->addWidget( anAddHypLbl, 3, 0 );
108   aLay->addWidget( myHyp[ AddHyp ], 3, 1 );
109   aLay->addWidget( myCreateHyp[ AddHyp ], 3, 2 );
110   aLay->addWidget( myEditHyp[ AddHyp ], 3, 3 );
111   aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ), 4, 0 );
112     
113   // Connect signals and slots
114   for ( int i = MainHyp; i <= AddHyp; i++ )
115   {
116     connect( myCreateHyp[ i ], SIGNAL( clicked() )       ,  SLOT( onCreateHyp() ) );
117     connect( myEditHyp[ i ]  , SIGNAL( clicked() )       ,  SLOT( onEditHyp() ) );
118     connect( myHyp[ i ]      , SIGNAL( activated( int ) ),  SLOT( onHyp( int ) ) );
119   }
120   connect( myHyp[ Algo ], SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) );
121   
122   // Initialize controls
123   
124   setAvailableHyps( Algo, QStringList() );
125   setAvailableHyps( MainHyp, QStringList() );
126   setAvailableHyps( AddHyp, QStringList() );
127 }
128
129 //================================================================================
130 /*!
131  * \brief Destructor
132  */
133 //================================================================================ 
134 SMESHGUI_MeshTab::~SMESHGUI_MeshTab()
135 {
136 }
137
138 //================================================================================
139 /*!
140  * \brief Sets available hypothesis or algorithms
141   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
142   * \param theHyps - list of available hypothesis names
143  * 
144  * Sets available main or additional hypothesis for this tab
145  */
146 //================================================================================
147 void SMESHGUI_MeshTab::setAvailableHyps( const int theId, const QStringList& theHyps )
148 {
149   myAvailableHyps[ theId ] = theHyps;
150
151   bool enable = ! theHyps.isEmpty();
152   if ( theId == Algo )
153   {
154     myHyp[ Algo ]->clear();
155     myHyp[ Algo ]->addItem( tr( "NONE" ) );
156     myHyp[ Algo ]->addItems( theHyps );
157     myHyp[ Algo ]->setCurrentIndex( 0 );
158   }
159   else {
160     myCreateHyp[ theId ]->setEnabled( enable );
161     myEditHyp[ theId ]->setEnabled( false );
162   }
163   myHyp[ theId ]->setEnabled( enable );
164 }
165
166 //================================================================================
167 /*!
168  * \brief Sets existing hypothesis
169   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
170   * \param theHyps - list of available hypothesis names
171  * 
172  * Sets existing main or additional hypothesis for this tab
173  */
174 //================================================================================
175 void SMESHGUI_MeshTab::setExistingHyps( const int theId, const QStringList& theHyps )
176 {
177   if ( theId != Algo )
178   {
179     myHyp[ theId ]->clear();
180     myHyp[ theId ]->addItem( tr( "NONE" ) );
181     myHyp[ theId ]->addItems( theHyps );
182     myHyp[ theId ]->setCurrentIndex( 0 );
183     myHyp[ theId ]->setEnabled( !theHyps.isEmpty() );
184     myEditHyp[ theId ]->setEnabled( false );
185   }
186 }
187
188 //================================================================================
189 /*!
190  * \brief Adds hypothesis in combo box of available ones
191   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
192   * \param theHyp - name of hypothesis to be added
193  * 
194  * Adds hypothesis in combo box of available ones. This method is called by operation
195  * after creation of new hypothesis.
196  */
197 //================================================================================
198 void SMESHGUI_MeshTab::addHyp( const int theId, const QString& theHyp )
199 {
200   myHyp[ theId ]->addItem( theHyp );
201   myHyp[ theId ]->setCurrentIndex( myHyp[ theId ]->count() - 1 );
202   myEditHyp[ theId ]->setEnabled( true );
203   myHyp[ theId ]->setEnabled( true );
204 }
205
206 //================================================================================
207 /*!
208  * \brief Renames hypothesis
209   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
210   * \param theIndex - index of hypothesis to be renamed
211   * \param theNewName - new name of hypothesis to be renamed
212  * 
213  * Renames hypothesis
214  */
215 //================================================================================
216 void SMESHGUI_MeshTab::renameHyp( const int theId, 
217                                   const int theIndex, 
218                                   const QString& theNewName )
219 {
220   if ( theIndex > 0 && theIndex < myHyp[ theId ]->count() )
221     myHyp[ theId ]->setItemText( theIndex, theNewName );
222 }                                  
223
224 //================================================================================
225 /*!
226  * \brief Sets current hypothesis 
227   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
228   * \param theIndex - index of hypothesis to be set as current
229  * 
230  * Sets current hypothesis 
231  */
232 //================================================================================
233 void SMESHGUI_MeshTab::setCurrentHyp( const int theId, const int theIndex )
234 {
235   if ( theIndex >= 0 && theIndex < myHyp[ theId ]->count() )
236   {
237     myHyp[ theId ]->setCurrentIndex( theIndex );
238     if ( myEditHyp[ theId ] )
239       myEditHyp[ theId ]->setEnabled( theIndex > 0 );
240   }
241 }
242
243 //================================================================================
244 /*!
245  * \brief Gets current hypothesis
246   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
247   * \retval int - index of current hypothesis
248  * 
249  * Gets current hypothesis
250  */
251 //================================================================================
252 int SMESHGUI_MeshTab::currentHyp( const int theId ) const
253 {
254   return myHyp[ theId ]->currentIndex();
255 }
256
257 //================================================================================
258 /*!
259  * \brief Emits createHyp( const int ) signal
260  * 
261  * SLOT called when "Create hypothesis" button clicked specifies sender and emits
262  * createHyp( const int ) signal
263  */
264 //================================================================================
265 void SMESHGUI_MeshTab::onCreateHyp()
266 {
267   bool isMainHyp = sender() == myCreateHyp[ MainHyp ];
268
269   QMenu aPopup( this );
270   
271   QStringList aHypNames = isMainHyp ? 
272     myAvailableHyps[ MainHyp ] : myAvailableHyps[ AddHyp ];
273
274   QList<QAction*> actions;
275   for ( int i = 0, n = aHypNames.count(); i < n; i++ )
276     actions.append( aPopup.addAction( aHypNames[ i ] ) );
277
278   QAction* a = aPopup.exec( QCursor::pos() );
279   if ( a )
280     emit createHyp( isMainHyp ? MainHyp : AddHyp, actions.indexOf( a ) );
281 }
282
283 //================================================================================
284 /*!
285  * \brief Emits editHyp( const int ) signal
286  * 
287  * SLOT called when "Edit hypothesis" button clicked specifies sender and emits
288  * editHyp( const int ) signal
289  */
290 //================================================================================
291 void SMESHGUI_MeshTab::onEditHyp()
292 {
293   const QObject* aSender = sender();
294   int aHypType = aSender == myEditHyp[ MainHyp ] ? MainHyp : AddHyp;
295   emit editHyp( aHypType, myHyp[ aHypType ]->currentIndex() - 1 );  // - 1 because there is NONE on the top
296 }
297
298 //================================================================================
299 /*!
300  * \brief Updates "Edit hypothesis" button state
301  * 
302  * SLOT called when current hypothesis changed. Disables "Edit hypothesis" button
303  * if current hypothesis is <None>, enables otherwise.
304  * If an algorithm changed, emits selectAlgo( theIndex ) signal
305  */
306 //================================================================================
307 void SMESHGUI_MeshTab::onHyp( int theIndex )
308 {
309   const QObject* aSender = sender();
310   if ( aSender == myHyp[ Algo ] )
311     emit selectAlgo( theIndex - 1 ); // - 1 because there is NONE on the top
312   else {
313     int anIndex = aSender == myHyp[ MainHyp ] ? MainHyp : AddHyp;
314     myEditHyp[ anIndex ]->setEnabled( theIndex > 0 );
315   }
316 }
317
318 //================================================================================
319 /*!
320  * \brief Resets all tab fields
321  *
322  * Resets all tab fields
323  */
324 //================================================================================  
325 void SMESHGUI_MeshTab::reset()
326 {
327   for ( int i = Algo; i <= AddHyp; i++ )
328   {
329     myHyp[ i ]->setCurrentIndex( 0 );
330     if ( myEditHyp[ i ] )
331       myEditHyp[ i ]->setEnabled( false );
332   }
333 }
334
335 /*!
336  * \brief Dialog for mech creation or editing
337  *
338  *  This dialog is used for mech creation or editing. 
339 */
340
341 //================================================================================
342 /*!
343  * \brief Constructor
344   * \param theToCreate - if this parameter is true then dialog is used for creation,
345   * for editing otherwise
346   * \param theIsMesh - if this parameter is true then dialog is used for mesh,
347   * for sub-mesh otherwise
348  * 
349  * Makes dialog's look and feel
350  */
351 //================================================================================
352 SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh )
353 : SMESHGUI_Dialog( 0, false, true )
354 {
355   // Create top controls
356
357   setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
358   // name 
359   createObject( tr( "NAME" ), mainFrame(), Obj );
360   setNameIndication( Obj, OneName );
361   setReadOnly( Obj, false );
362   // mesh
363   createObject( tr( "MESH" ), mainFrame(), Mesh );
364   // geometry
365   createObject( tr( "GEOMETRY" ), mainFrame(), Geom );
366   myGeomPopup = 0;
367   // mesh type
368   QLabel* anMeshTypeLbl = new QLabel( tr( "MESH_TYPE" ), this );
369   myMeshType = new QComboBox( this );
370   
371   // Create tab widget
372   
373   myTabWg = new QTabWidget( mainFrame() );
374   myTabs[ Dim0D ] = new SMESHGUI_MeshTab( myTabWg );
375   myTabs[ Dim1D ] = new SMESHGUI_MeshTab( myTabWg );
376   myTabs[ Dim2D ] = new SMESHGUI_MeshTab( myTabWg );
377   myTabs[ Dim3D ] = new SMESHGUI_MeshTab( myTabWg );
378   myTabWg->addTab( myTabs[ Dim3D ], tr( "DIM_3D" ) );
379   myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) );
380   myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) );
381   myTabWg->addTab( myTabs[ Dim0D ], tr( "DIM_0D" ) );
382
383   // Hypotheses Sets
384   myHypoSetButton = new QToolButton( mainFrame() );
385   myHypoSetButton->setText( tr( "HYPOTHESES_SETS" ) );
386   myHypoSetButton->setEnabled( false );
387   myHypoSetButton->setSizePolicy( QSizePolicy::MinimumExpanding, 
388                                   myHypoSetButton->sizePolicy().verticalPolicy() );
389   
390   // Fill layout
391   QGridLayout* aLay = new QGridLayout( mainFrame() );
392   aLay->setMargin( 0 );
393   aLay->setSpacing( SPACING );
394
395   aLay->addWidget( objectWg( Obj,  Label ),   0, 0 );
396   aLay->addWidget( objectWg( Obj,  Btn ),     0, 1 );
397   aLay->addWidget( objectWg( Obj,  Control ), 0, 2 );
398   aLay->addWidget( objectWg( Mesh, Label ),   1, 0 );
399   aLay->addWidget( objectWg( Mesh, Btn ),     1, 1 );
400   aLay->addWidget( objectWg( Mesh, Control ), 1, 2 );
401   aLay->addWidget( objectWg( Geom, Label ),   2, 0 );
402   aLay->addWidget( objectWg( Geom, Btn ),     2, 1 );
403   aLay->addWidget( objectWg( Geom, Control ), 2, 2 );
404   aLay->addWidget( anMeshTypeLbl,             3, 0 );
405   aLay->addWidget( myMeshType,                3, 2 );
406   aLay->addWidget( myTabWg,                   5, 0, 1, 3 );
407   aLay->addWidget( myHypoSetButton,           6, 0, 1, 3 );
408   aLay->setRowMinimumHeight( 3, 20 );
409
410   myMeshType->clear();
411
412   // Connect signals and slots
413   connect( myMeshType, SIGNAL( activated( int ) ), SLOT( onChangedMeshType( int ) ) );
414   // Disable controls if necessary
415   setObjectShown( Mesh, false );
416   if ( theToCreate )
417   {
418     setWindowTitle( tr( "CREATE_MESH" ) );
419     objectWg( Obj, Btn )->hide();
420     if ( theIsMesh )
421       setWindowTitle( tr( "CREATE_MESH" ) );
422     else
423     {
424       setWindowTitle( tr( "CREATE_SUBMESH" ) );
425       setObjectShown( Mesh, true );
426     }
427   }
428   else
429   {
430     setWindowTitle( tr( "EDIT_MESH_SUBMESH" ) );
431     objectWg( Mesh, Btn )->hide();
432     objectWg( Geom, Btn )->hide();
433   }
434 }
435
436 SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg()
437 {
438 }
439
440 //================================================================================
441 /*!
442  * \brief Gets tab with given id
443   * \param theId - Tab identifier. Possible values are in "Dimensions" enumeration
444   * \retval SMESHGUI_MeshTab* - pointer to the tab or null if given parameter is 
445   * invalid
446  * 
447  * Gets tab containing controls for definition of algorithms and AddHypotheses
448  */
449 //================================================================================
450 SMESHGUI_MeshTab* SMESHGUI_MeshDlg::tab( const int theId ) const
451 {
452   return ( theId >= Dim0D && theId <= Dim3D ? myTabs[ theId ] : 0 );
453 }
454
455 //================================================================================
456 /*!
457  * \brief Resets all dialog fields
458  */
459 //================================================================================  
460 void SMESHGUI_MeshDlg::reset()
461 {
462   clearSelection();
463   myTabs[ Dim0D ]->reset();
464   myTabs[ Dim1D ]->reset();
465   myTabs[ Dim2D ]->reset();
466   myTabs[ Dim3D ]->reset();
467 }
468
469 //================================================================================
470 /*!
471  * \brief Sets curent tab
472  */
473 //================================================================================    
474 void SMESHGUI_MeshDlg::setCurrentTab( const int theId  )
475 {
476   myTabWg->setCurrentIndex( Dim3D - theId );
477 }
478
479 //================================================================================
480 /*!
481  * \brief Enable/disable tabs
482   * \param int - maximum possible dimention
483  */
484 //================================================================================
485
486 void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
487 {
488   const int DIM = maxDim;
489   for ( int dim = Dim0D; dim <= Dim3D; ++dim ) {
490     bool enable = ( dim <= DIM );
491     if ( !enable ) {
492       myTabs[ dim ]->reset();
493       disableTab( dim );
494     }
495     else {
496       enableTab( dim );
497     }
498   }
499   // deselect desabled tab
500   if ( !myTabWg->isTabEnabled( myTabWg->currentIndex() ) )
501     setCurrentTab( DIM );
502 }
503
504 //================================================================================
505 /*!
506  * \brief Sets list of available Sets of Hypotheses
507  */
508 //================================================================================
509
510 void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
511 {
512   QMenu* aHypoSetPopup = myHypoSetButton->menu();
513   if ( !aHypoSetPopup ) {
514     aHypoSetPopup = new QMenu( myHypoSetButton );
515     connect( aHypoSetPopup, SIGNAL( triggered( QAction* ) ), SLOT( onHypoSetPopup( QAction* ) ) );
516     myHypoSetButton->setMenu( aHypoSetPopup );
517     myHypoSetButton->setPopupMode( QToolButton::InstantPopup );
518   }
519   aHypoSetPopup->clear();
520   for ( int i = 0, n = theSets.count(); i < n; i++ ) {
521     aHypoSetPopup->addAction( theSets[ i ] );
522   }
523   myHypoSetButton->setEnabled( !aHypoSetPopup->isEmpty() );
524 }
525
526 //================================================================================
527 /*!
528  * \brief Emits hypoSet signal
529  * 
530  * SLOT is called when a hypotheses set is selected. Emits hypoSet
531  * signal to notify operation about this event
532  */
533 //================================================================================
534
535 void SMESHGUI_MeshDlg::onHypoSetPopup( QAction* a )
536 {
537   emit hypoSet( a->text() );
538 }
539   
540 //================================================================================
541 /*!
542  * \brief Enable showing of the popup when Geometry selection btn is clicked
543   * \param enable - true to enable
544  */
545 //================================================================================
546
547 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
548
549 void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
550 {
551   if ( QToolButton* selBtn = qobject_cast<QToolButton*>( objectWg( Geom, Btn )))
552   {
553     if ( enable ) {
554       if ( ! myGeomPopup ) {
555         myGeomPopup = new QMenu();
556         myGeomPopup->addAction( tr("DIRECT_GEOM_SELECTION") )->setData( DIRECT_GEOM_INDEX );
557         myGeomPopup->addAction( tr("GEOM_BY_MESH_ELEM_SELECTION") )->setData( GEOM_BY_MESH_INDEX );
558         connect( myGeomPopup, SIGNAL( triggered( QAction* ) ), SLOT( onGeomPopup( QAction* ) ) );
559         connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
560       }
561     }
562     else {
563       disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
564       if ( myGeomPopup ) {
565         delete myGeomPopup;
566         myGeomPopup = 0;
567       }
568     }
569   }
570 }
571
572
573 //================================================================================
574 /*!
575  * \brief Disable tab
576  * \param int - tab ID
577  */
578 //================================================================================
579 void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
580   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false );
581   if ( theTabId == Dim3D ) myHypoSetButton->setEnabled( false );
582 }
583
584 //================================================================================
585 /*!
586  * \brief Enable tabs
587  * \param int - tab ID
588  */
589 //================================================================================
590 void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
591   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true );
592   if ( theTabId == Dim3D ) {
593     QMenu* aHypoSetPopup = myHypoSetButton->menu();
594     myHypoSetButton->setEnabled( aHypoSetPopup && !aHypoSetPopup->actions().isEmpty() );
595   }
596 }
597
598 //================================================================================
599 /*!
600  * \brief Check if tab enabled
601  * \param int - tab ID
602  */
603 //================================================================================
604 bool SMESHGUI_MeshDlg::isTabEnabled(const int theTabId) const {
605   return myTabWg->isTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ) );
606 }
607
608 void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
609 {
610   if ( myGeomPopup && isBtnOn )
611     myGeomPopup->exec( QCursor::pos() );
612 }
613
614 void SMESHGUI_MeshDlg::onGeomPopup( QAction* a )
615 {
616   emit geomSelectionByMesh( a->data().toInt() == GEOM_BY_MESH_INDEX );
617 }
618
619 int SMESHGUI_MeshDlg::getActiveObject()
620 {
621   for (int i = 0; i < 3; ++i )
622     if ( isObjectShown( i ) &&
623          (( QToolButton* )objectWg( i, Btn ))->isChecked())
624       return i;
625   return -1;
626 }
627 //================================================================================
628 /*!
629  * \brief Sets available types of mesh
630  * \param theTypeMesh - list of available types of mesh
631  */
632 //================================================================================
633 void SMESHGUI_MeshDlg::setAvailableMeshType( const QStringList& theTypeMesh )
634 {
635   myMeshType->clear();
636   myMeshType->addItems(theTypeMesh);
637 }
638 //================================================================================
639 /*!
640  * \brief Emits selectMeshType( const int, const int ) signal
641  *
642  * SLOT is called when a combo box "mesh type" is selected.
643  */
644 //================================================================================
645 void SMESHGUI_MeshDlg::onChangedMeshType( const int isIndex )
646 {
647   emit selectMeshType( Dim3D - myTabWg->currentIndex(), isIndex );
648 }
649 //================================================================================
650 /*!
651  * \brief Get current index types of mesh
652  */
653 //================================================================================
654 int SMESHGUI_MeshDlg::currentMeshType( )
655 {
656   return myMeshType->currentIndex( );
657 }
658
659