Salome HOME
Clean up of cout replaced by MESSAGE + minor corrections
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_CreateDualMeshOp.cxx
index 25f811700069ad11c3332ceeaeabdedd7034a5aa..c0fed0340de1e63fd79e8614e45f15864c9269f7 100644 (file)
 #include <SUIT_MessageBox.h>
 #include <SUIT_OverrideCursor.h>
 #include <SalomeApp_Tools.h>
+#include <SalomeApp_Application.h>
 #include <SALOME_Actor.h>
 
+// Qt includes
+#include <QLineEdit>
+#include <QCheckBox>
+
 // IDL includes
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
@@ -145,11 +150,15 @@ void SMESHGUI_CreateDualMeshOp::selectionDone()
     {
       SMESH::SMESH_subMesh_var subMesh =
         SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pObj );
-      // TODO: Check that mesh is only tetra
+      // Check that mesh is only tetra
       if (!checkMesh(idSource)){
         myDlg->ShowWarning( true );
+        myDlg->setButtonEnabled(false, QtxDialog::OK|QtxDialog::Apply);
       }
     }
+    std::string mesh_name = "dual_" + pObj->GetName();
+    myDlg->myMeshName->setText(QString(mesh_name.c_str()));
+
   }
   catch ( const SALOME::SALOME_Exception& S_ex )
   {
@@ -158,6 +167,7 @@ void SMESHGUI_CreateDualMeshOp::selectionDone()
   catch ( ... )
   {
   }
+
 }
 
 //================================================================================
@@ -217,13 +227,11 @@ bool SMESHGUI_CreateDualMeshOp::onApply()
   bool aResult = false;
   SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
   SMESH::SMESH_Mesh_var newMesh;
-  QByteArray newMeshName="MESH_DUAL";
+  QByteArray newMeshName=myDlg->myMeshName->text().toUtf8();
+  bool adapt_to_shape=myDlg->myProjShape->isChecked();
   try
   {
-    // TODO: Call the python script using medcoupling
-    // String to run medcoupling dual
-    // TODO: change name as previous name + "_dual"
-    newMesh = gen->CreateDualMesh(mesh, newMeshName.constData());
+    newMesh = gen->CreateDualMesh(mesh, newMeshName.constData(), adapt_to_shape);
 
     if ( !newMesh->_is_nil() )
       if ( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
@@ -246,10 +254,11 @@ bool SMESHGUI_CreateDualMeshOp::onApply()
   if( aResult )
   {
     SMESHGUI::Modified();
-    update( UF_ObjBrowser | UF_Model | UF_Viewer );
     selectionDone();
-  }
+    update( UF_ObjBrowser | UF_Model | UF_Viewer );
 
+  }
+  SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
 
   // updateObjBrowser(true);
   // SMESHGUI::Modified();