Salome HOME
Merge from BR_DumpPython_Extension branch (from tag mergeto_BR_V5_Dev_28Jan09)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_NodesDlg.cxx
index 4718dce509aaa483dc500b0759c72bd6b3fa502a..38869ceddb5f899eff69e34afbf1794f092d6fd9 100644 (file)
 
 namespace SMESH
 {
-  void AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z )
+  void AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z, const QStringList& theParameters )
   {
     SUIT_OverrideCursor wc;
     try {
       _PTR(SObject) aSobj = SMESH::FindSObject( theMesh );
       SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
       aMeshEditor->AddNode( x, y, z );
+      theMesh->SetParameters( SMESHGUI::JoinObjectParameters(theParameters) );
       _PTR(Study) aStudy = GetActiveStudyDocument();
       CORBA::Long anId = aStudy->StudyId();
       if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( anId, aSobj->GetID().c_str() ) ) {
@@ -400,12 +401,21 @@ bool SMESHGUI_NodesDlg::ClickOnApply()
     return false;
   }
 
+  if( !isValid() )
+    return false;
+
   /* Recup args and call method */
   double x = SpinBox_X->GetValue();
   double y = SpinBox_Y->GetValue();
   double z = SpinBox_Z->GetValue();
+
+  QStringList aParameters;
+  aParameters << SpinBox_X->text();
+  aParameters << SpinBox_Y->text();
+  aParameters << SpinBox_Z->text();
+
   mySimulation->SetVisibility( false );
-  SMESH::AddNode( myMesh, x, y, z );
+  SMESH::AddNode( myMesh, x, y, z, aParameters );
   SMESH::SetPointRepresentation( true );
 
   // select myMesh
@@ -591,3 +601,25 @@ void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e )
     ClickOnHelp();
   }
 }
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+bool SMESHGUI_NodesDlg::isValid()
+{
+  QString msg;
+  bool ok = true;
+  ok = SpinBox_X->isValid( msg, true ) && ok;
+  ok = SpinBox_Y->isValid( msg, true ) && ok;
+  ok = SpinBox_Z->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;
+}