X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MeshDlg.cxx;h=e05e2022df3ef9fe44b8edaed9bc4761a9aa68d0;hp=a9dbbcaa1e54b24814f24c38716fc10337d51d8a;hb=57b43b4d010e2d0a1529d3c131bbb9d416e63258;hpb=d0f366c4a3a66a71b0be94f7a6e2d146f80a94c4 diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx index a9dbbcaa1..e05e2022d 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx @@ -115,6 +115,7 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent ) 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 ) ) ); // Initialize controls @@ -141,6 +142,8 @@ SMESHGUI_MeshTab::~SMESHGUI_MeshTab() void SMESHGUI_MeshTab::setAvailableHyps( const int theId, const QStringList& theHyps ) { myAvailableHyps[ theId ] = theHyps; + + bool enable = ! theHyps.isEmpty(); if ( theId == Algo ) { myHyp[ Algo ]->clear(); @@ -148,6 +151,11 @@ void SMESHGUI_MeshTab::setAvailableHyps( const int theId, const QStringList& the myHyp[ Algo ]->insertStringList( theHyps ); myHyp[ Algo ]->setCurrentItem( 0 ); } + else { + myCreateHyp[ theId ]->setEnabled( enable ); + myEditHyp[ theId ]->setEnabled( false ); + } + myHyp[ theId ]->setEnabled( enable ); } //================================================================================ @@ -167,6 +175,7 @@ void SMESHGUI_MeshTab::setExistingHyps( const int theId, const QStringList& theH myHyp[ theId ]->insertItem( tr( "NONE" ) ); myHyp[ theId ]->insertStringList( theHyps ); myHyp[ theId ]->setCurrentItem( 0 ); + myHyp[ theId ]->setEnabled( !theHyps.isEmpty() ); myEditHyp[ theId ]->setEnabled( false ); } } @@ -186,6 +195,7 @@ void SMESHGUI_MeshTab::addHyp( const int theId, const QString& theHyp ) myHyp[ theId ]->insertItem( theHyp ); myHyp[ theId ]->setCurrentItem( myHyp[ theId ]->count() - 1 ); myEditHyp[ theId ]->setEnabled( true ); + myHyp[ theId ]->setEnabled( true ); } //================================================================================ @@ -288,22 +298,27 @@ void SMESHGUI_MeshTab::onEditHyp() { const QObject* aSender = sender(); int aHypType = aSender == myEditHyp[ MainHyp ] ? MainHyp : AddHyp; - emit editHyp( aHypType, myHyp[ aHypType ]->currentItem() ); + emit editHyp( aHypType, myHyp[ aHypType ]->currentItem() - 1 ); // - 1 because there is NONE on the top } //================================================================================ /*! * \brief Updates "Edit hypothesis" button state * - * SLOT called when current hypothesis changed disables "Edit hypothesis" button - * if current hypothesis is , enables otherwise + * SLOT called when current hypothesis changed. Disables "Edit hypothesis" button + * if current hypothesis is , enables otherwise. + * If an algorithm changed, emits selectAlgo( theIndex ) signal */ //================================================================================ void SMESHGUI_MeshTab::onHyp( int theIndex ) { const QObject* aSender = sender(); - int anIndex = aSender == myHyp[ MainHyp ] ? MainHyp : AddHyp; - myEditHyp[ anIndex ]->setEnabled( theIndex > 0 ); + if ( aSender == myHyp[ Algo ] ) + emit selectAlgo( theIndex - 1 ); // - 1 because there is NONE on the top + else { + int anIndex = aSender == myHyp[ MainHyp ] ? MainHyp : AddHyp; + myEditHyp[ anIndex ]->setEnabled( theIndex > 0 ); + } } //================================================================================ @@ -379,9 +394,9 @@ SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh myTabs[ Dim1D ] = new SMESHGUI_MeshTab( myTabWg ); myTabs[ Dim2D ] = new SMESHGUI_MeshTab( myTabWg ); myTabs[ Dim3D ] = new SMESHGUI_MeshTab( myTabWg ); - myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) ); - myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) ); myTabWg->addTab( myTabs[ Dim3D ], tr( "DIM_3D" ) ); + myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) ); + myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) ); // Hypotheses Sets myHypoSetPopup = new QPopupMenu(); @@ -462,7 +477,7 @@ void SMESHGUI_MeshDlg::reset() //================================================================================ void SMESHGUI_MeshDlg::setCurrentTab( const int theId ) { - myTabWg->setCurrentPage( theId ); + myTabWg->setCurrentPage( Dim3D - theId ); } //================================================================================ @@ -474,13 +489,16 @@ void SMESHGUI_MeshDlg::setCurrentTab( const int theId ) void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim ) { - for ( int i = Dim1D; i <= Dim3D; ++i ) { - int dim = i + 1; - bool enable = ( dim <= maxDim ); + const int DIM = maxDim - 1; + for ( int dim = Dim1D; dim <= Dim3D; ++dim ) { + bool enable = ( dim <= DIM ); if ( !enable ) - myTabs[ i ]->reset(); - myTabWg->setTabEnabled( myTabs[ i ], enable ); + myTabs[ dim ]->reset(); + myTabWg->setTabEnabled( myTabs[ dim ], enable ); } + // deselect desabled tab + if ( !myTabWg->isTabEnabled( myTabWg->currentPage() )) + setCurrentTab( DIM - 1 ); } //================================================================================