3 #include "MonCreateBoundaryDi.h"
4 #include "MonCreateListGroup.h"
5 #include "MonCreateCase.h"
10 #include "SalomeApp_Tools.h"
11 #include "HOMARDGUI_Utils.h"
12 #include "HomardQtCommun.h"
13 #include <utilities.h>
15 // -------------------------------------------------------------------------------
16 MonCreateBoundaryDi::MonCreateBoundaryDi(MonCreateCase* parent, bool modal,
17 HOMARD::HOMARD_Gen_var myHomardGen,
18 QString caseName, QString aBoundaryName)
19 // ---------------------------------------------------------------------------------
20 /* Constructs a MonCreateBoundaryDi */
22 QDialog(0), Ui_CreateBoundaryDi(),
23 _parent(parent), _aBoundaryName(aBoundaryName),
24 _myHomardGen(HOMARD::HOMARD_Gen::_duplicate(myHomardGen)),
27 MESSAGE("Constructeur") ;
32 if ( _aBoundaryName == QString("") ) {SetNewBoundaryName();};
35 // ------------------------------------------------------------------------
36 MonCreateBoundaryDi::~MonCreateBoundaryDi()
37 // ------------------------------------------------------------------------
39 // no need to delete child widgets, Qt does it all for us
41 // ------------------------------------------------------------------------
42 void MonCreateBoundaryDi::InitConnect()
43 // ------------------------------------------------------------------------
45 connect( PushFichier, SIGNAL(pressed()), this, SLOT(SetMeshFile()));
46 connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK()));
47 connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply()));
48 connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
49 connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp()));
50 connect( CBGroupe, SIGNAL(stateChanged(int)), this, SLOT( SetFiltrage()));
53 // ------------------------------------------------------------------------
54 bool MonCreateBoundaryDi::PushOnApply()
55 // ------------------------------------------------------------------------
56 // Appele lorsque l'un des boutons Ok ou Apply est presse
61 QString aBoundaryName=LEBoundaryName->text().trimmed();
62 if (aBoundaryName=="") {
63 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
64 QObject::tr("HOM_BOUN_NAME") );
68 // Le maillage de la frontiere discrete
69 QString aMeshFile=LEFileName->text().trimmed();
70 if (aMeshFile ==QString(""))
72 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
73 QObject::tr("HOM_BOUN_MESH") );
77 // Le nom du maillage de la frontiere discrete
78 QString aMeshName = HOMARD_QT_COMMUN::LireNomMaillage(aMeshFile);
81 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
82 QObject::tr("HOM_MED_FILE_2") );
86 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
87 if ( _aBoundaryName != aBoundaryName )
91 _aBoundaryName=aBoundaryName;
92 _aBoundary=_myHomardGen->CreateBoundary(CORBA::string_dup(_aBoundaryName.toStdString().c_str()),0);
93 _parent->addBoundaryDi(_aBoundaryName);
94 _aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str());
96 catch( SALOME::SALOME_Exception& S_ex )
98 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
99 QString(CORBA::string_dup(S_ex.details.text)) );
104 // Mise en place des attributs
105 _aBoundary->SetMeshFile(aMeshFile.toStdString().c_str());
106 _aBoundary->SetMeshName(aMeshName.toStdString().c_str());
109 HOMARD_UTILS::updateObjBrowser();
114 // ------------------------------------------------------------------------
115 void MonCreateBoundaryDi::PushOnOK()
116 // ------------------------------------------------------------------------
118 if (PushOnApply()) this->close();
119 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
121 // ------------------------------------------------------------------------
122 void MonCreateBoundaryDi::PushOnHelp()
123 // ------------------------------------------------------------------------
125 HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html#frontiere-discrete"));
127 // ------------------------------------------------------------------------
128 void MonCreateBoundaryDi::AssocieLesGroupes()
129 // ------------------------------------------------------------------------
131 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
132 aSeqGroupe->length(_listeGroupesBoundary.size());
133 QStringList::const_iterator it;
135 for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++)
136 aSeqGroupe[i++]=(*it).toStdString().c_str();
137 _aBoundary->SetGroups(aSeqGroupe);
141 // -------------------------------------------------
142 void MonCreateBoundaryDi::SetNewBoundaryName()
143 // --------------------------------------------------
146 HOMARD::listeBoundarys_var MyBoundarys = _myHomardGen->GetAllBoundarys();
147 int num = 0; QString aBoundaryName="";
148 while (aBoundaryName == QString("") )
150 aBoundaryName.setNum(num+1) ;
151 aBoundaryName.insert(0, QString("Boun_")) ;
152 for ( int i=0; i<MyBoundarys->length(); i++)
154 if ( aBoundaryName == QString(MyBoundarys[i]))
162 LEBoundaryName->setText(aBoundaryName);
164 // ------------------------------------------------------------------------
165 void MonCreateBoundaryDi::SetMeshFile()
166 // ------------------------------------------------------------------------
168 QString aMeshFile = HOMARD_QT_COMMUN::PushNomFichier();
169 if (!(aMeshFile.isEmpty())) LEFileName->setText(aMeshFile);
172 // ------------------------------------------------------------------------
173 void MonCreateBoundaryDi::setGroups (QStringList listGroup)
174 // ------------------------------------------------------------------------
176 _listeGroupesBoundary = listGroup;
178 // ------------------------------------------------------------------------
179 void MonCreateBoundaryDi::SetFiltrage()
180 // // ------------------------------------------------------------------------
182 if (!CBGroupe->isChecked()) return;
183 if (_aCaseName.toStdString().c_str() == QString()) {
184 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
185 QObject::tr("HOM_BOUN_CASE") );
189 MonCreateListGroup *aDlg = new MonCreateListGroup(NULL,this, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),
190 _aCaseName, _listeGroupesBoundary) ;