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