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