X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MultiEditDlg.cxx;h=36660f1eb71422ddc6ef3e686c6526e29e7b363f;hp=b1662d8e64175f0d3ba5ec06e0e5553e415327ab;hb=c9be7f0ec93cabbfbbe9d958a2756e2335ae2e5e;hpb=090aff07266d376ae028ae43434bdea7c0a0f9bb diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index b1662d8e6..36660f1eb 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -47,7 +47,9 @@ #include "SALOME_ListIteratorOfListIO.hxx" #include "VTKViewer_InteractorStyleSALOME.h" -#include +#include +#include +#include #include #include #include @@ -69,6 +71,8 @@ #include #include #include +#include +#include // IDL Headers #include "SALOMEconfig.h" @@ -90,6 +94,7 @@ SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg( QWidget* theParent, SALOME_Selection* theSelection, const int theMode, + const bool the3d2d, const char* theName ) : QDialog( theParent, theName, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) @@ -98,10 +103,12 @@ SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg( QWidget* theParent, mySubmeshFilter = new SMESH_TypeFilter( SUBMESH ); myGroupFilter = new SMESH_TypeFilter( GROUP ); + myEntityType = 0; + myFilterType = theMode; QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); - QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aMainFrame = createMainFrame ( this, the3d2d ); QFrame* aBtnFrame = createButtonFrame( this ); aDlgLay->addWidget( aMainFrame ); @@ -116,7 +123,7 @@ SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg( QWidget* theParent, // name : SMESHGUI_MultiEditDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent, const bool the3d2d ) { QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); aMainGrp->setFrameStyle( QFrame::NoFrame ); @@ -126,12 +133,22 @@ QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent ) // "Selected cells" group mySelGrp = new QGroupBox( 1, Qt::Horizontal, aMainGrp ); + + myEntityTypeGrp = 0; + if ( the3d2d ) { + myEntityTypeGrp = new QHButtonGroup( tr("SMESH_ELEMENTS_TYPE"), mySelGrp ); + (new QRadioButton( tr("SMESH_FACE"), myEntityTypeGrp ))->setChecked( true ); + (new QRadioButton( tr("SMESH_VOLUME"), myEntityTypeGrp )); + myEntityType = myEntityTypeGrp->id( myEntityTypeGrp->selected() ); + } + QFrame* aFrame = new QFrame( mySelGrp ); myListBox = new QListBox( aFrame ); myListBox->setSelectionMode( QListBox::Extended ); myListBox->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); // myListBox->setColumnMode( QListBox::FitToHeight ); + myListBox->installEventFilter( this ); myFilterBtn = new QPushButton( tr( "FILTER" ) , aFrame ); myAddBtn = new QPushButton( tr( "ADD" ) , aFrame ); @@ -197,10 +214,11 @@ QFrame* SMESHGUI_MultiEditDlg::createButtonFrame( QWidget* theParent ) // name : SMESHGUI_MultiEditDlg::isValid // Purpose : Verify validity of input data //======================================================================= -bool SMESHGUI_MultiEditDlg::isValid( const bool /*theMess*/ ) const +bool SMESHGUI_MultiEditDlg::isValid( const bool /*theMess*/ ) { + SMESH::long_array_var anIds = getIds(); return (!myMesh->_is_nil() && - (myListBox->count() > 0 || (myToAllChk->isChecked() && myActor))); + (myListBox->count() > 0 || (myToAllChk->isChecked() && myActor)) && anIds->length() > 0); } //======================================================================= @@ -216,6 +234,20 @@ SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg() } } +//======================================================================= +// name : SMESHGUI_MultiEditDlg::eventFilter +// Purpose : event filter +//======================================================================= +bool SMESHGUI_MultiEditDlg::eventFilter( QObject* object, QEvent* event ) +{ + if ( object == myListBox && event->type() == QEvent::KeyPress ) { + QKeyEvent* ke = (QKeyEvent*)event; + if ( ke->key() == Key_Delete ) + onRemoveBtn(); + } + return QDialog::eventFilter( object, event ); +} + //======================================================================= // name : SMESHGUI_MultiEditDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog @@ -251,12 +283,21 @@ void SMESHGUI_MultiEditDlg::Init( SALOME_Selection* theSelection ) connect( myGroupChk , SIGNAL( stateChanged( int ) ), SLOT( onGroupChk() ) ); connect( myToAllChk , SIGNAL( stateChanged( int ) ), SLOT( onToAllChk() ) ); + if ( myEntityTypeGrp ) + connect( myEntityTypeGrp, SIGNAL( clicked(int) ), SLOT( on3d2dChanged(int) ) ); + connect( myListBox, SIGNAL( selectionChanged() ), SLOT( onListSelectionChanged() ) ); - onSelectionDone(); + int nbSel = mySelection->IObjectCount(); + if ( nbSel == 1 ) + myIO = mySelection->firstIObject(); // set selection mode setSelectionMode(); + + // process selection + //onSelectionDone(); + updateButtons(); } @@ -293,10 +334,14 @@ SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds() vtkCell* aCell = aGrid->GetCell( i ); if ( aCell != 0 ) { - int nbNodes = aCell->GetNumberOfPoints(); - if ( nbNodes == 3 && myFilterType == SMESHGUI_TriaFilter || - nbNodes == 4 && myFilterType == SMESHGUI_QuadFilter || - ( nbNodes == 4 || nbNodes == 3 ) && myFilterType == SMESHGUI_UnknownFilter ) + vtkTriangle* aTri = vtkTriangle::SafeDownCast(aCell); + vtkQuad* aQua = vtkQuad::SafeDownCast(aCell); + vtkCell3D* a3d = vtkCell3D::SafeDownCast(aCell); + + if ( aTri && myFilterType == SMESHGUI_TriaFilter || + aQua && myFilterType == SMESHGUI_QuadFilter || + ( aTri || aQua ) && myFilterType == SMESHGUI_FaceFilter || + a3d && myFilterType == SMESHGUI_VolumeFilter ) { int anObjId = aVisualObj->GetElemObjId( i ); myIds.Add( anObjId ); @@ -329,6 +374,7 @@ void SMESHGUI_MultiEditDlg::onClose() SMESH::RemoveFilter(SMESHGUI_EdgeFilter); SMESH::RemoveFilter(SMESHGUI_FaceFilter); + SMESH::RemoveFilter(SMESHGUI_VolumeFilter); SMESH::RemoveFilter(SMESHGUI_QuadFilter); SMESH::RemoveFilter(SMESHGUI_TriaFilter); SMESH::SetPickable(); @@ -348,6 +394,9 @@ void SMESHGUI_MultiEditDlg::onSelectionDone() if ( myBusy || !isEnabled() ) return; myBusy = true; + myMesh = SMESH::SMESH_Mesh::_nil(); + myActor = 0; + int nbSel = mySelection->IObjectCount(); myListBox->clearSelection(); @@ -404,17 +453,20 @@ void SMESHGUI_MultiEditDlg::onSelectionDone() if ( nbSel == 1 ) { myActor = SMESH::FindActorByEntry(mySelection->firstIObject()->getEntry()); - if (!myActor) - myActor = SMESH::FindActorByObject( myMesh ); + //if ( !myActor && !myMesh->_is_nil() ) + // myActor = SMESH::FindActorByObject( myMesh ); VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle(); - Handle(VTKViewer_Filter) aFilter1 = aStyle->GetFilter( myFilterType ); - Handle(VTKViewer_Filter) aFilter2 = aStyle->GetFilter( SMESHGUI_FaceFilter ); - if ( !aFilter1.IsNull() ) - aFilter1->SetActor( myActor ); - if ( !aFilter2.IsNull() ) - aFilter2->SetActor( myActor ); - if ( myActor ) - SMESH::SetPickable(myActor); + Handle(VTKViewer_Filter) aFilter = aStyle->GetFilter( myFilterType ); + if ( myActor ) { + if ( !aFilter.IsNull() ) { + aFilter->SetActor( myActor ); + //SMESH::SetPickable( myActor ); + myIO = myActor->getIO(); + } + } + else { + myIO.Nullify(); + } } myBusy = false; @@ -472,11 +524,11 @@ void SMESHGUI_MultiEditDlg::onFilterBtn() { if ( myFilterDlg == 0 ) { - myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), SMESH::FACE ); + myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), entityType() ? SMESH::VOLUME : SMESH::FACE ); connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); } else - myFilterDlg->Init( SMESH::FACE ); + myFilterDlg->Init( entityType() ? SMESH::VOLUME : SMESH::FACE ); myFilterDlg->SetSelection( mySelection ); myFilterDlg->SetMesh( myMesh ); @@ -511,18 +563,15 @@ void SMESHGUI_MultiEditDlg::onFilterAccepted() } //======================================================================= -// name : SMESHGUI_MultiEditDlg::onAddBtn +// name : SMESHGUI_MultiEditDlg::isIdValid // Purpose : Verify whether Id of element satisfies to filters from viewer //======================================================================= bool SMESHGUI_MultiEditDlg::isIdValid( const int theId ) const { VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle(); - Handle(SMESHGUI_Filter) aFilter1 = + Handle(SMESHGUI_Filter) aFilter = Handle(SMESHGUI_Filter)::DownCast( aStyle->GetFilter( myFilterType ) ); - Handle(SMESHGUI_Filter) aFilter2 = - Handle(SMESHGUI_Filter)::DownCast( aStyle->GetFilter( SMESHGUI_FaceFilter ) ); - return ( aFilter1.IsNull() || aFilter1->IsObjValid( theId ) ) && - ( aFilter2.IsNull() || aFilter2->IsObjValid( theId ) ); + return ( !aFilter.IsNull() && aFilter->IsObjValid( theId ) ); } //======================================================================= @@ -551,7 +600,7 @@ void SMESHGUI_MultiEditDlg::onAddBtn() SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface( anIter.Value() ); if ( !aSubMesh->_is_nil() ) { - if ( aSubMesh->GetFather()->GetId() == myMesh->GetId() ) + if ( !myMesh->_is_nil() && aSubMesh->GetFather()->GetId() == myMesh->GetId() ) { SMESH::long_array_var anIds = aSubMesh->GetElementsId(); for ( int i = 0, n = anIds->length(); i < n; i++ ) @@ -570,9 +619,9 @@ void SMESHGUI_MultiEditDlg::onAddBtn() { SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface( anIter.Value() ); - if ( !aGroup->_is_nil() && aGroup->GetType() == SMESH::FACE ) + if ( !aGroup->_is_nil() && ( aGroup->GetType() == SMESH::FACE || aGroup->GetType() == SMESH::VOLUME ) ) { - if ( aGroup->GetMesh()->GetId() == myMesh->GetId() ) + if ( !myMesh->_is_nil() && aGroup->GetMesh()->GetId() == myMesh->GetId() ) { SMESH::long_array_var anIds = aGroup->GetListOfID(); for ( int i = 0, n = anIds->length(); i < n; i++ ) @@ -796,11 +845,11 @@ void SMESHGUI_MultiEditDlg::onToAllChk() emit ListContensChanged(); - updateButtons(); setSelectionMode(); - if ( myActor ) - mySelection->AddIObject( myActor->getIO(), true ); + //if ( !myIO.IsNull() ) + //mySelection->AddIObject( myIO, true ); + updateButtons(); } @@ -810,6 +859,13 @@ void SMESHGUI_MultiEditDlg::onToAllChk() //======================================================================= void SMESHGUI_MultiEditDlg::setSelectionMode() { + SMESH::RemoveFilter(SMESHGUI_EdgeFilter); + SMESH::RemoveFilter(SMESHGUI_FaceFilter); + SMESH::RemoveFilter(SMESHGUI_VolumeFilter); + SMESH::RemoveFilter(SMESHGUI_QuadFilter); + SMESH::RemoveFilter(SMESHGUI_TriaFilter); + SMESH::SetPickable(); + mySelection->ClearIObjects(); mySelection->ClearFilters(); @@ -823,14 +879,21 @@ void SMESHGUI_MultiEditDlg::setSelectionMode() QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); mySelection->AddFilter( myGroupFilter ); } - else - { + if ( myFilterType == SMESHGUI_VolumeFilter ) { + QAD_Application::getDesktop()->SetSelectionMode( VolumeSelection, true ); + SMESH::SetFilter( new SMESHGUI_VolumesFilter() ); + } + else { QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); if ( myFilterType == SMESHGUI_TriaFilter ) SMESH::SetFilter( new SMESHGUI_TriangleFilter() ); else if ( myFilterType == SMESHGUI_QuadFilter ) SMESH::SetFilter( new SMESHGUI_QuadrangleFilter() ); + else + SMESH::SetFilter( new SMESHGUI_FacesFilter() ); } + if ( !myIO.IsNull() ) + mySelection->AddIObject( myIO, true ); } //======================================================================= @@ -848,6 +911,8 @@ bool SMESHGUI_MultiEditDlg::onApply() if ( aMeshEditor->_is_nil() ) return false; + myBusy = true; + SMESH::long_array_var anIds = getIds(); bool aResult = process( aMeshEditor, anIds.inout() ); @@ -867,9 +932,46 @@ bool SMESHGUI_MultiEditDlg::onApply() updateButtons(); } + myBusy = false; return aResult; } +//======================================================================= +// name : SMESHGUI_MultiEditDlg::on3d2dChanged +// Purpose : +//======================================================================= +void SMESHGUI_MultiEditDlg::on3d2dChanged(int type) +{ + if ( myEntityType != type ) { + myEntityType = type; + + myListBox->clear(); + myIds.Clear(); + + emit ListContensChanged(); + + if ( type ) + myFilterType = SMESHGUI_VolumeFilter; + else + myFilterType = SMESHGUI_FaceFilter; + setSelectionMode(); + + updateButtons(); + + //myActor = 0; + } +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::entityType +// Purpose : +//======================================================================= + +int SMESHGUI_MultiEditDlg::entityType() +{ + return myEntityType; +} + /* Class : SMESHGUI_ChangeOrientationDlg Description : Modification of orientation of faces @@ -878,7 +980,7 @@ bool SMESHGUI_MultiEditDlg::onApply() SMESHGUI_ChangeOrientationDlg::SMESHGUI_ChangeOrientationDlg( QWidget* theParent, SALOME_Selection* theSelection, const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_UnknownFilter, theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_FaceFilter, true, theName ) { setCaption( tr( "CAPTION" ) ); } @@ -901,7 +1003,7 @@ bool SMESHGUI_ChangeOrientationDlg::process( SMESH::SMESH_MeshEditor_ptr theEdit SMESHGUI_UnionOfTrianglesDlg::SMESHGUI_UnionOfTrianglesDlg( QWidget* theParent, SALOME_Selection* theSelection, const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_TriaFilter, theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_TriaFilter, false, theName ) { setCaption( tr( "CAPTION" ) ); } @@ -924,7 +1026,7 @@ bool SMESHGUI_UnionOfTrianglesDlg::process( SMESH::SMESH_MeshEditor_ptr theEdito SMESHGUI_CuttingOfQuadsDlg::SMESHGUI_CuttingOfQuadsDlg( QWidget* theParent, SALOME_Selection* theSelection, const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_QuadFilter, theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_QuadFilter, false, theName ) { setCaption( tr( "CAPTION" ) );