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 "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 HOMARD::HOMARD_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(_aName.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(_aName);
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();
88 // ------------------------------------------------------------------------
89 void MonEditBoundaryAn::InitValBoundaryAnLimit()
90 // ------------------------------------------------------------------------
92 HOMARD::double_array_var mesCoordLimits = aBoundaryAn->GetLimit();
93 ASSERT(mesCoordLimits->length() == 3 );
94 _Xincr=mesCoordLimits[0];
95 _Yincr=mesCoordLimits[1];
96 _Zincr=mesCoordLimits[2];
98 // ------------------------------------------------------------------------
99 void MonEditBoundaryAn::InitValBoundaryAnCylindre()
100 // ------------------------------------------------------------------------
102 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
103 ASSERT(mesCoordBoundary->length() == 7 );
104 _BoundaryAnXcentre=mesCoordBoundary[0];
105 _BoundaryAnYcentre=mesCoordBoundary[1];
106 _BoundaryAnZcentre=mesCoordBoundary[2];
107 _BoundaryAnXaxis=mesCoordBoundary[3];
108 _BoundaryAnYaxis=mesCoordBoundary[4];
109 _BoundaryAnZaxis=mesCoordBoundary[5];
110 _BoundaryAnRayon=mesCoordBoundary[6];
112 // ------------------------------------------------------------------------
113 void MonEditBoundaryAn::InitValBoundaryAnSphere()
114 // ------------------------------------------------------------------------
116 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
117 ASSERT(mesCoordBoundary->length() == 4 );
118 _BoundaryAnXcentre=mesCoordBoundary[0];
119 _BoundaryAnYcentre=mesCoordBoundary[1];
120 _BoundaryAnZcentre=mesCoordBoundary[2];
121 _BoundaryAnRayon=mesCoordBoundary[3];
123 // ------------------------------------------------------------------------
124 void MonEditBoundaryAn::InitValBoundaryAnConeA()
125 // ------------------------------------------------------------------------
127 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
128 ASSERT(mesCoordBoundary->length() == 7 );
129 _BoundaryAnXaxisCone=mesCoordBoundary[0];
130 _BoundaryAnYaxisCone=mesCoordBoundary[1];
131 _BoundaryAnZaxisCone=mesCoordBoundary[2];
132 _BoundaryAngle=mesCoordBoundary[3];
133 _BoundaryAnXorigCone=mesCoordBoundary[4];
134 _BoundaryAnYorigCone=mesCoordBoundary[5];
135 _BoundaryAnZorigCone=mesCoordBoundary[6];
136 convertRayonAngle(-1) ;
138 // ------------------------------------------------------------------------
139 void MonEditBoundaryAn::InitValBoundaryAnConeR()
140 // ------------------------------------------------------------------------
142 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
143 ASSERT(mesCoordBoundary->length() == 8 );
144 _BoundaryAnXcone1=mesCoordBoundary[0];
145 _BoundaryAnYcone1=mesCoordBoundary[1];
146 _BoundaryAnZcone1=mesCoordBoundary[2];
147 _BoundaryAnRayon1=mesCoordBoundary[3];
148 _BoundaryAnXcone2=mesCoordBoundary[4];
149 _BoundaryAnYcone2=mesCoordBoundary[5];
150 _BoundaryAnZcone2=mesCoordBoundary[6];
151 _BoundaryAnRayon2=mesCoordBoundary[7];
152 convertRayonAngle(1) ;
154 // ------------------------------------------------------------------------
155 void MonEditBoundaryAn::SetCylinder()
156 // ------------------------------------------------------------------------
158 gBCylindre->setVisible(1);
159 gBSphere->setVisible(0);
160 gBCone->setVisible(0);
161 RBCylindre->setChecked(1);
164 RBSphere->setDisabled(true);
165 RBCone->setDisabled(true);
168 SpinBox_Xcent->setValue(_BoundaryAnXcentre);
169 SpinBox_Ycent->setValue(_BoundaryAnYcentre);
170 SpinBox_Zcent->setValue(_BoundaryAnZcentre);
172 SpinBox_Xaxis->setValue(_BoundaryAnXaxis);
173 SpinBox_Yaxis->setValue(_BoundaryAnYaxis);
174 SpinBox_Zaxis->setValue(_BoundaryAnZaxis);
177 SpinBox_Xaxis->setSingleStep(0.1);
178 SpinBox_Xcentre->setSingleStep(_Xincr);
179 SpinBox_Yaxis->setSingleStep(0.1);
180 SpinBox_Ycentre->setSingleStep(_Yincr);
181 SpinBox_Zaxis->setSingleStep(0.1);
182 SpinBox_Zcentre->setSingleStep(_Zincr);
184 SpinBox_Radius->setValue(_BoundaryAnRayon);
185 SpinBox_Radius->setSingleStep(_BoundaryAnRayon/10.);
188 // ------------------------------------------------------------------------
189 void MonEditBoundaryAn::SetSphere()
190 // ------------------------------------------------------------------------
192 gBCylindre->setVisible(0);
193 gBSphere->setVisible(1);
194 RBSphere->setChecked(1);
195 gBCone->setVisible(0);
196 RBCylindre->setDisabled(true);
197 RBCone->setDisabled(true);
201 SpinBox_Xcentre->setValue(_BoundaryAnXcentre);
202 if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); }
203 else { SpinBox_Xcentre->setSingleStep(1) ; }
205 SpinBox_Ycentre->setValue(_BoundaryAnYcentre);
206 if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); }
207 else { SpinBox_Ycentre->setSingleStep(1) ; }
209 SpinBox_Zcentre->setValue(_BoundaryAnZcentre);
210 if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); }
211 else { SpinBox_Zcentre->setSingleStep(1);}
213 SpinBox_Rayon->setMinimum(0.);
214 SpinBox_Rayon->setValue(_BoundaryAnRayon);
216 // ------------------------------------------------------------------------
217 void MonEditBoundaryAn::SetConeA()
218 // ------------------------------------------------------------------------
220 gBCylindre->setVisible(0);
221 gBSphere->setVisible(0);
222 gBCone->setVisible(1);
223 RBCone->setChecked(1);
224 RB_Def_angle->setChecked(1);
225 RBCylindre->setDisabled(true);
226 RBSphere->setDisabled(true);
230 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0, QApplication::UnicodeUTF8));
231 SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
232 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0, QApplication::UnicodeUTF8));
233 SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
234 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0, QApplication::UnicodeUTF8));
235 SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
237 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0, QApplication::UnicodeUTF8));
238 SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
239 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0, QApplication::UnicodeUTF8));
240 SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
241 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0, QApplication::UnicodeUTF8));
242 SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
244 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0, QApplication::UnicodeUTF8));
245 SpinBox_Cone_V1->setValue(_BoundaryAngle);
246 SpinBox_Cone_V1->setSingleStep(1.);
247 SpinBox_Cone_V1->setMaximum(90.);
249 TLCone_V2->setVisible(0);
250 SpinBox_Cone_V2->setVisible(0);
252 // ------------------------------------------------------------------------
253 void MonEditBoundaryAn::SetConeR()
254 // ------------------------------------------------------------------------
256 gBCylindre->setVisible(0);
257 gBSphere->setVisible(0);
258 gBCone->setVisible(1);
259 RBCone->setChecked(1);
260 RB_Def_radius->setChecked(1);
261 RBCylindre->setDisabled(true);
262 RBSphere->setDisabled(true);
266 TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0, QApplication::UnicodeUTF8));
267 SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
268 TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0, QApplication::UnicodeUTF8));
269 SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
270 TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0, QApplication::UnicodeUTF8));
271 SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
273 TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0, QApplication::UnicodeUTF8));
274 SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
275 SpinBox_Cone_V1->setMaximum(100000.*_DMax);
276 SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
278 TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0, QApplication::UnicodeUTF8));
279 SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
280 TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0, QApplication::UnicodeUTF8));
281 SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
282 TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0, QApplication::UnicodeUTF8));
283 SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
285 TLCone_V2->setVisible(1);
286 SpinBox_Cone_V2->setVisible(1);
287 TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0, QApplication::UnicodeUTF8));
288 SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
290 // ---------------------------------------------------
291 bool MonEditBoundaryAn::CreateOrUpdateBoundaryAn()
292 //----------------------------------------------------
293 // Mise a jour des attributs de la BoundaryAn
297 case 1 : // il s agit d un cylindre
299 aBoundaryAn->SetCylinder(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
302 case 2 : // il s agit d une sphere
304 aBoundaryAn->SetSphere(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
307 case 3 : // il s agit d un cone defini par un axe et un angle
309 aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_aName.toStdString().c_str()), \
310 _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
311 _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
314 case 4 : // il s agit d un cone defini par les 2 rayons
316 aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_aName.toStdString().c_str()), \
317 _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
318 _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
322 if (Chgt) myHomardGen->InvalideBoundary(_aName.toStdString().c_str());
323 HOMARD_UTILS::updateObjBrowser();