X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MeshDlg.cxx;h=94d9ce681cceee02ec7c919312b68995647f6de7;hp=e05e2022df3ef9fe44b8edaed9bc4761a9aa68d0;hb=f7aba4830d53719b963fdb7fccc98b760fdef2d1;hpb=57b43b4d010e2d0a1529d3c131bbb9d416e63258 diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx index e05e2022d..94d9ce681 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx @@ -1,50 +1,50 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -/** -* SMESH SMESHGUI -* -* Copyright (C) 2005 CEA/DEN, EDF R&D -* -* -* -* File : SMESHGUI_MeshDlg.cxx -* Author : Sergey LITONIN -* Module : SMESH -*/ +// SMESH SMESHGUI : GUI for SMESH component +// File : SMESHGUI_MeshDlg.cxx +// Author : Sergey LITONIN, Open CASCADE S.A.S. +// SMESH includes +// #include "SMESHGUI_MeshDlg.h" +// SALOME GUI includes #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 6 +#define MARGIN 11 /*! * \brief Tab for tab widget containing controls for definition of @@ -60,12 +60,11 @@ */ //================================================================================ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent ) -: QFrame( theParent ), - myPopup( 0 ) + : QFrame( theParent ) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - QIconSet aCreateIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO" ) ) ); - QIconSet aEditIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO_EDIT" ) ) ); + QIcon aCreateIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO" ) ) ); + QIcon aEditIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO_EDIT" ) ) ); // Algorifm QLabel* anAlgoLbl = new QLabel( tr( "ALGORITHM" ), this ); @@ -76,9 +75,9 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent ) myHyp[ MainHyp ] = new QComboBox( this ); myHyp[ MainHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); myCreateHyp[ MainHyp ] = new QToolButton( this ); - myCreateHyp[ MainHyp ]->setIconSet( aCreateIcon ); + myCreateHyp[ MainHyp ]->setIcon( aCreateIcon ); myEditHyp[ MainHyp ] = new QToolButton( this ); - myEditHyp[ MainHyp ]->setIconSet( aEditIcon ); + myEditHyp[ MainHyp ]->setIcon( aEditIcon ); // Line QFrame* aLine = new QFrame( this ); @@ -89,19 +88,22 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent ) myHyp[ AddHyp ] = new QComboBox( this ); myHyp[ AddHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); myCreateHyp[ AddHyp ] = new QToolButton( this ); - myCreateHyp[ AddHyp ]->setIconSet( aCreateIcon ); + myCreateHyp[ AddHyp ]->setIcon( aCreateIcon ); myEditHyp[ AddHyp ] = new QToolButton( this ); - myEditHyp[ AddHyp ]->setIconSet( aEditIcon ); + myEditHyp[ AddHyp ]->setIcon( aEditIcon ); // Fill layout - QGridLayout* aLay = new QGridLayout( this, 5, 4, 5, 5 ); + QGridLayout* aLay = new QGridLayout( this ); + aLay->setMargin( MARGIN ); + aLay->setSpacing( SPACING ); + aLay->addWidget( anAlgoLbl, 0, 0 ); aLay->addWidget( myHyp[ Algo ], 0, 1 ); aLay->addWidget( aHypLbl, 1, 0 ); aLay->addWidget( myHyp[ MainHyp ], 1, 1 ); aLay->addWidget( myCreateHyp[ MainHyp ], 1, 2 ); aLay->addWidget( myEditHyp[ MainHyp ], 1, 3 ); - aLay->addMultiCellWidget( aLine, 2, 2, 0, 3 ); + aLay->addWidget( aLine, 2, 0, 1, 4 ); aLay->addWidget( anAddHypLbl, 3, 0 ); aLay->addWidget( myHyp[ AddHyp ], 3, 1 ); aLay->addWidget( myCreateHyp[ AddHyp ], 3, 2 ); @@ -111,9 +113,9 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent ) // Connect signals and slots for ( int i = MainHyp; i <= AddHyp; i++ ) { - connect( myCreateHyp[ i ], SIGNAL( clicked() ), SLOT( onCreateHyp() ) ); - connect( myEditHyp[ i ], SIGNAL( clicked() ), SLOT( onEditHyp() ) ); - connect( myHyp[ i ], SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) ); + connect( myCreateHyp[ i ], SIGNAL( clicked() ) , SLOT( onCreateHyp() ) ); + connect( myEditHyp[ i ] , SIGNAL( clicked() ) , SLOT( onEditHyp() ) ); + connect( myHyp[ i ] , SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) ); } connect( myHyp[ Algo ], SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) ); @@ -124,10 +126,13 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent ) setAvailableHyps( AddHyp, QStringList() ); } +//================================================================================ +/*! + * \brief Destructor + */ +//================================================================================ SMESHGUI_MeshTab::~SMESHGUI_MeshTab() { - if ( myPopup ) - delete myPopup; } //================================================================================ @@ -147,9 +152,9 @@ void SMESHGUI_MeshTab::setAvailableHyps( const int theId, const QStringList& the if ( theId == Algo ) { myHyp[ Algo ]->clear(); - myHyp[ Algo ]->insertItem( tr( "NONE" ) ); - myHyp[ Algo ]->insertStringList( theHyps ); - myHyp[ Algo ]->setCurrentItem( 0 ); + myHyp[ Algo ]->addItem( tr( "NONE" ) ); + myHyp[ Algo ]->addItems( theHyps ); + myHyp[ Algo ]->setCurrentIndex( 0 ); } else { myCreateHyp[ theId ]->setEnabled( enable ); @@ -172,9 +177,9 @@ void SMESHGUI_MeshTab::setExistingHyps( const int theId, const QStringList& theH if ( theId != Algo ) { myHyp[ theId ]->clear(); - myHyp[ theId ]->insertItem( tr( "NONE" ) ); - myHyp[ theId ]->insertStringList( theHyps ); - myHyp[ theId ]->setCurrentItem( 0 ); + myHyp[ theId ]->addItem( tr( "NONE" ) ); + myHyp[ theId ]->addItems( theHyps ); + myHyp[ theId ]->setCurrentIndex( 0 ); myHyp[ theId ]->setEnabled( !theHyps.isEmpty() ); myEditHyp[ theId ]->setEnabled( false ); } @@ -192,8 +197,8 @@ void SMESHGUI_MeshTab::setExistingHyps( const int theId, const QStringList& theH //================================================================================ void SMESHGUI_MeshTab::addHyp( const int theId, const QString& theHyp ) { - myHyp[ theId ]->insertItem( theHyp ); - myHyp[ theId ]->setCurrentItem( myHyp[ theId ]->count() - 1 ); + myHyp[ theId ]->addItem( theHyp ); + myHyp[ theId ]->setCurrentIndex( myHyp[ theId ]->count() - 1 ); myEditHyp[ theId ]->setEnabled( true ); myHyp[ theId ]->setEnabled( true ); } @@ -213,7 +218,7 @@ void SMESHGUI_MeshTab::renameHyp( const int theId, const QString& theNewName ) { if ( theIndex > 0 && theIndex < myHyp[ theId ]->count() ) - myHyp[ theId ]->changeItem( theNewName, theIndex ); + myHyp[ theId ]->setItemText( theIndex, theNewName ); } //================================================================================ @@ -229,7 +234,7 @@ void SMESHGUI_MeshTab::setCurrentHyp( const int theId, const int theIndex ) { if ( theIndex >= 0 && theIndex < myHyp[ theId ]->count() ) { - myHyp[ theId ]->setCurrentItem( theIndex ); + myHyp[ theId ]->setCurrentIndex( theIndex ); if ( myEditHyp[ theId ] ) myEditHyp[ theId ]->setEnabled( theIndex > 0 ); } @@ -246,7 +251,7 @@ void SMESHGUI_MeshTab::setCurrentHyp( const int theId, const int theIndex ) //================================================================================ int SMESHGUI_MeshTab::currentHyp( const int theId ) const { - return myHyp[ theId ]->currentItem(); + return myHyp[ theId ]->currentIndex(); } //================================================================================ @@ -259,31 +264,20 @@ int SMESHGUI_MeshTab::currentHyp( const int theId ) const //================================================================================ void SMESHGUI_MeshTab::onCreateHyp() { - const QObject* aSender = sender(); - - if ( !myPopup ) - { - myPopup = new QPopupMenu( 0 ); - connect( myPopup, SIGNAL( activated( int ) ), SLOT( onPopupItem( int ) ) ); - } + bool isMainHyp = sender() == myCreateHyp[ MainHyp ]; + + QMenu aPopup( this ); - QStringList aHypNames; - if ( aSender == myCreateHyp[ MainHyp ] ) - { - aHypNames = myAvailableHyps[ MainHyp ]; - myPopup->setName( "MainHypPopup" ); - } - else - { - aHypNames = myAvailableHyps[ AddHyp ]; - myPopup->setName( "AddHypPopup" ); - } - - myPopup->clear(); + QStringList aHypNames = isMainHyp ? + myAvailableHyps[ MainHyp ] : myAvailableHyps[ AddHyp ]; + + QList actions; for ( int i = 0, n = aHypNames.count(); i < n; i++ ) - myPopup->insertItem( aHypNames[ i ], i ); + actions.append( aPopup.addAction( aHypNames[ i ] ) ); - myPopup->exec( QCursor::pos() ); + QAction* a = aPopup.exec( QCursor::pos() ); + if ( a ) + emit createHyp( isMainHyp ? MainHyp : AddHyp, actions.indexOf( a ) ); } //================================================================================ @@ -298,7 +292,7 @@ void SMESHGUI_MeshTab::onEditHyp() { const QObject* aSender = sender(); int aHypType = aSender == myEditHyp[ MainHyp ] ? MainHyp : AddHyp; - emit editHyp( aHypType, myHyp[ aHypType ]->currentItem() - 1 ); // - 1 because there is NONE on the top + emit editHyp( aHypType, myHyp[ aHypType ]->currentIndex() - 1 ); // - 1 because there is NONE on the top } //================================================================================ @@ -321,21 +315,6 @@ void SMESHGUI_MeshTab::onHyp( int theIndex ) } } -//================================================================================ -/*! - * \brief Emits createHyp signal - * - * SLOT called when item of popup for hypothesis creation is activated. Emits - * createHyp signal to notify operation obout this event - */ -//================================================================================ -void SMESHGUI_MeshTab::onPopupItem( int theId ) -{ - const QObject* aSender = sender(); - if ( aSender ) - emit createHyp( strcmp( aSender->name(), "MainHypPopup" ) == 0 ? MainHyp : AddHyp, theId ); -} - //================================================================================ /*! * \brief Resets all tab fields @@ -347,7 +326,7 @@ void SMESHGUI_MeshTab::reset() { for ( int i = Algo; i <= AddHyp; i++ ) { - myHyp[ i ]->setCurrentItem( 0 ); + myHyp[ i ]->setCurrentIndex( 0 ); if ( myEditHyp[ i ] ) myEditHyp[ i ]->setEnabled( false ); } @@ -374,72 +353,88 @@ SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh : SMESHGUI_Dialog( 0, false, true ) { // Create top controls - - QGroupBox* aGrp = new QGroupBox( 3, Qt::Horizontal, mainFrame() ); - aGrp->setFrameStyle( QFrame::NoFrame ); - aGrp->setInsideMargin( 0 ); + + setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) ); // name - createObject( tr( "NAME" ), aGrp, Obj ); + createObject( tr( "NAME" ), mainFrame(), Obj ); setNameIndication( Obj, OneName ); setReadOnly( Obj, false ); // mesh - createObject( tr( "MESH" ), aGrp, Mesh ); + createObject( tr( "MESH" ), mainFrame(), Mesh ); // geometry - createObject( tr( "GEOMETRY" ), aGrp, Geom ); + createObject( tr( "GEOMETRY" ), mainFrame(), Geom ); myGeomPopup = 0; + // mesh type + QLabel* anMeshTypeLbl = new QLabel( tr( "MESH_TYPE" ), this ); + myMeshType = new QComboBox( this ); // Create tab widget myTabWg = new QTabWidget( mainFrame() ); + myTabs[ Dim0D ] = new SMESHGUI_MeshTab( myTabWg ); myTabs[ Dim1D ] = new SMESHGUI_MeshTab( myTabWg ); myTabs[ Dim2D ] = new SMESHGUI_MeshTab( myTabWg ); myTabs[ Dim3D ] = new SMESHGUI_MeshTab( myTabWg ); myTabWg->addTab( myTabs[ Dim3D ], tr( "DIM_3D" ) ); myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) ); myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) ); + myTabWg->addTab( myTabs[ Dim0D ], tr( "DIM_0D" ) ); // Hypotheses Sets - myHypoSetPopup = new QPopupMenu(); - QButton* aHypoSetButton = new QPushButton( mainFrame(), "aHypoSetButton"); - aHypoSetButton->setText( tr( "HYPOTHESES_SETS" ) ); + myHypoSetButton = new QToolButton( mainFrame() ); + myHypoSetButton->setText( tr( "HYPOTHESES_SETS" ) ); + myHypoSetButton->setEnabled( false ); + myHypoSetButton->setSizePolicy( QSizePolicy::MinimumExpanding, + myHypoSetButton->sizePolicy().verticalPolicy() ); // Fill layout - QVBoxLayout* aLay = new QVBoxLayout( mainFrame(), 0, 5 ); - aLay->addWidget( aGrp ); - aLay->addItem( new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum) ); - aLay->addWidget( myTabWg ); - aLay->addWidget( aHypoSetButton ); + QGridLayout* aLay = new QGridLayout( mainFrame() ); + aLay->setMargin( 0 ); + aLay->setSpacing( SPACING ); + + aLay->addWidget( objectWg( Obj, Label ), 0, 0 ); + aLay->addWidget( objectWg( Obj, Btn ), 0, 1 ); + aLay->addWidget( objectWg( Obj, Control ), 0, 2 ); + aLay->addWidget( objectWg( Mesh, Label ), 1, 0 ); + aLay->addWidget( objectWg( Mesh, Btn ), 1, 1 ); + aLay->addWidget( objectWg( Mesh, Control ), 1, 2 ); + aLay->addWidget( objectWg( Geom, Label ), 2, 0 ); + aLay->addWidget( objectWg( Geom, Btn ), 2, 1 ); + aLay->addWidget( objectWg( Geom, Control ), 2, 2 ); + aLay->addWidget( anMeshTypeLbl, 3, 0 ); + aLay->addWidget( myMeshType, 3, 2 ); + aLay->addWidget( myTabWg, 5, 0, 1, 3 ); + aLay->addWidget( myHypoSetButton, 6, 0, 1, 3 ); + aLay->setRowMinimumHeight( 3, 20 ); + + myMeshType->clear(); + // Connect signals and slots + connect( myMeshType, SIGNAL( activated( int ) ), SLOT( onChangedMeshType( int ) ) ); // Disable controls if necessary setObjectShown( Mesh, false ); if ( theToCreate ) { - setCaption( tr( "CREATE_MESH" ) ); + setWindowTitle( tr( "CREATE_MESH" ) ); objectWg( Obj, Btn )->hide(); if ( theIsMesh ) - setCaption( tr( "CREATE_MESH" ) ); + setWindowTitle( tr( "CREATE_MESH" ) ); else { - setCaption( tr( "CREATE_SUBMESH" ) ); + setWindowTitle( tr( "CREATE_SUBMESH" ) ); setObjectShown( Mesh, true ); } } else { - setCaption( tr( "EDIT_MESH_SUBMESH" ) ); + setWindowTitle( tr( "EDIT_MESH_SUBMESH" ) ); objectWg( Mesh, Btn )->hide(); objectWg( Geom, Btn )->hide(); } - - // Connect signals and slots - connect( aHypoSetButton, SIGNAL( clicked() ), SLOT( onHypoSetButton() ) ); - connect( myHypoSetPopup, SIGNAL( activated( int ) ), SLOT( onHypoSetPopup( int ) ) ); } SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg() { - if ( myHypoSetPopup ) - delete myHypoSetPopup; } //================================================================================ @@ -454,7 +449,7 @@ SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg() //================================================================================ SMESHGUI_MeshTab* SMESHGUI_MeshDlg::tab( const int theId ) const { - return ( theId >= Dim1D && theId <= Dim3D ? myTabs[ theId ] : 0 ); + return ( theId >= Dim0D && theId <= Dim3D ? myTabs[ theId ] : 0 ); } //================================================================================ @@ -465,6 +460,7 @@ SMESHGUI_MeshTab* SMESHGUI_MeshDlg::tab( const int theId ) const void SMESHGUI_MeshDlg::reset() { clearSelection(); + myTabs[ Dim0D ]->reset(); myTabs[ Dim1D ]->reset(); myTabs[ Dim2D ]->reset(); myTabs[ Dim3D ]->reset(); @@ -477,7 +473,7 @@ void SMESHGUI_MeshDlg::reset() //================================================================================ void SMESHGUI_MeshDlg::setCurrentTab( const int theId ) { - myTabWg->setCurrentPage( Dim3D - theId ); + myTabWg->setCurrentIndex( Dim3D - theId ); } //================================================================================ @@ -489,16 +485,20 @@ void SMESHGUI_MeshDlg::setCurrentTab( const int theId ) void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim ) { - const int DIM = maxDim - 1; - for ( int dim = Dim1D; dim <= Dim3D; ++dim ) { + const int DIM = maxDim; + for ( int dim = Dim0D; dim <= Dim3D; ++dim ) { bool enable = ( dim <= DIM ); - if ( !enable ) + if ( !enable ) { myTabs[ dim ]->reset(); - myTabWg->setTabEnabled( myTabs[ dim ], enable ); + disableTab( dim ); + } + else { + enableTab( dim ); + } } // deselect desabled tab - if ( !myTabWg->isTabEnabled( myTabWg->currentPage() )) - setCurrentTab( DIM - 1 ); + if ( !myTabWg->isTabEnabled( myTabWg->currentIndex() ) ) + setCurrentTab( DIM ); } //================================================================================ @@ -509,10 +509,18 @@ void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim ) void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets ) { - myHypoSetPopup->clear(); + QMenu* aHypoSetPopup = myHypoSetButton->menu(); + if ( !aHypoSetPopup ) { + aHypoSetPopup = new QMenu( myHypoSetButton ); + connect( aHypoSetPopup, SIGNAL( triggered( QAction* ) ), SLOT( onHypoSetPopup( QAction* ) ) ); + myHypoSetButton->setMenu( aHypoSetPopup ); + myHypoSetButton->setPopupMode( QToolButton::InstantPopup ); + } + aHypoSetPopup->clear(); for ( int i = 0, n = theSets.count(); i < n; i++ ) { - myHypoSetPopup->insertItem( theSets[ i ], i ); + aHypoSetPopup->addAction( theSets[ i ] ); } + myHypoSetButton->setEnabled( !aHypoSetPopup->isEmpty() ); } //================================================================================ @@ -524,22 +532,11 @@ void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets ) */ //================================================================================ -void SMESHGUI_MeshDlg::onHypoSetPopup( int theIndex ) +void SMESHGUI_MeshDlg::onHypoSetPopup( QAction* a ) { - emit hypoSet( myHypoSetPopup->text( theIndex )); + emit hypoSet( a->text() ); } -//================================================================================ -/*! - * \brief Shows myHypoSetPopup - */ -//================================================================================ - -void SMESHGUI_MeshDlg::onHypoSetButton() -{ - myHypoSetPopup->exec( QCursor::pos() ); -} - //================================================================================ /*! * \brief Enable showing of the popup when Geometry selection btn is clicked @@ -551,28 +548,112 @@ enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX }; void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable ) { - if ( QButton* selBtn = dynamic_cast( objectWg( Geom, Btn ))) + if ( QToolButton* selBtn = qobject_cast( objectWg( Geom, Btn ))) { - disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) )); if ( enable ) { if ( ! myGeomPopup ) { - myGeomPopup = new QPopupMenu(); - myGeomPopup->insertItem( tr("DIRECT_GEOM_SELECTION"), DIRECT_GEOM_INDEX ); - myGeomPopup->insertItem( tr("GEOM_BY_MESH_ELEM_SELECTION"), GEOM_BY_MESH_INDEX ); - connect( myGeomPopup, SIGNAL( activated( int ) ), SLOT( onGeomPopup( int ) ) ); + myGeomPopup = new QMenu(); + myGeomPopup->addAction( tr("DIRECT_GEOM_SELECTION") )->setData( DIRECT_GEOM_INDEX ); + myGeomPopup->addAction( tr("GEOM_BY_MESH_ELEM_SELECTION") )->setData( GEOM_BY_MESH_INDEX ); + connect( myGeomPopup, SIGNAL( triggered( QAction* ) ), SLOT( onGeomPopup( QAction* ) ) ); + connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) )); + } + } + else { + disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) )); + if ( myGeomPopup ) { + delete myGeomPopup; + myGeomPopup = 0; } - connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) )); } } } + +//================================================================================ +/*! + * \brief Disable tab + * \param int - tab ID + */ +//================================================================================ +void SMESHGUI_MeshDlg::disableTab(const int theTabId) { + myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false ); + if ( theTabId == Dim3D ) myHypoSetButton->setEnabled( false ); +} + +//================================================================================ +/*! + * \brief Enable tabs + * \param int - tab ID + */ +//================================================================================ +void SMESHGUI_MeshDlg::enableTab(const int theTabId) { + myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true ); + if ( theTabId == Dim3D ) { + QMenu* aHypoSetPopup = myHypoSetButton->menu(); + myHypoSetButton->setEnabled( aHypoSetPopup && !aHypoSetPopup->actions().isEmpty() ); + } +} + +//================================================================================ +/*! + * \brief Check if tab enabled + * \param int - tab ID + */ +//================================================================================ +bool SMESHGUI_MeshDlg::isTabEnabled(const int theTabId) const { + return myTabWg->isTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ) ); +} + void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn) { if ( myGeomPopup && isBtnOn ) myGeomPopup->exec( QCursor::pos() ); } -void SMESHGUI_MeshDlg::onGeomPopup( int index ) +void SMESHGUI_MeshDlg::onGeomPopup( QAction* a ) +{ + emit geomSelectionByMesh( a->data().toInt() == GEOM_BY_MESH_INDEX ); +} + +int SMESHGUI_MeshDlg::getActiveObject() +{ + for (int i = 0; i < 3; ++i ) + if ( isObjectShown( i ) && + (( QToolButton* )objectWg( i, Btn ))->isChecked()) + return i; + return -1; +} +//================================================================================ +/*! + * \brief Sets available types of mesh + * \param theTypeMesh - list of available types of mesh + */ +//================================================================================ +void SMESHGUI_MeshDlg::setAvailableMeshType( const QStringList& theTypeMesh ) { - emit geomSelectionByMesh( index == GEOM_BY_MESH_INDEX ); + myMeshType->clear(); + myMeshType->addItems(theTypeMesh); } +//================================================================================ +/*! + * \brief Emits selectMeshType( const int, const int ) signal + * + * SLOT is called when a combo box "mesh type" is selected. + */ +//================================================================================ +void SMESHGUI_MeshDlg::onChangedMeshType( const int isIndex ) +{ + emit selectMeshType( Dim3D - myTabWg->currentIndex(), isIndex ); +} +//================================================================================ +/*! + * \brief Get current index types of mesh + */ +//================================================================================ +int SMESHGUI_MeshDlg::currentMeshType( ) +{ + return myMeshType->currentIndex( ); +} + +