Salome HOME
version 5_1_4 HOMARD_SRC
[modules/homard.git] / src / HOMARDGUI / MonCreateHypothesis.cxx
1 using namespace std;
2
3 #include "MonCreateHypothesis.h"
4 #include "MonCreateListGroup.h"
5 #include "MonCreateIteration.h"
6 #include "MonCreateZone.h"
7 #include "MonEditZone.h"
8
9 #include <QFileDialog>
10 #include <QMessageBox>
11
12 #include "SalomeApp_Tools.h"
13 #include "HOMARDGUI_Utils.h"
14 #include "HomardQtCommun.h"
15 #include <utilities.h>
16
17 // -------------------------------------------------------------------------------
18 MonCreateHypothesis::MonCreateHypothesis(MonCreateIteration* parent, bool modal,
19                                          HOMARD::HOMARD_Gen_var myHomardGen,
20                                          QString aHypothesisName,
21                                          QString caseName, QString aFieldFile)
22 // ---------------------------------------------------------------------------------
23 /* Constructs a MonCreateHypothesis */
24     :
25     QDialog(0), Ui_CreateHypothesis(),
26     _parent(parent), _aHypothesisName(aHypothesisName),
27     _aCaseName(caseName), _aFieldFile(aFieldFile), 
28     _aFieldName(""),
29     _aTypeAdap(-2), _aTypeRaff(1), _aTypeDera(0),
30     _TypeThR(3), _ThreshR(0),
31     _TypeThC(0), _ThreshC(0),
32     _UsCmpI(0), _TypeFieldInterp(0)
33 {
34       MESSAGE("Constructeur") ;
35       _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
36       setupUi(this);
37       setModal(modal);
38       InitConnect();
39
40       SetNewHypothesisName();
41       if (_aFieldFile != QString("")) {
42           RBChamp->setChecked(1);
43           SetChamp();
44       } else {
45           RBUniforme->setChecked(1);
46           SetUniforme();
47       }
48       SetFieldNo();
49 }
50
51 // ------------------------------------------------------------------------
52 MonCreateHypothesis::~MonCreateHypothesis()
53 // ------------------------------------------------------------------------
54 {
55     // no need to delete child widgets, Qt does it all for us
56 }
57 // ------------------------------------------------------------------------
58 void MonCreateHypothesis::InitConnect()
59 // ------------------------------------------------------------------------
60 {
61     connect( RBUniforme,   SIGNAL(clicked()), this, SLOT(SetUniforme()));
62     connect( RBChamp,      SIGNAL(clicked()), this, SLOT(SetChamp()));
63     connect( RBZone,       SIGNAL(clicked()), this, SLOT(SetZone()));
64     connect( RBUniRaff,    SIGNAL(clicked()), this, SLOT(SetUniRaff()));
65     connect( RBUniDera,    SIGNAL(clicked()), this, SLOT(SetUniDera()));
66     connect( CBFieldName,  SIGNAL(activated(int)), this, SLOT( SetFieldName()));
67     connect( RBRPE,        SIGNAL(clicked()), this, SLOT(SetRPE()));
68     connect( RBRRel,       SIGNAL(clicked()), this, SLOT(SetRRel()));
69     connect( RBRAbs,       SIGNAL(clicked()), this, SLOT(SetRAbs()));
70     connect( RBRNo,        SIGNAL(clicked()), this, SLOT(SetRNo()));
71     connect( RBCPE,        SIGNAL(clicked()), this, SLOT(SetCPE()));
72     connect( RBCRel,       SIGNAL(clicked()), this, SLOT(SetCRel()));
73     connect( RBCAbs,       SIGNAL(clicked()), this, SLOT(SetCAbs()));
74     connect( RBCNo,        SIGNAL(clicked()), this, SLOT(SetCNo()));
75     connect( RBL2,         SIGNAL(clicked()), this, SLOT(SetUCL2()));
76     connect( RBInf,        SIGNAL(clicked()), this, SLOT(SetUCInf()));
77     connect( PBZoneNew,    SIGNAL(pressed()), this, SLOT(PushZoneNew()));
78     connect( PBZoneEdit,   SIGNAL(pressed()), this, SLOT(PushZoneEdit()) );
79     connect( PBZoneDelete, SIGNAL(pressed()), this, SLOT(PushZoneDelete()) );
80     connect( CBGroupe,     SIGNAL(stateChanged(int)), this, SLOT(SetFiltrage()));
81     connect( RBFieldNo,    SIGNAL(clicked()), this, SLOT(SetFieldNo()));
82     connect( RBFieldAll,   SIGNAL(clicked()), this, SLOT(SetFieldAll()));
83     connect( RBFieldChosen,SIGNAL(clicked()), this, SLOT(SetFieldChosen()));
84     connect( buttonOk,     SIGNAL(pressed()), this, SLOT( PushOnOK()));
85     connect( buttonApply,  SIGNAL(pressed()), this, SLOT( PushOnApply()));
86     connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
87     connect( buttonHelp,   SIGNAL(pressed()), this, SLOT( PushOnHelp()));
88 }
89
90 // ------------------------------------------------------------------------
91 bool MonCreateHypothesis::PushOnApply()
92 // ------------------------------------------------------------------------
93 // Appele lorsque l'un des boutons Ok ou Apply est presse
94 //
95 {
96 // Verifications
97
98
99   if (LEHypothesisName->text().trimmed()=="") {
100     QMessageBox::information( 0, "Error",
101                               "The hypothesis must be named.",
102                               QMessageBox::Ok + QMessageBox::Default );
103     return false;
104   }
105
106   if (VerifieZone()     == false)  return false;
107   if (VerifieComposant() == false)  return false;
108
109 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
110   if (LEHypothesisName->text().trimmed() != _aHypothesisName)
111   {
112     _aHypothesisName=LEHypothesisName->text().trimmed();
113     try
114     {
115      _aHypothesis=_myHomardGen->CreateHypothesis(CORBA::string_dup(_aHypothesisName.toStdString().c_str()) );
116      _parent->addHypothese(_aHypothesisName);
117     }
118     catch( SALOME::SALOME_Exception& S_ex )
119     {
120       QMessageBox::information( 0, "Error",
121                   QString(CORBA::string_dup(S_ex.details.text)),
122                   QMessageBox::Ok + QMessageBox::Default );
123       return false;
124     }
125   }
126
127 // Mise en place des attributs
128   _aHypothesis->SetAdapRefinUnRef(_aTypeAdap,_aTypeRaff,_aTypeDera);
129   _aHypothesis->SetTypeFieldInterp(_TypeFieldInterp);
130   _aHypothesis->SetCaseCreation(_aCaseName.toStdString().c_str());
131
132   AssocieLesZones();
133   AssocieComposants();
134   AssocieLesGroupes();
135   AssocieFieldInterp();
136
137   HOMARD_UTILS::updateObjBrowser();
138   return true;
139 }
140
141
142 // ------------------------------------------------------------------------
143 void MonCreateHypothesis::PushOnOK()
144 // ------------------------------------------------------------------------
145 {
146      if (PushOnApply()) this->close();
147      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
148 }
149 // ------------------------------------------------------------------------
150 void MonCreateHypothesis::PushOnHelp()
151 // ------------------------------------------------------------------------
152 {
153   HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"));
154 }
155 // -------------------------------------------------
156 void MonCreateHypothesis::SetNewHypothesisName()
157 // --------------------------------------------------
158 {
159
160   HOMARD::listeHypotheses_var  MyHypos = _myHomardGen->GetAllHypotheses();
161   int num = 0;// 
162   QString aHypothesisName="";
163   while (aHypothesisName=="" )
164   {
165     aHypothesisName.setNum(num+1) ;
166     aHypothesisName.insert(0, QString("Hypo_")) ;
167     for ( int i=0; i<MyHypos->length(); i++)
168     {
169       if ( aHypothesisName ==  QString(MyHypos[i]))
170       {
171           num=num+1;
172           aHypothesisName="";
173           break;
174       }
175     }
176   }
177   LEHypothesisName->setText(aHypothesisName);
178 }
179
180 //
181 // ------------------------------------------------------------------------
182 void MonCreateHypothesis::SetUniforme()
183 // ------------------------------------------------------------------------
184 {
185   GBFieldManagement->setVisible(0);
186   if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
187   else                         { GBFieldFile->setVisible(1); }
188   GBAreaManagement->setVisible(0);
189   GBUniform->setVisible(1);
190   adjustSize();
191   _aTypeAdap = -1 ;
192 }
193 // ------------------------------------------------------------------------
194 void MonCreateHypothesis::SetChamp()
195 // ------------------------------------------------------------------------
196 {
197   if (_aFieldFile == QString(""))
198   {
199      QMessageBox::information( 0, "Error",
200                               QString("Enter FieldFile please "),
201                               QMessageBox::Ok + QMessageBox::Default );
202      close();
203      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
204      return;
205   }
206   LEFieldFile->setText(_aFieldFile);
207   LEFieldFile->setReadOnly(1);
208   InitFields();
209   GBUniform->setVisible(0);
210   GBAreaManagement->setVisible(0);
211   GBFieldManagement->setVisible(1);
212   GBFieldFile->setVisible(1);
213
214   GBUniform->adjustSize();
215   GBAreaManagement->adjustSize();
216   GBFieldManagement->adjustSize();
217   GBFieldFile->adjustSize();
218   adjustSize();
219
220   _aTypeAdap = 1 ;
221 }
222 // ------------------------------------------------------------------------
223 void MonCreateHypothesis::SetZone()
224 // ------------------------------------------------------------------------
225 {
226   GetAllZones();
227   GBUniform->setVisible(0);
228   GBFieldManagement->setVisible(0);
229   if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
230   else                         { GBFieldFile->setVisible(1); }
231   GBAreaManagement->setVisible(1);
232   adjustSize();
233   _aTypeRaff = 1 ;
234   _aTypeDera = 0 ;
235   _aTypeAdap = 0 ;
236 }
237
238 // ------------------------------------------------------------------------
239 void MonCreateHypothesis::PushZoneNew()
240 // ------------------------------------------------------------------------
241 {
242   MESSAGE("Debut de PushZoneNew")
243   MonCreateZone *aDlg = new MonCreateZone(this, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName) ;
244   aDlg->show();
245 }
246
247 // ------------------------------------------------------------------------
248 void MonCreateHypothesis::PushZoneEdit()
249 // ------------------------------------------------------------------------
250 {
251   MESSAGE("Debut de PushZoneEdit")
252   int colonne = TWZone->currentColumn();
253   QTableWidgetItem * monItem = TWZone->currentItem();
254   if (colonne !=1  or monItem == NULL) 
255   {
256     QMessageBox::information( 0, "Error",
257                               "Please, Select a Zone",
258                               QMessageBox::Ok + QMessageBox::Default );
259     return;
260   }
261   QString zoneName = monItem->text().trimmed();
262   MonEditZone *aDlg = new MonEditZone(this, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName, zoneName) ;
263   aDlg->show();
264 }
265 // ------------------------------------------------------------------------
266 void MonCreateHypothesis::PushZoneDelete()
267 // ------------------------------------------------------------------------
268 {
269   MESSAGE("Debut de PushZoneDelete")
270   QMessageBox::information( 0, "Error",
271                             "Inactive button.",
272                             QMessageBox::Ok + QMessageBox::Default );
273   return;
274 }
275
276 // ------------------------------------------------------------------------
277 void MonCreateHypothesis::GetAllZones()
278 // ------------------------------------------------------------------------
279 // Recuperation de toutes les zones enregistrees dans l'arbre d'etude
280 {
281   HOMARD::listeZones_var  mesZones = _myHomardGen->GetAllZones();
282   TWZone->clear();
283   int stop=TWZone->rowCount();
284   for ( int row=0; row< stop; row++)
285   {
286      TWZone->removeRow(row);
287   }
288   TWZone->setRowCount(0);
289   int row=0;
290   for (int i=0; i<mesZones->length(); i++)
291   {
292     TWZone->insertRow(row);
293     TWZone->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
294     TWZone->item( row, 0 )->setFlags( 0 );
295     TWZone->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
296     TWZone->item( row, 0 )->setCheckState( Qt::Unchecked );
297     TWZone->setItem( row, 1, new QTableWidgetItem(QString(mesZones[i])));
298     TWZone->item( row, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
299     row=row+1;
300   }
301   TWZone->resizeColumnsToContents();
302   TWZone->resizeRowsToContents();
303   TWZone->clearSelection();
304 }
305     
306 // ------------------------------------------------------------------------
307 void MonCreateHypothesis::addZone(QString newZone)
308 // ------------------------------------------------------------------------
309 {
310   int row = TWZone->rowCount() ;
311   TWZone->setRowCount( row+1 );
312   TWZone->setItem( row, 0, new QTableWidgetItem( 0 ) );
313   TWZone->item( row, 0 )->setFlags( Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
314   TWZone->item( row, 0 )->setCheckState( Qt::Checked );
315   TWZone->setItem( row, 1, new QTableWidgetItem( newZone ) );
316   TWZone->scrollToItem( TWZone->item( row, 1 ) );
317   TWZone->resizeRowsToContents();
318   TWZone->resizeColumnToContents(1);
319   TWZone->clearSelection();
320   TWZone->item( row, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
321 }
322
323 // ------------------------------------------------------------------------
324 QStringList MonCreateHypothesis::GetZonesChecked()
325 // ------------------------------------------------------------------------
326 // Retourne les zones enregistrees
327 {
328   QStringList ListeZone ;
329   for ( int row=0; row< TWZone->rowCount(); row++)
330   {
331       if ( TWZone->item( row, 0 )->checkState() ==  Qt::Checked )
332           ListeZone.insert(0, QString(TWZone->item(row, 1)->text()) ) ;
333   }
334   return ListeZone ;
335 }
336
337 // ------------------------------------------------------------------------
338 QStringList MonCreateHypothesis::GetListCompChecked()
339 // ------------------------------------------------------------------------
340 // Retourne les composantes retenues
341 {
342   MESSAGE( "Dans GetListCompChecked" );
343   QStringList ListeComposant ;
344
345   ListeComposant.clear();
346   for ( int row=0; row< TWCMP->rowCount(); row++)
347       if ( TWCMP->item( row, 0 )->checkState() ==  Qt::Checked )
348           ListeComposant.insert(0, QString(TWCMP->item(row, 1)->text()) ) ;
349   // Choix du texte des radio-boutons selon 1 ou plusieurs composantes
350   if ( ListeComposant.count() < 2 )
351   { RBL2->setText(QString("Absolute value"));
352     RBInf->setText(QString("Relative value"));
353   }
354   else
355   { RBL2->setText(QString("L2 norm"));
356     RBInf->setText(QString("Infinite Norm"));
357   }
358   return ListeComposant ;
359 //
360 }
361 // ------------------------------------------------------------------------
362 void MonCreateHypothesis::AssocieFieldInterp()
363 // ------------------------------------------------------------------------
364 {
365   if ( _TypeFieldInterp != 2 ) return;
366   for ( int row=0; row< TWField->rowCount(); row++)
367       if ( TWField->item( row, 0 )->checkState() ==  Qt::Checked )
368       { _aHypothesis->AddFieldInterp(TWField->item(row, 1)->text().toStdString().c_str()); }
369 }
370 // ------------------------------------------------------------------------
371 void MonCreateHypothesis::SetUniRaff()
372 // ------------------------------------------------------------------------
373 {
374   _aTypeRaff = 1 ;
375   _aTypeDera = 0 ;
376 }
377 // ------------------------------------------------------------------------
378 void MonCreateHypothesis::SetUniDera()
379 // ------------------------------------------------------------------------
380 {
381   _aTypeRaff = 0 ;
382   _aTypeDera = 1 ;
383 }
384
385 // ------------------------------------------------------------------------
386 void MonCreateHypothesis::InitFields()
387 // ------------------------------------------------------------------------
388 {
389   CBFieldName->clear();
390   std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
391   // Mise en place de la liste dans le menu pour l'indicateur d'erreur
392   std:: list<QString>::const_iterator it;
393   for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
394   {
395        CBFieldName->insertItem(0,QString(*it));
396   }
397   SetFieldName();
398 }
399 // ---------------------------------------
400 void MonCreateHypothesis::SetFieldName()
401 // -------------------------------------------
402 {
403   _aFieldName=CBFieldName->currentText();
404   if (QString(_aFieldFile) == QString("") or QString(_aFieldName) == QString("") ) { return; }
405
406   for ( int row=0; row < TWCMP->rowCount() ; row++)
407   {
408      TWCMP->removeRow(row);
409   }
410   //TWCMP->setRowCount(0);
411   //TWCMP->resizeRowsToContents();
412
413   std::list<QString>  maListe =HOMARD_QT_COMMUN::GetListeComposants(_aFieldFile, _aFieldName);
414   std::list<QString>::const_iterator it;
415   for ( it=maListe.begin() ; it != maListe.end(); it++)
416   {
417        TWCMP->insertRow(0);
418        TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
419        TWCMP->item( 0, 0 )->setFlags( 0 );
420        TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
421        TWCMP->item( 0, 0 )->setCheckState( Qt::Checked );
422        TWCMP->setItem( 0, 1, new QTableWidgetItem(QString((*it))));
423        TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
424   }
425   TWCMP->resizeColumnsToContents();
426   TWCMP->resizeRowsToContents();
427   TWCMP->clearSelection();
428   // Choix du texte des radio-boutons selon 1 ou plusieurs composantes
429   if ( TWCMP->rowCount() == 1 )
430   { RBL2->setText(QString("Absolute value"));
431     RBInf->setText(QString("Relative value"));
432   }
433   else
434   { RBL2->setText(QString("L2 norm"));
435     RBInf->setText(QString("Infinite Norm"));
436   }
437   // Par defaut, on propose la valeur absolue / norme L2
438   SetUCL2();
439 }
440 // ------------------------------------------------------------------------
441 void MonCreateHypothesis::SetRPE()
442 // ------------------------------------------------------------------------
443 {
444   _aTypeRaff = 1 ;
445   _TypeThR = 3 ;
446   RBRPE->setChecked(true);
447   SpinBox_RPE->setEnabled(true);
448   SpinBox_RRel->setEnabled(false);
449   SpinBox_RAbs->setEnabled(false);
450 }
451 // ------------------------------------------------------------------------
452 void MonCreateHypothesis::SetRRel()
453 // ------------------------------------------------------------------------
454 {
455   _aTypeRaff = 1 ;
456   _TypeThR = 2 ;
457   RBRRel->setChecked(true);
458   SpinBox_RPE->setEnabled(false);
459   SpinBox_RRel->setEnabled(true);
460   SpinBox_RAbs->setEnabled(false);
461 }
462 // ------------------------------------------------------------------------
463 void MonCreateHypothesis::SetRAbs()
464 // ------------------------------------------------------------------------
465 {
466   _aTypeRaff = 1 ;
467   _TypeThR = 1 ;
468   RBRAbs->setChecked(true);
469   SpinBox_RPE->setEnabled(false);
470   SpinBox_RRel->setEnabled(false);
471   SpinBox_RAbs->setEnabled(true);
472 }
473 // ------------------------------------------------------------------------
474 void MonCreateHypothesis::SetRNo()
475 // ------------------------------------------------------------------------
476 {
477   _aTypeRaff = 0 ;
478   _TypeThR = 0;
479   RBRNo->setChecked(true);
480   SpinBox_RPE->setEnabled(false);
481   SpinBox_RRel->setEnabled(false);
482   SpinBox_RAbs->setEnabled(false);
483 }
484 // ------------------------------------------------------------------------
485 void MonCreateHypothesis::SetCPE()
486 // ------------------------------------------------------------------------
487 {
488   _aTypeDera = 1 ;
489   _TypeThC = 3 ;
490   RBCPE->setChecked(true);
491   SpinBox_CPE->setEnabled(true);
492   SpinBox_CRel->setEnabled(false);
493   SpinBox_CAbs->setEnabled(false);
494 }
495 // ------------------------------------------------------------------------
496 void MonCreateHypothesis::SetCRel()
497 // ------------------------------------------------------------------------
498 {
499   _aTypeDera = 1 ;
500   _TypeThC = 2 ;
501   RBCRel->setChecked(true);
502   SpinBox_CPE->setEnabled(false);
503   SpinBox_CRel->setEnabled(true);
504   SpinBox_CAbs->setEnabled(false);
505 }
506 // ------------------------------------------------------------------------
507 void MonCreateHypothesis::SetCAbs()
508 // ------------------------------------------------------------------------
509 {
510   _aTypeDera = 1 ;
511   _TypeThC = 1 ;
512   RBCAbs->setChecked(true);
513   SpinBox_CPE->setEnabled(false);
514   SpinBox_CRel->setEnabled(false);
515   SpinBox_CAbs->setEnabled(true);
516 }
517 // ------------------------------------------------------------------------
518 void MonCreateHypothesis::SetCNo()
519 // ------------------------------------------------------------------------
520 {
521   _aTypeDera = 0 ;
522   _TypeThC = 0;
523   RBCNo->setChecked(true);
524   SpinBox_CPE->setEnabled(false);
525   SpinBox_CRel->setEnabled(false);
526   SpinBox_CAbs->setEnabled(false);
527 }
528 // ------------------------------------------------------------------------
529 void MonCreateHypothesis::SetUCL2()
530 // ------------------------------------------------------------------------
531 {
532   _UsCmpI = 0 ;
533   RBL2->setChecked(true);
534 }
535 // ------------------------------------------------------------------------
536 void MonCreateHypothesis::SetUCInf()
537 // ------------------------------------------------------------------------
538 {
539   _UsCmpI = 1 ;
540   RBInf->setChecked(true);
541 }
542 // ------------------------------------------------------------------------
543 void MonCreateHypothesis::SetFiltrage()
544 // ------------------------------------------------------------------------
545 {
546   if (!CBGroupe->isChecked()) return;
547   MonCreateListGroup *aDlg = new MonCreateListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),_aCaseName, _aListeGroupes) ;
548   aDlg->show();
549 }
550
551 // ------------------------------------------------------------------------
552 void MonCreateHypothesis::setGroups(QStringList listGroup)
553 // ------------------------------------------------------------------------
554 {
555     _aListeGroupes=listGroup;
556 }
557 // ------------------------------------------------------------------------
558 bool MonCreateHypothesis::VerifieZone()
559 // ------------------------------------------------------------------------
560 {
561   if ( _aTypeAdap != 0 ) return true;
562   _aListeZone = GetZonesChecked() ;
563   if (_aListeZone.count() == 0)
564   {
565      QMessageBox::information( 0, "Error",
566                               QString("At least, one zone must be given."),
567                               QMessageBox::Ok + QMessageBox::Default );
568      return false;
569   }
570   return true;
571 }
572 // ------------------------------------------------------------------------
573 bool MonCreateHypothesis::VerifieComposant()
574 // ------------------------------------------------------------------------
575 {
576   if ( _aTypeAdap != 1 ) return true;
577   _aListeComposant = GetListCompChecked() ;
578   if (_aListeComposant.count() == 0)
579   {
580      QMessageBox::information( 0, "Error",
581                               QString("At least, one composant must be given."),
582                                QMessageBox::Ok + QMessageBox::Default );
583      return false;
584   }
585   return true;
586 }
587
588 // ------------------------------------------------------------------------
589 void MonCreateHypothesis::AssocieLesZones()
590 // ------------------------------------------------------------------------
591 {
592   if ( _aTypeAdap != 0 ) return;
593   _aListeZone = GetZonesChecked() ;
594   for ( int i=0 ; i< _aListeZone.count() ; i++ )
595       { _myHomardGen->AssociateHypoZone(_aListeZone[i].toStdString().c_str(),_aHypothesisName.toStdString().c_str()); }
596 };
597 // ------------------------------------------------------------------------
598 void MonCreateHypothesis::AssocieComposants()
599 // ------------------------------------------------------------------------
600 {
601   if ( _aTypeAdap != 1 ) return;
602   MESSAGE( "Dans AssocieComposants, _TypeThC : " << _TypeThC );
603   MESSAGE( "Dans AssocieComposants, _TypeThR : " << _TypeThR );
604
605   _ThreshR = 0;
606   if ( _TypeThR == 1 ) { _ThreshR = SpinBox_RAbs->value();}
607   if ( _TypeThR == 2 ) { _ThreshR = SpinBox_RRel->value();}
608   if ( _TypeThR == 3 ) { _ThreshR = SpinBox_RPE->value(); }
609
610   _ThreshC = 0;
611   if ( _TypeThC == 1 ) { _ThreshC = SpinBox_CAbs->value();}
612   if ( _TypeThC == 2 ) { _ThreshC = SpinBox_CRel->value();}
613   if ( _TypeThC == 3 ) { _ThreshC = SpinBox_CPE->value(); }
614
615   _aFieldName=CBFieldName->currentText();
616   _aHypothesis->SetField(CORBA::string_dup(_aFieldName.toStdString().c_str()) ) ;
617   _aHypothesis->SetRefinThr( _TypeThR, _ThreshR ) ;
618   _aHypothesis->SetUnRefThr( _TypeThC, _ThreshC ) ;
619   _aHypothesis->SetUseComp( _UsCmpI ) ;
620   _aListeComposant = GetListCompChecked() ;
621   for ( int i=0 ; i< _aListeComposant.count() ; i++ )
622       { _aHypothesis->AddComp(_aListeComposant[i].toStdString().c_str()); }
623 };
624 // ------------------------------------------------------------------------
625 void MonCreateHypothesis::AssocieLesGroupes()
626 // ------------------------------------------------------------------------
627 {
628   HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
629   aSeqGroupe->length(_aListeGroupes.size());
630   QStringList::const_iterator it;
631   int i=0;
632   for (it = _aListeGroupes.constBegin(); it != _aListeGroupes.constEnd(); it++)
633      aSeqGroupe[i++]=(*it).toStdString().c_str();
634   _aHypothesis->SetGroups(aSeqGroupe);
635
636 }
637 // ------------------------------------------------------------------------
638 void MonCreateHypothesis::SetFieldNo()
639 // ------------------------------------------------------------------------
640 // Par defaut, on n'interpole rien
641 {
642   if ( _aTypeAdap == 1 ) { GBFieldFile->setVisible(1); }
643   else                   { GBFieldFile->setVisible(0); }
644   TWField->setVisible(0);
645 //
646    adjustSize();
647   _TypeFieldInterp = 0 ;
648 }
649 // ------------------------------------------------------------------------
650 void MonCreateHypothesis::SetFieldAll()
651 // ------------------------------------------------------------------------
652 // Par defaut, on interpole tout
653 {
654   if (_aFieldFile == QString(""))
655   {
656      QMessageBox::information( 0, "Error",
657                               QString("Enter FieldFile please "),
658                               QMessageBox::Ok + QMessageBox::Default );
659      close();
660      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
661      return;
662   }
663   LEFieldFile->setText(_aFieldFile);
664   LEFieldFile->setReadOnly(1);
665   GBFieldFile->setVisible(1);
666   TWField->setVisible(0);
667 //
668   _TypeFieldInterp = 1 ;
669    adjustSize();
670 }
671 // ------------------------------------------------------------------------
672 void MonCreateHypothesis::SetFieldChosen()
673 // ------------------------------------------------------------------------
674 {
675   if (_aFieldFile == QString(""))
676   {
677      QMessageBox::information( 0, "Error",
678                               QString("Enter FieldFile please "),
679                               QMessageBox::Ok + QMessageBox::Default );
680      close();
681      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
682      return;
683   }
684   LEFieldFile->setText(_aFieldFile);
685   LEFieldFile->setReadOnly(1);
686   GBFieldFile->setVisible(1);
687   // Recuperation de la liste des champs contenus dans le fichier _aFieldFile
688   std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
689
690   // Initialisation de la table
691   TWField->clear();
692   for ( int row=0; row< TWField->rowCount(); row++)
693      TWField->removeRow(row);
694
695   TWField->setRowCount(0);
696   std:: list<QString>::const_iterator it;
697   int row=0;
698   for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
699   {
700     TWField->insertRow(row);
701     TWField->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
702     TWField->item( row, 0 )->setFlags( 0 );
703     TWField->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
704     TWField->item( row, 0 )->setCheckState( Qt::Unchecked );
705     TWField->setItem( row, 1, new QTableWidgetItem(QString(*it)));
706     TWField->item( row, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
707     row=row+1;
708   }
709   TWField->resizeColumnsToContents();
710   TWField->resizeRowsToContents();
711   TWField->clearSelection();
712   TWField->setVisible(1);
713
714   _TypeFieldInterp = 2 ;
715    adjustSize();
716 }