1 // Copyright (C) 2011 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.
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
22 #include "MonCreateHypothesis.h"
23 #include "MonCreateListGroup.h"
24 #include "MonCreateIteration.h"
25 #include "MonCreateZone.h"
26 #include "MonEditZone.h"
28 #include <QFileDialog>
29 #include <QMessageBox>
31 #include "SalomeApp_Tools.h"
32 #include "HOMARDGUI_Utils.h"
33 #include "HomardQtCommun.h"
34 #include <utilities.h>
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 */
44 QDialog(0), Ui_CreateHypothesis(),
45 _parent(parent), _aHypothesisName(aHypothesisName),
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),
56 MESSAGE("Constructeur") ;
57 _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
62 SetNewHypothesisName();
63 if (_aFieldFile != QString(""))
64 { RBChamp->setChecked(1);
68 { RBUniforme->setChecked(1);
72 GBAdvancedOptions->setVisible(0);
75 // ------------------------------------------------------------------------
76 MonCreateHypothesis::~MonCreateHypothesis()
77 // ------------------------------------------------------------------------
79 // no need to delete child widgets, Qt does it all for us
81 // ------------------------------------------------------------------------
82 void MonCreateHypothesis::InitConnect()
83 // ------------------------------------------------------------------------
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()));
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()));
108 connect( RBFieldNo, SIGNAL(clicked()), this, SLOT(SetFieldNo()));
109 connect( RBFieldAll, SIGNAL(clicked()), this, SLOT(SetFieldAll()));
110 connect( RBFieldChosen,SIGNAL(clicked()), this, SLOT(SetFieldChosen()));
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()));
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()));
123 // ------------------------------------------------------------------------
124 bool MonCreateHypothesis::PushOnApply()
125 // ------------------------------------------------------------------------
126 // Appele lorsque l'un des boutons Ok ou Apply est presse
132 if (LEHypothesisName->text().trimmed()=="") {
133 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
134 QObject::tr("HOM_HYPO_NAME") );
138 if (VerifieZone() == false) return false;
139 if (VerifieComposant() == false) return false;
141 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
142 if (LEHypothesisName->text().trimmed() != _aHypothesisName)
144 _aHypothesisName=LEHypothesisName->text().trimmed();
147 _aHypothesis=_myHomardGen->CreateHypothesis(CORBA::string_dup(_aHypothesisName.toStdString().c_str()) );
148 _parent->addHypothese(_aHypothesisName);
150 catch( SALOME::SALOME_Exception& S_ex )
152 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
153 QString(CORBA::string_dup(S_ex.details.text)) );
158 // Mise en place des attributs
159 _aHypothesis->SetAdapRefinUnRef(_aTypeAdap,_aTypeRaff,_aTypeDera);
160 _aHypothesis->SetTypeFieldInterp(_TypeFieldInterp);
161 _aHypothesis->SetCaseCreation(_aCaseName.toStdString().c_str());
166 AssocieFieldInterp();
169 if (CBAdvanced->isChecked())
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);
181 HOMARD_UTILS::updateObjBrowser();
186 // ------------------------------------------------------------------------
187 void MonCreateHypothesis::PushOnOK()
188 // ------------------------------------------------------------------------
190 if (PushOnApply()) this->close();
191 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
193 // ------------------------------------------------------------------------
194 void MonCreateHypothesis::PushOnHelp()
195 // ------------------------------------------------------------------------
197 HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"));
199 // -------------------------------------------------
200 void MonCreateHypothesis::SetNewHypothesisName()
201 // --------------------------------------------------
204 HOMARD::listeHypotheses_var MyHypos = _myHomardGen->GetAllHypotheses();
206 QString aHypothesisName="";
207 while (aHypothesisName=="" )
209 aHypothesisName.setNum(num+1) ;
210 aHypothesisName.insert(0, QString("Hypo_")) ;
211 for ( int i=0; i<MyHypos->length(); i++)
213 if ( aHypothesisName == QString(MyHypos[i]))
221 LEHypothesisName->setText(aHypothesisName);
225 // ------------------------------------------------------------------------
226 void MonCreateHypothesis::SetUniforme()
227 // ------------------------------------------------------------------------
229 GBFieldManagement->setVisible(0);
230 if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
231 else { GBFieldFile->setVisible(1); }
232 GBAreaManagement->setVisible(0);
233 GBUniform->setVisible(1);
237 // ------------------------------------------------------------------------
238 void MonCreateHypothesis::SetChamp()
239 // ------------------------------------------------------------------------
241 if (_aFieldFile == QString(""))
243 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
244 QObject::tr("HOM_HYPO_FIELD_FILE") );
246 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
249 LEFieldFile->setText(_aFieldFile);
250 LEFieldFile->setReadOnly(1);
252 GBUniform->setVisible(0);
253 GBAreaManagement->setVisible(0);
254 GBFieldManagement->setVisible(1);
255 GBFieldFile->setVisible(1);
257 GBUniform->adjustSize();
258 GBAreaManagement->adjustSize();
259 GBFieldManagement->adjustSize();
260 GBFieldFile->adjustSize();
265 // ------------------------------------------------------------------------
266 void MonCreateHypothesis::SetZone()
267 // ------------------------------------------------------------------------
270 GBUniform->setVisible(0);
271 GBFieldManagement->setVisible(0);
272 if ( _TypeFieldInterp == 0 ) { GBFieldFile->setVisible(0); }
273 else { GBFieldFile->setVisible(1); }
274 GBAreaManagement->setVisible(1);
281 // ------------------------------------------------------------------------
282 void MonCreateHypothesis::PushZoneNew()
283 // ------------------------------------------------------------------------
285 MESSAGE("Debut de MonCreateHypothesis::PushZoneNew")
286 MonCreateZone *aDlg = new MonCreateZone(this, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName) ;
290 // ------------------------------------------------------------------------
291 void MonCreateHypothesis::PushZoneEdit()
292 // ------------------------------------------------------------------------
294 MESSAGE("Debut de MonCreateHypothesis::PushZoneEdit")
295 int colonne = TWZone->currentColumn();
296 QTableWidgetItem * monItem = TWZone->currentItem();
297 if (colonne !=2 or monItem == NULL)
299 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
300 QObject::tr("HOM_HYPO_ZONE_1") );
303 QString zoneName = monItem->text().trimmed();
304 MonEditZone *aDlg = new MonEditZone(this, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName, zoneName) ;
307 // ------------------------------------------------------------------------
308 void MonCreateHypothesis::PushZoneDelete()
309 // ------------------------------------------------------------------------
311 MESSAGE("Debut de MonCreateHypothesis::PushZoneDelete")
312 QMessageBox::warning( 0, QObject::tr("HOM_WARNING"),
313 QObject::tr("HOM_INACTIVE_BUTTON") );
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
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++)
329 TWZone->removeRow(row);
331 TWZone->setRowCount(0);
333 for (int i=0; i<mesZones->length(); i++)
335 TWZone->insertRow(row);
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 );
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 );
347 TWZone->setItem( row, 2, new QTableWidgetItem(QString(mesZones[i]).trimmed()));
348 TWZone->item( row, 2 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
352 TWZone->resizeColumnsToContents();
353 TWZone->resizeRowsToContents();
354 TWZone->clearSelection();
356 // ------------------------------------------------------------------------
357 void MonCreateHypothesis::addZoneinTWZone(QString newZone)
358 // ------------------------------------------------------------------------
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 );
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 );
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 );
373 TWZone->setItem( row, 2, new QTableWidgetItem( newZone ) );
374 TWZone->scrollToItem( TWZone->item( row, 2 ) );
376 TWZone->resizeRowsToContents();
377 TWZone->resizeColumnToContents(1);
378 TWZone->clearSelection();
380 TWZone->item( row, 2 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
382 // ------------------------------------------------------------------------
383 QStringList MonCreateHypothesis::GetZonesChecked()
384 // ------------------------------------------------------------------------
385 // Retourne les zones enregistrees
387 MESSAGE("Debut de GetZonesChecked") ;
388 QStringList ListeZone ;
389 // On ne peut pas avoir selectionne les deux options
391 for ( int row=0; row< TWZone->rowCount(); row++)
393 if ( ( TWZone->item( row, 0 )->checkState() == Qt::Checked ) and ( TWZone->item( row, 1 )->checkState() == Qt::Checked ) )
395 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
396 QObject::tr("HOM_HYPO_ZONE_3") );
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
405 QString Dera = "-1" ;
406 for ( int row=0; row< TWZone->rowCount(); row++)
408 // MESSAGE ("row "<<row<<", zone : "<<TWZone->item(row, 2)->text().toStdString());
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()) ) ; }
418 MESSAGE("Fin de GetZonesChecked ; longueur de ListeZone : "<<ListeZone.count()) ;
423 // ------------------------------------------------------------------------
424 QStringList MonCreateHypothesis::GetListCompChecked()
425 // ------------------------------------------------------------------------
426 // Retourne les composantes retenues
428 MESSAGE( "Debut de GetListCompChecked" );
429 QStringList ListeComposant ;
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"));
441 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
442 RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
444 return ListeComposant ;
447 // ------------------------------------------------------------------------
448 void MonCreateHypothesis::AssocieFieldInterp()
449 // ------------------------------------------------------------------------
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()); }
456 // ------------------------------------------------------------------------
457 void MonCreateHypothesis::SetUniRaff()
458 // ------------------------------------------------------------------------
463 // ------------------------------------------------------------------------
464 void MonCreateHypothesis::SetUniDera()
465 // ------------------------------------------------------------------------
471 // ------------------------------------------------------------------------
472 void MonCreateHypothesis::InitFields()
473 // ------------------------------------------------------------------------
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++)
481 CBFieldName->insertItem(0,QString(*it));
485 // ---------------------------------------
486 void MonCreateHypothesis::SetFieldName()
487 // -------------------------------------------
489 MESSAGE("Debut de SetFieldName");
490 _aFieldName=CBFieldName->currentText();
491 if (QString(_aFieldFile) == QString("") or QString(_aFieldName) == QString("") ) { return; }
493 int nbrow= TWCMP->rowCount() ;
494 for ( int row=0; row < nbrow ; row++)
496 TWCMP->removeRow(row);
498 TWCMP->setRowCount(0);
499 //TWCMP->resizeRowsToContents();
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++)
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 );
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"));
522 { RBL2->setText(QObject::tr("HOM_HYPO_NORM_L2"));
523 RBInf->setText(QObject::tr("HOM_HYPO_NORM_INF"));
525 // Par defaut, on propose la valeur absolue / norme L2
528 // ------------------------------------------------------------------------
529 void MonCreateHypothesis::SetRPE()
530 // ------------------------------------------------------------------------
534 RBRPE->setChecked(true);
535 SpinBox_RPE->setEnabled(true);
536 SpinBox_RRel->setEnabled(false);
537 SpinBox_RAbs->setEnabled(false);
539 // ------------------------------------------------------------------------
540 void MonCreateHypothesis::SetRRel()
541 // ------------------------------------------------------------------------
545 RBRRel->setChecked(true);
546 SpinBox_RPE->setEnabled(false);
547 SpinBox_RRel->setEnabled(true);
548 SpinBox_RAbs->setEnabled(false);
550 // ------------------------------------------------------------------------
551 void MonCreateHypothesis::SetRAbs()
552 // ------------------------------------------------------------------------
556 RBRAbs->setChecked(true);
557 SpinBox_RPE->setEnabled(false);
558 SpinBox_RRel->setEnabled(false);
559 SpinBox_RAbs->setEnabled(true);
561 // ------------------------------------------------------------------------
562 void MonCreateHypothesis::SetRNo()
563 // ------------------------------------------------------------------------
567 RBRNo->setChecked(true);
568 SpinBox_RPE->setEnabled(false);
569 SpinBox_RRel->setEnabled(false);
570 SpinBox_RAbs->setEnabled(false);
572 // ------------------------------------------------------------------------
573 void MonCreateHypothesis::SetCPE()
574 // ------------------------------------------------------------------------
578 RBCPE->setChecked(true);
579 SpinBox_CPE->setEnabled(true);
580 SpinBox_CRel->setEnabled(false);
581 SpinBox_CAbs->setEnabled(false);
583 // ------------------------------------------------------------------------
584 void MonCreateHypothesis::SetCRel()
585 // ------------------------------------------------------------------------
589 RBCRel->setChecked(true);
590 SpinBox_CPE->setEnabled(false);
591 SpinBox_CRel->setEnabled(true);
592 SpinBox_CAbs->setEnabled(false);
594 // ------------------------------------------------------------------------
595 void MonCreateHypothesis::SetCAbs()
596 // ------------------------------------------------------------------------
600 RBCAbs->setChecked(true);
601 SpinBox_CPE->setEnabled(false);
602 SpinBox_CRel->setEnabled(false);
603 SpinBox_CAbs->setEnabled(true);
605 // ------------------------------------------------------------------------
606 void MonCreateHypothesis::SetCNo()
607 // ------------------------------------------------------------------------
611 RBCNo->setChecked(true);
612 SpinBox_CPE->setEnabled(false);
613 SpinBox_CRel->setEnabled(false);
614 SpinBox_CAbs->setEnabled(false);
616 // ------------------------------------------------------------------------
617 void MonCreateHypothesis::SetUCL2()
618 // ------------------------------------------------------------------------
621 RBL2->setChecked(true);
623 // ------------------------------------------------------------------------
624 void MonCreateHypothesis::SetUCInf()
625 // ------------------------------------------------------------------------
628 RBInf->setChecked(true);
630 // ------------------------------------------------------------------------
631 void MonCreateHypothesis::SetUseField()
632 // ------------------------------------------------------------------------
634 if ( CBJump->isChecked() ) { _UsField = 1 ; }
635 else { _UsField = 0 ; }
637 // ------------------------------------------------------------------------
638 void MonCreateHypothesis::SetFiltrage()
639 // ------------------------------------------------------------------------
641 if (!CBGroupe->isChecked()) return;
642 MonCreateListGroup *aDlg = new MonCreateListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),_aCaseName, _aListeGroupes) ;
646 // ------------------------------------------------------------------------
647 void MonCreateHypothesis::setGroups(QStringList listGroup)
648 // ------------------------------------------------------------------------
650 _aListeGroupes=listGroup;
652 // ------------------------------------------------------------------------
653 bool MonCreateHypothesis::VerifieZone()
654 // ------------------------------------------------------------------------
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)
662 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
663 QObject::tr("HOM_HYPO_ZONE_2") );
666 MESSAGE("Fin de VerifieZone") ;
669 // ------------------------------------------------------------------------
670 bool MonCreateHypothesis::VerifieComposant()
671 // ------------------------------------------------------------------------
673 if ( _aTypeAdap != 1 ) return true;
674 _aListeComposant = GetListCompChecked() ;
675 if (_aListeComposant.count() == 0)
677 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
678 QObject::tr("HOM_HYPO_COMP") );
684 // ------------------------------------------------------------------------
685 void MonCreateHypothesis::AssocieLesZones()
686 // ------------------------------------------------------------------------
688 MESSAGE( "Debut de AssocieLesZones" );
689 if ( _aTypeAdap != 0 ) return;
690 _aListeZone = GetZonesChecked() ;
691 MESSAGE(". Longueur de _aListeZone : "<<_aListeZone.count()) ;
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);
700 MESSAGE( "Fin de AssocieLesZones" );
702 // ------------------------------------------------------------------------
703 void MonCreateHypothesis::AssocieComposants()
704 // ------------------------------------------------------------------------
706 if ( _aTypeAdap != 1 ) return;
707 MESSAGE( "Dans AssocieComposants, _TypeThC : " << _TypeThC );
708 MESSAGE( "Dans AssocieComposants, _TypeThR : " << _TypeThR );
711 if ( _TypeThR == 1 ) { _ThreshR = SpinBox_RAbs->value();}
712 if ( _TypeThR == 2 ) { _ThreshR = SpinBox_RRel->value();}
713 if ( _TypeThR == 3 ) { _ThreshR = SpinBox_RPE->value(); }
716 if ( _TypeThC == 1 ) { _ThreshC = SpinBox_CAbs->value();}
717 if ( _TypeThC == 2 ) { _ThreshC = SpinBox_CRel->value();}
718 if ( _TypeThC == 3 ) { _ThreshC = SpinBox_CPE->value(); }
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()); }
730 // ------------------------------------------------------------------------
731 void MonCreateHypothesis::AssocieLesGroupes()
732 // ------------------------------------------------------------------------
734 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
735 aSeqGroupe->length(_aListeGroupes.size());
736 QStringList::const_iterator it;
738 for (it = _aListeGroupes.constBegin(); it != _aListeGroupes.constEnd(); it++)
739 aSeqGroupe[i++]=(*it).toStdString().c_str();
740 _aHypothesis->SetGroups(aSeqGroupe);
743 // ------------------------------------------------------------------------
744 void MonCreateHypothesis::SetFieldNo()
745 // ------------------------------------------------------------------------
746 // Par defaut, on n'interpole rien
748 if ( _aTypeAdap == 1 ) { GBFieldFile->setVisible(1); }
749 else { GBFieldFile->setVisible(0); }
750 TWField->setVisible(0);
753 _TypeFieldInterp = 0 ;
755 // ------------------------------------------------------------------------
756 void MonCreateHypothesis::SetFieldAll()
757 // ------------------------------------------------------------------------
758 // Par defaut, on interpole tout
760 if (_aFieldFile == QString(""))
762 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
763 QObject::tr("HOM_HYPO_FIELD_FILE") );
765 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
768 LEFieldFile->setText(_aFieldFile);
769 LEFieldFile->setReadOnly(1);
770 GBFieldFile->setVisible(1);
771 TWField->setVisible(0);
773 _TypeFieldInterp = 1 ;
776 // ------------------------------------------------------------------------
777 void MonCreateHypothesis::SetFieldChosen()
778 // ------------------------------------------------------------------------
780 if (_aFieldFile == QString(""))
782 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
783 QObject::tr("HOM_HYPO_FIELD_FILE") );
785 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
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) );
794 // Initialisation de la table
796 int nbrow=TWField->rowCount();
797 for ( int row=0; row< nbrow; row++)
799 TWField->removeRow(row);
801 TWField->setRowCount(0);
802 std:: list<QString>::const_iterator it;
804 for ( it=listeChamp.begin() ; it != listeChamp.end(); it++)
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 );
815 TWField->resizeColumnsToContents();
816 TWField->resizeRowsToContents();
817 TWField->clearSelection();
818 TWField->setVisible(1);
820 _TypeFieldInterp = 2 ;
823 // ------------------------------------------------------------------------
824 void MonCreateHypothesis::SetAdvanced()
825 // ------------------------------------------------------------------------
827 MESSAGE("Debut de SetAdvanced ");
828 if (CBAdvanced->isChecked())
829 { GBAdvancedOptions->setVisible(1);
830 if (_aFieldFile != QString(""))
831 { GBAdapInit->setVisible(1) ;
834 { GBAdapInit->setVisible(0) ;
838 { GBAdvancedOptions->setVisible(0);
845 // ------------------------------------------------------------------------
846 void MonCreateHypothesis::SetAIN()
847 // ------------------------------------------------------------------------
849 MESSAGE("Debut de SetAIN ");
852 // ------------------------------------------------------------------------
853 void MonCreateHypothesis::SetAIR()
854 // ------------------------------------------------------------------------
856 MESSAGE("Debut de SetAIR ");
859 // ------------------------------------------------------------------------
860 void MonCreateHypothesis::SetAID()
861 // ------------------------------------------------------------------------
863 MESSAGE("Debut de SetAID ");