1 // Copyright (C) 2011 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 "MonEditHypothesis.h"
23 #include "MonEditListGroup.h"
25 #include "SalomeApp_Tools.h"
26 #include "HOMARDGUI_Utils.h"
27 #include "HomardQtCommun.h"
28 #include <utilities.h>
31 // -------------------------------------------------------------------------------------------------------------------------------------
32 MonEditHypothesis::MonEditHypothesis( MonCreateIteration* parent, bool modal,
33 HOMARD::HOMARD_Gen_var myHomardGen,
34 QString aHypothesisName,
35 QString caseName, QString aFieldFile ):
36 // -------------------------------------------------------------------------------------------------------------------------------------
37 /* Constructs a MonEditHypothesis
38 herite de MonCreateHypothesis
40 MonCreateHypothesis(parent, modal,myHomardGen, aHypothesisName, caseName, aFieldFile)
42 MESSAGE("Hypothese " << aHypothesisName.toStdString().c_str());
43 setWindowTitle(QObject::tr("HOM_HYPO_EDIT_WINDOW_TITLE"));
44 _aHypothesis = _myHomardGen->GetHypothesis(_aHypothesisName.toStdString().c_str());
45 if (caseName == QString("") ){ _aCaseName = _aHypothesis->GetCaseCreation();}
49 // ------------------------------
50 MonEditHypothesis::~MonEditHypothesis()
51 // ------------------------------
54 // ------------------------------
55 void MonEditHypothesis::InitGroupes()
56 // ------------------------------
58 HOMARD::ListGroupType_var maListe = _aHypothesis->GetGroups();
59 for ( int i = 0; i < maListe->length(); i++ )
60 _aListeGroupes << QString(maListe[i]);
62 if (maListe->length() == 0) { CBGroupe->hide();}
65 // ------------------------------
66 void MonEditHypothesis::InitValEdit()
67 // ------------------------------
69 MESSAGE("Debut de InitValEdit");
70 LEHypothesisName->setText(_aHypothesisName);
71 LEHypothesisName->setReadOnly(true);
72 HOMARD::listeTypes_var ListTypes (_aHypothesis->GetAdapRefinUnRef());
73 ASSERT( ListTypes->length()==3) ;
74 _aTypeAdap = ListTypes[0];
75 _aTypeRaff = ListTypes[1];
76 _aTypeDera = ListTypes[2];
78 if (_aTypeAdap == -1) InitAdaptUniforme();
79 if (_aTypeAdap == 0) InitAdaptZone();
80 if (_aTypeAdap == 1) InitAdaptChamps();
82 RBUniDera->setDisabled(true);
83 RBUniRaff->setDisabled(true);
87 if (_aTypeAdap == 1 or _TypeFieldInterp >= 1 )
89 if (_aFieldFile == QString("")) { GBFieldFile->setVisible(0); }
92 GBFieldFile->setVisible(1);
93 LEFieldFile->setText(_aFieldFile);
94 LEFieldFile->setReadOnly(1);
99 GBFieldFile->setVisible(0);
103 // ----------------------------------------
104 void MonEditHypothesis::InitAdaptUniforme()
105 // ----------------------------------------
106 // Affichage des informations pour une adaptation uniforme
108 // Choix des options generales
109 GBFieldManagement->setVisible(0);
110 GBAreaManagement->setVisible(0);
111 GBUniform->setVisible(1);
113 RBUniforme->setChecked(true);
114 RBUniforme->setEnabled(false);
115 RBChamp->setEnabled(false);
116 RBZone->setEnabled(false);
118 // Raffinement ou deraffinement ?
121 ASSERT(_aTypeRaff==1);
122 RBUniDera->setChecked(false);
123 RBUniRaff->setChecked(true);
127 ASSERT(_aTypeRaff==0);
128 RBUniDera->setChecked(true);
129 RBUniRaff->setChecked(false);
133 // -------------------------------------
134 void MonEditHypothesis::InitAdaptZone()
135 // -------------------------------------
136 // Affichage des informations pour une adaptation selon des zones :
140 // Choix des options generales
141 GBUniform->setVisible(0);
142 GBFieldManagement->setVisible(0);
143 GBAreaManagement->setVisible(1);
145 RBZone->setChecked(true);
146 RBChamp->setEnabled(false);
147 RBUniforme->setEnabled(false);
148 RBZone->setEnabled(false);
150 // Recuperation de toutes les zones decrites et notation de celles retenues
152 HOMARD::listeZonesHypo_var mesZonesAvant = _aHypothesis->GetZones();
153 for (int i=0; i<mesZonesAvant->length(); i++)
155 for ( int j =0 ; j < TWZone->rowCount(); j++)
157 if (TWZone->item(j,1)->text().toStdString() == string(mesZonesAvant[i]))
159 TWZone->item( j,0 )->setCheckState( Qt::Checked );
165 // Inactivation des choix
166 for ( int j =0 ; j < TWZone->rowCount(); j++)
168 TWZone->item( j, 0 )->setFlags(0);
170 PBZoneNew->setVisible(0);
174 // -------------------------------------
175 void MonEditHypothesis::InitAdaptChamps()
176 // -------------------------------------
177 // Affichage des informations pour une adaptation selon un champ :
183 MESSAGE ("Debut de InitAdaptChamps");
184 // Choix des options generales
185 GBUniform->setVisible(0);
186 GBAreaManagement->setVisible(0);
187 GBFieldManagement->setVisible(1);
189 RBChamp->setChecked(true);
190 RBUniforme->setEnabled(false);
191 RBChamp->setEnabled(false);
192 RBZone->setEnabled(false);
196 HOMARD::InfosHypo_var aInfosHypo = _aHypothesis->GetField();
197 _aFieldName = aInfosHypo->FieldName;
198 _TypeThR = aInfosHypo->TypeThR;
199 _ThreshR = aInfosHypo->ThreshR;
200 _TypeThC = aInfosHypo->TypeThC;
201 _ThreshC = aInfosHypo->ThreshC;
202 _UsField = aInfosHypo->UsField;
203 _UsCmpI = aInfosHypo->UsCmpI;
206 CBFieldName->insertItem(0,_aFieldName);
207 CBFieldName->setCurrentIndex(0);
208 CBFieldName->setEnabled(false);
209 //SetFieldName(Qt::Unchecked);
211 HOMARD::listeComposantsHypo_var mesComposantsAvant = _aHypothesis->GetListComp();
213 TWCMP->setRowCount(0);
214 TWCMP->resizeRowsToContents();
215 for (int i=0; i<mesComposantsAvant->length(); i++)
218 TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
219 TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
220 TWCMP->item( 0, 0 )->setCheckState(Qt::Checked );
221 TWCMP->item( 0, 0 )->setFlags( 0 );
222 TWCMP->setItem( 0, 1, new QTableWidgetItem(QString(mesComposantsAvant[i]).trimmed()));
223 TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
225 TWCMP->resizeColumnsToContents();
226 TWCMP->resizeRowsToContents();
227 TWCMP->clearSelection();
229 // Les seuils de raffinement
230 RBRAbs->setEnabled(false) ;
231 RBRRel->setEnabled(false) ;
232 RBRPE->setEnabled(false) ;
233 RBRNo->setEnabled(false) ;
237 RBRNo->setEnabled(true) ;
241 if ( _TypeThR == 1 ) { SpinBox_RAbs->setValue(_ThreshR); SetRAbs(); RBRAbs->setEnabled(true);}
242 if ( _TypeThR == 2 ) { SpinBox_RRel->setValue(_ThreshR); SetRRel(); RBRRel->setEnabled(true);}
243 if ( _TypeThR == 3 ) { SpinBox_RPE->setValue(_ThreshR); SetRPE(); RBRPE->setEnabled(true);}
246 // Les seuils de deraffinement
247 RBCAbs->setEnabled(false) ;
248 RBCRel->setEnabled(false) ;
249 RBCPE->setEnabled(false) ;
250 RBCNo->setEnabled(false) ;
254 RBCNo->setEnabled(true) ;
258 if ( _TypeThC == 1 ) { SpinBox_CAbs->setValue(_ThreshC); SetCAbs(); RBCAbs->setEnabled(true);}
259 if ( _TypeThC == 2 ) { SpinBox_CRel->setValue(_ThreshC); SetCRel(); RBCRel->setEnabled(true);}
260 if ( _TypeThC == 3 ) { SpinBox_CPE->setValue(_ThreshC); SetCPE(); RBCPE->setEnabled(true);}
262 // Le choix de la prise en compte des composantes
263 if ( TWCMP->rowCount() == 1 )
264 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS"));
265 RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL"));
268 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
269 RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
271 if ( _UsField == 0 ) { CBJump->hide(); }
274 CBJump->setChecked(true);
275 CBJump->setEnabled(false);
279 RBL2->setChecked(true);
280 RBL2->setEnabled(true);
281 RBInf->setEnabled(false) ;
285 RBL2->setEnabled(false) ;
286 RBInf->setChecked(true);
287 RBInf->setEnabled(true);
290 // -------------------------------------
291 void MonEditHypothesis::InitFieldInterp()
292 // -------------------------------------
293 // Affichage des informations pour les interpolations
295 MESSAGE ("Debut de InitFieldInterp");
296 // Choix des options generales
297 _TypeFieldInterp = _aHypothesis->GetTypeFieldInterp();
298 MESSAGE ("_TypeFieldInterp = " << _TypeFieldInterp);
300 // Aucune interpolation
301 if ( _TypeFieldInterp == 0 )
303 RBFieldNo->setChecked(true);
304 TWField->setVisible(0);
306 // Interpolation de tous les champs
307 if ( _TypeFieldInterp == 1 )
309 RBFieldAll->setChecked(true);
310 TWField->setVisible(0);
312 // Interpolation de champs choisis
313 if ( _TypeFieldInterp == 2 )
315 RBFieldChosen->setChecked(true);
317 TWField->setVisible(1);
318 HOMARD::listFieldInterpHypo_var mesChampsAvant = _aHypothesis->GetListFieldInterp();
320 TWField->setRowCount(0);
321 TWField->resizeRowsToContents();
322 for (int i=0; i<mesChampsAvant->length(); i++)
324 TWField->insertRow(0);
325 TWField->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
326 TWField->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
327 TWField->item( 0, 0 )->setCheckState(Qt::Checked );
328 TWField->item( 0, 0 )->setFlags( 0 );
329 TWField->setItem( 0, 1, new QTableWidgetItem(QString(mesChampsAvant[i]).trimmed()));
330 TWField->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
332 TWField->resizeColumnsToContents();
333 TWField->resizeRowsToContents();
334 TWField->clearSelection();
336 RBFieldNo->setEnabled(false) ;
337 RBFieldAll->setEnabled(false) ;
338 RBFieldChosen->setEnabled(false) ;
341 // -------------------------------------
342 bool MonEditHypothesis::PushOnApply()
343 // -------------------------------------
345 // Pour du raffinement selon un champ, les seuils ont-ils change ?
346 if ( _aTypeAdap == 1 )
350 if (_TypeThR == 1) { _ThreshR = SpinBox_RAbs->value(); }
351 if (_TypeThR == 2) { _ThreshR = SpinBox_RRel->value(); }
352 if (_TypeThR == 3) { _ThreshR = SpinBox_RPE->value(); }
353 _aHypothesis->SetRefinThr(_TypeThR, _ThreshR) ;
357 if (_TypeThC == 1) { _ThreshC = SpinBox_CAbs->value() ; }
358 if (_TypeThC == 2) { _ThreshC = SpinBox_CRel->value() ; }
359 if (_TypeThC == 3) { _ThreshC = SpinBox_CPE->value() ; }
360 _aHypothesis->SetUnRefThr(_TypeThC, _ThreshC) ;
363 _myHomardGen->InvalideHypo(_aHypothesisName.toStdString().c_str());
364 HOMARD_UTILS::updateObjBrowser();
368 // ------------------------------------------------------------------------
369 void MonEditHypothesis::SetFiltrage()
370 // ------------------------------------------------------------------------
372 if (CBGroupe->isChecked())
374 MonEditListGroup *aDlg = new MonEditListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),_aCaseName, _aListeGroupes) ;