1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_MeshDlg.cxx
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
28 #include "SMESHGUI_MeshDlg.h"
30 // SALOME GUI includes
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
37 #include <QGridLayout>
40 #include <QListWidget>
42 #include <QPushButton>
44 #include <QToolButton>
45 #include <QVBoxLayout>
47 #include <Standard_Integer.hxx>
53 * \brief Tab for tab widget containing controls for definition of
54 * algorithms and hypotheses
57 //================================================================================
60 * \param theParent - Parent widget for this tab
62 * Makes tab's look and feel
64 //================================================================================
65 SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
68 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
69 QIcon aCreateIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO" ) ) );
70 QIcon aEditIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO_EDIT" ) ) );
71 QIcon aPlusIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_PLUS" ) ) );
72 QIcon aMinusIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_MINUS" ) ) );
75 QLabel* anAlgoLbl = new QLabel( tr( "ALGORITHM" ), this );
76 myHypCombo[ Algo ] = new QComboBox( this );
79 QLabel* aHypLbl = new QLabel( tr( "HYPOTHESIS" ), this );
80 myHypCombo[ MainHyp ] = new QComboBox( this );
81 myHypCombo[ MainHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
82 myCreateHypBtn[ MainHyp ] = new QToolButton( this );
83 myCreateHypBtn[ MainHyp ]->setIcon( aCreateIcon );
84 myEditHypBtn[ MainHyp ] = new QToolButton( this );
85 myEditHypBtn[ MainHyp ]->setIcon( aEditIcon );
88 QFrame* aLine = new QFrame( this );
89 aLine->setFrameStyle( QFrame::HLine | QFrame::Sunken );
92 QLabel* anAddHypLbl = new QLabel( tr( "ADD_HYPOTHESIS" ), this );
93 myHypCombo[ AddHyp ] = new QComboBox( this );
94 myHypCombo[ AddHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
95 myCreateHypBtn[ AddHyp ] = new QToolButton( this );
96 myCreateHypBtn[ AddHyp ]->setIcon( aCreateIcon );
97 myEditHypBtn[ AddHyp ] = new QToolButton( this );
98 myEditHypBtn[ AddHyp ]->setIcon( aEditIcon );
99 myEditHypBtn[ MoreAddHyp ] = new QToolButton( this );
100 myEditHypBtn[ MoreAddHyp ]->setIcon( aEditIcon );
102 myAddHypList = new QListWidget( this );
103 myMoreAddHypBtn = new QToolButton( this );
104 myMoreAddHypBtn->setIcon( aPlusIcon );
105 myLessAddHypBtn = new QToolButton( this );
106 myLessAddHypBtn->setIcon( aMinusIcon );
109 QGridLayout* aLay = new QGridLayout( this );
110 aLay->setMargin( MARGIN );
111 aLay->setSpacing( SPACING );
113 aLay->addWidget( anAlgoLbl, 0, 0 );
114 aLay->addWidget( myHypCombo[ Algo ], 0, 1 );
115 aLay->addWidget( aHypLbl, 1, 0 );
116 aLay->addWidget( myHypCombo[ MainHyp ], 1, 1 );
117 aLay->addWidget( myCreateHypBtn[ MainHyp ], 1, 2 );
118 aLay->addWidget( myEditHypBtn[ MainHyp ], 1, 3 );
119 aLay->addWidget( aLine, 2, 0, 1, 4 );
120 aLay->addWidget( anAddHypLbl, 3, 0 );
121 aLay->addWidget( myHypCombo[ AddHyp ], 3, 1 );
122 aLay->addWidget( myCreateHypBtn[ AddHyp ], 3, 2 );
123 aLay->addWidget( myEditHypBtn[ AddHyp ], 3, 3 );
124 aLay->addWidget( myAddHypList, 4, 1, 2, 1 );
125 aLay->addWidget( myMoreAddHypBtn, 4, 2 );
126 aLay->addWidget( myEditHypBtn[ MoreAddHyp ], 4, 3 );
127 aLay->addWidget( myLessAddHypBtn, 5, 2 );
128 aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ), 6, 0 );
130 // Connect signals and slots
131 for ( int i = MainHyp; i <= AddHyp; i++ )
133 connect( myCreateHypBtn[ i ], SIGNAL( clicked() ) , SLOT( onCreateHyp() ) );
134 connect( myEditHypBtn[ i ] , SIGNAL( clicked() ) , SLOT( onEditHyp() ) );
135 connect( myHypCombo[ i ] , SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) );
137 connect( myHypCombo[ Algo ], SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) );
139 connect( myAddHypList, SIGNAL( currentRowChanged( int ) ), SLOT( onHyp( int ) ) );
140 connect( myEditHypBtn[ MoreAddHyp ], SIGNAL( clicked() ), SLOT( onEditHyp() ) );
141 connect( myMoreAddHypBtn, SIGNAL( clicked() ), SLOT( onMoreAddHyp() ));
142 connect( myLessAddHypBtn, SIGNAL( clicked() ), SLOT( onLessAddHyp() ));
144 // Initialize controls
146 setAvailableHyps( Algo, QStringList() );
147 setAvailableHyps( MainHyp, QStringList() );
148 setAvailableHyps( AddHyp, QStringList() );
151 //================================================================================
155 //================================================================================
156 SMESHGUI_MeshTab::~SMESHGUI_MeshTab()
160 //================================================================================
162 * \brief Adds an item in a control corresponding to \a type
163 * \param [in] txt - item text
164 * \param [in] type - HypType
165 * \param [in] index - index of item in a list of items
167 //================================================================================
169 void SMESHGUI_MeshTab::addItem( const QString& txt, const int type, const int index )
171 if ( type <= AddHyp )
173 myHypCombo[ type ]->addItem( txt, QVariant( index ));
174 myHypCombo[ type ]->setMaxVisibleItems( qMax( 10, myHypCombo[ type ]->count() ) );
178 QListWidgetItem* item = new QListWidgetItem( txt, myAddHypList );
179 item->setData( Qt::UserRole, QVariant( index ));
183 //================================================================================
185 * \brief Returns index of hyp of a given type
187 //================================================================================
189 int SMESHGUI_MeshTab::getCurrentIndex( const int type, const bool curByType ) const
191 if ( type <= AddHyp )
193 return myHypCombo[ type ]->itemData( myHypCombo[ type ]->currentIndex() ).toInt();
197 int row = curByType ? ( type - AddHyp - 1 ) : myAddHypList->currentRow();
198 if ( QListWidgetItem* item = myAddHypList->item( row ))
199 return item->data( Qt::UserRole ).toInt();
204 //================================================================================
206 * \brief Sets available hypothesis or algorithms
207 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
208 * \param theHyps - list of available hypothesis names
210 * Sets available main or additional hypothesis for this tab
212 //================================================================================
213 void SMESHGUI_MeshTab::setAvailableHyps( const int theId, const QStringList& theHyps )
215 myAvailableHypTypes[ theId ] = theHyps;
217 bool enable = ! theHyps.isEmpty();
218 if ( theId == Algo ) // fill list of algos
220 myHypCombo[ Algo ]->clear();
223 addItem( tr( "NONE"), Algo, 0 );
224 for ( int i = 0, nbHyp = theHyps.count(); i < nbHyp; ++i )
225 addItem( theHyps[i], Algo, i+1 );
226 myHypCombo[ Algo ]->setCurrentIndex( 0 );
229 else // enable buttons
231 myCreateHypBtn[ theId ]->setEnabled( enable );
232 myEditHypBtn [ theId ]->setEnabled( false );
234 myHypCombo[ theId ]->setEnabled( enable );
237 //================================================================================
239 * \brief Sets existing hypothesis
240 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
241 * \param theHyps - list of available hypothesis names
242 * \param theDefaultAvlbl - \c true means that the algorithm can work w/o hypothesis
243 * with some default parameters
245 * Sets existing main or additional hypothesis for this tab
247 //================================================================================
248 void SMESHGUI_MeshTab::setExistingHyps( const int theId,
249 const QStringList& theHyps,
250 bool theDefaultAvlbl)
254 bool enable = ! myAvailableHypTypes[ theId ].isEmpty();
255 myHypCombo[ theId ]->clear();
258 QString none = tr( theDefaultAvlbl ? "DEFAULT" : ( theId == AddHyp ) ? "NONE" : "NONE" );
259 addItem( none, theId, 0 );
260 for ( int i = 0, nbHyp = theHyps.count(); i < nbHyp; ++i )
261 addItem( theHyps[i], theId, i+1 );
262 myHypCombo[ theId ]->setCurrentIndex( 0 );
264 myHypCombo [ theId ]->setEnabled( enable );
265 myEditHypBtn[ theId ]->setEnabled( false );
266 if ( theId == AddHyp )
268 myAddHypList->clear();
269 myEditHypBtn[ MoreAddHyp ]->setEnabled( false );
270 myMoreAddHypBtn->setEnabled( false );
271 myLessAddHypBtn->setEnabled( false );
276 //================================================================================
278 * \brief Adds hypothesis in combo box of available ones
279 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
280 * \param theHyp - name of hypothesis to be added
282 * Adds hypothesis in combo box of available ones. This method is called by operation
283 * after creation of new hypothesis.
285 //================================================================================
286 void SMESHGUI_MeshTab::addHyp( const int theId, const QString& theHyp )
288 int index = myHypCombo[ theId ]->count();
289 if ( theId == AddHyp )
290 index += myAddHypList->count();
291 addItem( theHyp, theId, index );
292 myHypCombo[ theId ]->setCurrentIndex( myHypCombo[ theId ]->count() - 1 );
293 myEditHypBtn[ theId ]->setEnabled( true );
294 myHypCombo[ theId ]->setEnabled( true );
295 if ( theId == AddHyp )
296 myMoreAddHypBtn->setEnabled( true );
299 //================================================================================
301 * \brief Renames hypothesis
302 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
303 * \param theIndex - index of hypothesis to be renamed
304 * \param theNewName - new name of hypothesis to be renamed
308 //================================================================================
309 // void SMESHGUI_MeshTab::renameHyp( const int theId,
310 // const int theIndex,
311 // const QString& theNewName )
313 // if ( theIndex > 0 && theIndex < myHypCombo[ theId ]->count() )
314 // myHypCombo[ theId ]->setItemText( theIndex, theNewName );
317 //================================================================================
319 * \brief Sets current hypothesis
320 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
321 * \param theIndex - index of hypothesis to be set as current
323 * Sets current hypothesis
325 //================================================================================
326 void SMESHGUI_MeshTab::setCurrentHyp( const int theId, const int theIndex )
328 if ( theId <= AddHyp )
330 if ( theIndex >= 0 && theIndex < myHypCombo[ theId ]->count() )
332 myHypCombo[ theId ]->setCurrentIndex( theIndex );
333 if ( myEditHypBtn[ theId ] )
334 myEditHypBtn[ theId ]->setEnabled( theIndex > 0 );
335 if ( theId == AddHyp )
336 myMoreAddHypBtn ->setEnabled( theIndex > 0 );
339 else // more than one additional hyp assigned
341 // move a hyp from myHypCombo[ AddHyp ] to myAddHypList
342 for ( int i = 1, nb = myHypCombo[ AddHyp ]->count(); i < nb; ++i )
344 int curIndex = myHypCombo[ AddHyp ]->itemData( i ).toInt();
345 if ( theIndex == curIndex )
347 addItem( myHypCombo[ AddHyp ]->itemText( i ), theId, theIndex );
348 myHypCombo[ AddHyp ]->removeItem( i );
355 //================================================================================
357 * \brief Gets current hypothesis
358 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
359 * \retval int - index of current hypothesis
361 * Gets current hypothesis
362 * Use theId > AddHyp to get more than selected addetional hyps (see nbAddHypTypes()).
364 //================================================================================
365 int SMESHGUI_MeshTab::currentHyp( const int theId ) const
367 return getCurrentIndex( theId, /*curByType=*/true );
370 //================================================================================
372 * \brief Returns nb of selected supplementary additional hypotheses
374 * Access to their indices is via currentHyp( AddHyp + i ) where i is within the
375 * range 0 <= i < this->nbAddHypTypes()
377 //================================================================================
379 int SMESHGUI_MeshTab::nbAddHypTypes() const
381 return myAddHypList->count();
384 //================================================================================
386 * \brief Emits createHyp( const int ) signal
388 * SLOT called when "Create hypothesis" button clicked specifies sender and emits
389 * createHyp( const int ) signal
391 //================================================================================
392 void SMESHGUI_MeshTab::onCreateHyp()
394 bool isMainHyp = ( sender() == myCreateHypBtn[ MainHyp ]);
396 QMenu aPopup( this );
398 QStringList aHypNames = isMainHyp ?
399 myAvailableHypTypes[ MainHyp ] : myAvailableHypTypes[ AddHyp ];
401 QList<QAction*> actions;
402 for ( int i = 0, n = aHypNames.count(); i < n; i++ )
403 actions.append( aPopup.addAction( aHypNames[ i ] ) );
405 QAction* a = aPopup.exec( QCursor::pos() );
407 emit createHyp( isMainHyp ? MainHyp : AddHyp, actions.indexOf( a ) );
410 //================================================================================
412 * \brief Emits editHyp( const int ) signal
414 * SLOT called when "Edit hypothesis" button clicked specifies sender and emits
415 * editHyp( const int ) signal
417 //================================================================================
418 void SMESHGUI_MeshTab::onEditHyp()
420 const QObject* aSender = sender();
421 int aHypType = MainHyp;
422 for ( ; aHypType <= MoreAddHyp; ++aHypType )
423 if ( aSender == myEditHypBtn[ aHypType ])
425 emit editHyp( Min( aHypType, AddHyp ),
426 getCurrentIndex( aHypType ) - 1 ); // - 1 because there is NONE on the top
429 //================================================================================
431 * \brief Updates "Edit hypothesis" button state
433 * SLOT called when current hypothesis changed. Disables "Edit hypothesis" button
434 * if current hypothesis is <None>, enables otherwise.
435 * If an algorithm changed, emits selectAlgo( theIndex ) signal
437 //================================================================================
438 void SMESHGUI_MeshTab::onHyp( int theIndex )
440 const QObject* aSender = sender();
441 if ( aSender == myHypCombo[ Algo ] )
443 emit selectAlgo( theIndex - 1 ); // - 1 because there is NONE on the top
445 else if ( aSender == myAddHypList )
447 myEditHypBtn[ MoreAddHyp ]->setEnabled( theIndex >= 0 );
448 myLessAddHypBtn ->setEnabled( theIndex >= 0 );
452 int type = ( aSender == myHypCombo[ MainHyp ] ? MainHyp : AddHyp );
453 myEditHypBtn[ type ]->setEnabled( theIndex > 0 );
455 if ( type == AddHyp )
456 myMoreAddHypBtn ->setEnabled( theIndex > 0 );
460 //================================================================================
462 * \brief Adds a current additional hyp to myAddHypList
464 * SLOT called when myMoreAddHypBtn ("plus") clicked
466 //================================================================================
468 void SMESHGUI_MeshTab::onMoreAddHyp()
470 int hypIndex = currentHyp( AddHyp );
473 // move a hyp from myHypCombo[ AddHyp ] to myAddHypList
474 int comboIndex = myHypCombo[ AddHyp ]->currentIndex();
475 addItem( myHypCombo[ AddHyp ]->itemText( comboIndex ), MoreAddHyp, hypIndex );
477 myHypCombo[ AddHyp ]->removeItem( comboIndex );
478 myHypCombo[ AddHyp ]->setCurrentIndex( 0 );
480 myMoreAddHypBtn->setEnabled( false );
481 myEditHypBtn[ AddHyp ]->setEnabled( false );
485 //================================================================================
487 * \brief Removes a current additional hyp from myAddHypList
489 * SLOT called when myLessAddHypBtn ("minus") clicked
491 //================================================================================
493 void SMESHGUI_MeshTab::onLessAddHyp()
495 if ( QListWidgetItem * item = myAddHypList->currentItem() )
497 // move a hyp from myAddHypList to myHypCombo[ AddHyp ]
498 int hypIndex = item->data( Qt::UserRole ).toInt();
499 addItem( item->text(), AddHyp, hypIndex );
500 delete item;//myAddHypList->takeItem( myAddHypList->currentRow() );
504 //================================================================================
506 * \brief Resets all tab fields
508 * Resets all tab fields
510 //================================================================================
511 void SMESHGUI_MeshTab::reset()
513 for ( int i = Algo; i <= AddHyp; i++ )
515 myHypCombo[ i ]->setCurrentIndex( 0 );
516 if ( myEditHypBtn[ i ] )
517 myEditHypBtn[ i ]->setEnabled( false );
522 * \brief Dialog for mech creation or editing
524 * This dialog is used for mech creation or editing.
527 //================================================================================
530 * \param theToCreate - if this parameter is true then dialog is used for creation,
531 * for editing otherwise
532 * \param theIsMesh - if this parameter is true then dialog is used for mesh,
533 * for sub-mesh otherwise
535 * Makes dialog's look and feel
537 //================================================================================
538 SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh )
539 : SMESHGUI_Dialog( 0, false, true )
541 // Create top controls
543 setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
545 createObject( tr( "NAME" ), mainFrame(), Obj );
546 setNameIndication( Obj, OneName );
547 setReadOnly( Obj, false );
549 createObject( tr( "MESH" ), mainFrame(), Mesh );
551 createObject( tr( "GEOMETRY" ), mainFrame(), Geom );
554 QLabel* anMeshTypeLbl = new QLabel( tr( "MESH_TYPE" ), this );
555 myMeshType = new QComboBox( this );
559 myTabWg = new QTabWidget( mainFrame() );
560 myTabs[ Dim0D ] = new SMESHGUI_MeshTab( myTabWg );
561 myTabs[ Dim1D ] = new SMESHGUI_MeshTab( myTabWg );
562 myTabs[ Dim2D ] = new SMESHGUI_MeshTab( myTabWg );
563 myTabs[ Dim3D ] = new SMESHGUI_MeshTab( myTabWg );
564 myTabWg->addTab( myTabs[ Dim3D ], tr( "DIM_3D" ) );
565 myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) );
566 myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) );
567 myTabWg->addTab( myTabs[ Dim0D ], tr( "DIM_0D" ) );
570 myHypoSetButton = new QToolButton( mainFrame() );
571 myHypoSetButton->setText( tr( "HYPOTHESES_SETS" ) );
572 myHypoSetButton->setEnabled( false );
573 myHypoSetButton->setSizePolicy( QSizePolicy::MinimumExpanding,
574 myHypoSetButton->sizePolicy().verticalPolicy() );
577 QGridLayout* aLay = new QGridLayout( mainFrame() );
578 aLay->setMargin( 0 );
579 aLay->setSpacing( SPACING );
581 aLay->addWidget( objectWg( Obj, Label ), 0, 0 );
582 aLay->addWidget( objectWg( Obj, Btn ), 0, 1 );
583 aLay->addWidget( objectWg( Obj, Control ), 0, 2 );
584 aLay->addWidget( objectWg( Mesh, Label ), 1, 0 );
585 aLay->addWidget( objectWg( Mesh, Btn ), 1, 1 );
586 aLay->addWidget( objectWg( Mesh, Control ), 1, 2 );
587 aLay->addWidget( objectWg( Geom, Label ), 2, 0 );
588 aLay->addWidget( objectWg( Geom, Btn ), 2, 1 );
589 aLay->addWidget( objectWg( Geom, Control ), 2, 2 );
590 aLay->addWidget( anMeshTypeLbl, 3, 0 );
591 aLay->addWidget( myMeshType, 3, 2 );
592 aLay->addWidget( myTabWg, 5, 0, 1, 3 );
593 aLay->addWidget( myHypoSetButton, 6, 0, 1, 3 );
594 aLay->setRowMinimumHeight( 3, 20 );
598 // Connect signals and slots
599 connect( myMeshType, SIGNAL( activated( int ) ), SLOT( onChangedMeshType( int ) ) );
600 // Disable controls if necessary
601 setObjectShown( Mesh, false );
604 setWindowTitle( tr( "CREATE_MESH" ) );
605 objectWg( Obj, Btn )->hide();
607 setWindowTitle( tr( "CREATE_MESH" ) );
610 setWindowTitle( tr( "CREATE_SUBMESH" ) );
611 setObjectShown( Mesh, true );
616 setWindowTitle( tr( "EDIT_MESH_SUBMESH" ) );
617 objectWg( Mesh, Btn )->hide();
618 objectWg( Geom, Btn )->hide();
622 SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg()
626 //================================================================================
628 * \brief Gets tab with given id
629 * \param theId - Tab identifier. Possible values are in "Dimensions" enumeration
630 * \retval SMESHGUI_MeshTab* - pointer to the tab or null if given parameter is
633 * Gets tab containing controls for definition of algorithms and AddHypotheses
635 //================================================================================
636 SMESHGUI_MeshTab* SMESHGUI_MeshDlg::tab( const int theId ) const
638 return ( theId >= Dim0D && theId <= Dim3D ? myTabs[ theId ] : 0 );
641 //================================================================================
643 * \brief Resets all dialog fields
645 //================================================================================
646 void SMESHGUI_MeshDlg::reset()
649 myTabs[ Dim0D ]->reset();
650 myTabs[ Dim1D ]->reset();
651 myTabs[ Dim2D ]->reset();
652 myTabs[ Dim3D ]->reset();
655 //================================================================================
657 * \brief Sets curent tab
659 //================================================================================
660 void SMESHGUI_MeshDlg::setCurrentTab( const int theId )
662 myTabWg->setCurrentIndex( Dim3D - theId );
665 //================================================================================
667 * \brief Enable/disable tabs
668 * \param int - maximum possible dimention
670 //================================================================================
672 void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
674 const int DIM = maxDim;
675 for ( int dim = Dim0D; dim <= Dim3D; ++dim ) {
676 bool enable = ( dim <= DIM );
678 myTabs[ dim ]->reset();
685 // deselect desabled tab
686 if ( !myTabWg->isTabEnabled( myTabWg->currentIndex() ) )
687 setCurrentTab( DIM );
690 //================================================================================
692 * \brief Sets list of available Sets of Hypotheses
694 //================================================================================
696 void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
698 QMenu* aHypoSetPopup = myHypoSetButton->menu();
699 if ( !aHypoSetPopup ) {
700 aHypoSetPopup = new QMenu( myHypoSetButton );
701 connect( aHypoSetPopup, SIGNAL( triggered( QAction* ) ), SLOT( onHypoSetPopup( QAction* ) ) );
702 myHypoSetButton->setMenu( aHypoSetPopup );
703 myHypoSetButton->setPopupMode( QToolButton::InstantPopup );
705 aHypoSetPopup->clear();
706 for ( int i = 0, n = theSets.count(); i < n; i++ ) {
707 aHypoSetPopup->addAction( theSets[ i ] );
709 myHypoSetButton->setEnabled( !aHypoSetPopup->isEmpty() );
712 //================================================================================
714 * \brief Emits hypoSet signal
716 * SLOT is called when a hypotheses set is selected. Emits hypoSet
717 * signal to notify operation about this event
719 //================================================================================
721 void SMESHGUI_MeshDlg::onHypoSetPopup( QAction* a )
723 emit hypoSet( a->text() );
726 //================================================================================
728 * \brief Enable showing of the popup when Geometry selection btn is clicked
729 * \param enable - true to enable
731 //================================================================================
733 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
735 void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
737 if ( QToolButton* selBtn = qobject_cast<QToolButton*>( objectWg( Geom, Btn )))
740 if ( ! myGeomPopup ) {
741 myGeomPopup = new QMenu();
742 myGeomPopup->addAction( tr("DIRECT_GEOM_SELECTION") )->setData( DIRECT_GEOM_INDEX );
743 myGeomPopup->addAction( tr("GEOM_BY_MESH_ELEM_SELECTION") )->setData( GEOM_BY_MESH_INDEX );
744 connect( myGeomPopup, SIGNAL( triggered( QAction* ) ), SLOT( onGeomPopup( QAction* ) ) );
745 connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
749 disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
759 //================================================================================
762 * \param int - tab ID
764 //================================================================================
765 void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
766 myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false );
767 if ( theTabId == Dim3D ) myHypoSetButton->setEnabled( false );
770 //================================================================================
773 * \param int - tab ID
775 //================================================================================
776 void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
777 myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true );
778 if ( theTabId == Dim3D ) {
779 QMenu* aHypoSetPopup = myHypoSetButton->menu();
780 myHypoSetButton->setEnabled( aHypoSetPopup && !aHypoSetPopup->actions().isEmpty() );
784 //================================================================================
786 * \brief Check if tab enabled
787 * \param int - tab ID
789 //================================================================================
790 bool SMESHGUI_MeshDlg::isTabEnabled(const int theTabId) const {
791 return myTabWg->isTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ) );
794 void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
796 if ( myGeomPopup && isBtnOn )
797 myGeomPopup->exec( QCursor::pos() );
800 void SMESHGUI_MeshDlg::onGeomPopup( QAction* a )
802 emit geomSelectionByMesh( a->data().toInt() == GEOM_BY_MESH_INDEX );
805 int SMESHGUI_MeshDlg::getActiveObject()
807 for (int i = 0; i < 3; ++i )
808 if ( isObjectShown( i ) &&
809 (( QToolButton* )objectWg( i, Btn ))->isChecked())
813 //================================================================================
815 * \brief Sets available types of mesh
816 * \param theTypeMesh - list of available types of mesh
818 //================================================================================
819 void SMESHGUI_MeshDlg::setAvailableMeshType( const QStringList& theTypeMesh )
822 myMeshType->addItems(theTypeMesh);
824 //================================================================================
826 * \brief Emits selectMeshType( const int, const int ) signal
828 * SLOT is called when a combo box "mesh type" is selected.
830 //================================================================================
831 void SMESHGUI_MeshDlg::onChangedMeshType( const int isIndex )
833 emit selectMeshType( Dim3D - myTabWg->currentIndex(), isIndex );
835 //================================================================================
837 * \brief Get current index types of mesh
839 //================================================================================
840 int SMESHGUI_MeshDlg::currentMeshType( )
842 return myMeshType->currentIndex( );
844 //================================================================================
846 * \brief Set current index types of mesh
848 //================================================================================
849 void SMESHGUI_MeshDlg::setCurrentMeshType( const int theIndex )
851 myMeshType->setCurrentIndex( theIndex );