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