From: vsr Date: Tue, 1 Feb 2005 14:55:30 +0000 (+0000) Subject: Fix PAL7951 X-Git-Tag: V2_2_0b2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2177157cb700c78f88eae60fc085a2521de00686;p=modules%2Fsmesh.git Fix PAL7951 --- diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index 77bffa191..36660f1eb 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -148,6 +148,7 @@ QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent, const bool t 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 ); @@ -213,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); } //======================================================================= @@ -232,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 @@ -272,10 +288,16 @@ void SMESHGUI_MultiEditDlg::Init( SALOME_Selection* theSelection ) 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(); } @@ -431,13 +453,19 @@ void SMESHGUI_MultiEditDlg::onSelectionDone() if ( nbSel == 1 ) { myActor = SMESH::FindActorByEntry(mySelection->firstIObject()->getEntry()); - if ( !myActor && !myMesh->_is_nil() ) - myActor = SMESH::FindActorByObject( myMesh ); + //if ( !myActor && !myMesh->_is_nil() ) + // myActor = SMESH::FindActorByObject( myMesh ); VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle(); Handle(VTKViewer_Filter) aFilter = aStyle->GetFilter( myFilterType ); - if ( !aFilter.IsNull() && myActor ) { - aFilter->SetActor( myActor ); - //SMESH::SetPickable( myActor ); + if ( myActor ) { + if ( !aFilter.IsNull() ) { + aFilter->SetActor( myActor ); + //SMESH::SetPickable( myActor ); + myIO = myActor->getIO(); + } + } + else { + myIO.Nullify(); } } myBusy = false; @@ -817,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(); } @@ -864,6 +892,8 @@ void SMESHGUI_MultiEditDlg::setSelectionMode() else SMESH::SetFilter( new SMESHGUI_FacesFilter() ); } + if ( !myIO.IsNull() ) + mySelection->AddIObject( myIO, true ); } //======================================================================= @@ -920,15 +950,15 @@ void SMESHGUI_MultiEditDlg::on3d2dChanged(int type) emit ListContensChanged(); - updateButtons(); - if ( type ) myFilterType = SMESHGUI_VolumeFilter; else myFilterType = SMESHGUI_FaceFilter; setSelectionMode(); - myActor = 0; + updateButtons(); + + //myActor = 0; } } diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h index 0ec412661..0f69a5d72 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h @@ -34,7 +34,6 @@ #include #include CORBA_SERVER_HEADER(SMESH_Mesh) -class QCloseEvent; class SMESHGUI_FilterDlg; class QCheckBox; class QGroupBox; @@ -47,6 +46,7 @@ class SALOME_Selection; class SMESH_Actor; class SALOME_Actor; class QButtonGroup; +class QObject; /* Class : SMESHGUI_MultiEditDlg @@ -68,6 +68,8 @@ public: void Init( SALOME_Selection* ) ; + bool eventFilter( QObject* object, QEvent* event ); + signals: void ListContensChanged(); @@ -98,7 +100,7 @@ protected: void hideEvent ( QHideEvent * ); /* ESC key */ QFrame* createButtonFrame( QWidget* ); QFrame* createMainFrame ( QWidget*, const bool ); - bool isValid( const bool ) const; + bool isValid( const bool ); SMESH::long_array_var getIds(); void updateButtons(); void setSelectionMode(); @@ -141,6 +143,7 @@ protected: Handle(SMESH_TypeFilter) myGroupFilter; bool myBusy; int myEntityType; + Handle(SALOME_InteractiveObject) myIO; }; /*