Salome HOME
Copyright update 2022
[modules/homard.git] / src / HOMARDGUI / MonEditYACS.cxx
1 // Copyright (C) 2011-2022  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "MonEditYACS.h"
21
22 #include "SalomeApp_Tools.h"
23 #include "HOMARDGUI_Utils.h"
24 #include "HomardQtCommun.h"
25 #include <utilities.h>
26
27 using namespace std;
28
29 // -------------------------------------------------------------
30 /* Constructs a MonEditYACS
31     herite de MonCreateYACS
32 */
33 // -------------------------------------------------------------
34 MonEditYACS::MonEditYACS ( bool modal,
35                            HOMARD::HOMARD_Gen_var myHomardGen,
36                            QString Name ):
37    MonCreateYACS(myHomardGen, Name)
38 {
39     MESSAGE("Debut de MonEditYACS" << Name.toStdString().c_str());
40     setWindowTitle(QObject::tr("HOM_YACS_EDIT_WINDOW_TITLE"));
41     _Name = Name;
42     aYACS = myHomardGen->GetYACS(_Name.toStdString().c_str());
43     InitValEdit();
44 }
45 // ------------------------------
46 MonEditYACS::~MonEditYACS()
47 // ------------------------------
48 {
49 }
50 // ------------------------------
51 void MonEditYACS::InitValEdit()
52 // ------------------------------
53 {
54   MESSAGE("InitValEdit");
55   LEName->setText(_Name);
56   LEName->setReadOnly(true);
57
58   _aCaseName = aYACS->GetCaseName();
59   LECaseName->setText(_aCaseName);
60   LECaseName->setReadOnly(true);
61   PBCaseName->setVisible(0);
62
63   _aScriptFile = aYACS->GetScriptFile();
64   LEScriptFile->setText(_aScriptFile);
65
66   _aDirName = aYACS->GetDirName();
67   LEDirName->setText(_aDirName);
68   LEDirName->setReadOnly(true);
69
70   _aMeshFile = aYACS->GetMeshFile();
71   LEMeshFile->setText(_aMeshFile);
72
73   _Type=aYACS->GetType();
74   if(_Type==1) { RBConstant->setChecked(true); }
75   else         { RBVariable->setChecked(true); };
76   RBConstant->setEnabled(false);
77   RBVariable->setEnabled(false);
78
79   _MaxIter = aYACS->GetMaxIter();
80   SpinBoxMaxIter->setValue(_MaxIter) ;
81   _MaxNode = aYACS->GetMaxNode();
82   SpinBoxMaxNode->setValue(_MaxNode) ;
83   _MaxElem = aYACS->GetMaxElem();
84   SpinBoxMaxElem->setValue(_MaxElem) ;
85 //
86 }
87
88 // ---------------------------------------------------
89 bool MonEditYACS:: CreateOrUpdate()
90 //----------------------------------------------------
91 //  Edition/modification du schema
92 {
93   MESSAGE("CreateOrUpdate");
94   bool chgt = false ;
95   int valeur_i ;
96   // A. Recuperation et comparaison des valeurs
97   // A.1. Le script de lancement
98   QString aScriptFile=LEScriptFile->text().trimmed();
99   if ( aScriptFile != _aScriptFile )
100   {
101 //     MESSAGE("modification de ScriptFile : "<<_aScriptFile.toStdString()<<" devient "<<aScriptFile.toStdString());
102     _aScriptFile = aScriptFile ;
103     aYACS->SetScriptFile(CORBA::string_dup(_aScriptFile.toStdString().c_str())) ;
104     chgt = true ;
105   }
106   // A.2. Le maillage initial
107   QString aMeshFile=LEMeshFile->text().trimmed();
108   if ( aMeshFile != _aMeshFile )
109   {
110 //     MESSAGE("modification de aMeshFile : "<<_aMeshFile.toStdString()<<" devient "<<aMeshFile.toStdString());
111     _aMeshFile = aMeshFile ;
112     aYACS->SetMeshFile(CORBA::string_dup(_aMeshFile.toStdString().c_str())) ;
113     chgt = true ;
114   }
115   // A.3. La convergence
116   valeur_i = SpinBoxMaxIter->value() ;
117   if ( valeur_i != _MaxIter )
118   {
119 //     MESSAGE("modification de MaxIter : "<<_MaxIter<<" devient "<<valeur_i);
120     _MaxIter = valeur_i ;
121     aYACS->SetMaxIter(_MaxIter) ;
122     chgt = true ;
123   }
124   valeur_i = SpinBoxMaxNode->value() ;
125   if ( valeur_i != _MaxNode )
126   {
127 //     MESSAGE("modification de MaxNode : "<<_MaxNode<<" devient "<<valeur_i);
128     _MaxNode = valeur_i ;
129     aYACS->SetMaxNode(_MaxNode) ;
130     chgt = true ;
131   }
132   valeur_i = SpinBoxMaxElem->value() ;
133   if ( valeur_i != _MaxElem )
134   {
135 //     MESSAGE("modification de MaxElem : "<<_MaxElem<<" devient "<<valeur_i);
136     _MaxElem = valeur_i ;
137     aYACS->SetMaxElem(_MaxElem) ;
138     chgt = true ;
139   }
140 // B. Si changement
141   if ( chgt )
142   {
143     myHomardGen->InvalideYACS(_Name.toStdString().c_str());
144   }
145
146   HOMARD_UTILS::updateObjBrowser();
147   return true ;
148 }