3 #include "MonEditHypothesis.h"
4 #include "MonEditListGroup.h"
8 #include "SalomeApp_Tools.h"
9 #include "HOMARDGUI_Utils.h"
10 #include "HomardQtCommun.h"
11 #include <utilities.h>
14 // -------------------------------------------------------------------------------------------------------------------------------------
15 MonEditHypothesis::MonEditHypothesis( MonCreateIteration* parent, bool modal,
16 HOMARD::HOMARD_Gen_var myHomardGen,
17 QString aHypothesisName,
18 QString caseName, QString aFieldFile ):
19 // -------------------------------------------------------------------------------------------------------------------------------------
20 /* Constructs a MonEditHypothesis
21 herite de MonCreateHypothesis
23 MonCreateHypothesis(parent, modal,myHomardGen, aHypothesisName, caseName, aFieldFile)
25 MESSAGE("Hypothese " << aHypothesisName.toStdString().c_str());
26 setWindowTitle("Edit Hypothesis");
27 _aHypothesis = _myHomardGen->GetHypothesis(_aHypothesisName.toStdString().c_str());
28 if (caseName == QString("") ){ _aCaseName = _aHypothesis->GetCaseCreation();}
32 // ------------------------------
33 MonEditHypothesis::~MonEditHypothesis()
34 // ------------------------------
37 // ------------------------------
38 void MonEditHypothesis::InitGroupes()
39 // ------------------------------
41 HOMARD::ListGroupType_var maListe = _aHypothesis->GetGroups();
42 for ( int i = 0; i < maListe->length(); i++ )
43 _aListeGroupes << QString(maListe[i]);
45 if (maListe->length() == 0) { CBGroupe->hide();}
48 // ------------------------------
49 void MonEditHypothesis::InitValEdit()
50 // ------------------------------
52 MESSAGE("Debut de InitValEdit");
53 LEHypothesisName->setText(_aHypothesisName);
54 LEHypothesisName->setReadOnly(true);
55 HOMARD::listeTypes_var ListTypes (_aHypothesis->GetAdapRefinUnRef());
56 ASSERT( ListTypes->length()==3) ;
57 _aTypeAdap = ListTypes[0];
58 _aTypeRaff = ListTypes[1];
59 _aTypeDera = ListTypes[2];
61 if (_aTypeAdap == -1) InitAdaptUniforme();
62 if (_aTypeAdap == 0) InitAdaptZone();
63 if (_aTypeAdap == 1) InitAdaptChamps();
65 RBUniDera->setDisabled(true);
66 RBUniRaff->setDisabled(true);
70 if (_aTypeAdap == 1 or _TypeFieldInterp >= 1 )
72 if (_aFieldFile == QString("")) { GBFieldFile->setVisible(0); }
75 GBFieldFile->setVisible(1);
76 LEFieldFile->setText(_aFieldFile);
77 LEFieldFile->setReadOnly(1);
82 GBFieldFile->setVisible(0);
86 // ----------------------------------------
87 void MonEditHypothesis::InitAdaptUniforme()
88 // ----------------------------------------
89 // Affichage des informations pour une adaptation uniforme
91 // Choix des options generales
92 GBFieldManagement->setVisible(0);
93 GBAreaManagement->setVisible(0);
94 GBUniform->setVisible(1);
96 RBUniforme->setChecked(true);
97 RBUniforme->setEnabled(false);
98 RBChamp->setEnabled(false);
99 RBZone->setEnabled(false);
101 // Raffinement ou deraffinement ?
104 ASSERT(_aTypeRaff==1);
105 RBUniDera->setChecked(false);
106 RBUniRaff->setChecked(true);
110 ASSERT(_aTypeRaff==0);
111 RBUniDera->setChecked(true);
112 RBUniRaff->setChecked(false);
116 // -------------------------------------
117 void MonEditHypothesis::InitAdaptZone()
118 // -------------------------------------
119 // Affichage des informations pour une adaptation selon des zones :
123 // Choix des options generales
124 GBUniform->setVisible(0);
125 GBFieldManagement->setVisible(0);
126 GBAreaManagement->setVisible(1);
128 RBZone->setChecked(true);
129 RBChamp->setEnabled(false);
130 RBUniforme->setEnabled(false);
131 RBZone->setEnabled(false);
133 // Recuperation de toutes les zones decrites et notation de celles retenues
135 HOMARD::listeZonesHypo_var mesZonesAvant = _aHypothesis->GetZones();
136 for (int i=0; i<mesZonesAvant->length(); i++)
138 for ( int j =0 ; j < TWZone->rowCount(); j++)
140 if (TWZone->item(j,1)->text().toStdString() == string(mesZonesAvant[i]))
142 TWZone->item( j,0 )->setCheckState( Qt::Checked );
148 // Inactivation des choix
149 for ( int j =0 ; j < TWZone->rowCount(); j++)
151 TWZone->item( j, 0 )->setFlags(0);
153 PBZoneNew->setVisible(0);
157 // -------------------------------------
158 void MonEditHypothesis::InitAdaptChamps()
159 // -------------------------------------
160 // Affichage des informations pour une adaptation selon un champ :
166 MESSAGE ("Debut de InitAdaptChamps");
167 // Choix des options generales
168 GBUniform->setVisible(0);
169 GBAreaManagement->setVisible(0);
170 GBFieldManagement->setVisible(1);
172 RBChamp->setChecked(true);
173 RBUniforme->setEnabled(false);
174 RBChamp->setEnabled(false);
175 RBZone->setEnabled(false);
179 HOMARD::InfosHypo_var aInfosHypo = _aHypothesis->GetField();
180 _aFieldName = aInfosHypo->FieldName;
181 _TypeThR = aInfosHypo->TypeThR;
182 _ThreshR = aInfosHypo->ThreshR;
183 _TypeThC = aInfosHypo->TypeThC;
184 _ThreshC = aInfosHypo->ThreshC;
185 _UsCmpI = aInfosHypo->UsCmpI;
188 CBFieldName->insertItem(0,_aFieldName);
189 CBFieldName->setCurrentIndex(0);
190 CBFieldName->setEnabled(false);
191 //SetFieldName(Qt::Unchecked);
193 HOMARD::listeComposantsHypo_var mesComposantsAvant = _aHypothesis->GetListComp();
195 TWCMP->setRowCount(0);
196 TWCMP->resizeRowsToContents();
197 for (int i=0; i<mesComposantsAvant->length(); i++)
200 TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
201 TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
202 TWCMP->item( 0, 0 )->setCheckState(Qt::Checked );
203 TWCMP->item( 0, 0 )->setFlags( 0 );
204 TWCMP->setItem( 0, 1, new QTableWidgetItem(QString(mesComposantsAvant[i]).trimmed()));
205 TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
207 TWCMP->resizeColumnsToContents();
208 TWCMP->resizeRowsToContents();
209 TWCMP->clearSelection();
211 // Les seuils de raffinement
212 RBRAbs->setEnabled(false) ;
213 RBRRel->setEnabled(false) ;
214 RBRPE->setEnabled(false) ;
215 RBRNo->setEnabled(false) ;
219 RBRNo->setEnabled(true) ;
223 if ( _TypeThR == 1 ) { SpinBox_RAbs->setValue(_ThreshR); SetRAbs(); RBRAbs->setEnabled(true);}
224 if ( _TypeThR == 2 ) { SpinBox_RRel->setValue(_ThreshR); SetRRel(); RBRRel->setEnabled(true);}
225 if ( _TypeThR == 3 ) { SpinBox_RPE->setValue(_ThreshR); SetRPE(); RBRPE->setEnabled(true);}
228 // Les seuils de deraffinement
229 RBCAbs->setEnabled(false) ;
230 RBCRel->setEnabled(false) ;
231 RBCPE->setEnabled(false) ;
232 RBCNo->setEnabled(false) ;
236 RBCNo->setEnabled(true) ;
240 if ( _TypeThC == 1 ) { SpinBox_CAbs->setValue(_ThreshC); SetCAbs(); RBCAbs->setEnabled(true);}
241 if ( _TypeThC == 2 ) { SpinBox_CRel->setValue(_ThreshC); SetCRel(); RBCRel->setEnabled(true);}
242 if ( _TypeThC == 3 ) { SpinBox_CPE->setValue(_ThreshC); SetCPE(); RBCPE->setEnabled(true);}
244 // Le choix de la prise en compte des composantes
245 if ( TWCMP->rowCount() == 1 )
246 { RBL2->setText(QString("Absolute value"));
247 RBInf->setText(QString("Relative value"));
250 { RBL2->setText(QString("L2 norm"));
251 RBInf->setText(QString("Infinite Norm"));
255 RBL2->setChecked(true);
256 RBL2->setEnabled(true);
257 RBInf->setEnabled(false) ;
261 RBL2->setEnabled(false) ;
262 RBInf->setChecked(true);
263 RBInf->setEnabled(true);
266 // -------------------------------------
267 void MonEditHypothesis::InitFieldInterp()
268 // -------------------------------------
269 // Affichage des informations pour les interpolations
271 MESSAGE ("Debut de InitFieldInterp");
272 // Choix des options generales
273 _TypeFieldInterp = _aHypothesis->GetTypeFieldInterp();
274 MESSAGE ("_TypeFieldInterp = " << _TypeFieldInterp);
276 // Aucune interpolation
277 if ( _TypeFieldInterp == 0 )
279 RBFieldNo->setChecked(true);
280 TWField->setVisible(0);
282 // Interpolation de tous les champs
283 if ( _TypeFieldInterp == 1 )
285 RBFieldAll->setChecked(true);
286 TWField->setVisible(0);
288 // Interpolation de champs choisis
289 if ( _TypeFieldInterp == 2 )
291 RBFieldChosen->setChecked(true);
293 TWField->setVisible(1);
294 HOMARD::listFieldInterpHypo_var mesChampsAvant = _aHypothesis->GetListFieldInterp();
296 TWField->setRowCount(0);
297 TWField->resizeRowsToContents();
298 for (int i=0; i<mesChampsAvant->length(); i++)
300 TWField->insertRow(0);
301 TWField->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
302 TWField->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
303 TWField->item( 0, 0 )->setCheckState(Qt::Checked );
304 TWField->item( 0, 0 )->setFlags( 0 );
305 TWField->setItem( 0, 1, new QTableWidgetItem(QString(mesChampsAvant[i]).trimmed()));
306 TWField->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
308 TWField->resizeColumnsToContents();
309 TWField->resizeRowsToContents();
310 TWField->clearSelection();
312 RBFieldNo->setEnabled(false) ;
313 RBFieldAll->setEnabled(false) ;
314 RBFieldChosen->setEnabled(false) ;
317 // -------------------------------------
318 bool MonEditHypothesis::PushOnApply()
319 // -------------------------------------
321 // Pour du raffinement selon un champ, les seuils ont-ils change ?
322 if ( _aTypeAdap == 1 )
326 if (_TypeThR == 1) { _ThreshR = SpinBox_RAbs->value(); }
327 if (_TypeThR == 2) { _ThreshR = SpinBox_RRel->value(); }
328 if (_TypeThR == 3) { _ThreshR = SpinBox_RPE->value(); }
329 _aHypothesis->SetRefinThr(_TypeThR, _ThreshR) ;
333 if (_TypeThC == 1) { _ThreshC = SpinBox_CAbs->value() ; }
334 if (_TypeThC == 2) { _ThreshC = SpinBox_CRel->value() ; }
335 if (_TypeThC == 3) { _ThreshC = SpinBox_CPE->value() ; }
336 _aHypothesis->SetUnRefThr(_TypeThC, _ThreshC) ;
339 _myHomardGen->InvalideHypo(_aHypothesisName.toStdString().c_str());
340 HOMARD_UTILS::updateObjBrowser();
344 // ------------------------------------------------------------------------
345 void MonEditHypothesis::SetFiltrage()
346 // ------------------------------------------------------------------------
348 if (CBGroupe->isChecked())
350 MonEditListGroup *aDlg = new MonEditListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),_aCaseName, _aListeGroupes) ;