1 // #Copyright (C) 2011-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MonCreateBoundaryAn.h"
21 #include "MonCreateCase.h"
23 #include <QFileDialog>
24 #include <QMessageBox>
26 #include "SalomeApp_Tools.h"
27 #include "HOMARDGUI_Utils.h"
28 #include "HomardQtCommun.h"
29 #include <utilities.h>
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>
38 #define PI 3.141592653589793
41 // ------------------------------------------------------------------------------------------------------------------------
42 MonCreateBoundaryAn::MonCreateBoundaryAn(MonCreateCase* parent, bool modal,
43 HOMARD::HOMARD_Gen_var myHomardGen0,
45 // ------------------------------------------------------------------------------------------------------------------------------
46 /* Constructs a MonCreateBoundaryAn
47 appele pour une vraie creation
48 initialise un cylindre et non une sphere
50 QDialog(0), Ui_CreateBoundaryAn(),
54 _Xmin(0), _Xmax(0), _Xincr(0), _Ymin(0), _Ymax(0), _Yincr(0), _Zmin(0), _Zmax(0), _Zincr(0), _DMax(0),
56 _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0),
57 _BoundaryAnXaxis(0), _BoundaryAnYaxis(0), _BoundaryAnZaxis(0),
58 _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0),
59 _BoundaryAnXcone1(0), _BoundaryAnYcone1(0), _BoundaryAnZcone1(0), _BoundaryAnRayon1(0),
60 _BoundaryAnXcone2(0), _BoundaryAnYcone2(0), _BoundaryAnZcone2(0), _BoundaryAnRayon2(0),
61 _BoundaryAnXaxisCone(0), _BoundaryAnYaxisCone(0), _BoundaryAnZaxisCone(0),
65 MESSAGE("Constructeur") ;
66 myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
71 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
72 QPixmap pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" );
74 RBSphere->setIcon(IS);
75 QPixmap pix2 = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" );
76 QIcon IS2=QIcon(pix2);
77 RBCylindre->setIcon(IS2);
78 QPixmap pix3 = resMgr->loadPixmap( "HOMARD", "cone.png" );
79 QIcon IS3=QIcon(pix3);
81 QPixmap pix4 = resMgr->loadPixmap( "HOMARD", "conepointvector.png" );
82 QIcon IS4=QIcon(pix4);
83 RB_Def_angle->setIcon(IS4);
84 QPixmap pix5 = resMgr->loadPixmap( "HOMARD", "conedxyz.png" );
85 QIcon IS5=QIcon(pix5);
86 RB_Def_radius->setIcon(IS5);
91 InitValBoundaryAn(); // Cherche les valeurs de la boite englobante le maillage
92 InitMinMax(); // Initialise les bornes des boutons
93 SetCylinder(); // Propose un cylindre en premier choix
95 // --------------------------------------------------------------------------------------------------------------
96 MonCreateBoundaryAn::MonCreateBoundaryAn(MonCreateCase* parent,
97 HOMARD::HOMARD_Gen_var myHomardGen0,
99 // --------------------------------------------------------------------------------------------------------------
100 // Constructeur appele par MonEditBoundaryAn
102 QDialog(0), Ui_CreateBoundaryAn(),
103 myHomardGen(myHomardGen0),
106 _aCaseName(caseName),
108 _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0),
109 _BoundaryAnXaxis(0), _BoundaryAnYaxis(0), _BoundaryAnZaxis(0),
110 // Pour affichage lors de l edition d une BoundaryAn sans nom de Cas
111 _Xcentre(0), _Ycentre(0), _Zcentre(0), _Rayon(0),
112 _Xmin(1), _Xmax(1), _Xincr(1), _Ymin(1), _Ymax(1), _Yincr(1), _Zmin(1), _Zmax(1), _Zincr(1), _DMax(1),
115 // MESSAGE("Debut de MonCreateBoundaryAn")
117 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
118 QPixmap pix = resMgr->loadPixmap( "HOMARD", "spherepoint.png" );
120 RBSphere->setIcon(IS);
121 QPixmap pix2 = resMgr->loadPixmap( "HOMARD", "cylinderpointvector.png" );
122 QIcon IS2=QIcon(pix2);
123 RBCylindre->setIcon(IS2);
124 QPixmap pix3 = resMgr->loadPixmap( "HOMARD", "cone.png" );
125 QIcon IS3=QIcon(pix3);
126 RBCone->setIcon(IS3);
127 QPixmap pix4 = resMgr->loadPixmap( "HOMARD", "conepointvector.png" );
128 QIcon IS4=QIcon(pix4);
129 RB_Def_angle->setIcon(IS4);
130 QPixmap pix5 = resMgr->loadPixmap( "HOMARD", "conedxyz.png" );
131 QIcon IS5=QIcon(pix5);
132 RB_Def_radius->setIcon(IS5);
137 // ------------------------------------------------------------------------
138 MonCreateBoundaryAn::~MonCreateBoundaryAn()
139 // ------------------------------------------------------------------------
141 // no need to delete child widgets, Qt does it all for us
143 // ------------------------------------------------------------------------
144 void MonCreateBoundaryAn::InitConnect()
145 // ------------------------------------------------------------------------
147 connect( RBCylindre, SIGNAL(clicked()) , this, SLOT(SetCylinder()) ) ;
148 connect( RBSphere, SIGNAL(clicked()) , this, SLOT(SetSphere()) ) ;
149 connect( RBCone, SIGNAL(clicked()) , this, SLOT(SetCone()) ) ;
150 connect( RB_Def_radius, SIGNAL(clicked()) , this, SLOT(SetConeR()) );
151 connect( RB_Def_angle, SIGNAL(clicked()) , this, SLOT(SetConeA()) );
152 connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) );
153 connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) );
154 connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) );
155 connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) );
157 // ------------------------------------------------------------------------
158 void MonCreateBoundaryAn::InitValBoundaryAn()
159 // ------------------------------------------------------------------------
162 // 1. Les coordonnees extremes du maillage
164 if (_aCaseName == QString("")) { return; }
166 HOMARD::HOMARD_Cas_var aCas = myHomardGen->GetCase(_aCaseName.toStdString().c_str());
167 HOMARD::extrema_var MesExtremes = aCas->GetBoundingBox();
168 int num = MesExtremes->length() ;
170 _Xmin=MesExtremes[0]; _Xmax=MesExtremes[1]; _Xincr=MesExtremes[2];
171 _Ymin=MesExtremes[3]; _Ymax=MesExtremes[4]; _Yincr=MesExtremes[5];
172 _Zmin=MesExtremes[6]; _Zmax=MesExtremes[7]; _Zincr=MesExtremes[8];
173 _DMax=MesExtremes[9];
174 MESSAGE ("_Xmin : " << _Xmin << " _Xmax : " << _Xmax << " _Xincr : " << _Xincr ) ;
175 MESSAGE ("_Ymin : " << _Ymin << " _Ymax : " << _Ymax << " _Yincr : " << _Yincr ) ;
176 MESSAGE ("_Zmin : " << _Zmin << " _Zmax : " << _Zmax << " _Zincr : " << _Zincr) ;
177 MESSAGE ("_DMax : " << _DMax);
179 // 2. Caracteristiques des frontieres
181 _Xcentre=(_Xmin + _Xmax)/2.;
183 _Ycentre=(_Ymin + _Ymax)/2.;
185 _Zcentre=(_Zmin + _Zmax)/2.;
190 // ------------------------------------------------------------------------
191 void MonCreateBoundaryAn::InitMinMax()
192 // ------------------------------------------------------------------------
196 SpinBox_Xcent->setValue(_Xcentre);
197 SpinBox_Xcent->setSingleStep(_Xincr);
199 SpinBox_Ycent->setValue(_Ycentre);
200 SpinBox_Ycent->setSingleStep(_Yincr);
202 SpinBox_Zcent->setValue(_Zcentre);
203 SpinBox_Zcent->setSingleStep(_Zincr);
205 SpinBox_Xaxis->setValue(0.);
206 SpinBox_Xaxis->setSingleStep(0.1);
208 SpinBox_Yaxis->setValue(0.);
209 SpinBox_Yaxis->setSingleStep(0.1);
211 SpinBox_Zaxis->setValue(1.);
212 SpinBox_Zaxis->setSingleStep(0.1);
214 SpinBox_Radius->setValue(_Rayon);
215 SpinBox_Radius->setSingleStep(_Rayon/10.);
216 SpinBox_Radius->setMinimum(0.);
220 SpinBox_Xcentre->setValue(_Xcentre);
221 SpinBox_Xcentre->setSingleStep(_Xincr);
223 SpinBox_Ycentre->setValue(_Ycentre);
224 SpinBox_Ycentre->setSingleStep(_Yincr);
226 SpinBox_Zcentre->setValue(_Zcentre);
227 SpinBox_Zcentre->setSingleStep(_Zincr);
229 SpinBox_Rayon->setValue(_Rayon);
230 SpinBox_Rayon->setSingleStep(_Rayon/10.);
231 SpinBox_Rayon->setMinimum(0.);
235 _BoundaryAnXcone1 = _Xcentre ;
236 SpinBox_Cone_X1->setSingleStep(_Xincr);
237 _BoundaryAnXcone2 = _Xcentre ;
238 SpinBox_Cone_X2->setSingleStep(_Xincr);
240 _BoundaryAnYcone1 = _Ycentre ;
241 SpinBox_Cone_Y1->setSingleStep(_Yincr);
242 _BoundaryAnYcone2 = _Ycentre ;
243 SpinBox_Cone_Y2->setSingleStep(_Yincr);
245 _BoundaryAnZcone1 = _Zmin ;
246 SpinBox_Cone_Z1->setSingleStep(_Zincr);
247 _BoundaryAnZcone2 = _Zmax ;
248 SpinBox_Cone_Z2->setSingleStep(_Zincr);
250 _BoundaryAnRayon1 = 0. ;
251 SpinBox_Cone_V1->setMinimum(0.);
252 _BoundaryAnRayon2 = _Rayon ;
253 SpinBox_Cone_V2->setSingleStep(_Rayon/10.);
254 SpinBox_Cone_V2->setMinimum(0.);
257 convertRayonAngle(1) ;
258 SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
259 SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
260 SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
261 SpinBox_Cone_V1->setValue(_BoundaryAngle);
262 SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
263 SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
264 SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
266 // ------------------------------------------------------------------------
267 bool MonCreateBoundaryAn::PushOnApply()
268 // ------------------------------------------------------------------------
269 // Appele lorsque l'un des boutons Ok ou Apply est presse
272 if (LEName->text().trimmed()=="")
274 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
275 QObject::tr("HOM_BOUN_NAME") );
281 case 1 : // il s agit d un cylindre
283 if ((_BoundaryAnXcentre != SpinBox_Xcent->value()) ||
284 (_BoundaryAnYcentre != SpinBox_Ycent->value()) ||
285 (_BoundaryAnZcentre != SpinBox_Zcent->value()) ||
286 (_BoundaryAnRayon != SpinBox_Radius->value()) ||
287 (_BoundaryAnXaxis != SpinBox_Xaxis->value()) ||
288 (_BoundaryAnYaxis != SpinBox_Yaxis->value()) ||
289 (_BoundaryAnZaxis != SpinBox_Zaxis->value()) )
292 _BoundaryAnXaxis= SpinBox_Xaxis->value();
293 _BoundaryAnYaxis= SpinBox_Yaxis->value();
294 _BoundaryAnZaxis= SpinBox_Zaxis->value();
295 _BoundaryAnXcentre=SpinBox_Xcent->value();
296 _BoundaryAnYcentre=SpinBox_Ycent->value();
297 _BoundaryAnZcentre=SpinBox_Zcent->value();
298 _BoundaryAnRayon=SpinBox_Radius->value();
303 case 2 : // il s agit d une sphere
305 if ((_BoundaryAnXcentre != SpinBox_Xcentre->value()) ||
306 (_BoundaryAnYcentre != SpinBox_Ycentre->value()) ||
307 (_BoundaryAnZcentre != SpinBox_Zcentre->value()) ||
308 (_BoundaryAnRayon != SpinBox_Rayon->value()) )
311 _BoundaryAnXcentre=SpinBox_Xcentre->value();
312 _BoundaryAnYcentre=SpinBox_Ycentre->value();
313 _BoundaryAnZcentre=SpinBox_Zcentre->value();
314 _BoundaryAnRayon=SpinBox_Rayon->value();
319 case 3 : // il s agit d un cone defini par un axe et un angle
321 if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value()) ||
322 (_BoundaryAnYaxisCone != SpinBox_Cone_Y1->value()) ||
323 (_BoundaryAnZaxisCone != SpinBox_Cone_Z1->value()) ||
324 (_BoundaryAnXorigCone != SpinBox_Cone_X2->value()) ||
325 (_BoundaryAnYorigCone != SpinBox_Cone_Y2->value()) ||
326 (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value()) ||
327 (_BoundaryAngle != SpinBox_Cone_V1->value()) )
330 _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ;
331 _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ;
332 _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ;
333 _BoundaryAnXorigCone = SpinBox_Cone_X2->value() ;
334 _BoundaryAnYorigCone = SpinBox_Cone_Y2->value() ;
335 _BoundaryAnZorigCone = SpinBox_Cone_Z2->value() ;
336 _BoundaryAngle = SpinBox_Cone_V1->value() ;
341 case 4 : // il s agit d un cone defini par les 2 rayons
343 if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value()) ||
344 (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value()) ||
345 (_BoundaryAnZcone1 != SpinBox_Cone_Z1->value()) ||
346 (_BoundaryAnRayon1 != SpinBox_Cone_V1->value()) ||
347 (_BoundaryAnXcone2 != SpinBox_Cone_X2->value()) ||
348 (_BoundaryAnYcone2 != SpinBox_Cone_Y2->value()) ||
349 (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value()) ||
350 (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) )
353 _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ;
354 _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ;
355 _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ;
356 _BoundaryAnRayon1 = SpinBox_Cone_V1->value() ;
357 _BoundaryAnXcone2 = SpinBox_Cone_X2->value() ;
358 _BoundaryAnYcone2 = SpinBox_Cone_Y2->value() ;
359 _BoundaryAnZcone2 = SpinBox_Cone_Z2->value() ;
360 _BoundaryAnRayon2 = SpinBox_Cone_V2->value() ;
366 bool bOK = CreateOrUpdateBoundaryAn();
368 if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; }
373 // ---------------------------------------------------
374 bool MonCreateBoundaryAn:: CreateOrUpdateBoundaryAn()
375 //----------------------------------------------------
376 // Creation de l'objet boundary
378 _aName = LEName->text().trimmed();
381 case 1 : // il s agit d un cylindre
385 aBoundaryAn = myHomardGen->CreateBoundaryCylinder(CORBA::string_dup(_aName.toStdString().c_str()), \
386 _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
388 catch( SALOME::SALOME_Exception& S_ex )
390 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
391 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
396 case 2 : // il s agit d une sphere
400 aBoundaryAn = myHomardGen->CreateBoundarySphere(CORBA::string_dup(_aName.toStdString().c_str()), \
401 _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
403 catch( SALOME::SALOME_Exception& S_ex )
405 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
406 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
411 case 3 : // il s agit d un cone defini par un axe et un angle
415 aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_aName.toStdString().c_str()), \
416 _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
417 _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
419 catch( SALOME::SALOME_Exception& S_ex )
421 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
422 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
427 case 4 : // il s agit d un cone defini par les 2 rayons
431 aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_aName.toStdString().c_str()), \
432 _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
433 _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
435 catch( SALOME::SALOME_Exception& S_ex )
437 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
438 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
444 _parent->AddBoundaryAn(_aName);
448 // ------------------------------------------------------------------------
449 void MonCreateBoundaryAn::PushOnOK()
450 // ------------------------------------------------------------------------
452 if (PushOnApply()) this->close();
454 // ------------------------------------------------------------------------
455 void MonCreateBoundaryAn::PushOnHelp()
456 // ------------------------------------------------------------------------
458 char* LanguageShort = myHomardGen->GetLanguageShort();
459 HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("un-cylindre"), QString(LanguageShort));
462 // -----------------------------------
463 void MonCreateBoundaryAn::SetNewName()
464 // -----------------------------------
466 // Recherche d'un nom par defaut qui n'existe pas encore
468 HOMARD::listeBoundarys_var MyObjects = myHomardGen->GetAllBoundarysName();
469 int num = 0; QString aName="";
472 aName.setNum(num+1) ;
473 aName.insert(0, QString("Boun_")) ;
474 for ( int i=0; i<MyObjects->length(); i++)
476 if ( aName == QString(MyObjects[i]))
484 LEName->setText(aName);
486 // ------------------------------------------------------------------------
487 void MonCreateBoundaryAn::SetCylinder()
488 // ------------------------------------------------------------------------
490 MESSAGE("Debut de SetCylinder")
491 gBCylindre->setVisible(1);
492 gBSphere->setVisible(0);
493 gBCone->setVisible(0);
496 // MESSAGE("Fin de SetCylinder")
498 // ------------------------------------------------------------------------
499 void MonCreateBoundaryAn::SetSphere()
500 // ------------------------------------------------------------------------
502 MESSAGE("Debut de SetSphere")
503 gBCylindre->setVisible(0);
504 gBSphere->setVisible(1);
505 gBCone->setVisible(0);
508 // MESSAGE("Fin de SetSphere")
510 // ------------------------------------------------------------------------
511 void MonCreateBoundaryAn::SetConeR()
512 // ------------------------------------------------------------------------
514 MESSAGE("Debut de SetConeR")
516 // Stockage et conversion des valeurs si elles ont change
517 if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value()) ||
518 (_BoundaryAnYaxisCone != SpinBox_Cone_Y1->value()) ||
519 (_BoundaryAnZaxisCone != SpinBox_Cone_Z1->value()) ||
520 (_BoundaryAnXorigCone != SpinBox_Cone_X2->value()) ||
521 (_BoundaryAnYorigCone != SpinBox_Cone_Y2->value()) ||
522 (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value()) ||
523 (_BoundaryAngle != SpinBox_Cone_V1->value()) )
525 MESSAGE("Stockage et conversion")
526 _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ;
527 _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ;
528 _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ;
529 _BoundaryAnXorigCone = SpinBox_Cone_X2->value() ;
530 _BoundaryAnYorigCone = SpinBox_Cone_Y2->value() ;
531 _BoundaryAnZorigCone = SpinBox_Cone_Z2->value() ;
532 _BoundaryAngle = SpinBox_Cone_V1->value() ;
533 convertRayonAngle(-1) ;
538 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0, QApplication::UnicodeUTF8));
539 SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
540 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0, QApplication::UnicodeUTF8));
541 SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
542 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0, QApplication::UnicodeUTF8));
543 SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
545 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0, QApplication::UnicodeUTF8));
546 SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
547 SpinBox_Cone_V1->setMaximum(100000.*_DMax);
548 SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
550 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0, QApplication::UnicodeUTF8));
551 SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
552 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0, QApplication::UnicodeUTF8));
553 SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
554 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0, QApplication::UnicodeUTF8));
555 SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
557 TLCone_V2->setVisible(1);
558 SpinBox_Cone_V2->setVisible(1);
559 TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0, QApplication::UnicodeUTF8));
560 SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
562 // MESSAGE("Fin de SetConeR")
564 // ------------------------------------------------------------------------
565 void MonCreateBoundaryAn::SetConeA()
566 // ------------------------------------------------------------------------
568 MESSAGE("Debut de SetConeA")
569 // Stockage et conversion des valeurs si elles ont change
570 if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value()) ||
571 (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value()) ||
572 (_BoundaryAnZcone1 != SpinBox_Cone_Z1->value()) ||
573 (_BoundaryAnRayon1 != SpinBox_Cone_V1->value()) ||
574 (_BoundaryAnXcone2 != SpinBox_Cone_X2->value()) ||
575 (_BoundaryAnYcone2 != SpinBox_Cone_Y2->value()) ||
576 (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value()) ||
577 (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) )
579 MESSAGE("Stockage et conversion")
580 _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ;
581 _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ;
582 _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ;
583 _BoundaryAnRayon1 = SpinBox_Cone_V1->value() ;
584 _BoundaryAnXcone2 = SpinBox_Cone_X2->value() ;
585 _BoundaryAnYcone2 = SpinBox_Cone_Y2->value() ;
586 _BoundaryAnZcone2 = SpinBox_Cone_Z2->value() ;
587 _BoundaryAnRayon2 = SpinBox_Cone_V2->value() ;
588 convertRayonAngle(1) ;
593 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0, QApplication::UnicodeUTF8));
594 SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
595 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0, QApplication::UnicodeUTF8));
596 SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
597 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0, QApplication::UnicodeUTF8));
598 SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
600 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0, QApplication::UnicodeUTF8));
601 SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
602 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0, QApplication::UnicodeUTF8));
603 SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
604 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0, QApplication::UnicodeUTF8));
605 SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
607 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0, QApplication::UnicodeUTF8));
608 SpinBox_Cone_V1->setValue(_BoundaryAngle);
609 SpinBox_Cone_V1->setSingleStep(1.);
610 SpinBox_Cone_V1->setMaximum(90.);
612 TLCone_V2->setVisible(0);
613 SpinBox_Cone_V2->setVisible(0);
614 // MESSAGE("Fin de SetConeA")
618 // ------------------------------------------------------------------------
619 void MonCreateBoundaryAn::SetCone()
620 // ------------------------------------------------------------------------
622 MESSAGE("Debut de SetCone")
623 gBCylindre->setVisible(0);
624 gBSphere->setVisible(0);
625 gBCone->setVisible(1);
628 if ( RB_Def_radius->isChecked() )
636 // MESSAGE("Fin de SetCone")
638 // ------------------------------------------------------------------------
639 void MonCreateBoundaryAn::convertRayonAngle(int option)
640 // ------------------------------------------------------------------------
641 // Conversion entre les deux formulations du cone :
642 // par deux rayons ou avec un axe et un angle.
643 // Voir sfcoi1 de HOMARD
645 MESSAGE("Debut de convertRayonAngle, option = "<<option)
654 // A----------------B----------O
656 // Thales : RA/RB = AO/BO ==> BO = AB*RB/(RA-RB)
657 // Angle : tg(alpha) = RA/AO
660 // De rayon vers angle :
663 double xa, ya, za, ra ;
664 double xb, yb, zb, rb ;
665 // Positionnement de A vers B, avec RA>RB
666 if ( _BoundaryAnRayon1 > _BoundaryAnRayon2 )
668 xa = _BoundaryAnXcone1 ;
669 ya = _BoundaryAnYcone1 ;
670 za = _BoundaryAnZcone1 ;
671 ra = _BoundaryAnRayon1 ;
672 xb = _BoundaryAnXcone2 ;
673 yb = _BoundaryAnYcone2 ;
674 zb = _BoundaryAnZcone2 ;
675 rb = _BoundaryAnRayon2 ;
679 xa = _BoundaryAnXcone2 ;
680 ya = _BoundaryAnYcone2 ;
681 za = _BoundaryAnZcone2 ;
682 ra = _BoundaryAnRayon2 ;
683 xb = _BoundaryAnXcone1 ;
684 yb = _BoundaryAnYcone1 ;
685 zb = _BoundaryAnZcone1 ;
686 rb = _BoundaryAnRayon1 ;
688 // Axe : relie les deux centres, de A vers B. L'axe est normalise
689 _BoundaryAnXaxisCone = xb - xa ;
690 _BoundaryAnYaxisCone = yb - ya ;
691 _BoundaryAnZaxisCone = zb - za ;
692 daux = sqrt ( _BoundaryAnXaxisCone*_BoundaryAnXaxisCone + _BoundaryAnYaxisCone*_BoundaryAnYaxisCone + _BoundaryAnZaxisCone*_BoundaryAnZaxisCone ) ;
693 _BoundaryAnXaxisCone = _BoundaryAnXaxisCone/daux ;
694 _BoundaryAnYaxisCone = _BoundaryAnYaxisCone/daux ;
695 _BoundaryAnZaxisCone = _BoundaryAnZaxisCone/daux ;
697 daux = daux * rb / (ra-rb) ;
698 _BoundaryAnXorigCone = xb + daux*_BoundaryAnXaxisCone ;
699 _BoundaryAnYorigCone = yb + daux*_BoundaryAnYaxisCone ;
700 _BoundaryAnZorigCone = zb + daux*_BoundaryAnZaxisCone ;
702 daux = ra / sqrt((_BoundaryAnXorigCone-xa)*(_BoundaryAnXorigCone-xa) + (_BoundaryAnYorigCone-ya)*(_BoundaryAnYorigCone-ya) + (_BoundaryAnZorigCone-za)*(_BoundaryAnZorigCone-za) ) ;
703 _BoundaryAngle = atan(daux)*180./PI ;
705 // D'angle vers rayon :
708 double xax, yax, zax ;
709 // L'axe est normalise
710 daux = sqrt ( _BoundaryAnXaxisCone*_BoundaryAnXaxisCone + _BoundaryAnYaxisCone*_BoundaryAnYaxisCone + _BoundaryAnZaxisCone*_BoundaryAnZaxisCone ) ;
711 xax = _BoundaryAnXaxisCone/daux ;
712 yax = _BoundaryAnYaxisCone/daux ;
713 zax = _BoundaryAnZaxisCone/daux ;
714 // Centre 1 : l'origine
715 _BoundaryAnXcone1 = _BoundaryAnXorigCone ;
716 _BoundaryAnYcone1 = _BoundaryAnYorigCone ;
717 _BoundaryAnZcone1 = _BoundaryAnZorigCone ;
719 _BoundaryAnRayon1 = 0. ;
720 // Centre 2 : l'origine decalee d'une longueur arbitraire le long de l'axe
721 _BoundaryAnXcone2 = _BoundaryAnXorigCone + _DMax*xax ;
722 _BoundaryAnYcone2 = _BoundaryAnYorigCone + _DMax*yax ;
723 _BoundaryAnZcone2 = _BoundaryAnZorigCone + _DMax*zax ;
724 // Rayon 2 : a calculer
725 _BoundaryAnRayon2 = _DMax*tan(_BoundaryAngle*PI/180.) ;
727 // MESSAGE("Fin de convertRayonAngle")