X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupOpDlg.cxx;h=b4084b6655b391f4cf23e1a6d91dbff3b7e09e78;hp=44cdfdf94b337e51c4b1ac53d06e50379d15b709;hb=264eeb2edd6977ccf2d2bd88cbb210353f63f7c9;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070 diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx index 44cdfdf94..b4084b665 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 +// 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 -// version 2.1 of the License. +// 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 +// version 2.1 of the License, or (at your option) any later version. // -// 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. +// 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 -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// 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/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_GroupOpDlg.cxx // Author : Sergey LITONIN, Open CASCADE S.A.S. @@ -29,35 +30,35 @@ #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" - -#include - -// SALOME GUI includes -#include -#include -#include -#include +#include "SMESH_TypeFilter.hxx" +#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 #include #include -#include #include -#include -#include -#include -#include +#include +#include #define SPACING 6 #define MARGIN 11 @@ -74,7 +75,8 @@ SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myIsApplyAndClose( false ) { setModal(false); @@ -106,7 +108,7 @@ QWidget* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent ) aLay->setSpacing(SPACING); // ------------------------------------------------------ - QGroupBox* aNameGrp = new QGroupBox(tr("NAME"), aMainGrp); + QGroupBox* aNameGrp = new QGroupBox(tr("RESULT"), aMainGrp); QHBoxLayout* aNameGrpLayout = new QHBoxLayout(aNameGrp); aNameGrpLayout->setMargin(MARGIN); aNameGrpLayout->setSpacing(SPACING); @@ -131,7 +133,7 @@ QWidget* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent ) QLabel* aColorLab = new QLabel(tr( "SMESH_CHECK_COLOR" ), aColorBox ); myColorBtn = new QtxColorButton(aColorBox); myColorBtn->setSizePolicy( QSizePolicy::MinimumExpanding, - myColorBtn->sizePolicy().verticalPolicy() ); + myColorBtn->sizePolicy().verticalPolicy() ); aColorBoxLayout->addWidget(aColorLab); aColorBoxLayout->addWidget(myColorBtn); @@ -199,7 +201,7 @@ QWidget* SMESHGUI_GroupOpDlg::createButtonFrame (QWidget* theParent) // connect signals and slots connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); - connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(reject())); connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp())); @@ -223,12 +225,16 @@ void SMESHGUI_GroupOpDlg::Init() // selection and SMESHGUI connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject())); + connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), SLOT(onOpenView())); + connect(mySMESHGUI, SIGNAL(SignalCloseView()), SLOT(onCloseView())); // set selection mode if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); - mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); + mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP)); + + setDefaultGroupColor(); } /*! @@ -242,7 +248,7 @@ bool SMESHGUI_GroupOpDlg::isValid( const QList& theL if ( theListGrp.isEmpty() ) { SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"), - tr("INCORRECT_ARGUMENTS") ); + tr("INCORRECT_ARGUMENTS") ); return false; } @@ -252,7 +258,7 @@ bool SMESHGUI_GroupOpDlg::isValid( const QList& theL { SMESH::SMESH_GroupBase_var aGrp = *anIter; if ( CORBA::is_nil( aGrp ) ) - continue; // nonsence + continue; // nonsense SMESH::SMESH_Mesh_var aMesh = aGrp->GetMesh(); if ( CORBA::is_nil( aMesh ) ) @@ -289,14 +295,14 @@ bool SMESHGUI_GroupOpDlg::isValid( const QList& theL if ( aMeshId == -1 ) { SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"), - tr("DIFF_MESHES")); + tr("DIFF_MESHES")); return false; } if ( aGrpType == -1 ) { SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"), - tr("DIFF_TYPES")); + tr("DIFF_TYPES")); return false; } @@ -308,14 +314,17 @@ bool SMESHGUI_GroupOpDlg::isValid( const QList& theL */ void SMESHGUI_GroupOpDlg::onOk() { + SUIT_OverrideCursor oc; + setIsApplyAndClose( true ); if ( onApply() ) - onClose(); + reject(); + setIsApplyAndClose( false ); } /*! - \brief SLOT called when "Close" button pressed closes dialog + \brief SLOT called when dialog is closed */ -void SMESHGUI_GroupOpDlg::onClose() +void SMESHGUI_GroupOpDlg::reject() { if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); @@ -324,7 +333,33 @@ void SMESHGUI_GroupOpDlg::onClose() mySMESHGUI->ResetState(); mySelectionMgr->clearFilters(); reset(); - reject(); + QDialog::reject(); +} + +//================================================================================= +// function : onOpenView() +// purpose : +//================================================================================= +void SMESHGUI_GroupOpDlg::onOpenView() +{ + if ( mySelector ) { + SMESH::SetPointRepresentation(false); + } + else { + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); + mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled(true); + } +} + +//================================================================================= +// function : onCloseView() +// purpose : +//================================================================================= +void SMESHGUI_GroupOpDlg::onCloseView() +{ + onDeactivate(); + mySelector = 0; } /*! @@ -343,10 +378,10 @@ void SMESHGUI_GroupOpDlg::onHelp() platform = "application"; #endif SUIT_MessageBox::warning(this, tr("WRN_WARNING"), - tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", - platform)). - arg(myHelpFileName)); + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); } } @@ -415,6 +450,14 @@ SALOMEDS::Color SMESHGUI_GroupOpDlg::getColor() const return aColor; } +/*! + \brief Set default color for group +*/ +void SMESHGUI_GroupOpDlg::setDefaultGroupColor() +{ + myColorBtn->setColor( SMESH::GetColor( "SMESH", "default_grp_color", QColor( 255, 170, 0 ) ) ); +} + /*! \brief SLOT, called when selection is changed. Current implementation does nothing. The method should be redefined in derived classes to update @@ -455,17 +498,13 @@ void SMESHGUI_GroupOpDlg::enterEvent(QEvent*) { mySMESHGUI->EmitSignalDeactivateDialog(); setEnabled(true); - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); + if ( aViewWindow ) { aViewWindow->SetSelectionMode(ActorSelection); - mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); -} - -/*! - \brief Provides reaction on close event, closes the dialog box -*/ -void SMESHGUI_GroupOpDlg::closeEvent(QCloseEvent*) -{ - onClose(); + if (!mySelector) + mySelector = aViewWindow->GetSelector(); + } + mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP)); } /*! @@ -477,6 +516,7 @@ void SMESHGUI_GroupOpDlg::reset() { myNameEdit->setText(""); myNameEdit->setFocus(); + setDefaultGroupColor(); } /*! @@ -500,7 +540,7 @@ void SMESHGUI_GroupOpDlg::setName( const QString& theName ) } /*! - \brief Provides reaction on “F1” button pressing + \brief Provides reaction on �F1� button pressing \param e key press event */ void SMESHGUI_GroupOpDlg::keyPressEvent( QKeyEvent* e ) @@ -524,6 +564,28 @@ bool SMESHGUI_GroupOpDlg::onApply() return false; } +/*! + \brief Set value of the flag indicating that the dialog is + accepted by Apply & Close button + \param theFlag value of the flag + \sa isApplyAndClose() +*/ +void SMESHGUI_GroupOpDlg::setIsApplyAndClose( const bool theFlag ) +{ + myIsApplyAndClose = theFlag; +} + +/*! + \brief Get value of the flag indicating that the dialog is + accepted by Apply & Close button + \return value of the flag + \sa setApplyAndClose() +*/ +bool SMESHGUI_GroupOpDlg::isApplyAndClose() const +{ + return myIsApplyAndClose; +} + // === === === === === === === === === === === === === === === === === === === === === /*! @@ -567,7 +629,7 @@ void SMESHGUI_UnionGroupsDlg::reset() */ bool SMESHGUI_UnionGroupsDlg::onApply() { - if ( getSMESHGUI()->isActiveStudyLocked()) + if ( SMESHGUI::isStudyLocked()) return false; // Verify validity of group name @@ -585,6 +647,7 @@ bool SMESHGUI_UnionGroupsDlg::onApply() QString aName = getName(); bool aRes = false; + QStringList anEntryList; try { SMESH::ListOfGroups_var aList = convert( myGroups ); @@ -593,6 +656,8 @@ bool SMESHGUI_UnionGroupsDlg::onApply() if ( !CORBA::is_nil( aNewGrp ) ) { aNewGrp->SetColor( getColor() ); + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) ) + anEntryList.append( aSObject->GetID().c_str() ); aRes = true; } } @@ -603,14 +668,18 @@ bool SMESHGUI_UnionGroupsDlg::onApply() if ( aRes ) { + SMESHGUI::Modified(); getSMESHGUI()->updateObjBrowser(true); reset(); + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + anApp->browseObjects( anEntryList, isApplyAndClose() ); return true; } else { SUIT_MessageBox::critical(this, tr("SMESH_ERROR"), - tr("SMESH_OPERATION_FAILED")); + tr("SMESH_OPERATION_FAILED")); return false; } } @@ -669,7 +738,7 @@ void SMESHGUI_IntersectGroupsDlg::reset() */ bool SMESHGUI_IntersectGroupsDlg::onApply() { - if ( getSMESHGUI()->isActiveStudyLocked()) + if ( SMESHGUI::isStudyLocked()) return false; // Verify validity of group name @@ -687,6 +756,7 @@ bool SMESHGUI_IntersectGroupsDlg::onApply() QString aName = getName(); bool aRes = false; + QStringList anEntryList; try { SMESH::ListOfGroups_var aList = convert( myGroups ); @@ -695,6 +765,8 @@ bool SMESHGUI_IntersectGroupsDlg::onApply() if ( !CORBA::is_nil( aNewGrp ) ) { aNewGrp->SetColor( getColor() ); + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) ) + anEntryList.append( aSObject->GetID().c_str() ); aRes = true; } } @@ -705,14 +777,18 @@ bool SMESHGUI_IntersectGroupsDlg::onApply() if ( aRes ) { + SMESHGUI::Modified(); getSMESHGUI()->updateObjBrowser(true); reset(); + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + anApp->browseObjects( anEntryList, isApplyAndClose() ); return true; } else { SUIT_MessageBox::critical(this, tr("SMESH_ERROR"), - tr("SMESH_OPERATION_FAILED")); + tr("SMESH_OPERATION_FAILED")); return false; } } @@ -822,7 +898,7 @@ void SMESHGUI_CutGroupsDlg::reset() */ bool SMESHGUI_CutGroupsDlg::onApply() { - if ( getSMESHGUI()->isActiveStudyLocked()) + if ( SMESHGUI::isStudyLocked()) return false; // Verify validity of group name @@ -852,6 +928,7 @@ bool SMESHGUI_CutGroupsDlg::onApply() QString aName = getName(); bool aRes = false; + QStringList anEntryList; try { SMESH::ListOfGroups_var aList1 = convert( myGroups1 ); @@ -861,6 +938,8 @@ bool SMESHGUI_CutGroupsDlg::onApply() if ( !CORBA::is_nil( aNewGrp ) ) { aNewGrp->SetColor( getColor() ); + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) ) + anEntryList.append( aSObject->GetID().c_str() ); aRes = true; } } @@ -871,14 +950,18 @@ bool SMESHGUI_CutGroupsDlg::onApply() if ( aRes ) { + SMESHGUI::Modified(); getSMESHGUI()->updateObjBrowser(true); reset(); + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + anApp->browseObjects( anEntryList, isApplyAndClose() ); return true; } else { SUIT_MessageBox::critical(this, tr("SMESH_ERROR"), - tr("SMESH_OPERATION_FAILED")); + tr("SMESH_OPERATION_FAILED")); return false; } } @@ -910,35 +993,55 @@ void SMESHGUI_CutGroupsDlg::onSelectionDone() \param theModule module */ SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule ) -: SMESHGUI_GroupOpDlg( theModule ) + : SMESHGUI_GroupOpDlg( theModule ) { setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) ); - setHelpFileName( "creating_groups_page.html#gui_create_dim_group" ); + setHelpFileName( "group_of_underlying_elements_page.html" ); QGroupBox* anArgGrp = getArgGrp(); - QLabel* aLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp ); - - myCombo = new QComboBox( anArgGrp ); - static QStringList anItems; - if ( anItems.isEmpty() ) + QLabel* aTypeLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp ); + + myTypeCombo = new QComboBox( anArgGrp ); + QStringList anItems; { - anItems.append( tr( "NODE" ) ); - anItems.append( tr( "EDGE" ) ); - anItems.append( tr( "FACE" ) ); - anItems.append( tr( "VOLUME" ) ); + anItems.append( tr( "MESH_NODE" ) ); + anItems.append( tr( "SMESH_EDGE" ) ); + anItems.append( tr( "SMESH_FACE" ) ); + anItems.append( tr( "SMESH_VOLUME" ) ); + anItems.append( tr( "SMESH_ELEM0D" ) ); + anItems.append( tr( "SMESH_BALL" ) ); } - myCombo->addItems( anItems ); - myCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - + myTypeCombo->addItems( anItems ); + myTypeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QLabel* aNbNoLbl = new QLabel( tr( "NUMBER_OF_COMMON_NODES" ), anArgGrp ); + + myNbNoCombo = new QComboBox( anArgGrp ); + anItems.clear(); + { + anItems.append( tr( "ALL" ) ); + anItems.append( tr( "MAIN" ) ); + anItems.append( tr( "AT_LEAST_ONE" ) ); + anItems.append( tr( "MAJORITY" ) ); + } + myNbNoCombo->addItems( anItems ); + myNbNoCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myListWg = new QListWidget( anArgGrp ); + myUnderlOnlyChk = new QCheckBox( tr("UNDERLYING_ENTITIES_ONLY"), anArgGrp ); + myUnderlOnlyChk->setChecked( false ); + // layout QGridLayout* aLay = new QGridLayout( anArgGrp ); aLay->setSpacing( SPACING ); - aLay->addWidget( aLbl, 0, 0 ); - aLay->addWidget( myCombo, 0, 1 ); - aLay->addWidget( myListWg, 1, 0, 1, 2 ); + aLay->addWidget( aTypeLbl, 0, 0 ); + aLay->addWidget( myTypeCombo, 0, 1 ); + aLay->addWidget( aNbNoLbl, 1, 0 ); + aLay->addWidget( myNbNoCombo, 1, 1 ); + aLay->addWidget( myListWg, 2, 0, 1, 2 ); + aLay->addWidget( myUnderlOnlyChk, 3, 0 ); } /*! @@ -966,7 +1069,7 @@ void SMESHGUI_DimGroupDlg::reset() */ SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const { - return (SMESH::ElementType)( myCombo->currentIndex() + 1 ); + return (SMESH::ElementType)( myTypeCombo->currentIndex() + 1 ); } /*! @@ -976,7 +1079,7 @@ SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const */ void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType ) { - myCombo->setCurrentIndex( theElemType - 1 ); + myTypeCombo->setCurrentIndex( theElemType - 1 ); } /*! @@ -985,7 +1088,7 @@ void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType */ bool SMESHGUI_DimGroupDlg::onApply() { - if ( getSMESHGUI()->isActiveStudyLocked()) + if ( SMESHGUI::isStudyLocked()) return false; // Verify validity of group name @@ -1003,15 +1106,27 @@ bool SMESHGUI_DimGroupDlg::onApply() QString aName = getName(); bool aRes = false; + QStringList anEntryList; try { - SMESH::ListOfGroups_var aList = convert( myGroups ); + SMESH::ListOfIDSources_var aList = new SMESH::ListOfIDSources(); + aList->length( myGroups.count() ); + QList::const_iterator anIter = myGroups.begin(); + for ( int i = 0; anIter != myGroups.end(); ++anIter, ++i ) + aList[ i ] = SMESH::SMESH_IDSource::_narrow( *anIter ); + SMESH::ElementType anElemType = getElementType(); - SMESH::SMESH_Group_var aNewGrp = - aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData() ); + SMESH::NB_COMMON_NODES_ENUM aNbCoNodes = + (SMESH::NB_COMMON_NODES_ENUM) myNbNoCombo->currentIndex(); + + SMESH::SMESH_Group_var aNewGrp = + aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData(), + aNbCoNodes, myUnderlOnlyChk->isChecked() ); if ( !CORBA::is_nil( aNewGrp ) ) { aNewGrp->SetColor( getColor() ); + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) ) + anEntryList.append( aSObject->GetID().c_str() ); aRes = true; } } @@ -1022,14 +1137,18 @@ bool SMESHGUI_DimGroupDlg::onApply() if ( aRes ) { + SMESHGUI::Modified(); getSMESHGUI()->updateObjBrowser(true); reset(); + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + anApp->browseObjects( anEntryList, isApplyAndClose() ); return true; } else { SUIT_MessageBox::critical(this, tr("SMESH_ERROR"), - tr("SMESH_OPERATION_FAILED")); + tr("SMESH_OPERATION_FAILED")); return false; } } @@ -1044,5 +1163,3 @@ void SMESHGUI_DimGroupDlg::onSelectionDone() myListWg->clear(); myListWg->addItems( aNames ); } - -