1 // Copyright (C) 2007-2016 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>
38 #include <QGridLayout>
41 #include <QListWidget>
43 #include <QPushButton>
45 #include <QToolButton>
46 #include <QVBoxLayout>
48 #include <Standard_Integer.hxx>
54 * \brief Tab for tab widget containing controls for definition of
55 * algorithms and hypotheses
58 //================================================================================
61 * \param theParent - Parent widget for this tab
63 * Makes tab's look and feel
65 //================================================================================
66 SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
69 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
70 QIcon aCreateIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO" ) ) );
71 QIcon aEditIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO_EDIT" ) ) );
72 QIcon aPlusIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_PLUS" ) ) );
73 QIcon aMinusIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_MINUS" ) ) );
76 QLabel* anAlgoLbl = new QLabel( tr( "ALGORITHM" ), this );
77 myHypCombo[ Algo ] = new QComboBox( this );
80 QLabel* aHypLbl = new QLabel( tr( "HYPOTHESIS" ), this );
81 myHypCombo[ MainHyp ] = new QComboBox( this );
82 myHypCombo[ MainHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
83 myCreateHypBtn[ MainHyp ] = new QToolButton( this );
84 myCreateHypBtn[ MainHyp ]->setIcon( aCreateIcon );
85 myEditHypBtn[ MainHyp ] = new QToolButton( this );
86 myEditHypBtn[ MainHyp ]->setIcon( aEditIcon );
89 QFrame* aLine = new QFrame( this );
90 aLine->setFrameStyle( QFrame::HLine | QFrame::Sunken );
93 QLabel* anAddHypLbl = new QLabel( tr( "ADD_HYPOTHESIS" ), this );
94 myHypCombo[ AddHyp ] = new QComboBox( this );
95 myHypCombo[ AddHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
96 myCreateHypBtn[ AddHyp ] = new QToolButton( this );
97 myCreateHypBtn[ AddHyp ]->setIcon( aCreateIcon );
98 myEditHypBtn[ AddHyp ] = new QToolButton( this );
99 myEditHypBtn[ AddHyp ]->setIcon( aEditIcon );
100 myEditHypBtn[ MoreAddHyp ] = new QToolButton( this );
101 myEditHypBtn[ MoreAddHyp ]->setIcon( aEditIcon );
103 myAddHypList = new QListWidget( this );
104 myMoreAddHypBtn = new QToolButton( this );
105 myMoreAddHypBtn->setIcon( aPlusIcon );
106 myLessAddHypBtn = new QToolButton( this );
107 myLessAddHypBtn->setIcon( aMinusIcon );
110 QGridLayout* aLay = new QGridLayout( this );
111 aLay->setMargin( MARGIN );
112 aLay->setSpacing( SPACING );
114 aLay->addWidget( anAlgoLbl, 0, 0 );
115 aLay->addWidget( myHypCombo[ Algo ], 0, 1 );
116 aLay->addWidget( aHypLbl, 1, 0 );
117 aLay->addWidget( myHypCombo[ MainHyp ], 1, 1 );
118 aLay->addWidget( myCreateHypBtn[ MainHyp ], 1, 2 );
119 aLay->addWidget( myEditHypBtn[ MainHyp ], 1, 3 );
120 aLay->addWidget( aLine, 2, 0, 1, 4 );
121 aLay->addWidget( anAddHypLbl, 3, 0 );
122 aLay->addWidget( myHypCombo[ AddHyp ], 3, 1 );
123 aLay->addWidget( myCreateHypBtn[ AddHyp ], 3, 2 );
124 aLay->addWidget( myEditHypBtn[ AddHyp ], 3, 3 );
125 aLay->addWidget( myAddHypList, 4, 1, 2, 1 );
126 aLay->addWidget( myMoreAddHypBtn, 4, 2 );
127 aLay->addWidget( myEditHypBtn[ MoreAddHyp ], 4, 3 );
128 aLay->addWidget( myLessAddHypBtn, 5, 2 );
129 aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ), 6, 0 );
131 // Connect signals and slots
132 for ( int i = MainHyp; i <= AddHyp; i++ )
134 connect( myCreateHypBtn[ i ], SIGNAL( clicked() ) , SLOT( onCreateHyp() ) );
135 connect( myEditHypBtn[ i ] , SIGNAL( clicked() ) , SLOT( onEditHyp() ) );
136 connect( myHypCombo[ i ] , SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) );
138 connect( myHypCombo[ Algo ], SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) );
140 connect( myAddHypList, SIGNAL( currentRowChanged( int ) ), SLOT( onHyp( int ) ) );
141 connect( myEditHypBtn[ MoreAddHyp ], SIGNAL( clicked() ), SLOT( onEditHyp() ) );
142 connect( myMoreAddHypBtn, SIGNAL( clicked() ), SLOT( onMoreAddHyp() ));
143 connect( myLessAddHypBtn, SIGNAL( clicked() ), SLOT( onLessAddHyp() ));
145 // Initialize controls
147 setAvailableHyps( Algo, QStringList() );
148 setAvailableHyps( MainHyp, QStringList() );
149 setAvailableHyps( AddHyp, QStringList() );
152 //================================================================================
156 //================================================================================
157 SMESHGUI_MeshTab::~SMESHGUI_MeshTab()
161 //================================================================================
163 * \brief Adds an item in a control corresponding to \a type
164 * \param [in] txt - item text
165 * \param [in] type - HypType
166 * \param [in] index - index of item in a list of items
167 * \param [in] isGroup - is the item a group title
169 //================================================================================
170 void SMESHGUI_MeshTab::addItem( const QString& txt,
175 const char* prefix = " ";
176 if ( type <= AddHyp )
180 int idx = myHypCombo[ type ]->count();
181 myHypCombo[ type ]->addItem( txt.mid( 6 ), QVariant( index ));
182 myHypCombo[ type ]->setItemData( idx, "separator", Qt::AccessibleDescriptionRole );
186 myHypCombo[ type ]->addItem( prefix + txt, QVariant( index ));
188 //myHypCombo[ type ]->setMaxVisibleItems( qMax( 10, myHypCombo[ type ]->count() ) );
192 QListWidgetItem* item = new QListWidgetItem( prefix + txt, myAddHypList );
193 item->setData( Qt::UserRole, QVariant( index ));
197 //================================================================================
199 * \brief Returns index of hyp of a given type
201 //================================================================================
202 int SMESHGUI_MeshTab::getCurrentIndex( const int type, const bool curByType ) const
204 if ( type <= AddHyp )
206 return myHypCombo[ type ]->itemData( myHypCombo[ type ]->currentIndex() ).toInt();
210 int row = curByType ? ( type - AddHyp - 1 ) : myAddHypList->currentRow();
211 if ( QListWidgetItem* item = myAddHypList->item( row ))
212 return item->data( Qt::UserRole ).toInt();
217 //================================================================================
219 * \brief Sets available hypothesis or algorithms
220 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
221 * \param theHyps - list of available hypothesis names
223 * Sets available main or additional hypothesis for this tab
225 //================================================================================
226 void SMESHGUI_MeshTab::setAvailableHyps( const int theId, const QStringList& theHyps )
228 myAvailableHypTypes[ theId ] = theHyps;
230 bool enable = ! theHyps.isEmpty();
231 if ( theId == Algo ) // fill list of algos
233 myHypCombo[ Algo ]->clear();
236 addItem( tr( "NONE"), Algo, 0 );
237 for ( int i = 0, nbHyp = theHyps.count(); i < nbHyp; ++i )
238 addItem( theHyps[i], Algo, i+1, theHyps[i].startsWith( "GROUP:" ));
239 myHypCombo[ Algo ]->setCurrentIndex( 0 );
242 else // enable buttons
244 myCreateHypBtn[ theId ]->setEnabled( enable );
245 myEditHypBtn [ theId ]->setEnabled( false );
247 myHypCombo[ theId ]->setEnabled( enable );
250 //================================================================================
252 * \brief Sets existing hypothesis
253 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
254 * \param theHyps - list of available hypothesis names
255 * \param theDefaultAvlbl - \c true means that the algorithm can work w/o hypothesis
256 * with some default parameters
258 * Sets existing main or additional hypothesis for this tab
260 //================================================================================
261 void SMESHGUI_MeshTab::setExistingHyps( const int theId,
262 const QStringList& theHyps,
263 bool theDefaultAvlbl)
267 bool enable = ! myAvailableHypTypes[ theId ].isEmpty();
268 myHypCombo[ theId ]->clear();
271 QString none = tr( theDefaultAvlbl ? "DEFAULT" : ( theId == AddHyp ) ? "NONE" : "NONE" );
272 addItem( none, theId, 0 );
273 for ( int i = 0, nbHyp = theHyps.count(); i < nbHyp; ++i )
274 addItem( theHyps[i], theId, i+1 );
275 myHypCombo[ theId ]->setCurrentIndex( 0 );
277 myHypCombo [ theId ]->setEnabled( enable );
278 myEditHypBtn[ theId ]->setEnabled( false );
279 if ( theId == AddHyp )
281 myAddHypList->clear();
282 myEditHypBtn[ MoreAddHyp ]->setEnabled( false );
283 myMoreAddHypBtn->setEnabled( false );
284 myLessAddHypBtn->setEnabled( false );
289 //================================================================================
291 * \brief Adds hypothesis in combo box of available ones
292 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
293 * \param theHyp - name of hypothesis to be added
295 * Adds hypothesis in combo box of available ones. This method is called by operation
296 * after creation of new hypothesis.
298 //================================================================================
299 void SMESHGUI_MeshTab::addHyp( const int theId, const QString& theHyp )
301 int index = myHypCombo[ theId ]->count();
302 if ( theId == AddHyp )
303 index += myAddHypList->count();
304 addItem( theHyp, theId, index );
305 myHypCombo[ theId ]->setCurrentIndex( myHypCombo[ theId ]->count() - 1 );
306 myEditHypBtn[ theId ]->setEnabled( true );
307 myHypCombo[ theId ]->setEnabled( true );
308 if ( theId == AddHyp )
309 myMoreAddHypBtn->setEnabled( true );
312 //================================================================================
314 * \brief Sets current hypothesis
315 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
316 * \param theIndex - index of hypothesis to be set as current
318 * Sets current hypothesis
320 //================================================================================
321 void SMESHGUI_MeshTab::setCurrentHyp( const int theId, const int theIndex )
323 if ( theId <= AddHyp )
325 if ( theIndex >= 0 && theIndex < myHypCombo[ theId ]->count() )
327 myHypCombo[ theId ]->setCurrentIndex( theIndex );
328 if ( myEditHypBtn[ theId ] )
329 myEditHypBtn[ theId ]->setEnabled( theIndex > 0 );
330 if ( theId == AddHyp )
331 myMoreAddHypBtn ->setEnabled( theIndex > 0 );
334 else // more than one additional hyp assigned
338 // move a hyp from myHypCombo[ AddHyp ] to myAddHypList
339 for ( int i = 1, nb = myHypCombo[ AddHyp ]->count(); i < nb; ++i )
341 int curIndex = myHypCombo[ AddHyp ]->itemData( i ).toInt();
342 if ( theIndex == curIndex )
344 addItem( myHypCombo[ AddHyp ]->itemText( i ), theId, theIndex );
345 myHypCombo[ AddHyp ]->removeItem( i );
352 myAddHypList->clear();
357 //================================================================================
359 * \brief Gets current hypothesis
360 * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
361 * \retval int - index of current hypothesis
363 * Gets current hypothesis
364 * Use theId > AddHyp to get more than selected addetional hyps (see nbAddHypTypes()).
366 //================================================================================
367 int SMESHGUI_MeshTab::currentHyp( const int theId ) const
369 return getCurrentIndex( theId, /*curByType=*/true );
372 //================================================================================
374 * \brief Returns nb of selected supplementary additional hypotheses
376 * Access to their indices is via currentHyp( AddHyp + i ) where i is within the
377 * range 0 <= i < this->nbAddHypTypes()
379 //================================================================================
380 int SMESHGUI_MeshTab::nbAddHypTypes() const
382 return myAddHypList->count();
385 //================================================================================
387 * \brief Emits createHyp( const int ) signal
389 * SLOT called when "Create hypothesis" button clicked specifies sender and emits
390 * createHyp( const int ) signal
392 //================================================================================
393 void SMESHGUI_MeshTab::onCreateHyp()
395 bool isMainHyp = ( sender() == myCreateHypBtn[ MainHyp ]);
397 QtxMenu aPopup( this );
399 QStringList aHypNames = isMainHyp ?
400 myAvailableHypTypes[ MainHyp ] : myAvailableHypTypes[ AddHyp ];
402 QList<QAction*> actions;
403 for ( int i = 0, n = aHypNames.count(); i < n; i++ )
406 if ( aHypNames[ i ].startsWith( "GROUP:" ))
408 aPopup.appendGroupTitle( aHypNames[ i ].mid( 6 ));
412 a = aPopup.addAction( aHypNames[ i ] );
416 QAction* a = aPopup.exec( QCursor::pos() );
418 emit createHyp( isMainHyp ? MainHyp : AddHyp, actions.indexOf( a ) );
421 //================================================================================
423 * \brief Emits editHyp( const int ) signal
425 * SLOT called when "Edit hypothesis" button clicked specifies sender and emits
426 * editHyp( const int ) signal
428 //================================================================================
429 void SMESHGUI_MeshTab::onEditHyp()
431 const QObject* aSender = sender();
432 int aHypType = MainHyp;
433 for ( ; aHypType <= MoreAddHyp; ++aHypType )
434 if ( aSender == myEditHypBtn[ aHypType ])
436 emit editHyp( Min( aHypType, AddHyp ),
437 getCurrentIndex( aHypType ) - 1 ); // - 1 because there is NONE on the top
440 //================================================================================
442 * \brief Updates "Edit hypothesis" button state
444 * SLOT called when current hypothesis changed. Disables "Edit hypothesis" button
445 * if current hypothesis is <None>, enables otherwise.
446 * If an algorithm changed, emits selectAlgo( theIndex ) signal
448 //================================================================================
449 void SMESHGUI_MeshTab::onHyp( int theIndex )
451 QObject* aSender = sender();
453 if ( QComboBox* cb = qobject_cast< QComboBox* >( aSender ))
455 // don't allow selecting a group title
456 if ( cb->itemData( theIndex, Qt::AccessibleDescriptionRole ) == "separator" )
458 cb->setCurrentIndex( theIndex+1 );
463 if ( aSender == myHypCombo[ Algo ] )
465 emit selectAlgo( theIndex - 1 ); // - 1 because there is NONE on the top
467 else if ( aSender == myAddHypList )
469 myEditHypBtn[ MoreAddHyp ]->setEnabled( theIndex >= 0 );
470 myLessAddHypBtn ->setEnabled( theIndex >= 0 );
474 int type = ( aSender == myHypCombo[ MainHyp ] ? MainHyp : AddHyp );
475 myEditHypBtn[ type ]->setEnabled( theIndex > 0 );
477 if ( type == AddHyp )
478 myMoreAddHypBtn ->setEnabled( theIndex > 0 );
482 //================================================================================
484 * \brief Adds a current additional hyp to myAddHypList
486 * SLOT called when myMoreAddHypBtn ("plus") clicked
488 //================================================================================
489 void SMESHGUI_MeshTab::onMoreAddHyp()
491 int hypIndex = currentHyp( AddHyp );
494 // move a hyp from myHypCombo[ AddHyp ] to myAddHypList
495 int comboIndex = myHypCombo[ AddHyp ]->currentIndex();
496 addItem( myHypCombo[ AddHyp ]->itemText( comboIndex ), MoreAddHyp, hypIndex );
498 myHypCombo[ AddHyp ]->removeItem( comboIndex );
499 myHypCombo[ AddHyp ]->setCurrentIndex( 0 );
501 myMoreAddHypBtn->setEnabled( false );
502 myEditHypBtn[ AddHyp ]->setEnabled( false );
506 //================================================================================
508 * \brief Removes a current additional hyp from myAddHypList
510 * SLOT called when myLessAddHypBtn ("minus") clicked
512 //================================================================================
513 void SMESHGUI_MeshTab::onLessAddHyp()
515 if ( QListWidgetItem * item = myAddHypList->currentItem() )
517 // move a hyp from myAddHypList to myHypCombo[ AddHyp ]
518 int hypIndex = item->data( Qt::UserRole ).toInt();
519 addItem( item->text(), AddHyp, hypIndex );
520 delete item;//myAddHypList->takeItem( myAddHypList->currentRow() );
524 //================================================================================
526 * \brief Resets all tab fields
528 * Resets all tab fields
530 //================================================================================
531 void SMESHGUI_MeshTab::reset()
533 for ( int i = Algo; i <= AddHyp; i++ )
535 myHypCombo[ i ]->setCurrentIndex( 0 );
536 if ( myEditHypBtn[ i ] )
537 myEditHypBtn[ i ]->setEnabled( false );
542 * \brief Dialog for mech creation or editing
544 * This dialog is used for mech creation or editing.
547 //================================================================================
550 * \param theToCreate - if this parameter is true then dialog is used for creation,
551 * for editing otherwise
552 * \param theIsMesh - if this parameter is true then dialog is used for mesh,
553 * for sub-mesh otherwise
555 * Makes dialog's look and feel
557 //================================================================================
558 SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh )
559 : SMESHGUI_Dialog( 0, false, true )
561 // Create top controls
563 setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
565 createObject( tr( "NAME" ), mainFrame(), Obj );
566 setNameIndication( Obj, OneName );
567 setReadOnly( Obj, false );
569 createObject( tr( "MESH" ), mainFrame(), Mesh );
571 createObject( tr( "GEOMETRY" ), mainFrame(), Geom );
574 QLabel* anMeshTypeLbl = new QLabel( tr( "MESH_TYPE" ), this );
575 myMeshType = new QComboBox( this );
579 myTabWg = new QTabWidget( mainFrame() );
580 myTabs[ Dim0D ] = new SMESHGUI_MeshTab( myTabWg );
581 myTabs[ Dim1D ] = new SMESHGUI_MeshTab( myTabWg );
582 myTabs[ Dim2D ] = new SMESHGUI_MeshTab( myTabWg );
583 myTabs[ Dim3D ] = new SMESHGUI_MeshTab( myTabWg );
584 myTabWg->addTab( myTabs[ Dim3D ], tr( "DIM_3D" ) );
585 myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) );
586 myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) );
587 myTabWg->addTab( myTabs[ Dim0D ], tr( "DIM_0D" ) );
590 myHypoSetButton = new QToolButton( mainFrame() );
591 myHypoSetButton->setText( tr( "HYPOTHESES_SETS" ) );
592 myHypoSetButton->setEnabled( false );
593 myHypoSetButton->setSizePolicy( QSizePolicy::MinimumExpanding,
594 myHypoSetButton->sizePolicy().verticalPolicy() );
597 QGridLayout* aLay = new QGridLayout( mainFrame() );
598 aLay->setMargin( 0 );
599 aLay->setSpacing( SPACING );
601 aLay->addWidget( objectWg( Obj, Label ), 0, 0 );
602 aLay->addWidget( objectWg( Obj, Btn ), 0, 1 );
603 aLay->addWidget( objectWg( Obj, Control ), 0, 2 );
604 aLay->addWidget( objectWg( Mesh, Label ), 1, 0 );
605 aLay->addWidget( objectWg( Mesh, Btn ), 1, 1 );
606 aLay->addWidget( objectWg( Mesh, Control ), 1, 2 );
607 aLay->addWidget( objectWg( Geom, Label ), 2, 0 );
608 aLay->addWidget( objectWg( Geom, Btn ), 2, 1 );
609 aLay->addWidget( objectWg( Geom, Control ), 2, 2 );
610 aLay->addWidget( anMeshTypeLbl, 3, 0 );
611 aLay->addWidget( myMeshType, 3, 2 );
612 aLay->addWidget( myTabWg, 5, 0, 1, 3 );
613 aLay->addWidget( myHypoSetButton, 6, 0, 1, 3 );
614 aLay->setRowMinimumHeight( 3, 20 );
618 // Connect signals and slots
619 connect( myMeshType, SIGNAL( activated( int ) ), SLOT( onChangedMeshType( int ) ) );
620 // Disable controls if necessary
621 setObjectShown( Mesh, false );
624 setWindowTitle( tr( "CREATE_MESH" ) );
625 objectWg( Obj, Btn )->hide();
627 setWindowTitle( tr( "CREATE_MESH" ) );
630 setWindowTitle( tr( "CREATE_SUBMESH" ) );
631 setObjectShown( Mesh, true );
636 setWindowTitle( tr( "EDIT_MESH_SUBMESH" ) );
637 objectWg( Mesh, Btn )->hide();
638 objectWg( Geom, Btn )->hide();
640 setTitile( theToCreate, theIsMesh );
643 SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg()
647 //================================================================================
649 * \brief Set dialog title
651 //================================================================================
652 void SMESHGUI_MeshDlg::setTitile( const bool theToCreate, const bool theIsMesh )
656 setWindowTitle( tr( theIsMesh ? "CREATE_MESH" : "CREATE_SUBMESH" ));
660 setWindowTitle( tr( theIsMesh ? "EDIT_MESH" : "EDIT_SUBMESH") );
665 //================================================================================
667 * \brief Gets tab with given id
668 * \param theId - Tab identifier. Possible values are in "Dimensions" enumeration
669 * \retval SMESHGUI_MeshTab* - pointer to the tab or null if given parameter is
672 * Gets tab containing controls for definition of algorithms and AddHypotheses
674 //================================================================================
675 SMESHGUI_MeshTab* SMESHGUI_MeshDlg::tab( const int theId ) const
677 return ( theId >= Dim0D && theId <= Dim3D ? myTabs[ theId ] : 0 );
680 //================================================================================
682 * \brief Resets all dialog fields
684 //================================================================================
685 void SMESHGUI_MeshDlg::reset()
688 myTabs[ Dim0D ]->reset();
689 myTabs[ Dim1D ]->reset();
690 myTabs[ Dim2D ]->reset();
691 myTabs[ Dim3D ]->reset();
694 //================================================================================
696 * \brief Sets curent tab
698 //================================================================================
699 void SMESHGUI_MeshDlg::setCurrentTab( const int theId )
701 myTabWg->setCurrentIndex( Dim3D - theId );
704 //================================================================================
706 * \brief Enable/disable tabs
707 * \param int - maximum possible dimention
709 //================================================================================
710 void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
712 const int DIM = maxDim;
713 for ( int dim = Dim0D; dim <= Dim3D; ++dim ) {
714 bool enable = ( dim <= DIM );
716 myTabs[ dim ]->reset();
723 // deselect desabled tab
724 if ( !myTabWg->isTabEnabled( myTabWg->currentIndex() ) )
725 setCurrentTab( DIM );
728 //================================================================================
730 * \brief Sets list of available Sets of Hypotheses
732 //================================================================================
733 void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
735 QMenu* aHypoSetPopup = myHypoSetButton->menu();
736 if ( !aHypoSetPopup ) {
737 aHypoSetPopup = new QMenu( myHypoSetButton );
738 connect( aHypoSetPopup, SIGNAL( triggered( QAction* ) ), SLOT( onHypoSetPopup( QAction* ) ) );
739 myHypoSetButton->setMenu( aHypoSetPopup );
740 myHypoSetButton->setPopupMode( QToolButton::InstantPopup );
742 aHypoSetPopup->clear();
743 for ( int i = 0, n = theSets.count(); i < n; i++ ) {
744 aHypoSetPopup->addAction( theSets[ i ] );
746 myHypoSetButton->setEnabled( !aHypoSetPopup->isEmpty() );
749 //================================================================================
751 * \brief Emits hypoSet signal
753 * SLOT is called when a hypotheses set is selected. Emits hypoSet
754 * signal to notify operation about this event
756 //================================================================================
757 void SMESHGUI_MeshDlg::onHypoSetPopup( QAction* a )
759 emit hypoSet( a->text() );
762 //================================================================================
764 * \brief Enable showing of the popup when Geometry selection btn is clicked
765 * \param enable - true to enable
767 //================================================================================
769 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
771 void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
773 if ( QToolButton* selBtn = qobject_cast<QToolButton*>( objectWg( Geom, Btn )))
776 if ( ! myGeomPopup ) {
777 myGeomPopup = new QMenu();
778 myGeomPopup->addAction( tr("DIRECT_GEOM_SELECTION") )->setData( DIRECT_GEOM_INDEX );
779 myGeomPopup->addAction( tr("GEOM_BY_MESH_ELEM_SELECTION") )->setData( GEOM_BY_MESH_INDEX );
780 connect( myGeomPopup, SIGNAL( triggered( QAction* ) ), SLOT( onGeomPopup( QAction* ) ) );
781 connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
785 disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
795 //================================================================================
798 * \param int - tab ID
800 //================================================================================
801 void SMESHGUI_MeshDlg::disableTab(const int theTabId)
803 myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false );
806 //================================================================================
809 * \param int - tab ID
811 //================================================================================
812 void SMESHGUI_MeshDlg::enableTab(const int theTabId)
814 myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true );
815 if ( theTabId == Dim3D ) {
816 QMenu* aHypoSetPopup = myHypoSetButton->menu();
817 myHypoSetButton->setEnabled( aHypoSetPopup && !aHypoSetPopup->actions().isEmpty() );
821 //================================================================================
823 * \brief Check if tab enabled
824 * \param int - tab ID
826 //================================================================================
827 bool SMESHGUI_MeshDlg::isTabEnabled(const int theTabId) const
829 return myTabWg->isTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ) );
832 //================================================================================
834 * \brief SLOT called when a Geom selection button is clicked
836 //================================================================================
837 void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
839 if ( myGeomPopup && isBtnOn )
840 myGeomPopup->exec( QCursor::pos() );
843 //================================================================================
845 * \brief SLOT called when a item of Geom selection popup is choosen
847 //================================================================================
848 void SMESHGUI_MeshDlg::onGeomPopup( QAction* a )
850 emit geomSelectionByMesh( a->data().toInt() == GEOM_BY_MESH_INDEX );
853 //================================================================================
855 * \brief Return ID of an active selection button
857 //================================================================================
858 int SMESHGUI_MeshDlg::getActiveObject()
860 for (int i = 0; i < 3; ++i )
861 if ( isObjectShown( i ) &&
862 (( QToolButton* )objectWg( i, Btn ))->isChecked())
866 //================================================================================
868 * \brief Sets available types of mesh
869 * \param theTypeMesh - list of available types of mesh
871 //================================================================================
872 void SMESHGUI_MeshDlg::setAvailableMeshType( const QStringList& theTypeMesh )
875 myMeshType->addItems(theTypeMesh);
877 //================================================================================
879 * \brief Emits selectMeshType( const int, const int ) signal
881 * SLOT is called when a combo box "mesh type" is selected.
883 //================================================================================
884 void SMESHGUI_MeshDlg::onChangedMeshType( const int isIndex )
886 emit selectMeshType( Dim3D - myTabWg->currentIndex(), isIndex );
888 //================================================================================
890 * \brief Get current index types of mesh
892 //================================================================================
893 int SMESHGUI_MeshDlg::currentMeshType( )
895 return myMeshType->currentIndex( );
897 //================================================================================
899 * \brief Set current index types of mesh
901 //================================================================================
902 void SMESHGUI_MeshDlg::setCurrentMeshType( const int theIndex )
904 myMeshType->setCurrentIndex( theIndex );