1 // Copyright (C) 2011-2012 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
22 #include "MonEditBoundaryAn.h"
24 #include "SalomeApp_Tools.h"
25 #include "HOMARDGUI_Utils.h"
26 #include <utilities.h>
29 // ------------------------------------------------------------------------
30 MonEditBoundaryAn::MonEditBoundaryAn( MonCreateCase* parent, bool modal,
31 HOMARD::HOMARD_Gen_var myHomardGen,
32 QString caseName, QString boundaryName ):
33 // ------------------------------------------------------------------------
34 /* Constructs a MonEditBoundaryAn
35 herite de MonCreateBoundaryAn
37 MonCreateBoundaryAn(parent, myHomardGen, caseName)
39 MESSAGE("Debut de MonEditBoundaryAn pour " << boundaryName.toStdString().c_str());
40 setWindowTitle(QObject::tr("HOM_BOUN_A_EDIT_WINDOW_TITLE"));
42 aBoundaryAn = _myHomardGen->GetBoundary(_aName.toStdString().c_str());
45 // ------------------------------------------------------------------------
46 MonEditBoundaryAn::~MonEditBoundaryAn()
47 // ------------------------------------------------------------------------
49 // no need to delete child widgets, Qt does it all for us
51 // ------------------------------------------------------------------------
52 void MonEditBoundaryAn::InitValEdit()
53 // ------------------------------------------------------------------------
55 LEBoundaryName->setText(_aName);
56 LEBoundaryName->setReadOnly(true);
57 _Type = aBoundaryAn->GetType();
58 MESSAGE("_Type : "<<_Type);
59 InitValBoundaryAnLimit();
60 if (_aCaseName != QString("")) InitValBoundaryAn();
63 case 1 : // il s agit d un cylindre
65 InitValBoundaryAnCylindre();
69 case 2: // il s agit d une sphere
71 InitValBoundaryAnSphere();
75 case 3: // il s agit d un cone defini par un axe et un angle
77 InitValBoundaryAnConeA();
81 case 4: // il s agit d un cone defini par les 2 rayons
83 InitValBoundaryAnConeR();
89 // ------------------------------------------------------------------------
90 void MonEditBoundaryAn::InitValBoundaryAnLimit()
91 // ------------------------------------------------------------------------
93 HOMARD::double_array_var mesCoordLimits = aBoundaryAn->GetLimit();
94 ASSERT(mesCoordLimits->length() == 3 );
95 _Xincr=mesCoordLimits[0];
96 _Yincr=mesCoordLimits[1];
97 _Zincr=mesCoordLimits[2];
99 // ------------------------------------------------------------------------
100 void MonEditBoundaryAn::InitValBoundaryAnCylindre()
101 // ------------------------------------------------------------------------
103 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
104 ASSERT(mesCoordBoundary->length() == 7 );
105 _BoundaryAnXcentre=mesCoordBoundary[0];
106 _BoundaryAnYcentre=mesCoordBoundary[1];
107 _BoundaryAnZcentre=mesCoordBoundary[2];
108 _BoundaryAnXaxis=mesCoordBoundary[3];
109 _BoundaryAnYaxis=mesCoordBoundary[4];
110 _BoundaryAnZaxis=mesCoordBoundary[5];
111 _BoundaryAnRayon=mesCoordBoundary[6];
113 // ------------------------------------------------------------------------
114 void MonEditBoundaryAn::InitValBoundaryAnSphere()
115 // ------------------------------------------------------------------------
117 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
118 ASSERT(mesCoordBoundary->length() == 4 );
119 _BoundaryAnXcentre=mesCoordBoundary[0];
120 _BoundaryAnYcentre=mesCoordBoundary[1];
121 _BoundaryAnZcentre=mesCoordBoundary[2];
122 _BoundaryAnRayon=mesCoordBoundary[3];
124 // ------------------------------------------------------------------------
125 void MonEditBoundaryAn::InitValBoundaryAnConeA()
126 // ------------------------------------------------------------------------
128 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
129 ASSERT(mesCoordBoundary->length() == 7 );
130 _BoundaryAnXaxisCone=mesCoordBoundary[0];
131 _BoundaryAnYaxisCone=mesCoordBoundary[1];
132 _BoundaryAnZaxisCone=mesCoordBoundary[2];
133 _BoundaryAngle=mesCoordBoundary[3];
134 _BoundaryAnXorigCone=mesCoordBoundary[4];
135 _BoundaryAnYorigCone=mesCoordBoundary[5];
136 _BoundaryAnZorigCone=mesCoordBoundary[6];
137 convertRayonAngle(-1) ;
139 // ------------------------------------------------------------------------
140 void MonEditBoundaryAn::InitValBoundaryAnConeR()
141 // ------------------------------------------------------------------------
143 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
144 ASSERT(mesCoordBoundary->length() == 8 );
145 _BoundaryAnXcone1=mesCoordBoundary[0];
146 _BoundaryAnYcone1=mesCoordBoundary[1];
147 _BoundaryAnZcone1=mesCoordBoundary[2];
148 _BoundaryAnRayon1=mesCoordBoundary[3];
149 _BoundaryAnXcone2=mesCoordBoundary[4];
150 _BoundaryAnYcone2=mesCoordBoundary[5];
151 _BoundaryAnZcone2=mesCoordBoundary[6];
152 _BoundaryAnRayon2=mesCoordBoundary[7];
153 convertRayonAngle(1) ;
155 // ------------------------------------------------------------------------
156 void MonEditBoundaryAn::SetCylinder()
157 // ------------------------------------------------------------------------
159 gBCylindre->setVisible(1);
160 gBSphere->setVisible(0);
161 gBCone->setVisible(0);
162 RBCylindre->setChecked(1);
165 RBSphere->setDisabled(true);
166 RBCone->setDisabled(true);
169 SpinBox_Xcent->setValue(_BoundaryAnXcentre);
170 SpinBox_Ycent->setValue(_BoundaryAnYcentre);
171 SpinBox_Zcent->setValue(_BoundaryAnZcentre);
173 SpinBox_Xaxis->setValue(_BoundaryAnXaxis);
174 SpinBox_Yaxis->setValue(_BoundaryAnYaxis);
175 SpinBox_Zaxis->setValue(_BoundaryAnZaxis);
178 SpinBox_Xaxis->setSingleStep(0.1);
179 SpinBox_Xcentre->setSingleStep(_Xincr);
180 SpinBox_Yaxis->setSingleStep(0.1);
181 SpinBox_Ycentre->setSingleStep(_Yincr);
182 SpinBox_Zaxis->setSingleStep(0.1);
183 SpinBox_Zcentre->setSingleStep(_Zincr);
185 SpinBox_Radius->setValue(_BoundaryAnRayon);
186 SpinBox_Radius->setSingleStep(_BoundaryAnRayon/10.);
189 // ------------------------------------------------------------------------
190 void MonEditBoundaryAn::SetSphere()
191 // ------------------------------------------------------------------------
193 gBCylindre->setVisible(0);
194 gBSphere->setVisible(1);
195 RBSphere->setChecked(1);
196 gBCone->setVisible(0);
197 RBCylindre->setDisabled(true);
198 RBCone->setDisabled(true);
202 SpinBox_Xcentre->setValue(_BoundaryAnXcentre);
203 if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); }
204 else { SpinBox_Xcentre->setSingleStep(1) ; }
206 SpinBox_Ycentre->setValue(_BoundaryAnYcentre);
207 if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); }
208 else { SpinBox_Ycentre->setSingleStep(1) ; }
210 SpinBox_Zcentre->setValue(_BoundaryAnZcentre);
211 if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); }
212 else { SpinBox_Zcentre->setSingleStep(1);}
214 SpinBox_Rayon->setMinimum(0.);
215 SpinBox_Rayon->setValue(_BoundaryAnRayon);
217 // ------------------------------------------------------------------------
218 void MonEditBoundaryAn::SetConeA()
219 // ------------------------------------------------------------------------
221 gBCylindre->setVisible(0);
222 gBSphere->setVisible(0);
223 gBCone->setVisible(1);
224 RBCone->setChecked(1);
225 RB_Def_angle->setChecked(1);
226 RBCylindre->setDisabled(true);
227 RBSphere->setDisabled(true);
231 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0, QApplication::UnicodeUTF8));
232 SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
233 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0, QApplication::UnicodeUTF8));
234 SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
235 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0, QApplication::UnicodeUTF8));
236 SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
238 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0, QApplication::UnicodeUTF8));
239 SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
240 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0, QApplication::UnicodeUTF8));
241 SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
242 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0, QApplication::UnicodeUTF8));
243 SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
245 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0, QApplication::UnicodeUTF8));
246 SpinBox_Cone_V1->setValue(_BoundaryAngle);
247 SpinBox_Cone_V1->setSingleStep(1.);
248 SpinBox_Cone_V1->setMaximum(90.);
250 TLCone_V2->setVisible(0);
251 SpinBox_Cone_V2->setVisible(0);
253 // ------------------------------------------------------------------------
254 void MonEditBoundaryAn::SetConeR()
255 // ------------------------------------------------------------------------
257 gBCylindre->setVisible(0);
258 gBSphere->setVisible(0);
259 gBCone->setVisible(1);
260 RBCone->setChecked(1);
261 RB_Def_radius->setChecked(1);
262 RBCylindre->setDisabled(true);
263 RBSphere->setDisabled(true);
267 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0, QApplication::UnicodeUTF8));
268 SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
269 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0, QApplication::UnicodeUTF8));
270 SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
271 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0, QApplication::UnicodeUTF8));
272 SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
274 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0, QApplication::UnicodeUTF8));
275 SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
276 SpinBox_Cone_V1->setMaximum(100000.*_DMax);
277 SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
279 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0, QApplication::UnicodeUTF8));
280 SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
281 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0, QApplication::UnicodeUTF8));
282 SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
283 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0, QApplication::UnicodeUTF8));
284 SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
286 TLCone_V2->setVisible(1);
287 SpinBox_Cone_V2->setVisible(1);
288 TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0, QApplication::UnicodeUTF8));
289 SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
291 // ---------------------------------------------------
292 bool MonEditBoundaryAn::CreateOrUpdateBoundaryAn()
293 //----------------------------------------------------
294 // Mise a jour des attributs de la BoundaryAn
298 case 1 : // il s agit d un cylindre
300 aBoundaryAn->SetCylinder(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
303 case 2 : // il s agit d une sphere
305 aBoundaryAn->SetSphere(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
308 case 3 : // il s agit d un cone defini par un axe et un angle
310 aBoundaryAn = _myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_aName.toStdString().c_str()), \
311 _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
312 _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
315 case 4 : // il s agit d un cone defini par les 2 rayons
317 aBoundaryAn = _myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_aName.toStdString().c_str()), \
318 _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
319 _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
323 if (Chgt) _myHomardGen->InvalideBoundary(_aName.toStdString().c_str());
324 HOMARD_UTILS::updateObjBrowser();