Salome HOME
Implement bos #26453: [EDF] (2021) SMESH: uniform refinement
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_HomardBoundaryDlg.cxx
1 // Copyright (C) 2011-2021  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "SMESHGUI_HomardBoundaryDlg.h"
21
22 #include "SMESHGUI_HomardAdaptDlg.h"
23 #include "SMESHGUI_HomardListGroup.h"
24
25 #include "SMESHGUI_Utils.h"
26
27 #include <QFileDialog>
28 #include <QMessageBox>
29
30 #include "SalomeApp_Tools.h"
31 #include "SMESHGUI_HomardUtils.h"
32 #include <utilities.h>
33
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>
39
40 #include "math.h"
41 #define PI 3.141592653589793
42
43 using namespace std;
44
45 // ----------------------------------------------------------------------------------
46 SMESH_CreateBoundaryAn::SMESH_CreateBoundaryAn(SMESHGUI_HomardAdaptDlg* parent, bool modal,
47                                          SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
48                                          QString caseName) :
49 /* Constructs a SMESH_CreateBoundaryAn
50    appele pour une vraie creation
51    initialise un cylindre et non une sphere
52 */
53     QDialog(0), SMESH_Ui_CreateBoundaryAn(),
54     _parent(parent),
55     _Name (""),
56     _aCaseName(caseName),
57     _Type(1),
58     _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0),
59     _BoundaryAnXaxis(0), _BoundaryAnYaxis(0), _BoundaryAnZaxis(0),
60     _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0),
61     _Xmin(0), _Xmax(0), _Xincr(0), _Ymin(0), _Ymax(0), _Yincr(0), _Zmin(0), _Zmax(0), _Zincr(0), _DMax(0),
62     _BoundaryAnXcone1(0), _BoundaryAnYcone1(0), _BoundaryAnZcone1(0), _BoundaryAnRayon1(0),
63     _BoundaryAnXcone2(0), _BoundaryAnYcone2(0), _BoundaryAnZcone2(0), _BoundaryAnRayon2(0),
64     _BoundaryAnXaxisCone(0), _BoundaryAnYaxisCone(0), _BoundaryAnZaxisCone(0),
65     _BoundaryAnXorigCone(0), _BoundaryAnYorigCone(0), _BoundaryAnZorigCone(0),
66     _BoundaryAngle(0),
67     _BoundaryAnToreXcentre(0), _BoundaryAnToreYcentre(0), _BoundaryAnToreZcentre(0),
68     _BoundaryAnToreXaxe(0), _BoundaryAnToreYaxe(0), _BoundaryAnToreZaxe(0),
69     _BoundaryAnToreRRev(0), _BoundaryAnToreRPri(0),
70     Chgt (false)
71     {
72       MESSAGE("Constructeur") ;
73       myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
74       setupUi(this);
75       setModal(modal);
76
77       // Gestion des icones
78       QPixmap pix ;
79       QIcon IS ;
80       SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
81       pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" );
82       IS=QIcon(pix);
83       RBSphere->setIcon(IS);
84       pix = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" );
85       IS=QIcon(pix);
86       RBCylindre->setIcon(IS);
87       pix = resMgr->loadPixmap( "HOMARD", "cone.png" );
88       IS=QIcon(pix);
89       RBCone->setIcon(IS);
90       pix = resMgr->loadPixmap( "HOMARD", "conepointvector.png" );
91       IS=QIcon(pix);
92       RB_Def_angle->setIcon(IS);
93       pix = resMgr->loadPixmap( "HOMARD", "conedxyz.png" );
94       IS=QIcon(pix);
95       RB_Def_radius->setIcon(IS);
96       pix = resMgr->loadPixmap( "HOMARD", "toruspointvector.png" );
97       IS=QIcon(pix);
98       RBTore->setIcon(IS);
99
100       InitConnect( );
101
102       SetNewName() ;
103       InitValBoundaryAn();          // Cherche les valeurs de la boite englobante le maillage
104       InitMinMax();                 // Initialise les bornes des boutons
105       SetCylinder();                // Propose un cylindre en premier choix
106     }
107
108 // -------------------------------------------------------------------------------
109 SMESH_CreateBoundaryAn::SMESH_CreateBoundaryAn(SMESHGUI_HomardAdaptDlg* parent,
110                                          SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
111                                          QString caseName):
112     QDialog(0), SMESH_Ui_CreateBoundaryAn(),
113     _parent(parent),
114     _Name (""),
115     _aCaseName(caseName),
116     _Type(1),
117     _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0),
118     _BoundaryAnXaxis(0), _BoundaryAnYaxis(0), _BoundaryAnZaxis(0),
119     // Pour affichage lors de l edition d une BoundaryAn sans nom de Cas
120     _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0),
121     _Xmin(1), _Xmax(1), _Xincr(1), _Ymin(1), _Ymax(1), _Yincr(1), _Zmin(1), _Zmax(1), _Zincr(1), _DMax(1),
122      Chgt (false),
123      myHomardGen(myHomardGen0)
124     {
125   //  MESSAGE("Debut de  SMESH_CreateBoundaryAn")
126       setupUi(this);
127       SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
128       QPixmap pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" );
129       QIcon IS=QIcon(pix);
130       RBSphere->setIcon(IS);
131       QPixmap pix2 = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" );
132       QIcon IS2=QIcon(pix2);
133       RBCylindre->setIcon(IS2);
134       QPixmap pix3 = resMgr->loadPixmap( "HOMARD", "cone.png" );
135       QIcon IS3=QIcon(pix3);
136       RBCone->setIcon(IS3);
137       QPixmap pix4 = resMgr->loadPixmap( "HOMARD", "conepointvector.png" );
138       QIcon IS4=QIcon(pix4);
139       RB_Def_angle->setIcon(IS4);
140       QPixmap pix5 = resMgr->loadPixmap( "HOMARD", "conedxyz.png" );
141       QIcon IS5=QIcon(pix5);
142       RB_Def_radius->setIcon(IS5);
143       setModal(true);
144       InitConnect();
145     }
146
147 // ------------------------------------------------------------------------
148 SMESH_CreateBoundaryAn::~SMESH_CreateBoundaryAn()
149 // ------------------------------------------------------------------------
150 {
151     // no need to delete child widgets, Qt does it all for us
152 }
153 // ------------------------------------------------------------------------
154 void SMESH_CreateBoundaryAn::InitConnect()
155 // ------------------------------------------------------------------------
156 {
157     connect( RBCylindre,    SIGNAL(clicked()) , this, SLOT(SetCylinder()) ) ;
158     connect( RBSphere,      SIGNAL(clicked()) , this, SLOT(SetSphere()) ) ;
159     connect( RBCone,        SIGNAL(clicked()) , this, SLOT(SetCone()) ) ;
160     connect( RB_Def_radius, SIGNAL(clicked()) , this, SLOT(SetConeR()) );
161     connect( RB_Def_angle,  SIGNAL(clicked()) , this, SLOT(SetConeA()) );
162     connect( RBTore,        SIGNAL(clicked()) , this, SLOT(SetTore()) ) ;
163     connect( buttonOk,     SIGNAL( pressed() ), this, SLOT( PushOnOK() ) );
164     connect( buttonApply,  SIGNAL( pressed() ), this, SLOT( PushOnApply() ) );
165     connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) );
166     connect( buttonHelp,   SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) );
167 }
168 // ------------------------------------------------------------------------
169 void SMESH_CreateBoundaryAn::InitValBoundaryAn()
170 // ------------------------------------------------------------------------
171 {
172 //
173 //  1. Les coordonnees extremes du maillage
174 //
175     if (_aCaseName == QString("")) { return; }
176
177     SMESHHOMARD::HOMARD_Cas_var aCas = myHomardGen->GetCase(_aCaseName.toStdString().c_str());
178     SMESHHOMARD::extrema_var  MesExtremes = aCas->GetBoundingBox();
179     int num = MesExtremes->length() ;
180     ASSERT(num == 10);
181     _Xmin=MesExtremes[0]; _Xmax=MesExtremes[1]; _Xincr=MesExtremes[2];
182     _Ymin=MesExtremes[3]; _Ymax=MesExtremes[4]; _Yincr=MesExtremes[5];
183     _Zmin=MesExtremes[6]; _Zmax=MesExtremes[7]; _Zincr=MesExtremes[8];
184     _DMax=MesExtremes[9];
185      MESSAGE ("_Xmin : " << _Xmin << " _Xmax : " << _Xmax << " _Xincr : " << _Xincr ) ;
186      MESSAGE ("_Ymin : " << _Ymin << " _Ymax : " << _Ymax << " _Yincr : " << _Yincr ) ;
187      MESSAGE ("_Zmin : " << _Zmin << " _Zmax : " << _Zmax << " _Zincr : " << _Zincr) ;
188      MESSAGE ("_DMax : " << _DMax);
189
190 //  2. Caracteristiques des frontieres
191 // en X
192     _Xcentre=(_Xmin + _Xmax)/2.;
193 // en Y
194     _Ycentre=(_Ymin + _Ymax)/2.;
195 // en Z
196     _Zcentre=(_Zmin + _Zmax)/2.;
197 // Rayon
198     _Rayon= _DMax/4.;
199 }
200
201 // ------------------------------------------------------------------------
202 void SMESH_CreateBoundaryAn::InitMinMax()
203 // ------------------------------------------------------------------------
204 {
205   // Cylindre
206   // . X du centre
207   SpinBox_Xcent->setValue(_Xcentre);
208   SpinBox_Xcent->setSingleStep(_Xincr);
209   // . Y du centre
210   SpinBox_Ycent->setValue(_Ycentre);
211   SpinBox_Ycent->setSingleStep(_Yincr);
212   // . Z du centre
213   SpinBox_Zcent->setValue(_Zcentre);
214   SpinBox_Zcent->setSingleStep(_Zincr);
215   // . X de l'axe
216   SpinBox_Xaxis->setValue(0.);
217   SpinBox_Xaxis->setSingleStep(0.1);
218   // . Y de l'axe
219   SpinBox_Yaxis->setValue(0.);
220   SpinBox_Yaxis->setSingleStep(0.1);
221   // . Z de l'axe
222   SpinBox_Zaxis->setValue(1.);
223   SpinBox_Zaxis->setSingleStep(0.1);
224   // . Rayon
225   SpinBox_Radius->setValue(_Rayon);
226   SpinBox_Radius->setSingleStep(_Rayon/10.);
227
228   // Sphere
229   // . X du centre
230   SpinBox_Xcentre->setValue(_Xcentre);
231   SpinBox_Xcentre->setSingleStep(_Xincr);
232   // . Y du centre
233   SpinBox_Ycentre->setValue(_Ycentre);
234   SpinBox_Ycentre->setSingleStep(_Yincr);
235   // . Z du centre
236   SpinBox_Zcentre->setValue(_Zcentre);
237   SpinBox_Zcentre->setSingleStep(_Zincr);
238   // . Rayon
239   SpinBox_Rayon->setValue(_Rayon);
240   SpinBox_Rayon->setSingleStep(_Rayon/10.);
241
242   // Cone en rayons
243   // . X des centres
244   _BoundaryAnXcone1 = _Xcentre ;
245   SpinBox_Cone_X1->setSingleStep(_Xincr);
246   _BoundaryAnXcone2 = _Xcentre ;
247   SpinBox_Cone_X2->setSingleStep(_Xincr);
248   // . Y des centres
249   _BoundaryAnYcone1 = _Ycentre ;
250   SpinBox_Cone_Y1->setSingleStep(_Yincr);
251   _BoundaryAnYcone2 = _Ycentre ;
252   SpinBox_Cone_Y2->setSingleStep(_Yincr);
253   // . Z des centres
254   _BoundaryAnZcone1 = _Zmin ;
255   SpinBox_Cone_Z1->setSingleStep(_Zincr);
256   _BoundaryAnZcone2 = _Zmax ;
257   SpinBox_Cone_Z2->setSingleStep(_Zincr);
258   // . Rayons/Angles
259   _BoundaryAnRayon1 = 0. ;
260   _BoundaryAnRayon2 = _Rayon ;
261   SpinBox_Cone_V2->setSingleStep(_Rayon/10.);
262
263   // Cone en angle
264   convertRayonAngle(1) ;
265   SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
266   SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
267   SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
268   SpinBox_Cone_V1->setValue(_BoundaryAngle);
269   SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
270   SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
271   SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
272
273   // Tore
274   // . X du centre
275   SpinBoxToreXcent->setValue(_Xcentre);
276   SpinBoxToreXcent->setSingleStep(_Xincr);
277   // . Y du centre
278   SpinBoxToreYcent->setValue(_Ycentre);
279   SpinBoxToreYcent->setSingleStep(_Yincr);
280   // . Z du centre
281   SpinBoxToreZcent->setValue(_Zcentre);
282   SpinBoxToreZcent->setSingleStep(_Zincr);
283   // . X de l'axe
284   SpinBoxToreXaxe->setValue(0.);
285   SpinBoxToreXaxe->setSingleStep(0.1);
286   // . Y de l'axe
287   SpinBoxToreYaxe->setValue(0.);
288   SpinBoxToreYaxe->setSingleStep(0.1);
289   // . Z de l'axe
290   SpinBoxToreZaxe->setValue(1.);
291   SpinBoxToreZaxe->setSingleStep(0.1);
292   // . Rayon de revolution
293   SpinBoxToreRRev->setValue(_Rayon);
294   SpinBoxToreRRev->setSingleStep(_Rayon/10.);
295   // . Rayon primaire
296   SpinBoxToreRPri->setValue(_Rayon/3.);
297   SpinBoxToreRPri->setSingleStep(_Rayon/20.);
298 }
299 // ------------------------------------------------------------------------
300 bool SMESH_CreateBoundaryAn::PushOnApply()
301 // ------------------------------------------------------------------------
302 // Appele lorsque l'un des boutons Ok ou Apply est presse
303 //
304 {
305   if (LEName->text().trimmed()=="")
306   {
307     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
308                               QObject::tr("HOM_BOUN_NAME") );
309     return false;
310   }
311
312   switch (_Type)
313   {
314       case 1 : // il s agit d un cylindre
315       {
316         if ((_BoundaryAnXcentre != SpinBox_Xcent->value())  ||
317             (_BoundaryAnYcentre != SpinBox_Ycent->value())  ||
318             (_BoundaryAnZcentre != SpinBox_Zcent->value())  ||
319             (_BoundaryAnRayon   != SpinBox_Radius->value()) ||
320             (_BoundaryAnXaxis   != SpinBox_Xaxis->value()) ||
321             (_BoundaryAnYaxis   != SpinBox_Yaxis->value()) ||
322             (_BoundaryAnZaxis   != SpinBox_Zaxis->value()) )
323         {
324           Chgt = true;
325           _BoundaryAnXaxis= SpinBox_Xaxis->value();
326           _BoundaryAnYaxis= SpinBox_Yaxis->value();
327           _BoundaryAnZaxis= SpinBox_Zaxis->value();
328           _BoundaryAnXcentre=SpinBox_Xcent->value();
329           _BoundaryAnYcentre=SpinBox_Ycent->value();
330           _BoundaryAnZcentre=SpinBox_Zcent->value();
331           _BoundaryAnRayon=SpinBox_Radius->value();
332         }
333         break;
334       }
335
336       case 2 : // il s agit d une sphere
337       {
338         if ((_BoundaryAnXcentre != SpinBox_Xcentre->value()) ||
339             (_BoundaryAnYcentre != SpinBox_Ycentre->value()) ||
340             (_BoundaryAnZcentre != SpinBox_Zcentre->value()) ||
341             (_BoundaryAnRayon   != SpinBox_Rayon->value())  )
342         {
343            Chgt = true;
344           _BoundaryAnXcentre=SpinBox_Xcentre->value();
345           _BoundaryAnYcentre=SpinBox_Ycentre->value();
346           _BoundaryAnZcentre=SpinBox_Zcentre->value();
347           _BoundaryAnRayon=SpinBox_Rayon->value();
348         }
349         break;
350       }
351
352       case 3 : // il s agit d un cone defini par un axe et un angle
353       {
354         if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value())  ||
355             (_BoundaryAnYaxisCone != SpinBox_Cone_Y1->value())  ||
356             (_BoundaryAnZaxisCone != SpinBox_Cone_Z1->value())  ||
357             (_BoundaryAnXorigCone != SpinBox_Cone_X2->value())  ||
358             (_BoundaryAnYorigCone != SpinBox_Cone_Y2->value())  ||
359             (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value())  ||
360             (_BoundaryAngle       != SpinBox_Cone_V1->value()) )
361         {
362            Chgt = true;
363           _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ;
364           _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ;
365           _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ;
366           _BoundaryAnXorigCone = SpinBox_Cone_X2->value() ;
367           _BoundaryAnYorigCone = SpinBox_Cone_Y2->value() ;
368           _BoundaryAnZorigCone = SpinBox_Cone_Z2->value() ;
369           _BoundaryAngle       = SpinBox_Cone_V1->value() ;
370         }
371         break;
372       }
373
374       case 4 : // il s agit d un cone defini par les 2 rayons
375       {
376         if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value())  ||
377             (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value())  ||
378             (_BoundaryAnZcone1 != SpinBox_Cone_Z1->value())  ||
379             (_BoundaryAnRayon1 != SpinBox_Cone_V1->value())  ||
380             (_BoundaryAnXcone2 != SpinBox_Cone_X2->value())  ||
381             (_BoundaryAnYcone2 != SpinBox_Cone_Y2->value())  ||
382             (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value())  ||
383             (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) )
384         {
385            Chgt = true;
386           _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ;
387           _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ;
388           _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ;
389           _BoundaryAnRayon1 = SpinBox_Cone_V1->value() ;
390           _BoundaryAnXcone2 = SpinBox_Cone_X2->value() ;
391           _BoundaryAnYcone2 = SpinBox_Cone_Y2->value() ;
392           _BoundaryAnZcone2 = SpinBox_Cone_Z2->value() ;
393           _BoundaryAnRayon2 = SpinBox_Cone_V2->value() ;
394         }
395         break;
396       }
397       case 5 : // il s agit d un tore
398       {
399         if ((_BoundaryAnToreXcentre != SpinBoxToreXcent->value())  ||
400             (_BoundaryAnToreYcentre != SpinBoxToreYcent->value())  ||
401             (_BoundaryAnToreZcentre != SpinBoxToreZcent->value())  ||
402             (_BoundaryAnToreRRev   != SpinBoxToreRRev->value()) ||
403             (_BoundaryAnToreRPri   != SpinBoxToreRPri->value()) ||
404             (_BoundaryAnToreXaxe   != SpinBoxToreXaxe->value()) ||
405             (_BoundaryAnToreYaxe   != SpinBoxToreYaxe->value()) ||
406             (_BoundaryAnToreZaxe   != SpinBoxToreZaxe->value()) )
407         {
408           Chgt = true;
409           _BoundaryAnToreXcentre= SpinBoxToreXcent->value();
410           _BoundaryAnToreYcentre= SpinBoxToreYcent->value();
411           _BoundaryAnToreZcentre= SpinBoxToreZcent->value();
412           _BoundaryAnToreRRev=SpinBoxToreRRev->value();
413           _BoundaryAnToreRPri=SpinBoxToreRPri->value();
414           _BoundaryAnToreXaxe=SpinBoxToreXaxe->value();
415           _BoundaryAnToreYaxe=SpinBoxToreYaxe->value();
416           _BoundaryAnToreZaxe=SpinBoxToreZaxe->value();
417         }
418         break;
419       }
420
421  }
422
423 // Controles
424 // L'axe pour un cylindre
425   if ( _Type == 5 )
426   {
427     double daux = _BoundaryAnXaxis*_BoundaryAnXaxis + _BoundaryAnYaxis*_BoundaryAnYaxis + _BoundaryAnZaxis*_BoundaryAnZaxis ;
428     if ( daux < 0.0000001 )
429     {
430       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
431                                 QObject::tr("HOM_AXE") );
432       return false;
433     }
434   }
435
436   //
437   // Création ou mise Ã  jour de la frontière
438   //
439   bool bOK = CreateOrUpdateBoundaryAn();
440
441   //if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; }
442
443   return bOK;
444
445 }
446 // ---------------------------------------------------
447 bool SMESH_CreateBoundaryAn::CreateOrUpdateBoundaryAn()
448 //----------------------------------------------------
449 //  Creation de l'objet boundary
450 {
451   MESSAGE("Debut de CreateOrUpdateBoundaryAn avec _Type ="<<_Type<<", _Name ="<<_Name.toStdString().c_str()<<" et LEName ="<<LEName->text().trimmed().toStdString().c_str());
452 //
453   if (_Name != LEName->text().trimmed())
454   {
455     _Name = LEName->text().trimmed() ;
456     try
457     {
458       switch (_Type)
459       {
460         case 1 : // il s agit d un cylindre
461         { aBoundaryAn = myHomardGen->CreateBoundaryCylinder(CORBA::string_dup(_Name.toStdString().c_str()), \
462             _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
463           break;
464         }
465         case 2 : // il s agit d une sphere
466         { aBoundaryAn = myHomardGen->CreateBoundarySphere(CORBA::string_dup(_Name.toStdString().c_str()), \
467             _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
468           break;
469        }
470         case 3 : // il s agit d un cone defini par un axe et un angle
471         { aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_Name.toStdString().c_str()), \
472             _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
473             _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
474           break;
475         }
476         case 4 : // il s agit d un cone defini par les 2 rayons
477         { aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_Name.toStdString().c_str()), \
478             _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
479             _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
480           break;
481         }
482         case 5 : // il s agit d un tore
483         { aBoundaryAn = myHomardGen->CreateBoundaryTorus(CORBA::string_dup(_Name.toStdString().c_str()), \
484             _BoundaryAnToreXcentre, _BoundaryAnToreYcentre, _BoundaryAnToreZcentre, _BoundaryAnToreXaxe, _BoundaryAnToreYaxe, _BoundaryAnToreZaxe, _BoundaryAnToreRRev, _BoundaryAnToreRPri );
485           break;
486         }
487       }
488     }
489     catch( SALOME::SALOME_Exception& S_ex )
490     {
491       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
492                                 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
493       return false ;
494     }
495     _parent->AddBoundaryAn(_Name);
496
497     return true;
498   }
499   else {
500     QMessageBox::warning( 0, QObject::tr("HOM_WARNING"),
501                              QObject::tr("HOM_SELECT_OBJECT_4") );
502     return false ;
503   }
504   MESSAGE("Fin de CreateOrUpdateBoundaryAn");
505 }
506 // ------------------------------------------------------------------------
507 void SMESH_CreateBoundaryAn::PushOnOK()
508 // ------------------------------------------------------------------------
509 {
510      if (PushOnApply()) this->close();
511 }
512 // ------------------------------------------------------------------------
513 void SMESH_CreateBoundaryAn::PushOnHelp()
514 // ------------------------------------------------------------------------
515 {
516   SMESH::ShowHelpFile(QString("gui_create_boundary.html"));
517   //std::string LanguageShort = myHomardGen->GetLanguageShort();
518   //HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("un-cylindre"), QString(LanguageShort.c_str()));
519 }
520
521 // -----------------------------------
522 void SMESH_CreateBoundaryAn::SetNewName()
523 // -----------------------------------
524 {
525 // Recherche d'un nom par defaut qui n'existe pas encore
526
527   SMESHHOMARD::listeBoundarys_var MyObjects = myHomardGen->GetAllBoundarysName();
528   int num = 0; QString aName="";
529   while (aName=="" )
530   {
531     aName.setNum(num+1) ;
532     aName.insert(0, QString("Boun_")) ;
533     for ( int i=0; i<MyObjects->length(); i++)
534     {
535       if ( aName ==  QString(MyObjects[i]))
536       {
537         num ++ ;
538         aName = "" ;
539         break ;
540       }
541    }
542   }
543   LEName->setText(aName);
544 }
545 // ------------------------------------------------------------------------
546 void SMESH_CreateBoundaryAn::SetCylinder()
547 // ------------------------------------------------------------------------
548 {
549   MESSAGE("Debut de SetCylinder")
550   gBCylindre->setVisible(1);
551   gBSphere->setVisible(0);
552   gBCone->setVisible(0);
553   gBTore->setVisible(0);
554 //
555   _Type=1;
556 //
557   adjustSize();
558 //   MESSAGE("Fin de SetCylinder")
559 }
560 // ------------------------------------------------------------------------
561 void SMESH_CreateBoundaryAn::SetSphere()
562 // ------------------------------------------------------------------------
563 {
564   MESSAGE("Debut de SetSphere")
565   gBCylindre->setVisible(0);
566   gBSphere->setVisible(1);
567   gBCone->setVisible(0);
568   gBTore->setVisible(0);
569 //
570   _Type=2;
571 //
572   adjustSize();
573 //   MESSAGE("Fin de SetSphere")
574 }
575 // ------------------------------------------------------------------------
576 void SMESH_CreateBoundaryAn::SetConeR()
577 // ------------------------------------------------------------------------
578 {
579   MESSAGE("Debut de SetConeR")
580 //
581 // Stockage et conversion des valeurs si elles ont change
582   if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value())  ||
583       (_BoundaryAnYaxisCone != SpinBox_Cone_Y1->value())  ||
584       (_BoundaryAnZaxisCone != SpinBox_Cone_Z1->value())  ||
585       (_BoundaryAnXorigCone != SpinBox_Cone_X2->value())  ||
586       (_BoundaryAnYorigCone != SpinBox_Cone_Y2->value())  ||
587       (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value())  ||
588       (_BoundaryAngle       != SpinBox_Cone_V1->value()) )
589   {
590     MESSAGE("Stockage et conversion")
591     _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ;
592     _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ;
593     _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ;
594     _BoundaryAnXorigCone = SpinBox_Cone_X2->value() ;
595     _BoundaryAnYorigCone = SpinBox_Cone_Y2->value() ;
596     _BoundaryAnZorigCone = SpinBox_Cone_Z2->value() ;
597     _BoundaryAngle       = SpinBox_Cone_V1->value() ;
598     convertRayonAngle(-1) ;
599   }
600 //
601   _Type=4;
602 //
603   TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0));
604   SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
605   TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0));
606   SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
607   TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0));
608   SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
609 //
610   TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0));
611   SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
612   SpinBox_Cone_V1->setMaximum(100000.*_DMax);
613   SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
614 //
615   TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0));
616   SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
617   TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0));
618   SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
619   TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0));
620   SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
621 //
622   TLCone_V2->setVisible(1);
623   SpinBox_Cone_V2->setVisible(1);
624   TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0));
625   SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
626 //
627 //   MESSAGE("Fin de SetConeR")
628 }
629 // ------------------------------------------------------------------------
630 void SMESH_CreateBoundaryAn::SetConeA()
631 // ------------------------------------------------------------------------
632 {
633   MESSAGE("Debut de SetConeA")
634 // Stockage et conversion des valeurs si elles ont change
635   if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value())  ||
636       (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value())  ||
637       (_BoundaryAnZcone1 != SpinBox_Cone_Z1->value())  ||
638       (_BoundaryAnRayon1 != SpinBox_Cone_V1->value())  ||
639       (_BoundaryAnXcone2 != SpinBox_Cone_X2->value())  ||
640       (_BoundaryAnYcone2 != SpinBox_Cone_Y2->value())  ||
641       (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value())  ||
642       (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) )
643   {
644     MESSAGE("Stockage et conversion")
645     _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ;
646     _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ;
647     _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ;
648     _BoundaryAnRayon1 = SpinBox_Cone_V1->value() ;
649     _BoundaryAnXcone2 = SpinBox_Cone_X2->value() ;
650     _BoundaryAnYcone2 = SpinBox_Cone_Y2->value() ;
651     _BoundaryAnZcone2 = SpinBox_Cone_Z2->value() ;
652     _BoundaryAnRayon2 = SpinBox_Cone_V2->value() ;
653     convertRayonAngle(1) ;
654   }
655 //
656   _Type=3;
657 //
658   TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0));
659   SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
660   TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0));
661   SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
662   TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0));
663   SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
664 //
665   TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0));
666   SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
667   TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0));
668   SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
669   TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0));
670   SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
671 //
672   TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0));
673   SpinBox_Cone_V1->setValue(_BoundaryAngle);
674   SpinBox_Cone_V1->setSingleStep(1.);
675   SpinBox_Cone_V1->setMaximum(90.);
676 //
677   TLCone_V2->setVisible(0);
678   SpinBox_Cone_V2->setVisible(0);
679 //   MESSAGE("Fin de SetConeA")
680 }
681
682
683 // ------------------------------------------------------------------------
684 void SMESH_CreateBoundaryAn::SetCone()
685 // ------------------------------------------------------------------------
686 {
687   MESSAGE("Debut de SetCone")
688   gBCylindre->setVisible(0);
689   gBSphere->setVisible(0);
690   gBCone->setVisible(1);
691   gBTore->setVisible(0);
692 //
693   if ( RB_Def_radius->isChecked() )
694   {
695     SetConeR();
696   }
697   else
698   {
699     SetConeA();
700   }
701 //
702   adjustSize();
703 //   MESSAGE("Fin de SetCone")
704 }
705 // ------------------------------------------------------------------------
706 void SMESH_CreateBoundaryAn::SetTore()
707 // ------------------------------------------------------------------------
708 {
709   MESSAGE("Debut de SetTore")
710   gBCylindre->setVisible(0);
711   gBSphere->setVisible(0);
712   gBCone->setVisible(0);
713   gBTore->setVisible(1);
714 //
715   _Type=5;
716 //
717   adjustSize();
718 //   MESSAGE("Fin de SetTore")
719 }
720 // ------------------------------------------------------------------------
721 void SMESH_CreateBoundaryAn::convertRayonAngle(int option)
722 // ------------------------------------------------------------------------
723 // Conversion entre les deux formulations du cone :
724 // par deux rayons ou avec un axe et un angle.
725 // Voir sfcoi1 de HOMARD
726 {
727   MESSAGE("Debut de convertRayonAngle, option = "<<option)
728 //
729 //         o
730 //         !    .
731 //         !        .
732 //       RA!            .
733 //         !                o
734 //         !              RB!   .
735 //         !                !       .
736 //         A----------------B----------O
737 //
738 //   Thales : RA/RB = AO/BO  ==> BO = AB*RB/(RA-RB)
739 //   Angle  : tg(alpha) = RA/AO
740 //
741   double daux ;
742 // De rayon vers angle :
743   if ( option == 1 )
744   {
745     double xa, ya, za, ra ;
746     double xb, yb, zb, rb ;
747 // Positionnement de A vers B, avec RA>RB
748     if ( _BoundaryAnRayon1 > _BoundaryAnRayon2 )
749     {
750       xa = _BoundaryAnXcone1 ;
751       ya = _BoundaryAnYcone1 ;
752       za = _BoundaryAnZcone1 ;
753       ra = _BoundaryAnRayon1 ;
754       xb = _BoundaryAnXcone2 ;
755       yb = _BoundaryAnYcone2 ;
756       zb = _BoundaryAnZcone2 ;
757       rb = _BoundaryAnRayon2 ;
758     }
759     else
760     {
761       xa = _BoundaryAnXcone2 ;
762       ya = _BoundaryAnYcone2 ;
763       za = _BoundaryAnZcone2 ;
764       ra = _BoundaryAnRayon2 ;
765       xb = _BoundaryAnXcone1 ;
766       yb = _BoundaryAnYcone1 ;
767       zb = _BoundaryAnZcone1 ;
768       rb = _BoundaryAnRayon1 ;
769     }
770 // Axe : relie les deux centres, de A vers B.  L'axe est normalise
771     _BoundaryAnXaxisCone = xb - xa ;
772     _BoundaryAnYaxisCone = yb - ya ;
773     _BoundaryAnZaxisCone = zb - za ;
774     daux = sqrt ( _BoundaryAnXaxisCone*_BoundaryAnXaxisCone + _BoundaryAnYaxisCone*_BoundaryAnYaxisCone + _BoundaryAnZaxisCone*_BoundaryAnZaxisCone ) ;
775     _BoundaryAnXaxisCone = _BoundaryAnXaxisCone/daux ;
776     _BoundaryAnYaxisCone = _BoundaryAnYaxisCone/daux ;
777     _BoundaryAnZaxisCone = _BoundaryAnZaxisCone/daux ;
778 // Origine
779     daux = daux * rb / (ra-rb) ;
780     _BoundaryAnXorigCone = xb + daux*_BoundaryAnXaxisCone ;
781     _BoundaryAnYorigCone = yb + daux*_BoundaryAnYaxisCone ;
782     _BoundaryAnZorigCone = zb + daux*_BoundaryAnZaxisCone ;
783 // Angle en degre
784     daux = ra / sqrt((_BoundaryAnXorigCone-xa)*(_BoundaryAnXorigCone-xa) + (_BoundaryAnYorigCone-ya)*(_BoundaryAnYorigCone-ya) + (_BoundaryAnZorigCone-za)*(_BoundaryAnZorigCone-za) ) ;
785     _BoundaryAngle = atan(daux)*180./PI ;
786   }
787 // D'angle vers rayon :
788   else
789   {
790     double xax, yax, zax ;
791 // L'axe est normalise
792     daux = sqrt ( _BoundaryAnXaxisCone*_BoundaryAnXaxisCone + _BoundaryAnYaxisCone*_BoundaryAnYaxisCone + _BoundaryAnZaxisCone*_BoundaryAnZaxisCone ) ;
793     xax = _BoundaryAnXaxisCone/daux ;
794     yax = _BoundaryAnYaxisCone/daux ;
795     zax = _BoundaryAnZaxisCone/daux ;
796 // Centre 1 : l'origine
797     _BoundaryAnXcone1 = _BoundaryAnXorigCone ;
798     _BoundaryAnYcone1 = _BoundaryAnYorigCone ;
799     _BoundaryAnZcone1 = _BoundaryAnZorigCone ;
800 // Rayon 1 : nul
801     _BoundaryAnRayon1 = 0. ;
802 // Centre 2 : l'origine decalee d'une longueur arbitraire le long de l'axe
803     _BoundaryAnXcone2 = _BoundaryAnXorigCone + _DMax*xax ;
804     _BoundaryAnYcone2 = _BoundaryAnYorigCone + _DMax*yax ;
805     _BoundaryAnZcone2 = _BoundaryAnZorigCone + _DMax*zax ;
806 // Rayon 2 : a calculer
807     _BoundaryAnRayon2 = _DMax*tan(_BoundaryAngle*PI/180.) ;
808   }
809 //   MESSAGE("Fin de convertRayonAngle")
810 }
811
812 // -------------------------------------------------------------------------------
813 SMESH_CreateBoundaryCAO::SMESH_CreateBoundaryCAO(SMESHGUI_HomardAdaptDlg* parent, bool modal,
814                                            SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
815                                            QString caseName, QString aName)
816 // ---------------------------------------------------------------------------------
817 /* Constructs a SMESH_CreateBoundaryCAO */
818     :
819     QDialog(0), SMESH_Ui_CreateBoundaryCAO(),
820     _parent(parent), _aName(aName),
821     myHomardGen(SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0)),
822     _aCaseName(caseName)
823     {
824       MESSAGE("Constructeur") ;
825       setupUi(this);
826       setModal(modal);
827       InitConnect();
828
829      if ( _aName == QString("") ) {SetNewName();};
830     }
831
832 // ------------------------------------------------------------------------
833 SMESH_CreateBoundaryCAO::~SMESH_CreateBoundaryCAO()
834 // ------------------------------------------------------------------------
835 {
836     // no need to delete child widgets, Qt does it all for us
837 }
838 // ------------------------------------------------------------------------
839 void SMESH_CreateBoundaryCAO::InitConnect()
840 // ------------------------------------------------------------------------
841 {
842     connect( PushFichier,  SIGNAL(pressed()), this, SLOT(SetCAOFile()));
843     connect( buttonOk,     SIGNAL(pressed()), this, SLOT( PushOnOK()));
844     connect( buttonApply,  SIGNAL(pressed()), this, SLOT( PushOnApply()));
845     connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
846     connect( buttonHelp,   SIGNAL(pressed()), this, SLOT( PushOnHelp()));
847     connect( CBGroupe,     SIGNAL(stateChanged(int)), this, SLOT( SetFiltrage()));
848 }
849
850 // ------------------------------------------------------------------------
851 bool SMESH_CreateBoundaryCAO::PushOnApply()
852 // ------------------------------------------------------------------------
853 // Appele lorsque l'un des boutons Ok ou Apply est presse
854 //
855 {
856 // Verifications
857
858   QString aName=LEName->text().trimmed();
859   if (aName=="") {
860     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
861                               QObject::tr("HOM_BOUN_NAME") );
862     return false;
863   }
864
865 //  La CAO
866   QString aCAOFile=LEFileName->text().trimmed();
867   if (aCAOFile ==QString(""))
868   {
869     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
870                               QObject::tr("HOM_BOUN_CAO") );
871     return false;
872   }
873
874 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
875   if ( _aName != aName )
876   {
877    try
878    {
879      _aName=aName;
880      aBoundary=myHomardGen->CreateBoundaryCAO(CORBA::string_dup(_aName.toStdString().c_str()), aCAOFile.toStdString().c_str());
881      _parent->AddBoundaryCAO(_aName);
882      aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str());
883    }
884    catch( SALOME::SALOME_Exception& S_ex )
885    {
886       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
887                                 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
888       return false;
889    }
890   }
891
892 // Les groupes
893   AssocieLesGroupes();
894
895   //HOMARD_UTILS::updateObjBrowser();
896   return true;
897 }
898
899
900 // ------------------------------------------------------------------------
901 void SMESH_CreateBoundaryCAO::PushOnOK()
902 // ------------------------------------------------------------------------
903 {
904      if (PushOnApply()) this->close();
905      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
906 }
907 // ------------------------------------------------------------------------
908 void SMESH_CreateBoundaryCAO::PushOnHelp()
909 // ------------------------------------------------------------------------
910 {
911   SMESH::ShowHelpFile(QString("gui_create_boundary.html"));
912   //std::string LanguageShort = myHomardGen->GetLanguageShort();
913   //HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("CAO"), QString(LanguageShort.c_str()));
914 }
915 // ------------------------------------------------------------------------
916 void SMESH_CreateBoundaryCAO::AssocieLesGroupes()
917 // ------------------------------------------------------------------------
918 {
919   SMESHHOMARD::ListGroupType_var aSeqGroupe = new SMESHHOMARD::ListGroupType;
920   aSeqGroupe->length(_listeGroupesBoundary.size());
921   QStringList::const_iterator it;
922   int i=0;
923   for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++)
924      aSeqGroupe[i++]=(*it).toStdString().c_str();
925   aBoundary->SetGroups(aSeqGroupe);
926
927 }
928
929 // -------------------------------------------------
930 void SMESH_CreateBoundaryCAO::SetNewName()
931 // --------------------------------------------------
932 {
933
934   SMESHHOMARD::listeBoundarys_var  MyObjects = myHomardGen->GetAllBoundarysName();
935   int num = 0; QString aName="";
936   while (aName == QString("") )
937   {
938     aName.setNum(num+1) ;
939     aName.insert(0, QString("Boun_")) ;
940     for ( int i=0; i<MyObjects->length(); i++)
941     {
942       if ( aName ==  QString(MyObjects[i]))
943       {
944         num ++ ;
945         aName = "" ;
946         break ;
947       }
948    }
949   }
950   LEName->setText(aName);
951 }
952 // ------------------------------------------------------------------------
953 void SMESH_CreateBoundaryCAO::SetCAOFile()
954 // ------------------------------------------------------------------------
955 {
956   QString aCAOFile = SMESH_HOMARD_QT_COMMUN::PushNomFichier( false, QString("xao") );
957   if (!(aCAOFile.isEmpty())) LEFileName->setText(aCAOFile);
958 }
959
960 // ------------------------------------------------------------------------
961 void SMESH_CreateBoundaryCAO::setGroups (QStringList listGroup)
962 // ------------------------------------------------------------------------
963 {
964     _listeGroupesBoundary = listGroup;
965 }
966 // ------------------------------------------------------------------------
967 void SMESH_CreateBoundaryCAO::SetFiltrage()
968 // // ------------------------------------------------------------------------
969 {
970   if (!CBGroupe->isChecked()) return;
971   if (_aCaseName.toStdString().c_str() == QString()) {
972     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
973                               QObject::tr("HOM_BOUN_CASE") );
974     return;
975   }
976
977   SMESH_CreateListGroupCAO *aDlg = new SMESH_CreateListGroupCAO(this, true, SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen),
978                             _aCaseName, _listeGroupesBoundary) ;
979   aDlg->show();
980 }
981
982 // -------------------------------------------------------------------------------
983 SMESH_CreateBoundaryDi::SMESH_CreateBoundaryDi(SMESHGUI_HomardAdaptDlg* parent, bool modal,
984                                          SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
985                                          QString caseName, QString aName)
986 // ---------------------------------------------------------------------------------
987 /* Constructs a SMESH_CreateBoundaryDi */
988     :
989     QDialog(0), SMESH_Ui_CreateBoundaryDi(),
990     _parent(parent), _aName(aName),
991     myHomardGen(SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0)),
992     _aCaseName(caseName)
993     {
994       MESSAGE("Constructeur") ;
995       setupUi(this);
996       setModal(modal);
997       InitConnect();
998
999      if ( _aName == QString("") ) {SetNewName();};
1000     }
1001
1002 // ------------------------------------------------------------------------
1003 SMESH_CreateBoundaryDi::~SMESH_CreateBoundaryDi()
1004 // ------------------------------------------------------------------------
1005 {
1006     // no need to delete child widgets, Qt does it all for us
1007 }
1008 // ------------------------------------------------------------------------
1009 void SMESH_CreateBoundaryDi::InitConnect()
1010 // ------------------------------------------------------------------------
1011 {
1012     connect( PushFichier,  SIGNAL(pressed()), this, SLOT(SetMeshFile()));
1013     connect( buttonOk,     SIGNAL(pressed()), this, SLOT( PushOnOK()));
1014     connect( buttonApply,  SIGNAL(pressed()), this, SLOT( PushOnApply()));
1015     connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
1016     connect( buttonHelp,   SIGNAL(pressed()), this, SLOT( PushOnHelp()));
1017     connect( CBGroupe,     SIGNAL(stateChanged(int)), this, SLOT( SetFiltrage()));
1018 }
1019
1020 // ------------------------------------------------------------------------
1021 bool SMESH_CreateBoundaryDi::PushOnApply()
1022 // ------------------------------------------------------------------------
1023 // Appele lorsque l'un des boutons Ok ou Apply est presse
1024 //
1025 {
1026 // Verifications
1027
1028   QString aName=LEName->text().trimmed();
1029   if (aName=="") {
1030     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1031                               QObject::tr("HOM_BOUN_NAME") );
1032     return false;
1033   }
1034
1035 //  Le maillage de la frontiere discrete
1036   QString aMeshFile=LEFileName->text().trimmed();
1037   if (aMeshFile ==QString(""))
1038   {
1039     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1040                               QObject::tr("HOM_BOUN_MESH") );
1041     return false;
1042   }
1043
1044   //  Le nom du maillage de la frontiere discrete
1045   QString aMeshName = SMESH_HOMARD_QT_COMMUN::LireNomMaillage(aMeshFile);
1046   if (aMeshName == "" )
1047   {
1048     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1049                               QObject::tr("HOM_MED_FILE_2") );
1050     return false;
1051   }
1052
1053 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
1054   if ( _aName != aName )
1055   {
1056    try
1057    {
1058      _aName=aName;
1059      aBoundary=myHomardGen->CreateBoundaryDi(CORBA::string_dup(_aName.toStdString().c_str()), aMeshName.toStdString().c_str(), aMeshFile.toStdString().c_str());
1060      _parent->AddBoundaryDi(_aName);
1061      aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str());
1062    }
1063    catch( SALOME::SALOME_Exception& S_ex )
1064    {
1065       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1066                                 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
1067       return false;
1068    }
1069   }
1070
1071 // Les groupes
1072   AssocieLesGroupes();
1073
1074   //HOMARD_UTILS::updateObjBrowser();
1075   return true;
1076 }
1077
1078
1079 // ------------------------------------------------------------------------
1080 void SMESH_CreateBoundaryDi::PushOnOK()
1081 // ------------------------------------------------------------------------
1082 {
1083      if (PushOnApply()) this->close();
1084      if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
1085 }
1086 // ------------------------------------------------------------------------
1087 void SMESH_CreateBoundaryDi::PushOnHelp()
1088 // ------------------------------------------------------------------------
1089 {
1090   SMESH::ShowHelpFile(QString("gui_create_boundary.html"));
1091   //std::string LanguageShort = myHomardGen->GetLanguageShort();
1092   //HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort.c_str()));
1093 }
1094 // ------------------------------------------------------------------------
1095 void SMESH_CreateBoundaryDi::AssocieLesGroupes()
1096 // ------------------------------------------------------------------------
1097 {
1098   SMESHHOMARD::ListGroupType_var aSeqGroupe = new SMESHHOMARD::ListGroupType;
1099   aSeqGroupe->length(_listeGroupesBoundary.size());
1100   QStringList::const_iterator it;
1101   int i=0;
1102   for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++)
1103      aSeqGroupe[i++]=(*it).toStdString().c_str();
1104   aBoundary->SetGroups(aSeqGroupe);
1105
1106 }
1107
1108 // -------------------------------------------------
1109 void SMESH_CreateBoundaryDi::SetNewName()
1110 // --------------------------------------------------
1111 {
1112
1113   SMESHHOMARD::listeBoundarys_var  MyObjects = myHomardGen->GetAllBoundarysName();
1114   int num = 0; QString aName="";
1115   while (aName == QString("") )
1116   {
1117     aName.setNum(num+1) ;
1118     aName.insert(0, QString("Boun_")) ;
1119     for ( int i=0; i<MyObjects->length(); i++)
1120     {
1121       if ( aName ==  QString(MyObjects[i]))
1122       {
1123         num ++ ;
1124         aName = "" ;
1125         break ;
1126       }
1127    }
1128   }
1129   LEName->setText(aName);
1130 }
1131 // ------------------------------------------------------------------------
1132 void SMESH_CreateBoundaryDi::SetMeshFile()
1133 // ------------------------------------------------------------------------
1134 {
1135   QString aMeshFile = SMESH_HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") );
1136   if (!(aMeshFile.isEmpty())) LEFileName->setText(aMeshFile);
1137 }
1138
1139 // ------------------------------------------------------------------------
1140 void SMESH_CreateBoundaryDi::setGroups (QStringList listGroup)
1141 // ------------------------------------------------------------------------
1142 {
1143     _listeGroupesBoundary = listGroup;
1144 }
1145 // ------------------------------------------------------------------------
1146 void SMESH_CreateBoundaryDi::SetFiltrage()
1147 // // ------------------------------------------------------------------------
1148 {
1149   if (!CBGroupe->isChecked()) return;
1150   if (_aCaseName.toStdString().c_str() == QString()) {
1151     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1152                               QObject::tr("HOM_BOUN_CASE") );
1153     return;
1154   }
1155
1156   SMESH_CreateListGroup *aDlg = new SMESH_CreateListGroup
1157     (this, true, SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen),
1158      _aCaseName, _listeGroupesBoundary);
1159   aDlg->show();
1160 }
1161
1162 // ------------------------------------------------------------------------
1163 SMESH_EditBoundaryAn::SMESH_EditBoundaryAn( SMESHGUI_HomardAdaptDlg* parent, bool modal,
1164                                       SMESHHOMARD::HOMARD_Gen_var myHomardGen,
1165                                       QString caseName, QString Name ):
1166 // ------------------------------------------------------------------------
1167 /* Constructs a SMESH_EditBoundaryAn
1168     herite de SMESH_CreateBoundaryAn
1169 */
1170     SMESH_CreateBoundaryAn(parent, myHomardGen, caseName)
1171 {
1172     MESSAGE("Debut de SMESH_EditBoundaryAn pour " << Name.toStdString().c_str());
1173     setWindowTitle(QObject::tr("HOM_BOUN_A_EDIT_WINDOW_TITLE"));
1174     _Name=Name;
1175     aBoundaryAn = myHomardGen->GetBoundary(_Name.toStdString().c_str());
1176     InitValEdit();
1177 }
1178 // ------------------------------------------------------------------------
1179 SMESH_EditBoundaryAn::~SMESH_EditBoundaryAn()
1180 // ------------------------------------------------------------------------
1181 {
1182     // no need to delete child widgets, Qt does it all for us
1183 }
1184 // ------------------------------------------------------------------------
1185 void SMESH_EditBoundaryAn::InitValEdit()
1186 // ------------------------------------------------------------------------
1187 {
1188   LEName->setText(_Name);
1189   LEName->setReadOnly(true);
1190   _Type = aBoundaryAn->GetType();
1191   MESSAGE("_Type : "<<_Type);
1192   InitValBoundaryAnLimit();
1193   if (_aCaseName != QString("")) InitValBoundaryAn();
1194   switch (_Type)
1195   {
1196     case 1 : // il s agit d un cylindre
1197     {
1198       InitValBoundaryAnCylindre();
1199       SetCylinder();
1200       break;
1201     }
1202     case 2: // il s agit d une sphere
1203     {
1204       InitValBoundaryAnSphere();
1205       SetSphere();
1206       break;
1207     }
1208     case 3: // il s agit d un cone defini par un axe et un angle
1209     {
1210       InitValBoundaryAnConeA();
1211       SetConeA();
1212       break;
1213     }
1214     case 4: // il s agit d un cone defini par les 2 rayons
1215     {
1216       InitValBoundaryAnConeR();
1217       SetConeR();
1218       break;
1219     }
1220     case 5: // il s agit d un tore
1221     {
1222       InitValBoundaryAnTore();
1223       SetTore();
1224       break;
1225     }
1226   };
1227 }
1228 // ------------------------------------------------------------------------
1229 void SMESH_EditBoundaryAn::InitValBoundaryAnLimit()
1230 // ------------------------------------------------------------------------
1231 {
1232   SMESHHOMARD::double_array_var  mesCoordLimits = aBoundaryAn->GetLimit();
1233   ASSERT(mesCoordLimits->length() == 3 );
1234   _Xincr=mesCoordLimits[0];
1235   _Yincr=mesCoordLimits[1];
1236   _Zincr=mesCoordLimits[2];
1237 }
1238 // ------------------------------------------------------------------------
1239 void SMESH_EditBoundaryAn::InitValBoundaryAnCylindre()
1240 // ------------------------------------------------------------------------
1241 {
1242   SMESHHOMARD::double_array_var  mesCoordBoundary = aBoundaryAn->GetCoords();
1243   ASSERT(mesCoordBoundary->length() == 7 );
1244   _BoundaryAnXcentre=mesCoordBoundary[0];
1245   _BoundaryAnYcentre=mesCoordBoundary[1];
1246   _BoundaryAnZcentre=mesCoordBoundary[2];
1247   _BoundaryAnXaxis=mesCoordBoundary[3];
1248   _BoundaryAnYaxis=mesCoordBoundary[4];
1249   _BoundaryAnZaxis=mesCoordBoundary[5];
1250   _BoundaryAnRayon=mesCoordBoundary[6];
1251 }
1252 // ------------------------------------------------------------------------
1253 void SMESH_EditBoundaryAn::InitValBoundaryAnSphere()
1254 // ------------------------------------------------------------------------
1255 {
1256   SMESHHOMARD::double_array_var  mesCoordBoundary = aBoundaryAn->GetCoords();
1257   ASSERT(mesCoordBoundary->length() == 4 );
1258   _BoundaryAnXcentre=mesCoordBoundary[0];
1259   _BoundaryAnYcentre=mesCoordBoundary[1];
1260   _BoundaryAnZcentre=mesCoordBoundary[2];
1261   _BoundaryAnRayon=mesCoordBoundary[3];
1262 }
1263 // ------------------------------------------------------------------------
1264 void SMESH_EditBoundaryAn::InitValBoundaryAnConeA()
1265 // ------------------------------------------------------------------------
1266 {
1267   SMESHHOMARD::double_array_var  mesCoordBoundary = aBoundaryAn->GetCoords();
1268   ASSERT(mesCoordBoundary->length() == 7 );
1269   _BoundaryAnXaxisCone=mesCoordBoundary[0];
1270   _BoundaryAnYaxisCone=mesCoordBoundary[1];
1271   _BoundaryAnZaxisCone=mesCoordBoundary[2];
1272   _BoundaryAngle=mesCoordBoundary[3];
1273   _BoundaryAnXorigCone=mesCoordBoundary[4];
1274   _BoundaryAnYorigCone=mesCoordBoundary[5];
1275   _BoundaryAnZorigCone=mesCoordBoundary[6];
1276   convertRayonAngle(-1) ;
1277 }
1278 // ------------------------------------------------------------------------
1279 void SMESH_EditBoundaryAn::InitValBoundaryAnConeR()
1280 // ------------------------------------------------------------------------
1281 {
1282   SMESHHOMARD::double_array_var  mesCoordBoundary = aBoundaryAn->GetCoords();
1283   ASSERT(mesCoordBoundary->length() == 8 );
1284   _BoundaryAnXcone1=mesCoordBoundary[0];
1285   _BoundaryAnYcone1=mesCoordBoundary[1];
1286   _BoundaryAnZcone1=mesCoordBoundary[2];
1287   _BoundaryAnRayon1=mesCoordBoundary[3];
1288   _BoundaryAnXcone2=mesCoordBoundary[4];
1289   _BoundaryAnYcone2=mesCoordBoundary[5];
1290   _BoundaryAnZcone2=mesCoordBoundary[6];
1291   _BoundaryAnRayon2=mesCoordBoundary[7];
1292   convertRayonAngle(1) ;
1293 }
1294 // ------------------------------------------------------------------------
1295 void SMESH_EditBoundaryAn::InitValBoundaryAnTore()
1296 // ------------------------------------------------------------------------
1297 {
1298   SMESHHOMARD::double_array_var  mesCoordBoundary = aBoundaryAn->GetCoords();
1299   ASSERT(mesCoordBoundary->length() == 8 );
1300   _BoundaryAnXcentre=mesCoordBoundary[0];
1301   _BoundaryAnYcentre=mesCoordBoundary[1];
1302   _BoundaryAnZcentre=mesCoordBoundary[2];
1303   _BoundaryAnXaxis=mesCoordBoundary[3];
1304   _BoundaryAnYaxis=mesCoordBoundary[4];
1305   _BoundaryAnZaxis=mesCoordBoundary[5];
1306   _BoundaryAnRayon1=mesCoordBoundary[6];
1307   _BoundaryAnRayon2=mesCoordBoundary[7];
1308 }
1309 // ------------------------------------------------------------------------
1310 void SMESH_EditBoundaryAn::SetCylinder()
1311 // ------------------------------------------------------------------------
1312 {
1313   gBCylindre->setVisible(1);
1314   gBSphere->setVisible(0);
1315   gBCone->setVisible(0);
1316   gBTore->setVisible(0);
1317   RBCylindre->setChecked(1);
1318   _Type=1;
1319   RBSphere->setDisabled(true);
1320   RBCone->setDisabled(true);
1321   RBTore->setDisabled(true);
1322
1323   SpinBox_Xcent->setValue(_BoundaryAnXcentre);
1324   SpinBox_Ycent->setValue(_BoundaryAnYcentre);
1325   SpinBox_Zcent->setValue(_BoundaryAnZcentre);
1326
1327   SpinBox_Xaxis->setValue(_BoundaryAnXaxis);
1328   SpinBox_Yaxis->setValue(_BoundaryAnYaxis);
1329   SpinBox_Zaxis->setValue(_BoundaryAnZaxis);
1330
1331
1332   SpinBox_Xaxis->setSingleStep(0.1);
1333   SpinBox_Xcentre->setSingleStep(_Xincr);
1334   SpinBox_Yaxis->setSingleStep(0.1);
1335   SpinBox_Ycentre->setSingleStep(_Yincr);
1336   SpinBox_Zaxis->setSingleStep(0.1);
1337   SpinBox_Zcentre->setSingleStep(_Zincr);
1338 // Rayon
1339   SpinBox_Radius->setValue(_BoundaryAnRayon);
1340   SpinBox_Radius->setSingleStep(_BoundaryAnRayon/10.);
1341 //
1342   adjustSize();
1343 }
1344 // ------------------------------------------------------------------------
1345 void SMESH_EditBoundaryAn::SetSphere()
1346 // ------------------------------------------------------------------------
1347 {
1348   gBCylindre->setVisible(0);
1349   gBSphere->setVisible(1);
1350   RBSphere->setChecked(1);
1351   gBCone->setVisible(0);
1352   gBTore->setVisible(0);
1353   RBCylindre->setDisabled(true);
1354   RBCone->setDisabled(true);
1355   RBTore->setDisabled(true);
1356   _Type=2 ;
1357
1358   SpinBox_Xcentre->setValue(_BoundaryAnXcentre);
1359   if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); }
1360   else             { SpinBox_Xcentre->setSingleStep(1) ; }
1361
1362   SpinBox_Ycentre->setValue(_BoundaryAnYcentre);
1363   if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); }
1364   else             { SpinBox_Ycentre->setSingleStep(1) ; }
1365
1366   SpinBox_Zcentre->setValue(_BoundaryAnZcentre);
1367   if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); }
1368   else             { SpinBox_Zcentre->setSingleStep(1);}
1369
1370   SpinBox_Rayon->setValue(_BoundaryAnRayon);
1371 //
1372   adjustSize();
1373 }
1374 // ------------------------------------------------------------------------
1375 void SMESH_EditBoundaryAn::SetConeA()
1376 // ------------------------------------------------------------------------
1377 {
1378   gBCylindre->setVisible(0);
1379   gBSphere->setVisible(0);
1380   gBCone->setVisible(1);
1381   RBCone->setChecked(1);
1382   gBTore->setVisible(0);
1383   RB_Def_angle->setChecked(1);
1384   RBCylindre->setDisabled(true);
1385   RBSphere->setDisabled(true);
1386   RBTore->setDisabled(true);
1387   _Type=3;
1388 //
1389   TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0));
1390   SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
1391   TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0));
1392   SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
1393   TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0));
1394   SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
1395 //
1396   TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0));
1397   SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
1398   TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0));
1399   SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
1400   TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0));
1401   SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
1402 //
1403   TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0));
1404   SpinBox_Cone_V1->setValue(_BoundaryAngle);
1405   SpinBox_Cone_V1->setSingleStep(1.);
1406   SpinBox_Cone_V1->setMaximum(90.);
1407 //
1408   TLCone_V2->setVisible(0);
1409   SpinBox_Cone_V2->setVisible(0);
1410 //
1411   adjustSize();
1412 }
1413 // ------------------------------------------------------------------------
1414 void SMESH_EditBoundaryAn::SetConeR()
1415 // ------------------------------------------------------------------------
1416 {
1417   gBCylindre->setVisible(0);
1418   gBSphere->setVisible(0);
1419   gBCone->setVisible(1);
1420   gBTore->setVisible(0);
1421   RBCone->setChecked(1);
1422   RB_Def_radius->setChecked(1);
1423   RBCylindre->setDisabled(true);
1424   RBSphere->setDisabled(true);
1425   RBTore->setDisabled(true);
1426   _Type=4;
1427 //
1428   TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0));
1429   SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
1430   TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0));
1431   SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
1432   TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0));
1433   SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
1434 //
1435   TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0));
1436   SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
1437   SpinBox_Cone_V1->setMaximum(100000.*_DMax);
1438   SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
1439 //
1440   TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0));
1441   SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
1442   TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0));
1443   SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
1444   TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0));
1445   SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
1446 //
1447   TLCone_V2->setVisible(1);
1448   SpinBox_Cone_V2->setVisible(1);
1449   TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0));
1450   SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
1451 //
1452   adjustSize();
1453 }
1454 // ------------------------------------------------------------------------
1455 void SMESH_EditBoundaryAn::SetTore()
1456 // ------------------------------------------------------------------------
1457 {
1458   gBCylindre->setVisible(0);
1459   gBSphere->setVisible(0);
1460   gBCone->setVisible(0);
1461   gBTore->setVisible(1);
1462   RBTore->setChecked(1);
1463   _Type=5;
1464   RBCylindre->setDisabled(true);
1465   RBSphere->setDisabled(true);
1466   RBCone->setDisabled(true);
1467
1468   SpinBoxToreXcent->setValue(_BoundaryAnXcentre);
1469   SpinBoxToreYcent->setValue(_BoundaryAnYcentre);
1470   SpinBoxToreZcent->setValue(_BoundaryAnZcentre);
1471
1472   SpinBoxToreXaxe->setValue(_BoundaryAnXaxis);
1473   SpinBoxToreYaxe->setValue(_BoundaryAnYaxis);
1474   SpinBoxToreZaxe->setValue(_BoundaryAnZaxis);
1475
1476
1477   SpinBoxToreXaxe->setSingleStep(0.1);
1478   SpinBoxToreXcent->setSingleStep(_Xincr);
1479   SpinBoxToreYaxe->setSingleStep(0.1);
1480   SpinBoxToreYcent->setSingleStep(_Yincr);
1481   SpinBoxToreZaxe->setSingleStep(0.1);
1482   SpinBoxToreZcent->setSingleStep(_Zincr);
1483 // Rayon de revolution
1484   SpinBoxToreRRev->setValue(_BoundaryAnRayon1);
1485   SpinBoxToreRRev->setSingleStep(_BoundaryAnRayon1/10.);
1486 // Rayon primaire
1487   SpinBoxToreRPri->setValue(_BoundaryAnRayon2);
1488   SpinBoxToreRPri->setSingleStep(_BoundaryAnRayon2/10.);
1489 //
1490   adjustSize();
1491 }
1492 // ---------------------------------------------------
1493 bool SMESH_EditBoundaryAn::CreateOrUpdateBoundaryAn()
1494 //----------------------------------------------------
1495 //  Mise a jour des attributs de la BoundaryAn
1496 {
1497   switch (_Type)
1498   {
1499     case 1 : // il s agit d un cylindre
1500     {
1501       aBoundaryAn->SetCylinder(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
1502       break;
1503     }
1504     case 2 : // il s agit d une sphere
1505     {
1506       aBoundaryAn->SetSphere(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
1507       break;
1508     }
1509     case 3 : // il s agit d un cone defini par un axe et un angle
1510     {
1511       aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_Name.toStdString().c_str()), \
1512       _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
1513       _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
1514       break;
1515     }
1516     case 4 : // il s agit d un cone defini par les 2 rayons
1517     {
1518       aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_Name.toStdString().c_str()), \
1519         _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
1520         _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
1521       break;
1522     }
1523     case 5 : // il s agit d un tore
1524     {
1525       aBoundaryAn->SetTorus(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon1, _BoundaryAnRayon2 );
1526       break;
1527     }
1528   }
1529   if (Chgt) myHomardGen->InvalideBoundary(_Name.toStdString().c_str());
1530   //HOMARD_UTILS::updateObjBrowser();
1531   return true;
1532 }
1533
1534 // --------------------------------------------------------------------------------------
1535 /* Constructs a SMESH_EditBoundaryCAO
1536     herite de SMESH_CreateBoundaryCAO
1537 */
1538 // --------------------------------------------------------------------------------------
1539 SMESH_EditBoundaryCAO::SMESH_EditBoundaryCAO( SMESHGUI_HomardAdaptDlg* parent, bool modal,
1540                                               SMESHHOMARD::HOMARD_Gen_var myHomardGen,
1541                                               QString caseName, QString Name):
1542     SMESH_CreateBoundaryCAO(parent, modal, myHomardGen, caseName, Name)
1543 {
1544     MESSAGE("Debut de Boundary pour " << Name.toStdString().c_str());
1545     setWindowTitle(QObject::tr("HOM_BOUN_C_EDIT_WINDOW_TITLE"));
1546     try
1547     {
1548      aBoundary=myHomardGen->GetBoundary(CORBA::string_dup(_aName.toStdString().c_str()));
1549      if (caseName==QString("")) { _aCaseName=aBoundary->GetCaseCreation();}
1550      InitValEdit();
1551     }
1552     catch( SALOME::SALOME_Exception& S_ex )
1553     {
1554       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1555                                 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
1556       return;
1557     }
1558
1559     SMESHHOMARD::ListGroupType_var maListe = aBoundary->GetGroups();
1560     for ( int i = 0; i < maListe->length(); i++ )
1561        _listeGroupesBoundary << QString(maListe[i]);
1562
1563 }
1564 // ------------------------------
1565 SMESH_EditBoundaryCAO::~SMESH_EditBoundaryCAO()
1566 // ------------------------------
1567 {
1568 }
1569 // ------------------------------
1570 void SMESH_EditBoundaryCAO::InitValEdit()
1571 // ------------------------------
1572 {
1573       LEName->setText(_aName);
1574       LEName->setReadOnly(true);
1575
1576       QString aDataFile = aBoundary->GetDataFile();
1577       LEFileName->setText(aDataFile);
1578       LEFileName->setReadOnly(1);
1579       PushFichier->setVisible(0);
1580 //
1581       adjustSize();
1582 }
1583 // ------------------------------
1584 bool SMESH_EditBoundaryCAO::PushOnApply()
1585 // ------------------------------
1586 {
1587      return true;
1588 }
1589 // ------------------------------------------------------------------------
1590 void SMESH_EditBoundaryCAO::SetFiltrage()
1591 // // ------------------------------------------------------------------------
1592 {
1593   if (!CBGroupe->isChecked()) return;
1594   if (_aCaseName.toStdString().c_str() == QString())
1595   {
1596     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1597                               QObject::tr("HOM_BOUN_CASE") );
1598     return;
1599   }
1600   SMESHHOMARD::HOMARD_Cas_var monCas= myHomardGen->GetCase(_aCaseName.toStdString().c_str());
1601   SMESHHOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
1602
1603   SMESH_EditListGroupCAO *aDlg = new SMESH_EditListGroupCAO
1604     (this, true, SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen),
1605      _aCaseName, _listeGroupesBoundary) ;
1606   aDlg->show();
1607 }
1608
1609 // -------------------------------------------------------------------------------------------------------------------------------------
1610 SMESH_EditBoundaryDi::SMESH_EditBoundaryDi( SMESHGUI_HomardAdaptDlg* parent, bool modal,
1611                                       SMESHHOMARD::HOMARD_Gen_var myHomardGen,
1612                                       QString caseName, QString Name):
1613 // -------------------------------------------------------------------------------------------------------------------------------------
1614 /* Constructs a SMESH_EditBoundaryDi
1615     herite de SMESH_CreateBoundaryDi
1616 */
1617   SMESH_CreateBoundaryDi(parent, modal, myHomardGen, caseName, Name)
1618 {
1619     MESSAGE("Debut de Boundary pour " << Name.toStdString().c_str());
1620     setWindowTitle(QObject::tr("HOM_BOUN_D_EDIT_WINDOW_TITLE"));
1621     try
1622     {
1623      aBoundary=myHomardGen->GetBoundary(CORBA::string_dup(_aName.toStdString().c_str()));
1624      if (caseName==QString("")) { _aCaseName=aBoundary->GetCaseCreation();}
1625      InitValEdit();
1626     }
1627     catch( SALOME::SALOME_Exception& S_ex )
1628     {
1629       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1630                                 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
1631       return;
1632     }
1633
1634     SMESHHOMARD::ListGroupType_var maListe = aBoundary->GetGroups();
1635     for ( int i = 0; i < maListe->length(); i++ )
1636        _listeGroupesBoundary << QString(maListe[i]);
1637
1638 }
1639 // ------------------------------
1640 SMESH_EditBoundaryDi::~SMESH_EditBoundaryDi()
1641 // ------------------------------
1642 {
1643 }
1644 // ------------------------------
1645 void SMESH_EditBoundaryDi::InitValEdit()
1646 // ------------------------------
1647 {
1648       LEName->setText(_aName);
1649       LEName->setReadOnly(true);
1650
1651       QString aDataFile = aBoundary->GetDataFile();
1652       LEFileName->setText(aDataFile);
1653       LEFileName->setReadOnly(1);
1654       PushFichier->setVisible(0);
1655 //
1656       adjustSize();
1657 }
1658 // ------------------------------
1659 bool SMESH_EditBoundaryDi::PushOnApply()
1660 // ------------------------------
1661 {
1662      return true;
1663 }
1664 // ------------------------------------------------------------------------
1665 void SMESH_EditBoundaryDi::SetFiltrage()
1666 // // ------------------------------------------------------------------------
1667 {
1668   if (!CBGroupe->isChecked()) return;
1669   if (_aCaseName.toStdString().c_str() == QString())
1670   {
1671     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
1672                               QObject::tr("HOM_BOUN_CASE") );
1673     return;
1674   }
1675   SMESHHOMARD::HOMARD_Cas_var monCas= myHomardGen->GetCase(_aCaseName.toStdString().c_str());
1676   SMESHHOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
1677
1678   SMESH_EditListGroup *aDlg = new SMESH_EditListGroup
1679     (this, true, SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen),
1680      _aCaseName, _listeGroupesBoundary);
1681   aDlg->show();
1682 }