1 // Copyright (C) 2011-2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "MonEditIteration.h"
24 #include "SalomeApp_Tools.h"
25 #include "HOMARDGUI_Utils.h"
26 #include "HomardQtCommun.h"
27 #include <utilities.h>
30 // -------------------------------------------------------------------------------------------------------------------------------------
31 MonEditIteration::MonEditIteration ( QWidget* parent, bool modal,
32 HOMARD::HOMARD_Gen_var myHomardGen,
33 QString IterParentName, QString IterName ):
34 // -------------------------------------------------------------------------------------------------------------------------------------
35 /* Constructs a MonEditIteration
36 herite de MonCreateIteration
38 MonCreateIteration(parent, modal, myHomardGen, IterParentName),
39 _rank(-1), _step(-1), _IterationName(""), _FieldFile(""),_aTypeAdap()
41 MESSAGE("Debut de MonEditIteration" << IterName.toStdString().c_str());
42 setWindowTitle(QObject::tr("HOM_ITER_EDIT_WINDOW_TITLE"));
43 _IterationName = IterName;
44 aIter = myHomardGen->GetIteration(_IterationName.toStdString().c_str());
46 // Attention au cas ou c'est une iteration initiale : il faut inhiber l'essentiel
47 int etat = aIter->GetState() ;
48 if ( etat <= 0 ) { InitValEdit0(etat); }
49 else { InitValEdit(); }
51 // ------------------------------
52 MonEditIteration::~MonEditIteration()
53 // ------------------------------
57 // ------------------------------
58 void MonEditIteration::InitValEdit0(int etat)
59 // ------------------------------
60 // Cas d'une iteration initiale d'un cas (initial ou poursuite)
63 LEName->setText(_IterationName);
64 LEName->setReadOnly(true);
66 // Invisibilite de l'iteration parent
67 Iter_Parent->setVisible(0);
68 PBIterParent->setVisible(0);
69 LEIterationParentName->setVisible(0);
71 // Affichage bloque du nom du maillage de l'iteration courante
72 QString MeshName = aIter->GetMeshName();
73 Mesh_n->setText(QObject::tr("HOM_ITER_STARTING_POINT_0"));
74 LEMeshName_n->setText(MeshName);
75 LEMeshName_n->setReadOnly(1);
78 if ( etat == 0 ) { Mesh_np1->setText(QObject::tr("HOM_ITER_STARTING_POINT_1")) ; }
79 else { Mesh_np1->setText(QObject::tr("HOM_ITER_STARTING_POINT_2")) ; }
80 LEMeshName_np1->setVisible(0);
82 // Invisibilite des hypotheses et des champs
83 Hypothese->setVisible(0);
84 GBField->setVisible(0);
88 // ------------------------------
89 void MonEditIteration::InitValEdit()
90 // ------------------------------
91 // Cas d'une iteration courante
93 // Affichage bloque du nom de l'iteration
94 LEName->setText(_IterationName);
95 LEName->setReadOnly(true);
97 // Affichage bloque du nom de l'iteration parent
98 _IterParentName = aIter->GetIterParentName();
99 LEIterationParentName->setText(_IterParentName);
100 LEIterationParentName->setReadOnly(true);
101 PBIterParent->setEnabled(false);
102 PBIterParent->setVisible(0);
104 // Affichage bloque du nom du maillage de l'iteration parent
105 aIterParent = myHomardGen->GetIteration(_IterParentName.toStdString().c_str());
106 QString MeshNameParent = aIterParent->GetMeshName();
107 LEMeshName_n->setText(MeshNameParent);
108 LEMeshName_n->setReadOnly(1);
110 // Affichage bloque du nom du maillage de l'iteration courante
111 QString MeshName = aIter->GetMeshName();
112 LEMeshName_np1->setText(MeshName);
113 LEMeshName_np1->setReadOnly(1);
115 // Affichage de la bonne hypothese
116 QString HypoName = aIter->GetHypoName();
117 CBHypothese->insertItem(0,HypoName);
118 CBHypothese->setCurrentIndex(0);
119 CBHypothese->setEnabled(false);
120 PBHypoNew->setVisible(0);
122 // Pour une adaptation selon un champ
123 HOMARD::HOMARD_Hypothesis_var myHypo = myHomardGen->GetHypothesis(HypoName.toStdString().c_str()) ;
124 _aTypeAdap = myHypo->GetAdapType() ;
125 if ( _aTypeAdap == 1 )
127 _FieldFile = aIter->GetFieldFile();
128 LEFieldFile->setText(_FieldFile);
129 _step = aIter->GetTimeStep() ;
130 SpinBox_TimeStep->setValue(_step);
131 _rank = aIter->GetRank() ;
132 SpinBox_Rank->setValue(_rank);
134 // Cas ou on prend le dernier pas de temps ou sans pas de temps
138 SpinBox_Rank->setVisible(0);
139 TimeStep->setVisible(0);
140 SpinBox_TimeStep->setVisible(0);
142 if ( _step == -2 ) { RBLast->setChecked(true); }
143 else { RBNo->setChecked(true); }
146 // Cas avec pas de temps
150 SpinBox_Rank->setVisible(1);
151 TimeStep->setVisible(1);
152 SpinBox_TimeStep->setVisible(1);
153 RBChosen->setChecked(true);
158 GBField->setVisible(0);
164 // -------------------------------------
165 bool MonEditIteration::PushOnApply()
166 // -------------------------------------
168 if ( _aTypeAdap == 1)
170 // Pour du raffinement selon un champ, les instants ont-ils change ?
171 if ( (_FieldFile != LEFieldFile->text().trimmed()) or
172 ( _rank != SpinBox_Rank->value()) or
173 ( _step != SpinBox_TimeStep->value()))
175 _FieldFile = LEFieldFile->text().trimmed();
176 aIter->SetFieldFile(CORBA::string_dup(_FieldFile.toStdString().c_str()));
177 _rank = SpinBox_Rank->value();
178 _step = SpinBox_TimeStep->value();
179 if ( _step == -2 ) { aIter->SetTimeStepRankLast(); }
180 else { aIter->SetTimeStepRank(_step, _rank); }
181 myHomardGen->InvalideIter(_IterationName.toStdString().c_str());
182 HOMARD_UTILS::updateObjBrowser();