Salome HOME
30b8dfe333df5da9449d488aa4ef17e070043f0f
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshDlg.cxx
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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 ) // fill list of algos
153   {
154     myHyp[ Algo ]->clear();
155     if ( enable )
156     {
157       myHyp[ Algo ]->addItem( tr( "NONE" ) );
158       myHyp[ Algo ]->addItems( theHyps );
159       myHyp[ Algo ]->setCurrentIndex( 0 );
160     }
161   }
162   else // enable buttons
163   {
164     myCreateHyp[ theId ]->setEnabled( enable );
165     myEditHyp  [ theId ]->setEnabled( false );
166   }
167   myHyp[ theId ]->setEnabled( enable );
168 }
169
170 //================================================================================
171 /*!
172  * \brief Sets existing hypothesis
173  * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
174  * \param theHyps - list of available hypothesis names
175  * \param theDefaultAvlbl - \c true means that the algorithm can with w/o hypothesis
176  *                          with some default parameters
177  *
178  * Sets existing main or additional hypothesis for this tab
179  */
180 //================================================================================
181 void SMESHGUI_MeshTab::setExistingHyps( const int          theId,
182                                         const QStringList& theHyps,
183                                         bool               theDefaultAvlbl)
184 {
185   if ( theId != Algo )
186   {
187     bool enable = ! myAvailableHyps[ theId ].isEmpty();
188     myHyp[ theId ]->clear();
189     if ( enable )
190     {
191       QString none = tr( theDefaultAvlbl ? "DEFAULT" : ( theId == AddHyp ) ? "NONE" : "NONE" );
192       myHyp[ theId ]->addItem( none );
193       myHyp[ theId ]->addItems( theHyps );
194       myHyp[ theId ]->setCurrentIndex( 0 );
195     }
196     myHyp    [ theId ]->setEnabled( enable );
197     myEditHyp[ theId ]->setEnabled( false );
198   }
199 }
200
201 //================================================================================
202 /*!
203  * \brief Adds hypothesis in combo box of available ones
204  * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
205  * \param theHyp - name of hypothesis to be added
206  *
207  * Adds hypothesis in combo box of available ones. This method is called by operation
208  * after creation of new hypothesis.
209  */
210 //================================================================================
211 void SMESHGUI_MeshTab::addHyp( const int theId, const QString& theHyp )
212 {
213   myHyp[ theId ]->addItem( theHyp );
214   myHyp[ theId ]->setCurrentIndex( myHyp[ theId ]->count() - 1 );
215   myEditHyp[ theId ]->setEnabled( true );
216   myHyp[ theId ]->setEnabled( true );
217 }
218
219 //================================================================================
220 /*!
221  * \brief Renames hypothesis
222   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
223   * \param theIndex - index of hypothesis to be renamed
224   * \param theNewName - new name of hypothesis to be renamed
225  * 
226  * Renames hypothesis
227  */
228 //================================================================================
229 void SMESHGUI_MeshTab::renameHyp( const int theId, 
230                                   const int theIndex, 
231                                   const QString& theNewName )
232 {
233   if ( theIndex > 0 && theIndex < myHyp[ theId ]->count() )
234     myHyp[ theId ]->setItemText( theIndex, theNewName );
235 }                                  
236
237 //================================================================================
238 /*!
239  * \brief Sets current hypothesis 
240   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
241   * \param theIndex - index of hypothesis to be set as current
242  * 
243  * Sets current hypothesis 
244  */
245 //================================================================================
246 void SMESHGUI_MeshTab::setCurrentHyp( const int theId, const int theIndex )
247 {
248   if ( theIndex >= 0 && theIndex < myHyp[ theId ]->count() )
249   {
250     myHyp[ theId ]->setCurrentIndex( theIndex );
251     if ( myEditHyp[ theId ] )
252       myEditHyp[ theId ]->setEnabled( theIndex > 0 );
253   }
254 }
255
256 //================================================================================
257 /*!
258  * \brief Gets current hypothesis
259   * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
260   * \retval int - index of current hypothesis
261  * 
262  * Gets current hypothesis
263  */
264 //================================================================================
265 int SMESHGUI_MeshTab::currentHyp( const int theId ) const
266 {
267   return myHyp[ theId ]->currentIndex();
268 }
269
270 //================================================================================
271 /*!
272  * \brief Emits createHyp( const int ) signal
273  * 
274  * SLOT called when "Create hypothesis" button clicked specifies sender and emits
275  * createHyp( const int ) signal
276  */
277 //================================================================================
278 void SMESHGUI_MeshTab::onCreateHyp()
279 {
280   bool isMainHyp = sender() == myCreateHyp[ MainHyp ];
281
282   QMenu aPopup( this );
283   
284   QStringList aHypNames = isMainHyp ? 
285     myAvailableHyps[ MainHyp ] : myAvailableHyps[ AddHyp ];
286
287   QList<QAction*> actions;
288   for ( int i = 0, n = aHypNames.count(); i < n; i++ )
289     actions.append( aPopup.addAction( aHypNames[ i ] ) );
290
291   QAction* a = aPopup.exec( QCursor::pos() );
292   if ( a )
293     emit createHyp( isMainHyp ? MainHyp : AddHyp, actions.indexOf( a ) );
294 }
295
296 //================================================================================
297 /*!
298  * \brief Emits editHyp( const int ) signal
299  * 
300  * SLOT called when "Edit hypothesis" button clicked specifies sender and emits
301  * editHyp( const int ) signal
302  */
303 //================================================================================
304 void SMESHGUI_MeshTab::onEditHyp()
305 {
306   const QObject* aSender = sender();
307   int aHypType = aSender == myEditHyp[ MainHyp ] ? MainHyp : AddHyp;
308   emit editHyp( aHypType, myHyp[ aHypType ]->currentIndex() - 1 );  // - 1 because there is NONE on the top
309 }
310
311 //================================================================================
312 /*!
313  * \brief Updates "Edit hypothesis" button state
314  * 
315  * SLOT called when current hypothesis changed. Disables "Edit hypothesis" button
316  * if current hypothesis is <None>, enables otherwise.
317  * If an algorithm changed, emits selectAlgo( theIndex ) signal
318  */
319 //================================================================================
320 void SMESHGUI_MeshTab::onHyp( int theIndex )
321 {
322   const QObject* aSender = sender();
323   if ( aSender == myHyp[ Algo ] )
324     emit selectAlgo( theIndex - 1 ); // - 1 because there is NONE on the top
325   else {
326     int anIndex = aSender == myHyp[ MainHyp ] ? MainHyp : AddHyp;
327     myEditHyp[ anIndex ]->setEnabled( theIndex > 0 );
328   }
329 }
330
331 //================================================================================
332 /*!
333  * \brief Resets all tab fields
334  *
335  * Resets all tab fields
336  */
337 //================================================================================  
338 void SMESHGUI_MeshTab::reset()
339 {
340   for ( int i = Algo; i <= AddHyp; i++ )
341   {
342     myHyp[ i ]->setCurrentIndex( 0 );
343     if ( myEditHyp[ i ] )
344       myEditHyp[ i ]->setEnabled( false );
345   }
346 }
347
348 /*!
349  * \brief Dialog for mech creation or editing
350  *
351  *  This dialog is used for mech creation or editing. 
352 */
353
354 //================================================================================
355 /*!
356  * \brief Constructor
357   * \param theToCreate - if this parameter is true then dialog is used for creation,
358   * for editing otherwise
359   * \param theIsMesh - if this parameter is true then dialog is used for mesh,
360   * for sub-mesh otherwise
361  * 
362  * Makes dialog's look and feel
363  */
364 //================================================================================
365 SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh )
366 : SMESHGUI_Dialog( 0, false, true )
367 {
368   // Create top controls
369
370   setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
371   // name 
372   createObject( tr( "NAME" ), mainFrame(), Obj );
373   setNameIndication( Obj, OneName );
374   setReadOnly( Obj, false );
375   // mesh
376   createObject( tr( "MESH" ), mainFrame(), Mesh );
377   // geometry
378   createObject( tr( "GEOMETRY" ), mainFrame(), Geom );
379   myGeomPopup = 0;
380   // mesh type
381   QLabel* anMeshTypeLbl = new QLabel( tr( "MESH_TYPE" ), this );
382   myMeshType = new QComboBox( this );
383   
384   // Create tab widget
385   
386   myTabWg = new QTabWidget( mainFrame() );
387   myTabs[ Dim0D ] = new SMESHGUI_MeshTab( myTabWg );
388   myTabs[ Dim1D ] = new SMESHGUI_MeshTab( myTabWg );
389   myTabs[ Dim2D ] = new SMESHGUI_MeshTab( myTabWg );
390   myTabs[ Dim3D ] = new SMESHGUI_MeshTab( myTabWg );
391   myTabWg->addTab( myTabs[ Dim3D ], tr( "DIM_3D" ) );
392   myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) );
393   myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) );
394   myTabWg->addTab( myTabs[ Dim0D ], tr( "DIM_0D" ) );
395
396   // Hypotheses Sets
397   myHypoSetButton = new QToolButton( mainFrame() );
398   myHypoSetButton->setText( tr( "HYPOTHESES_SETS" ) );
399   myHypoSetButton->setEnabled( false );
400   myHypoSetButton->setSizePolicy( QSizePolicy::MinimumExpanding, 
401                                   myHypoSetButton->sizePolicy().verticalPolicy() );
402   
403   // Fill layout
404   QGridLayout* aLay = new QGridLayout( mainFrame() );
405   aLay->setMargin( 0 );
406   aLay->setSpacing( SPACING );
407
408   aLay->addWidget( objectWg( Obj,  Label ),   0, 0 );
409   aLay->addWidget( objectWg( Obj,  Btn ),     0, 1 );
410   aLay->addWidget( objectWg( Obj,  Control ), 0, 2 );
411   aLay->addWidget( objectWg( Mesh, Label ),   1, 0 );
412   aLay->addWidget( objectWg( Mesh, Btn ),     1, 1 );
413   aLay->addWidget( objectWg( Mesh, Control ), 1, 2 );
414   aLay->addWidget( objectWg( Geom, Label ),   2, 0 );
415   aLay->addWidget( objectWg( Geom, Btn ),     2, 1 );
416   aLay->addWidget( objectWg( Geom, Control ), 2, 2 );
417   aLay->addWidget( anMeshTypeLbl,             3, 0 );
418   aLay->addWidget( myMeshType,                3, 2 );
419   aLay->addWidget( myTabWg,                   5, 0, 1, 3 );
420   aLay->addWidget( myHypoSetButton,           6, 0, 1, 3 );
421   aLay->setRowMinimumHeight( 3, 20 );
422
423   myMeshType->clear();
424
425   // Connect signals and slots
426   connect( myMeshType, SIGNAL( activated( int ) ), SLOT( onChangedMeshType( int ) ) );
427   // Disable controls if necessary
428   setObjectShown( Mesh, false );
429   if ( theToCreate )
430   {
431     setWindowTitle( tr( "CREATE_MESH" ) );
432     objectWg( Obj, Btn )->hide();
433     if ( theIsMesh )
434       setWindowTitle( tr( "CREATE_MESH" ) );
435     else
436     {
437       setWindowTitle( tr( "CREATE_SUBMESH" ) );
438       setObjectShown( Mesh, true );
439     }
440   }
441   else
442   {
443     setWindowTitle( tr( "EDIT_MESH_SUBMESH" ) );
444     objectWg( Mesh, Btn )->hide();
445     objectWg( Geom, Btn )->hide();
446   }
447 }
448
449 SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg()
450 {
451 }
452
453 //================================================================================
454 /*!
455  * \brief Gets tab with given id
456   * \param theId - Tab identifier. Possible values are in "Dimensions" enumeration
457   * \retval SMESHGUI_MeshTab* - pointer to the tab or null if given parameter is 
458   * invalid
459  * 
460  * Gets tab containing controls for definition of algorithms and AddHypotheses
461  */
462 //================================================================================
463 SMESHGUI_MeshTab* SMESHGUI_MeshDlg::tab( const int theId ) const
464 {
465   return ( theId >= Dim0D && theId <= Dim3D ? myTabs[ theId ] : 0 );
466 }
467
468 //================================================================================
469 /*!
470  * \brief Resets all dialog fields
471  */
472 //================================================================================  
473 void SMESHGUI_MeshDlg::reset()
474 {
475   clearSelection();
476   myTabs[ Dim0D ]->reset();
477   myTabs[ Dim1D ]->reset();
478   myTabs[ Dim2D ]->reset();
479   myTabs[ Dim3D ]->reset();
480 }
481
482 //================================================================================
483 /*!
484  * \brief Sets curent tab
485  */
486 //================================================================================    
487 void SMESHGUI_MeshDlg::setCurrentTab( const int theId  )
488 {
489   myTabWg->setCurrentIndex( Dim3D - theId );
490 }
491
492 //================================================================================
493 /*!
494  * \brief Enable/disable tabs
495   * \param int - maximum possible dimention
496  */
497 //================================================================================
498
499 void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
500 {
501   const int DIM = maxDim;
502   for ( int dim = Dim0D; dim <= Dim3D; ++dim ) {
503     bool enable = ( dim <= DIM );
504     if ( !enable ) {
505       myTabs[ dim ]->reset();
506       disableTab( dim );
507     }
508     else {
509       enableTab( dim );
510     }
511   }
512   // deselect desabled tab
513   if ( !myTabWg->isTabEnabled( myTabWg->currentIndex() ) )
514     setCurrentTab( DIM );
515 }
516
517 //================================================================================
518 /*!
519  * \brief Sets list of available Sets of Hypotheses
520  */
521 //================================================================================
522
523 void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
524 {
525   QMenu* aHypoSetPopup = myHypoSetButton->menu();
526   if ( !aHypoSetPopup ) {
527     aHypoSetPopup = new QMenu( myHypoSetButton );
528     connect( aHypoSetPopup, SIGNAL( triggered( QAction* ) ), SLOT( onHypoSetPopup( QAction* ) ) );
529     myHypoSetButton->setMenu( aHypoSetPopup );
530     myHypoSetButton->setPopupMode( QToolButton::InstantPopup );
531   }
532   aHypoSetPopup->clear();
533   for ( int i = 0, n = theSets.count(); i < n; i++ ) {
534     aHypoSetPopup->addAction( theSets[ i ] );
535   }
536   myHypoSetButton->setEnabled( !aHypoSetPopup->isEmpty() );
537 }
538
539 //================================================================================
540 /*!
541  * \brief Emits hypoSet signal
542  * 
543  * SLOT is called when a hypotheses set is selected. Emits hypoSet
544  * signal to notify operation about this event
545  */
546 //================================================================================
547
548 void SMESHGUI_MeshDlg::onHypoSetPopup( QAction* a )
549 {
550   emit hypoSet( a->text() );
551 }
552   
553 //================================================================================
554 /*!
555  * \brief Enable showing of the popup when Geometry selection btn is clicked
556   * \param enable - true to enable
557  */
558 //================================================================================
559
560 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
561
562 void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
563 {
564   if ( QToolButton* selBtn = qobject_cast<QToolButton*>( objectWg( Geom, Btn )))
565   {
566     if ( enable ) {
567       if ( ! myGeomPopup ) {
568         myGeomPopup = new QMenu();
569         myGeomPopup->addAction( tr("DIRECT_GEOM_SELECTION") )->setData( DIRECT_GEOM_INDEX );
570         myGeomPopup->addAction( tr("GEOM_BY_MESH_ELEM_SELECTION") )->setData( GEOM_BY_MESH_INDEX );
571         connect( myGeomPopup, SIGNAL( triggered( QAction* ) ), SLOT( onGeomPopup( QAction* ) ) );
572         connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
573       }
574     }
575     else {
576       disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
577       if ( myGeomPopup ) {
578         delete myGeomPopup;
579         myGeomPopup = 0;
580       }
581     }
582   }
583 }
584
585
586 //================================================================================
587 /*!
588  * \brief Disable tab
589  * \param int - tab ID
590  */
591 //================================================================================
592 void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
593   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false );
594   if ( theTabId == Dim3D ) myHypoSetButton->setEnabled( false );
595 }
596
597 //================================================================================
598 /*!
599  * \brief Enable tabs
600  * \param int - tab ID
601  */
602 //================================================================================
603 void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
604   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true );
605   if ( theTabId == Dim3D ) {
606     QMenu* aHypoSetPopup = myHypoSetButton->menu();
607     myHypoSetButton->setEnabled( aHypoSetPopup && !aHypoSetPopup->actions().isEmpty() );
608   }
609 }
610
611 //================================================================================
612 /*!
613  * \brief Check if tab enabled
614  * \param int - tab ID
615  */
616 //================================================================================
617 bool SMESHGUI_MeshDlg::isTabEnabled(const int theTabId) const {
618   return myTabWg->isTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ) );
619 }
620
621 void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
622 {
623   if ( myGeomPopup && isBtnOn )
624     myGeomPopup->exec( QCursor::pos() );
625 }
626
627 void SMESHGUI_MeshDlg::onGeomPopup( QAction* a )
628 {
629   emit geomSelectionByMesh( a->data().toInt() == GEOM_BY_MESH_INDEX );
630 }
631
632 int SMESHGUI_MeshDlg::getActiveObject()
633 {
634   for (int i = 0; i < 3; ++i )
635     if ( isObjectShown( i ) &&
636          (( QToolButton* )objectWg( i, Btn ))->isChecked())
637       return i;
638   return -1;
639 }
640 //================================================================================
641 /*!
642  * \brief Sets available types of mesh
643  * \param theTypeMesh - list of available types of mesh
644  */
645 //================================================================================
646 void SMESHGUI_MeshDlg::setAvailableMeshType( const QStringList& theTypeMesh )
647 {
648   myMeshType->clear();
649   myMeshType->addItems(theTypeMesh);
650 }
651 //================================================================================
652 /*!
653  * \brief Emits selectMeshType( const int, const int ) signal
654  *
655  * SLOT is called when a combo box "mesh type" is selected.
656  */
657 //================================================================================
658 void SMESHGUI_MeshDlg::onChangedMeshType( const int isIndex )
659 {
660   emit selectMeshType( Dim3D - myTabWg->currentIndex(), isIndex );
661 }
662 //================================================================================
663 /*!
664  * \brief Get current index types of mesh
665  */
666 //================================================================================
667 int SMESHGUI_MeshDlg::currentMeshType( )
668 {
669   return myMeshType->currentIndex( );
670 }
671
672