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
20 #include "MonEditHypothesis.h"
21 #include "MonEditListGroup.h"
23 #include "SalomeApp_Tools.h"
24 #include "HOMARDGUI_Utils.h"
25 #include "HomardQtCommun.h"
27 #include <utilities.h>
31 // ----------------------------------------------------------------------------
32 MonEditHypothesis::MonEditHypothesis( MonCreateIteration* parent, bool modal,
33 HOMARD::HOMARD_Gen_var myHomardGen,
35 QString caseName, QString aFieldFile ):
36 // ----------------------------------------------------------------------------
37 /* Constructs a MonEditHypothesis
38 herite de MonCreateHypothesis
40 MonCreateHypothesis(parent, modal,myHomardGen, Name, caseName, aFieldFile)
42 MESSAGE("Hypothese " << Name.toStdString().c_str());
43 setWindowTitle(QObject::tr("HOM_HYPO_EDIT_WINDOW_TITLE"));
44 aHypothesis = myHomardGen->GetHypothesis(_Name.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 LEName->setText(_Name);
71 LEName->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 || _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);
101 // Les options avancees (non modifiables)
102 CBAdvanced->setVisible(0) ;
103 int NivMax = aHypothesis->GetNivMax();
104 double DiamMin = aHypothesis->GetDiamMin();
105 int AdapInit = aHypothesis->GetAdapInit();
106 int LevelOutput = aHypothesis->GetLevelOutput();
107 if ( NivMax > 0 || DiamMin > 0 || AdapInit != 0 || LevelOutput != 0 )
108 { GBAdvancedOptions->setVisible(1);
110 { spinBoxNivMax->setValue(NivMax);
111 spinBoxNivMax->setDisabled(true); }
113 { TLMaximalLevel->setVisible(0);
114 spinBoxNivMax->setVisible(0); }
116 { doubleSpinBoxDiamMin->setValue(DiamMin);
117 doubleSpinBoxDiamMin->setDisabled(true); }
119 { TLMinimalDiameter->setVisible(0);
120 doubleSpinBoxDiamMin->setVisible(0); }
124 { RBAIR->setChecked(true); }
126 { RBAID->setChecked(true); }
127 RBAIN->setEnabled(false);
128 RBAIR->setEnabled(false);
129 RBAID->setEnabled(false);
132 { GBAdapInit->setVisible(0) ;
134 if ( LevelOutput != 0 )
136 CBLevelOutput->setChecked(true);
137 CBLevelOutput->setEnabled(false);
140 { CBLevelOutput->setVisible(0) ;
144 { GBAdvancedOptions->setVisible(0); }
148 // ----------------------------------------
149 void MonEditHypothesis::InitAdaptUniforme()
150 // ----------------------------------------
151 // Affichage des informations pour une adaptation uniforme
153 // Choix des options generales
154 GBFieldManagement->setVisible(0);
155 GBAreaManagement->setVisible(0);
156 GBUniform->setVisible(1);
158 RBUniforme->setChecked(true);
159 RBUniforme->setEnabled(false);
160 RBChamp->setEnabled(false);
161 RBZone->setEnabled(false);
163 // Raffinement ou deraffinement ?
166 VERIFICATION(_aTypeRaff==1);
167 RBUniDera->setChecked(false);
168 RBUniRaff->setChecked(true);
172 VERIFICATION(_aTypeRaff==0);
173 RBUniDera->setChecked(true);
174 RBUniRaff->setChecked(false);
178 // -------------------------------------
179 void MonEditHypothesis::InitAdaptZone()
180 // -------------------------------------
181 // Affichage des informations pour une adaptation selon des zones :
183 MESSAGE ("Debut de InitAdaptZone");
184 // Choix des options generales
185 GBUniform->setVisible(0);
186 GBFieldManagement->setVisible(0);
187 GBAreaManagement->setVisible(1);
189 RBZone->setChecked(true);
190 RBChamp->setEnabled(false);
191 RBUniforme->setEnabled(false);
192 RBZone->setEnabled(false);
194 // Recuperation de toutes les zones decrites et notation de celles retenues
196 HOMARD::listeZonesHypo_var mesZonesAvant = aHypothesis->GetZones();
197 for (int i=0; i<mesZonesAvant->length(); i++)
199 MESSAGE ("i"<<i<<", zone :"<<string(mesZonesAvant[i])<<", type :"<<string(mesZonesAvant[i+1]));
200 for ( int j =0 ; j < TWZone->rowCount(); j++)
202 MESSAGE (". j"<<j<<", zone :"<<TWZone->item(j,2)->text().toStdString());
203 if ( TWZone->item(j,2)->text().toStdString() == string(mesZonesAvant[i]) )
205 MESSAGE ("OK avec "<<string(mesZonesAvant[i]));
206 if ( string(mesZonesAvant[i+1]) == "1" )
208 MESSAGE ("... RAFF");
209 TWZone->item( j,0 )->setCheckState( Qt::Checked );
210 TWZone->item( j,1 )->setCheckState( Qt::Unchecked ); }
213 MESSAGE ("... DERA");
214 TWZone->item( j,0 )->setCheckState( Qt::Unchecked );
215 TWZone->item( j,1 )->setCheckState( Qt::Checked ); }
222 // Inactivation des choix
223 for ( int j =0 ; j < TWZone->rowCount(); j++)
225 TWZone->item( j, 0 )->setFlags(0);
226 TWZone->item( j, 1 )->setFlags(0);
228 PBZoneNew->setVisible(0);
231 // -------------------------------------
232 void MonEditHypothesis::InitAdaptChamps()
233 // -------------------------------------
234 // Affichage des informations pour une adaptation selon un champ :
240 MESSAGE ("Debut de InitAdaptChamps");
241 // Choix des options generales
242 GBUniform->setVisible(0);
243 GBAreaManagement->setVisible(0);
244 GBFieldManagement->setVisible(1);
246 RBChamp->setChecked(true);
247 RBUniforme->setEnabled(false);
248 RBChamp->setEnabled(false);
249 RBZone->setEnabled(false);
251 HOMARD::InfosHypo_var aInfosHypo = aHypothesis->GetField();
252 _aFieldName = aInfosHypo->FieldName;
253 _TypeThR = aInfosHypo->TypeThR;
254 _ThreshR = aInfosHypo->ThreshR;
255 _TypeThC = aInfosHypo->TypeThC;
256 _ThreshC = aInfosHypo->ThreshC;
257 _UsField = aInfosHypo->UsField;
258 _UsCmpI = aInfosHypo->UsCmpI;
260 CBFieldName->insertItem(0,_aFieldName);
261 CBFieldName->setCurrentIndex(0);
262 CBFieldName->setEnabled(false);
263 //SetFieldName(Qt::Unchecked);
265 HOMARD::listeComposantsHypo_var mesComposantsAvant = aHypothesis->GetComps();
267 TWCMP->setRowCount(0);
268 TWCMP->resizeRowsToContents();
269 for (int i=0; i<mesComposantsAvant->length(); i++)
272 TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
273 TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
274 TWCMP->item( 0, 0 )->setCheckState(Qt::Checked );
275 TWCMP->item( 0, 0 )->setFlags( 0 );
276 TWCMP->setItem( 0, 1, new QTableWidgetItem(QString(mesComposantsAvant[i]).trimmed()));
277 TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
279 TWCMP->resizeColumnsToContents();
280 TWCMP->resizeRowsToContents();
281 TWCMP->clearSelection();
283 // Les seuils de raffinement
284 RBRAbs->setEnabled(false) ;
285 RBRRel->setEnabled(false) ;
286 RBRPE->setEnabled(false) ;
287 RBRMuSigma->setEnabled(false) ;
288 RBRNo->setEnabled(false) ;
292 RBRNo->setEnabled(true) ;
296 if ( _TypeThR == 1 ) { SpinBox_RAbs->setValue(_ThreshR); SetRAbs(); RBRAbs->setEnabled(true);}
297 if ( _TypeThR == 2 ) { SpinBox_RRel->setValue(_ThreshR); SetRRel(); RBRRel->setEnabled(true);}
298 if ( _TypeThR == 3 ) { SpinBox_RPE->setValue(_ThreshR); SetRPE(); RBRPE->setEnabled(true);}
299 if ( _TypeThR == 4 ) { SpinBox_RMuSigma->setValue(_ThreshR); SetRMS(); RBRMuSigma->setEnabled(true);}
302 // Les seuils de deraffinement
303 RBCAbs->setEnabled(false) ;
304 RBCRel->setEnabled(false) ;
305 RBCPE->setEnabled(false) ;
306 RBCMuSigma->setEnabled(false) ;
307 RBCNo->setEnabled(false) ;
311 RBCNo->setEnabled(true) ;
315 if ( _TypeThC == 1 ) { SpinBox_CAbs->setValue(_ThreshC); SetCAbs(); RBCAbs->setEnabled(true);}
316 if ( _TypeThC == 2 ) { SpinBox_CRel->setValue(_ThreshC); SetCRel(); RBCRel->setEnabled(true);}
317 if ( _TypeThC == 3 ) { SpinBox_CPE->setValue(_ThreshC); SetCPE(); RBCPE->setEnabled(true);}
318 if ( _TypeThC == 4 ) { SpinBox_CMuSigma->setValue(_ThreshC); SetCMS(); RBCMuSigma->setEnabled(true);}
320 // Le choix de la prise en compte des composantes
321 if ( TWCMP->rowCount() == 1 )
322 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS"));
323 RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL"));
326 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
327 RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
329 if ( _UsField == 0 ) { CBJump->hide(); }
332 CBJump->setChecked(true);
333 CBJump->setEnabled(false);
337 RBL2->setChecked(true);
338 RBL2->setEnabled(true);
339 RBInf->setEnabled(false) ;
343 RBL2->setEnabled(false) ;
344 RBInf->setChecked(true);
345 RBInf->setEnabled(true);
348 // -------------------------------------
349 void MonEditHypothesis::InitFieldInterp()
350 // -------------------------------------
351 // Affichage des informations pour les interpolations
353 MESSAGE ("Debut de InitFieldInterp");
354 // Choix des options generales
355 _TypeFieldInterp = aHypothesis->GetTypeFieldInterp();
356 MESSAGE ("_TypeFieldInterp = " << _TypeFieldInterp);
358 // Aucune interpolation
359 if ( _TypeFieldInterp == 0 )
361 RBFieldNo->setChecked(true);
362 TWField->setVisible(0);
364 // Interpolation de tous les champs
365 if ( _TypeFieldInterp == 1 )
367 RBFieldAll->setChecked(true);
368 TWField->setVisible(0);
370 // Interpolation de champs choisis
371 if ( _TypeFieldInterp == 2 )
373 RBFieldChosen->setChecked(true);
375 TWField->setVisible(1);
376 HOMARD::listeFieldInterpsHypo_var mesChampsAvant = aHypothesis->GetFieldInterps();
378 TWField->setRowCount(0);
379 TWField->resizeRowsToContents();
380 for (int iaux=0; iaux<mesChampsAvant->length(); iaux++)
382 TWField->insertRow(0);
383 TWField->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
384 TWField->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
385 TWField->item( 0, 0 )->setCheckState(Qt::Checked );
386 TWField->item( 0, 0 )->setFlags( 0 );
387 TWField->setItem( 0, 1, new QTableWidgetItem(QString(mesChampsAvant[iaux]).trimmed()));
388 TWField->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
391 TWField->resizeColumnsToContents();
392 TWField->resizeRowsToContents();
393 TWField->clearSelection();
395 RBFieldNo->setEnabled(false) ;
396 RBFieldAll->setEnabled(false) ;
397 RBFieldChosen->setEnabled(false) ;
400 // -------------------------------------
401 bool MonEditHypothesis::PushOnApply()
402 // -------------------------------------
404 // Pour du raffinement selon un champ, les seuils ont-ils change ?
405 if ( _aTypeAdap == 1 )
409 if (_TypeThR == 1) { _ThreshR = SpinBox_RAbs->value(); }
410 if (_TypeThR == 2) { _ThreshR = SpinBox_RRel->value(); }
411 if (_TypeThR == 3) { _ThreshR = SpinBox_RPE->value(); }
412 if (_TypeThR == 4) { _ThreshR = SpinBox_RMuSigma->value(); }
413 aHypothesis->SetRefinThr(_TypeThR, _ThreshR) ;
417 if (_TypeThC == 1) { _ThreshC = SpinBox_CAbs->value() ; }
418 if (_TypeThC == 2) { _ThreshC = SpinBox_CRel->value() ; }
419 if (_TypeThC == 3) { _ThreshC = SpinBox_CPE->value() ; }
420 if (_TypeThC == 4) { _ThreshC = SpinBox_CMuSigma->value() ; }
421 aHypothesis->SetUnRefThr(_TypeThC, _ThreshC) ;
424 myHomardGen->InvalideHypo(_Name.toStdString().c_str());
425 HOMARD_UTILS::updateObjBrowser();
429 // ------------------------------------------------------------------------
430 void MonEditHypothesis::SetFiltrage()
431 // ------------------------------------------------------------------------
433 if (CBGroupe->isChecked())
435 MonEditListGroup *aDlg = new MonEditListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(myHomardGen),_aCaseName, _aListeGroupes) ;