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);
101 // Les options avancees (non modifiables)
102 CBAdvanced->setVisible(0) ;
103 int NivMax = _aHypothesis->GetNivMax();
104 double DiamMin = _aHypothesis->GetDiamMin();
106 { GBAdvancedOptions->setVisible(1);
107 spinBoxNivMax->setValue(NivMax);
108 spinBoxNivMax->setDisabled(true);
109 doubleSpinBoxDiamMin->setValue(DiamMin);
110 doubleSpinBoxDiamMin->setDisabled(true);
113 { GBAdvancedOptions->setVisible(0); }
117 // ----------------------------------------
118 void MonEditHypothesis::InitAdaptUniforme()
119 // ----------------------------------------
120 // Affichage des informations pour une adaptation uniforme
122 // Choix des options generales
123 GBFieldManagement->setVisible(0);
124 GBAreaManagement->setVisible(0);
125 GBUniform->setVisible(1);
127 RBUniforme->setChecked(true);
128 RBUniforme->setEnabled(false);
129 RBChamp->setEnabled(false);
130 RBZone->setEnabled(false);
132 // Raffinement ou deraffinement ?
135 ASSERT(_aTypeRaff==1);
136 RBUniDera->setChecked(false);
137 RBUniRaff->setChecked(true);
141 ASSERT(_aTypeRaff==0);
142 RBUniDera->setChecked(true);
143 RBUniRaff->setChecked(false);
147 // -------------------------------------
148 void MonEditHypothesis::InitAdaptZone()
149 // -------------------------------------
150 // Affichage des informations pour une adaptation selon des zones :
154 // Choix des options generales
155 GBUniform->setVisible(0);
156 GBFieldManagement->setVisible(0);
157 GBAreaManagement->setVisible(1);
159 RBZone->setChecked(true);
160 RBChamp->setEnabled(false);
161 RBUniforme->setEnabled(false);
162 RBZone->setEnabled(false);
164 // Recuperation de toutes les zones decrites et notation de celles retenues
166 HOMARD::listeZonesHypo_var mesZonesAvant = _aHypothesis->GetZones();
167 for (int i=0; i<mesZonesAvant->length(); i++)
169 for ( int j =0 ; j < TWZone->rowCount(); j++)
171 if (TWZone->item(j,1)->text().toStdString() == string(mesZonesAvant[i]))
173 TWZone->item( j,0 )->setCheckState( Qt::Checked );
179 // Inactivation des choix
180 for ( int j =0 ; j < TWZone->rowCount(); j++)
182 TWZone->item( j, 0 )->setFlags(0);
184 PBZoneNew->setVisible(0);
188 // -------------------------------------
189 void MonEditHypothesis::InitAdaptChamps()
190 // -------------------------------------
191 // Affichage des informations pour une adaptation selon un champ :
197 MESSAGE ("Debut de InitAdaptChamps");
198 // Choix des options generales
199 GBUniform->setVisible(0);
200 GBAreaManagement->setVisible(0);
201 GBFieldManagement->setVisible(1);
203 RBChamp->setChecked(true);
204 RBUniforme->setEnabled(false);
205 RBChamp->setEnabled(false);
206 RBZone->setEnabled(false);
210 HOMARD::InfosHypo_var aInfosHypo = _aHypothesis->GetField();
211 _aFieldName = aInfosHypo->FieldName;
212 _TypeThR = aInfosHypo->TypeThR;
213 _ThreshR = aInfosHypo->ThreshR;
214 _TypeThC = aInfosHypo->TypeThC;
215 _ThreshC = aInfosHypo->ThreshC;
216 _UsField = aInfosHypo->UsField;
217 _UsCmpI = aInfosHypo->UsCmpI;
220 CBFieldName->insertItem(0,_aFieldName);
221 CBFieldName->setCurrentIndex(0);
222 CBFieldName->setEnabled(false);
223 //SetFieldName(Qt::Unchecked);
225 HOMARD::listeComposantsHypo_var mesComposantsAvant = _aHypothesis->GetListComp();
227 TWCMP->setRowCount(0);
228 TWCMP->resizeRowsToContents();
229 for (int i=0; i<mesComposantsAvant->length(); i++)
232 TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
233 TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
234 TWCMP->item( 0, 0 )->setCheckState(Qt::Checked );
235 TWCMP->item( 0, 0 )->setFlags( 0 );
236 TWCMP->setItem( 0, 1, new QTableWidgetItem(QString(mesComposantsAvant[i]).trimmed()));
237 TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
239 TWCMP->resizeColumnsToContents();
240 TWCMP->resizeRowsToContents();
241 TWCMP->clearSelection();
243 // Les seuils de raffinement
244 RBRAbs->setEnabled(false) ;
245 RBRRel->setEnabled(false) ;
246 RBRPE->setEnabled(false) ;
247 RBRNo->setEnabled(false) ;
251 RBRNo->setEnabled(true) ;
255 if ( _TypeThR == 1 ) { SpinBox_RAbs->setValue(_ThreshR); SetRAbs(); RBRAbs->setEnabled(true);}
256 if ( _TypeThR == 2 ) { SpinBox_RRel->setValue(_ThreshR); SetRRel(); RBRRel->setEnabled(true);}
257 if ( _TypeThR == 3 ) { SpinBox_RPE->setValue(_ThreshR); SetRPE(); RBRPE->setEnabled(true);}
260 // Les seuils de deraffinement
261 RBCAbs->setEnabled(false) ;
262 RBCRel->setEnabled(false) ;
263 RBCPE->setEnabled(false) ;
264 RBCNo->setEnabled(false) ;
268 RBCNo->setEnabled(true) ;
272 if ( _TypeThC == 1 ) { SpinBox_CAbs->setValue(_ThreshC); SetCAbs(); RBCAbs->setEnabled(true);}
273 if ( _TypeThC == 2 ) { SpinBox_CRel->setValue(_ThreshC); SetCRel(); RBCRel->setEnabled(true);}
274 if ( _TypeThC == 3 ) { SpinBox_CPE->setValue(_ThreshC); SetCPE(); RBCPE->setEnabled(true);}
276 // Le choix de la prise en compte des composantes
277 if ( TWCMP->rowCount() == 1 )
278 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS"));
279 RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL"));
282 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
283 RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
285 if ( _UsField == 0 ) { CBJump->hide(); }
288 CBJump->setChecked(true);
289 CBJump->setEnabled(false);
293 RBL2->setChecked(true);
294 RBL2->setEnabled(true);
295 RBInf->setEnabled(false) ;
299 RBL2->setEnabled(false) ;
300 RBInf->setChecked(true);
301 RBInf->setEnabled(true);
304 // -------------------------------------
305 void MonEditHypothesis::InitFieldInterp()
306 // -------------------------------------
307 // Affichage des informations pour les interpolations
309 MESSAGE ("Debut de InitFieldInterp");
310 // Choix des options generales
311 _TypeFieldInterp = _aHypothesis->GetTypeFieldInterp();
312 MESSAGE ("_TypeFieldInterp = " << _TypeFieldInterp);
314 // Aucune interpolation
315 if ( _TypeFieldInterp == 0 )
317 RBFieldNo->setChecked(true);
318 TWField->setVisible(0);
320 // Interpolation de tous les champs
321 if ( _TypeFieldInterp == 1 )
323 RBFieldAll->setChecked(true);
324 TWField->setVisible(0);
326 // Interpolation de champs choisis
327 if ( _TypeFieldInterp == 2 )
329 RBFieldChosen->setChecked(true);
331 TWField->setVisible(1);
332 HOMARD::listFieldInterpHypo_var mesChampsAvant = _aHypothesis->GetListFieldInterp();
334 TWField->setRowCount(0);
335 TWField->resizeRowsToContents();
336 for (int i=0; i<mesChampsAvant->length(); i++)
338 TWField->insertRow(0);
339 TWField->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
340 TWField->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
341 TWField->item( 0, 0 )->setCheckState(Qt::Checked );
342 TWField->item( 0, 0 )->setFlags( 0 );
343 TWField->setItem( 0, 1, new QTableWidgetItem(QString(mesChampsAvant[i]).trimmed()));
344 TWField->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
346 TWField->resizeColumnsToContents();
347 TWField->resizeRowsToContents();
348 TWField->clearSelection();
350 RBFieldNo->setEnabled(false) ;
351 RBFieldAll->setEnabled(false) ;
352 RBFieldChosen->setEnabled(false) ;
355 // -------------------------------------
356 bool MonEditHypothesis::PushOnApply()
357 // -------------------------------------
359 // Pour du raffinement selon un champ, les seuils ont-ils change ?
360 if ( _aTypeAdap == 1 )
364 if (_TypeThR == 1) { _ThreshR = SpinBox_RAbs->value(); }
365 if (_TypeThR == 2) { _ThreshR = SpinBox_RRel->value(); }
366 if (_TypeThR == 3) { _ThreshR = SpinBox_RPE->value(); }
367 _aHypothesis->SetRefinThr(_TypeThR, _ThreshR) ;
371 if (_TypeThC == 1) { _ThreshC = SpinBox_CAbs->value() ; }
372 if (_TypeThC == 2) { _ThreshC = SpinBox_CRel->value() ; }
373 if (_TypeThC == 3) { _ThreshC = SpinBox_CPE->value() ; }
374 _aHypothesis->SetUnRefThr(_TypeThC, _ThreshC) ;
377 _myHomardGen->InvalideHypo(_aHypothesisName.toStdString().c_str());
378 HOMARD_UTILS::updateObjBrowser();
382 // ------------------------------------------------------------------------
383 void MonEditHypothesis::SetFiltrage()
384 // ------------------------------------------------------------------------
386 if (CBGroupe->isChecked())
388 MonEditListGroup *aDlg = new MonEditListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),_aCaseName, _aListeGroupes) ;