1 // Copyright (C) 2011-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MonEditBoundaryAn.h"
22 #include "SalomeApp_Tools.h"
23 #include "HOMARDGUI_Utils.h"
24 #include <utilities.h>
28 // ------------------------------------------------------------------------
29 MonEditBoundaryAn::MonEditBoundaryAn( MonCreateCase* parent, bool modal,
30 ADAPT::ADAPT_Gen_var myHomardGen,
31 QString caseName, QString Name ):
32 // ------------------------------------------------------------------------
33 /* Constructs a MonEditBoundaryAn
34 herite de MonCreateBoundaryAn
36 MonCreateBoundaryAn(parent, myHomardGen, caseName)
38 MESSAGE("Debut de MonEditBoundaryAn pour " << Name.toStdString().c_str());
39 setWindowTitle(QObject::tr("HOM_BOUN_A_EDIT_WINDOW_TITLE"));
41 aBoundaryAn = myHomardGen->GetBoundary(_Name.toStdString().c_str());
44 // ------------------------------------------------------------------------
45 MonEditBoundaryAn::~MonEditBoundaryAn()
46 // ------------------------------------------------------------------------
48 // no need to delete child widgets, Qt does it all for us
50 // ------------------------------------------------------------------------
51 void MonEditBoundaryAn::InitValEdit()
52 // ------------------------------------------------------------------------
54 LEName->setText(_Name);
55 LEName->setReadOnly(true);
56 _Type = aBoundaryAn->GetType();
57 MESSAGE("_Type : "<<_Type);
58 InitValBoundaryAnLimit();
59 if (_aCaseName != QString("")) InitValBoundaryAn();
62 case 1 : // il s agit d un cylindre
64 InitValBoundaryAnCylindre();
68 case 2: // il s agit d une sphere
70 InitValBoundaryAnSphere();
74 case 3: // il s agit d un cone defini par un axe et un angle
76 InitValBoundaryAnConeA();
80 case 4: // il s agit d un cone defini par les 2 rayons
82 InitValBoundaryAnConeR();
86 case 5: // il s agit d un tore
88 InitValBoundaryAnTore();
94 // ------------------------------------------------------------------------
95 void MonEditBoundaryAn::InitValBoundaryAnLimit()
96 // ------------------------------------------------------------------------
98 ADAPT::double_array_var mesCoordLimits = aBoundaryAn->GetLimit();
99 ASSERT(mesCoordLimits->length() == 3 );
100 _Xincr=mesCoordLimits[0];
101 _Yincr=mesCoordLimits[1];
102 _Zincr=mesCoordLimits[2];
104 // ------------------------------------------------------------------------
105 void MonEditBoundaryAn::InitValBoundaryAnCylindre()
106 // ------------------------------------------------------------------------
108 ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
109 ASSERT(mesCoordBoundary->length() == 7 );
110 _BoundaryAnXcentre=mesCoordBoundary[0];
111 _BoundaryAnYcentre=mesCoordBoundary[1];
112 _BoundaryAnZcentre=mesCoordBoundary[2];
113 _BoundaryAnXaxis=mesCoordBoundary[3];
114 _BoundaryAnYaxis=mesCoordBoundary[4];
115 _BoundaryAnZaxis=mesCoordBoundary[5];
116 _BoundaryAnRayon=mesCoordBoundary[6];
118 // ------------------------------------------------------------------------
119 void MonEditBoundaryAn::InitValBoundaryAnSphere()
120 // ------------------------------------------------------------------------
122 ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
123 ASSERT(mesCoordBoundary->length() == 4 );
124 _BoundaryAnXcentre=mesCoordBoundary[0];
125 _BoundaryAnYcentre=mesCoordBoundary[1];
126 _BoundaryAnZcentre=mesCoordBoundary[2];
127 _BoundaryAnRayon=mesCoordBoundary[3];
129 // ------------------------------------------------------------------------
130 void MonEditBoundaryAn::InitValBoundaryAnConeA()
131 // ------------------------------------------------------------------------
133 ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
134 ASSERT(mesCoordBoundary->length() == 7 );
135 _BoundaryAnXaxisCone=mesCoordBoundary[0];
136 _BoundaryAnYaxisCone=mesCoordBoundary[1];
137 _BoundaryAnZaxisCone=mesCoordBoundary[2];
138 _BoundaryAngle=mesCoordBoundary[3];
139 _BoundaryAnXorigCone=mesCoordBoundary[4];
140 _BoundaryAnYorigCone=mesCoordBoundary[5];
141 _BoundaryAnZorigCone=mesCoordBoundary[6];
142 convertRayonAngle(-1) ;
144 // ------------------------------------------------------------------------
145 void MonEditBoundaryAn::InitValBoundaryAnConeR()
146 // ------------------------------------------------------------------------
148 ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
149 ASSERT(mesCoordBoundary->length() == 8 );
150 _BoundaryAnXcone1=mesCoordBoundary[0];
151 _BoundaryAnYcone1=mesCoordBoundary[1];
152 _BoundaryAnZcone1=mesCoordBoundary[2];
153 _BoundaryAnRayon1=mesCoordBoundary[3];
154 _BoundaryAnXcone2=mesCoordBoundary[4];
155 _BoundaryAnYcone2=mesCoordBoundary[5];
156 _BoundaryAnZcone2=mesCoordBoundary[6];
157 _BoundaryAnRayon2=mesCoordBoundary[7];
158 convertRayonAngle(1) ;
160 // ------------------------------------------------------------------------
161 void MonEditBoundaryAn::InitValBoundaryAnTore()
162 // ------------------------------------------------------------------------
164 ADAPT::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
165 ASSERT(mesCoordBoundary->length() == 8 );
166 _BoundaryAnXcentre=mesCoordBoundary[0];
167 _BoundaryAnYcentre=mesCoordBoundary[1];
168 _BoundaryAnZcentre=mesCoordBoundary[2];
169 _BoundaryAnXaxis=mesCoordBoundary[3];
170 _BoundaryAnYaxis=mesCoordBoundary[4];
171 _BoundaryAnZaxis=mesCoordBoundary[5];
172 _BoundaryAnRayon1=mesCoordBoundary[6];
173 _BoundaryAnRayon2=mesCoordBoundary[7];
175 // ------------------------------------------------------------------------
176 void MonEditBoundaryAn::SetCylinder()
177 // ------------------------------------------------------------------------
179 gBCylindre->setVisible(1);
180 gBSphere->setVisible(0);
181 gBCone->setVisible(0);
182 gBTore->setVisible(0);
183 RBCylindre->setChecked(1);
185 RBSphere->setDisabled(true);
186 RBCone->setDisabled(true);
187 RBTore->setDisabled(true);
189 SpinBox_Xcent->setValue(_BoundaryAnXcentre);
190 SpinBox_Ycent->setValue(_BoundaryAnYcentre);
191 SpinBox_Zcent->setValue(_BoundaryAnZcentre);
193 SpinBox_Xaxis->setValue(_BoundaryAnXaxis);
194 SpinBox_Yaxis->setValue(_BoundaryAnYaxis);
195 SpinBox_Zaxis->setValue(_BoundaryAnZaxis);
198 SpinBox_Xaxis->setSingleStep(0.1);
199 SpinBox_Xcentre->setSingleStep(_Xincr);
200 SpinBox_Yaxis->setSingleStep(0.1);
201 SpinBox_Ycentre->setSingleStep(_Yincr);
202 SpinBox_Zaxis->setSingleStep(0.1);
203 SpinBox_Zcentre->setSingleStep(_Zincr);
205 SpinBox_Radius->setValue(_BoundaryAnRayon);
206 SpinBox_Radius->setSingleStep(_BoundaryAnRayon/10.);
210 // ------------------------------------------------------------------------
211 void MonEditBoundaryAn::SetSphere()
212 // ------------------------------------------------------------------------
214 gBCylindre->setVisible(0);
215 gBSphere->setVisible(1);
216 RBSphere->setChecked(1);
217 gBCone->setVisible(0);
218 gBTore->setVisible(0);
219 RBCylindre->setDisabled(true);
220 RBCone->setDisabled(true);
221 RBTore->setDisabled(true);
224 SpinBox_Xcentre->setValue(_BoundaryAnXcentre);
225 if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); }
226 else { SpinBox_Xcentre->setSingleStep(1) ; }
228 SpinBox_Ycentre->setValue(_BoundaryAnYcentre);
229 if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); }
230 else { SpinBox_Ycentre->setSingleStep(1) ; }
232 SpinBox_Zcentre->setValue(_BoundaryAnZcentre);
233 if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); }
234 else { SpinBox_Zcentre->setSingleStep(1);}
236 SpinBox_Rayon->setValue(_BoundaryAnRayon);
240 // ------------------------------------------------------------------------
241 void MonEditBoundaryAn::SetConeA()
242 // ------------------------------------------------------------------------
244 gBCylindre->setVisible(0);
245 gBSphere->setVisible(0);
246 gBCone->setVisible(1);
247 RBCone->setChecked(1);
248 gBTore->setVisible(0);
249 RB_Def_angle->setChecked(1);
250 RBCylindre->setDisabled(true);
251 RBSphere->setDisabled(true);
252 RBTore->setDisabled(true);
255 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0));
256 SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
257 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0));
258 SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
259 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0));
260 SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
262 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0));
263 SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
264 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0));
265 SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
266 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0));
267 SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
269 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0));
270 SpinBox_Cone_V1->setValue(_BoundaryAngle);
271 SpinBox_Cone_V1->setSingleStep(1.);
272 SpinBox_Cone_V1->setMaximum(90.);
274 TLCone_V2->setVisible(0);
275 SpinBox_Cone_V2->setVisible(0);
279 // ------------------------------------------------------------------------
280 void MonEditBoundaryAn::SetConeR()
281 // ------------------------------------------------------------------------
283 gBCylindre->setVisible(0);
284 gBSphere->setVisible(0);
285 gBCone->setVisible(1);
286 gBTore->setVisible(0);
287 RBCone->setChecked(1);
288 RB_Def_radius->setChecked(1);
289 RBCylindre->setDisabled(true);
290 RBSphere->setDisabled(true);
291 RBTore->setDisabled(true);
294 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0));
295 SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
296 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0));
297 SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
298 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0));
299 SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
301 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0));
302 SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
303 SpinBox_Cone_V1->setMaximum(100000.*_DMax);
304 SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
306 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0));
307 SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
308 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0));
309 SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
310 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0));
311 SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
313 TLCone_V2->setVisible(1);
314 SpinBox_Cone_V2->setVisible(1);
315 TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0));
316 SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
320 // ------------------------------------------------------------------------
321 void MonEditBoundaryAn::SetTore()
322 // ------------------------------------------------------------------------
324 gBCylindre->setVisible(0);
325 gBSphere->setVisible(0);
326 gBCone->setVisible(0);
327 gBTore->setVisible(1);
328 RBTore->setChecked(1);
330 RBCylindre->setDisabled(true);
331 RBSphere->setDisabled(true);
332 RBCone->setDisabled(true);
334 SpinBoxToreXcent->setValue(_BoundaryAnXcentre);
335 SpinBoxToreYcent->setValue(_BoundaryAnYcentre);
336 SpinBoxToreZcent->setValue(_BoundaryAnZcentre);
338 SpinBoxToreXaxe->setValue(_BoundaryAnXaxis);
339 SpinBoxToreYaxe->setValue(_BoundaryAnYaxis);
340 SpinBoxToreZaxe->setValue(_BoundaryAnZaxis);
343 SpinBoxToreXaxe->setSingleStep(0.1);
344 SpinBoxToreXcent->setSingleStep(_Xincr);
345 SpinBoxToreYaxe->setSingleStep(0.1);
346 SpinBoxToreYcent->setSingleStep(_Yincr);
347 SpinBoxToreZaxe->setSingleStep(0.1);
348 SpinBoxToreZcent->setSingleStep(_Zincr);
349 // Rayon de revolution
350 SpinBoxToreRRev->setValue(_BoundaryAnRayon1);
351 SpinBoxToreRRev->setSingleStep(_BoundaryAnRayon1/10.);
353 SpinBoxToreRPri->setValue(_BoundaryAnRayon2);
354 SpinBoxToreRPri->setSingleStep(_BoundaryAnRayon2/10.);
358 // ---------------------------------------------------
359 bool MonEditBoundaryAn::CreateOrUpdateBoundaryAn()
360 //----------------------------------------------------
361 // Mise a jour des attributs de la BoundaryAn
365 case 1 : // il s agit d un cylindre
367 aBoundaryAn->SetCylinder(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
370 case 2 : // il s agit d une sphere
372 aBoundaryAn->SetSphere(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
375 case 3 : // il s agit d un cone defini par un axe et un angle
377 aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_Name.toStdString().c_str()), \
378 _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
379 _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
382 case 4 : // il s agit d un cone defini par les 2 rayons
384 aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_Name.toStdString().c_str()), \
385 _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
386 _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
389 case 5 : // il s agit d un tore
391 aBoundaryAn->SetTorus(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon1, _BoundaryAnRayon2 );
395 if (Chgt) myHomardGen->InvalideBoundary(_Name.toStdString().c_str());
396 HOMARD_UTILS::updateObjBrowser();