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