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::information( 0, "Error",
64 "The boundary must be named.",
65 QMessageBox::Ok + QMessageBox::Default );
69 // Le maillage de la frontiere discrete
70 QString aMeshFile=LEFileName->text().trimmed();
71 if (aMeshFile ==QString(""))
73 QMessageBox::information( 0, "Error",
74 QString("The mesh of the boundary must be selected."),
75 QMessageBox::Ok + QMessageBox::Default );
79 // Le nom du maillage de la frontiere discrete
80 QString aMeshName = HOMARD_QT_COMMUN::LireNomMaillage(aMeshFile);
83 QMessageBox::information( 0, "Error",
84 QString("no mesh in mesh file"),
85 QMessageBox::Ok + QMessageBox::Default );
89 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
90 if ( _aBoundaryName != aBoundaryName )
94 _aBoundaryName=aBoundaryName;
95 _aBoundary=_myHomardGen->CreateBoundary(CORBA::string_dup(_aBoundaryName.toStdString().c_str()),0);
96 _parent->addBoundaryDi(_aBoundaryName);
97 _aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str());
99 catch( SALOME::SALOME_Exception& S_ex )
101 QMessageBox::information( 0, "Error",
102 QString(CORBA::string_dup(S_ex.details.text)),
103 QMessageBox::Ok + QMessageBox::Default );
108 // Mise en place des attributs
109 _aBoundary->SetMeshFile(aMeshFile.toStdString().c_str());
110 _aBoundary->SetMeshName(aMeshName.toStdString().c_str());
113 HOMARD_UTILS::updateObjBrowser();
118 // ------------------------------------------------------------------------
119 void MonCreateBoundaryDi::PushOnOK()
120 // ------------------------------------------------------------------------
122 if (PushOnApply()) this->close();
123 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
125 // ------------------------------------------------------------------------
126 void MonCreateBoundaryDi::PushOnHelp()
127 // ------------------------------------------------------------------------
129 HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"));
131 // ------------------------------------------------------------------------
132 void MonCreateBoundaryDi::AssocieLesGroupes()
133 // ------------------------------------------------------------------------
135 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
136 aSeqGroupe->length(_listeGroupesBoundary.size());
137 QStringList::const_iterator it;
139 for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++)
140 aSeqGroupe[i++]=(*it).toStdString().c_str();
141 _aBoundary->SetGroups(aSeqGroupe);
145 // -------------------------------------------------
146 void MonCreateBoundaryDi::SetNewBoundaryName()
147 // --------------------------------------------------
150 HOMARD::listeBoundarys_var MyBoundarys = _myHomardGen->GetAllBoundarys();
151 int num = 0; QString aBoundaryName="";
152 while (aBoundaryName == QString("") )
154 aBoundaryName.setNum(num+1) ;
155 aBoundaryName.insert(0, QString("Boun_")) ;
156 for ( int i=0; i<MyBoundarys->length(); i++)
158 if ( aBoundaryName == QString(MyBoundarys[i]))
166 LEBoundaryName->setText(aBoundaryName);
168 // ------------------------------------------------------------------------
169 void MonCreateBoundaryDi::SetMeshFile()
170 // ------------------------------------------------------------------------
172 QString aMeshFile = HOMARD_QT_COMMUN::PushNomFichier();
173 if (!(aMeshFile.isEmpty())) LEFileName->setText(aMeshFile);
176 // ------------------------------------------------------------------------
177 void MonCreateBoundaryDi::setGroups (QStringList listGroup)
178 // ------------------------------------------------------------------------
180 _listeGroupesBoundary = listGroup;
182 // ------------------------------------------------------------------------
183 void MonCreateBoundaryDi::SetFiltrage()
184 // // ------------------------------------------------------------------------
186 if (!CBGroupe->isChecked()) return;
187 if (_aCaseName.toStdString().c_str() == QString()) {
188 QMessageBox::information( 0, "Error",
189 "Case MeshFile unknowned.",
190 QMessageBox::Ok + QMessageBox::Default );
194 MonCreateListGroup *aDlg = new MonCreateListGroup(NULL,this, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),
195 _aCaseName, _listeGroupesBoundary) ;