smesh/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx

254 lines
8.7 KiB
C++
Raw Normal View History

2020-05-25 20:14:06 +05:00
// Copyright (C) 2011-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
2020-05-26 13:46:55 +05:00
// SMESH SMESHGUI : GUI for the adaptation in the SMESH component
2020-05-25 20:14:06 +05:00
// File : SMESHGUI_AdaptDlg.cxx
// Author : Gerald NICOLAS, EDF
2020-05-27 20:01:35 +05:00
// SMESH includes
2020-05-26 13:46:55 +05:00
#include "SMESHGUI.h"
2020-05-27 20:01:35 +05:00
#include "SMESHGUI_AdaptDlg.h"
2020-05-26 13:46:55 +05:00
// SALOME GUI includes
2020-05-25 20:14:06 +05:00
#include <SUIT_Desktop.h>
2020-05-27 20:01:35 +05:00
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
2020-05-26 13:46:55 +05:00
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
2020-05-27 14:43:49 +05:00
// HOMARD includes
#include "MonCreateCase.h"
2020-05-27 20:01:35 +05:00
// SALOME KERNEL includes
#include "utilities.h"
#include <SALOME_LifeCycleCORBA.hxx>
2020-05-25 20:14:06 +05:00
//=================================================================================
// function : SMESHGUI_AdaptDlg()
// purpose :
//=================================================================================
SMESHGUI_AdaptDlg::SMESHGUI_AdaptDlg( SMESHGUI* theModule,
2020-05-26 13:46:55 +05:00
int theCommandID,
SMESH::SMESH_Mesh_ptr theMesh )
2020-06-04 20:41:47 +05:00
: mySMESHGUI( theModule )
2020-05-25 20:14:06 +05:00
{
2020-05-28 17:22:10 +05:00
bool ok = action( theCommandID ) ;
2020-05-25 20:14:06 +05:00
}
2020-05-28 17:22:10 +05:00
2020-06-04 20:41:47 +05:00
//=================================================================================
// function : ~SMESHGUI_AdaptDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_AdaptDlg::~SMESHGUI_AdaptDlg()
{
}
2020-05-28 17:22:10 +05:00
/*!
* \brief Pilote les actions d'adaption de maillage
* \param
* \return bool OK/notOK
*/
bool SMESHGUI_AdaptDlg::action (int theCommandID)
//=======================================================================
{
std::cout << "SMESHGUI_AdaptDlg::action avec theCommandID : " << theCommandID << std::endl;
2020-06-04 20:41:47 +05:00
2020-05-28 17:22:10 +05:00
// Preferences
recupPreferences();
2020-06-04 20:41:47 +05:00
2020-05-28 17:22:10 +05:00
// Menus and actions
bool ok = OnGUIEvent (theCommandID) ;
if ( ! ok ) INFOS("Erreur");
return ok ;
}
/*!
* \brief Gets the preferences for the adaptation
* \param
* \return
2020-06-04 20:41:47 +05:00
*
2020-05-28 17:22:10 +05:00
* 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();
2020-06-03 13:23:34 +05:00
SUIT_ResourceMgr* resMgr = mySMESHGUI->getApp()->resourceMgr();
2020-05-28 17:22:10 +05:00
// B. Les valeurs
// B.1. La langue
2020-06-03 13:23:34 +05:00
_LanguageShort = resMgr->stringValue("language", "language", "en" );
INFOS ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() );
2020-06-04 20:41:47 +05:00
// adaptGen->SetLanguageShort(_LanguageShort.toStdString().c_str());
2020-06-03 13:23:34 +05:00
2020-05-28 17:22:10 +05:00
// B.2. Les publications
bool publish_mesh ;
2020-06-03 13:23:34 +05:00
publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_in", false );
2020-05-28 17:22:10 +05:00
if ( publish_mesh ) { _PublisMeshIN = 1 ; }
else { _PublisMeshIN = 0 ; }
2020-06-03 13:23:34 +05:00
publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_out", false );
2020-05-28 17:22:10 +05:00
if ( publish_mesh ) { _PublisMeshOUT = 1 ; }
else { _PublisMeshOUT = 0 ; }
2020-06-03 13:23:34 +05:00
INFOS ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT);
2020-06-04 20:41:47 +05:00
// adaptGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT);
2020-06-03 13:23:34 +05:00
2020-05-28 17:22:10 +05:00
// B.3. Les maximum pour YACS
2020-06-03 13:23:34 +05:00
_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);
2020-06-04 20:41:47 +05:00
// adaptGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem);
2020-06-03 13:23:34 +05:00
2020-05-28 17:22:10 +05:00
// B.4. La convergence pour YACS
2020-06-03 13:23:34 +05:00
QString QString_v = resMgr->stringValue ( "HOMARD", "yacs_type_test", "None" );
2020-05-28 17:22:10 +05:00
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 ; }
2020-06-03 13:23:34 +05:00
2020-05-28 17:22:10 +05:00
INFOS ("Enregistrement de YACSTypeTest = " << _YACSTypeTest);
2020-06-04 20:41:47 +05:00
// adaptGen->SetYACSConvergenceType(_YACSTypeTest);
2020-06-03 13:23:34 +05:00
2020-05-28 17:22:10 +05:00
INFOS("Fin de recupPreferences")
}
2020-05-27 20:01:35 +05:00
/*!
* \brief Launches the GUI for the adaptation
2020-05-28 17:22:10 +05:00
* \param theCommandID - the integer that references the operation
* \return bool OK/notOK
2020-05-27 20:01:35 +05:00
*/
2020-05-27 14:43:49 +05:00
bool SMESHGUI_AdaptDlg::OnGUIEvent (int theCommandID)
{
std::cout << "OnGUIEvent avec theCommandID : " << theCommandID << std::endl;
// A. Controles
2020-05-28 17:22:10 +05:00
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2020-05-27 15:13:20 +05:00
if ( !app ) return false;
2020-05-27 20:01:35 +05:00
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*> ( app->activeStudy() );
if ( !aStudy )
2020-05-27 15:13:20 +05:00
{
2020-05-28 17:22:10 +05:00
INFOS ( "FAILED to cast active study to SalomeApp_Study" );
2020-05-27 15:13:20 +05:00
return false;
}
SUIT_Desktop* parent = SUIT_Session::session()->activeApplication()->desktop();
2020-05-27 20:01:35 +05:00
SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
2020-05-28 17:22:10 +05:00
Engines::EngineComponent_var comp = ls->FindOrLoad_Component("FactoryServer", "SMESH");
2020-05-28 13:48:20 +05:00
ADAPT::ADAPT_Gen_var adaptGen = ADAPT::ADAPT_Gen::_narrow(comp);
if (!CORBA::is_nil(adaptGen))
adaptGen->UpdateStudy();
2020-05-27 20:01:35 +05:00
2020-05-28 17:22:10 +05:00
mySMESHGUI->getApp()->updateObjectBrowser();
2020-05-27 14:43:49 +05:00
//
// B. Choix selon les commandes
2020-06-04 20:41:47 +05:00
bool ok = true ;
2020-05-27 14:43:49 +05:00
SCRUTE(theCommandID);
switch (theCommandID)
{
2020-06-04 20:41:47 +05:00
case 8000: // Raffinement uniforme
{
INFOS("Raffinement uniforme");
// A faire
break;
}
case 8011: // Création d'un Cas
2020-05-27 14:43:49 +05:00
{
2020-06-04 20:41:47 +05:00
INFOS("Création d'un Cas");
2020-05-28 13:40:28 +05:00
MonCreateCase *aDlg = new MonCreateCase( true,
2020-05-28 13:48:20 +05:00
ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ;
2020-05-28 13:40:28 +05:00
aDlg->show();
2020-05-27 14:43:49 +05:00
break;
}
2020-06-04 20:41:47 +05:00
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");
2020-05-27 14:43:49 +05:00
// MonPursueIteration *aDlg = new MonPursueIteration( true,
2020-05-28 13:48:20 +05:00
// ADAPT::ADAPT_Gen::_duplicate(adaptGen) ) ;
2020-05-27 14:43:49 +05:00
// aDlg->show();
// break;
2020-06-04 20:41:47 +05:00
}
case 8013: // Création d'une itération
{
INFOS("Création d'une itération" );
2020-05-27 14:43:49 +05:00
// MonCreateIteration *IterDlg = new MonCreateIteration( parent, true,
2020-05-28 13:48:20 +05:00
// ADAPT::ADAPT_Gen::_duplicate(adaptGen), _ObjectName ) ;
2020-05-27 14:43:49 +05:00
// IterDlg->show();
2020-06-04 20:41:47 +05:00
break;
}
case 8014: // Calcule une itération
{
INFOS("Calcule une itération" );
2020-05-28 13:48:20 +05:00
// try { adaptGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 1); }
2020-05-27 14:43:49 +05:00
// catch( SALOME::SALOME_Exception& S_ex )
// {
// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
// QObject::tr(CORBA::string_dup(S_ex.details.text)) );
2020-05-28 17:22:10 +05:00
// mySMESHGUI->getApp()->updateObjectBrowser();
2020-06-04 20:41:47 +05:00
// ok = false;
2020-05-27 14:43:49 +05:00
// }
2020-06-04 20:41:47 +05:00
break;
}
case 8015: // Calcule une itération et publication
{
INFOS("Calcule une itération et publication");
2020-05-28 13:48:20 +05:00
// try { adaptGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 2); }
2020-05-27 14:43:49 +05:00
// catch( SALOME::SALOME_Exception& S_ex )
// {
// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
// QObject::tr(CORBA::string_dup(S_ex.details.text)) );
2020-05-28 17:22:10 +05:00
// mySMESHGUI->getApp()->updateObjectBrowser();
2020-06-04 20:41:47 +05:00
// ok = false;
2020-05-27 14:43:49 +05:00
// }
2020-06-04 20:41:47 +05:00
break;
2020-05-26 13:46:55 +05:00
}
2020-06-04 20:41:47 +05:00
case 8020: // Adaptation avec MG-Adpat
2020-05-26 13:46:55 +05:00
{
2020-06-04 20:41:47 +05:00
INFOS("Interface avec MG-Adapt" );
// A faire
break;
2020-05-26 13:46:55 +05:00
}
}
2020-06-04 20:41:47 +05:00
mySMESHGUI->getApp()->updateObjectBrowser();
return ok;
2020-05-26 13:46:55 +05:00
}