Salome HOME
Merge remote-tracking branch 'origin/master' into gni/adaptation
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_AdaptDlg.cxx
index a83311fdf7375b4fc3ff5dcd8d42e15cf4549c02..90dff1ad325d09f9686426c673981824fd5836c1 100644 (file)
@@ -24,6 +24,8 @@
 //  SMESH includes
 #include "SMESHGUI.h"
 #include "SMESHGUI_AdaptDlg.h"
+#include "SMESHGUI_MG_ADAPTDRIVER.h"
+#include "MG_ADAPT.hxx"
 
 // SALOME GUI includes
 #include <SUIT_Desktop.h>
@@ -33,7 +35,7 @@
 #include <SalomeApp_Study.h>
 
 // HOMARD includes
-#include "MonCreateCase.h"
+// #include "MonCreateCase.h"
 
 // SALOME KERNEL includes
 #include "utilities.h"
@@ -48,7 +50,7 @@ SMESHGUI_AdaptDlg::SMESHGUI_AdaptDlg( SMESHGUI* theModule,
                                       SMESH::SMESH_Mesh_ptr theMesh )
   : mySMESHGUI( theModule )
 {
-  bool ok = action( theCommandID ) ;
+  action( theCommandID ) ;
 }
 
 //=================================================================================
@@ -64,88 +66,87 @@ SMESHGUI_AdaptDlg::~SMESHGUI_AdaptDlg()
   * \param
   * \return bool OK/notOK
 */
-bool SMESHGUI_AdaptDlg::action (int theCommandID)
+void SMESHGUI_AdaptDlg::action (int theCommandID)
 //=======================================================================
 {
   std::cout  << "SMESHGUI_AdaptDlg::action avec theCommandID : " << theCommandID << std::endl;
 
 // Preferences
-  recupPreferences();
+//   recupPreferences();
 
 // Menus and actions
   bool ok =  OnGUIEvent (theCommandID) ;
   if ( ! ok ) INFOS("Erreur");
 
-  return ok ;
+  return ;
 }
 
