X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_SmoothingDlg.cxx;h=be2178dbb40557768d5dc032c67c172583e1573c;hb=daa2cf53970e196bfe3c82cfde426f1ccc43e630;hp=c2144b1f4692cbe308d78e0c12aa89792c579e57;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx index c2144b1f4..be2178dbb 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2010 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 @@ -19,6 +19,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_SmoothingDlg.cxx // Author : Michael ZORIN, Open CASCADE S.A.S. @@ -137,8 +138,9 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) LineEditElements = new QLineEdit(GroupArguments); LineEditElements->setValidator(myIdValidator); - QPushButton* filterElemBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); - connect(filterElemBtn, SIGNAL(clicked()), this, SLOT(setElemFilters())); + LineEditElements->setMaxLength(-1); + myElemFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); + connect(myElemFilterBtn, SIGNAL(clicked()), this, SLOT(setElemFilters())); // Control for the whole mesh selection CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments); @@ -151,6 +153,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) LineEditNodes = new QLineEdit(GroupArguments); LineEditNodes->setValidator(myIdValidator); + LineEditNodes->setMaxLength(-1); QPushButton* filterNodeBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments ); connect(filterNodeBtn, SIGNAL(clicked()), this, SLOT(setNodeFilters())); @@ -175,7 +178,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1); GroupArgumentsLayout->addWidget(LineEditElements, 0, 2); - GroupArgumentsLayout->addWidget(filterElemBtn, 0, 3); + GroupArgumentsLayout->addWidget(myElemFilterBtn, 0, 3); GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4); GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0); GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1); @@ -229,7 +232,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) SpinBox_IterationLimit->setRange(1, 999999); SpinBox_IterationLimit->setValue(20); - SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, 3); + SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, "parametric_precision"); SpinBox_AspectRatio->SetValue(1.1); GroupArguments->show(); @@ -365,33 +368,36 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply() if ( CheckBoxParametric->isChecked() ) { if(CheckBoxMesh->isChecked()) - aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(), - anIterationLimit, aMaxAspectRatio, aMethod); - else - aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(), - anIterationLimit, aMaxAspectRatio, aMethod); + aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + else + aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); } else { if(CheckBoxMesh->isChecked()) - aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(), - anIterationLimit, aMaxAspectRatio, aMethod); - else - aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), - anIterationLimit, aMaxAspectRatio, aMethod); + aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + else + aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); } - myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + myMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); } catch (...) { } if (aResult) { - Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + if ( myActor ) { + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + SALOME_ListIO aList; + aList.Append(anIO); + mySelectionMgr->setSelectedObjects(aList, false); + } - SALOME_ListIO aList; - aList.Append(anIO); - mySelectionMgr->setSelectedObjects(aList, false); SMESH::UpdateView(); + SMESHGUI::Modified(); Init(); mySelectedObject = SMESH::SMESH_IDSource::_nil(); @@ -448,10 +454,10 @@ void SMESHGUI_SmoothingDlg::ClickOnHelp() 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)); } } @@ -490,28 +496,28 @@ void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText) const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO(); TColStd_MapOfInteger newIndices; for (int i = 0; i < aListId.count(); i++) { - const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); - if (e) - newIndices.Add(e->GetID()); - myNbOkElements++; + const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); + if (e) + newIndices.Add(e->GetID()); + myNbOkElements++; } mySelector->AddOrRemoveIndex(anIO, newIndices, false); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->highlight( anIO, true, true ); + aViewWindow->highlight( anIO, true, true ); myElementsId = theNewText; } else if (send == LineEditNodes) { TColStd_MapOfInteger newIndices; for (int i = 0; i < aListId.count(); i++) { - const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt()); - if (n) - newIndices.Add(n->GetID()); - myNbOkNodes++; + const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt()); + if (n) + newIndices.Add(n->GetID()); + myNbOkNodes++; } mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->highlight( myActor->getIO(), true, true ); + aViewWindow->highlight( myActor->getIO(), true, true ); } } @@ -564,7 +570,7 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() return; myActor = SMESH::FindActorByObject(myMesh); - if (!myActor) + if (!myActor && !CheckBoxMesh->isChecked()) return; int aNbUnits = 0; @@ -600,9 +606,9 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() // OK if (myEditCurrentArgument == LineEditElements) - myNbOkElements = aNbUnits; + myNbOkElements = true; else if (myEditCurrentArgument == LineEditNodes) - myNbOkNodes = aNbUnits; + myNbOkNodes = true; if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) { buttonOk->setEnabled(true); @@ -629,21 +635,21 @@ void SMESHGUI_SmoothingDlg::SetEditCurrentArgument() myEditCurrentArgument = LineEditElements; SMESH::SetPointRepresentation(false); if (CheckBoxMesh->isChecked()) { - // mySelectionMgr->setSelectionModes(ActorSelection); - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(ActorSelection); - mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); + // mySelectionMgr->setSelectionModes(ActorSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); + mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter); } else { - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) - aViewWindow->SetSelectionMode(FaceSelection); - } + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); + } } else if (send == SelectNodesButton) { - LineEditNodes->clear(); + LineEditNodes->clear(); myEditCurrentArgument = LineEditNodes; SMESH::SetPointRepresentation(true); - if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) { - aViewWindow->SetSelectionMode(NodeSelection); - } + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) { + aViewWindow->SetSelectionMode(NodeSelection); + } } myEditCurrentArgument->setFocus(); @@ -727,6 +733,7 @@ void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh) TextLabelElements->setText(tr("SMESH_NAME")); else TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); + myElemFilterBtn->setEnabled(!toSelectMesh); if (myEditCurrentArgument != LineEditElements && myEditCurrentArgument != LineEditNodes) { @@ -779,6 +786,12 @@ void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e ) //================================================================================= void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem ) { + if(myMesh->_is_nil()) { + SUIT_MessageBox::critical(this, + tr("SMESH_ERROR"), + tr("NO_MESH_SELECTED")); + return; + } if ( !myFilterDlg ) { QList types;