Salome HOME
Merge from V6_main 01/04/2013
[modules/homard.git] / src / HOMARDGUI / MonCreateHypothesis.cxx
1 // Copyright (C) 2011-2013  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 using namespace std;
21
22 #include "MonCreateHypothesis.h"
23 #include "MonCreateListGroup.h"
24 #include "MonCreateIteration.h"
25 #include "MonCreateZone.h"
26 #include "MonEditZone.h"
27
28 #include <QFileDialog>
29 #include <QMessageBox>
30
31 #include "SalomeApp_Tools.h"
32 #include "HOMARDGUI_Utils.h"
33 #include "HomardQtCommun.h"
34 #include <utilities.h>
35
36 // -------------------------------------------------------------------------------
37 MonCreateHypothesis::MonCreateHypothesis(MonCreateIteration* parent, bool modal,
38                                          HOMARD::HOMARD_Gen_var myHomardGen,
39                                          QString aHypothesisName,
40                                          QString caseName, QString aFieldFile)
41 // ---------------------------------------------------------------------------------
42 /* Constructs a MonCreateHypothesis */
43     :
44     QDialog(0), Ui_CreateHypothesis(),
45     _parent(parent), _aHypothesisName(aHypothesisName),
46     _aCaseName(caseName), _aFieldFile(aFieldFile),
47     _aFieldName(""),
48     _aTypeAdap(-2), _aTypeRaff(1), _aTypeDera(0),
49     _TypeThR(3), _ThreshR(0),
50     _TypeThC(0), _ThreshC(0),
51     _UsField(0), _UsCmpI(0), _TypeFieldInterp(0),
52     _NivMax(-1),
53     _DiamMin(-1.),
54     _AdapInit(0),
55     _LevelOutput(0)
56
57 {
58       MESSAGE("Constructeur") ;
59       _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
60       setupUi(this);
61       setModal(modal);
62       InitConnect();
63
64       SetNewHypothesisName();
65       if (_aFieldFile != QString(""))
66       { RBChamp->setChecked(1);
67         SetChamp();
68       }
69       else
70       { RBUniforme->setChecked(1);
71         SetUniforme();
72       }
73       SetFieldNo();
74       GBAdvancedOptions->setVisible(0);
75       CBLevelOutput->setChecked(false);
76 }
77
78 // ------------------------------------------------------------------------
79 MonCreateHypothesis::~MonCreateHypothesis()
80 // ------------------------------------------------------------------------
81 {
82     // no need to delete child widgets, Qt does it all for us
83 }
84 // ------------------------------------------------------------------------
85 void MonCreateHypothesis::InitConnect()
86 // ------------------------------------------------------------------------
87 {
88     connect( RBUniforme,   SIGNAL(clicked()), this, SLOT(SetUniforme()));
89     connect( RBChamp,      SIGNAL(clicked()), this, SLOT(SetChamp()));
90     connect( RBZone,       SIGNAL(clicked()), this, SLOT(SetZone()));
91     connect( RBUniRaff,    SIGNAL(clicked()), this, SLOT(SetUniRaff()));
92     connect( RBUniDera,    SIGNAL(clicked()), this, SLOT(SetUniDera()));
93
94     connect( CBFieldName,  SIGNAL(activated(int)), this, SLOT( SetFieldName()));
95     connect( RBRPE,        SIGNAL(clicked()), this, SLOT(SetRPE()));
96     connect( RBRRel,       SIGNAL(clicked()), this, SLOT(SetRRel()));
97     connect( RBRMuSigma,   SIGNAL(clicked()), this, SLOT(SetRMS()));
98     connect( RBRAbs,       SIGNAL(clicked()), this, SLOT(SetRAbs()));
99     connect( RBRNo,        SIGNAL(clicked()), this, SLOT(SetRNo()));
100     connect( RBCPE,        SIGNAL(clicked()), this, SLOT(SetCPE()));
101     connect( RBCRel,       SIGNAL(clicked()), this, SLOT(SetCRel()));
102     connect( RBCMuSigma,   SIGNAL(clicked()), this, SLOT(SetCMS()));
103     connect( RBCAbs,       SIGNAL(clicked()), this, SLOT(SetCAbs()));
104     connect( RBCNo,        SIGNAL(clicked()), this, SLOT(SetCNo()));
105     connect( RBL2,         SIGNAL(clicked()), this, SLOT(SetUCL2()));
106     connect( RBInf,        SIGNAL(clicked()), this, SLOT(SetUCInf()));
107     connect( CBJump,       SIGNAL(stateChanged(int)), this, SLOT(SetUseField()));
108     connect( PBZoneNew,    SIGNAL(pressed()), this, SLOT(PushZoneNew()));
109     connect( PBZoneEdit,   SIGNAL(pressed()), this, SLOT(PushZoneEdit()) );
110     connect( PBZoneDelete, SIGNAL(pressed()), this, SLOT(PushZoneDelete()) );
111     connect( CBGroupe,     SIGNAL(stateChanged(int)), this, SLOT(SetFiltrage()));
112
113     connect( RBFieldNo,    SIGNAL(clicked()), this, SLOT(SetFieldNo()));
114     connect( RBFieldAll,   SIGNAL(clicked()), this, SLOT(SetFieldAll()));
115     connect( RBFieldChosen,SIGNAL(clicked()), this, SLOT(SetFieldChosen()));
116
117     connect( CBAdvanced,   SIGNAL(stateChanged(int)), this, SLOT(SetAdvanced()));
118     connect( RBAIN,        SIGNAL(clicked()), this, SLOT(SetAIN()));
119     connect( RBAIR,        SIGNAL(clicked()), this, SLOT(SetAIR()));
120     connect( RBAID,        SIGNAL(clicked()), this, SLOT(SetAID()));
121
122     connect( buttonOk,     SIGNAL(pressed()), this, SLOT( PushOnOK()));
123     connect( buttonApply,  SIGNAL(pressed()), this, SLOT( PushOnApply()));
124     connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
125     connect( buttonHelp,   SIGNAL(pressed()), this, SLOT( PushOnHelp()));
126 }
127
128 // ------------------------------------------------------------------------
129 bool MonCreateHypothesis::PushOnApply()
130 // ------------------------------------------------------------------------
131 // Appele lorsque l'un des boutons Ok ou Apply est presse
132 //
133 {
134 // Verifications
135
136
137   if (LEHypothesisName->text().trimmed()=="") {
138     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
139                               QObject::tr("HOM_HYPO_NAME") );
140     return false;
141   }
142
143   if (VerifieZone()      == false)  return false;
144   if (VerifieComposant() == false)  return false;
145
146 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
147   if (LEHypothesisName->text().trimmed() != _aHypothesisName)
148   {
149     _aHypothesisName=LEHypothesisName->text().trimmed();
150     try
151     {
152      _aHypothesis=_myHomardGen->CreateHypothesis(CORBA::string_dup(_aHypothesisName.toStdString().c_str()) );
153      _parent->addHypothese(_aHypothesisName);
154     }
155     catch( SALOME::SALOME_Exception& S_ex )
156     {
157       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
158                                 QString(CORBA::string_dup(S_ex.details.text)) );
159       return false;
160     }
161   }
162
163 // Mise en place des attributs
164   _aHypothesis->SetAdapRefinUnRef(_aTypeAdap,_aTypeRaff,_aTypeDera);
165   _aHypothesis->SetTypeFieldInterp(_TypeFieldInterp);
166   _aHypothesis->SetCaseCreation(_aCaseName.toStdString().c_str());
167
168   AssocieLesZones();
169   AssocieComposants();
170   AssocieLesGroupes();
171   AssocieFieldInterp();
172
173 // Options avancees
174   if (CBAdvanced->isChecked())
175   {
176 // Enregistrement du niveau maximal
177     _NivMax = spinBoxNivMax->value() ;
178     _aHypothesis->SetNivMax(_NivMax);
179 // Enregistrement du diametre minimal
180     _DiamMin = doubleSpinBoxDiamMin->value() ;
181     _aHypothesis->SetDiamMin(_DiamMin);
182 // Enregistrement de l'intialisation de l'adaptation
183     _aHypothesis->SetAdapInit(_AdapInit);
184 // Sortie des niveaux de raffinement
185     if (CBLevelOutput->isChecked()) { _LevelOutput = 1 ; }
186     _aHypothesis->SetLevelOutput(_LevelOutput);
187   }
188
189   HOMARD_UTILS::updateObjBrowser() ;
190
191   return true;
192 }
193
194
195 // ------------------------------------------------------------------------
196 void MonCreateHypothesis::PushOnOK()
197 // ------------------------------------------------------------------------
198 {
199      if (PushOnApply()) this->close();
200      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
201 }
202 // ------------------------------------------------------------------------
203 void MonCreateHypothesis::PushOnHelp()
204 // ------------------------------------------------------------------------
205 {
206   HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"));
207 }
208 // -------------------------------------------------
209 void MonCreateHypothesis::SetNewHypothesisName()
210 // --------------------------------------------------
211 {
212
213   HOMARD::listeHypotheses_var  MyHypos = _myHomardGen->GetAllHypothesesName();
214   int num = 0;//
215   QString aHypothesisName="";
216   while (aHypothesisName=="" )
217   {
218     aHypothesisName.setNum(num+1) ;
219     aHypothesisName.insert(0, QString("Hypo_")) ;
220     for ( int i=0; i<MyHypos->length(); i++)
221     {
222       if ( aHypothesisName ==  QString(MyHypos[i]))
223       {
224           num=num+1;
225           aHypothesisName="";
226           break;
227       }
228     }
229   }
230   LEHypothesisName->setText(aHypothesisName);
231 }
232
233 //
234 // ------------------------------------------------------------------------
235 void MonCreateHypothesis::SetUniforme()
236 // ------------------------------------------------------------------------
237 {
238   GBFieldManagement->setVisible(0);
239   if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
240   else                         { GBFieldFile->setVisible(1); }
241   GBAreaManagement->setVisible(0);
242   GBUniform->setVisible(1);
243   adjustSize();
244   _aTypeAdap = -1 ;
245 }
246 // ------------------------------------------------------------------------
247 void MonCreateHypothesis::SetChamp()
248 // ------------------------------------------------------------------------
249 {
250   if (_aFieldFile == QString(""))
251   {
252     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
253                               QObject::tr("HOM_HYPO_FIELD_FILE") );
254      close();
255      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
256      return;
257   }
258   LEFieldFile->setText(_aFieldFile);
259   LEFieldFile->setReadOnly(1);
260   InitFields();
261   GBUniform->setVisible(0);
262   GBAreaManagement->setVisible(0);
263   GBFieldManagement->setVisible(1);
264   GBFieldFile->setVisible(1);
265
266   GBUniform->adjustSize();
267   GBAreaManagement->adjustSize();
268   GBFieldManagement->adjustSize();
269   GBFieldFile->adjustSize();
270   adjustSize();
271
272   _aTypeAdap = 1 ;
273 }
274 // ------------------------------------------------------------------------
275 void MonCreateHypothesis::SetZone()
276 // ------------------------------------------------------------------------
277 {
278   GetAllZones();
279   GBUniform->setVisible(0);
280   GBFieldManagement->setVisible(0);
281   if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
282   else                         { GBFieldFile->setVisible(1); }
283   GBAreaManagement->setVisible(1);
284   adjustSize();
285   _aTypeRaff = 1 ;
286   _aTypeDera = 0 ;
287   _aTypeAdap = 0 ;
288 }
289
290 // ------------------------------------------------------------------------
291 void MonCreateHypothesis::PushZoneNew()
292 // ------------------------------------------------------------------------
293 {
294   MESSAGE("Debut de MonCreateHypothesis::PushZoneNew")
295   MonCreateZone *aDlg = new MonCreateZone(this, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName) ;
296   aDlg->show();
297 }
298
299 // ------------------------------------------------------------------------
300 void MonCreateHypothesis::PushZoneEdit()
301 // ------------------------------------------------------------------------
302 {
303   MESSAGE("Debut de MonCreateHypothesis::PushZoneEdit")
304   int colonne = TWZone->currentColumn();
305   QTableWidgetItem * monItem = TWZone->currentItem();
306   if (colonne !=2  or monItem == NULL)
307   {
308     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
309                               QObject::tr("HOM_HYPO_ZONE_1") );
310     return;
311   }
312   QString zoneName = monItem->text().trimmed();
313   MonEditZone *aDlg = new MonEditZone(this, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName, zoneName) ;
314   aDlg->show();
315 }
316 // ------------------------------------------------------------------------
317 void MonCreateHypothesis::PushZoneDelete()
318 // ------------------------------------------------------------------------
319 {
320   MESSAGE("Debut de MonCreateHypothesis::PushZoneDelete")
321   QMessageBox::warning( 0, QObject::tr("HOM_WARNING"),
322                           QObject::tr("HOM_INACTIVE_BUTTON") );
323   return;
324 }
325
326 // ------------------------------------------------------------------------
327 void MonCreateHypothesis::GetAllZones()
328 // ------------------------------------------------------------------------
329 // Recuperation de toutes les zones enregistrees dans l'arbre d'etude
330 // et affichage dans le tableau
331 // Par defaut, aucune n'est selectionnee
332 {
333   MESSAGE("Debut de GetAllZones") ;
334   HOMARD::listeZones_var mesZones = _myHomardGen->GetAllZonesName();
335   int nbrow=TWZone->rowCount();
336   for ( int row=0; row< nbrow; row++)
337   {
338      TWZone->removeRow(row);
339   }
340   TWZone->setRowCount(0);
341   int row=0;
342   for (int i=0; i<mesZones->length(); i++)
343   {
344     TWZone->insertRow(row);
345 //
346     TWZone->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
347     TWZone->item( row, 0 )->setFlags( 0 );
348     TWZone->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
349     TWZone->item( row, 0 )->setCheckState( Qt::Unchecked );
350 //
351     TWZone->setItem( row, 1, new QTableWidgetItem( QString ("") ) );
352     TWZone->item( row, 1 )->setFlags( 0 );
353     TWZone->item( row, 1 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
354     TWZone->item( row, 1 )->setCheckState( Qt::Unchecked );
355 //
356     TWZone->setItem( row, 2, new QTableWidgetItem(QString(mesZones[i]).trimmed()));
357     TWZone->item( row, 2 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
358 //
359     row += 1;
360   }
361   TWZone->resizeColumnsToContents();
362   TWZone->resizeRowsToContents();
363   TWZone->clearSelection();
364 }
365 // ------------------------------------------------------------------------
366 void MonCreateHypothesis::addZoneinTWZone(QString newZone)
367 // ------------------------------------------------------------------------
368 {
369   MESSAGE("Debut de addZoneinTWZone") ;
370   int row = TWZone->rowCount() ;
371 // Par defaut, on suppose qu'une nouvelle zone est destinee au raffinement
372   TWZone->setRowCount( row+1 );
373 //
374   TWZone->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
375   TWZone->item( row, 0 )->setFlags( Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
376   TWZone->item( row, 0 )->setCheckState( Qt::Checked );
377 //
378   TWZone->setItem( row, 1, new QTableWidgetItem( QString ("") ) );
379   TWZone->item( row, 1 )->setFlags( Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
380   TWZone->item( row, 1 )->setCheckState( Qt::Unchecked );
381 //
382   TWZone->setItem( row, 2, new QTableWidgetItem( newZone ) );
383   TWZone->scrollToItem( TWZone->item( row, 2 ) );
384 //
385   TWZone->resizeRowsToContents();
386   TWZone->resizeColumnToContents(1);
387   TWZone->clearSelection();
388 //
389   TWZone->item( row, 2 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
390 }
391 // ------------------------------------------------------------------------
392 QStringList MonCreateHypothesis::GetZonesChecked()
393 // ------------------------------------------------------------------------
394 // Retourne les zones enregistrees
395 {
396   MESSAGE("Debut de GetZonesChecked") ;
397   QStringList ListeZone ;
398 // On ne peut pas avoir selectionne les deux options
399   int Pbm = 0 ;
400   for ( int row=0; row< TWZone->rowCount(); row++)
401   {
402     if ( ( TWZone->item( row, 0 )->checkState() == Qt::Checked ) and ( TWZone->item( row, 1 )->checkState() == Qt::Checked ) )
403     {
404       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
405                                 QObject::tr("HOM_HYPO_ZONE_3") );
406       Pbm = 1 ;
407     }
408   }
409 // Si tout va bien, on affecte
410 // Attention, on insere en tete, donc on commence d'inserer le type, psui le nom de la zone
411   if ( Pbm == 0 )
412   {
413     QString Raff =  "1" ;
414     QString Dera = "-1" ;
415     for ( int row=0; row< TWZone->rowCount(); row++)
416     {
417 //     MESSAGE ("row "<<row<<", zone : "<<TWZone->item(row, 2)->text().toStdString());
418 //  En raffinement :
419       if ( TWZone->item(row,0)->checkState() == Qt::Checked )
420       { ListeZone.insert(0, Raff) ;
421         ListeZone.insert(0, QString(TWZone->item(row, 2)->text()) ) ; }
422 //  En deraffinement :
423       if ( TWZone->item(row,1)->checkState() == Qt::Checked )
424       { ListeZone.insert(0, Dera) ;
425         ListeZone.insert(0, QString(TWZone->item(row, 2)->text()) ) ; }
426     }
427   MESSAGE("Fin de GetZonesChecked ; longueur de ListeZone : "<<ListeZone.count()) ;
428   }
429 //
430 return ListeZone ;
431 }
432 // ------------------------------------------------------------------------
433 QStringList MonCreateHypothesis::GetListCompChecked()
434 // ------------------------------------------------------------------------
435 // Retourne les composantes retenues
436 {
437   MESSAGE( "Debut de GetListCompChecked" );
438   QStringList ListeComposant ;
439
440   ListeComposant.clear();
441   for ( int row=0; row< TWCMP->rowCount(); row++)
442       if ( TWCMP->item( row, 0 )->checkState() == Qt::Checked )
443           ListeComposant.insert(0, QString(TWCMP->item(row, 1)->text()) ) ;
444   // Choix du texte des radio-boutons selon 1 ou plusieurs composantes
445   if ( ListeComposant.count() < 2 )
446   { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS"));
447     RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL"));
448   }
449   else
450   { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
451     RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
452   }
453   return ListeComposant ;
454 //
455 }
456 // ------------------------------------------------------------------------
457 void MonCreateHypothesis::AssocieFieldInterp()
458 // ------------------------------------------------------------------------
459 {
460   if ( _TypeFieldInterp != 2 ) return;
461   for ( int row=0; row< TWField->rowCount(); row++)
462       if ( TWField->item( row, 0 )->checkState() == Qt::Checked )
463       { _aHypothesis->AddFieldInterp(TWField->item(row, 1)->text().toStdString().c_str()); }
464 }
465 // ------------------------------------------------------------------------
466 void MonCreateHypothesis::SetUniRaff()
467 // ------------------------------------------------------------------------
468 {
469   _aTypeRaff = 1 ;
470   _aTypeDera = 0 ;
471 }
472 // ------------------------------------------------------------------------
473 void MonCreateHypothesis::SetUniDera()
474 // ------------------------------------------------------------------------
475 {
476   _aTypeRaff = 0 ;
477   _aTypeDera = 1 ;
478 }
479
480 // ------------------------------------------------------------------------
481 void MonCreateHypothesis::InitFields()
482 // ------------------------------------------------------------------------
483 {
484   CBFieldName->clear();
485   std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
486   // Mise en place de la liste dans le menu pour l'indicateur d'erreur
487   std:: list<QString>::const_iterator it;
488   for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
489   {
490        CBFieldName->insertItem(0,QString(*it));
491   }
492   SetFieldName();
493 }
494 // ---------------------------------------
495 void MonCreateHypothesis::SetFieldName()
496 // -------------------------------------------
497 {
498   MESSAGE("Debut de SetFieldName");
499   _aFieldName=CBFieldName->currentText();
500   if (QString(_aFieldFile) == QString("") or QString(_aFieldName) == QString("") ) { return; }
501
502   int nbrow= TWCMP->rowCount() ;
503   for ( int row=0; row < nbrow ; row++)
504   {
505      TWCMP->removeRow(row);
506   }
507   TWCMP->setRowCount(0);
508   //TWCMP->resizeRowsToContents();
509
510   std::list<QString>  maListe =HOMARD_QT_COMMUN::GetListeComposants(_aFieldFile, _aFieldName);
511   std::list<QString>::const_iterator it;
512   for ( it=maListe.begin() ; it != maListe.end(); it++)
513   {
514        TWCMP->insertRow(0);
515        TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
516        TWCMP->item( 0, 0 )->setFlags( 0 );
517        TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
518        TWCMP->item( 0, 0 )->setCheckState( Qt::Checked );
519        TWCMP->setItem( 0, 1, new QTableWidgetItem(QString((*it)).trimmed()));
520        TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
521   }
522   TWCMP->resizeColumnsToContents();
523   TWCMP->resizeRowsToContents();
524   TWCMP->clearSelection();
525   // Choix du texte des radio-boutons selon 1 ou plusieurs composantes
526   if ( TWCMP->rowCount() == 1 )
527   { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS"));
528     RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL"));
529   }
530   else
531   { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
532     RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
533   }
534   // Par defaut, on propose la valeur absolue / norme L2
535   SetUCL2();
536 }
537 // ------------------------------------------------------------------------
538 void MonCreateHypothesis::SetRPE()
539 // ------------------------------------------------------------------------
540 {
541   _aTypeRaff = 1 ;
542   _TypeThR = 3 ;
543   RBRPE->setChecked(true);
544   SpinBox_RPE->setEnabled(true);
545   SpinBox_RRel->setEnabled(false);
546   SpinBox_RAbs->setEnabled(false);
547   SpinBox_RMuSigma->setEnabled(false);
548 }
549 // ------------------------------------------------------------------------
550 void MonCreateHypothesis::SetRRel()
551 // ------------------------------------------------------------------------
552 {
553   _aTypeRaff = 1 ;
554   _TypeThR = 2 ;
555   RBRRel->setChecked(true);
556   SpinBox_RPE->setEnabled(false);
557   SpinBox_RRel->setEnabled(true);
558   SpinBox_RAbs->setEnabled(false);
559   SpinBox_RMuSigma->setEnabled(false);
560 }
561 // ------------------------------------------------------------------------
562 void MonCreateHypothesis::SetRAbs()
563 // ------------------------------------------------------------------------
564 {
565   _aTypeRaff = 1 ;
566   _TypeThR = 1 ;
567   RBRAbs->setChecked(true);
568   SpinBox_RPE->setEnabled(false);
569   SpinBox_RRel->setEnabled(false);
570   SpinBox_RAbs->setEnabled(true);
571   SpinBox_RMuSigma->setEnabled(false);
572 }
573 // ------------------------------------------------------------------------
574 void MonCreateHypothesis::SetRMS()
575 // ------------------------------------------------------------------------
576 {
577   _aTypeRaff = 1 ;
578   _TypeThR = 4 ;
579   RBRMuSigma->setChecked(true);
580   SpinBox_RPE->setEnabled(false);
581   SpinBox_RRel->setEnabled(false);
582   SpinBox_RAbs->setEnabled(false);
583   SpinBox_RMuSigma->setEnabled(true);
584 }
585 // ------------------------------------------------------------------------
586 void MonCreateHypothesis::SetRNo()
587 // ------------------------------------------------------------------------
588 {
589   _aTypeRaff = 0 ;
590   _TypeThR = 0;
591   RBRNo->setChecked(true);
592   SpinBox_RPE->setEnabled(false);
593   SpinBox_RRel->setEnabled(false);
594   SpinBox_RAbs->setEnabled(false);
595   SpinBox_RMuSigma->setEnabled(false);
596 }
597 // ------------------------------------------------------------------------
598 void MonCreateHypothesis::SetCPE()
599 // ------------------------------------------------------------------------
600 {
601   _aTypeDera = 1 ;
602   _TypeThC = 3 ;
603   RBCPE->setChecked(true);
604   SpinBox_CPE->setEnabled(true);
605   SpinBox_CRel->setEnabled(false);
606   SpinBox_CAbs->setEnabled(false);
607   SpinBox_CMuSigma->setEnabled(false);
608 }
609 // ------------------------------------------------------------------------
610 void MonCreateHypothesis::SetCRel()
611 // ------------------------------------------------------------------------
612 {
613   _aTypeDera = 1 ;
614   _TypeThC = 2 ;
615   RBCRel->setChecked(true);
616   SpinBox_CPE->setEnabled(false);
617   SpinBox_CRel->setEnabled(true);
618   SpinBox_CAbs->setEnabled(false);
619   SpinBox_CMuSigma->setEnabled(false);
620 }
621 // ------------------------------------------------------------------------
622 void MonCreateHypothesis::SetCAbs()
623 // ------------------------------------------------------------------------
624 {
625   _aTypeDera = 1 ;
626   _TypeThC = 1 ;
627   RBCAbs->setChecked(true);
628   SpinBox_CPE->setEnabled(false);
629   SpinBox_CRel->setEnabled(false);
630   SpinBox_CAbs->setEnabled(true);
631   SpinBox_CMuSigma->setEnabled(false);
632 }
633 // ------------------------------------------------------------------------
634 void MonCreateHypothesis::SetCMS()
635 // ------------------------------------------------------------------------
636 {
637   _aTypeDera = 1 ;
638   _TypeThC = 4 ;
639   RBCMuSigma->setChecked(true);
640   SpinBox_CPE->setEnabled(false);
641   SpinBox_CRel->setEnabled(false);
642   SpinBox_CAbs->setEnabled(false);
643   SpinBox_CMuSigma->setEnabled(true);
644 }
645 // ------------------------------------------------------------------------
646 void MonCreateHypothesis::SetCNo()
647 // ------------------------------------------------------------------------
648 {
649   _aTypeDera = 0 ;
650   _TypeThC = 0;
651   RBCNo->setChecked(true);
652   SpinBox_CPE->setEnabled(false);
653   SpinBox_CRel->setEnabled(false);
654   SpinBox_CAbs->setEnabled(false);
655   SpinBox_CMuSigma->setEnabled(false);
656 }
657 // ------------------------------------------------------------------------
658 void MonCreateHypothesis::SetUCL2()
659 // ------------------------------------------------------------------------
660 {
661   _UsCmpI = 0 ;
662   RBL2->setChecked(true);
663 }
664 // ------------------------------------------------------------------------
665 void MonCreateHypothesis::SetUCInf()
666 // ------------------------------------------------------------------------
667 {
668   _UsCmpI = 1 ;
669   RBInf->setChecked(true);
670 }
671 // ------------------------------------------------------------------------
672 void MonCreateHypothesis::SetUseField()
673 // ------------------------------------------------------------------------
674 {
675   if ( CBJump->isChecked() ) { _UsField = 1 ; }
676   else                       { _UsField = 0 ; }
677 }
678 // ------------------------------------------------------------------------
679 void MonCreateHypothesis::SetFiltrage()
680 // ------------------------------------------------------------------------
681 {
682   if (!CBGroupe->isChecked()) return;
683   MonCreateListGroup *aDlg = new MonCreateListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),_aCaseName, _aListeGroupes) ;
684   aDlg->show();
685 }
686
687 // ------------------------------------------------------------------------
688 void MonCreateHypothesis::setGroups(QStringList listGroup)
689 // ------------------------------------------------------------------------
690 {
691     _aListeGroupes=listGroup;
692 }
693 // ------------------------------------------------------------------------
694 bool MonCreateHypothesis::VerifieZone()
695 // ------------------------------------------------------------------------
696 {
697   if ( _aTypeAdap != 0 ) return true;
698   MESSAGE("Debut de VerifieZone") ;
699   _aListeZone = GetZonesChecked() ;
700   MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
701   if (_aListeZone.count() == 0)
702   {
703     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
704                               QObject::tr("HOM_HYPO_ZONE_2") );
705      return false;
706   }
707   MESSAGE("Fin de VerifieZone") ;
708   return true;
709 }
710 // ------------------------------------------------------------------------
711 bool MonCreateHypothesis::VerifieComposant()
712 // ------------------------------------------------------------------------
713 {
714   if ( _aTypeAdap != 1 ) return true;
715   _aListeComposant = GetListCompChecked() ;
716   if (_aListeComposant.count() == 0)
717   {
718     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
719                               QObject::tr("HOM_HYPO_COMP") );
720      return false;
721   }
722   return true;
723 }
724
725 // ------------------------------------------------------------------------
726 void MonCreateHypothesis::AssocieLesZones()
727 // ------------------------------------------------------------------------
728 {
729   MESSAGE( "Debut de AssocieLesZones" );
730   if ( _aTypeAdap != 0 ) return;
731   _aListeZone = GetZonesChecked() ;
732   MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
733   QString Raff =  "1" ;
734   int TypeUse ;
735   for ( int i=0 ; i< _aListeZone.count() ; i++ )
736   { if ( _aListeZone[i+1] == Raff ) { TypeUse =  1 ; }
737     else                            { TypeUse = -1 ; }
738     _aHypothesis->AddZone(_aListeZone[i].toStdString().c_str(), TypeUse);
739     i += 1 ;
740   }
741   MESSAGE( "Fin de AssocieLesZones" );
742 };
743 // ------------------------------------------------------------------------
744 void MonCreateHypothesis::AssocieComposants()
745 // ------------------------------------------------------------------------
746 {
747   if ( _aTypeAdap != 1 ) return;
748   MESSAGE( "Dans AssocieComposants, _TypeThC : " << _TypeThC );
749   MESSAGE( "Dans AssocieComposants, _TypeThR : " << _TypeThR );
750
751   _ThreshR = 0;
752   if ( _TypeThR == 1 ) { _ThreshR = SpinBox_RAbs->value();}
753   if ( _TypeThR == 2 ) { _ThreshR = SpinBox_RRel->value();}
754   if ( _TypeThR == 3 ) { _ThreshR = SpinBox_RPE->value(); }
755   if ( _TypeThR == 4 ) { _ThreshR = SpinBox_RMuSigma->value(); }
756
757   _ThreshC = 0;
758   if ( _TypeThC == 1 ) { _ThreshC = SpinBox_CAbs->value();}
759   if ( _TypeThC == 2 ) { _ThreshC = SpinBox_CRel->value();}
760   if ( _TypeThC == 3 ) { _ThreshC = SpinBox_CPE->value(); }
761   if ( _TypeThC == 4 ) { _ThreshC = SpinBox_CMuSigma->value(); }
762
763   _aFieldName=CBFieldName->currentText();
764   _aHypothesis->SetField(CORBA::string_dup(_aFieldName.toStdString().c_str()) ) ;
765   _aHypothesis->SetRefinThr( _TypeThR, _ThreshR ) ;
766   _aHypothesis->SetUnRefThr( _TypeThC, _ThreshC ) ;
767   _aHypothesis->SetUseField( _UsField ) ;
768   _aHypothesis->SetUseComp( _UsCmpI ) ;
769   _aListeComposant = GetListCompChecked() ;
770   for ( int i=0 ; i< _aListeComposant.count() ; i++ )
771       { _aHypothesis->AddComp(_aListeComposant[i].toStdString().c_str()); }
772 };
773 // ------------------------------------------------------------------------
774 void MonCreateHypothesis::AssocieLesGroupes()
775 // ------------------------------------------------------------------------
776 {
777   HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
778   aSeqGroupe->length(_aListeGroupes.size());
779   QStringList::const_iterator it;
780   int i=0;
781   for (it = _aListeGroupes.constBegin(); it != _aListeGroupes.constEnd(); it++)
782      aSeqGroupe[i++]=(*it).toStdString().c_str();
783   _aHypothesis->SetGroups(aSeqGroupe);
784
785 }
786 // ------------------------------------------------------------------------
787 void MonCreateHypothesis::SetFieldNo()
788 // ------------------------------------------------------------------------
789 // Par defaut, on n'interpole rien
790 {
791   if ( _aTypeAdap == 1 ) { GBFieldFile->setVisible(1); }
792   else                   { GBFieldFile->setVisible(0); }
793   TWField->setVisible(0);
794 //
795    adjustSize();
796   _TypeFieldInterp = 0 ;
797 }
798 // ------------------------------------------------------------------------
799 void MonCreateHypothesis::SetFieldAll()
800 // ------------------------------------------------------------------------
801 // Par defaut, on interpole tout
802 {
803   if (_aFieldFile == QString(""))
804   {
805     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
806                               QObject::tr("HOM_HYPO_FIELD_FILE") );
807      close();
808      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
809      return;
810   }
811   LEFieldFile->setText(_aFieldFile);
812   LEFieldFile->setReadOnly(1);
813   GBFieldFile->setVisible(1);
814   TWField->setVisible(0);
815 //
816   _TypeFieldInterp = 1 ;
817    adjustSize();
818 }
819 // ------------------------------------------------------------------------
820 void MonCreateHypothesis::SetFieldChosen()
821 // ------------------------------------------------------------------------
822 {
823   if (_aFieldFile == QString(""))
824   {
825     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
826                               QObject::tr("HOM_HYPO_FIELD_FILE") );
827      close();
828      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
829      return;
830   }
831   LEFieldFile->setText(_aFieldFile);
832   LEFieldFile->setReadOnly(1);
833   GBFieldFile->setVisible(1);
834   // Recuperation de la liste des champs contenus dans le fichier _aFieldFile
835   std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
836
837   // Initialisation de la table
838   TWField->clear();
839   int nbrow=TWField->rowCount();
840   for ( int row=0; row< nbrow; row++)
841   {
842      TWField->removeRow(row);
843   }
844   TWField->setRowCount(0);
845   std:: list<QString>::const_iterator it;
846   int row=0;
847   for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
848   {
849     TWField->insertRow(row);
850     TWField->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
851     TWField->item( row, 0 )->setFlags( 0 );
852     TWField->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
853     TWField->item( row, 0 )->setCheckState( Qt::Unchecked );
854     TWField->setItem( row, 1, new QTableWidgetItem(QString(*it).trimmed()));
855     TWField->item( row, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
856     row=row+1;
857   }
858   TWField->resizeColumnsToContents();
859   TWField->resizeRowsToContents();
860   TWField->clearSelection();
861   TWField->setVisible(1);
862
863   _TypeFieldInterp = 2 ;
864    adjustSize();
865 }
866 // ------------------------------------------------------------------------
867 void MonCreateHypothesis::SetAdvanced()
868 // ------------------------------------------------------------------------
869 {
870   MESSAGE("Debut de SetAdvanced ");
871   if (CBAdvanced->isChecked())
872   { GBAdvancedOptions->setVisible(1);
873     if (_aFieldFile != QString(""))
874     { GBAdapInit->setVisible(1) ;
875     }
876     else
877     { GBAdapInit->setVisible(0) ;
878     }
879   }
880   else
881   { GBAdvancedOptions->setVisible(0);
882     _NivMax = -1 ;
883     _DiamMin = -1. ;
884     _AdapInit = 0 ;
885     CBLevelOutput->setChecked(false);
886     _LevelOutput = 0 ;
887   }
888   adjustSize();
889 }
890 // ------------------------------------------------------------------------
891 void MonCreateHypothesis::SetAIN()
892 // ------------------------------------------------------------------------
893 {
894   MESSAGE("Debut de SetAIN ");
895   _AdapInit = 0 ;
896 }
897 // ------------------------------------------------------------------------
898 void MonCreateHypothesis::SetAIR()
899 // ------------------------------------------------------------------------
900 {
901   MESSAGE("Debut de SetAIR ");
902   _AdapInit = 1 ;
903 }
904 // ------------------------------------------------------------------------
905 void MonCreateHypothesis::SetAID()
906 // ------------------------------------------------------------------------
907 {
908   MESSAGE("Debut de SetAID ");
909   _AdapInit = -1 ;
910 }