-/*!
-  * \brief Gets the preferences for the adaptation
-  * \param
-  * \return
-  *
-  * Pour chaque valeur, le defaut est la valeur definie dans ADAPT_Gen
-  * . Si la recuperation dans config/salome s'est bien passee a la creation de ADAPT_Gen
-  *   ces valeurs sont les valeurs definies.
-  * . Si cela ne s'est pas bien passe, ce sont les valeurs par defaut de ADAPT_Gen
-*/
-void SMESHGUI_AdaptDlg::recupPreferences()
-{
-  INFOS("Début de recupPreferences")
+// /*!
+//   * \brief Gets the preferences for the adaptation
+//   * \param
+//   * \return
+//   *
+//   * Pour chaque valeur, le defaut est la valeur definie dans ADAPT_Gen
+//   * . Si la recuperation dans config/salome s'est bien passee a la creation de ADAPT_Gen
+//   *   ces valeurs sont les valeurs definies.
+//   * . Si cela ne s'est pas bien passe, ce sont les valeurs par defaut de ADAPT_Gen
+// */
+// void SMESHGUI_AdaptDlg::recupPreferences()
+// {
+//   INFOS("Début de recupPreferences")
+// //
+// // A. Declarations
+// //
+//   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+//   SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
+//   Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH");
+//   ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
+//   if (!CORBA::is_nil(adaptGen))
+//     adaptGen->UpdateStudy();
 //
-// A. Declarations
+//   SUIT_ResourceMgr* resMgr = mySMESHGUI->getApp()->resourceMgr();
 //
-  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
-  SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
-  Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH");
-  ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
-  if (!CORBA::is_nil(adaptGen))
-    adaptGen->UpdateStudy();
-
-  SUIT_ResourceMgr* resMgr = mySMESHGUI->getApp()->resourceMgr();
-
-// B. Les valeurs
-// B.1. La langue
-
-  _LanguageShort = resMgr->stringValue("language", "language", "en" );
-  INFOS ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() );
-//   adaptGen->SetLanguageShort(_LanguageShort.toStdString().c_str());
-
-// B.2. Les publications
-  bool publish_mesh ;
-
-  publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_in", false );
-  if ( publish_mesh ) { _PublisMeshIN = 1 ; }
-  else                { _PublisMeshIN = 0 ; }
-
-  publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_out", false );
-  if ( publish_mesh ) { _PublisMeshOUT = 1 ; }
-  else                { _PublisMeshOUT = 0 ; }
-
-  INFOS ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT);
-//   adaptGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT);
-
-// B.3. Les maximum pour YACS
-
-  _YACSMaxIter = resMgr->integerValue("HOMARD", "yacs_max_iter", 0 );
-  _YACSMaxNode = resMgr->integerValue("HOMARD", "yacs_max_node", 0 );
-  _YACSMaxElem = resMgr->integerValue("HOMARD", "yacs_max_elem", 0 );
-
-  INFOS ("Enregistrement de YACSMaxIter = " << _YACSMaxIter<<", YACSMaxNode = "<< _YACSMaxNode<<", YACSMaxElem = "<< _YACSMaxElem);
-//   adaptGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem);
-
-// B.4. La convergence pour YACS
-
-  QString QString_v = resMgr->stringValue ( "HOMARD", "yacs_type_test", "None" );
-  if ( ( QString_v == "VTest > VRef" ) || ( QString_v == "VTest &gt; VRef" ) )      { _YACSTypeTest = 1 ; }
-  else if ( ( QString_v == "VTest < VRef" ) || ( QString_v == "VTest &lt; VRef" ) ) { _YACSTypeTest = 2 ; }
-  else                                                                              { _YACSTypeTest = 0 ; }
-
-  INFOS ("Enregistrement de YACSTypeTest = " << _YACSTypeTest);
-//   adaptGen->SetYACSConvergenceType(_YACSTypeTest);
-
-  INFOS("Fin de recupPreferences")
-}
+// // B. Les valeurs
+// // B.1. La langue
+//
+//   _LanguageShort = resMgr->stringValue("language", "language", "en" );
+//   INFOS ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() );
+// //   adaptGen->SetLanguageShort(_LanguageShort.toStdString().c_str());
+//
+// // B.2. Les publications avec HOMARD
+//   bool publish_mesh ;
+//
+//   publish_mesh = resMgr->booleanValue("HOMARD", "homard_publish_mesh_in", false );
+//   if ( publish_mesh ) { _PublisMeshIN = 1 ; }
+//   else                { _PublisMeshIN = 0 ; }
+//
+//   publish_mesh = resMgr->booleanValue("HOMARD", "homard_publish_mesh_out", false );
+//   if ( publish_mesh ) { _PublisMeshOUT = 1 ; }
+//   else                { _PublisMeshOUT = 0 ; }
+//
+//   INFOS ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT);
+// //   adaptGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT);
+//
+// // B.3. Les maximum pour YACS avec HOMARD
+//
+//   _YACSMaxIter = resMgr->integerValue("HOMARD", "homard_yacs_max_iter", 0 );
+//   _YACSMaxNode = resMgr->integerValue("HOMARD", "homard_yacs_max_node", 0 );
+//   _YACSMaxElem = resMgr->integerValue("HOMARD", "homard_yacs_max_elem", 0 );
+//
+//   INFOS ("Enregistrement de YACSMaxIter = " << _YACSMaxIter<<", YACSMaxNode = "<< _YACSMaxNode<<", YACSMaxElem = "<< _YACSMaxElem);
+// //   adaptGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem);
+//
+// // B.4. La convergence pour YACS avec HOMARD
+//
+//   QString QString_v = resMgr->stringValue ( "HOMARD", "homard_yacs_type_test", "None" );
+//   if ( ( QString_v == "VTest > VRef" ) || ( QString_v == "VTest &gt; VRef" ) )      { _YACSTypeTest = 1 ; }
+//   else if ( ( QString_v == "VTest < VRef" ) || ( QString_v == "VTest &lt; VRef" ) ) { _YACSTypeTest = 2 ; }
+//   else                                                                              { _YACSTypeTest = 0 ; }
+//
+//   INFOS ("Enregistrement de YACSTypeTest = " << _YACSTypeTest);
+// //   adaptGen->SetYACSConvergenceType(_YACSTypeTest);
+//
+// }
 
 /*!
   * \brief Launches the GUI for the adaptation
@@ -170,9 +171,9 @@ bool SMESHGUI_AdaptDlg::OnGUIEvent (int theCommandID)
 
   SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
   Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH");
-  ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
-  if (!CORBA::is_nil(adaptGen))
-    adaptGen->UpdateStudy();
+//   ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
+//   if (!CORBA::is_nil(adaptGen))
+//     adaptGen->UpdateStudy();
 
   mySMESHGUI->getApp()->updateObjectBrowser();
 //
@@ -190,57 +191,47 @@ bool SMESHGUI_AdaptDlg::OnGUIEvent (int theCommandID)
     case 8011: // Création d'un Cas
     {
       INFOS("Création d'un Cas");
-      MonCreateCase *aDlg = new MonCreateCase( true,
-                            ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ;
-      aDlg->show();
+//       MonCreateCase *aDlg = new MonCreateCase( true,
+//                             ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ;
+//       aDlg->show();
       break;
     }
     case 8012: // Création d'un cas en poursuite d'une itération
     {
       INFOS("Création d'un cas en poursuite d'une itération");
-//       MonPursueIteration *aDlg = new MonPursueIteration( true,
-//                                 ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ;
-//       aDlg->show();
-//       break;
+//       A faire
+      break;
     }
     case 8013: // Création d'une itération
     {
       INFOS("Création d'une itération" );
-//       MonCreateIteration *IterDlg = new MonCreateIteration( parent, true,
-//                                      ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName ) ;
-//       IterDlg->show();
+//       A faire
       break;
     }
     case 8014: // Calcule une itération
     {
       INFOS("Calcule une itération" );
-//       try { adaptGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 1); }
-//       catch( SALOME::SALOME_Exception& S_ex )
-//       {
-//         QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
-//                                   QObject::tr(CORBA::string_dup(S_ex.details.text)) );
-//         mySMESHGUI->getApp()->updateObjectBrowser();
-//         ok = false;
-//       }
+//       A faire
       break;
     }
     case 8015: // Calcule une itération et publication
     {
       INFOS("Calcule une itération et publication");
-//       try { adaptGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 2); }
-//       catch( SALOME::SALOME_Exception& S_ex )
-//       {
-//         QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
-//                                   QObject::tr(CORBA::string_dup(S_ex.details.text)) );
-//         mySMESHGUI->getApp()->updateObjectBrowser();
-//         ok = false;
-//       }
+//       A faire
       break;
     }
     case 8020: // Adaptation avec MG-Adpat
     {
       INFOS("Interface avec MG-Adapt" );
 //       A faire
+
+      MgAdapt* model = new MgAdapt();
+      bool isCreation = false;
+         if (mySMESHGUI->isStudyLocked()) break;
+      mySMESHGUI->EmitSignalDeactivateDialog();
+      SMESHGUI_MG_ADAPTDRIVER *mgAdapt = new SMESHGUI_MG_ADAPTDRIVER(mySMESHGUI, model, isCreation);
+      mgAdapt->show();
+      delete model;
       break;
     }