1 // Copyright (C) 2011-2020 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MonCreateHypothesis.h"
21 #include "MonCreateListGroup.h"
22 #include "MonCreateIteration.h"
23 #include "MonCreateZone.h"
24 #include "MonEditZone.h"
26 #include <QFileDialog>
27 #include <QMessageBox>
29 #include "SalomeApp_Tools.h"
30 #include "HOMARDGUI_Utils.h"
31 #include "HomardQtCommun.h"
32 #include <utilities.h>
36 // -------------------------------------------------------------------------------
37 MonCreateHypothesis::MonCreateHypothesis(MonCreateIteration* parent, bool modal,
38 HOMARD::HOMARD_Gen_var myHomardGen0,
40 QString caseName, QString aFieldFile)
41 // ---------------------------------------------------------------------------------
42 /* Constructs a MonCreateHypothesis */
44 QScrollArea(0), Ui_CreateHypothesis(),
45 _parent(parent), _Name(Name),
46 _aCaseName(caseName), _aFieldFile(aFieldFile),
48 _aTypeAdap(-2), _aTypeRaff(1), _aTypeDera(0),
49 _TypeThR(3), _ThreshR(0),
50 _TypeThC(0), _ThreshC(0),
51 _UsField(0), _UsCmpI(0), _TypeFieldInterp(0),
58 MESSAGE("Constructeur") ;
59 myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
61 if ( modal ) { setWindowModality(Qt::WindowModal); }
62 else { setWindowModality(Qt::NonModal); }
63 setWindowFlags( Qt::WindowStaysOnTopHint ) ;
67 if (_aFieldFile != QString(""))
68 { RBChamp->setChecked(1);
72 { RBUniforme->setChecked(1);
76 GBAdvancedOptions->setVisible(0);
77 CBOutputLevel->setChecked(false);
78 CBOutputQuality->setChecked(false);
79 CBOutputDiameter->setChecked(false);
80 CBOutputParent->setChecked(false);
81 CBOutputVoisins->setChecked(false);
87 // ------------------------------------------------------------------------
88 MonCreateHypothesis::~MonCreateHypothesis()
89 // ------------------------------------------------------------------------
91 // no need to delete child widgets, Qt does it all for us
93 // ------------------------------------------------------------------------
94 void MonCreateHypothesis::InitConnect()
95 // ------------------------------------------------------------------------
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()));
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( PBZoneDelete, SIGNAL(pressed()), this, SLOT(PushZoneDelete()) );
120 connect( CBGroupe, SIGNAL(stateChanged(int)), this, SLOT(SetFiltrage()));
122 connect( RBFieldNo, SIGNAL(clicked()), this, SLOT(SetFieldNo()));
123 connect( RBFieldAll, SIGNAL(clicked()), this, SLOT(SetFieldAll()));
124 connect( RBFieldChosen,SIGNAL(clicked()), this, SLOT(SetFieldChosen()));
126 connect( CBAdvanced, SIGNAL(stateChanged(int)), this, SLOT(SetAdvanced()));
127 connect( RBAIN, SIGNAL(clicked()), this, SLOT(SetAIN()));
128 connect( RBAIR, SIGNAL(clicked()), this, SLOT(SetAIR()));
129 connect( RBAID, SIGNAL(clicked()), this, SLOT(SetAID()));
131 connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK()));
132 connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply()));
133 connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
134 connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp()));
137 // ------------------------------------------------------------------------
138 bool MonCreateHypothesis::PushOnApply()
139 // ------------------------------------------------------------------------
140 // Appele lorsque l'un des boutons Ok ou Apply est presse
146 if (LEName->text().trimmed()=="") {
147 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
148 QObject::tr("HOM_HYPO_NAME") );
152 if (VerifieZone() == false) return false;
153 if (VerifieComposant() == false) return false;
155 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
156 if (LEName->text().trimmed() != _Name)
158 _Name=LEName->text().trimmed();
161 aHypothesis=myHomardGen->CreateHypothesis(CORBA::string_dup(_Name.toStdString().c_str()) );
162 _parent->addHypothese(_Name);
164 catch( SALOME::SALOME_Exception& S_ex )
166 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
167 QString(CORBA::string_dup(S_ex.details.text)) );
172 // Mise en place des attributs
173 if ( _aTypeAdap == -1 )
176 if ( _aTypeRaff == 1 ) { TypeRaffDera = 1 ; }
177 else { TypeRaffDera = -1 ; }
178 aHypothesis->SetUnifRefinUnRef(TypeRaffDera);
180 aHypothesis->SetTypeFieldInterp(_TypeFieldInterp);
181 aHypothesis->SetCaseCreation(_aCaseName.toStdString().c_str());
186 AssocieFieldInterp();
189 if (CBAdvanced->isChecked())
191 // Enregistrement du niveau maximal
192 _NivMax = SpinBoxNivMax->value() ;
193 aHypothesis->SetNivMax(_NivMax);
194 // Enregistrement du diametre minimal
195 _DiamMin = doubleSpinBoxDiamMin->value() ;
196 aHypothesis->SetDiamMin(_DiamMin);
197 // Enregistrement de l'intialisation de l'adaptation
198 aHypothesis->SetAdapInit(_AdapInit);
199 // Sortie optionnelle des niveaux de raffinement, des diametres, des qualites
201 if (CBOutputLevel->isChecked()) { _ExtraOutput = 2 ; }
202 if (CBOutputQuality->isChecked()) { _ExtraOutput = 3*_ExtraOutput ; }
203 if (CBOutputDiameter->isChecked()) { _ExtraOutput = 5*_ExtraOutput ; }
204 if (CBOutputParent->isChecked()) { _ExtraOutput = 7*_ExtraOutput ; }
205 if (CBOutputVoisins->isChecked()) { _ExtraOutput = 11*_ExtraOutput ; }
206 aHypothesis->SetExtraOutput(_ExtraOutput);
209 HOMARD_UTILS::updateObjBrowser() ;
215 // ------------------------------------------------------------------------
216 void MonCreateHypothesis::PushOnOK()
217 // ------------------------------------------------------------------------
219 if (PushOnApply()) this->close();
220 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
222 // ------------------------------------------------------------------------
223 void MonCreateHypothesis::PushOnHelp()
224 // ------------------------------------------------------------------------
226 std::string LanguageShort = myHomardGen->GetLanguageShort();
227 HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str()));
229 // -------------------------------------------------
230 void MonCreateHypothesis::SetNewName()
231 // --------------------------------------------------
234 HOMARD::listeHypotheses_var MyObjects = myHomardGen->GetAllHypothesesName();
239 aName.setNum(num+1) ;
240 aName.insert(0, QString("Hypo_")) ;
241 for ( int i=0; i<MyObjects->length(); i++)
243 if ( aName == QString(MyObjects[i]))
251 LEName->setText(aName);
255 // ------------------------------------------------------------------------
256 void MonCreateHypothesis::SetUniforme()
257 // ------------------------------------------------------------------------
259 GBFieldManagement->setVisible(0);
260 if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
261 else { GBFieldFile->setVisible(1); }
262 GBAreaManagement->setVisible(0);
263 GBUniform->setVisible(1);
269 // ------------------------------------------------------------------------
270 void MonCreateHypothesis::SetChamp()
271 // ------------------------------------------------------------------------
273 if (_aFieldFile == QString(""))
275 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
276 QObject::tr("HOM_HYPO_FIELD_FILE") );
278 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
281 LEFieldFile->setText(_aFieldFile);
282 LEFieldFile->setReadOnly(1);
284 GBUniform->setVisible(0);
285 GBAreaManagement->setVisible(0);
286 GBFieldManagement->setVisible(1);
287 GBFieldFile->setVisible(1);
289 GBUniform->adjustSize();
290 GBAreaManagement->adjustSize();
291 GBFieldManagement->adjustSize();
292 GBFieldFile->adjustSize();
298 // ------------------------------------------------------------------------
299 void MonCreateHypothesis::SetZone()
300 // ------------------------------------------------------------------------
303 GBUniform->setVisible(0);
304 GBFieldManagement->setVisible(0);
305 if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
306 else { GBFieldFile->setVisible(1); }
307 GBAreaManagement->setVisible(1);
316 // ------------------------------------------------------------------------
317 void MonCreateHypothesis::PushZoneNew()
318 // ------------------------------------------------------------------------
320 MESSAGE("Debut de MonCreateHypothesis::PushZoneNew")
321 MonCreateZone *aDlg = new MonCreateZone(this, true, HOMARD::HOMARD_Gen::_duplicate(myHomardGen), _aCaseName) ;
325 // ------------------------------------------------------------------------
326 void MonCreateHypothesis::PushZoneEdit()
327 // ------------------------------------------------------------------------
329 MESSAGE("Debut de MonCreateHypothesis::PushZoneEdit")
330 int colonne = TWZone->currentColumn();
331 QTableWidgetItem * monItem = TWZone->currentItem();
332 if (colonne !=2 || monItem == NULL)
334 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
335 QObject::tr("HOM_HYPO_ZONE_1") );
338 QString zoneName = monItem->text().trimmed();
339 MonEditZone *aDlg = new MonEditZone(this, true, HOMARD::HOMARD_Gen::_duplicate(myHomardGen), _aCaseName, zoneName) ;
342 // ------------------------------------------------------------------------
343 void MonCreateHypothesis::PushZoneDelete()
344 // ------------------------------------------------------------------------
346 MESSAGE("Debut de MonCreateHypothesis::PushZoneDelete")
347 QMessageBox::warning( 0, QObject::tr("HOM_WARNING"),
348 QObject::tr("HOM_INACTIVE_BUTTON") );
352 // ------------------------------------------------------------------------
353 void MonCreateHypothesis::GetAllZones()
354 // ------------------------------------------------------------------------
355 // Recuperation de toutes les zones enregistrees dans l'arbre d'etude
356 // et affichage dans le tableau
357 // Par defaut, aucune n'est selectionnee
359 MESSAGE("Debut de GetAllZones") ;
360 HOMARD::listeZones_var mesZones = myHomardGen->GetAllZonesName();
361 int nbrow=TWZone->rowCount();
362 for ( int row=0; row< nbrow; row++)
364 TWZone->removeRow(row);
366 TWZone->setRowCount(0);
368 for (int i=0; i<mesZones->length(); i++)
370 TWZone->insertRow(row);
372 TWZone->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
373 TWZone->item( row, 0 )->setFlags( 0 );
374 TWZone->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
375 TWZone->item( row, 0 )->setCheckState( Qt::Unchecked );
377 TWZone->setItem( row, 1, new QTableWidgetItem( QString ("") ) );
378 TWZone->item( row, 1 )->setFlags( 0 );
379 TWZone->item( row, 1 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
380 TWZone->item( row, 1 )->setCheckState( Qt::Unchecked );
382 TWZone->setItem( row, 2, new QTableWidgetItem(QString(mesZones[i]).trimmed()));
383 TWZone->item( row, 2 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
387 TWZone->resizeColumnsToContents();
388 TWZone->resizeRowsToContents();
389 TWZone->clearSelection();
391 // ------------------------------------------------------------------------
392 void MonCreateHypothesis::addZoneinTWZone(QString newZone)
393 // ------------------------------------------------------------------------
395 MESSAGE("Debut de addZoneinTWZone") ;
396 int row = TWZone->rowCount() ;
397 // Par defaut, on suppose qu'une nouvelle zone est destinee au raffinement
398 TWZone->setRowCount( row+1 );
400 TWZone->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
401 TWZone->item( row, 0 )->setFlags( Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
402 TWZone->item( row, 0 )->setCheckState( Qt::Checked );
404 TWZone->setItem( row, 1, new QTableWidgetItem( QString ("") ) );
405 TWZone->item( row, 1 )->setFlags( Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
406 TWZone->item( row, 1 )->setCheckState( Qt::Unchecked );
408 TWZone->setItem( row, 2, new QTableWidgetItem( newZone ) );
409 TWZone->scrollToItem( TWZone->item( row, 2 ) );
411 TWZone->resizeRowsToContents();
412 TWZone->resizeColumnToContents(1);
413 TWZone->clearSelection();
415 TWZone->item( row, 2 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
417 // ------------------------------------------------------------------------
418 QStringList MonCreateHypothesis::GetZonesChecked()
419 // ------------------------------------------------------------------------
420 // Retourne les zones enregistrees
422 MESSAGE("Debut de GetZonesChecked") ;
423 QStringList ListeZone ;
424 // On ne peut pas avoir selectionne les deux options
426 for ( int row=0; row< TWZone->rowCount(); row++)
428 if ( ( TWZone->item( row, 0 )->checkState() == Qt::Checked ) && ( TWZone->item( row, 1 )->checkState() == Qt::Checked ) )
430 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
431 QObject::tr("HOM_HYPO_ZONE_3") );
435 // Si tout va bien, on affecte
436 // Attention, on insere en tete, donc on commence d'inserer le type, psui le nom de la zone
440 QString Dera = "-1" ;
441 for ( int row=0; row< TWZone->rowCount(); row++)
443 // MESSAGE ("row "<<row<<", zone : "<<TWZone->item(row, 2)->text().toStdString());
445 if ( TWZone->item(row,0)->checkState() == Qt::Checked )
446 { ListeZone.insert(0, Raff) ;
447 ListeZone.insert(0, QString(TWZone->item(row, 2)->text()) ) ; }
448 // En deraffinement :
449 if ( TWZone->item(row,1)->checkState() == Qt::Checked )
450 { ListeZone.insert(0, Dera) ;
451 ListeZone.insert(0, QString(TWZone->item(row, 2)->text()) ) ; }
453 MESSAGE("Fin de GetZonesChecked ; longueur de ListeZone : "<<ListeZone.count()) ;
458 // ------------------------------------------------------------------------
459 QStringList MonCreateHypothesis::GetListCompChecked()
460 // ------------------------------------------------------------------------
461 // Retourne les composantes retenues
463 MESSAGE( "Debut de GetListCompChecked" );
464 QStringList ListeComposant ;
466 ListeComposant.clear();
467 for ( int row=0; row< TWCMP->rowCount(); row++)
468 if ( TWCMP->item( row, 0 )->checkState() == Qt::Checked )
469 ListeComposant.insert(0, QString(TWCMP->item(row, 1)->text()) ) ;
470 // Choix du texte des radio-boutons selon 1 ou plusieurs composantes
471 if ( ListeComposant.count() < 2 )
472 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS"));
473 RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL"));
476 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
477 RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
479 return ListeComposant ;
482 // ------------------------------------------------------------------------
483 void MonCreateHypothesis::AssocieFieldInterp()
484 // ------------------------------------------------------------------------
486 if ( _TypeFieldInterp != 2 ) return;
487 for ( int row=0; row< TWField->rowCount(); row++)
489 if ( TWField->item( row, 0 )->checkState() == Qt::Checked )
491 aHypothesis->AddFieldInterp(TWField->item(row, 1)->text().toStdString().c_str());
495 // ------------------------------------------------------------------------
496 void MonCreateHypothesis::SetUniRaff()
497 // ------------------------------------------------------------------------
502 // ------------------------------------------------------------------------
503 void MonCreateHypothesis::SetUniDera()
504 // ------------------------------------------------------------------------
510 // ------------------------------------------------------------------------
511 void MonCreateHypothesis::InitFields()
512 // ------------------------------------------------------------------------
514 CBFieldName->clear();
515 std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
516 // Mise en place de la liste dans le menu pour l'indicateur d'erreur
517 std:: list<QString>::const_iterator it;
518 for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
520 CBFieldName->insertItem(0,QString(*it));
524 // ---------------------------------------
525 void MonCreateHypothesis::SetFieldName()
526 // -------------------------------------------
528 MESSAGE("Debut de SetFieldName");
529 _aFieldName=CBFieldName->currentText();
530 if (QString(_aFieldFile) == QString("") || QString(_aFieldName) == QString("") ) { return; }
532 int nbrow= TWCMP->rowCount() ;
533 for ( int row=0; row < nbrow ; row++)
535 TWCMP->removeRow(row);
537 TWCMP->setRowCount(0);
538 //TWCMP->resizeRowsToContents();
540 std::list<QString> maListe =HOMARD_QT_COMMUN::GetListeComposants(_aFieldFile, _aFieldName);
541 std::list<QString>::const_iterator it;
542 for ( it=maListe.begin() ; it != maListe.end(); it++)
545 TWCMP->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
546 TWCMP->item( 0, 0 )->setFlags( 0 );
547 TWCMP->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
548 TWCMP->item( 0, 0 )->setCheckState( Qt::Checked );
549 TWCMP->setItem( 0, 1, new QTableWidgetItem(QString((*it)).trimmed()));
550 TWCMP->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
552 TWCMP->resizeColumnsToContents();
553 TWCMP->resizeRowsToContents();
554 TWCMP->clearSelection();
555 // Choix du texte des radio-boutons selon 1 ou plusieurs composantes
556 if ( TWCMP->rowCount() == 1 )
557 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_ABS"));
558 RBInf->setText(QObject::tr("HOM_HYPO_NORM_REL"));
561 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
562 RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
564 // Par defaut, on propose la valeur absolue / norme L2
567 // ------------------------------------------------------------------------
568 void MonCreateHypothesis::SetRPE()
569 // ------------------------------------------------------------------------
573 RBRPE->setChecked(true);
574 SpinBox_RPE->setEnabled(true);
575 SpinBox_RRel->setEnabled(false);
576 SpinBox_RAbs->setEnabled(false);
577 SpinBox_RMuSigma->setEnabled(false);
579 // ------------------------------------------------------------------------
580 void MonCreateHypothesis::SetRRel()
581 // ------------------------------------------------------------------------
585 RBRRel->setChecked(true);
586 SpinBox_RPE->setEnabled(false);
587 SpinBox_RRel->setEnabled(true);
588 SpinBox_RAbs->setEnabled(false);
589 SpinBox_RMuSigma->setEnabled(false);
591 // ------------------------------------------------------------------------
592 void MonCreateHypothesis::SetRAbs()
593 // ------------------------------------------------------------------------
597 RBRAbs->setChecked(true);
598 SpinBox_RPE->setEnabled(false);
599 SpinBox_RRel->setEnabled(false);
600 SpinBox_RAbs->setEnabled(true);
601 SpinBox_RMuSigma->setEnabled(false);
603 // ------------------------------------------------------------------------
604 void MonCreateHypothesis::SetRMS()
605 // ------------------------------------------------------------------------
609 RBRMuSigma->setChecked(true);
610 SpinBox_RPE->setEnabled(false);
611 SpinBox_RRel->setEnabled(false);
612 SpinBox_RAbs->setEnabled(false);
613 SpinBox_RMuSigma->setEnabled(true);
615 // ------------------------------------------------------------------------
616 void MonCreateHypothesis::SetRNo()
617 // ------------------------------------------------------------------------
621 RBRNo->setChecked(true);
622 SpinBox_RPE->setEnabled(false);
623 SpinBox_RRel->setEnabled(false);
624 SpinBox_RAbs->setEnabled(false);
625 SpinBox_RMuSigma->setEnabled(false);
627 // ------------------------------------------------------------------------
628 void MonCreateHypothesis::SetCPE()
629 // ------------------------------------------------------------------------
633 RBCPE->setChecked(true);
634 SpinBox_CPE->setEnabled(true);
635 SpinBox_CRel->setEnabled(false);
636 SpinBox_CAbs->setEnabled(false);
637 SpinBox_CMuSigma->setEnabled(false);
639 // ------------------------------------------------------------------------
640 void MonCreateHypothesis::SetCRel()
641 // ------------------------------------------------------------------------
645 RBCRel->setChecked(true);
646 SpinBox_CPE->setEnabled(false);
647 SpinBox_CRel->setEnabled(true);
648 SpinBox_CAbs->setEnabled(false);
649 SpinBox_CMuSigma->setEnabled(false);
651 // ------------------------------------------------------------------------
652 void MonCreateHypothesis::SetCAbs()
653 // ------------------------------------------------------------------------
657 RBCAbs->setChecked(true);
658 SpinBox_CPE->setEnabled(false);
659 SpinBox_CRel->setEnabled(false);
660 SpinBox_CAbs->setEnabled(true);
661 SpinBox_CMuSigma->setEnabled(false);
663 // ------------------------------------------------------------------------
664 void MonCreateHypothesis::SetCMS()
665 // ------------------------------------------------------------------------
669 RBCMuSigma->setChecked(true);
670 SpinBox_CPE->setEnabled(false);
671 SpinBox_CRel->setEnabled(false);
672 SpinBox_CAbs->setEnabled(false);
673 SpinBox_CMuSigma->setEnabled(true);
675 // ------------------------------------------------------------------------
676 void MonCreateHypothesis::SetCNo()
677 // ------------------------------------------------------------------------
681 RBCNo->setChecked(true);
682 SpinBox_CPE->setEnabled(false);
683 SpinBox_CRel->setEnabled(false);
684 SpinBox_CAbs->setEnabled(false);
685 SpinBox_CMuSigma->setEnabled(false);
687 // ------------------------------------------------------------------------
688 void MonCreateHypothesis::SetUCL2()
689 // ------------------------------------------------------------------------
692 RBL2->setChecked(true);
694 // ------------------------------------------------------------------------
695 void MonCreateHypothesis::SetUCInf()
696 // ------------------------------------------------------------------------
698 if ( TWCMP->rowCount() == 1 ) { _UsCmpI = 2 ; }
699 else { _UsCmpI = 1 ; }
700 RBInf->setChecked(true);
702 // ------------------------------------------------------------------------
703 void MonCreateHypothesis::SetUseField()
704 // ------------------------------------------------------------------------
706 if ( CBJump->isChecked() ) { _UsField = 1 ; }
707 else { _UsField = 0 ; }
709 // ------------------------------------------------------------------------
710 void MonCreateHypothesis::SetFiltrage()
711 // ------------------------------------------------------------------------
713 if (!CBGroupe->isChecked()) return;
714 MonCreateListGroup *aDlg = new MonCreateListGroup(this, NULL, true, HOMARD::HOMARD_Gen::_duplicate(myHomardGen),_aCaseName, _aListeGroupes) ;
718 // ------------------------------------------------------------------------
719 void MonCreateHypothesis::setGroups(QStringList listGroup)
720 // ------------------------------------------------------------------------
722 _aListeGroupes=listGroup;
724 // ------------------------------------------------------------------------
725 bool MonCreateHypothesis::VerifieZone()
726 // ------------------------------------------------------------------------
728 if ( _aTypeAdap != 0 ) return true;
729 MESSAGE("Debut de VerifieZone") ;
730 _aListeZone = GetZonesChecked() ;
731 MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
732 if (_aListeZone.count() == 0)
734 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
735 QObject::tr("HOM_HYPO_ZONE_2") );
738 MESSAGE("Fin de VerifieZone") ;
741 // ------------------------------------------------------------------------
742 bool MonCreateHypothesis::VerifieComposant()
743 // ------------------------------------------------------------------------
745 if ( _aTypeAdap != 1 ) return true;
746 _aListeComposant = GetListCompChecked() ;
747 if (_aListeComposant.count() == 0)
749 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
750 QObject::tr("HOM_HYPO_COMP") );
756 // ------------------------------------------------------------------------
757 void MonCreateHypothesis::AssocieLesZones()
758 // ------------------------------------------------------------------------
760 MESSAGE( "Debut de AssocieLesZones" );
761 if ( _aTypeAdap != 0 ) return;
762 _aListeZone = GetZonesChecked() ;
763 MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
766 for ( int i=0 ; i< _aListeZone.count() ; i++ )
767 { if ( _aListeZone[i+1] == Raff ) { TypeUse = 1 ; }
768 else { TypeUse = -1 ; }
769 aHypothesis->AddZone(_aListeZone[i].toStdString().c_str(), TypeUse);
772 MESSAGE( "Fin de AssocieLesZones" );
774 // ------------------------------------------------------------------------
775 void MonCreateHypothesis::AssocieComposants()
776 // ------------------------------------------------------------------------
778 if ( _aTypeAdap != 1 ) return;
779 MESSAGE( "Dans AssocieComposants, _TypeThC : " << _TypeThC );
780 MESSAGE( "Dans AssocieComposants, _TypeThR : " << _TypeThR );
783 if ( _TypeThR == 1 ) { _ThreshR = SpinBox_RAbs->value();}
784 if ( _TypeThR == 2 ) { _ThreshR = SpinBox_RRel->value();}
785 if ( _TypeThR == 3 ) { _ThreshR = SpinBox_RPE->value(); }
786 if ( _TypeThR == 4 ) { _ThreshR = SpinBox_RMuSigma->value(); }
789 if ( _TypeThC == 1 ) { _ThreshC = SpinBox_CAbs->value();}
790 if ( _TypeThC == 2 ) { _ThreshC = SpinBox_CRel->value();}
791 if ( _TypeThC == 3 ) { _ThreshC = SpinBox_CPE->value(); }
792 if ( _TypeThC == 4 ) { _ThreshC = SpinBox_CMuSigma->value(); }
794 _aFieldName=CBFieldName->currentText();
795 aHypothesis->SetField(CORBA::string_dup(_aFieldName.toStdString().c_str()) ) ;
796 if ( _TypeThR > 0 ) { aHypothesis->SetRefinThr( _TypeThR, _ThreshR ) ; }
797 if ( _TypeThC > 0 ) { aHypothesis->SetUnRefThr( _TypeThC, _ThreshC ) ; }
798 aHypothesis->SetUseField( _UsField ) ;
799 aHypothesis->SetUseComp( _UsCmpI ) ;
800 _aListeComposant = GetListCompChecked() ;
801 for ( int i=0 ; i< _aListeComposant.count() ; i++ )
802 { aHypothesis->AddComp(_aListeComposant[i].toStdString().c_str()); }
804 // ------------------------------------------------------------------------
805 void MonCreateHypothesis::AssocieLesGroupes()
806 // ------------------------------------------------------------------------
808 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
809 aSeqGroupe->length(_aListeGroupes.size());
810 QStringList::const_iterator it;
812 for (it = _aListeGroupes.constBegin(); it != _aListeGroupes.constEnd(); it++)
813 aSeqGroupe[i++]=(*it).toStdString().c_str();
814 aHypothesis->SetGroups(aSeqGroupe);
817 // ------------------------------------------------------------------------
818 void MonCreateHypothesis::SetFieldNo()
819 // ------------------------------------------------------------------------
820 // Par defaut, on n'interpole rien
822 if ( _aTypeAdap == 1 ) { GBFieldFile->setVisible(1); }
823 else { GBFieldFile->setVisible(0); }
824 TWField->setVisible(0);
826 _TypeFieldInterp = 0 ;
830 // ------------------------------------------------------------------------
831 void MonCreateHypothesis::SetFieldAll()
832 // ------------------------------------------------------------------------
833 // Par defaut, on interpole tout
835 if (_aFieldFile == QString(""))
837 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
838 QObject::tr("HOM_HYPO_FIELD_FILE") );
840 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
843 LEFieldFile->setText(_aFieldFile);
844 LEFieldFile->setReadOnly(1);
845 GBFieldFile->setVisible(1);
846 TWField->setVisible(0);
848 _TypeFieldInterp = 1 ;
852 // ------------------------------------------------------------------------
853 void MonCreateHypothesis::SetFieldChosen()
854 // ------------------------------------------------------------------------
856 if (_aFieldFile == QString(""))
858 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
859 QObject::tr("HOM_HYPO_FIELD_FILE") );
861 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
864 LEFieldFile->setText(_aFieldFile);
865 LEFieldFile->setReadOnly(1);
866 GBFieldFile->setVisible(1);
867 // Recuperation de la liste des champs contenus dans le fichier _aFieldFile
868 std::list<QString> listeChamp = HOMARD_QT_COMMUN::GetListeChamps(QString(_aFieldFile) );
870 // Initialisation de la table
872 int nbrow=TWField->rowCount();
873 for ( int row=0; row< nbrow; row++)
875 TWField->removeRow(row);
877 TWField->setRowCount(0);
878 std:: list<QString>::const_iterator it;
880 for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
882 TWField->insertRow(row);
883 TWField->setItem( row, 0, new QTableWidgetItem( QString ("") ) );
884 TWField->item( row, 0 )->setFlags( 0 );
885 TWField->item( row, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
886 TWField->item( row, 0 )->setCheckState( Qt::Unchecked );
887 TWField->setItem( row, 1, new QTableWidgetItem(QString(*it).trimmed()));
888 TWField->item( row, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
891 TWField->resizeColumnsToContents();
892 TWField->resizeRowsToContents();
893 TWField->clearSelection();
894 TWField->setVisible(1);
896 _TypeFieldInterp = 2 ;
900 // ------------------------------------------------------------------------
901 void MonCreateHypothesis::SetAdvanced()
902 // ------------------------------------------------------------------------
904 MESSAGE("Debut de SetAdvanced ");
905 if (CBAdvanced->isChecked())
906 { GBAdvancedOptions->setVisible(1);
907 if (_aFieldFile != QString("")) { GBAdapInit->setVisible(1) ; }
908 else { GBAdapInit->setVisible(0) ; }
911 { GBAdvancedOptions->setVisible(0);
915 CBOutputLevel->setChecked(false);
916 CBOutputQuality->setChecked(false);
917 CBOutputDiameter->setChecked(false);
918 CBOutputParent->setChecked(false);
919 CBOutputVoisins->setChecked(false);
925 // ------------------------------------------------------------------------
926 void MonCreateHypothesis::SetAIN()
927 // ------------------------------------------------------------------------
929 MESSAGE("Debut de SetAIN ");
932 // ------------------------------------------------------------------------
933 void MonCreateHypothesis::SetAIR()
934 // ------------------------------------------------------------------------
936 MESSAGE("Debut de SetAIR ");
939 // ------------------------------------------------------------------------
940 void MonCreateHypothesis::SetAID()
941 // ------------------------------------------------------------------------
943 MESSAGE("Debut de SetAID ");