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