X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHOMARDGUI%2FHOMARDGUI.cxx;h=e5c07103822e3678f7fb3c6f43cf3eb2ce52d46a;hb=0fb79a105b0a07b04479ad190861aede8ac4c345;hp=c116df3d2a9ffc08011e9b43ac91914c604930e8;hpb=a98a6c26b86d7c1b952e4a04de60a04e15fc5183;p=modules%2Fhomard.git diff --git a/src/HOMARDGUI/HOMARDGUI.cxx b/src/HOMARDGUI/HOMARDGUI.cxx index c116df3d..e5c07103 100644 --- a/src/HOMARDGUI/HOMARDGUI.cxx +++ b/src/HOMARDGUI/HOMARDGUI.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2011-2013 CEA/DEN, EDF R&D +// Copyright (C) 2011-2022 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. +// 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 @@ -18,14 +18,13 @@ // // File : HOMARDGUI.cxx -// Author : Paul RASCLE, EDF +// Author : Gerald NICOLAS, EDF // Module : HOMARD #include "HOMARDGUI.h" // SALOME Includes -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include "SUIT_ResourceMgr.h" @@ -39,7 +38,6 @@ #include "OB_Browser.h" #include "SALOME_ListIO.hxx" -#include "SALOME_ListIteratorOfListIO.hxx" #include "SalomeApp_Application.h" #include "SalomeApp_DataModel.h" @@ -50,6 +48,8 @@ #include "SalomeApp_Module.h" #include "SALOMEconfig.h" #include +#include +#include #include @@ -60,6 +60,7 @@ #include "MonCreateIteration.h" #include "MonPursueIteration.h" #include "MonCreateYACS.h" +#include "MonEditBoundaryCAO.h" #include "MonEditBoundaryAn.h" #include "MonEditBoundaryDi.h" #include "MonEditCase.h" @@ -91,8 +92,6 @@ HOMARDGUI::HOMARDGUI(const QString&) : SalomeApp_Module( "HOMARD" ) // default name { } - - //======================================================================= // function : ~HOMARDGUI() // purpose : Destructor @@ -107,7 +106,8 @@ HOMARDGUI::~HOMARDGUI() //======================================================================= HOMARD::HOMARD_Gen_var HOMARDGUI::InitHOMARDGen(SalomeApp_Application* app) { - Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","HOMARD" ); + Engines::EngineComponent_var comp; + comp = app->lcc()->FindOrLoad_Component( "FactoryServer","HOMARD" ); HOMARD::HOMARD_Gen_var clr = HOMARD::HOMARD_Gen::_narrow(comp); ASSERT(!CORBA::is_nil(clr)); return clr; @@ -181,7 +181,7 @@ void HOMARDGUI::createActions(){ //================================================ void HOMARDGUI::createPreferences() { - MESSAGE("createPreferences") + MESSAGE("createPreferences"); int Onglet, Bloc, Pref ; // 1. Generalites @@ -201,20 +201,30 @@ void HOMARDGUI::createPreferences() Bloc = addPreference( tr( "PREF_YACS_MAX" ), Onglet ); setPreferenceProperty( Bloc, "columns", 1 ); - Pref = addPreference( tr( "PREF_YACS_MAX_ITER" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "max_iter" ); + 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", "max_node" ); + 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", "max_elem" ); + 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 ); } @@ -223,7 +233,7 @@ void HOMARDGUI::createPreferences() //================================================ void HOMARDGUI::createMenus() { - MESSAGE("createMenus") + MESSAGE("createMenus"); // int HOMARD_Id = createMenu( tr( "HOM_MEN_HOMARD" ), -1, 5, 10 ); createMenu( 1101, HOMARD_Id, -1 ); //Create_Case @@ -247,53 +257,105 @@ void HOMARDGUI::createMenus() 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( 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 HOMARDGUI::recupPreferences() { - MESSAGE("recupPreferences") + INFOS("recupPreferences") +// +// A. Declarations +// + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( application() ); + HOMARD::HOMARD_Gen_var homardGen = HOMARDGUI::InitHOMARDGen(app); + int defaut_i ; + std::string defaut_s ; + QString QString_v ; // -// . La langue +// B. Les valeurs +// B.1. La langue +// + SUIT_ResourceMgr* resMgr0 = getApp()->resourceMgr(); + QString lang = resMgr0->stringValue( resMgr0->langSection(), "language", "en" ); + INFOS ("Récupération de lang = " << lang.toStdString().c_str() ); + defaut_s = homardGen->GetLanguageShort(); + INFOS ("Récupération de defaut_s = " << defaut_s.c_str() ); SUIT_ResourceMgr* resMgr = getApp()->resourceMgr(); - _LanguageShort = resMgr->stringValue("language", "language", "en"); - MESSAGE("_LanguageShort " << _LanguageShort.toStdString().c_str() ); + _LanguageShort = resMgr->stringValue("language", "language", QString(defaut_s.c_str()) ); + INFOS ("Récupération de LanguageShort = " << _LanguageShort.toStdString().c_str() ); // -// . Les publications - _publish_mesh_in = resMgr->booleanValue("HOMARD", "publish_mesh_in", false ); - int pu_m_in = 0 ; - if ( _publish_mesh_in ) pu_m_in = 1 ; +// B.2. Les publications + bool publish_mesh ; // - _publish_mesh_out = resMgr->booleanValue("HOMARD", "publish_mesh_out", false ); - int pu_m_out = 0 ; - if ( _publish_mesh_out ) pu_m_out = 1 ; - MESSAGE("_publish_mesh_in " << _publish_mesh_in << ", _publish_mesh_out " << _publish_mesh_out ); + _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 +// + INFOS ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() ); + INFOS ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT); + INFOS ("Enregistrement de YACSMaxIter = " << _YACSMaxIter<<", YACSMaxNode = "<< _YACSMaxNode<<", YACSMaxElem = "<< _YACSMaxElem); + INFOS ("Enregistrement de YACSTypeTest = " << _YACSTypeTest); // -// . Enregistrement dans l'objet general - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( application() ); - HOMARD::HOMARD_Gen_var homardGen = HOMARDGUI::InitHOMARDGen(app); homardGen->SetLanguageShort(_LanguageShort.toStdString().c_str()); - homardGen->SetPublisMesh(pu_m_in, pu_m_out); + homardGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT); + homardGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem); +// + homardGen->SetYACSConvergenceType(_YACSTypeTest); } //================================================ void HOMARDGUI::OnGUIEvent() //================================================ { - MESSAGE("OnGUIEvent()") + MESSAGE("OnGUIEvent()"); setOrb(); const QObject* obj = sender(); - if ( !obj || !obj->inherits( "QAction" ) ) - return; + if ( !obj || !obj->inherits( "QAction" ) ) { return; } int id = actionId((QAction*)obj); - bool ret; - if ( id != -1 ) - ret = OnGUIEvent( id ); - MESSAGE("************** End of OnGUIEvent()"); + if ( id != -1 ) { bool ret = OnGUIEvent( id ); } + MESSAGE("Fin de OnGUIEvent()"); } //======================================================================= @@ -302,31 +364,27 @@ void HOMARDGUI::OnGUIEvent() bool HOMARDGUI::OnGUIEvent (int theCommandID) { MESSAGE("OnGUIEvent avec theCommandID = "<( application() ); if ( !app ) return false; SalomeApp_Study* stud = dynamic_cast ( app->activeStudy() ); - if ( !stud ) { + if ( !stud ) + { MESSAGE ( "FAILED to cast active study to SalomeApp_Study" ); return false; } SUIT_Desktop* parent = application()->desktop(); + HOMARD::HOMARD_Gen_var homardGen = HOMARDGUI::InitHOMARDGen(app); if (!CORBA::is_nil(homardGen)) - { - // Set current study - SalomeApp_Study* aSAStudy =dynamic_cast(app->activeStudy()); - _PTR(Study) aStudy = aSAStudy->studyDS(); - SALOMEDS::Study_ptr aStudyDS; - if (aStudy) - aStudyDS = _CAST(Study,aStudy)->GetStudy(); - homardGen->SetCurrentStudy(aStudyDS); - } - getApp()->updateObjectBrowser(); + homardGen->UpdateStudy(); + getApp()->updateObjectBrowser(); +// B. Choix selon les commandes SCRUTE(theCommandID); switch (theCommandID) { @@ -415,8 +473,14 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) _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 - if (HOMARD_UTILS::isBoundaryDi(obj)) + else if (HOMARD_UTILS::isBoundaryDi(obj)) { MonEditBoundaryDi *aDlg = new MonEditBoundaryDi(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ; aDlg->show(); @@ -471,7 +535,7 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) if (obj) { // Suppression d'une frontiere - if ( HOMARD_UTILS::isBoundaryDi(obj) || HOMARD_UTILS::isBoundaryAn(obj) ) + if ( HOMARD_UTILS::isBoundaryCAO(obj) || HOMARD_UTILS::isBoundaryDi(obj) || HOMARD_UTILS::isBoundaryAn(obj) ) { try { homardGen->DeleteBoundary(_ObjectName.toStdString().c_str()); } @@ -554,7 +618,7 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) case 1301: // Information sur un maillage { - MESSAGE("etape 1301") + MESSAGE("etape 1301"); MESSAGE("command " << theCommandID << " activated"); MonMeshInfo *aDlg = new MonMeshInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ; aDlg->show(); @@ -573,18 +637,18 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) break; } - case 1401: // Création d'un schema YACS + case 1401: // Création d'un schema YACS { - MESSAGE("etape 1401") + 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 + case 1402: // Ecriture d'un schéma YACS { - MESSAGE("etape 1402") + 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 ) @@ -648,7 +712,9 @@ void HOMARDGUI::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 } //============================================================================= @@ -657,9 +723,7 @@ void HOMARDGUI::setOrb() { try { - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init( 0 , 0 ); + _orb = KERNEL::GetRefToORB(); } catch (...) { @@ -703,7 +767,12 @@ void HOMARDGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& t bool DeleteObject = false ; bool EditObject = false ; // - if ( HOMARD_UTILS::isBoundaryAn(obj) ) + if ( HOMARD_UTILS::isBoundaryCAO(obj) ) + { + EditObject = true ; + DeleteObject = true ; + } + else if ( HOMARD_UTILS::isBoundaryAn(obj) ) { EditObject = true ; DeleteObject = true ;