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