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