1 // Copyright (C) 2011-2022 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 "MonEditZone.h"
22 #include "SalomeApp_Tools.h"
23 #include "HOMARDGUI_Utils.h"
24 #include <utilities.h>
25 #include <SUIT_Desktop.h>
26 #include <SUIT_MessageBox.h>
27 #include <SUIT_ResourceMgr.h>
28 #include <SUIT_Session.h>
29 #include <SUIT_ViewManager.h>
33 // ------------------------------------------------------------------------
34 MonEditZone::MonEditZone( MonCreateHypothesis* parent, bool modal,
35 HOMARD::HOMARD_Gen_var myHomardGen,
36 QString caseName, QString Name ):
37 // ------------------------------------------------------------------------
38 /* Constructs a MonEditZone
39 herite de MonCreateZone
41 MonCreateZone(parent, myHomardGen, caseName)
43 MESSAGE("Debut de MonEditZone pour " << Name.toStdString().c_str());
44 setWindowTitle(QObject::tr("HOM_ZONE_EDIT_WINDOW_TITLE"));
46 aZone = myHomardGen->GetZone(_Name.toStdString().c_str());
49 // ------------------------------------------------------------------------
50 MonEditZone::~MonEditZone()
51 // ------------------------------------------------------------------------
53 // no need to delete child widgets, Qt does it all for us
55 // ------------------------------------------------------------------------
56 void MonEditZone::InitValEdit()
57 // ------------------------------------------------------------------------
59 MESSAGE("InitValEdit ");
60 LEName->setText(_Name);
61 LEName->setReadOnly(true);
62 _Type = aZone->GetType();
63 MESSAGE("InitValEdit _Type ="<<_Type);
65 if (_aCaseName != QString("")) InitValZone();
68 case 11 : // il s agit d un rectangle
70 case 12 : // il s agit d un rectangle
72 case 13 : // il s agit d un rectangle
74 case 2 : // il s agit d une boite
80 case 4 : // il s agit d une sphere
86 case 31 : // il s agit d un cercle issu d'un cylindre
88 case 32 : // il s agit d un cercle issu d'un cylindre
90 case 33 : // il s agit d un cercle issu d'un cylindre
92 case 5 : // il s agit d un cylindre
94 InitValZoneCylinder();
98 case 61 : // il s agit d un disque avec trou issu d'un tuyau
100 case 62 : // il s agit d un disque avec trou issu d'un tuyau
102 case 63 : // il s agit d un disque avec trou issu d'un tuyau
104 case 7 : // il s agit d un tuyau
112 // ------------------------------------------------------------------------
113 void MonEditZone::InitValZoneLimit()
114 // ------------------------------------------------------------------------
116 HOMARD::double_array_var mesCoordLimits = aZone->GetLimit();
117 ASSERT(mesCoordLimits->length() == 3 );
118 _Xincr=mesCoordLimits[0];
119 _Yincr=mesCoordLimits[1];
120 _Zincr=mesCoordLimits[2];
122 // ------------------------------------------------------------------------
123 void MonEditZone::InitValZoneBox()
124 // ------------------------------------------------------------------------
126 HOMARD::double_array_var mesCoordZones = aZone->GetCoords();
127 ASSERT(mesCoordZones->length() == 6 );
128 _ZoneXmin=mesCoordZones[0];
129 _ZoneXmax=mesCoordZones[1];
130 _ZoneYmin=mesCoordZones[2];
131 _ZoneYmax=mesCoordZones[3];
132 _ZoneZmin=mesCoordZones[4];
133 _ZoneZmax=mesCoordZones[5];
135 // ------------------------------------------------------------------------
136 void MonEditZone::InitValZoneSphere()
137 // ------------------------------------------------------------------------
139 HOMARD::double_array_var mesCoordZones = aZone->GetCoords();
140 ASSERT(mesCoordZones->length() == 4 );
141 _ZoneXcentre=mesCoordZones[0];
142 _ZoneYcentre=mesCoordZones[1];
143 _ZoneZcentre=mesCoordZones[2];
144 _ZoneRayon=mesCoordZones[3];
147 // ------------------------------------------------------------------------
148 void MonEditZone::InitValZoneCylinder()
149 // ------------------------------------------------------------------------
151 HOMARD::double_array_var mesCoordZones = aZone->GetCoords();
152 ASSERT(mesCoordZones->length() == 8 );
153 _ZoneXcentre=mesCoordZones[0];
154 _ZoneYcentre=mesCoordZones[1];
155 _ZoneZcentre=mesCoordZones[2];
156 _ZoneXaxis=mesCoordZones[3];
157 _ZoneYaxis=mesCoordZones[4];
158 _ZoneZaxis=mesCoordZones[5];
159 _ZoneRayon=mesCoordZones[6];
160 _ZoneHaut=mesCoordZones[7];
162 // ------------------------------------------------------------------------
163 void MonEditZone::InitValZonePipe()
164 // ------------------------------------------------------------------------
166 HOMARD::double_array_var mesCoordZones = aZone->GetCoords();
167 ASSERT(mesCoordZones->length() == 9 );
168 _ZoneXcentre=mesCoordZones[0];
169 _ZoneYcentre=mesCoordZones[1];
170 _ZoneZcentre=mesCoordZones[2];
171 _ZoneXaxis=mesCoordZones[3];
172 _ZoneYaxis=mesCoordZones[4];
173 _ZoneZaxis=mesCoordZones[5];
174 _ZoneRayon=mesCoordZones[6];
175 _ZoneHaut=mesCoordZones[7];
176 _ZoneRayonInt=mesCoordZones[8];
178 // ------------------------------------------------------------------------
179 void MonEditZone::SetBox()
180 // ------------------------------------------------------------------------
183 gBBox->setVisible(1);
184 gBSphere->setVisible(0);
185 gBCylindre->setVisible(0) ;
186 gBPipe->setVisible(0) ;
187 RBBox->setChecked(1);
189 RBCylinder->setDisabled(true);
190 RBPipe->setDisabled(true);
191 if ( _Type == 2 ) { RBSphere->setDisabled(true); }
192 else { RBSphere->setVisible(0);
193 RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0));
194 RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0));
195 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ;
196 QPixmap pix = resMgr->loadPixmap( "HOMARD", "boxdxy.png" ) ;
197 QIcon IS=QIcon(pix) ;
198 RBBox->setIcon(IS) ; }
201 SpinBox_Xmini->setValue(_ZoneXmin);
202 SpinBox_Xmaxi->setValue(_ZoneXmax);
205 if ( _Xincr > 0 ) {incr=_Xincr;} else{incr=1.;}
206 SpinBox_Xmini->setSingleStep(incr);
207 SpinBox_Xmaxi->setSingleStep(incr);
209 SpinBox_Ymini->setValue(_ZoneYmin);
210 SpinBox_Ymaxi->setValue(_ZoneYmax);
211 if ( _Yincr > 0 ) {incr=_Yincr;} else{incr=1.;}
212 SpinBox_Ymini->setSingleStep(incr);
213 SpinBox_Ymaxi->setSingleStep(incr);
215 SpinBox_Zmini->setValue(_ZoneZmin);
216 SpinBox_Zmaxi->setValue(_ZoneZmax);
217 if ( _Zincr > 0 ) {incr=_Zincr;} else{incr=1.;}
218 SpinBox_Zmini->setSingleStep(incr);
219 SpinBox_Zmaxi->setSingleStep(incr);
221 if ( _Type == 12 ) { SpinBox_Xmini->setDisabled(true) ;
222 SpinBox_Xmaxi->setDisabled(true) ; }
223 else if ( _Type == 13 ) { SpinBox_Ymini->setDisabled(true) ;
224 SpinBox_Ymaxi->setDisabled(true) ; }
225 else if ( _Type == 11 ) { SpinBox_Zmini->setDisabled(true) ;
226 SpinBox_Zmaxi->setDisabled(true) ; }
229 // ------------------------------------------------------------------------
230 void MonEditZone::SetSphere()
231 // ------------------------------------------------------------------------
233 gBBox->setVisible(0);
234 gBSphere->setVisible(1);
235 gBCylindre->setVisible(0) ;
236 gBPipe->setVisible(0) ;
237 RBSphere->setChecked(1);
238 RBBox->setDisabled(true);
239 RBCylinder->setDisabled(true);
240 RBPipe->setDisabled(true);
243 SpinBox_Xcentre->setValue(_ZoneXcentre);
244 if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); }
245 else { SpinBox_Xcentre->setSingleStep(1) ; }
247 SpinBox_Ycentre->setValue(_ZoneYcentre);
248 if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); }
249 else { SpinBox_Ycentre->setSingleStep(1) ; }
251 SpinBox_Zcentre->setValue(_ZoneZcentre);
252 if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); }
253 else { SpinBox_Zcentre->setSingleStep(1);}
255 SpinBox_Rayon->setValue(_ZoneRayon);
257 // ------------------------------------------------------------------------
258 void MonEditZone::SetCylinder()
259 // ------------------------------------------------------------------------
261 MESSAGE("SetCylinder _Xincr ="<<_Xincr<< " _Yincr ="<<_Yincr<< " _Zincr ="<<_Zincr);
262 gBBox->setVisible(0);
263 gBSphere->setVisible(0);
264 gBCylindre->setVisible(1) ;
265 gBPipe->setVisible(0) ;
266 RBCylinder->setChecked(1);
267 RBBox->setDisabled(true);
268 RBPipe->setDisabled(true);
269 if ( _Type == 5 ) { RBSphere->setDisabled(true); }
270 else { RBSphere->setVisible(0);
271 RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0));
272 RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0));
273 TLXbase->setText(QApplication::translate("CreateZone", "X centre", 0));
274 TLYbase->setText(QApplication::translate("CreateZone", "Y centre", 0));
275 TLZbase->setText(QApplication::translate("CreateZone", "Z centre", 0));
276 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ;
277 QPixmap pix = resMgr->loadPixmap( "HOMARD", "disk.png" ) ;
278 QIcon IS=QIcon(pix) ;
279 RBCylinder->setIcon(IS) ; }
282 SpinBox_Xbase->setValue(_ZoneXcentre);
283 if ( _Xincr > 0) { SpinBox_Xbase->setSingleStep(_Xincr); }
284 else { SpinBox_Xbase->setSingleStep(1) ; }
286 SpinBox_Ybase->setValue(_ZoneYcentre);
287 if ( _Yincr > 0) { SpinBox_Ybase->setSingleStep(_Yincr); }
288 else { SpinBox_Ybase->setSingleStep(1) ; }
290 SpinBox_Zbase->setValue(_ZoneZcentre);
291 if ( _Zincr > 0) { SpinBox_Zbase->setSingleStep(_Zincr); }
292 else { SpinBox_Zbase->setSingleStep(1) ;}
294 SpinBox_Radius->setValue(_ZoneRayon);
297 { SpinBox_Xaxis->setValue(_ZoneXaxis) ;
298 SpinBox_Yaxis->setValue(_ZoneYaxis) ;
299 SpinBox_Zaxis->setValue(_ZoneZaxis) ;
300 SpinBox_Haut->setValue(_ZoneHaut) ;
303 { SpinBox_Xaxis->setVisible(0) ;
304 SpinBox_Yaxis->setVisible(0) ;
305 SpinBox_Zaxis->setVisible(0) ;
306 SpinBox_Haut->setVisible(0) ;
307 TLXaxis->setVisible(0) ;
308 TLYaxis->setVisible(0) ;
309 TLZaxis->setVisible(0) ;
310 TLHaut->setVisible(0) ;
311 if ( _Type == 32 ) { SpinBox_Xbase->setDisabled(true) ; }
312 else if ( _Type == 33 ) { SpinBox_Ybase->setDisabled(true) ; }
313 else if ( _Type == 31 ) { SpinBox_Zbase->setDisabled(true) ; }
316 // ------------------------------------------------------------------------
317 void MonEditZone::SetPipe()
318 // ------------------------------------------------------------------------
320 MESSAGE("SetPipe _Xincr ="<<_Xincr<< " _Yincr ="<<_Yincr<< " _Zincr ="<<_Zincr);
321 gBBox->setVisible(0);
322 gBSphere->setVisible(0);
323 gBCylindre->setVisible(0) ;
324 gBPipe->setVisible(1) ;
325 RBPipe->setChecked(1);
326 RBBox->setDisabled(true);
327 RBCylinder->setDisabled(true);
328 if ( _Type == 7 ) { RBSphere->setDisabled(true); }
329 else { RBSphere->setVisible(0);
330 RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0));
331 RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0));
332 TLXbase_p->setText(QApplication::translate("CreateZone", "X centre", 0));
333 TLYbase_p->setText(QApplication::translate("CreateZone", "Y centre", 0));
334 TLZbase_p->setText(QApplication::translate("CreateZone", "Z centre", 0));
335 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ;
336 QPixmap pix = resMgr->loadPixmap( "HOMARD", "diskwithhole.png" ) ;
337 QIcon IS=QIcon(pix) ;
338 RBPipe->setIcon(IS) ; }
341 SpinBox_Xbase_p->setValue(_ZoneXcentre);
342 if ( _Xincr > 0) { SpinBox_Xbase_p->setSingleStep(_Xincr); }
343 else { SpinBox_Xbase_p->setSingleStep(1) ; }
345 SpinBox_Ybase_p->setValue(_ZoneYcentre);
346 if ( _Yincr > 0) { SpinBox_Ybase_p->setSingleStep(_Yincr); }
347 else { SpinBox_Ybase_p->setSingleStep(1) ; }
349 SpinBox_Zbase_p->setValue(_ZoneZcentre);
350 if ( _Zincr > 0) { SpinBox_Zbase_p->setSingleStep(_Zincr); }
351 else { SpinBox_Zbase_p->setSingleStep(1) ;}
353 SpinBox_Radius_int->setValue(_ZoneRayonInt);
354 SpinBox_Radius_ext->setValue(_ZoneRayon);
357 { SpinBox_Xaxis_p->setValue(_ZoneXaxis) ;
358 SpinBox_Yaxis_p->setValue(_ZoneYaxis) ;
359 SpinBox_Zaxis_p->setValue(_ZoneZaxis) ;
360 SpinBox_Haut_p->setValue(_ZoneHaut) ;
363 { SpinBox_Xaxis_p->setVisible(0) ;
364 SpinBox_Yaxis_p->setVisible(0) ;
365 SpinBox_Zaxis_p->setVisible(0) ;
366 SpinBox_Haut_p->setVisible(0) ;
367 TLXaxis_p->setVisible(0) ;
368 TLYaxis_p->setVisible(0) ;
369 TLZaxis_p->setVisible(0) ;
370 TLHaut_p->setVisible(0) ;
371 if ( _Type == 62 ) { SpinBox_Xbase_p->setDisabled(true) ; }
372 else if ( _Type == 63 ) { SpinBox_Ybase_p->setDisabled(true) ; }
373 else if ( _Type == 61 ) { SpinBox_Zbase_p->setDisabled(true) ; }
378 // ---------------------------------------------------
379 bool MonEditZone::CreateOrUpdateZone()
380 //----------------------------------------------------
381 // Pas de Creation de la zone
382 // Mise a jour des attributs de la Zone
388 case 11 : // il s agit d un rectangle
390 case 12 : // il s agit d un rectangle
392 case 13 : // il s agit d un rectangle
394 case 2 : // il s agit d un parallelepipede
395 { aZone->SetBox( _ZoneXmin, _ZoneXmax, _ZoneYmin, _ZoneYmax, _ZoneZmin, _ZoneZmax );
398 case 4 : // il s agit d une sphere
399 { aZone->SetSphere( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneRayon );
402 case 31 : // il s agit d un disque issu d'un cylindre
404 case 32 : // il s agit d un disque issu d'un cylindre
406 case 33 : // il s agit d un disque issu d'un cylindre
408 case 5 : // il s agit d un cylindre
409 { aZone->SetCylinder( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut );
412 case 61 : // il s agit d un disque issu d'un cylindre
414 case 62 : // il s agit d un disque issu d'un cylindre
416 case 63 : // il s agit d un disque issu d'un cylindre
418 case 7 : // il s agit d un tuyau
419 { aZone->SetPipe( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut, _ZoneRayonInt );
423 if (Chgt) myHomardGen->InvalideZone(_Name.toStdString().c_str());
424 HOMARD_UTILS::updateObjBrowser();
426 catch( const SALOME::SALOME_Exception& S_ex ) {
427 SalomeApp_Tools::QtCatchCorbaException( S_ex );