Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SmoothingDlg.cxx
index d824e32ac0e065b3a0f37c97868446108bc559f9..3b83752eb5c1527da99d5cd4aa3784380eb804ad 100644 (file)
@@ -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.
@@ -229,7 +230,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,19 +366,19 @@ 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( aParameters.join(":").toLatin1().constData() );
@@ -386,11 +387,13 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply()
     }
 
     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();
       Init();
 
@@ -448,10 +451,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 +493,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 +567,7 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
     return;
 
   myActor = SMESH::FindActorByObject(myMesh);
-  if (!myActor)
+  if (!myActor && !CheckBoxMesh->isChecked())
     return;
 
   int aNbUnits = 0;
@@ -629,21 +632,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();
@@ -782,8 +785,8 @@ void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem )
 {
   if(myMesh->_is_nil()) {
     SUIT_MessageBox::critical(this,
-                             tr("SMESH_ERROR"),
-                             tr("NO_MESH_SELECTED"));
+                              tr("SMESH_ERROR"),
+                              tr("NO_MESH_SELECTED"));
    return;
   }
   if ( !myFilterDlg )