From: nicolas Date: Thu, 16 Jan 2014 08:40:00 +0000 (+0000) Subject: Gestion des préférences entre HOMARD_GEN et le GUI X-Git-Tag: V7_4_0a1~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dceaa0ae1b8afc0a1c616b93d793e2fdbccf5dbc;p=modules%2Fhomard.git Gestion des préférences entre HOMARD_GEN et le GUI --- diff --git a/idl/HOMARD_Gen.idl b/idl/HOMARD_Gen.idl index 8ae213db..2331b305 100644 --- a/idl/HOMARD_Gen.idl +++ b/idl/HOMARD_Gen.idl @@ -200,6 +200,7 @@ module HOMARD // // +// La creation des schemas YACS HOMARD_YACS CreateYACSSchema(in string YACSName, in string CaseName, in string ScriptFile, in string DirName, in string MeshFile) raises(SALOME::SALOME_Exception); long YACSWrite (in string YACSName) raises (SALOME::SALOME_Exception); @@ -207,12 +208,18 @@ module HOMARD raises(SALOME::SALOME_Exception); // +// Les preferences void SetLanguageShort (in string LanguageShort) raises (SALOME::SALOME_Exception); string GetLanguageShort () raises (SALOME::SALOME_Exception); void SetPublisMesh (in long PublisMeshIN, in long PublisMeshOUT) raises (SALOME::SALOME_Exception); long GetPublisMeshIN () raises (SALOME::SALOME_Exception); long GetPublisMeshOUT () raises (SALOME::SALOME_Exception); + void SetYACSMaximum(in long YACSMaxIter, in long YACSMaxNode, in long YACSMaxElem) + raises (SALOME::SALOME_Exception); + long GetYACSMaxIter() raises (SALOME::SALOME_Exception); + long GetYACSMaxNode() raises (SALOME::SALOME_Exception); + long GetYACSMaxElem() raises (SALOME::SALOME_Exception); }; }; diff --git a/src/HOMARDGUI/HOMARDGUI.cxx b/src/HOMARDGUI/HOMARDGUI.cxx index c116df3d..f5f5004c 100644 --- a/src/HOMARDGUI/HOMARDGUI.cxx +++ b/src/HOMARDGUI/HOMARDGUI.cxx @@ -91,8 +91,6 @@ HOMARDGUI::HOMARDGUI(const QString&) : SalomeApp_Module( "HOMARD" ) // default name { } - - //======================================================================= // function : ~HOMARDGUI() // purpose : Destructor @@ -201,17 +199,17 @@ 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 ); @@ -253,31 +251,66 @@ void HOMARDGUI::createMenus() //================================================ // 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") // -// . La langue +// 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 ; +// +// B. Les valeurs +// B.1. La langue +// + defaut_s = homardGen->GetLanguageShort(); 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())); // -// . 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 ); +// +// 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); // -// . 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); } //================================================ @@ -287,13 +320,10 @@ void HOMARDGUI::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,11 +332,13 @@ 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; } @@ -326,7 +358,7 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) } getApp()->updateObjectBrowser(); - +// B. Choix selon les commandes SCRUTE(theCommandID); switch (theCommandID) { diff --git a/src/HOMARDGUI/HOMARDGUI.h b/src/HOMARDGUI/HOMARDGUI.h index 2bca7287..8689ac6d 100644 --- a/src/HOMARDGUI/HOMARDGUI.h +++ b/src/HOMARDGUI/HOMARDGUI.h @@ -95,8 +95,11 @@ private: int anId; QString _ObjectName; QString _LanguageShort ; - bool _publish_mesh_in ; - bool _publish_mesh_out ; + int _PublisMeshIN ; + int _PublisMeshOUT ; + int _YACSMaxIter ; + int _YACSMaxNode ; + int _YACSMaxElem ; }; #endif diff --git a/src/HOMARDGUI/MonCreateBoundaryAn.cxx b/src/HOMARDGUI/MonCreateBoundaryAn.cxx index 194569cb..52b7a15c 100644 --- a/src/HOMARDGUI/MonCreateBoundaryAn.cxx +++ b/src/HOMARDGUI/MonCreateBoundaryAn.cxx @@ -525,8 +525,8 @@ void MonCreateBoundaryAn::PushOnOK() void MonCreateBoundaryAn::PushOnHelp() // ------------------------------------------------------------------------ { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("un-cylindre"), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("un-cylindre"), QString(LanguageShort.c_str())); } // ----------------------------------- diff --git a/src/HOMARDGUI/MonCreateBoundaryDi.cxx b/src/HOMARDGUI/MonCreateBoundaryDi.cxx index 3af08800..2385da0c 100644 --- a/src/HOMARDGUI/MonCreateBoundaryDi.cxx +++ b/src/HOMARDGUI/MonCreateBoundaryDi.cxx @@ -139,8 +139,8 @@ void MonCreateBoundaryDi::PushOnOK() void MonCreateBoundaryDi::PushOnHelp() // ------------------------------------------------------------------------ { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort.c_str())); } // ------------------------------------------------------------------------ void MonCreateBoundaryDi::AssocieLesGroupes() diff --git a/src/HOMARDGUI/MonCreateCase.cxx b/src/HOMARDGUI/MonCreateCase.cxx index 417bae8f..39ca08b3 100644 --- a/src/HOMARDGUI/MonCreateCase.cxx +++ b/src/HOMARDGUI/MonCreateCase.cxx @@ -316,8 +316,8 @@ void MonCreateCase::PushOnOK() void MonCreateCase::PushOnHelp() //------------------------------- { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort.c_str())); } // --------------------------------- void MonCreateCase::SetNewName() @@ -443,8 +443,8 @@ void MonCreateCase::PushBoundaryDiEdit() void MonCreateCase::PushBoundaryDiHelp() // ------------------------------------------------------------------------ { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort.c_str())); } // ------------------------------------------------------------------------ void MonCreateCase::SetBoundaryA() @@ -523,8 +523,8 @@ void MonCreateCase::PushBoundaryAnEdit() void MonCreateCase::PushBoundaryAnHelp() // ------------------------------------------------------------------------ { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-analytique"), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-analytique"), QString(LanguageShort.c_str())); } // ------------------------------------------------------------------------ void MonCreateCase::CaseNameChanged() diff --git a/src/HOMARDGUI/MonCreateHypothesis.cxx b/src/HOMARDGUI/MonCreateHypothesis.cxx index 21c52bc2..629dca87 100644 --- a/src/HOMARDGUI/MonCreateHypothesis.cxx +++ b/src/HOMARDGUI/MonCreateHypothesis.cxx @@ -207,8 +207,8 @@ void MonCreateHypothesis::PushOnOK() void MonCreateHypothesis::PushOnHelp() // ------------------------------------------------------------------------ { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str())); } // ------------------------------------------------- void MonCreateHypothesis::SetNewName() diff --git a/src/HOMARDGUI/MonCreateIteration.cxx b/src/HOMARDGUI/MonCreateIteration.cxx index 5a1d967d..a86e9e78 100644 --- a/src/HOMARDGUI/MonCreateIteration.cxx +++ b/src/HOMARDGUI/MonCreateIteration.cxx @@ -190,8 +190,8 @@ void MonCreateIteration::PushOnOK() void MonCreateIteration::PushOnHelp() // ------------------------------------------------------------------------ { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_iteration.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_iteration.html"), QString(""), QString(LanguageShort.c_str())); } // ------------------------------------------------------------------------ void MonCreateIteration::SetIterParentName() diff --git a/src/HOMARDGUI/MonCreateListGroup.cxx b/src/HOMARDGUI/MonCreateListGroup.cxx index d7442211..59d8e358 100644 --- a/src/HOMARDGUI/MonCreateListGroup.cxx +++ b/src/HOMARDGUI/MonCreateListGroup.cxx @@ -115,8 +115,8 @@ void MonCreateListGroup::PushOnOK() void MonCreateListGroup::PushOnHelp() // ------------------------------------------------------------------------ { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str())); } // ------------------------------------------------------------------------ void MonCreateListGroup::InitGroupes() diff --git a/src/HOMARDGUI/MonCreateYACS.cxx b/src/HOMARDGUI/MonCreateYACS.cxx index 2463febe..8c6aa062 100644 --- a/src/HOMARDGUI/MonCreateYACS.cxx +++ b/src/HOMARDGUI/MonCreateYACS.cxx @@ -262,8 +262,8 @@ void MonCreateYACS::PushOnOK() void MonCreateYACS::PushOnHelp() //------------------------------- { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("yacs.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("yacs.html"), QString(""), QString(LanguageShort.c_str())); } // ------------------------------------------------- void MonCreateYACS::SetNewName() diff --git a/src/HOMARDGUI/MonCreateZone.cxx b/src/HOMARDGUI/MonCreateZone.cxx index 372459ae..dc4a38b5 100644 --- a/src/HOMARDGUI/MonCreateZone.cxx +++ b/src/HOMARDGUI/MonCreateZone.cxx @@ -580,8 +580,8 @@ void MonCreateZone::PushOnOK() void MonCreateZone::PushOnHelp() // ------------------------------------------------------------------------ { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_zone.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_zone.html"), QString(""), QString(LanguageShort.c_str())); } // ----------------------------------- diff --git a/src/HOMARDGUI/MonIterInfo.cxx b/src/HOMARDGUI/MonIterInfo.cxx index f2c4ce3e..6f903fe3 100644 --- a/src/HOMARDGUI/MonIterInfo.cxx +++ b/src/HOMARDGUI/MonIterInfo.cxx @@ -130,8 +130,8 @@ void MonIterInfo::PushOnOK() void MonIterInfo::PushOnHelp() //------------------------------- { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_mesh_info.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_mesh_info.html"), QString(""), QString(LanguageShort.c_str())); } // ------------------------------------------------------------------------ void MonIterInfo::SetBlockSize() diff --git a/src/HOMARDGUI/MonMeshInfo.cxx b/src/HOMARDGUI/MonMeshInfo.cxx index 143f1bd6..e09886fc 100644 --- a/src/HOMARDGUI/MonMeshInfo.cxx +++ b/src/HOMARDGUI/MonMeshInfo.cxx @@ -190,8 +190,8 @@ void MonMeshInfo::PushOnOK() void MonMeshInfo::PushOnHelp() //------------------------------- { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort.c_str())); } // --------------------------------- void MonMeshInfo::SetNewCaseName() diff --git a/src/HOMARDGUI/MonPursueIteration.cxx b/src/HOMARDGUI/MonPursueIteration.cxx index e441e581..22ac05dc 100644 --- a/src/HOMARDGUI/MonPursueIteration.cxx +++ b/src/HOMARDGUI/MonPursueIteration.cxx @@ -221,8 +221,8 @@ void MonPursueIteration::PushOnOK() void MonPursueIteration::PushOnHelp() //------------------------------- { - char* LanguageShort = myHomardGen->GetLanguageShort(); - HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort)); + std::string LanguageShort = myHomardGen->GetLanguageShort(); + HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort.c_str())); } // --------------------------------- void MonPursueIteration::SetNewCaseName() diff --git a/src/HOMARD_I/HOMARD_Gen_i.cxx b/src/HOMARD_I/HOMARD_Gen_i.cxx index 53f174f1..8cab8d1e 100755 --- a/src/HOMARD_I/HOMARD_Gen_i.cxx +++ b/src/HOMARD_I/HOMARD_Gen_i.cxx @@ -4997,7 +4997,7 @@ void HOMARD_Gen_i::SetPreferences( ) bool ok = true ; // A. Les valeurs par defaut ; elles doivent etre coherentes - std::string LanguageShort = "fr" ; + std::string LanguageShort = "en" ; int PublisMeshIN = 0 ; int PublisMeshOUT = 0 ; int YACSMaxIter = 0 ; @@ -5078,7 +5078,7 @@ void HOMARD_Gen_i::SetPreferences( ) ligne_bis >> mot_cle ; std::string chaine2 = GetStringInTexte ( mot_cle, "\"", 1 ) ; chaine2 = GetStringInTexte ( chaine2, "\"", 0 ) ; -// MESSAGE("chaine2 = "<> PublisMeshIN ; } if ( chaine2 == "publish_mesh_out" ) { chainebis >> PublisMeshOUT ; } // 3.2.2. Les maximum pour YACS - if ( chaine2 == "max_iter" ) { chainebis >> YACSMaxIter ; } - if ( chaine2 == "max_node" ) { chainebis >> YACSMaxNode ; } - if ( chaine2 == "max_elem" ) { chainebis >> YACSMaxElem ; } + if ( chaine2 == "yacs_max_iter" ) { chainebis >> YACSMaxIter ; } + if ( chaine2 == "yacs_max_node" ) { chainebis >> YACSMaxNode ; } + if ( chaine2 == "yacs_max_elem" ) { chainebis >> YACSMaxElem ; } } } }