1 // Copyright (C) 2011-2021 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 "SMESHGUI_HomardBoundaryDlg.h"
22 #include "SMESHGUI_HomardAdaptDlg.h"
23 #include "SMESHGUI_HomardListGroup.h"
25 #include "SMESHGUI_Utils.h"
27 #include <QFileDialog>
28 #include <QMessageBox>
30 #include "SalomeApp_Tools.h"
31 #include "SMESHGUI_HomardUtils.h"
32 #include <utilities.h>
34 #include <SUIT_Desktop.h>
35 #include <SUIT_MessageBox.h>
36 #include <SUIT_ResourceMgr.h>
37 #include <SUIT_Session.h>
38 #include <SUIT_ViewManager.h>
41 #define PI 3.141592653589793
45 // ----------------------------------------------------------------------------------
46 SMESH_CreateBoundaryAn::SMESH_CreateBoundaryAn(SMESHGUI_HomardAdaptDlg* parent, bool modal,
47 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
49 /* Constructs a SMESH_CreateBoundaryAn
50 appele pour une vraie creation
51 initialise un cylindre et non une sphere
53 QDialog(0), SMESH_Ui_CreateBoundaryAn(),
57 _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0),
58 _BoundaryAnXaxis(0), _BoundaryAnYaxis(0), _BoundaryAnZaxis(0),
59 _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0),
60 _Xmin(0), _Xmax(0), _Xincr(0), _Ymin(0), _Ymax(0), _Yincr(0), _Zmin(0), _Zmax(0), _Zincr(0), _DMax(0),
61 _BoundaryAnXcone1(0), _BoundaryAnYcone1(0), _BoundaryAnZcone1(0), _BoundaryAnRayon1(0),
62 _BoundaryAnXcone2(0), _BoundaryAnYcone2(0), _BoundaryAnZcone2(0), _BoundaryAnRayon2(0),
63 _BoundaryAnXaxisCone(0), _BoundaryAnYaxisCone(0), _BoundaryAnZaxisCone(0),
64 _BoundaryAnXorigCone(0), _BoundaryAnYorigCone(0), _BoundaryAnZorigCone(0),
66 _BoundaryAnToreXcentre(0), _BoundaryAnToreYcentre(0), _BoundaryAnToreZcentre(0),
67 _BoundaryAnToreXaxe(0), _BoundaryAnToreYaxe(0), _BoundaryAnToreZaxe(0),
68 _BoundaryAnToreRRev(0), _BoundaryAnToreRPri(0),
71 MESSAGE("Constructeur") ;
72 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
79 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
80 pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" );
82 RBSphere->setIcon(IS);
83 pix = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" );
85 RBCylindre->setIcon(IS);
86 pix = resMgr->loadPixmap( "HOMARD", "cone.png" );
89 pix = resMgr->loadPixmap( "HOMARD", "conepointvector.png" );
91 RB_Def_angle->setIcon(IS);
92 pix = resMgr->loadPixmap( "HOMARD", "conedxyz.png" );
94 RB_Def_radius->setIcon(IS);
95 pix = resMgr->loadPixmap( "HOMARD", "toruspointvector.png" );
102 InitValBoundaryAn(); // Cherche les valeurs de la boite englobante le maillage
103 InitMinMax(); // Initialise les bornes des boutons
104 SetCylinder(); // Propose un cylindre en premier choix
107 // -------------------------------------------------------------------------------
108 SMESH_CreateBoundaryAn::SMESH_CreateBoundaryAn(SMESHGUI_HomardAdaptDlg* parent,
109 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
111 QDialog(0), SMESH_Ui_CreateBoundaryAn(),
115 _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0),
116 _BoundaryAnXaxis(0), _BoundaryAnYaxis(0), _BoundaryAnZaxis(0),
117 // Pour affichage lors de l edition d une BoundaryAn sans nom de Cas
118 _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0),
119 _Xmin(1), _Xmax(1), _Xincr(1), _Ymin(1), _Ymax(1), _Yincr(1), _Zmin(1), _Zmax(1), _Zincr(1), _DMax(1),
122 // MESSAGE("Debut de SMESH_CreateBoundaryAn")
123 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
125 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
126 QPixmap pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" );
128 RBSphere->setIcon(IS);
129 QPixmap pix2 = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" );
130 QIcon IS2=QIcon(pix2);
131 RBCylindre->setIcon(IS2);
132 QPixmap pix3 = resMgr->loadPixmap( "HOMARD", "cone.png" );
133 QIcon IS3=QIcon(pix3);
134 RBCone->setIcon(IS3);
135 QPixmap pix4 = resMgr->loadPixmap( "HOMARD", "conepointvector.png" );
136 QIcon IS4=QIcon(pix4);
137 RB_Def_angle->setIcon(IS4);
138 QPixmap pix5 = resMgr->loadPixmap( "HOMARD", "conedxyz.png" );
139 QIcon IS5=QIcon(pix5);
140 RB_Def_radius->setIcon(IS5);
145 // ------------------------------------------------------------------------
146 SMESH_CreateBoundaryAn::~SMESH_CreateBoundaryAn()
147 // ------------------------------------------------------------------------
149 // no need to delete child widgets, Qt does it all for us
151 // ------------------------------------------------------------------------
152 void SMESH_CreateBoundaryAn::InitConnect()
153 // ------------------------------------------------------------------------
155 connect( RBCylindre, SIGNAL(clicked()) , this, SLOT(SetCylinder()) ) ;
156 connect( RBSphere, SIGNAL(clicked()) , this, SLOT(SetSphere()) ) ;
157 connect( RBCone, SIGNAL(clicked()) , this, SLOT(SetCone()) ) ;
158 connect( RB_Def_radius, SIGNAL(clicked()) , this, SLOT(SetConeR()) );
159 connect( RB_Def_angle, SIGNAL(clicked()) , this, SLOT(SetConeA()) );
160 connect( RBTore, SIGNAL(clicked()) , this, SLOT(SetTore()) ) ;
161 connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) );
162 connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) );
163 connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) );
164 connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) );
166 // ------------------------------------------------------------------------
167 void SMESH_CreateBoundaryAn::InitValBoundaryAn()
168 // ------------------------------------------------------------------------
171 // 1. Les coordonnees extremes du maillage
173 SMESHHOMARD::HOMARD_Cas_var aCas = myHomardGen->GetCase();
174 SMESHHOMARD::extrema_var MesExtremes = aCas->GetBoundingBox();
175 int num = MesExtremes->length() ;
177 _Xmin=MesExtremes[0]; _Xmax=MesExtremes[1]; _Xincr=MesExtremes[2];
178 _Ymin=MesExtremes[3]; _Ymax=MesExtremes[4]; _Yincr=MesExtremes[5];
179 _Zmin=MesExtremes[6]; _Zmax=MesExtremes[7]; _Zincr=MesExtremes[8];
180 _DMax=MesExtremes[9];
181 MESSAGE ("_Xmin : " << _Xmin << " _Xmax : " << _Xmax << " _Xincr : " << _Xincr ) ;
182 MESSAGE ("_Ymin : " << _Ymin << " _Ymax : " << _Ymax << " _Yincr : " << _Yincr ) ;
183 MESSAGE ("_Zmin : " << _Zmin << " _Zmax : " << _Zmax << " _Zincr : " << _Zincr) ;
184 MESSAGE ("_DMax : " << _DMax);
186 // 2. Caracteristiques des frontieres
188 _Xcentre=(_Xmin + _Xmax)/2.;
190 _Ycentre=(_Ymin + _Ymax)/2.;
192 _Zcentre=(_Zmin + _Zmax)/2.;
197 // ------------------------------------------------------------------------
198 void SMESH_CreateBoundaryAn::InitMinMax()
199 // ------------------------------------------------------------------------
203 SpinBox_Xcent->setValue(_Xcentre);
204 SpinBox_Xcent->setSingleStep(_Xincr);
206 SpinBox_Ycent->setValue(_Ycentre);
207 SpinBox_Ycent->setSingleStep(_Yincr);
209 SpinBox_Zcent->setValue(_Zcentre);
210 SpinBox_Zcent->setSingleStep(_Zincr);
212 SpinBox_Xaxis->setValue(0.);
213 SpinBox_Xaxis->setSingleStep(0.1);
215 SpinBox_Yaxis->setValue(0.);
216 SpinBox_Yaxis->setSingleStep(0.1);
218 SpinBox_Zaxis->setValue(1.);
219 SpinBox_Zaxis->setSingleStep(0.1);
221 SpinBox_Radius->setValue(_Rayon);
222 SpinBox_Radius->setSingleStep(_Rayon/10.);
226 SpinBox_Xcentre->setValue(_Xcentre);
227 SpinBox_Xcentre->setSingleStep(_Xincr);
229 SpinBox_Ycentre->setValue(_Ycentre);
230 SpinBox_Ycentre->setSingleStep(_Yincr);
232 SpinBox_Zcentre->setValue(_Zcentre);
233 SpinBox_Zcentre->setSingleStep(_Zincr);
235 SpinBox_Rayon->setValue(_Rayon);
236 SpinBox_Rayon->setSingleStep(_Rayon/10.);
240 _BoundaryAnXcone1 = _Xcentre ;
241 SpinBox_Cone_X1->setSingleStep(_Xincr);
242 _BoundaryAnXcone2 = _Xcentre ;
243 SpinBox_Cone_X2->setSingleStep(_Xincr);
245 _BoundaryAnYcone1 = _Ycentre ;
246 SpinBox_Cone_Y1->setSingleStep(_Yincr);
247 _BoundaryAnYcone2 = _Ycentre ;
248 SpinBox_Cone_Y2->setSingleStep(_Yincr);
250 _BoundaryAnZcone1 = _Zmin ;
251 SpinBox_Cone_Z1->setSingleStep(_Zincr);
252 _BoundaryAnZcone2 = _Zmax ;
253 SpinBox_Cone_Z2->setSingleStep(_Zincr);
255 _BoundaryAnRayon1 = 0. ;
256 _BoundaryAnRayon2 = _Rayon ;
257 SpinBox_Cone_V2->setSingleStep(_Rayon/10.);
260 convertRayonAngle(1) ;
261 SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
262 SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
263 SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
264 SpinBox_Cone_V1->setValue(_BoundaryAngle);
265 SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
266 SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
267 SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
271 SpinBoxToreXcent->setValue(_Xcentre);
272 SpinBoxToreXcent->setSingleStep(_Xincr);
274 SpinBoxToreYcent->setValue(_Ycentre);
275 SpinBoxToreYcent->setSingleStep(_Yincr);
277 SpinBoxToreZcent->setValue(_Zcentre);
278 SpinBoxToreZcent->setSingleStep(_Zincr);
280 SpinBoxToreXaxe->setValue(0.);
281 SpinBoxToreXaxe->setSingleStep(0.1);
283 SpinBoxToreYaxe->setValue(0.);
284 SpinBoxToreYaxe->setSingleStep(0.1);
286 SpinBoxToreZaxe->setValue(1.);
287 SpinBoxToreZaxe->setSingleStep(0.1);
288 // . Rayon de revolution
289 SpinBoxToreRRev->setValue(_Rayon);
290 SpinBoxToreRRev->setSingleStep(_Rayon/10.);
292 SpinBoxToreRPri->setValue(_Rayon/3.);
293 SpinBoxToreRPri->setSingleStep(_Rayon/20.);
295 // ------------------------------------------------------------------------
296 bool SMESH_CreateBoundaryAn::PushOnApply()
297 // ------------------------------------------------------------------------
298 // Appele lorsque l'un des boutons Ok ou Apply est presse
301 if (LEName->text().trimmed()=="")
303 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
304 QObject::tr("HOM_BOUN_NAME") );
310 case 1 : // il s agit d un cylindre
312 if ((_BoundaryAnXcentre != SpinBox_Xcent->value()) ||
313 (_BoundaryAnYcentre != SpinBox_Ycent->value()) ||
314 (_BoundaryAnZcentre != SpinBox_Zcent->value()) ||
315 (_BoundaryAnRayon != SpinBox_Radius->value()) ||
316 (_BoundaryAnXaxis != SpinBox_Xaxis->value()) ||
317 (_BoundaryAnYaxis != SpinBox_Yaxis->value()) ||
318 (_BoundaryAnZaxis != SpinBox_Zaxis->value()) )
321 _BoundaryAnXaxis= SpinBox_Xaxis->value();
322 _BoundaryAnYaxis= SpinBox_Yaxis->value();
323 _BoundaryAnZaxis= SpinBox_Zaxis->value();
324 _BoundaryAnXcentre=SpinBox_Xcent->value();
325 _BoundaryAnYcentre=SpinBox_Ycent->value();
326 _BoundaryAnZcentre=SpinBox_Zcent->value();
327 _BoundaryAnRayon=SpinBox_Radius->value();
332 case 2 : // il s agit d une sphere
334 if ((_BoundaryAnXcentre != SpinBox_Xcentre->value()) ||
335 (_BoundaryAnYcentre != SpinBox_Ycentre->value()) ||
336 (_BoundaryAnZcentre != SpinBox_Zcentre->value()) ||
337 (_BoundaryAnRayon != SpinBox_Rayon->value()) )
340 _BoundaryAnXcentre=SpinBox_Xcentre->value();
341 _BoundaryAnYcentre=SpinBox_Ycentre->value();
342 _BoundaryAnZcentre=SpinBox_Zcentre->value();
343 _BoundaryAnRayon=SpinBox_Rayon->value();
348 case 3 : // il s agit d un cone defini par un axe et un angle
350 if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value()) ||
351 (_BoundaryAnYaxisCone != SpinBox_Cone_Y1->value()) ||
352 (_BoundaryAnZaxisCone != SpinBox_Cone_Z1->value()) ||
353 (_BoundaryAnXorigCone != SpinBox_Cone_X2->value()) ||
354 (_BoundaryAnYorigCone != SpinBox_Cone_Y2->value()) ||
355 (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value()) ||
356 (_BoundaryAngle != SpinBox_Cone_V1->value()) )
359 _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ;
360 _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ;
361 _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ;
362 _BoundaryAnXorigCone = SpinBox_Cone_X2->value() ;
363 _BoundaryAnYorigCone = SpinBox_Cone_Y2->value() ;
364 _BoundaryAnZorigCone = SpinBox_Cone_Z2->value() ;
365 _BoundaryAngle = SpinBox_Cone_V1->value() ;
370 case 4 : // il s agit d un cone defini par les 2 rayons
372 if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value()) ||
373 (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value()) ||
374 (_BoundaryAnZcone1 != SpinBox_Cone_Z1->value()) ||
375 (_BoundaryAnRayon1 != SpinBox_Cone_V1->value()) ||
376 (_BoundaryAnXcone2 != SpinBox_Cone_X2->value()) ||
377 (_BoundaryAnYcone2 != SpinBox_Cone_Y2->value()) ||
378 (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value()) ||
379 (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) )
382 _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ;
383 _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ;
384 _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ;
385 _BoundaryAnRayon1 = SpinBox_Cone_V1->value() ;
386 _BoundaryAnXcone2 = SpinBox_Cone_X2->value() ;
387 _BoundaryAnYcone2 = SpinBox_Cone_Y2->value() ;
388 _BoundaryAnZcone2 = SpinBox_Cone_Z2->value() ;
389 _BoundaryAnRayon2 = SpinBox_Cone_V2->value() ;
393 case 5 : // il s agit d un tore
395 if ((_BoundaryAnToreXcentre != SpinBoxToreXcent->value()) ||
396 (_BoundaryAnToreYcentre != SpinBoxToreYcent->value()) ||
397 (_BoundaryAnToreZcentre != SpinBoxToreZcent->value()) ||
398 (_BoundaryAnToreRRev != SpinBoxToreRRev->value()) ||
399 (_BoundaryAnToreRPri != SpinBoxToreRPri->value()) ||
400 (_BoundaryAnToreXaxe != SpinBoxToreXaxe->value()) ||
401 (_BoundaryAnToreYaxe != SpinBoxToreYaxe->value()) ||
402 (_BoundaryAnToreZaxe != SpinBoxToreZaxe->value()) )
405 _BoundaryAnToreXcentre= SpinBoxToreXcent->value();
406 _BoundaryAnToreYcentre= SpinBoxToreYcent->value();
407 _BoundaryAnToreZcentre= SpinBoxToreZcent->value();
408 _BoundaryAnToreRRev=SpinBoxToreRRev->value();
409 _BoundaryAnToreRPri=SpinBoxToreRPri->value();
410 _BoundaryAnToreXaxe=SpinBoxToreXaxe->value();
411 _BoundaryAnToreYaxe=SpinBoxToreYaxe->value();
412 _BoundaryAnToreZaxe=SpinBoxToreZaxe->value();
420 // L'axe pour un cylindre
423 double daux = _BoundaryAnXaxis*_BoundaryAnXaxis + _BoundaryAnYaxis*_BoundaryAnYaxis + _BoundaryAnZaxis*_BoundaryAnZaxis ;
424 if ( daux < 0.0000001 )
426 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
427 QObject::tr("HOM_AXE") );
433 // Création ou mise à jour de la frontière
435 bool bOK = CreateOrUpdateBoundaryAn();
437 //if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; }
442 // ---------------------------------------------------
443 bool SMESH_CreateBoundaryAn::CreateOrUpdateBoundaryAn()
444 //----------------------------------------------------
445 // Creation de l'objet boundary
447 MESSAGE("Debut de CreateOrUpdateBoundaryAn avec _Type ="<<_Type<<", _Name ="<<_Name.toStdString().c_str()<<" et LEName ="<<LEName->text().trimmed().toStdString().c_str());
449 if (_Name != LEName->text().trimmed())
451 _Name = LEName->text().trimmed() ;
456 case 1 : // il s agit d un cylindre
457 { aBoundaryAn = myHomardGen->CreateBoundaryCylinder(CORBA::string_dup(_Name.toStdString().c_str()), \
458 _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
461 case 2 : // il s agit d une sphere
462 { aBoundaryAn = myHomardGen->CreateBoundarySphere(CORBA::string_dup(_Name.toStdString().c_str()), \
463 _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
466 case 3 : // il s agit d un cone defini par un axe et un angle
467 { aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_Name.toStdString().c_str()), \
468 _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
469 _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
472 case 4 : // il s agit d un cone defini par les 2 rayons
473 { aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_Name.toStdString().c_str()), \
474 _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
475 _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
478 case 5 : // il s agit d un tore
479 { aBoundaryAn = myHomardGen->CreateBoundaryTorus(CORBA::string_dup(_Name.toStdString().c_str()), \
480 _BoundaryAnToreXcentre, _BoundaryAnToreYcentre, _BoundaryAnToreZcentre, _BoundaryAnToreXaxe, _BoundaryAnToreYaxe, _BoundaryAnToreZaxe, _BoundaryAnToreRRev, _BoundaryAnToreRPri );
485 catch( SALOME::SALOME_Exception& S_ex )
487 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
488 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
491 _parent->AddBoundaryAn(_Name);
496 QMessageBox::warning( 0, QObject::tr("HOM_WARNING"),
497 QObject::tr("HOM_SELECT_OBJECT_4") );
500 MESSAGE("Fin de CreateOrUpdateBoundaryAn");
502 // ------------------------------------------------------------------------
503 void SMESH_CreateBoundaryAn::PushOnOK()
504 // ------------------------------------------------------------------------
506 if (PushOnApply()) this->close();
508 // ------------------------------------------------------------------------
509 void SMESH_CreateBoundaryAn::PushOnHelp()
510 // ------------------------------------------------------------------------
512 SMESH::ShowHelpFile(QString("homard_create_boundary.html#analytical-boundary"));
515 // -----------------------------------
516 void SMESH_CreateBoundaryAn::SetNewName()
517 // -----------------------------------
519 // Recherche d'un nom par defaut qui n'existe pas encore
521 SMESHHOMARD::listeBoundarys_var MyObjects = myHomardGen->GetAllBoundarysName();
522 int num = 0; QString aName="";
525 aName.setNum(num+1) ;
526 aName.insert(0, QString("Boun_")) ;
527 for ( int i=0; i<MyObjects->length(); i++)
529 if ( aName == QString(MyObjects[i]))
537 LEName->setText(aName);
539 // ------------------------------------------------------------------------
540 void SMESH_CreateBoundaryAn::SetCylinder()
541 // ------------------------------------------------------------------------
543 MESSAGE("Debut de SetCylinder")
544 gBCylindre->setVisible(1);
545 gBSphere->setVisible(0);
546 gBCone->setVisible(0);
547 gBTore->setVisible(0);
552 // MESSAGE("Fin de SetCylinder")
554 // ------------------------------------------------------------------------
555 void SMESH_CreateBoundaryAn::SetSphere()
556 // ------------------------------------------------------------------------
558 MESSAGE("Debut de SetSphere")
559 gBCylindre->setVisible(0);
560 gBSphere->setVisible(1);
561 gBCone->setVisible(0);
562 gBTore->setVisible(0);
567 // MESSAGE("Fin de SetSphere")
569 // ------------------------------------------------------------------------
570 void SMESH_CreateBoundaryAn::SetConeR()
571 // ------------------------------------------------------------------------
573 MESSAGE("Debut de SetConeR")
575 // Stockage et conversion des valeurs si elles ont change
576 if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value()) ||
577 (_BoundaryAnYaxisCone != SpinBox_Cone_Y1->value()) ||
578 (_BoundaryAnZaxisCone != SpinBox_Cone_Z1->value()) ||
579 (_BoundaryAnXorigCone != SpinBox_Cone_X2->value()) ||
580 (_BoundaryAnYorigCone != SpinBox_Cone_Y2->value()) ||
581 (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value()) ||
582 (_BoundaryAngle != SpinBox_Cone_V1->value()) )
584 MESSAGE("Stockage et conversion")
585 _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ;
586 _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ;
587 _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ;
588 _BoundaryAnXorigCone = SpinBox_Cone_X2->value() ;
589 _BoundaryAnYorigCone = SpinBox_Cone_Y2->value() ;
590 _BoundaryAnZorigCone = SpinBox_Cone_Z2->value() ;
591 _BoundaryAngle = SpinBox_Cone_V1->value() ;
592 convertRayonAngle(-1) ;
597 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0));
598 SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
599 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0));
600 SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
601 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0));
602 SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
604 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0));
605 SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
606 SpinBox_Cone_V1->setMaximum(100000.*_DMax);
607 SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
609 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0));
610 SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
611 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0));
612 SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
613 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0));
614 SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
616 TLCone_V2->setVisible(1);
617 SpinBox_Cone_V2->setVisible(1);
618 TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0));
619 SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
621 // MESSAGE("Fin de SetConeR")
623 // ------------------------------------------------------------------------
624 void SMESH_CreateBoundaryAn::SetConeA()
625 // ------------------------------------------------------------------------
627 MESSAGE("Debut de SetConeA")
628 // Stockage et conversion des valeurs si elles ont change
629 if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value()) ||
630 (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value()) ||
631 (_BoundaryAnZcone1 != SpinBox_Cone_Z1->value()) ||
632 (_BoundaryAnRayon1 != SpinBox_Cone_V1->value()) ||
633 (_BoundaryAnXcone2 != SpinBox_Cone_X2->value()) ||
634 (_BoundaryAnYcone2 != SpinBox_Cone_Y2->value()) ||
635 (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value()) ||
636 (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) )
638 MESSAGE("Stockage et conversion")
639 _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ;
640 _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ;
641 _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ;
642 _BoundaryAnRayon1 = SpinBox_Cone_V1->value() ;
643 _BoundaryAnXcone2 = SpinBox_Cone_X2->value() ;
644 _BoundaryAnYcone2 = SpinBox_Cone_Y2->value() ;
645 _BoundaryAnZcone2 = SpinBox_Cone_Z2->value() ;
646 _BoundaryAnRayon2 = SpinBox_Cone_V2->value() ;
647 convertRayonAngle(1) ;
652 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0));
653 SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
654 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0));
655 SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
656 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0));
657 SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
659 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0));
660 SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
661 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0));
662 SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
663 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0));
664 SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
666 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0));
667 SpinBox_Cone_V1->setValue(_BoundaryAngle);
668 SpinBox_Cone_V1->setSingleStep(1.);
669 SpinBox_Cone_V1->setMaximum(90.);
671 TLCone_V2->setVisible(0);
672 SpinBox_Cone_V2->setVisible(0);
673 // MESSAGE("Fin de SetConeA")
677 // ------------------------------------------------------------------------
678 void SMESH_CreateBoundaryAn::SetCone()
679 // ------------------------------------------------------------------------
681 MESSAGE("Debut de SetCone")
682 gBCylindre->setVisible(0);
683 gBSphere->setVisible(0);
684 gBCone->setVisible(1);
685 gBTore->setVisible(0);
687 if ( RB_Def_radius->isChecked() )
697 // MESSAGE("Fin de SetCone")
699 // ------------------------------------------------------------------------
700 void SMESH_CreateBoundaryAn::SetTore()
701 // ------------------------------------------------------------------------
703 MESSAGE("Debut de SetTore")
704 gBCylindre->setVisible(0);
705 gBSphere->setVisible(0);
706 gBCone->setVisible(0);
707 gBTore->setVisible(1);
712 // MESSAGE("Fin de SetTore")
714 // ------------------------------------------------------------------------
715 void SMESH_CreateBoundaryAn::convertRayonAngle(int option)
716 // ------------------------------------------------------------------------
717 // Conversion entre les deux formulations du cone :
718 // par deux rayons ou avec un axe et un angle.
719 // Voir sfcoi1 de HOMARD
721 MESSAGE("Debut de convertRayonAngle, option = "<<option)
730 // A----------------B----------O
732 // Thales : RA/RB = AO/BO ==> BO = AB*RB/(RA-RB)
733 // Angle : tg(alpha) = RA/AO
736 // De rayon vers angle :
739 double xa, ya, za, ra ;
740 double xb, yb, zb, rb ;
741 // Positionnement de A vers B, avec RA>RB
742 if ( _BoundaryAnRayon1 > _BoundaryAnRayon2 )
744 xa = _BoundaryAnXcone1 ;
745 ya = _BoundaryAnYcone1 ;
746 za = _BoundaryAnZcone1 ;
747 ra = _BoundaryAnRayon1 ;
748 xb = _BoundaryAnXcone2 ;
749 yb = _BoundaryAnYcone2 ;
750 zb = _BoundaryAnZcone2 ;
751 rb = _BoundaryAnRayon2 ;
755 xa = _BoundaryAnXcone2 ;
756 ya = _BoundaryAnYcone2 ;
757 za = _BoundaryAnZcone2 ;
758 ra = _BoundaryAnRayon2 ;
759 xb = _BoundaryAnXcone1 ;
760 yb = _BoundaryAnYcone1 ;
761 zb = _BoundaryAnZcone1 ;
762 rb = _BoundaryAnRayon1 ;
764 // Axe : relie les deux centres, de A vers B. L'axe est normalise
765 _BoundaryAnXaxisCone = xb - xa ;
766 _BoundaryAnYaxisCone = yb - ya ;
767 _BoundaryAnZaxisCone = zb - za ;
768 daux = sqrt ( _BoundaryAnXaxisCone*_BoundaryAnXaxisCone + _BoundaryAnYaxisCone*_BoundaryAnYaxisCone + _BoundaryAnZaxisCone*_BoundaryAnZaxisCone ) ;
769 _BoundaryAnXaxisCone = _BoundaryAnXaxisCone/daux ;
770 _BoundaryAnYaxisCone = _BoundaryAnYaxisCone/daux ;
771 _BoundaryAnZaxisCone = _BoundaryAnZaxisCone/daux ;
773 daux = daux * rb / (ra-rb) ;
774 _BoundaryAnXorigCone = xb + daux*_BoundaryAnXaxisCone ;
775 _BoundaryAnYorigCone = yb + daux*_BoundaryAnYaxisCone ;
776 _BoundaryAnZorigCone = zb + daux*_BoundaryAnZaxisCone ;
778 daux = ra / sqrt((_BoundaryAnXorigCone-xa)*(_BoundaryAnXorigCone-xa) + (_BoundaryAnYorigCone-ya)*(_BoundaryAnYorigCone-ya) + (_BoundaryAnZorigCone-za)*(_BoundaryAnZorigCone-za) ) ;
779 _BoundaryAngle = atan(daux)*180./PI ;
781 // D'angle vers rayon :
784 double xax, yax, zax ;
785 // L'axe est normalise
786 daux = sqrt ( _BoundaryAnXaxisCone*_BoundaryAnXaxisCone + _BoundaryAnYaxisCone*_BoundaryAnYaxisCone + _BoundaryAnZaxisCone*_BoundaryAnZaxisCone ) ;
787 xax = _BoundaryAnXaxisCone/daux ;
788 yax = _BoundaryAnYaxisCone/daux ;
789 zax = _BoundaryAnZaxisCone/daux ;
790 // Centre 1 : l'origine
791 _BoundaryAnXcone1 = _BoundaryAnXorigCone ;
792 _BoundaryAnYcone1 = _BoundaryAnYorigCone ;
793 _BoundaryAnZcone1 = _BoundaryAnZorigCone ;
795 _BoundaryAnRayon1 = 0. ;
796 // Centre 2 : l'origine decalee d'une longueur arbitraire le long de l'axe
797 _BoundaryAnXcone2 = _BoundaryAnXorigCone + _DMax*xax ;
798 _BoundaryAnYcone2 = _BoundaryAnYorigCone + _DMax*yax ;
799 _BoundaryAnZcone2 = _BoundaryAnZorigCone + _DMax*zax ;
800 // Rayon 2 : a calculer
801 _BoundaryAnRayon2 = _DMax*tan(_BoundaryAngle*PI/180.) ;
803 // MESSAGE("Fin de convertRayonAngle")
806 // -------------------------------------------------------------------------------
807 SMESH_CreateBoundaryCAO::SMESH_CreateBoundaryCAO(SMESHGUI_HomardAdaptDlg* parent, bool modal,
808 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
809 QString caseName, QString aName)
810 // ---------------------------------------------------------------------------------
811 /* Constructs a SMESH_CreateBoundaryCAO */
813 QDialog(0), SMESH_Ui_CreateBoundaryCAO(),
814 _parent(parent), _aName(aName),
815 myHomardGen(SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0))
817 MESSAGE("Constructeur") ;
822 if ( _aName == QString("") ) {SetNewName();};
825 // ------------------------------------------------------------------------
826 SMESH_CreateBoundaryCAO::~SMESH_CreateBoundaryCAO()
827 // ------------------------------------------------------------------------
829 // no need to delete child widgets, Qt does it all for us
831 // ------------------------------------------------------------------------
832 void SMESH_CreateBoundaryCAO::InitConnect()
833 // ------------------------------------------------------------------------
835 connect( PushFichier, SIGNAL(pressed()), this, SLOT(SetCAOFile()));
836 connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK()));
837 connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply()));
838 connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
839 connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp()));
840 connect( CBGroupe, SIGNAL(stateChanged(int)), this, SLOT( SetFiltrage()));
843 // ------------------------------------------------------------------------
844 bool SMESH_CreateBoundaryCAO::PushOnApply()
845 // ------------------------------------------------------------------------
846 // Appele lorsque l'un des boutons Ok ou Apply est presse
851 QString aName=LEName->text().trimmed();
853 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
854 QObject::tr("HOM_BOUN_NAME") );
859 QString aCAOFile=LEFileName->text().trimmed();
860 if (aCAOFile ==QString(""))
862 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
863 QObject::tr("HOM_BOUN_CAO") );
867 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
868 if ( _aName != aName )
873 aBoundary=myHomardGen->CreateBoundaryCAO(CORBA::string_dup(_aName.toStdString().c_str()), aCAOFile.toStdString().c_str());
874 _parent->AddBoundaryCAO(_aName);
875 aBoundary->SetCaseCreation("Case_1");
877 catch( SALOME::SALOME_Exception& S_ex )
879 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
880 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
888 //HOMARD_UTILS::updateObjBrowser();
893 // ------------------------------------------------------------------------
894 void SMESH_CreateBoundaryCAO::PushOnOK()
895 // ------------------------------------------------------------------------
897 if (PushOnApply()) this->close();
898 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
900 // ------------------------------------------------------------------------
901 void SMESH_CreateBoundaryCAO::PushOnHelp()
902 // ------------------------------------------------------------------------
904 SMESH::ShowHelpFile(QString("homard_create_boundary.html#cao-boundary"));
906 // ------------------------------------------------------------------------
907 void SMESH_CreateBoundaryCAO::AssocieLesGroupes()
908 // ------------------------------------------------------------------------
910 SMESHHOMARD::ListGroupType_var aSeqGroupe = new SMESHHOMARD::ListGroupType;
911 aSeqGroupe->length(_listeGroupesBoundary.size());
912 QStringList::const_iterator it;
914 for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++)
915 aSeqGroupe[i++]=(*it).toStdString().c_str();
916 aBoundary->SetGroups(aSeqGroupe);
920 // -------------------------------------------------
921 void SMESH_CreateBoundaryCAO::SetNewName()
922 // --------------------------------------------------
925 SMESHHOMARD::listeBoundarys_var MyObjects = myHomardGen->GetAllBoundarysName();
926 int num = 0; QString aName="";
927 while (aName == QString("") )
929 aName.setNum(num+1) ;
930 aName.insert(0, QString("Boun_")) ;
931 for ( int i=0; i<MyObjects->length(); i++)
933 if ( aName == QString(MyObjects[i]))
941 LEName->setText(aName);
943 // ------------------------------------------------------------------------
944 void SMESH_CreateBoundaryCAO::SetCAOFile()
945 // ------------------------------------------------------------------------
947 QString aCAOFile = SMESH_HOMARD_QT_COMMUN::PushNomFichier( false, QString("xao") );
948 if (!(aCAOFile.isEmpty())) LEFileName->setText(aCAOFile);
951 // ------------------------------------------------------------------------
952 void SMESH_CreateBoundaryCAO::setGroups (QStringList listGroup)
953 // ------------------------------------------------------------------------
955 _listeGroupesBoundary = listGroup;
957 // ------------------------------------------------------------------------
958 void SMESH_CreateBoundaryCAO::SetFiltrage()
959 // ------------------------------------------------------------------------
961 if (!CBGroupe->isChecked()) return;
963 SMESH_CreateListGroupCAO *aDlg = new SMESH_CreateListGroupCAO
964 (this, true, SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen),
965 "Case_1", _listeGroupesBoundary);
969 // -------------------------------------------------------------------------------
970 SMESH_CreateBoundaryDi::SMESH_CreateBoundaryDi(SMESHGUI_HomardAdaptDlg* parent, bool modal,
971 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
972 QString caseName, QString aName)
973 // ---------------------------------------------------------------------------------
974 /* Constructs a SMESH_CreateBoundaryDi */
976 QDialog(0), SMESH_Ui_CreateBoundaryDi(),
977 _parent(parent), _aName(aName),
978 myHomardGen(SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0))
980 MESSAGE("Constructeur") ;
985 if ( _aName == QString("") ) {SetNewName();};
988 // ------------------------------------------------------------------------
989 SMESH_CreateBoundaryDi::~SMESH_CreateBoundaryDi()
990 // ------------------------------------------------------------------------
992 // no need to delete child widgets, Qt does it all for us
994 // ------------------------------------------------------------------------
995 void SMESH_CreateBoundaryDi::InitConnect()
996 // ------------------------------------------------------------------------
998 connect( PushFichier, SIGNAL(pressed()), this, SLOT(SetMeshFile()));
999 connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK()));
1000 connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply()));
1001 connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
1002 connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp()));
1003 connect( CBGroupe, SIGNAL(stateChanged(int)), this, SLOT( SetFiltrage()));
1006 // ------------------------------------------------------------------------
1007 bool SMESH_CreateBoundaryDi::PushOnApply()
1008 // ------------------------------------------------------------------------
1009 // Appele lorsque l'un des boutons Ok ou Apply est presse
1014 QString aName=LEName->text().trimmed();
1016 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1017 QObject::tr("HOM_BOUN_NAME") );
1021 // Le maillage de la frontiere discrete
1022 QString aMeshFile=LEFileName->text().trimmed();
1023 if (aMeshFile ==QString(""))
1025 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1026 QObject::tr("HOM_BOUN_MESH") );
1030 // Le nom du maillage de la frontiere discrete
1031 QString aMeshName = SMESH_HOMARD_QT_COMMUN::LireNomMaillage(aMeshFile);
1032 if (aMeshName == "" )
1034 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1035 QObject::tr("HOM_MED_FILE_2") );
1039 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
1040 if ( _aName != aName )
1045 aBoundary=myHomardGen->CreateBoundaryDi(CORBA::string_dup(_aName.toStdString().c_str()), aMeshName.toStdString().c_str(), aMeshFile.toStdString().c_str());
1046 _parent->AddBoundaryDi(_aName);
1047 aBoundary->SetCaseCreation("Case_1");
1049 catch( SALOME::SALOME_Exception& S_ex )
1051 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1052 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
1058 AssocieLesGroupes();
1060 //HOMARD_UTILS::updateObjBrowser();
1065 // ------------------------------------------------------------------------
1066 void SMESH_CreateBoundaryDi::PushOnOK()
1067 // ------------------------------------------------------------------------
1069 if (PushOnApply()) this->close();
1070 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
1072 // ------------------------------------------------------------------------
1073 void SMESH_CreateBoundaryDi::PushOnHelp()
1074 // ------------------------------------------------------------------------
1076 SMESH::ShowHelpFile(QString("homard_create_boundary.html#discrete-boundary"));
1078 // ------------------------------------------------------------------------
1079 void SMESH_CreateBoundaryDi::AssocieLesGroupes()
1080 // ------------------------------------------------------------------------
1082 SMESHHOMARD::ListGroupType_var aSeqGroupe = new SMESHHOMARD::ListGroupType;
1083 aSeqGroupe->length(_listeGroupesBoundary.size());
1084 QStringList::const_iterator it;
1086 for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++)
1087 aSeqGroupe[i++]=(*it).toStdString().c_str();
1088 aBoundary->SetGroups(aSeqGroupe);
1092 // -------------------------------------------------
1093 void SMESH_CreateBoundaryDi::SetNewName()
1094 // --------------------------------------------------
1097 SMESHHOMARD::listeBoundarys_var MyObjects = myHomardGen->GetAllBoundarysName();
1098 int num = 0; QString aName="";
1099 while (aName == QString("") )
1101 aName.setNum(num+1) ;
1102 aName.insert(0, QString("Boun_")) ;
1103 for ( int i=0; i<MyObjects->length(); i++)
1105 if ( aName == QString(MyObjects[i]))
1113 LEName->setText(aName);
1115 // ------------------------------------------------------------------------
1116 void SMESH_CreateBoundaryDi::SetMeshFile()
1117 // ------------------------------------------------------------------------
1119 QString aMeshFile = SMESH_HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") );
1120 if (!(aMeshFile.isEmpty())) LEFileName->setText(aMeshFile);
1123 // ------------------------------------------------------------------------
1124 void SMESH_CreateBoundaryDi::setGroups (QStringList listGroup)
1125 // ------------------------------------------------------------------------
1127 _listeGroupesBoundary = listGroup;
1129 // ------------------------------------------------------------------------
1130 void SMESH_CreateBoundaryDi::SetFiltrage()
1131 // // ------------------------------------------------------------------------
1133 if (!CBGroupe->isChecked()) return;
1135 SMESH_CreateListGroup *aDlg = new SMESH_CreateListGroup
1136 (this, true, SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen),
1137 "Case_1", _listeGroupesBoundary);
1141 // ------------------------------------------------------------------------
1142 SMESH_EditBoundaryAn::SMESH_EditBoundaryAn( SMESHGUI_HomardAdaptDlg* parent, bool modal,
1143 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
1144 QString caseName, QString Name ):
1145 // ------------------------------------------------------------------------
1146 /* Constructs a SMESH_EditBoundaryAn
1147 herite de SMESH_CreateBoundaryAn
1149 SMESH_CreateBoundaryAn(parent, myHomardGen0, caseName)
1151 MESSAGE("Debut de SMESH_EditBoundaryAn pour " << Name.toStdString().c_str());
1152 setWindowTitle(QObject::tr("HOM_BOUN_A_EDIT_WINDOW_TITLE"));
1154 aBoundaryAn = myHomardGen->GetBoundary(_Name.toStdString().c_str());
1157 // ------------------------------------------------------------------------
1158 SMESH_EditBoundaryAn::~SMESH_EditBoundaryAn()
1159 // ------------------------------------------------------------------------
1161 // no need to delete child widgets, Qt does it all for us
1163 // ------------------------------------------------------------------------
1164 void SMESH_EditBoundaryAn::InitValEdit()
1165 // ------------------------------------------------------------------------
1167 LEName->setText(_Name);
1168 LEName->setReadOnly(true);
1169 _Type = aBoundaryAn->GetType();
1170 MESSAGE("_Type : "<<_Type);
1171 InitValBoundaryAnLimit();
1172 InitValBoundaryAn();
1175 case 1 : // il s agit d un cylindre
1177 InitValBoundaryAnCylindre();
1181 case 2: // il s agit d une sphere
1183 InitValBoundaryAnSphere();
1187 case 3: // il s agit d un cone defini par un axe et un angle
1189 InitValBoundaryAnConeA();
1193 case 4: // il s agit d un cone defini par les 2 rayons
1195 InitValBoundaryAnConeR();
1199 case 5: // il s agit d un tore
1201 InitValBoundaryAnTore();
1207 // ------------------------------------------------------------------------
1208 void SMESH_EditBoundaryAn::InitValBoundaryAnLimit()
1209 // ------------------------------------------------------------------------
1211 SMESHHOMARD::double_array_var mesCoordLimits = aBoundaryAn->GetLimit();
1212 ASSERT(mesCoordLimits->length() == 3 );
1213 _Xincr=mesCoordLimits[0];
1214 _Yincr=mesCoordLimits[1];
1215 _Zincr=mesCoordLimits[2];
1217 // ------------------------------------------------------------------------
1218 void SMESH_EditBoundaryAn::InitValBoundaryAnCylindre()
1219 // ------------------------------------------------------------------------
1221 SMESHHOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
1222 ASSERT(mesCoordBoundary->length() == 7 );
1223 _BoundaryAnXcentre=mesCoordBoundary[0];
1224 _BoundaryAnYcentre=mesCoordBoundary[1];
1225 _BoundaryAnZcentre=mesCoordBoundary[2];
1226 _BoundaryAnXaxis=mesCoordBoundary[3];
1227 _BoundaryAnYaxis=mesCoordBoundary[4];
1228 _BoundaryAnZaxis=mesCoordBoundary[5];
1229 _BoundaryAnRayon=mesCoordBoundary[6];
1231 // ------------------------------------------------------------------------
1232 void SMESH_EditBoundaryAn::InitValBoundaryAnSphere()
1233 // ------------------------------------------------------------------------
1235 SMESHHOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
1236 ASSERT(mesCoordBoundary->length() == 4 );
1237 _BoundaryAnXcentre=mesCoordBoundary[0];
1238 _BoundaryAnYcentre=mesCoordBoundary[1];
1239 _BoundaryAnZcentre=mesCoordBoundary[2];
1240 _BoundaryAnRayon=mesCoordBoundary[3];
1242 // ------------------------------------------------------------------------
1243 void SMESH_EditBoundaryAn::InitValBoundaryAnConeA()
1244 // ------------------------------------------------------------------------
1246 SMESHHOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
1247 ASSERT(mesCoordBoundary->length() == 7 );
1248 _BoundaryAnXaxisCone=mesCoordBoundary[0];
1249 _BoundaryAnYaxisCone=mesCoordBoundary[1];
1250 _BoundaryAnZaxisCone=mesCoordBoundary[2];
1251 _BoundaryAngle=mesCoordBoundary[3];
1252 _BoundaryAnXorigCone=mesCoordBoundary[4];
1253 _BoundaryAnYorigCone=mesCoordBoundary[5];
1254 _BoundaryAnZorigCone=mesCoordBoundary[6];
1255 convertRayonAngle(-1) ;
1257 // ------------------------------------------------------------------------
1258 void SMESH_EditBoundaryAn::InitValBoundaryAnConeR()
1259 // ------------------------------------------------------------------------
1261 SMESHHOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
1262 ASSERT(mesCoordBoundary->length() == 8 );
1263 _BoundaryAnXcone1=mesCoordBoundary[0];
1264 _BoundaryAnYcone1=mesCoordBoundary[1];
1265 _BoundaryAnZcone1=mesCoordBoundary[2];
1266 _BoundaryAnRayon1=mesCoordBoundary[3];
1267 _BoundaryAnXcone2=mesCoordBoundary[4];
1268 _BoundaryAnYcone2=mesCoordBoundary[5];
1269 _BoundaryAnZcone2=mesCoordBoundary[6];
1270 _BoundaryAnRayon2=mesCoordBoundary[7];
1271 convertRayonAngle(1) ;
1273 // ------------------------------------------------------------------------
1274 void SMESH_EditBoundaryAn::InitValBoundaryAnTore()
1275 // ------------------------------------------------------------------------
1277 SMESHHOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
1278 ASSERT(mesCoordBoundary->length() == 8 );
1279 _BoundaryAnXcentre=mesCoordBoundary[0];
1280 _BoundaryAnYcentre=mesCoordBoundary[1];
1281 _BoundaryAnZcentre=mesCoordBoundary[2];
1282 _BoundaryAnXaxis=mesCoordBoundary[3];
1283 _BoundaryAnYaxis=mesCoordBoundary[4];
1284 _BoundaryAnZaxis=mesCoordBoundary[5];
1285 _BoundaryAnRayon1=mesCoordBoundary[6];
1286 _BoundaryAnRayon2=mesCoordBoundary[7];
1288 // ------------------------------------------------------------------------
1289 void SMESH_EditBoundaryAn::SetCylinder()
1290 // ------------------------------------------------------------------------
1292 gBCylindre->setVisible(1);
1293 gBSphere->setVisible(0);
1294 gBCone->setVisible(0);
1295 gBTore->setVisible(0);
1296 RBCylindre->setChecked(1);
1298 RBSphere->setDisabled(true);
1299 RBCone->setDisabled(true);
1300 RBTore->setDisabled(true);
1302 SpinBox_Xcent->setValue(_BoundaryAnXcentre);
1303 SpinBox_Ycent->setValue(_BoundaryAnYcentre);
1304 SpinBox_Zcent->setValue(_BoundaryAnZcentre);
1306 SpinBox_Xaxis->setValue(_BoundaryAnXaxis);
1307 SpinBox_Yaxis->setValue(_BoundaryAnYaxis);
1308 SpinBox_Zaxis->setValue(_BoundaryAnZaxis);
1311 SpinBox_Xaxis->setSingleStep(0.1);
1312 SpinBox_Xcentre->setSingleStep(_Xincr);
1313 SpinBox_Yaxis->setSingleStep(0.1);
1314 SpinBox_Ycentre->setSingleStep(_Yincr);
1315 SpinBox_Zaxis->setSingleStep(0.1);
1316 SpinBox_Zcentre->setSingleStep(_Zincr);
1318 SpinBox_Radius->setValue(_BoundaryAnRayon);
1319 SpinBox_Radius->setSingleStep(_BoundaryAnRayon/10.);
1323 // ------------------------------------------------------------------------
1324 void SMESH_EditBoundaryAn::SetSphere()
1325 // ------------------------------------------------------------------------
1327 gBCylindre->setVisible(0);
1328 gBSphere->setVisible(1);
1329 RBSphere->setChecked(1);
1330 gBCone->setVisible(0);
1331 gBTore->setVisible(0);
1332 RBCylindre->setDisabled(true);
1333 RBCone->setDisabled(true);
1334 RBTore->setDisabled(true);
1337 SpinBox_Xcentre->setValue(_BoundaryAnXcentre);
1338 if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); }
1339 else { SpinBox_Xcentre->setSingleStep(1) ; }
1341 SpinBox_Ycentre->setValue(_BoundaryAnYcentre);
1342 if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); }
1343 else { SpinBox_Ycentre->setSingleStep(1) ; }
1345 SpinBox_Zcentre->setValue(_BoundaryAnZcentre);
1346 if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); }
1347 else { SpinBox_Zcentre->setSingleStep(1);}
1349 SpinBox_Rayon->setValue(_BoundaryAnRayon);
1353 // ------------------------------------------------------------------------
1354 void SMESH_EditBoundaryAn::SetConeA()
1355 // ------------------------------------------------------------------------
1357 gBCylindre->setVisible(0);
1358 gBSphere->setVisible(0);
1359 gBCone->setVisible(1);
1360 RBCone->setChecked(1);
1361 gBTore->setVisible(0);
1362 RB_Def_angle->setChecked(1);
1363 RBCylindre->setDisabled(true);
1364 RBSphere->setDisabled(true);
1365 RBTore->setDisabled(true);
1368 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0));
1369 SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
1370 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0));
1371 SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
1372 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0));
1373 SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
1375 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0));
1376 SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
1377 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0));
1378 SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
1379 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0));
1380 SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
1382 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0));
1383 SpinBox_Cone_V1->setValue(_BoundaryAngle);
1384 SpinBox_Cone_V1->setSingleStep(1.);
1385 SpinBox_Cone_V1->setMaximum(90.);
1387 TLCone_V2->setVisible(0);
1388 SpinBox_Cone_V2->setVisible(0);
1392 // ------------------------------------------------------------------------
1393 void SMESH_EditBoundaryAn::SetConeR()
1394 // ------------------------------------------------------------------------
1396 gBCylindre->setVisible(0);
1397 gBSphere->setVisible(0);
1398 gBCone->setVisible(1);
1399 gBTore->setVisible(0);
1400 RBCone->setChecked(1);
1401 RB_Def_radius->setChecked(1);
1402 RBCylindre->setDisabled(true);
1403 RBSphere->setDisabled(true);
1404 RBTore->setDisabled(true);
1407 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0));
1408 SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
1409 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0));
1410 SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
1411 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0));
1412 SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
1414 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0));
1415 SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
1416 SpinBox_Cone_V1->setMaximum(100000.*_DMax);
1417 SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
1419 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0));
1420 SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
1421 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0));
1422 SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
1423 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0));
1424 SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
1426 TLCone_V2->setVisible(1);
1427 SpinBox_Cone_V2->setVisible(1);
1428 TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0));
1429 SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
1433 // ------------------------------------------------------------------------
1434 void SMESH_EditBoundaryAn::SetTore()
1435 // ------------------------------------------------------------------------
1437 gBCylindre->setVisible(0);
1438 gBSphere->setVisible(0);
1439 gBCone->setVisible(0);
1440 gBTore->setVisible(1);
1441 RBTore->setChecked(1);
1443 RBCylindre->setDisabled(true);
1444 RBSphere->setDisabled(true);
1445 RBCone->setDisabled(true);
1447 SpinBoxToreXcent->setValue(_BoundaryAnXcentre);
1448 SpinBoxToreYcent->setValue(_BoundaryAnYcentre);
1449 SpinBoxToreZcent->setValue(_BoundaryAnZcentre);
1451 SpinBoxToreXaxe->setValue(_BoundaryAnXaxis);
1452 SpinBoxToreYaxe->setValue(_BoundaryAnYaxis);
1453 SpinBoxToreZaxe->setValue(_BoundaryAnZaxis);
1456 SpinBoxToreXaxe->setSingleStep(0.1);
1457 SpinBoxToreXcent->setSingleStep(_Xincr);
1458 SpinBoxToreYaxe->setSingleStep(0.1);
1459 SpinBoxToreYcent->setSingleStep(_Yincr);
1460 SpinBoxToreZaxe->setSingleStep(0.1);
1461 SpinBoxToreZcent->setSingleStep(_Zincr);
1462 // Rayon de revolution
1463 SpinBoxToreRRev->setValue(_BoundaryAnRayon1);
1464 SpinBoxToreRRev->setSingleStep(_BoundaryAnRayon1/10.);
1466 SpinBoxToreRPri->setValue(_BoundaryAnRayon2);
1467 SpinBoxToreRPri->setSingleStep(_BoundaryAnRayon2/10.);
1471 // ---------------------------------------------------
1472 bool SMESH_EditBoundaryAn::CreateOrUpdateBoundaryAn()
1473 //----------------------------------------------------
1474 // Mise a jour des attributs de la BoundaryAn
1478 case 1 : // il s agit d un cylindre
1480 aBoundaryAn->SetCylinder(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
1483 case 2 : // il s agit d une sphere
1485 aBoundaryAn->SetSphere(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
1488 case 3 : // il s agit d un cone defini par un axe et un angle
1490 aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_Name.toStdString().c_str()), \
1491 _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
1492 _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
1495 case 4 : // il s agit d un cone defini par les 2 rayons
1497 aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_Name.toStdString().c_str()), \
1498 _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
1499 _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
1502 case 5 : // il s agit d un tore
1504 aBoundaryAn->SetTorus(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon1, _BoundaryAnRayon2 );
1508 if (Chgt) myHomardGen->InvalideBoundary(_Name.toStdString().c_str());
1509 //HOMARD_UTILS::updateObjBrowser();
1513 // --------------------------------------------------------------------------------------
1514 /* Constructs a SMESH_EditBoundaryCAO
1515 herite de SMESH_CreateBoundaryCAO
1517 // --------------------------------------------------------------------------------------
1518 SMESH_EditBoundaryCAO::SMESH_EditBoundaryCAO( SMESHGUI_HomardAdaptDlg* parent, bool modal,
1519 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
1520 QString caseName, QString Name):
1521 SMESH_CreateBoundaryCAO(parent, modal, myHomardGen0, caseName, Name)
1523 MESSAGE("Debut de Boundary pour " << Name.toStdString().c_str());
1524 setWindowTitle(QObject::tr("HOM_BOUN_C_EDIT_WINDOW_TITLE"));
1526 aBoundary = myHomardGen->GetBoundary(CORBA::string_dup(_aName.toStdString().c_str()));
1529 catch( SALOME::SALOME_Exception& S_ex ) {
1530 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1531 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
1535 SMESHHOMARD::ListGroupType_var maListe = aBoundary->GetGroups();
1536 for ( int i = 0; i < maListe->length(); i++ )
1537 _listeGroupesBoundary << QString(maListe[i]);
1540 // ------------------------------
1541 SMESH_EditBoundaryCAO::~SMESH_EditBoundaryCAO()
1542 // ------------------------------
1545 // ------------------------------
1546 void SMESH_EditBoundaryCAO::InitValEdit()
1547 // ------------------------------
1549 LEName->setText(_aName);
1550 LEName->setReadOnly(true);
1552 QString aDataFile = aBoundary->GetDataFile();
1553 LEFileName->setText(aDataFile);
1554 LEFileName->setReadOnly(1);
1555 PushFichier->setVisible(0);
1559 // ------------------------------
1560 bool SMESH_EditBoundaryCAO::PushOnApply()
1561 // ------------------------------
1565 // ------------------------------------------------------------------------
1566 void SMESH_EditBoundaryCAO::SetFiltrage()
1567 // ------------------------------------------------------------------------
1569 if (!CBGroupe->isChecked()) return;
1570 //SMESHHOMARD::HOMARD_Cas_var monCas = myHomardGen->GetCase();
1571 //SMESHHOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
1573 SMESH_EditListGroupCAO *aDlg = new SMESH_EditListGroupCAO
1574 (this, true, SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen),
1575 "Case_1", _listeGroupesBoundary) ;
1579 // ------------------------------------------------------------------------------------
1580 /* Constructs a SMESH_EditBoundaryDi
1581 herite de SMESH_CreateBoundaryDi
1583 // ------------------------------------------------------------------------------------
1584 SMESH_EditBoundaryDi::SMESH_EditBoundaryDi( SMESHGUI_HomardAdaptDlg* parent, bool modal,
1585 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
1586 QString caseName, QString Name):
1587 SMESH_CreateBoundaryDi(parent, modal, myHomardGen0, caseName, Name)
1589 MESSAGE("Debut de Boundary pour " << Name.toStdString().c_str());
1590 setWindowTitle(QObject::tr("HOM_BOUN_D_EDIT_WINDOW_TITLE"));
1592 aBoundary = myHomardGen->GetBoundary(CORBA::string_dup(_aName.toStdString().c_str()));
1595 catch( SALOME::SALOME_Exception& S_ex ) {
1596 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1597 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
1601 SMESHHOMARD::ListGroupType_var maListe = aBoundary->GetGroups();
1602 for ( int i = 0; i < maListe->length(); i++ )
1603 _listeGroupesBoundary << QString(maListe[i]);
1606 // ------------------------------
1607 SMESH_EditBoundaryDi::~SMESH_EditBoundaryDi()
1608 // ------------------------------
1611 // ------------------------------
1612 void SMESH_EditBoundaryDi::InitValEdit()
1613 // ------------------------------
1615 LEName->setText(_aName);
1616 LEName->setReadOnly(true);
1618 QString aDataFile = aBoundary->GetDataFile();
1619 LEFileName->setText(aDataFile);
1620 LEFileName->setReadOnly(1);
1621 PushFichier->setVisible(0);
1625 // ------------------------------
1626 bool SMESH_EditBoundaryDi::PushOnApply()
1627 // ------------------------------
1631 // ------------------------------------------------------------------------
1632 void SMESH_EditBoundaryDi::SetFiltrage()
1633 // // ------------------------------------------------------------------------
1635 if (!CBGroupe->isChecked()) return;
1636 SMESHHOMARD::HOMARD_Cas_var monCas = myHomardGen->GetCase();
1637 SMESHHOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
1639 SMESH_EditListGroup *aDlg = new SMESH_EditListGroup
1640 (this, true, SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen),
1641 "Case_1", _listeGroupesBoundary);