Salome HOME
Item Delete in pop-up of link on hypotheses or algorithm doesn't work.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SmoothingDlg.cxx
index 4b9134bc35fb603a0ff5ce1dfc2605021a60ec34..8090b5455852514bcf0725e393f8601ee76649e4 100644 (file)
@@ -123,6 +123,8 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
   GroupArgumentsLayout->setSpacing(SPACING);
   GroupArgumentsLayout->setMargin(MARGIN);
 
+  myIdValidator = new SMESHGUI_IdValidator(this);
+
   // Controls for elements selection
   TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
 
@@ -130,7 +132,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
   SelectElementsButton->setIcon(image1);
 
   LineEditElements = new QLineEdit(GroupArguments);
-  LineEditElements->setValidator(new SMESHGUI_IdValidator(this));
+  LineEditElements->setValidator(myIdValidator);
 
   // Control for the whole mesh selection
   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
@@ -142,7 +144,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
   SelectNodesButton->setIcon(image1);
 
   LineEditNodes  = new QLineEdit(GroupArguments);
-  LineEditNodes->setValidator(new SMESHGUI_IdValidator(this));
+  LineEditNodes->setValidator(myIdValidator);
 
   // Controls for method selection
   TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments);
@@ -183,7 +185,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
   GroupButtonsLayout->setSpacing(SPACING);
   GroupButtonsLayout->setMargin(MARGIN);
 
-  buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons);
+  buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
   buttonOk->setAutoDefault(true);
   buttonOk->setDefault(true);
   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
@@ -309,8 +311,7 @@ void SMESHGUI_SmoothingDlg::ClickOnApply()
   if (mySMESHGUI->isActiveStudyLocked())
     return;
 
-  if (myNbOkElements &&
-      (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
+  if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
     QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
     QStringList aListNodesId    = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
 
@@ -321,7 +322,7 @@ void SMESHGUI_SmoothingDlg::ClickOnApply()
     for (int i = 0; i < aListElementsId.count(); i++)
       anElementsId[i] = aListElementsId[i].toInt();
 
-    if (myNbOkNodes) {
+    if ( myNbOkNodes && aListNodesId.count() > 0 ) {
       aNodesId->length(aListNodesId.count());
       for (int i = 0; i < aListNodesId.count(); i++)
         aNodesId[i] = aListNodesId[i].toInt();
@@ -338,15 +339,15 @@ void SMESHGUI_SmoothingDlg::ClickOnApply()
 
     bool aResult = false;
     try {
+      SUIT_OverrideCursor aWaitCursor;
       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
-      QApplication::setOverrideCursor(Qt::WaitCursor);
+
       if ( CheckBoxParametric->isChecked() )
        aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
                                                anIterationLimit, aMaxAspectRatio, aMethod);
       else
        aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
                                      anIterationLimit, aMaxAspectRatio, aMethod);
-      QApplication::restoreOverrideCursor();
     } catch (...) {
     }
 
@@ -490,7 +491,6 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
   if (myBusy) return;
 
   // clear
-  myActor = 0;
   QString aString = "";
 
   myBusy = true;
@@ -499,6 +499,7 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
     myNbOkElements = 0;
     buttonOk->setEnabled(false);
     buttonApply->setEnabled(false);
+    myActor = 0;
   }
   myBusy = false;
 
@@ -591,7 +592,7 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
   else if (myEditCurrentArgument == LineEditNodes)
     myNbOkNodes = true;
 
-  if (myNbOkElements) {
+  if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
     buttonOk->setEnabled(true);
     buttonApply->setEnabled(true);
   }
@@ -616,17 +617,21 @@ void SMESHGUI_SmoothingDlg::SetEditCurrentArgument()
         myEditCurrentArgument = LineEditElements;
         SMESH::SetPointRepresentation(false);
         if (CheckBoxMesh->isChecked()) {
-          mySelectionMgr->setSelectionModes(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(CellSelection);
+           aViewWindow->SetSelectionMode(FaceSelection);
        }
-      }        else if (send == SelectNodesButton) {
+      } else if (send == SelectNodesButton) {
+       LineEditNodes->clear();
         myEditCurrentArgument = LineEditNodes;
         SMESH::SetPointRepresentation(true);
-       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
          aViewWindow->SetSelectionMode(NodeSelection);
+       }
       }
 
       myEditCurrentArgument->setFocus();
@@ -666,7 +671,7 @@ void SMESHGUI_SmoothingDlg::ActivateThisDialog()
 
   mySMESHGUI->SetActiveDialogBox(this);
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-    aViewWindow->SetSelectionMode(CellSelection);
+    aViewWindow->SetSelectionMode(FaceSelection);
   SelectionIntoArgument();
 }
 
@@ -720,13 +725,17 @@ void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh)
   SMESH::SetPointRepresentation(false);
 
   if (toSelectMesh) {
-    mySelectionMgr->setSelectionModes(ActorSelection);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(ActorSelection);
+    //    mySelectionMgr->setSelectionModes(ActorSelection);
     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
     LineEditElements->setReadOnly(true);
+    LineEditElements->setValidator(0);
   } else {
     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-      aViewWindow->SetSelectionMode(CellSelection);
+      aViewWindow->SetSelectionMode(FaceSelection);
     LineEditElements->setReadOnly(false);
+    LineEditElements->setValidator(myIdValidator);
     onTextChange(LineEditElements->text());
   }