Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshDlg.cxx
1 // Copyright (C) 2007-2012  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   
368   // Create tab widget
369   
370   myTabWg = new QTabWidget( mainFrame() );
371   myTabs[ Dim0D ] = new SMESHGUI_MeshTab( myTabWg );
372   myTabs[ Dim1D ] = new SMESHGUI_MeshTab( myTabWg );
373   myTabs[ Dim2D ] = new SMESHGUI_MeshTab( myTabWg );
374   myTabs[ Dim3D ] = new SMESHGUI_MeshTab( myTabWg );
375   myTabWg->addTab( myTabs[ Dim3D ], tr( "DIM_3D" ) );
376   myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) );
377   myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) );
378   myTabWg->addTab( myTabs[ Dim0D ], tr( "DIM_0D" ) );
379
380   // Hypotheses Sets
381   myHypoSetButton = new QToolButton( mainFrame() );
382   myHypoSetButton->setText( tr( "HYPOTHESES_SETS" ) );
383   myHypoSetButton->setEnabled( false );
384   myHypoSetButton->setSizePolicy( QSizePolicy::MinimumExpanding, 
385                                   myHypoSetButton->sizePolicy().verticalPolicy() );
386   
387   // Fill layout
388   QGridLayout* aLay = new QGridLayout( mainFrame() );
389   aLay->setMargin( 0 );
390   aLay->setSpacing( SPACING );
391
392   aLay->addWidget( objectWg( Obj,  Label ),   0, 0 );
393   aLay->addWidget( objectWg( Obj,  Btn ),     0, 1 );
394   aLay->addWidget( objectWg( Obj,  Control ), 0, 2 );
395   aLay->addWidget( objectWg( Mesh, Label ),   1, 0 );
396   aLay->addWidget( objectWg( Mesh, Btn ),     1, 1 );
397   aLay->addWidget( objectWg( Mesh, Control ), 1, 2 );
398   aLay->addWidget( objectWg( Geom, Label ),   2, 0 );
399   aLay->addWidget( objectWg( Geom, Btn ),     2, 1 );
400   aLay->addWidget( objectWg( Geom, Control ), 2, 2 );
401   aLay->addWidget( myTabWg,                   4, 0, 1, 3 );
402   aLay->addWidget( myHypoSetButton,           5, 0, 1, 3 );
403   aLay->setRowMinimumHeight( 3, 20 );
404
405   // Disable controls if necessary
406   setObjectShown( Mesh, false );
407   if ( theToCreate )
408   {
409     setWindowTitle( tr( "CREATE_MESH" ) );
410     objectWg( Obj, Btn )->hide();
411     if ( theIsMesh )
412       setWindowTitle( tr( "CREATE_MESH" ) );
413     else
414     {
415       setWindowTitle( tr( "CREATE_SUBMESH" ) );
416       setObjectShown( Mesh, true );
417     }
418   }
419   else
420   {
421     setWindowTitle( tr( "EDIT_MESH_SUBMESH" ) );
422     objectWg( Mesh, Btn )->hide();
423     objectWg( Geom, Btn )->hide();
424   }
425 }
426
427 SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg()
428 {
429 }
430
431 //================================================================================
432 /*!
433  * \brief Gets tab with given id
434   * \param theId - Tab identifier. Possible values are in "Dimensions" enumeration
435   * \retval SMESHGUI_MeshTab* - pointer to the tab or null if given parameter is 
436   * invalid
437  * 
438  * Gets tab containing controls for definition of algorithms and AddHypotheses
439  */
440 //================================================================================
441 SMESHGUI_MeshTab* SMESHGUI_MeshDlg::tab( const int theId ) const
442 {
443   return ( theId >= Dim0D && theId <= Dim3D ? myTabs[ theId ] : 0 );
444 }
445
446 //================================================================================
447 /*!
448  * \brief Resets all dialog fields
449  */
450 //================================================================================  
451 void SMESHGUI_MeshDlg::reset()
452 {
453   clearSelection();
454   myTabs[ Dim0D ]->reset();
455   myTabs[ Dim1D ]->reset();
456   myTabs[ Dim2D ]->reset();
457   myTabs[ Dim3D ]->reset();
458 }
459
460 //================================================================================
461 /*!
462  * \brief Sets curent tab
463  */
464 //================================================================================    
465 void SMESHGUI_MeshDlg::setCurrentTab( const int theId  )
466 {
467   myTabWg->setCurrentIndex( Dim3D - theId );
468 }
469
470 //================================================================================
471 /*!
472  * \brief Enable/disable tabs
473   * \param int - maximum possible dimention
474  */
475 //================================================================================
476
477 void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
478 {
479   const int DIM = maxDim;
480   for ( int dim = Dim0D; dim <= Dim3D; ++dim ) {
481     bool enable = ( dim <= DIM );
482     if ( !enable ) {
483       myTabs[ dim ]->reset();
484       disableTab( dim );
485     }
486     else {
487       enableTab( dim );
488     }
489   }
490   // deselect desabled tab
491   if ( !myTabWg->isTabEnabled( myTabWg->currentIndex() ) )
492     setCurrentTab( DIM );
493 }
494
495 //================================================================================
496 /*!
497  * \brief Sets list of available Sets of Hypotheses
498  */
499 //================================================================================
500
501 void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
502 {
503   QMenu* aHypoSetPopup = myHypoSetButton->menu();
504   if ( !aHypoSetPopup ) {
505     aHypoSetPopup = new QMenu( myHypoSetButton );
506     connect( aHypoSetPopup, SIGNAL( triggered( QAction* ) ), SLOT( onHypoSetPopup( QAction* ) ) );
507     myHypoSetButton->setMenu( aHypoSetPopup );
508     myHypoSetButton->setPopupMode( QToolButton::InstantPopup );
509   }
510   aHypoSetPopup->clear();
511   for ( int i = 0, n = theSets.count(); i < n; i++ ) {
512     aHypoSetPopup->addAction( theSets[ i ] );
513   }
514   myHypoSetButton->setEnabled( !aHypoSetPopup->isEmpty() );
515 }
516
517 //================================================================================
518 /*!
519  * \brief Emits hypoSet signal
520  * 
521  * SLOT is called when a hypotheses set is selected. Emits hypoSet
522  * signal to notify operation about this event
523  */
524 //================================================================================
525
526 void SMESHGUI_MeshDlg::onHypoSetPopup( QAction* a )
527 {
528   emit hypoSet( a->text() );
529 }
530   
531 //================================================================================
532 /*!
533  * \brief Enable showing of the popup when Geometry selection btn is clicked
534   * \param enable - true to enable
535  */
536 //================================================================================
537
538 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
539
540 void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
541 {
542   if ( QToolButton* selBtn = qobject_cast<QToolButton*>( objectWg( Geom, Btn )))
543   {
544     if ( enable ) {
545       if ( ! myGeomPopup ) {
546         myGeomPopup = new QMenu();
547         myGeomPopup->addAction( tr("DIRECT_GEOM_SELECTION") )->setData( DIRECT_GEOM_INDEX );
548         myGeomPopup->addAction( tr("GEOM_BY_MESH_ELEM_SELECTION") )->setData( GEOM_BY_MESH_INDEX );
549         connect( myGeomPopup, SIGNAL( triggered( QAction* ) ), SLOT( onGeomPopup( QAction* ) ) );
550         connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
551       }
552     }
553     else {
554       disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
555       if ( myGeomPopup ) {
556         delete myGeomPopup;
557         myGeomPopup = 0;
558       }
559     }
560   }
561 }
562
563
564 //================================================================================
565 /*!
566  * \brief Disable tab
567  * \param int - tab ID
568  */
569 //================================================================================
570 void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
571   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false );
572   if ( theTabId == Dim3D ) myHypoSetButton->setEnabled( false );
573 }
574
575 //================================================================================
576 /*!
577  * \brief Enable tabs
578  * \param int - tab ID
579  */
580 //================================================================================
581 void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
582   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true );
583   if ( theTabId == Dim3D ) {
584     QMenu* aHypoSetPopup = myHypoSetButton->menu();
585     myHypoSetButton->setEnabled( aHypoSetPopup && !aHypoSetPopup->actions().isEmpty() );
586   }
587 }
588
589 //================================================================================
590 /*!
591  * \brief Check if tab enabled
592  * \param int - tab ID
593  */
594 //================================================================================
595 bool SMESHGUI_MeshDlg::isTabEnabled(const int theTabId) const {
596   return myTabWg->isTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ) );
597 }
598
599 void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
600 {
601   if ( myGeomPopup && isBtnOn )
602     myGeomPopup->exec( QCursor::pos() );
603 }
604
605 void SMESHGUI_MeshDlg::onGeomPopup( QAction* a )
606 {
607   emit geomSelectionByMesh( a->data().toInt() == GEOM_BY_MESH_INDEX );
608 }
609
610 int SMESHGUI_MeshDlg::getActiveObject()
611 {
612   for (int i = 0; i < 3; ++i )
613     if ( isObjectShown( i ) &&
614          (( QToolButton* )objectWg( i, Btn ))->isChecked())
615       return i;
616   return -1;
617 }