From: vsr Date: Thu, 3 Jun 2010 08:24:13 +0000 (+0000) Subject: 0020898: EDF 1429 SMESH: Remove elements using "Set Filters" fails X-Git-Tag: V5_1_4~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c5b8df021f4097bb2cd1bb616731b2880dc36f80;p=modules%2Fsmesh.git 0020898: EDF 1429 SMESH: Remove elements using "Set Filters" fails --- diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index 9253da04b..f9b4af034 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -2517,31 +2517,18 @@ void SMESHGUI_FilterDlg::setIdsToWg (QWidget* theWg, const QList& theIds) if (theWg == 0) return; + QStringList aStrList; + foreach(int id, theIds) + aStrList << QString::number(id); + if (theWg->inherits("QListWidget")) { - QListWidget* aListBox = qobject_cast( theWg ); - aListBox->clear(); - - QStringList aStrList; - QList::const_iterator anIter; - for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) - aStrList.append(QString("%1").arg(*anIter)); - - aListBox->addItems(aStrList); + qobject_cast(theWg)->clear(); + qobject_cast(theWg)->addItems(aStrList); } else if (theWg->inherits("QLineEdit")) { - QLineEdit* aLineEdit = qobject_cast( theWg ); - QString aStr; - QList::const_iterator anIter; - - for (anIter = theIds.begin(); anIter != theIds.end(); ++ anIter) - aStr += QString("%1 ").arg(*anIter); - - if (!aStr.isEmpty()) - aStr.remove(aStr.length() - 1, 1); - - aLineEdit->setText(aStr); + qobject_cast( theWg )->setText(aStrList.join(" ")); } } diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx index 44f495fb3..a007feb0f 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx @@ -123,6 +123,7 @@ SMESHGUI_RemoveElementsDlg SelectButtonC1A1->setIcon(image1); LineEditC1A1 = new QLineEdit(GroupC1); LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this)); + LineEditC1A1->setMaxLength(-1); QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupC1 ); connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); @@ -232,7 +233,7 @@ void SMESHGUI_RemoveElementsDlg::ClickOnApply() bool aResult = false; try { SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - aResult = aMeshEditor->RemoveElements(anArrayOfIdeces.inout()); + aResult = aMeshEditor->RemoveElements(anArrayOfIdeces.in()); } catch (const SALOME::SALOME_Exception& S_ex) { SalomeApp_Tools::QtCatchCorbaException(S_ex); myEditCurrentArgument->clear(); @@ -311,9 +312,6 @@ void SMESHGUI_RemoveElementsDlg::onTextChange(const QString& theNewText) myNbOkElements = 0; - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); - // hilight entered elements if(myActor){ if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){ @@ -335,12 +333,8 @@ void SMESHGUI_RemoveElementsDlg::onTextChange(const QString& theNewText) } } - if (myNbOkElements) { - buttonOk->setEnabled(true); - buttonApply->setEnabled(true); - } - myBusy = false; + updateButtons(); } //================================================================================= @@ -349,56 +343,52 @@ void SMESHGUI_RemoveElementsDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_RemoveElementsDlg::SelectionIntoArgument() { - if (myBusy) return; + if (myBusy) return; // busy + if (myFilterDlg && myFilterDlg->isVisible()) return; // filter digl active + if (!GroupButtons->isEnabled()) return; // inactive // clear - myNbOkElements = false; + myNbOkElements = 0; myActor = 0; myBusy = true; myEditCurrentArgument->setText(""); myBusy = false; - if (!GroupButtons->isEnabled()) // inactive - return; - - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); - // get selected mesh SALOME_ListIO aList; mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); int nbSel = aList.Extent(); - if (nbSel != 1) - return; - - Handle(SALOME_InteractiveObject) anIO = aList.First(); - myMesh = SMESH::GetMeshByIO(anIO); - if (myMesh->_is_nil()) - return; - - myActor = SMESH::FindActorByEntry(anIO->getEntry()); - if (!myActor) - return; - - // get selected nodes - QString aString = ""; - int nbElems = SMESH::GetNameOfSelectedElements(mySelector,anIO,aString); - if(nbElems < 1) - return; - myBusy = true; - myEditCurrentArgument->setText(aString); - myBusy = false; - - // OK - - myNbOkElements = nbElems; - - buttonOk->setEnabled(true); - buttonApply->setEnabled(true); + if (nbSel == 1) { + + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myMesh = SMESH::GetMeshByIO(anIO); + + if (!myMesh->_is_nil()) { + + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (myActor) { + + // get selected nodes + QString aString = ""; + int nbElems = SMESH::GetNameOfSelectedElements(mySelector,anIO,aString); + if (nbElems > 0) { + myBusy = true; + myEditCurrentArgument->setText(aString); + myBusy = false; + + // OK + + myNbOkElements = nbElems; + } // if (nbElems > 0) + } // if (myActor) + } // if (!myMesh->_is_nil()) + } // if (nbSel == 1) { + + updateButtons(); } //================================================================================= @@ -524,3 +514,13 @@ void SMESHGUI_RemoveElementsDlg::setFilters() myFilterDlg->show(); } + +//================================================================================= +// function : updateButtons +// purpose : enable / disable control buttons +//================================================================================= +void SMESHGUI_RemoveElementsDlg::updateButtons() +{ + buttonOk->setEnabled(myNbOkElements > 0); + buttonApply->setEnabled(myNbOkElements > 0); +} diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h index 246c78a47..9a372bb27 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h @@ -107,6 +107,7 @@ private slots: void ActivateThisDialog(); void onTextChange( const QString& ); void setFilters(); + void updateButtons(); }; #endif // SMESHGUI_REMOVEELEMENTSDLG_H diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx index 3fcef3f95..58fd31fb3 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx @@ -123,6 +123,7 @@ SMESHGUI_RemoveNodesDlg SelectButtonC1A1->setIcon(image1); LineEditC1A1 = new QLineEdit(GroupC1); LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this)); + LineEditC1A1->setMaxLength(-1); QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupC1 ); connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters())); @@ -234,7 +235,7 @@ void SMESHGUI_RemoveNodesDlg::ClickOnApply() bool aResult = false; try { SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - aResult = aMeshEditor->RemoveNodes(anArrayOfIdeces.inout()); + aResult = aMeshEditor->RemoveNodes(anArrayOfIdeces.in()); } catch (const SALOME::SALOME_Exception& S_ex) { SalomeApp_Tools::QtCatchCorbaException(S_ex); myEditCurrentArgument->clear(); @@ -317,9 +318,6 @@ void SMESHGUI_RemoveNodesDlg::onTextChange(const QString& theNewText) myNbOkNodes = 0; - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); - // hilight entered nodes if(myActor){ if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){ @@ -341,12 +339,8 @@ void SMESHGUI_RemoveNodesDlg::onTextChange(const QString& theNewText) } } - if (myNbOkNodes) { - buttonOk->setEnabled(true); - buttonApply->setEnabled(true); - } - myBusy = false; + updateButtons(); } //================================================================================= @@ -355,56 +349,51 @@ void SMESHGUI_RemoveNodesDlg::onTextChange(const QString& theNewText) //================================================================================= void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument() { - if (myBusy) return; - + if (myBusy) return; // busy + if (myFilterDlg && myFilterDlg->isVisible()) return; // filter dlg active + if (!GroupButtons->isEnabled()) return; // inactive + // clear - myNbOkNodes = false; + myNbOkNodes = 0; myActor = 0; myBusy = true; myEditCurrentArgument->setText(""); myBusy = false; - if (!GroupButtons->isEnabled()) // inactive - return; - - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); - // get selected mesh SALOME_ListIO aList; mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); int nbSel = aList.Extent(); - if (nbSel != 1) - return; - - Handle(SALOME_InteractiveObject) anIO = aList.First(); - myMesh = SMESH::GetMeshByIO(anIO); - if (myMesh->_is_nil()) - return; - - myActor = SMESH::FindActorByEntry(anIO->getEntry()); - if (!myActor) - return; - - // get selected nodes - - QString aString = ""; - int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,anIO,aString); - if(nbNodes < 1) - return; - myBusy = true; - myEditCurrentArgument->setText(aString); - myBusy = false; - - // OK - - myNbOkNodes = true; - - buttonOk->setEnabled(true); - buttonApply->setEnabled(true); + if (nbSel == 1) { + + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myMesh = SMESH::GetMeshByIO(anIO); + + if (!myMesh->_is_nil()) { + + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (myActor) { + + // get selected nodes + QString aString = ""; + int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,anIO,aString); + if (nbNodes > 0) { + myBusy = true; + myEditCurrentArgument->setText(aString); + myBusy = false; + + // OK + + myNbOkNodes = nbNodes; + } // if (nbNodes > 0) + } // if (myActor) + } // if (!myMesh->_is_nil()) + } // if (nbSel == 1) + + updateButtons(); } //================================================================================= @@ -531,3 +520,13 @@ void SMESHGUI_RemoveNodesDlg::setFilters() myFilterDlg->show(); } + +//================================================================================= +// function : updateButtons +// purpose : enable / disable control buttons +//================================================================================= +void SMESHGUI_RemoveNodesDlg::updateButtons() +{ + buttonOk->setEnabled(myNbOkNodes > 0); + buttonApply->setEnabled(myNbOkNodes > 0); +} diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h index 866757ef5..2ce8f9e7e 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h @@ -107,6 +107,7 @@ private slots: void ActivateThisDialog(); void onTextChange( const QString& ); void setFilters(); + void updateButtons(); }; #endif // SMESHGUI_REMOVENODESDLG_H