Salome HOME
interpolation des champs
[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   {
464     if ( TWField->item( row, 0 )->checkState() == Qt::Checked )
465     {
466       aHypothesis->AddFieldInterp(TWField->item(row, 1)->text().toStdString().c_str());
467     }
468   }
469 }
470 // ------------------------------------------------------------------------
471 void MonCreateHypothesis::SetUniRaff()
472 // ------------------------------------------------------------------------
473 {
474   _aTypeRaff = 1 ;
475   _aTypeDera = 0 ;
476 }
477 // ------------------------------------------------------------------------
478 void MonCreateHypothesis::SetUniDera()
479 // ------------------------------------------------------------------------
480 {
481   _aTypeRaff = 0 ;
482   _aTypeDera = 1 ;
483 }
484
485 // ------------------------------------------------------------------------
486 void MonCreateHypothesis::InitFields()
487 // ------------------------------------------------------------------------
488 {
489   CBFieldName->clear();
490   std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
491   // Mise en place de la liste dans le menu pour l'indicateur d'erreur
492   std:: list<QString>::const_iterator it;
493   for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
494   {
495        CBFieldName->insertItem(0,QString(*it));
496   }
497   SetFieldName();
498 }
499 // ---------------------------------------
500 void MonCreateHypothesis::SetFieldName()
501 // -------------------------------------------
502 {
503   MESSAGE("Debut de SetFieldName");
504   _aFieldName=CBFieldName->currentText();
505   if (QString(_aFieldFile) == QString("") or QString(_aFieldName) == QString("") ) { return; }
506
507   int nbrow= TWCMP->rowCount() ;
508   for ( int row=0; row < nbrow ; row++)
509   {
510      TWCMP->removeRow(row);
511   }
512   TWCMP->setRowCount(0);
513   //TWCMP->resizeRowsToContents();
514
515   std::list<QString>  maListe =HOMARD_QT_COMMUN::GetListeComposants(_aFieldFile, _aFieldName);
516   std::list<QString>::const_iterator it;
517   for ( it=maListe.begin() ; it != maListe.end(); it++)
518   {
519        TWCMP->insertRow(0);
520        TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
521        TWCMP->item( 0, 0 )->setFlags( 0 );
522        TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
523        TWCMP->item( 0, 0 )->setCheckState( Qt::Checked );
524        TWCMP->setItem( 0, 1, new QTableWidgetItem(QString((*it)).trimmed()));
525        TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
526   }
527   TWCMP->resizeColumnsToContents();
528   TWCMP->resizeRowsToContents();
529   TWCMP->clearSelection();
530   // Choix du texte des radio-boutons selon 1 ou plusieurs composantes
531   if ( TWCMP->rowCount() == 1 )
532   { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS"));
533     RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL"));
534   }
535   else
536   { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
537     RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
538   }
539   // Par defaut, on propose la valeur absolue / norme L2
540   SetUCL2();
541 }
542 // ------------------------------------------------------------------------
543 void MonCreateHypothesis::SetRPE()
544 // ------------------------------------------------------------------------
545 {
546   _aTypeRaff = 1 ;
547   _TypeThR = 3 ;
548   RBRPE->setChecked(true);
549   SpinBox_RPE->setEnabled(true);
550   SpinBox_RRel->setEnabled(false);
551   SpinBox_RAbs->setEnabled(false);
552   SpinBox_RMuSigma->setEnabled(false);
553 }
554 // ------------------------------------------------------------------------
555 void MonCreateHypothesis::SetRRel()
556 // ------------------------------------------------------------------------
557 {
558   _aTypeRaff = 1 ;
559   _TypeThR = 2 ;
560   RBRRel->setChecked(true);
561   SpinBox_RPE->setEnabled(false);
562   SpinBox_RRel->setEnabled(true);
563   SpinBox_RAbs->setEnabled(false);
564   SpinBox_RMuSigma->setEnabled(false);
565 }
566 // ------------------------------------------------------------------------
567 void MonCreateHypothesis::SetRAbs()
568 // ------------------------------------------------------------------------
569 {
570   _aTypeRaff = 1 ;
571   _TypeThR = 1 ;
572   RBRAbs->setChecked(true);
573   SpinBox_RPE->setEnabled(false);
574   SpinBox_RRel->setEnabled(false);
575   SpinBox_RAbs->setEnabled(true);
576   SpinBox_RMuSigma->setEnabled(false);
577 }
578 // ------------------------------------------------------------------------
579 void MonCreateHypothesis::SetRMS()
580 // ------------------------------------------------------------------------
581 {
582   _aTypeRaff = 1 ;
583   _TypeThR = 4 ;
584   RBRMuSigma->setChecked(true);
585   SpinBox_RPE->setEnabled(false);
586   SpinBox_RRel->setEnabled(false);
587   SpinBox_RAbs->setEnabled(false);
588   SpinBox_RMuSigma->setEnabled(true);
589 }
590 // ------------------------------------------------------------------------
591 void MonCreateHypothesis::SetRNo()
592 // ------------------------------------------------------------------------
593 {
594   _aTypeRaff = 0 ;
595   _TypeThR = 0;
596   RBRNo->setChecked(true);
597   SpinBox_RPE->setEnabled(false);
598   SpinBox_RRel->setEnabled(false);
599   SpinBox_RAbs->setEnabled(false);
600   SpinBox_RMuSigma->setEnabled(false);
601 }
602 // ------------------------------------------------------------------------
603 void MonCreateHypothesis::SetCPE()
604 // ------------------------------------------------------------------------
605 {
606   _aTypeDera = 1 ;
607   _TypeThC = 3 ;
608   RBCPE->setChecked(true);
609   SpinBox_CPE->setEnabled(true);
610   SpinBox_CRel->setEnabled(false);
611   SpinBox_CAbs->setEnabled(false);
612   SpinBox_CMuSigma->setEnabled(false);
613 }
614 // ------------------------------------------------------------------------
615 void MonCreateHypothesis::SetCRel()
616 // ------------------------------------------------------------------------
617 {
618   _aTypeDera = 1 ;
619   _TypeThC = 2 ;
620   RBCRel->setChecked(true);
621   SpinBox_CPE->setEnabled(false);
622   SpinBox_CRel->setEnabled(true);
623   SpinBox_CAbs->setEnabled(false);
624   SpinBox_CMuSigma->setEnabled(false);
625 }
626 // ------------------------------------------------------------------------
627 void MonCreateHypothesis::SetCAbs()
628 // ------------------------------------------------------------------------
629 {
630   _aTypeDera = 1 ;
631   _TypeThC = 1 ;
632   RBCAbs->setChecked(true);
633   SpinBox_CPE->setEnabled(false);
634   SpinBox_CRel->setEnabled(false);
635   SpinBox_CAbs->setEnabled(true);
636   SpinBox_CMuSigma->setEnabled(false);
637 }
638 // ------------------------------------------------------------------------
639 void MonCreateHypothesis::SetCMS()
640 // ------------------------------------------------------------------------
641 {
642   _aTypeDera = 1 ;
643   _TypeThC = 4 ;
644   RBCMuSigma->setChecked(true);
645   SpinBox_CPE->setEnabled(false);
646   SpinBox_CRel->setEnabled(false);
647   SpinBox_CAbs->setEnabled(false);
648   SpinBox_CMuSigma->setEnabled(true);
649 }
650 // ------------------------------------------------------------------------
651 void MonCreateHypothesis::SetCNo()
652 // ------------------------------------------------------------------------
653 {
654   _aTypeDera = 0 ;
655   _TypeThC = 0;
656   RBCNo->setChecked(true);
657   SpinBox_CPE->setEnabled(false);
658   SpinBox_CRel->setEnabled(false);
659   SpinBox_CAbs->setEnabled(false);
660   SpinBox_CMuSigma->setEnabled(false);
661 }
662 // ------------------------------------------------------------------------
663 void MonCreateHypothesis::SetUCL2()
664 // ------------------------------------------------------------------------
665 {
666   _UsCmpI = 0 ;
667   RBL2->setChecked(true);
668 }
669 // ------------------------------------------------------------------------
670 void MonCreateHypothesis::SetUCInf()
671 // ------------------------------------------------------------------------
672 {
673   _UsCmpI = 1 ;
674   RBInf->setChecked(true);
675 }
676 // ------------------------------------------------------------------------
677 void MonCreateHypothesis::SetUseField()
678 // ------------------------------------------------------------------------
679 {
680   if ( CBJump->isChecked() ) { _UsField = 1 ; }
681   else                       { _UsField = 0 ; }
682 }
683 // ------------------------------------------------------------------------
684 void MonCreateHypothesis::SetFiltrage()
685 // ------------------------------------------------------------------------
686 {
687   if (!CBGroupe->isChecked()) return;
688   MonCreateListGroup *aDlg = new MonCreateListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(myHomardGen),_aCaseName, _aListeGroupes) ;
689   aDlg->show();
690 }
691
692 // ------------------------------------------------------------------------
693 void MonCreateHypothesis::setGroups(QStringList listGroup)
694 // ------------------------------------------------------------------------
695 {
696     _aListeGroupes=listGroup;
697 }
698 // ------------------------------------------------------------------------
699 bool MonCreateHypothesis::VerifieZone()
700 // ------------------------------------------------------------------------
701 {
702   if ( _aTypeAdap != 0 ) return true;
703   MESSAGE("Debut de VerifieZone") ;
704   _aListeZone = GetZonesChecked() ;
705   MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
706   if (_aListeZone.count() == 0)
707   {
708     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
709                               QObject::tr("HOM_HYPO_ZONE_2") );
710      return false;
711   }
712   MESSAGE("Fin de VerifieZone") ;
713   return true;
714 }
715 // ------------------------------------------------------------------------
716 bool MonCreateHypothesis::VerifieComposant()
717 // ------------------------------------------------------------------------
718 {
719   if ( _aTypeAdap != 1 ) return true;
720   _aListeComposant = GetListCompChecked() ;
721   if (_aListeComposant.count() == 0)
722   {
723     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
724                               QObject::tr("HOM_HYPO_COMP") );
725      return false;
726   }
727   return true;
728 }
729
730 // ------------------------------------------------------------------------
731 void MonCreateHypothesis::AssocieLesZones()
732 // ------------------------------------------------------------------------
733 {
734   MESSAGE( "Debut de AssocieLesZones" );
735   if ( _aTypeAdap != 0 ) return;
736   _aListeZone = GetZonesChecked() ;
737   MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
738   QString Raff =  "1" ;
739   int TypeUse ;
740   for ( int i=0 ; i< _aListeZone.count() ; i++ )
741   { if ( _aListeZone[i+1] == Raff ) { TypeUse =  1 ; }
742     else                            { TypeUse = -1 ; }
743     aHypothesis->AddZone(_aListeZone[i].toStdString().c_str(), TypeUse);
744     i += 1 ;
745   }
746   MESSAGE( "Fin de AssocieLesZones" );
747 };
748 // ------------------------------------------------------------------------
749 void MonCreateHypothesis::AssocieComposants()
750 // ------------------------------------------------------------------------
751 {
752   if ( _aTypeAdap != 1 ) return;
753   MESSAGE( "Dans AssocieComposants, _TypeThC : " << _TypeThC );
754   MESSAGE( "Dans AssocieComposants, _TypeThR : " << _TypeThR );
755
756   _ThreshR = 0;
757   if ( _TypeThR == 1 ) { _ThreshR = SpinBox_RAbs->value();}
758   if ( _TypeThR == 2 ) { _ThreshR = SpinBox_RRel->value();}
759   if ( _TypeThR == 3 ) { _ThreshR = SpinBox_RPE->value(); }
760   if ( _TypeThR == 4 ) { _ThreshR = SpinBox_RMuSigma->value(); }
761
762   _ThreshC = 0;
763   if ( _TypeThC == 1 ) { _ThreshC = SpinBox_CAbs->value();}
764   if ( _TypeThC == 2 ) { _ThreshC = SpinBox_CRel->value();}
765   if ( _TypeThC == 3 ) { _ThreshC = SpinBox_CPE->value(); }
766   if ( _TypeThC == 4 ) { _ThreshC = SpinBox_CMuSigma->value(); }
767
768   _aFieldName=CBFieldName->currentText();
769   aHypothesis->SetField(CORBA::string_dup(_aFieldName.toStdString().c_str()) ) ;
770   aHypothesis->SetRefinThr( _TypeThR, _ThreshR ) ;
771   aHypothesis->SetUnRefThr( _TypeThC, _ThreshC ) ;
772   aHypothesis->SetUseField( _UsField ) ;
773   aHypothesis->SetUseComp( _UsCmpI ) ;
774   _aListeComposant = GetListCompChecked() ;
775   for ( int i=0 ; i< _aListeComposant.count() ; i++ )
776       { aHypothesis->AddComp(_aListeComposant[i].toStdString().c_str()); }
777 };
778 // ------------------------------------------------------------------------
779 void MonCreateHypothesis::AssocieLesGroupes()
780 // ------------------------------------------------------------------------
781 {
782   HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
783   aSeqGroupe->length(_aListeGroupes.size());
784   QStringList::const_iterator it;
785   int i=0;
786   for (it = _aListeGroupes.constBegin(); it != _aListeGroupes.constEnd(); it++)
787      aSeqGroupe[i++]=(*it).toStdString().c_str();
788   aHypothesis->SetGroups(aSeqGroupe);
789
790 }
791 // ------------------------------------------------------------------------
792 void MonCreateHypothesis::SetFieldNo()
793 // ------------------------------------------------------------------------
794 // Par defaut, on n'interpole rien
795 {
796   if ( _aTypeAdap == 1 ) { GBFieldFile->setVisible(1); }
797   else                   { GBFieldFile->setVisible(0); }
798   TWField->setVisible(0);
799 //
800    adjustSize();
801   _TypeFieldInterp = 0 ;
802 }
803 // ------------------------------------------------------------------------
804 void MonCreateHypothesis::SetFieldAll()
805 // ------------------------------------------------------------------------
806 // Par defaut, on interpole tout
807 {
808   if (_aFieldFile == QString(""))
809   {
810     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
811                               QObject::tr("HOM_HYPO_FIELD_FILE") );
812      close();
813      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
814      return;
815   }
816   LEFieldFile->setText(_aFieldFile);
817   LEFieldFile->setReadOnly(1);
818   GBFieldFile->setVisible(1);
819   TWField->setVisible(0);
820 //
821   _TypeFieldInterp = 1 ;
822    adjustSize();
823 }
824 // ------------------------------------------------------------------------
825 void MonCreateHypothesis::SetFieldChosen()
826 // ------------------------------------------------------------------------
827 {
828   if (_aFieldFile == QString(""))
829   {
830     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
831                               QObject::tr("HOM_HYPO_FIELD_FILE") );
832      close();
833      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
834      return;
835   }
836   LEFieldFile->setText(_aFieldFile);
837   LEFieldFile->setReadOnly(1);
838   GBFieldFile->setVisible(1);
839   // Recuperation de la liste des champs contenus dans le fichier _aFieldFile
840   std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
841
842   // Initialisation de la table
843   TWField->clear();
844   int nbrow=TWField->rowCount();
845   for ( int row=0; row< nbrow; row++)
846   {
847      TWField->removeRow(row);
848   }
849   TWField->setRowCount(0);
850   std:: list<QString>::const_iterator it;
851   int row=0;
852   for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
853   {
854     TWField->insertRow(row);
855     TWField->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
856     TWField->item( row, 0 )->setFlags( 0 );
857     TWField->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
858     TWField->item( row, 0 )->setCheckState( Qt::Unchecked );
859     TWField->setItem( row, 1, new QTableWidgetItem(QString(*it).trimmed()));
860     TWField->item( row, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
861     row=row+1;
862   }
863   TWField->resizeColumnsToContents();
864   TWField->resizeRowsToContents();
865   TWField->clearSelection();
866   TWField->setVisible(1);
867
868   _TypeFieldInterp = 2 ;
869    adjustSize();
870 }
871 // ------------------------------------------------------------------------
872 void MonCreateHypothesis::SetAdvanced()
873 // ------------------------------------------------------------------------
874 {
875   MESSAGE("Debut de SetAdvanced ");
876   if (CBAdvanced->isChecked())
877   { GBAdvancedOptions->setVisible(1);
878     if (_aFieldFile != QString(""))
879     { GBAdapInit->setVisible(1) ;
880     }
881     else
882     { GBAdapInit->setVisible(0) ;
883     }
884   }
885   else
886   { GBAdvancedOptions->setVisible(0);
887     _NivMax = -1 ;
888     _DiamMin = -1. ;
889     _AdapInit = 0 ;
890     CBLevelOutput->setChecked(false);
891     _LevelOutput = 0 ;
892   }
893   adjustSize();
894 }
895 // ------------------------------------------------------------------------
896 void MonCreateHypothesis::SetAIN()
897 // ------------------------------------------------------------------------
898 {
899   MESSAGE("Debut de SetAIN ");
900   _AdapInit = 0 ;
901 }
902 // ------------------------------------------------------------------------
903 void MonCreateHypothesis::SetAIR()
904 // ------------------------------------------------------------------------
905 {
906   MESSAGE("Debut de SetAIR ");
907   _AdapInit = 1 ;
908 }
909 // ------------------------------------------------------------------------
910 void MonCreateHypothesis::SetAID()
911 // ------------------------------------------------------------------------
912 {
913   MESSAGE("Debut de SetAID ");
914   _AdapInit = -1 ;
915 }