Salome HOME
[bos #32517][EDF] Dynamic log messages switched on and off by SALOME_VERBOSE environm...
[modules/homard.git] / src / HOMARDGUI / MonCreateHypothesis.cxx
1 // Copyright (C) 2011-2022  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "MonCreateHypothesis.h"
21 #include "MonCreateListGroup.h"
22 #include "MonCreateIteration.h"
23 #include "MonCreateZone.h"
24 #include "MonEditZone.h"
25
26 #include <QFileDialog>
27 #include <QMessageBox>
28
29 #include "SalomeApp_Tools.h"
30 #include "HOMARDGUI_Utils.h"
31 #include "HomardQtCommun.h"
32 #include <utilities.h>
33
34 using namespace std;
35
36 // -------------------------------------------------------------------------------
37 MonCreateHypothesis::MonCreateHypothesis(MonCreateIteration* parent, bool modal,
38                                          HOMARD::HOMARD_Gen_var myHomardGen0,
39                                          QString Name,
40                                          QString caseName, QString aFieldFile)
41 // ---------------------------------------------------------------------------------
42 /* Constructs a MonCreateHypothesis */
43     :
44     QScrollArea(0), Ui_CreateHypothesis(),
45     _parent(parent), _Name(Name),
46     _aCaseName(caseName), _aFieldFile(aFieldFile),
47     _aFieldName(""),
48     _aTypeAdap(-2), _aTypeRaff(1), _aTypeDera(0),
49     _TypeThR(3), _ThreshR(0),
50     _TypeThC(0), _ThreshC(0),
51     _UsField(0), _UsCmpI(0), _TypeFieldInterp(0),
52     _NivMax(-1),
53     _DiamMin(-1.),
54     _AdapInit(0),
55     _ExtraOutput(1)
56
57 {
58       MESSAGE("Constructeur") ;
59       myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
60       setupUi(this);
61       if ( modal ) { setWindowModality(Qt::WindowModal); }
62       else         { setWindowModality(Qt::NonModal); }
63       setWindowFlags( Qt::WindowStaysOnTopHint ) ;
64       InitConnect();
65
66       SetNewName();
67       if (_aFieldFile != QString(""))
68       { RBChamp->setChecked(1);
69         SetChamp();
70       }
71       else
72       { RBUniforme->setChecked(1);
73         SetUniforme();
74       }
75       SetFieldNo();
76       GBAdvancedOptions->setVisible(0);
77       CBOutputLevel->setChecked(false);
78       CBOutputQuality->setChecked(false);
79       CBOutputDiameter->setChecked(false);
80       CBOutputParent->setChecked(false);
81       CBOutputVoisins->setChecked(false);
82       _ExtraOutput = 1 ;
83 //
84       adjustSize();
85 }
86
87 // ------------------------------------------------------------------------
88 MonCreateHypothesis::~MonCreateHypothesis()
89 // ------------------------------------------------------------------------
90 {
91     // no need to delete child widgets, Qt does it all for us
92 }
93 // ------------------------------------------------------------------------
94 void MonCreateHypothesis::InitConnect()
95 // ------------------------------------------------------------------------
96 {
97     connect( RBUniforme,   SIGNAL(clicked()), this, SLOT(SetUniforme()));
98     connect( RBChamp,      SIGNAL(clicked()), this, SLOT(SetChamp()));
99     connect( RBZone,       SIGNAL(clicked()), this, SLOT(SetZone()));
100     connect( RBUniRaff,    SIGNAL(clicked()), this, SLOT(SetUniRaff()));
101     connect( RBUniDera,    SIGNAL(clicked()), this, SLOT(SetUniDera()));
102
103     connect( CBFieldName,  SIGNAL(activated(int)), this, SLOT( SetFieldName()));
104     connect( RBRPE,        SIGNAL(clicked()), this, SLOT(SetRPE()));
105     connect( RBRRel,       SIGNAL(clicked()), this, SLOT(SetRRel()));
106     connect( RBRMuSigma,   SIGNAL(clicked()), this, SLOT(SetRMS()));
107     connect( RBRAbs,       SIGNAL(clicked()), this, SLOT(SetRAbs()));
108     connect( RBRNo,        SIGNAL(clicked()), this, SLOT(SetRNo()));
109     connect( RBCPE,        SIGNAL(clicked()), this, SLOT(SetCPE()));
110     connect( RBCRel,       SIGNAL(clicked()), this, SLOT(SetCRel()));
111     connect( RBCMuSigma,   SIGNAL(clicked()), this, SLOT(SetCMS()));
112     connect( RBCAbs,       SIGNAL(clicked()), this, SLOT(SetCAbs()));
113     connect( RBCNo,        SIGNAL(clicked()), this, SLOT(SetCNo()));
114     connect( RBL2,         SIGNAL(clicked()), this, SLOT(SetUCL2()));
115     connect( RBInf,        SIGNAL(clicked()), this, SLOT(SetUCInf()));
116     connect( CBJump,       SIGNAL(stateChanged(int)), this, SLOT(SetUseField()));
117     connect( PBZoneNew,    SIGNAL(pressed()), this, SLOT(PushZoneNew()));
118     connect( PBZoneEdit,   SIGNAL(pressed()), this, SLOT(PushZoneEdit()) );
119     connect( CBGroupe,     SIGNAL(stateChanged(int)), this, SLOT(SetFiltrage()));
120
121     connect( RBFieldNo,    SIGNAL(clicked()), this, SLOT(SetFieldNo()));
122     connect( RBFieldAll,   SIGNAL(clicked()), this, SLOT(SetFieldAll()));
123     connect( RBFieldChosen,SIGNAL(clicked()), this, SLOT(SetFieldChosen()));
124
125     connect( CBAdvanced,   SIGNAL(stateChanged(int)), this, SLOT(SetAdvanced()));
126     connect( RBAIN,        SIGNAL(clicked()), this, SLOT(SetAIN()));
127     connect( RBAIR,        SIGNAL(clicked()), this, SLOT(SetAIR()));
128     connect( RBAID,        SIGNAL(clicked()), this, SLOT(SetAID()));
129
130     connect( buttonOk,     SIGNAL(pressed()), this, SLOT( PushOnOK()));
131     connect( buttonApply,  SIGNAL(pressed()), this, SLOT( PushOnApply()));
132     connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
133     connect( buttonHelp,   SIGNAL(pressed()), this, SLOT( PushOnHelp()));
134 }
135
136 // ------------------------------------------------------------------------
137 bool MonCreateHypothesis::PushOnApply()
138 // ------------------------------------------------------------------------
139 // Appele lorsque l'un des boutons Ok ou Apply est presse
140 //
141 {
142 // Verifications
143
144
145   if (LEName->text().trimmed()=="") {
146     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
147                               QObject::tr("HOM_HYPO_NAME") );
148     return false;
149   }
150
151   if (VerifieZone()      == false)  return false;
152   if (VerifieComposant() == false)  return false;
153
154 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
155   if (LEName->text().trimmed() != _Name)
156   {
157     _Name=LEName->text().trimmed();
158     try
159     {
160      aHypothesis=myHomardGen->CreateHypothesis(CORBA::string_dup(_Name.toStdString().c_str()) );
161      _parent->addHypothese(_Name);
162     }
163     catch( SALOME::SALOME_Exception& S_ex )
164     {
165       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
166                                 QString(CORBA::string_dup(S_ex.details.text)) );
167       return false;
168     }
169   }
170
171 // Mise en place des attributs
172   if ( _aTypeAdap == -1 )
173   {
174     int TypeRaffDera ;
175     if ( _aTypeRaff == 1 ) { TypeRaffDera = 1 ; }
176     else                   { TypeRaffDera = -1 ; }
177     aHypothesis->SetUnifRefinUnRef(TypeRaffDera);
178   }
179   aHypothesis->SetTypeFieldInterp(_TypeFieldInterp);
180   aHypothesis->SetCaseCreation(_aCaseName.toStdString().c_str());
181
182   AssocieLesZones();
183   AssocieComposants();
184   AssocieLesGroupes();
185   AssocieFieldInterp();
186
187 // Options avancees
188   if (CBAdvanced->isChecked())
189   {
190 // Enregistrement du niveau maximal
191     _NivMax = SpinBoxNivMax->value() ;
192     aHypothesis->SetNivMax(_NivMax);
193 // Enregistrement du diametre minimal
194     _DiamMin = doubleSpinBoxDiamMin->value() ;
195     aHypothesis->SetDiamMin(_DiamMin);
196 // Enregistrement de l'intialisation de l'adaptation
197     aHypothesis->SetAdapInit(_AdapInit);
198 // Sortie optionnelle des niveaux de raffinement, des diametres, des qualites
199     _ExtraOutput = 1 ;
200     if (CBOutputLevel->isChecked())    { _ExtraOutput =  2 ; }
201     if (CBOutputQuality->isChecked())  { _ExtraOutput =  3*_ExtraOutput ; }
202     if (CBOutputDiameter->isChecked()) { _ExtraOutput =  5*_ExtraOutput ; }
203     if (CBOutputParent->isChecked())   { _ExtraOutput =  7*_ExtraOutput ; }
204     if (CBOutputVoisins->isChecked())  { _ExtraOutput = 11*_ExtraOutput ; }
205     aHypothesis->SetExtraOutput(_ExtraOutput);
206   }
207
208   HOMARD_UTILS::updateObjBrowser() ;
209
210   return true;
211 }
212
213
214 // ------------------------------------------------------------------------
215 void MonCreateHypothesis::PushOnOK()
216 // ------------------------------------------------------------------------
217 {
218      if (PushOnApply()) this->close();
219      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
220 }
221 // ------------------------------------------------------------------------
222 void MonCreateHypothesis::PushOnHelp()
223 // ------------------------------------------------------------------------
224 {
225   std::string LanguageShort = myHomardGen->GetLanguageShort();
226   HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str()));
227 }
228 // -------------------------------------------------
229 void MonCreateHypothesis::SetNewName()
230 // --------------------------------------------------
231 {
232
233   HOMARD::listeHypotheses_var  MyObjects = myHomardGen->GetAllHypothesesName();
234   int num = 0;//
235   QString aName="";
236   while (aName=="" )
237   {
238     aName.setNum(num+1) ;
239     aName.insert(0, QString("Hypo_")) ;
240     for ( int i=0; i<MyObjects->length(); i++)
241     {
242       if ( aName ==  QString(MyObjects[i]))
243       {
244         num ++ ;
245         aName = "" ;
246         break ;
247       }
248     }
249   }
250   LEName->setText(aName);
251 }
252
253 //
254 // ------------------------------------------------------------------------
255 void MonCreateHypothesis::SetUniforme()
256 // ------------------------------------------------------------------------
257 {
258   GBFieldManagement->setVisible(0);
259   if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
260   else                         { GBFieldFile->setVisible(1); }
261   GBAreaManagement->setVisible(0);
262   GBUniform->setVisible(1);
263
264   _aTypeAdap = -1 ;
265 //
266   adjustSize();
267 }
268 // ------------------------------------------------------------------------
269 void MonCreateHypothesis::SetChamp()
270 // ------------------------------------------------------------------------
271 {
272   if (_aFieldFile == QString(""))
273   {
274     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
275                               QObject::tr("HOM_HYPO_FIELD_FILE") );
276      close();
277      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
278      return;
279   }
280   LEFieldFile->setText(_aFieldFile);
281   LEFieldFile->setReadOnly(1);
282   InitFields();
283   GBUniform->setVisible(0);
284   GBAreaManagement->setVisible(0);
285   GBFieldManagement->setVisible(1);
286   GBFieldFile->setVisible(1);
287
288   GBUniform->adjustSize();
289   GBAreaManagement->adjustSize();
290   GBFieldManagement->adjustSize();
291   GBFieldFile->adjustSize();
292
293   _aTypeAdap = 1 ;
294 //
295   adjustSize();
296 }
297 // ------------------------------------------------------------------------
298 void MonCreateHypothesis::SetZone()
299 // ------------------------------------------------------------------------
300 {
301   GetAllZones();
302   GBUniform->setVisible(0);
303   GBFieldManagement->setVisible(0);
304   if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
305   else                         { GBFieldFile->setVisible(1); }
306   GBAreaManagement->setVisible(1);
307
308   _aTypeRaff = 1 ;
309   _aTypeDera = 0 ;
310   _aTypeAdap = 0 ;
311 //
312   adjustSize();
313 }
314
315 // ------------------------------------------------------------------------
316 void MonCreateHypothesis::PushZoneNew()
317 // ------------------------------------------------------------------------
318 {
319   MESSAGE("Debut de MonCreateHypothesis::PushZoneNew");
320   MonCreateZone *aDlg = new MonCreateZone(this, true, HOMARD::HOMARD_Gen::_duplicate(myHomardGen), _aCaseName) ;
321   aDlg->show();
322 }
323
324 // ------------------------------------------------------------------------
325 void MonCreateHypothesis::PushZoneEdit()
326 // ------------------------------------------------------------------------
327 {
328   MESSAGE("Debut de MonCreateHypothesis::PushZoneEdit");
329   int colonne = TWZone->currentColumn();
330   QTableWidgetItem * monItem = TWZone->currentItem();
331   if (colonne !=2  || monItem == NULL)
332   {
333     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
334                               QObject::tr("HOM_HYPO_ZONE_1") );
335     return;
336   }
337   QString zoneName = monItem->text().trimmed();
338   MonEditZone *aDlg = new MonEditZone(this, true, HOMARD::HOMARD_Gen::_duplicate(myHomardGen), _aCaseName, zoneName) ;
339   aDlg->show();
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   if ( TWCMP->rowCount() == 1 ) { _UsCmpI = 2 ; }
689   else                          { _UsCmpI = 1 ; }
690   RBInf->setChecked(true);
691 }
692 // ------------------------------------------------------------------------
693 void MonCreateHypothesis::SetUseField()
694 // ------------------------------------------------------------------------
695 {
696   if ( CBJump->isChecked() ) { _UsField = 1 ; }
697   else                       { _UsField = 0 ; }
698 }
699 // ------------------------------------------------------------------------
700 void MonCreateHypothesis::SetFiltrage()
701 // ------------------------------------------------------------------------
702 {
703   if (!CBGroupe->isChecked()) return;
704   MonCreateListGroup *aDlg = new MonCreateListGroup(this, NULL, true, HOMARD::HOMARD_Gen::_duplicate(myHomardGen),_aCaseName, _aListeGroupes) ;
705   aDlg->show();
706 }
707
708 // ------------------------------------------------------------------------
709 void MonCreateHypothesis::setGroups(QStringList listGroup)
710 // ------------------------------------------------------------------------
711 {
712     _aListeGroupes=listGroup;
713 }
714 // ------------------------------------------------------------------------
715 bool MonCreateHypothesis::VerifieZone()
716 // ------------------------------------------------------------------------
717 {
718   if ( _aTypeAdap != 0 ) return true;
719   MESSAGE("Debut de VerifieZone") ;
720   _aListeZone = GetZonesChecked() ;
721   MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
722   if (_aListeZone.count() == 0)
723   {
724     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
725                               QObject::tr("HOM_HYPO_ZONE_2") );
726      return false;
727   }
728   MESSAGE("Fin de VerifieZone") ;
729   return true;
730 }
731 // ------------------------------------------------------------------------
732 bool MonCreateHypothesis::VerifieComposant()
733 // ------------------------------------------------------------------------
734 {
735   if ( _aTypeAdap != 1 ) return true;
736   _aListeComposant = GetListCompChecked() ;
737   if (_aListeComposant.count() == 0)
738   {
739     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
740                               QObject::tr("HOM_HYPO_COMP") );
741      return false;
742   }
743   return true;
744 }
745
746 // ------------------------------------------------------------------------
747 void MonCreateHypothesis::AssocieLesZones()
748 // ------------------------------------------------------------------------
749 {
750   MESSAGE( "Debut de AssocieLesZones" );
751   if ( _aTypeAdap != 0 ) return;
752   _aListeZone = GetZonesChecked() ;
753   MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
754   QString Raff =  "1" ;
755   int TypeUse ;
756   for ( int i=0 ; i< _aListeZone.count() ; i++ )
757   { if ( _aListeZone[i+1] == Raff ) { TypeUse =  1 ; }
758     else                            { TypeUse = -1 ; }
759     aHypothesis->AddZone(_aListeZone[i].toStdString().c_str(), TypeUse);
760     i += 1 ;
761   }
762   MESSAGE( "Fin de AssocieLesZones" );
763 };
764 // ------------------------------------------------------------------------
765 void MonCreateHypothesis::AssocieComposants()
766 // ------------------------------------------------------------------------
767 {
768   if ( _aTypeAdap != 1 ) return;
769   MESSAGE( "Dans AssocieComposants, _TypeThC : " << _TypeThC );
770   MESSAGE( "Dans AssocieComposants, _TypeThR : " << _TypeThR );
771
772   _ThreshR = 0;
773   if ( _TypeThR == 1 ) { _ThreshR = SpinBox_RAbs->value();}
774   if ( _TypeThR == 2 ) { _ThreshR = SpinBox_RRel->value();}
775   if ( _TypeThR == 3 ) { _ThreshR = SpinBox_RPE->value(); }
776   if ( _TypeThR == 4 ) { _ThreshR = SpinBox_RMuSigma->value(); }
777
778   _ThreshC = 0;
779   if ( _TypeThC == 1 ) { _ThreshC = SpinBox_CAbs->value();}
780   if ( _TypeThC == 2 ) { _ThreshC = SpinBox_CRel->value();}
781   if ( _TypeThC == 3 ) { _ThreshC = SpinBox_CPE->value(); }
782   if ( _TypeThC == 4 ) { _ThreshC = SpinBox_CMuSigma->value(); }
783
784   _aFieldName=CBFieldName->currentText();
785   aHypothesis->SetField(CORBA::string_dup(_aFieldName.toStdString().c_str()) ) ;
786   if ( _TypeThR > 0 ) { aHypothesis->SetRefinThr( _TypeThR, _ThreshR ) ; }
787   if ( _TypeThC > 0 ) { aHypothesis->SetUnRefThr( _TypeThC, _ThreshC ) ; }
788   aHypothesis->SetUseField( _UsField ) ;
789   aHypothesis->SetUseComp( _UsCmpI ) ;
790   _aListeComposant = GetListCompChecked() ;
791   for ( int i=0 ; i< _aListeComposant.count() ; i++ )
792       { aHypothesis->AddComp(_aListeComposant[i].toStdString().c_str()); }
793 };
794 // ------------------------------------------------------------------------
795 void MonCreateHypothesis::AssocieLesGroupes()
796 // ------------------------------------------------------------------------
797 {
798   HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
799   aSeqGroupe->length(_aListeGroupes.size());
800   QStringList::const_iterator it;
801   int i=0;
802   for (it = _aListeGroupes.constBegin(); it != _aListeGroupes.constEnd(); it++)
803      aSeqGroupe[i++]=(*it).toStdString().c_str();
804   aHypothesis->SetGroups(aSeqGroupe);
805
806 }
807 // ------------------------------------------------------------------------
808 void MonCreateHypothesis::SetFieldNo()
809 // ------------------------------------------------------------------------
810 // Par defaut, on n'interpole rien
811 {
812   if ( _aTypeAdap == 1 ) { GBFieldFile->setVisible(1); }
813   else                   { GBFieldFile->setVisible(0); }
814   TWField->setVisible(0);
815 //
816   _TypeFieldInterp = 0 ;
817 //
818   adjustSize();
819 }
820 // ------------------------------------------------------------------------
821 void MonCreateHypothesis::SetFieldAll()
822 // ------------------------------------------------------------------------
823 // Par defaut, on interpole tout
824 {
825   if (_aFieldFile == QString(""))
826   {
827     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
828                               QObject::tr("HOM_HYPO_FIELD_FILE") );
829      close();
830      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
831      return;
832   }
833   LEFieldFile->setText(_aFieldFile);
834   LEFieldFile->setReadOnly(1);
835   GBFieldFile->setVisible(1);
836   TWField->setVisible(0);
837 //
838   _TypeFieldInterp = 1 ;
839 //
840   adjustSize();
841 }
842 // ------------------------------------------------------------------------
843 void MonCreateHypothesis::SetFieldChosen()
844 // ------------------------------------------------------------------------
845 {
846   if (_aFieldFile == QString(""))
847   {
848     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
849                               QObject::tr("HOM_HYPO_FIELD_FILE") );
850      close();
851      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
852      return;
853   }
854   LEFieldFile->setText(_aFieldFile);
855   LEFieldFile->setReadOnly(1);
856   GBFieldFile->setVisible(1);
857   // Recuperation de la liste des champs contenus dans le fichier _aFieldFile
858   std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
859
860   // Initialisation de la table
861   TWField->clear();
862   int nbrow=TWField->rowCount();
863   for ( int row=0; row< nbrow; row++)
864   {
865      TWField->removeRow(row);
866   }
867   TWField->setRowCount(0);
868   std:: list<QString>::const_iterator it;
869   int row=0;
870   for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
871   {
872     TWField->insertRow(row);
873     TWField->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
874     TWField->item( row, 0 )->setFlags( 0 );
875     TWField->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled  );
876     TWField->item( row, 0 )->setCheckState( Qt::Unchecked );
877     TWField->setItem( row, 1, new QTableWidgetItem(QString(*it).trimmed()));
878     TWField->item( row, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
879     row=row+1;
880   }
881   TWField->resizeColumnsToContents();
882   TWField->resizeRowsToContents();
883   TWField->clearSelection();
884   TWField->setVisible(1);
885
886   _TypeFieldInterp = 2 ;
887 //
888   adjustSize();
889 }
890 // ------------------------------------------------------------------------
891 void MonCreateHypothesis::SetAdvanced()
892 // ------------------------------------------------------------------------
893 {
894   MESSAGE("Debut de SetAdvanced ");
895   if (CBAdvanced->isChecked())
896   { GBAdvancedOptions->setVisible(1);
897     if (_aFieldFile != QString("")) { GBAdapInit->setVisible(1) ; }
898     else                            { GBAdapInit->setVisible(0) ; }
899   }
900   else
901   { GBAdvancedOptions->setVisible(0);
902     _NivMax = -1 ;
903     _DiamMin = -1. ;
904     _AdapInit = 0 ;
905     CBOutputLevel->setChecked(false);
906     CBOutputQuality->setChecked(false);
907     CBOutputDiameter->setChecked(false);
908     CBOutputParent->setChecked(false);
909     CBOutputVoisins->setChecked(false);
910     _ExtraOutput = 1 ;
911   }
912 //
913   adjustSize();
914 }
915 // ------------------------------------------------------------------------
916 void MonCreateHypothesis::SetAIN()
917 // ------------------------------------------------------------------------
918 {
919   MESSAGE("Debut de SetAIN ");
920   _AdapInit = 0 ;
921 }
922 // ------------------------------------------------------------------------
923 void MonCreateHypothesis::SetAIR()
924 // ------------------------------------------------------------------------
925 {
926   MESSAGE("Debut de SetAIR ");
927   _AdapInit = 1 ;
928 }
929 // ------------------------------------------------------------------------
930 void MonCreateHypothesis::SetAID()
931 // ------------------------------------------------------------------------
932 {
933   MESSAGE("Debut de SetAID ");
934   _AdapInit = -1 ;
935 }