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