Salome HOME
Filtrage des types de fichiers dans la sélection
[modules/homard.git] / src / HOMARDGUI / MonEditBoundaryAn.cxx
1 // Copyright (C) 2011-2013  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.
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 "MonEditBoundaryAn.h"
21
22 #include "SalomeApp_Tools.h"
23 #include "HOMARDGUI_Utils.h"
24 #include <utilities.h>
25
26 using namespace std;
27
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
35 */
36     MonCreateBoundaryAn(parent, myHomardGen, caseName)
37 {
38     MESSAGE("Debut de MonEditBoundaryAn pour " << Name.toStdString().c_str());
39     setWindowTitle(QObject::tr("HOM_BOUN_A_EDIT_WINDOW_TITLE"));
40     _aName=Name;
41     aBoundaryAn = myHomardGen->GetBoundary(_aName.toStdString().c_str());
42     InitValEdit();
43 }
44 // ------------------------------------------------------------------------
45 MonEditBoundaryAn::~MonEditBoundaryAn()
46 // ------------------------------------------------------------------------
47 {
48     // no need to delete child widgets, Qt does it all for us
49 }
50 // ------------------------------------------------------------------------
51 void MonEditBoundaryAn::InitValEdit()
52 // ------------------------------------------------------------------------
53 {
54   LEName->setText(_aName);
55   LEName->setReadOnly(true);
56   _Type = aBoundaryAn->GetType();
57   MESSAGE("_Type : "<<_Type);
58   InitValBoundaryAnLimit();
59   if (_aCaseName != QString("")) InitValBoundaryAn();
60   switch (_Type)
61   {
62     case 1 : // il s agit d un cylindre
63     {
64       InitValBoundaryAnCylindre();
65       SetCylinder();
66       break;
67     }
68     case 2: // il s agit d une sphere
69     {
70       InitValBoundaryAnSphere();
71       SetSphere();
72       break;
73     }
74     case 3: // il s agit d un cone defini par un axe et un angle
75     {
76       InitValBoundaryAnConeA();
77       SetConeA();
78       break;
79     }
80     case 4: // il s agit d un cone defini par les 2 rayons
81     {
82       InitValBoundaryAnConeR();
83       SetConeR();
84       break;
85     }
86   };
87 }
88 // ------------------------------------------------------------------------
89 void MonEditBoundaryAn::InitValBoundaryAnLimit()
90 // ------------------------------------------------------------------------
91 {
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];
97 }
98 // ------------------------------------------------------------------------
99 void MonEditBoundaryAn::InitValBoundaryAnCylindre()
100 // ------------------------------------------------------------------------
101 {
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];
111 }
112 // ------------------------------------------------------------------------
113 void MonEditBoundaryAn::InitValBoundaryAnSphere()
114 // ------------------------------------------------------------------------
115 {
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];
122 }
123 // ------------------------------------------------------------------------
124 void MonEditBoundaryAn::InitValBoundaryAnConeA()
125 // ------------------------------------------------------------------------
126 {
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) ;
137 }
138 // ------------------------------------------------------------------------
139 void MonEditBoundaryAn::InitValBoundaryAnConeR()
140 // ------------------------------------------------------------------------
141 {
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) ;
153 }
154 // ------------------------------------------------------------------------
155 void MonEditBoundaryAn::SetCylinder()
156 // ------------------------------------------------------------------------
157 {
158   gBCylindre->setVisible(1);
159   gBSphere->setVisible(0);
160   gBCone->setVisible(0);
161   RBCylindre->setChecked(1);
162   _Type=1;
163   RBSphere->setDisabled(true);
164   RBCone->setDisabled(true);
165
166   SpinBox_Xcent->setValue(_BoundaryAnXcentre);
167   SpinBox_Ycent->setValue(_BoundaryAnYcentre);
168   SpinBox_Zcent->setValue(_BoundaryAnZcentre);
169
170   SpinBox_Xaxis->setValue(_BoundaryAnXaxis);
171   SpinBox_Yaxis->setValue(_BoundaryAnYaxis);
172   SpinBox_Zaxis->setValue(_BoundaryAnZaxis);
173
174
175   SpinBox_Xaxis->setSingleStep(0.1);
176   SpinBox_Xcentre->setSingleStep(_Xincr);
177   SpinBox_Yaxis->setSingleStep(0.1);
178   SpinBox_Ycentre->setSingleStep(_Yincr);
179   SpinBox_Zaxis->setSingleStep(0.1);
180   SpinBox_Zcentre->setSingleStep(_Zincr);
181 // Rayon
182   SpinBox_Radius->setValue(_BoundaryAnRayon);
183   SpinBox_Radius->setSingleStep(_BoundaryAnRayon/10.);
184 //
185   adjustSize();
186 }
187 // ------------------------------------------------------------------------
188 void MonEditBoundaryAn::SetSphere()
189 // ------------------------------------------------------------------------
190 {
191   gBCylindre->setVisible(0);
192   gBSphere->setVisible(1);
193   RBSphere->setChecked(1);
194   gBCone->setVisible(0);
195   RBCylindre->setDisabled(true);
196   RBCone->setDisabled(true);
197   _Type=2 ;
198
199   SpinBox_Xcentre->setValue(_BoundaryAnXcentre);
200   if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); }
201   else             { SpinBox_Xcentre->setSingleStep(1) ; }
202
203   SpinBox_Ycentre->setValue(_BoundaryAnYcentre);
204   if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); }
205   else             { SpinBox_Ycentre->setSingleStep(1) ; }
206
207   SpinBox_Zcentre->setValue(_BoundaryAnZcentre);
208   if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); }
209   else             { SpinBox_Zcentre->setSingleStep(1);}
210
211   SpinBox_Rayon->setMinimum(0.);
212   SpinBox_Rayon->setValue(_BoundaryAnRayon);
213 //
214   adjustSize();
215 }
216 // ------------------------------------------------------------------------
217 void MonEditBoundaryAn::SetConeA()
218 // ------------------------------------------------------------------------
219 {
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);
227   _Type=3;
228 //
229   TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0, QApplication::UnicodeUTF8));
230   SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
231   TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0, QApplication::UnicodeUTF8));
232   SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
233   TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0, QApplication::UnicodeUTF8));
234   SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
235 //
236   TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0, QApplication::UnicodeUTF8));
237   SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
238   TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0, QApplication::UnicodeUTF8));
239   SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
240   TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0, QApplication::UnicodeUTF8));
241   SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
242 //
243   TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0, QApplication::UnicodeUTF8));
244   SpinBox_Cone_V1->setValue(_BoundaryAngle);
245   SpinBox_Cone_V1->setSingleStep(1.);
246   SpinBox_Cone_V1->setMaximum(90.);
247 //
248   TLCone_V2->setVisible(0);
249   SpinBox_Cone_V2->setVisible(0);
250 //
251   adjustSize();
252 }
253 // ------------------------------------------------------------------------
254 void MonEditBoundaryAn::SetConeR()
255 // ------------------------------------------------------------------------
256 {
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);
264   _Type=4;
265 //
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);
272 //
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);
277 //
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);
284 //
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);
289 //
290   adjustSize();
291 }
292 // ---------------------------------------------------
293 bool MonEditBoundaryAn::CreateOrUpdateBoundaryAn()
294 //----------------------------------------------------
295 //  Mise a jour des attributs de la BoundaryAn
296 {
297   switch (_Type)
298   {
299     case 1 : // il s agit d un cylindre
300     {
301       aBoundaryAn->SetCylinder(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
302       break;
303     }
304     case 2 : // il s agit d une sphere
305     {
306       aBoundaryAn->SetSphere(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
307       break;
308     }
309     case 3 : // il s agit d un cone defini par un axe et un angle
310     {
311       aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_aName.toStdString().c_str()), \
312       _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
313       _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
314       break;
315     }
316     case 4 : // il s agit d un cone defini par les 2 rayons
317       {
318       aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_aName.toStdString().c_str()), \
319         _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
320         _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
321       break;
322     }
323   }
324   if (Chgt) myHomardGen->InvalideBoundary(_aName.toStdString().c_str());
325   HOMARD_UTILS::updateObjBrowser();
326   return true;
327 }
328