From bb0c73cad0102749536b3ca64f0423f05dfce3df Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=A9rald=20NICOLAS?= Date: Mon, 25 May 2020 17:14:06 +0200 Subject: [PATCH] Dialogue pour l'adaptation --- src/SMESHGUI/CMakeLists.txt | 2 + src/SMESHGUI/SMESHGUI.cxx | 5 +- src/SMESHGUI/SMESHGUI_AdaptDlg.cxx | 911 +++++++++++++++++++++++++++++ src/SMESHGUI/SMESHGUI_AdaptDlg.h | 107 ++++ 4 files changed, 1023 insertions(+), 2 deletions(-) create mode 100644 src/SMESHGUI/SMESHGUI_AdaptDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_AdaptDlg.h diff --git a/src/SMESHGUI/CMakeLists.txt b/src/SMESHGUI/CMakeLists.txt index c0252dca4..9797f9199 100644 --- a/src/SMESHGUI/CMakeLists.txt +++ b/src/SMESHGUI/CMakeLists.txt @@ -146,6 +146,7 @@ SET(_moc_HEADERS SMESHGUI_SplitBiQuad.h SMESHGUI_IdPreview.h SMESHGUI_PreVisualObj.h + SMESHGUI_AdaptDlg.h ) # header files / no moc processing @@ -261,6 +262,7 @@ SET(_other_SOURCES SMESHGUI_SplitBiQuad.cxx SMESHGUI_PreVisualObj.cxx SMESHGUI_IdPreview.cxx + SMESHGUI_AdaptDlg.cxx ) # sources / to compile diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 18ce3d638..d81a58941 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -30,6 +30,7 @@ // SMESH includes #include "SMESHGUI.h" +#include "SMESHGUI_AdaptDlg.h" #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h" #include "SMESHGUI_AddMeshElementDlg.h" #include "SMESHGUI_AddQuadraticElementDlg.h" @@ -94,7 +95,6 @@ #include "SMESHGUI_TransparencyDlg.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" -#include "ADAPTGUI.h" #include "SMESH_version.h" @@ -5920,7 +5920,8 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const case SMESHOp::OpHOEdit: case SMESHOp::OpHODelete: case SMESHOp::OpMGAdapt: -// op = new ADAPTGUI( id ); + SMESHGUI_GroupDlg *aDlg = new SMESHGUI_AdaptDlg( this, id); + aDlg->show(); break; case SMESHOp::OpConvertMeshToQuadratic: op = new SMESHGUI_ConvToQuadOp(); diff --git a/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx b/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx new file mode 100644 index 000000000..c279949db --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AdaptDlg.cxx @@ -0,0 +1,911 @@ +// 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 +// + +// SMESH SMESHGUI : GUI for the adaptation in the SMESH component +// File : SMESHGUI_AdaptDlg.cxx +// Author : Gerald NICOLAS, EDF +// ADAPTGUI includes +// +#include "SMESHGUI_AdaptDlg.h" + +// SALOME Includes +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include +#include +#include +#include +#include +#include "SUIT_ViewWindow.h" +#include "SUIT_ViewManager.h" + +#include "CAM_Module.h" +#include "OB_Browser.h" + +#include "SALOME_ListIO.hxx" + +#include "SalomeApp_Application.h" +#include "SalomeApp_DataModel.h" +#include "SalomeApp_Study.h" +#include "LightApp_SelectionMgr.h" +#include "LightApp_Selection.h" +#include +#include "SalomeApp_Module.h" +#include "SALOMEconfig.h" +#include + +#include + + +// QT Includes +#include +#include "MonCreateCase.h" +#include "MonCreateIteration.h" +#include "MonPursueIteration.h" +#include "MonCreateYACS.h" +#include "MonEditBoundaryCAO.h" +#include "MonEditBoundaryAn.h" +#include "MonEditBoundaryDi.h" +#include "MonEditCase.h" +#include "MonEditHypothesis.h" +#include "MonEditIteration.h" +#include "MonEditYACS.h" +#include "MonEditZone.h" +#include "MonMeshInfo.h" +#include "MonIterInfo.h" +#include "MonEditFile.h" +#include "HomardQtCommun.h" + +// BOOST Includes +#include + +//Pour le _CAST +#include "SALOMEDS_Study.hxx" +#include "HOMARDGUI_Utils.h" + +using namespace std; + +static CORBA::ORB_var _orb; + +//================================================================================= +// function : SMESHGUI_AdaptDlg() +// purpose : +//================================================================================= +SMESHGUI_AdaptDlg::SMESHGUI_AdaptDlg( SMESHGUI* theModule, + int theCommandID ) +{ +} +//======================================================================= +// function : ~SMESHGUI_AdaptDlg() +// purpose : Destructor +//======================================================================= +SMESHGUI_AdaptDlg::~SMESHGUI_AdaptDlg() +{ +} + +// //======================================================================= +// // function : InitHOMARDGen +// // launch HOMARD component and return a handle +// //======================================================================= +// HOMARD::HOMARD_Gen_var SMESHGUI_AdaptDlg::InitHOMARDGen(SalomeApp_Application* app) +// { +// Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","HOMARD" ); +// HOMARD::HOMARD_Gen_var clr = HOMARD::HOMARD_Gen::_narrow(comp); +// ASSERT(!CORBA::is_nil(clr)); +// return clr; +// } +// +// //======================================================================= +// // Module's initialization +// void SMESHGUI_AdaptDlg::initialize( CAM_Application* app ) +// //======================================================================= +// { +// SalomeApp_Module::initialize( app ); +// InitHOMARDGen(dynamic_cast( app )); +// anId = 0; +// // createActions(); +// // createMenus(); +// recupPreferences(); +// } +// +// // //================================================ +// // // function : createHOMARDAction +// // // create an item in status bar and Homard menu +// // //================================================ +// // void SMESHGUI_AdaptDlg::createHOMARDAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle ) +// // { +// // // MESSAGE("createHOMARDAction"); +// // QIcon icon; +// // QWidget* parent = application()->desktop(); +// // SUIT_ResourceMgr* resMgr = application()->resourceMgr(); +// // QPixmap pix; +// // if ( icon_id.length() ) +// // pix = resMgr->loadPixmap( "HOMARD", tr( icon_id .toLatin1().data()) ); +// // else +// // pix = resMgr->loadPixmap( "HOMARD", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data()), false ); +// // if ( !pix.isNull() ) +// // icon = QIcon( pix ); +// // +// // QString tooltip = tr(QString( "HOM_TOP_%1" ).arg( po_id ).toLatin1().data()), +// // menu = tr(QString( "HOM_MEN_%1" ).arg( po_id ).toLatin1().data()), +// // status_bar = tr(QString( "HOM_STB_%1" ).arg( po_id ).toLatin1().data()); +// // +// // createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) ); +// // } +// +// // //================================================ +// // // function : createAction +// // // constructs Homard menu +// // // calls createHOMARDAction for each item +// // //================================================ +// // void SMESHGUI_AdaptDlg::createActions(){ +// // // +// // createHOMARDAction( 8011, "NEW_CASE", "cas_calcule.png" ); +// // createHOMARDAction( 8012, "PURSUE_ITERATION", "iter_poursuite.png" ); +// // createHOMARDAction( 8013, "NEW_ITERATION", "iter_next.png" ); +// // createHOMARDAction( 8014, "COMPUTE", "mesh_compute.png" ); +// // createHOMARDAction( 8015, "COMPUTE_PUBLISH", "mesh_compute.png" ); +// // createHOMARDAction( 1121, "MESH_INFO", "advanced_mesh_info.png" ); +// // createHOMARDAction( 1131, "MESH_PUBLICATION", "mesh_tree_mesh.png" ); +// // // +// // createHOMARDAction( 8016, "EDIT", "loop.png" ); +// // createHOMARDAction( 8017, "DELETE", "delete.png" ); +// // // +// // createHOMARDAction( 1301, "MESH_INFO", "advanced_mesh_info.png" ); +// // createHOMARDAction( 1302, "EDIT_MESS_FILE", "texte.png" ); +// // // +// // createHOMARDAction( 1401, "YACS", "table_view.png" ); +// // // +// // } +// +// //================================================ +// // function : createPreferences +// //================================================ +// void SMESHGUI_AdaptDlg::createPreferences() +// { +// MESSAGE("createPreferences") +// +// int Onglet, Bloc, Pref ; +// // 1. Generalites +// Onglet = addPreference( tr( "PREF_TAB_GENERAL" ) ); +// // Onglet = addPreference( tr( "PREF_TAB_SETTINGS" ) ) ; +// +// Bloc = addPreference( tr( "PREF_PUBLICATION" ), Onglet ); +// setPreferenceProperty( Bloc, "columns", 1 ); +// +// Pref = addPreference( tr( "PREF_PUBLICATION_MAILLAGE_IN" ), Bloc, LightApp_Preferences::Bool, "HOMARD", "publish_mesh_in" ); +// +// Pref = addPreference( tr( "PREF_PUBLICATION_MAILLAGE_OUT" ), Bloc, LightApp_Preferences::Bool, "HOMARD", "publish_mesh_out" ); +// +// // 2. YACS +// Onglet = addPreference( tr( "PREF_YACS" ) ) ; +// +// Bloc = addPreference( tr( "PREF_YACS_MAX" ), Onglet ); +// setPreferenceProperty( Bloc, "columns", 1 ); +// +// Pref = addPreference( tr( "PREF_YACS_MAX_ITER" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_iter" ); +// setPreferenceProperty( Pref, "min", 0 ); +// setPreferenceProperty( Pref, "max", 100000000 ); +// setPreferenceProperty( Pref, "step", 1 ); +// +// Pref = addPreference( tr( "PREF_YACS_MAX_NODE" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_node" ); +// setPreferenceProperty( Pref, "min", 0 ); +// setPreferenceProperty( Pref, "max", 100000000 ); +// setPreferenceProperty( Pref, "step", 1000 ); +// +// Pref = addPreference( tr( "PREF_YACS_MAX_ELEM" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_elem" ); +// setPreferenceProperty( Pref, "min", 0 ); +// setPreferenceProperty( Pref, "max", 100000000 ); +// setPreferenceProperty( Pref, "step", 1000 ); +// +// Bloc = addPreference( tr( "PREF_YACS_CONVERGENCE" ), Onglet ); +// setPreferenceProperty( Bloc, "columns", 1 ); +// +// Pref = addPreference( tr( "PREF_YACS_TYPE_TEST" ), Bloc, LightApp_Preferences::Selector, "HOMARD", "yacs_type_test" ); +// QStringList aListOfTypeTest; +// aListOfTypeTest << "None"; +// aListOfTypeTest << "VTest > VRef"; +// aListOfTypeTest << "VTest < VRef"; +// setPreferenceProperty( Pref, "strings", aListOfTypeTest ); +// } +// +// +// // //================================================ +// // // function : createMenus +// // //================================================ +// // void SMESHGUI_AdaptDlg::createMenus() +// // { +// // MESSAGE("createMenus") +// // // +// // int HOMARD_Id = createMenu( tr( "HOM_MEN_HOMARD" ), -1, 5, 10 ); +// // createMenu( 8011, HOMARD_Id, -1 ); //Create_Case +// // createMenu( 8012, HOMARD_Id, -1 ); //Pursue_Iteration +// // createMenu( separator(), HOMARD_Id,-1); +// // createMenu( 8013, HOMARD_Id, -1 ); //Create_Iteration +// // createMenu( 8014, HOMARD_Id, -1 ); //Compute +// // createMenu( 8015, HOMARD_Id, -1 ); //Compute and publish +// // // +// // HOMARD_Id = createMenu( tr( "HOM_MEN_MODIFICATION" ), -1, 5, 10 ); +// // createMenu( 8016, HOMARD_Id, -1 ); //Edit +// // createMenu( 8017, HOMARD_Id, -1 ); //Delete +// // // +// // HOMARD_Id = createMenu( tr( "HOM_MEN_INFORMATION" ), -1, 5, 10 ); +// // createMenu( 1301, HOMARD_Id, -1 ); //Information sur un maillage +// // createMenu( 1131, HOMARD_Id, -1 ); //Mesh publication +// // createMenu( separator(), HOMARD_Id,-1); +// // createMenu( 1302, HOMARD_Id, -1 ); //EditAsciiFile pour le fichier listeStd ou bilan +// // createMenu( separator(), HOMARD_Id,-1); +// // createMenu( 8016, HOMARD_Id, -1 ); //Edit +// // createMenu( separator(), HOMARD_Id,-1); +// // // +// // HOMARD_Id = createMenu( tr( "HOM_MEN_YACS" ), -1, 5, 10 ); +// // createMenu( 1401, HOMARD_Id, -1 ); // Création d'un schéma YACS +// // createMenu( separator(), HOMARD_Id,-1); +// // } +// +// //================================================ +// // function : recupPreferences +// // Pour chaque valeur, le defaut est la valeur definie dans HOMARD_Gen +// // . Si la recuperation dans config/salome s'est bien passee a la creation de HOMARD_Gen, +// // ces valeurs sont les valeurs definies. +// // . Si cela ne s'est pas bien passe, ce sont les valeurs par defaut de HOMARD_Gen +// //================================================ +// void SMESHGUI_AdaptDlg::recupPreferences() +// { +// MESSAGE("recupPreferences") +// // +// // A. Declarations +// // +// SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( application() ); +// HOMARD::HOMARD_Gen_var homardGen = SMESHGUI_AdaptDlg::InitHOMARDGen(app); +// int defaut_i ; +// std::string defaut_s ; +// QString QString_v ; +// // +// // B. Les valeurs +// // B.1. La langue +// // +// defaut_s = homardGen->GetLanguageShort(); +// SUIT_ResourceMgr* resMgr = getApp()->resourceMgr(); +// _LanguageShort = resMgr->stringValue("language", "language", QString(defaut_s.c_str()) ); +// // +// // B.2. Les publications +// bool publish_mesh ; +// // +// _PublisMeshIN = homardGen->GetPublisMeshIN(); +// if ( _PublisMeshIN == 1 ) { publish_mesh = true ; } +// else { publish_mesh = false ; } +// publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_in", publish_mesh ); +// if ( publish_mesh ) { _PublisMeshIN = 1 ; } +// else { _PublisMeshIN = 0 ; } +// // +// _PublisMeshOUT = homardGen->GetPublisMeshOUT(); +// if ( _PublisMeshOUT == 1 ) { publish_mesh = true ; } +// else { publish_mesh = false ; } +// publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_out", publish_mesh ); +// if ( publish_mesh ) { _PublisMeshOUT = 1 ; } +// else { _PublisMeshOUT = 0 ; } +// // +// // B.3. Les maximum pour YACS +// // +// defaut_i = homardGen->GetYACSMaxIter(); +// _YACSMaxIter = resMgr->integerValue("HOMARD", "yacs_max_iter", defaut_i ); +// // +// defaut_i = homardGen->GetYACSMaxNode(); +// _YACSMaxNode = resMgr->integerValue("HOMARD", "yacs_max_node", defaut_i ); +// // +// defaut_i = homardGen->GetYACSMaxElem(); +// _YACSMaxElem = resMgr->integerValue("HOMARD", "yacs_max_elem", defaut_i ); +// // +// // B.4. La convergence pour YACS +// // +// defaut_i = homardGen->GetYACSConvergenceType(); +// if ( defaut_i == 1 ) { QString_v = tr("VTest > VRef") ; } +// else if ( defaut_i == 2 ) { QString_v = tr("VTest < VRef") ; } +// else { QString_v = tr("None") ; } +// QString_v = resMgr->stringValue ( "HOMARD", "yacs_type_test", QString_v ); +// if ( ( QString_v == "VTest > VRef" ) || ( QString_v == "VTest > VRef" ) ) { _YACSTypeTest = 1 ; } +// else if ( ( QString_v == "VTest < VRef" ) || ( QString_v == "VTest < VRef" ) ) { _YACSTypeTest = 2 ; } +// else { _YACSTypeTest = 0 ; } +// // +// // C. Enregistrement dans l'objet general +// // +// MESSAGE ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() ); +// MESSAGE ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT); +// MESSAGE ("Enregistrement de YACSMaxIter = " << _YACSMaxIter<<", YACSMaxNode = "<< _YACSMaxNode<<", YACSMaxElem = "<< _YACSMaxElem); +// MESSAGE ("Enregistrement de YACSTypeTest = " << _YACSTypeTest); +// // +// homardGen->SetLanguageShort(_LanguageShort.toStdString().c_str()); +// homardGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT); +// homardGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem); +// // +// homardGen->SetYACSConvergenceType(_YACSTypeTest); +// } +// +// //================================================ +// void SMESHGUI_AdaptDlg::OnGUIEvent() +// //================================================ +// { +// MESSAGE("OnGUIEvent()") +// setOrb(); +// const QObject* obj = sender(); +// if ( !obj || !obj->inherits( "QAction" ) ) { return; } +// int id = actionId((QAction*)obj); +// if ( id != -1 ) { bool ret = OnGUIEvent( id ); } +// MESSAGE("Fin de OnGUIEvent()"); +// } +// +// //======================================================================= +// // Method OnGUIEvent pour Homard +// //======================================================================= +// bool SMESHGUI_AdaptDlg::OnGUIEvent (int theCommandID) +// { +// MESSAGE("OnGUIEvent avec theCommandID = "<( application() ); +// if ( !app ) return false; +// +// SalomeApp_Study* stud = dynamic_cast ( app->activeStudy() ); +// if ( !stud ) +// { +// MESSAGE ( "FAILED to cast active study to SalomeApp_Study" ); +// return false; +// } +// +// SUIT_Desktop* parent = application()->desktop(); +// +// HOMARD::HOMARD_Gen_var homardGen = SMESHGUI_AdaptDlg::InitHOMARDGen(app); +// +// if (!CORBA::is_nil(homardGen)) +// homardGen->UpdateStudy(); +// +// getApp()->updateObjectBrowser(); +// +// // B. Choix selon les commandes +// SCRUTE(theCommandID); +// switch (theCommandID) +// { +// case 8011: // Creation d un Cas +// { +// MESSAGE("command " << theCommandID << " activated"); +// MonCreateCase *aDlg = new MonCreateCase( true, +// HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ; +// aDlg->show(); +// break; +// } +// +// case 8012: // Poursuite d une iteration +// { +// MESSAGE("command " << theCommandID << " activated"); +// MonPursueIteration *aDlg = new MonPursueIteration( true, +// HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ; +// aDlg->show(); +// break; +// } +// +// case 8013: // Creation d une Iteration +// { +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// MonCreateIteration *IterDlg = new MonCreateIteration( parent, true, +// HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ; +// IterDlg->show(); +// break; +// } +// +// case 8014: // Compute une iteration +// { +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// try { homardGen->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)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// break; +// } +// +// case 8015: // Compute une iteration et publication +// { +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// try { homardGen->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)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// break; +// } +// +// case 1121: // Information sur le maillage de l'iteration +// { +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// MonIterInfo *IterDlg = new MonIterInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ; +// IterDlg->show(); +// break; +// } +// +// case 1131: // Publication du maillage de l'iteration +// { +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// homardGen->PublishMeshIterInSmesh(_ObjectName.toStdString().c_str()); +// break; +// } +// +// case 1132: // Publication du maillage de l'iteration a partir du fichier +// { +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// homardGen->PublishResultInSmesh(_ObjectName.toStdString().c_str(), 1); +// break; +// } +// +// case 8016: // Edition d'un objet +// { +// MESSAGE("command " << theCommandID << " activated"); +// QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1); +// if (nomObjet == QString("")) break; +// _PTR(SObject) obj = chercheMonObjet(); +// if (obj) +// { +// // Edition d'une frontiere CAO +// if (HOMARD_UTILS::isBoundaryCAO(obj)) +// { +// MonEditBoundaryCAO *aDlg = new MonEditBoundaryCAO(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ; +// aDlg->show(); +// } +// // Edition d'une frontiere discrete +// else if (HOMARD_UTILS::isBoundaryDi(obj)) +// { +// MonEditBoundaryDi *aDlg = new MonEditBoundaryDi(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ; +// aDlg->show(); +// } +// // Edition d'une frontiere analytique +// else if (HOMARD_UTILS::isBoundaryAn(obj)) +// { +// MonEditBoundaryAn *aDlg = new MonEditBoundaryAn(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ; +// aDlg->show(); +// } +// // Edition d'un cas +// else if (HOMARD_UTILS::isCase(obj)) +// { +// MonEditCase *aDlg = new MonEditCase(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ; +// aDlg->show(); +// } +// // Edition d'une hypothese +// else if (HOMARD_UTILS::isHypo(obj)) +// { +// MonEditHypothesis *aDlg = new MonEditHypothesis(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, QString(""), QString("")) ; +// aDlg->show(); +// } +// // Edition d'une iteration +// else if (HOMARD_UTILS::isIter(obj)) +// { +// MonEditIteration *aDlg = new MonEditIteration(parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ; +// aDlg->show(); +// } +// // Edition d'un schema YACS +// else if (HOMARD_UTILS::isYACS(obj)) +// { +// MESSAGE("appel de MonEditYACS"); +// MonEditYACS *aDlg = new MonEditYACS(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName) ; +// aDlg->show(); +// } +// // Edition d'une zone +// else if (HOMARD_UTILS::isZone(obj)) +// { +// MonEditZone *aDlg = new MonEditZone(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ; +// aDlg->show(); +// } +// } +// break; +// } +// +// case 8017: // Suppression d'un objet +// { +// MESSAGE("command " << theCommandID << " activated"); +// QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1); +// if (nomObjet == QString("")) break; +// _PTR(SObject) obj = chercheMonObjet(); +// if (obj) +// { +// // Suppression d'une frontiere +// if ( HOMARD_UTILS::isBoundaryCAO(obj) || HOMARD_UTILS::isBoundaryDi(obj) || HOMARD_UTILS::isBoundaryAn(obj) ) +// { +// try +// { homardGen->DeleteBoundary(_ObjectName.toStdString().c_str()); } +// catch( SALOME::SALOME_Exception& S_ex ) +// { +// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), +// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// } +// // Suppression d'un cas +// else if (HOMARD_UTILS::isCase(obj)) +// { +// try +// { homardGen->DeleteCase(_ObjectName.toStdString().c_str(), 1); } +// catch( SALOME::SALOME_Exception& S_ex ) +// { +// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), +// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// } +// // Suppression d'une hypothese +// else if (HOMARD_UTILS::isHypo(obj)) +// { +// try +// { homardGen->DeleteHypo(_ObjectName.toStdString().c_str()); } +// catch( SALOME::SALOME_Exception& S_ex ) +// { +// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), +// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// } +// // Suppression d'une iteration +// else if (HOMARD_UTILS::isIter(obj)) +// { +// try +// { homardGen->DeleteIteration(_ObjectName.toStdString().c_str(), 1); } +// catch( SALOME::SALOME_Exception& S_ex ) +// { +// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), +// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// } +// // Suppression d'un schema YACS +// else if (HOMARD_UTILS::isYACS(obj)) +// { +// try +// { homardGen->DeleteYACS(_ObjectName.toStdString().c_str(), 1); } +// catch( SALOME::SALOME_Exception& S_ex ) +// { +// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), +// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// } +// // Suppression d'une zone +// else if (HOMARD_UTILS::isZone(obj)) +// { +// try +// { homardGen->DeleteZone(_ObjectName.toStdString().c_str()); } +// catch( SALOME::SALOME_Exception& S_ex ) +// { +// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), +// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// } +// } +// break; +// } +// +// case 1301: // Information sur un maillage +// { +// MESSAGE("etape 1301") +// MESSAGE("command " << theCommandID << " activated"); +// MonMeshInfo *aDlg = new MonMeshInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ; +// aDlg->show(); +// break; +// } +// +// case 1302: // Affichage de fichier texte +// { +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// _PTR(SObject) obj = chercheMonObjet(); +// if ( (obj) && ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) ) ) +// { +// MonEditFile *aDlg = new MonEditFile( 0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, 0 ) ; +// if ( aDlg->_codret == 0 ) { aDlg->show(); } +// } +// break; +// } +// +// case 1401: // Création d'un schema YACS +// { +// MESSAGE("etape 1401") +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// MonCreateYACS *aDlg = new MonCreateYACS( true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ; +// aDlg->show(); +// break; +// } +// +// case 1402: // Ecriture d'un schéma YACS +// { +// MESSAGE("etape 1402") +// MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); +// try { homardGen->YACSWrite(_ObjectName.toStdString().c_str()); } +// catch( SALOME::SALOME_Exception& S_ex ) +// { +// QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), +// QObject::tr(CORBA::string_dup(S_ex.details.text)) ); +// getApp()->updateObjectBrowser(); +// return false; +// } +// break; +// } +// +// } +// getApp()->updateObjectBrowser(); +// return true; +// } +// +// //============================================================================= +// /*! +// * +// */ +// //============================================================================= +// +// // Module's engine IOR +// //============================================================================= +// QString SMESHGUI_AdaptDlg::engineIOR() const +// //============================================================================= +// { +// CORBA::String_var anIOR = getApp()->orb()->object_to_string( InitHOMARDGen(getApp()) ); +// return QString( anIOR.in() ); +// } +// +// // Module's activation +// //============================================================================= +// bool SMESHGUI_AdaptDlg::activateModule( SUIT_Study* theStudy ) +// //============================================================================= +// { +// bool bOk = SalomeApp_Module::activateModule( theStudy ); +// +// setMenuShown( true ); +// setToolShown( true ); +// +// return bOk; +// } +// +// // Module's deactivation +// //============================================================================= +// bool SMESHGUI_AdaptDlg::deactivateModule( SUIT_Study* theStudy ) +// //============================================================================= +// { +// setMenuShown( false ); +// setToolShown( false ); +// +// return SalomeApp_Module::deactivateModule( theStudy ); +// } +// +// // Default windows +// //============================================================================= +// void SMESHGUI_AdaptDlg::windows( QMap& theMap ) const +// //============================================================================= +// { +// theMap.clear(); +// theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); +// #ifndef DISABLE_PYCONSOLE +// theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); +// #endif +// } +// +// //============================================================================= +// void SMESHGUI_AdaptDlg::setOrb() +// //============================================================================= +// { +// try +// { +// ORB_INIT &init = *SINGLETON_::Instance(); +// ASSERT(SINGLETON_::IsAlreadyExisting()); +// _orb = init( 0 , 0 ); +// } +// catch (...) +// { +// INFOS("internal error : orb not found"); +// _orb = 0; +// } +// ASSERT(! CORBA::is_nil(_orb)); +// } +// //======================================== +// _PTR(SObject) SMESHGUI_AdaptDlg::chercheMonObjet() +// //======================================== +// { +// SALOMEDSClient_SObject* aSO = NULL; +// _PTR(SObject) obj; +// SALOME_ListIO lst; +// getApp()->selectionMgr()->selectedObjects( lst ); +// if ( lst.Extent() == 1 ) +// { +// Handle(SALOME_InteractiveObject) io = lst.First(); +// SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); +// _PTR(Study) study = appStudy->studyDS(); +// _PTR(SObject) obj = study->FindObjectID( io->getEntry() ); +// _ObjectName = QString( obj->GetName().c_str() ); +// return obj; +// } +// else { return _PTR(SObject)(aSO); } +// } +// //============================================================================= +// void SMESHGUI_AdaptDlg::contextMenuPopup( const QString& client, QMenu* menu, QString& title ) +// //============================================================================= +// { +// MESSAGE("Debut de contextMenuPopup"); +// _PTR(SObject) obj = chercheMonObjet(); +// if ( obj ) +// { +// title = QString( obj->GetName().c_str() ); +// _ObjectName = title; +// SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); +// // +// QPixmap pix ; +// bool DeleteObject = false ; +// bool EditObject = false ; +// // +// if ( HOMARD_UTILS::isBoundaryCAO(obj) ) +// { +// EditObject = true ; +// DeleteObject = true ; +// } +// else if ( HOMARD_UTILS::isBoundaryAn(obj) ) +// { +// EditObject = true ; +// DeleteObject = true ; +// } +// else if ( HOMARD_UTILS::isBoundaryDi(obj) ) +// { +// EditObject = true ; +// DeleteObject = true ; +// } +// else if ( HOMARD_UTILS::isCase(obj) ) +// { +// pix = resMgr->loadPixmap( "HOMARD", "table_view.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_YACS").toLatin1().data()), this, SLOT(YACSCreate())); +// EditObject = true ; +// DeleteObject = true ; +// } +// else if ( HOMARD_UTILS::isHypo(obj) ) +// { +// EditObject = true ; +// DeleteObject = true ; +// } +// else if ( HOMARD_UTILS::isIter(obj) ) +// { +// pix = resMgr->loadPixmap( "HOMARD", "iter_next.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_NEW_ITERATION").toLatin1().data()), this, SLOT(NextIter())); +// pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE").toLatin1().data()), this, SLOT(LanceCalcul0())); +// pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE_PUBLISH").toLatin1().data()), this, SLOT(LanceCalcul1())); +// pix = resMgr->loadPixmap( "HOMARD", "advanced_mesh_info.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_INFO").toLatin1().data()), this, SLOT(IterInfo())); +// pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish0())); +// EditObject = true ; +// DeleteObject = true ; +// } +// else if ( HOMARD_UTILS::isYACS(obj) ) +// { +// pix = resMgr->loadPixmap( "HOMARD", "write.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_WRITE").toLatin1().data()), this, SLOT(YACSWrite())); +// EditObject = true ; +// DeleteObject = true ; +// } +// else if ( HOMARD_UTILS::isZone(obj) ) +// { +// EditObject = true ; +// DeleteObject = true ; +// } +// else if ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) ) +// { +// pix = resMgr->loadPixmap( "HOMARD", "texte.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT_MESS_FILE").toLatin1().data()), this, SLOT(EditAsciiFile())); +// } +// else if ( HOMARD_UTILS::isFileType(obj,QString("Mesh")) ) +// { +// pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish1())); +// } +// // Ajout d'un menu d'edition pour les objets qui le proposent +// if ( EditObject ) +// { +// pix = resMgr->loadPixmap( "HOMARD", "loop.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT").toLatin1().data()), this, SLOT(Edit())); +// } +// // Ajout d'un menu de destruction pour les objets qui le proposent +// if ( DeleteObject ) +// { +// pix = resMgr->loadPixmap( "HOMARD", "delete.png" ); +// menu->addAction(QIcon(pix), tr(QString("HOM_MEN_DELETE").toLatin1().data()), this, SLOT(Delete())); +// } +// } +// } +// +// void SMESHGUI_AdaptDlg::NextIter() +// { +// this->OnGUIEvent(8013); +// } +// +// void SMESHGUI_AdaptDlg::LanceCalcul0() +// { +// this->OnGUIEvent(8014); +// } +// +// void SMESHGUI_AdaptDlg::LanceCalcul1() +// { +// this->OnGUIEvent(8015); +// } +// +// void SMESHGUI_AdaptDlg::IterInfo() +// { +// this->OnGUIEvent(1121); +// } +// +// void SMESHGUI_AdaptDlg::MeshPublish0() +// { +// this->OnGUIEvent(1131); +// } +// +// void SMESHGUI_AdaptDlg::MeshPublish1() +// { +// this->OnGUIEvent(1132); +// } +// +// void SMESHGUI_AdaptDlg::Edit() +// { +// this->OnGUIEvent(8016); +// } +// +// void SMESHGUI_AdaptDlg::Delete() +// { +// this->OnGUIEvent(8017); +// } +// +// void SMESHGUI_AdaptDlg::EditAsciiFile() +// { +// this->OnGUIEvent(1302); +// } +// +// void SMESHGUI_AdaptDlg::YACSCreate() +// { +// this->OnGUIEvent(1401); +// } +// void SMESHGUI_AdaptDlg::YACSWrite() +// { +// this->OnGUIEvent(1402); +// } +// + +// +//============================================================================= +// Export the module +//============================================================================= +extern "C" { + Standard_EXPORT CAM_Module* createModule() + { + return new SMESHGUI_AdaptDlg(""); + } +} + diff --git a/src/SMESHGUI/SMESHGUI_AdaptDlg.h b/src/SMESHGUI/SMESHGUI_AdaptDlg.h new file mode 100644 index 000000000..45cbe28bf --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AdaptDlg.h @@ -0,0 +1,107 @@ +// 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 +// + +// SMESH SMESHGUI : GUI for the adaptation in the SMESH component +// File : SMESHGUI_AdaptDlg.h +// Author : Gérald NICOLAS, EDF +// +#ifndef SMESHGUI_ADAPTDLG_H +#define SMESHGUI_ADAPTDLG_H + +#include "HOMARDGUI_Exports.hxx" + +#include +#include "SalomeApp_Study.h" + +#include +#include +#include CORBA_CLIENT_HEADER(HOMARD_Gen) +#include CORBA_CLIENT_HEADER(HOMARD_Cas) +#include CORBA_CLIENT_HEADER(HOMARD_Hypothesis) + +#include + +//================================================================================= +// class : SMESHGUI_AdaptDlg +// purpose : +//================================================================================= +class SMESHGUI_EXPORT SMESHGUI_AdaptDlg: public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_AdaptDlg( SMESHGUI*, + int theCommandID); + ~SMESHGUI_AdaptDlg(); + + virtual bool OnGUIEvent (int theCommandID); + void initialize( CAM_Application* ); + QString engineIOR() const; + void windows( QMap& ) const; + + static HOMARD::HOMARD_Gen_var InitHOMARDGen(SalomeApp_Application* ); + + +public slots: + bool deactivateModule( SUIT_Study* ); + bool activateModule( SUIT_Study* ); + static void setOrb(); + +private slots: + void OnGUIEvent(); + void EditAsciiFile(); + void LanceCalcul0(); + void LanceCalcul1(); + void IterInfo(); + void NextIter(); + void MeshPublish0(); + void MeshPublish1(); + void YACSCreate(); + void YACSWrite(); + void Edit(); + void Delete(); + +public: + virtual void contextMenuPopup( const QString&, QMenu*, QString& ); + + +private: + void createHOMARDAction( const int id, const QString& po_id, const QString& icon_id = QString(""), + const int key = 0, const bool toggle = false ); + void createActions(); + void createMenus(); + void recupPreferences(); + void createPopupMenus(); + _PTR(SObject) chercheMonObjet(); + + virtual void createPreferences(); + HOMARD::HOMARD_Gen_var myComponentHomard; + + int anId; + QString _ObjectName; + QString _LanguageShort ; + int _PublisMeshIN ; + int _PublisMeshOUT ; + int _YACSMaxIter ; + int _YACSMaxNode ; + int _YACSMaxElem ; + int _YACSTypeTest ; +}; + +#endif // SMESHGUI_ADAPTDLG_H -- 2.30.2