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