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