Salome HOME
Merge branch 'master' into gni/adaptation
[modules/smesh.git] / src / ADAPTGUI / MonCreateZone.cxx
1 // Copyright (C) 2011-2020  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 "MonCreateZone.h"
21 #include "MonCreateHypothesis.h"
22
23 #include <QFileDialog>
24 #include <QMessageBox>
25
26 #include "SalomeApp_Tools.h"
27 #include "HOMARDGUI_Utils.h"
28 #include "HomardQtCommun.h"
29 #include <utilities.h>
30
31 #include <SUIT_Desktop.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_Session.h>
35 #include <SUIT_ViewManager.h>
36
37 using namespace std;
38
39 // ----------------------------------------------------------------------
40 MonCreateZone::MonCreateZone(MonCreateHypothesis* parent, bool modal,
41                              ADAPT::ADAPT_Gen_var myAdaptGen0,
42                              QString caseName) :
43 // ----------------------------------------------------------------------
44 /* Constructs a MonCreateZone
45    appele pour une vraie creation
46    initialise une boite et non une sphere
47 */
48     QDialog(0), Ui_CreateZone(),
49     _parent(parent),
50     _Name (""),
51     _aCaseName(caseName),
52     _Orient(0),
53     _Type(2),
54     _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0),
55     _ZoneXcentre(0), _ZoneYcentre(0), _ZoneZcentre(0), _ZoneRayon(0),
56     _Xmin(0), _Xmax(0), _Xincr(0), _Ymin(0), _Ymax(0), _Yincr(0), _Zmin(0), _Zmax(0), _Zincr(0),
57     _ZoneXmin(0), _ZoneXmax(0), _ZoneYmin(0), _ZoneYmax(0), _ZoneZmin(0), _ZoneZmax(0),
58     _Xaxis(0), _Yaxis(0), _Zaxis(0), _RayonInt(0), _Haut(0),
59     _ZoneXaxis(0), _ZoneYaxis(0), _ZoneZaxis(0), _ZoneRayonInt(0), _ZoneHaut(0),
60     _DMax(0),
61     Chgt (false)
62     {
63       MESSAGE("Constructeur") ;
64       myAdaptGen=ADAPT::ADAPT_Gen::_duplicate(myAdaptGen0) ;
65       setupUi(this) ;
66       setModal(modal) ;
67       InitConnect( ) ;
68
69       SetNewName() ;
70       InitValZone() ;           // Cherche les valeurs de la boite englobante le maillage
71       InitMinMax() ;            // Initialise les bornes des boutons
72       SetBox() ;                // Propose une boite en premier choix
73
74     }
75 // ----------------------------------------------------------------------
76 MonCreateZone::MonCreateZone(MonCreateHypothesis* parent,
77                              ADAPT::ADAPT_Gen_var myAdaptGen0,
78                              QString caseName):
79 // ----------------------------------------------------------------------
80 // Constructeur appele par MonEditZone
81 //
82     QDialog(0), Ui_CreateZone(),
83      myAdaptGen(myAdaptGen0),
84     _parent(parent),
85     _Name (""),
86     _aCaseName(caseName),
87     _Orient(0),
88     _Type(2),
89     _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0),
90     _ZoneXcentre(0), _ZoneYcentre(0), _ZoneZcentre(0), _ZoneRayon(0),
91     _ZoneXmin(0), _ZoneXmax(0), _ZoneYmin(0), _ZoneYmax(0), _ZoneZmin(0), _ZoneZmax(0),
92     _Xaxis(0), _Yaxis(0), _Zaxis(0), _RayonInt(0), _Haut(0),
93     _ZoneXaxis(0), _ZoneYaxis(0), _ZoneZaxis(0), _ZoneRayonInt(0), _ZoneHaut(0),
94     // Pour affichage lors de l edition d une Zone sans nom de Cas
95     _Xmin(1), _Xmax(1), _Xincr(1), _Ymin(1), _Ymax(1), _Yincr(1), _Zmin(1), _Zmax(1), _Zincr(1),
96     _DMax(1),
97     Chgt (false)
98     {
99   //  MESSAGE("Debut de  MonCreateZone")
100       setupUi(this) ;
101
102       setModal(true) ;
103       InitConnect() ;
104     }
105
106 // ------------------------------------------------------------------------
107 MonCreateZone::~MonCreateZone()
108 // ------------------------------------------------------------------------
109 {
110     // no need to delete child widgets, Qt does it all for us
111 }
112 // ------------------------------------------------------------------------
113 void MonCreateZone::InitConnect()
114 // ------------------------------------------------------------------------
115 {
116     connect( RBBox,        SIGNAL(clicked()) , this, SLOT(SetBox()) ) ;
117     connect( RBSphere,     SIGNAL(clicked()) , this, SLOT(SetSphere()) ) ;
118     connect( RBCylinder,   SIGNAL(clicked()) , this, SLOT(SetCylinder()) ) ;
119     connect( RBPipe,       SIGNAL(clicked()) , this, SLOT(SetPipe()) ) ;
120     connect( buttonOk,     SIGNAL( pressed() ), this, SLOT( PushOnOK() ) ) ;
121     connect( buttonApply,  SIGNAL( pressed() ), this, SLOT( PushOnApply() ) ) ;
122     connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) ) ;
123     connect( buttonHelp,   SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) ) ;
124 }
125 // ------------------------------------------------------------------------
126 void MonCreateZone::InitValZone()
127 // ------------------------------------------------------------------------
128 {
129 //
130 //  1. Les coordonnees extremes du maillage
131 //
132   if (_aCaseName == QString("")) { return; }
133
134   ADAPT::HOMARD_Cas_var aCas = myAdaptGen->GetCase(_aCaseName.toStdString().c_str()) ;
135   ADAPT::extrema_var  MesExtremes = aCas->GetBoundingBox() ;
136   int num = MesExtremes->length() ;
137   ASSERT(num == 10) ;
138   _Xmin=MesExtremes[0]; _Xmax=MesExtremes[1]; _Xincr=MesExtremes[2];
139   _Ymin=MesExtremes[3]; _Ymax=MesExtremes[4]; _Yincr=MesExtremes[5];
140   _Zmin=MesExtremes[6]; _Zmax=MesExtremes[7]; _Zincr=MesExtremes[8];
141   _DMax=MesExtremes[9];
142   if ( _Xincr < 0 ) { _Orient = 2 ; }
143   else if ( _Yincr < 0 ) { _Orient = 3 ; }
144   else if ( _Zincr < 0 ) { _Orient = 1 ; }
145   MESSAGE ("_Xmin : " << _Xmin << " _Xmax : " << _Xmax << " _Xincr : " << _Xincr ) ;
146   MESSAGE ("_Ymin : " << _Ymin << " _Ymax : " << _Ymax << " _Yincr : " << _Yincr ) ;
147   MESSAGE ("_Zmin : " << _Zmin << " _Zmax : " << _Zmax << " _Zincr : " << _Zincr) ;
148   MESSAGE ("_DMax : " << _DMax) ;
149   MESSAGE ("_Orient : " << _Orient) ;
150 //  2. Caracteristiques des zones
151 // en X
152   if ( _Xincr < 0 )
153   {
154     _ZoneXmin = _Xmin;
155     _ZoneXmax = _Xmax;
156   }
157   else
158   {
159     _ZoneXmin = _Xmin - _Xincr;
160     _ZoneXmax = _Xmax + _Xincr;
161   }
162   _Xcentre=(_Xmin + _Xmax)/2.;
163 // en Y
164   if ( _Yincr < 0 )
165   {
166     _ZoneYmin = _Ymin;
167     _ZoneYmax = _Ymax;
168   }
169   else
170   {
171     _ZoneYmin = _Ymin - _Yincr;
172     _ZoneYmax = _Ymax + _Yincr;
173   }
174   _Ycentre=(_Ymin + _Ymax)/2.;
175 // en Z
176   if ( _Zincr < 0 )
177   {
178     _ZoneZmin = _Zmin;
179     _ZoneZmax = _Zmax;
180   }
181   else
182   {
183     _ZoneZmin = _Zmin - _Zincr;
184     _ZoneZmax = _Zmax + _Zincr;
185   }
186   _Zcentre=(_Zmin + _Zmax)/2.;
187 // Rayons
188   _Rayon= _DMax/4.;
189   _RayonInt= _DMax/8.;
190 // Axe et hauteur pour cylindre et tuyau
191   _Haut= _DMax/2.;
192 // 3. Gestion des icones
193   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ;
194   QPixmap pix = resMgr->loadPixmap( "HOMARD", "boxdxyz.png" ) ;
195   if ( _Orient == 0 ) { pix = resMgr->loadPixmap( "HOMARD", "boxdxyz.png" ) ; }
196   else                { pix = resMgr->loadPixmap( "HOMARD", "boxdxy.png" ) ; }
197   QIcon IS=QIcon(pix) ;
198   RBBox->setIcon(IS) ;
199
200   if ( _Orient == 0 ) { pix = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" ) ; }
201   else                { pix = resMgr->loadPixmap( "HOMARD", "disk.png" ) ;
202                         RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0));
203                         TLXbase->setText(QApplication::translate("CreateZone", "X centre", 0));
204                         TLYbase->setText(QApplication::translate("CreateZone", "Y centre", 0));
205                         TLZbase->setText(QApplication::translate("CreateZone", "Z centre", 0)); }
206   IS=QIcon(pix) ;
207   RBCylinder->setIcon(IS) ;
208
209   if ( _Orient == 0 ) { pix = resMgr->loadPixmap( "HOMARD", "pipe.png" ) ; }
210   else                { pix = resMgr->loadPixmap( "HOMARD", "diskwithhole.png" ) ;
211                         RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0));
212                         TLXbase_p->setText(QApplication::translate("CreateZone", "X centre", 0));
213                         TLYbase_p->setText(QApplication::translate("CreateZone", "Y centre", 0));
214                         TLZbase_p->setText(QApplication::translate("CreateZone", "Z centre", 0)); }
215   IS=QIcon(pix) ;
216   RBPipe->setIcon(IS) ;
217
218   if ( _Orient == 0 ) { pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" ) ;
219                         IS=QIcon(pix) ;
220                         RBSphere->setIcon(IS) ; }
221   else                { RBSphere->setVisible(0) ; }
222 }
223
224 // ------------------------------------------------------------------------
225 void MonCreateZone::InitMinMax()
226 // ------------------------------------------------------------------------
227 {
228 // en X
229     if ( _Xincr > 0) {
230       SpinBox_Xmini->setRange(_ZoneXmin,_ZoneXmax) ;
231       SpinBox_Xmaxi->setRange(_ZoneXmin,_ZoneXmax) ;
232       SpinBox_Xmini->setSingleStep(_Xincr) ;
233       SpinBox_Xmaxi->setSingleStep(_Xincr) ;
234       SpinBox_Xcentre->setSingleStep(_Xincr) ;
235     }
236     else {
237       SpinBox_Xmini->setValue(_ZoneXmin) ;
238       SpinBox_Xmaxi->setValue(_ZoneXmax) ;
239       SpinBox_Xcentre->setValue(_Xcentre) ;
240       SpinBox_Xbase->setValue(_Xcentre) ;
241       SpinBox_Xbase_p->setValue(_Xcentre) ;
242       SpinBox_Xmini->setEnabled(false) ;
243       SpinBox_Xmaxi->setEnabled(false) ;
244       SpinBox_Xcentre->setEnabled(false) ;
245       SpinBox_Xbase->setEnabled(false) ;
246       SpinBox_Xbase_p->setEnabled(false) ;
247     }
248 // en Y
249     if ( _Yincr > 0) {
250       SpinBox_Ymini->setRange(_ZoneYmin,_ZoneYmax) ;
251       SpinBox_Ymaxi->setRange(_ZoneYmin,_ZoneYmax) ;
252       SpinBox_Ymini->setSingleStep(_Yincr) ;
253       SpinBox_Ymaxi->setSingleStep(_Yincr) ;
254       SpinBox_Ycentre->setSingleStep(_Yincr) ;
255     }
256     else {
257       SpinBox_Ymini->setValue(_ZoneYmin) ;
258       SpinBox_Ymaxi->setValue(_ZoneYmax) ;
259       SpinBox_Ycentre->setValue(_Ycentre) ;
260       SpinBox_Ybase->setValue(_Ycentre) ;
261       SpinBox_Ybase_p->setValue(_Ycentre) ;
262       SpinBox_Ymini->setEnabled(false) ;
263       SpinBox_Ymaxi->setEnabled(false) ;
264       SpinBox_Ycentre->setEnabled(false) ;
265       SpinBox_Ybase->setEnabled(false) ;
266       SpinBox_Ybase_p->setEnabled(false) ;
267     }
268 // en Z
269     if ( _Zincr > 0) {
270       SpinBox_Zmini->setRange(_ZoneZmin,_ZoneZmax) ;
271       SpinBox_Zmaxi->setRange(_ZoneZmin,_ZoneZmax) ;
272       SpinBox_Zmini->setSingleStep(_Zincr) ;
273       SpinBox_Zmaxi->setSingleStep(_Zincr) ;
274       SpinBox_Zcentre->setSingleStep(_Zincr) ;
275     }
276     else {
277       SpinBox_Zmini->setValue(_ZoneZmin) ;
278       SpinBox_Zmaxi->setValue(_ZoneZmax) ;
279       SpinBox_Zcentre->setValue(_Zcentre) ;
280       SpinBox_Zbase->setValue(_Zcentre) ;
281       SpinBox_Zbase_p->setValue(_Zcentre) ;
282       SpinBox_Zmini->setEnabled(false) ;
283       SpinBox_Zmaxi->setEnabled(false) ;
284       SpinBox_Zcentre->setEnabled(false) ;
285       SpinBox_Zbase->setEnabled(false) ;
286       SpinBox_Zbase_p->setEnabled(false) ;
287     }
288 // Rayons
289     SpinBox_Rayon->setSingleStep(_Rayon/10.) ;
290     SpinBox_Radius->setSingleStep(_Rayon/10.) ;
291     SpinBox_Radius_int->setSingleStep(_Rayon/20.) ;
292     SpinBox_Radius_ext->setSingleStep(_Rayon/10.) ;
293 // Axe et hauteur
294 // Si une coordonnee est constante, inutile de demander l'axe et la hauteur
295     if ( _Orient > 0) {
296       SpinBox_Xaxis->setVisible(0) ;
297       SpinBox_Yaxis->setVisible(0) ;
298       SpinBox_Zaxis->setVisible(0) ;
299       SpinBox_Haut->setVisible(0) ;
300       TLXaxis->setVisible(0) ;
301       TLYaxis->setVisible(0) ;
302       TLZaxis->setVisible(0) ;
303       TLHaut->setVisible(0) ;
304       SpinBox_Xaxis_p->setVisible(0) ;
305       SpinBox_Yaxis_p->setVisible(0) ;
306       SpinBox_Zaxis_p->setVisible(0) ;
307       SpinBox_Haut_p->setVisible(0) ;
308       TLXaxis_p->setVisible(0) ;
309       TLYaxis_p->setVisible(0) ;
310       TLZaxis_p->setVisible(0) ;
311       TLHaut_p->setVisible(0) ;
312     }
313     else {
314       SpinBox_Haut->setSingleStep(_Rayon/10.) ;
315       SpinBox_Haut_p->setSingleStep(_Rayon/10.) ;
316     }
317 }
318 // ------------------------------------------------------------------------
319 bool MonCreateZone::PushOnApply()
320 // ------------------------------------------------------------------------
321 // Appele lorsque l'un des boutons Ok ou Apply est presse
322 //
323 {
324   if (LEName->text().trimmed()=="")
325   {
326     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
327                               QObject::tr("HOM_ZONE_NAME") ) ;
328     return false;
329   }
330
331   switch (_Type)
332   {
333     case 11 : // il s agit d un rectangle
334     { }
335     case 12 : // il s agit d un rectangle
336     { }
337     case 13 : // il s agit d un rectangle
338     { }
339     case 2 : // il s agit d un parallelipipede rectangle
340     {
341       if (  (_ZoneXmin != SpinBox_Xmini->value()) ||
342             (_ZoneXmax != SpinBox_Xmaxi->value()) ||
343             (_ZoneYmin != SpinBox_Ymini->value()) ||
344             (_ZoneYmax != SpinBox_Ymaxi->value()) ||
345             (_ZoneZmin != SpinBox_Zmini->value()) ||
346             (_ZoneZmax   != SpinBox_Zmaxi->value()) )
347       {
348         Chgt = true;
349         _ZoneXmin= SpinBox_Xmini->value() ; _ZoneXmax= SpinBox_Xmaxi->value() ;
350         _ZoneYmin= SpinBox_Ymini->value() ; _ZoneYmax= SpinBox_Ymaxi->value() ;
351         _ZoneZmin= SpinBox_Zmini->value() ; _ZoneZmax= SpinBox_Zmaxi->value() ;
352       }
353       break ;
354     }
355     case 4 : // il s agit d une sphere
356     {
357       if (  (_ZoneXcentre != SpinBox_Xcentre->value()) ||
358             (_ZoneYcentre != SpinBox_Ycentre->value()) ||
359             (_ZoneZcentre != SpinBox_Zbase->value())   ||
360             (_ZoneRayon   != SpinBox_Rayon->value()) )
361       {
362         Chgt = true;
363         _ZoneXcentre=SpinBox_Xcentre->value() ;
364         _ZoneYcentre=SpinBox_Ycentre->value() ;
365         _ZoneZcentre=SpinBox_Zcentre->value() ;
366         _ZoneRayon=SpinBox_Rayon->value() ;
367       }
368       break ;
369     }
370     case 31 : // il s agit d un disque issu d'un cylindre
371     { }
372     case 32 : // il s agit d un disque issu d'un cylindre
373     { }
374     case 33 : // il s agit d un disque issu d'un cylindre
375     { }
376     case 5 : // il s agit d un cylindre
377     {
378       if (  (_ZoneXcentre != SpinBox_Xbase->value())  ||
379             (_ZoneYcentre != SpinBox_Ybase->value())  ||
380             (_ZoneZcentre != SpinBox_Zbase->value())  ||
381             (_ZoneRayon   != SpinBox_Radius->value()) ||
382             (_ZoneHaut    != SpinBox_Haut->value())   ||
383             (_ZoneXaxis   != SpinBox_Xaxis->value())  ||
384             (_ZoneYaxis   != SpinBox_Yaxis->value())  ||
385             (_ZoneZaxis   != SpinBox_Zaxis->value()) )
386       {
387         Chgt = true;
388         _ZoneXcentre=SpinBox_Xbase->value() ;
389         _ZoneYcentre=SpinBox_Ybase->value() ;
390         _ZoneZcentre=SpinBox_Zbase->value() ;
391         _ZoneXaxis=SpinBox_Xaxis->value() ;
392         _ZoneYaxis=SpinBox_Yaxis->value() ;
393         _ZoneZaxis=SpinBox_Zaxis->value() ;
394         _ZoneRayon=SpinBox_Radius->value() ;
395         _ZoneHaut=SpinBox_Haut->value() ;
396       }
397       break ;
398     }
399     case 61 : // il s agit d un disque avec trou
400     { }
401     case 62 : // il s agit d un disque avec trou
402     { }
403     case 63 : // il s agit d un disque avec trou
404     { }
405     case 7 : // il s agit d un tuyau
406     {
407       if (  (_ZoneXcentre  != SpinBox_Xbase_p->value())  ||
408             (_ZoneYcentre  != SpinBox_Ybase_p->value())  ||
409             (_ZoneZcentre  != SpinBox_Zbase_p->value())  ||
410             (_ZoneRayonInt != SpinBox_Radius_int->value()) ||
411             (_ZoneRayon    != SpinBox_Radius_ext->value()) ||
412             (_ZoneHaut     != SpinBox_Haut_p->value())   ||
413             (_ZoneXaxis    != SpinBox_Xaxis_p->value())  ||
414             (_ZoneYaxis    != SpinBox_Yaxis_p->value())  ||
415             (_ZoneZaxis    != SpinBox_Zaxis_p->value()) )
416       {
417         Chgt = true;
418         _ZoneXcentre=SpinBox_Xbase_p->value() ;
419         _ZoneYcentre=SpinBox_Ybase_p->value() ;
420         _ZoneZcentre=SpinBox_Zbase_p->value() ;
421         _ZoneXaxis=SpinBox_Xaxis_p->value() ;
422         _ZoneYaxis=SpinBox_Yaxis_p->value() ;
423         _ZoneZaxis=SpinBox_Zaxis_p->value() ;
424         _ZoneRayonInt=SpinBox_Radius_int->value() ;
425         _ZoneRayon=SpinBox_Radius_ext->value() ;
426         _ZoneHaut=SpinBox_Haut_p->value() ;
427       }
428       break ;
429    }
430   }
431
432 // Controles
433 // Pour un rectangle ou un parallelepipede :
434   if ( ( _Type >= 11 && _Type <= 13 ) || _Type == 2 )
435   {
436     if ((_ZoneXmin >= _ZoneXmax) && (_Xincr > 0)) {
437       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
438                                 QObject::tr("HOM_ZONE_LIMIT").arg("X") ) ;
439       return false; }
440
441     if  ((_ZoneYmin >= _ZoneYmax) && (_Yincr > 0)) {
442       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
443                                 QObject::tr("HOM_ZONE_LIMIT").arg("Y") ) ;
444       return false; }
445
446     if ((_ZoneZmin >= _ZoneZmax) && (_Zincr > 0)) {
447       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
448                                 QObject::tr("HOM_ZONE_LIMIT").arg("Z") ) ;
449       return false; }
450   }
451 // L'axe pour un cylindre ou un tuyau :
452   if ( _Type == 5 || _Type == 7 )
453   {
454     double daux = _ZoneXaxis*_ZoneXaxis + _ZoneYaxis*_ZoneYaxis + _ZoneZaxis*_ZoneZaxis ;
455     if ( daux < 0.0000001 )
456     {
457       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
458                                 QObject::tr("HOM_AXE") );
459       return false;
460     }
461   }
462 // Rayons pour disque avec trou ou un tuyau :
463   if ( ( _Type >= 61 && _Type <= 63 ) || _Type == 7 )
464   {
465     if ( _ZoneRayonInt >= _ZoneRayon )
466     {
467       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
468                                 QObject::tr("HOM_ZONE_RAYON") );
469       return false;
470     }
471   }
472 //
473 // Création ou mise Ã  jour de la zone
474 //
475   bool bOK = CreateOrUpdateZone() ;
476
477   if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; }
478
479   return bOK;
480
481 }
482 // ---------------------------------------------------
483 bool MonCreateZone::CreateOrUpdateZone()
484 //----------------------------------------------------
485 //  Creation de la zone
486 {
487   MESSAGE("Debut de CreateOrUpdateZone avec _Type ="<<_Type<<", _Name ="<<_Name.toStdString().c_str()<<" et LEName ="<<LEName->text().trimmed().toStdString().c_str());
488 //
489   if (_Name != LEName->text().trimmed())
490   {
491     _Name = LEName->text().trimmed() ;
492     try
493     {
494       switch (_Type)
495       {
496         case 11 : // il s agit d un rectangle, dans le plan (X,Y)
497         { aZone = myAdaptGen->CreateZoneBox2D(CORBA::string_dup(_Name.toStdString().c_str()), \
498           _ZoneXmin, _ZoneXmax, _ZoneYmin, _ZoneYmax, _Orient );
499           break;
500         }
501         case 12 : // il s agit d un rectangle, dans le plan (Y,Z)
502         { aZone = myAdaptGen->CreateZoneBox2D(CORBA::string_dup(_Name.toStdString().c_str()), \
503           _ZoneYmin, _ZoneYmax, _ZoneZmin, _ZoneZmax, _Orient );
504           break;
505         }
506         case 13 : // il s agit d un rectangle, dans le plan (Z,X)
507         { aZone = myAdaptGen->CreateZoneBox2D(CORBA::string_dup(_Name.toStdString().c_str()), \
508           _ZoneZmin, _ZoneZmax, _ZoneXmin, _ZoneXmax, _Orient );
509           break;
510         }
511         case 2 : // il s agit d un parallelepipede
512         { aZone = myAdaptGen->CreateZoneBox(CORBA::string_dup(_Name.toStdString().c_str()), \
513           _ZoneXmin, _ZoneXmax, _ZoneYmin, _ZoneYmax, _ZoneZmin, _ZoneZmax );
514           break;
515         }
516         case 4 : // il s agit d une sphere
517         { aZone = myAdaptGen->CreateZoneSphere(CORBA::string_dup(_Name.toStdString().c_str()), \
518           _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneRayon );
519           break;
520         }
521         case 31 : // il s agit d un disque issu d'un cylindre, dans le plan (X,Y)
522         { aZone = myAdaptGen->CreateZoneDisk(CORBA::string_dup(_Name.toStdString().c_str()), \
523           _ZoneXcentre, _ZoneYcentre, _ZoneRayon, _Orient );
524           break;
525           }
526         case 32 : // il s agit d un disque issu d'un cylindre, dans le plan (Y,Z)
527         { aZone = myAdaptGen->CreateZoneDisk(CORBA::string_dup(_Name.toStdString().c_str()), \
528           _ZoneYcentre, _ZoneZcentre, _ZoneRayon, _Orient );
529           break;
530         }
531         case 33 : // il s agit d un disque issu d'un cylindre, dans le plan (Z,X)
532         { aZone = myAdaptGen->CreateZoneDisk(CORBA::string_dup(_Name.toStdString().c_str()), \
533           _ZoneZcentre, _ZoneXcentre, _ZoneRayon, _Orient );
534           break;
535         }
536         case 5 : // il s agit d un cylindre
537         { aZone = myAdaptGen->CreateZoneCylinder(CORBA::string_dup(_Name.toStdString().c_str()), \
538           _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut );
539           break;
540         }
541         case 61 : // il s agit d un disque avec trou, dans le plan (X,Y)
542         { aZone = myAdaptGen->CreateZoneDiskWithHole(CORBA::string_dup(_Name.toStdString().c_str()), \
543           _ZoneXcentre, _ZoneYcentre, _ZoneRayon, _ZoneRayonInt, _Orient );
544           break;
545         }
546         case 62 : // il s agit d un disque avec trou, dans le plan (Y,Z)
547         { aZone = myAdaptGen->CreateZoneDiskWithHole(CORBA::string_dup(_Name.toStdString().c_str()), \
548           _ZoneYcentre, _ZoneZcentre, _ZoneRayon, _ZoneRayonInt, _Orient );
549           break;
550         }
551         case 63 : // il s agit d un disque avec trou, dans le plan (Z,X)
552         { aZone = myAdaptGen->CreateZoneDiskWithHole(CORBA::string_dup(_Name.toStdString().c_str()), \
553           _ZoneZcentre, _ZoneXcentre, _ZoneRayon, _ZoneRayonInt, _Orient );
554           break;
555         }
556         case 7 : // il s agit d un tuyau
557         { aZone = myAdaptGen->CreateZonePipe(CORBA::string_dup(_Name.toStdString().c_str()), \
558           _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut, _ZoneRayonInt );
559           break;
560         }
561       }
562     }
563     catch( SALOME::SALOME_Exception& S_ex )
564     {
565       QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
566                                 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
567       return false ;
568     }
569     _parent->addZoneinTWZone(_Name) ;
570 // Mise en place des attributs
571     aZone->SetLimit(_Xincr, _Yincr, _Zincr) ;
572
573     return true;
574   }
575   else {
576     QMessageBox::warning( 0, QObject::tr("HOM_WARNING"),
577                              QObject::tr("HOM_SELECT_OBJECT_4") );
578     return false ;
579   }
580   MESSAGE("Fin de CreateOrUpdateZone");
581 }
582 // ------------------------------------------------------------------------
583 void MonCreateZone::PushOnOK()
584 // ------------------------------------------------------------------------
585 {
586     if (PushOnApply()) this->close() ;
587 }
588 // ------------------------------------------------------------------------
589 void MonCreateZone::PushOnHelp()
590 // ------------------------------------------------------------------------
591 {
592   std::string LanguageShort = myAdaptGen->GetLanguageShort();
593   HOMARD_UTILS::PushOnHelp(QString("gui_create_zone.html"), QString(""), QString(LanguageShort.c_str()));
594 }
595
596 // -----------------------------------
597 void MonCreateZone::SetNewName()
598 // -----------------------------------
599 {
600   MESSAGE("SetNewName");
601 // Recherche d'un nom par defaut qui n'existe pas encore
602
603   ADAPT::listeZones_var  MyObjects = myAdaptGen->GetAllZonesName() ;
604   int num = 0; QString aName="";
605   while (aName=="" )
606   {
607     aName.setNum(num+1) ;
608     aName.insert(0, QString("Zone_")) ;
609     for ( int i=0; i<MyObjects->length() ; i++)
610     {
611       if ( aName ==  QString(MyObjects[i]))
612       {
613         num ++ ;
614         aName = "" ;
615         break ;
616       }
617    }
618   }
619   LEName->setText(aName);
620   MESSAGE("SetNewName aName ="<<aName.toStdString().c_str());
621 }
622 // ------------------------------------------------------------------------
623 void MonCreateZone::SetBox()
624 // ------------------------------------------------------------------------
625 {
626   MESSAGE("Debut de SetBox")
627   gBBox->setVisible(1) ;
628   gBSphere->setVisible(0) ;
629   gBCylindre->setVisible(0) ;
630   gBPipe->setVisible(0) ;
631   adjustSize() ;
632   _Type=2;
633 // Sachant que l'increment est le 1/100eme de l'ecart (min/max), cela revient
634 // a initialiser la boite sur une boite 'centrale' comprise entre 2/5 et 3/5
635   if ( _Xincr > 0 ) { SpinBox_Xmini->setValue(_Xcentre-10*_Xincr) ;
636                       SpinBox_Xmaxi->setValue(_Xcentre+10*_Xincr) ; }
637   else { _Type=12 ; }
638   if ( _Yincr > 0 ) { SpinBox_Ymini->setValue(_Ycentre-10*_Yincr) ;
639                       SpinBox_Ymaxi->setValue(_Ycentre+10*_Yincr) ; }
640   else { _Type=13 ; }
641   if ( _Zincr > 0 ) { SpinBox_Zmini->setValue(_Zcentre-10*_Zincr) ;
642                       SpinBox_Zmaxi->setValue(_Zcentre+10*_Zincr) ; }
643   else { _Type=11 ; }
644   MESSAGE("Fin de SetBox")
645 }
646 // ------------------------------------------------------------------------
647 void MonCreateZone::SetSphere()
648 // ------------------------------------------------------------------------
649 {
650   MESSAGE("Debut de SetSphere")
651   gBBox->setVisible(0) ;
652   gBSphere->setVisible(1) ;
653   gBCylindre->setVisible(0) ;
654   gBPipe->setVisible(0) ;
655   adjustSize() ;
656   _Type=4;
657   SpinBox_Xcentre->setValue(_Xcentre) ;
658   SpinBox_Ycentre->setValue(_Ycentre) ;
659   SpinBox_Zcentre->setValue(_Zcentre) ;
660   SpinBox_Rayon->setValue(_Rayon) ;
661   MESSAGE("Fin de SetSphere")
662 }
663 // ------------------------------------------------------------------------
664 void MonCreateZone::SetCylinder()
665 // ------------------------------------------------------------------------
666 {
667   MESSAGE("Debut de SetCylinder")
668   gBBox->setVisible(0) ;
669   gBSphere->setVisible(0) ;
670   gBCylindre->setVisible(1) ;
671   gBPipe->setVisible(0) ;
672   adjustSize() ;
673   _Type=5;
674   if ( _Xincr > 0 ) { SpinBox_Xbase->setValue(_Xcentre) ;
675                       SpinBox_Xaxis->setValue(0.) ; }
676   else { _Type=32 ; }
677   if ( _Yincr > 0 ) { SpinBox_Ybase->setValue(_Ycentre) ;
678                       SpinBox_Yaxis->setValue(0.) ; }
679   else { _Type=33 ; }
680   if ( _Zincr > 0 ) { SpinBox_Zbase->setValue(_Zcentre) ;
681                       SpinBox_Zaxis->setValue(1.) ; }
682   else { _Type=31 ; }
683   SpinBox_Radius->setValue(_Rayon) ;
684   SpinBox_Haut->setValue(_Haut) ;
685   MESSAGE("Fin de SetCylinder")
686 }
687 // ------------------------------------------------------------------------
688 void MonCreateZone::SetPipe()
689 // ------------------------------------------------------------------------
690 {
691   MESSAGE("Debut de SetPipe")
692   gBBox->setVisible(0) ;
693   gBSphere->setVisible(0) ;
694   gBCylindre->setVisible(0) ;
695   gBPipe->setVisible(1) ;
696   adjustSize() ;
697   _Type=7;
698   if ( _Xincr > 0 ) { SpinBox_Xbase_p->setValue(_Xcentre) ;
699                       SpinBox_Xaxis_p->setValue(0.) ; }
700   else { _Type=62 ; }
701   if ( _Yincr > 0 ) { SpinBox_Ybase_p->setValue(_Ycentre) ;
702                       SpinBox_Yaxis_p->setValue(0.) ; }
703   else { _Type=63 ; }
704   if ( _Zincr > 0 ) { SpinBox_Zbase_p->setValue(_Zcentre) ;
705                       SpinBox_Zaxis_p->setValue(1.) ; }
706   else { _Type=61 ; }
707   SpinBox_Radius_int->setValue(_RayonInt) ;
708   SpinBox_Radius_ext->setValue(_Rayon) ;
709   SpinBox_Haut_p->setValue(_Haut) ;
710   MESSAGE("Fin de SetPipe")
711 }
712
713