Salome HOME
Dump Python extension
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ExtrusionDlg.cxx
index e09419d7ada986b2431cdde66baeda1fed354fd4..83e18035a241c58bf912b98e4d8d3408ce97d764 100644 (file)
@@ -52,6 +52,8 @@
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
 
+#include <SalomeApp_IntSpinBox.h>
+
 // OCCT includes
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
@@ -65,7 +67,6 @@
 #include <QPushButton>
 #include <QRadioButton>
 #include <QCheckBox>
-#include <QSpinBox>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
 #include <QGridLayout>
@@ -177,7 +178,7 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
 
   // Controls for nb. steps defining
   TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
-  SpinBox_NbSteps = new QSpinBox(GroupArguments);
+  SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupArguments);
 
   // CheckBox for groups generation
   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
@@ -359,6 +360,9 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
   if (mySMESHGUI->isActiveStudyLocked())
     return false;
 
+  if (!isValid())
+    return false;
+
   if (myNbOkElements) {
 
     SMESH::DirStruct aVector;
@@ -368,6 +372,12 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
 
     long aNbSteps = (long)SpinBox_NbSteps->value();
 
+    QStringList aParameters;
+    aParameters << SpinBox_Dx->text();
+    aParameters << SpinBox_Dy->text();
+    aParameters << SpinBox_Dz->text();
+    aParameters << SpinBox_NbSteps->text();
+
     try {
       SUIT_OverrideCursor aWaitCursor;
       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
@@ -378,6 +388,8 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
       else
         aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
 
+      myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
+
     } catch (...) {
     }
 
@@ -755,3 +767,26 @@ void SMESHGUI_ExtrusionDlg::keyPressEvent( QKeyEvent* e )
     ClickOnHelp();
   }
 }
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+bool SMESHGUI_ExtrusionDlg::isValid()
+{
+  QString msg;
+  bool ok = true;
+  ok = SpinBox_Dx->isValid( msg, true ) && ok;
+  ok = SpinBox_Dy->isValid( msg, true ) && ok;
+  ok = SpinBox_Dz->isValid( msg, true ) && ok;
+  ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
+
+  if( !ok ) {
+    QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+    if ( !msg.isEmpty() )
+      str += "\n" + msg;
+    SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
+    return false;
+  }
+  return true;
+}