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 "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, QApplication::UnicodeUTF8));
194 RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0, QApplication::UnicodeUTF8));
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->setMinimum(0.);
256 SpinBox_Rayon->setValue(_ZoneRayon);
258 // ------------------------------------------------------------------------
259 void MonEditZone::SetCylinder()
260 // ------------------------------------------------------------------------
262 MESSAGE("SetCylinder _Xincr ="<<_Xincr<< " _Yincr ="<<_Yincr<< " _Zincr ="<<_Zincr);
263 gBBox->setVisible(0);
264 gBSphere->setVisible(0);
265 gBCylindre->setVisible(1) ;
266 gBPipe->setVisible(0) ;
267 RBCylinder->setChecked(1);
268 RBBox->setDisabled(true);
269 RBPipe->setDisabled(true);
270 if ( _Type == 5 ) { RBSphere->setDisabled(true); }
271 else { RBSphere->setVisible(0);
272 RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0, QApplication::UnicodeUTF8));
273 RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0, QApplication::UnicodeUTF8));
274 TLXbase->setText(QApplication::translate("CreateZone", "X centre", 0, QApplication::UnicodeUTF8));
275 TLYbase->setText(QApplication::translate("CreateZone", "Y centre", 0, QApplication::UnicodeUTF8));
276 TLZbase->setText(QApplication::translate("CreateZone", "Z centre", 0, QApplication::UnicodeUTF8));
277 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ;
278 QPixmap pix = resMgr->loadPixmap( "HOMARD", "disk.png" ) ;
279 QIcon IS=QIcon(pix) ;
280 RBCylinder->setIcon(IS) ; }
283 SpinBox_Xbase->setValue(_ZoneXcentre);
284 if ( _Xincr > 0) { SpinBox_Xbase->setSingleStep(_Xincr); }
285 else { SpinBox_Xbase->setSingleStep(1) ; }
287 SpinBox_Ybase->setValue(_ZoneYcentre);
288 if ( _Yincr > 0) { SpinBox_Ybase->setSingleStep(_Yincr); }
289 else { SpinBox_Ybase->setSingleStep(1) ; }
291 SpinBox_Zbase->setValue(_ZoneZcentre);
292 if ( _Zincr > 0) { SpinBox_Zbase->setSingleStep(_Zincr); }
293 else { SpinBox_Zbase->setSingleStep(1) ;}
295 SpinBox_Radius->setMinimum(0.);
296 SpinBox_Radius->setValue(_ZoneRayon);
299 { SpinBox_Xaxis->setValue(_ZoneXaxis) ;
300 SpinBox_Yaxis->setValue(_ZoneYaxis) ;
301 SpinBox_Zaxis->setValue(_ZoneZaxis) ;
302 SpinBox_Haut->setValue(_ZoneHaut) ;
305 { SpinBox_Xaxis->setVisible(0) ;
306 SpinBox_Yaxis->setVisible(0) ;
307 SpinBox_Zaxis->setVisible(0) ;
308 SpinBox_Haut->setVisible(0) ;
309 TLXaxis->setVisible(0) ;
310 TLYaxis->setVisible(0) ;
311 TLZaxis->setVisible(0) ;
312 TLHaut->setVisible(0) ;
313 if ( _Type == 32 ) { SpinBox_Xbase->setDisabled(true) ; }
314 else if ( _Type == 33 ) { SpinBox_Ybase->setDisabled(true) ; }
315 else if ( _Type == 31 ) { SpinBox_Zbase->setDisabled(true) ; }
318 // ------------------------------------------------------------------------
319 void MonEditZone::SetPipe()
320 // ------------------------------------------------------------------------
322 MESSAGE("SetPipe _Xincr ="<<_Xincr<< " _Yincr ="<<_Yincr<< " _Zincr ="<<_Zincr);
323 gBBox->setVisible(0);
324 gBSphere->setVisible(0);
325 gBCylindre->setVisible(0) ;
326 gBPipe->setVisible(1) ;
327 RBPipe->setChecked(1);
328 RBBox->setDisabled(true);
329 RBCylinder->setDisabled(true);
330 if ( _Type == 7 ) { RBSphere->setDisabled(true); }
331 else { RBSphere->setVisible(0);
332 RBPipe->setText(QApplication::translate("CreateZone", "Disk with hole", 0, QApplication::UnicodeUTF8));
333 RBCylinder->setText(QApplication::translate("CreateZone", "Disk", 0, QApplication::UnicodeUTF8));
334 TLXbase_p->setText(QApplication::translate("CreateZone", "X centre", 0, QApplication::UnicodeUTF8));
335 TLYbase_p->setText(QApplication::translate("CreateZone", "Y centre", 0, QApplication::UnicodeUTF8));
336 TLZbase_p->setText(QApplication::translate("CreateZone", "Z centre", 0, QApplication::UnicodeUTF8));
337 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr() ;
338 QPixmap pix = resMgr->loadPixmap( "HOMARD", "diskwithhole.png" ) ;
339 QIcon IS=QIcon(pix) ;
340 RBPipe->setIcon(IS) ; }
343 SpinBox_Xbase_p->setValue(_ZoneXcentre);
344 if ( _Xincr > 0) { SpinBox_Xbase_p->setSingleStep(_Xincr); }
345 else { SpinBox_Xbase_p->setSingleStep(1) ; }
347 SpinBox_Ybase_p->setValue(_ZoneYcentre);
348 if ( _Yincr > 0) { SpinBox_Ybase_p->setSingleStep(_Yincr); }
349 else { SpinBox_Ybase_p->setSingleStep(1) ; }
351 SpinBox_Zbase_p->setValue(_ZoneZcentre);
352 if ( _Zincr > 0) { SpinBox_Zbase_p->setSingleStep(_Zincr); }
353 else { SpinBox_Zbase_p->setSingleStep(1) ;}
355 SpinBox_Radius_int->setMinimum(0.);
356 SpinBox_Radius_int->setValue(_ZoneRayonInt);
357 SpinBox_Radius_ext->setMinimum(0.);
358 SpinBox_Radius_ext->setValue(_ZoneRayon);
361 { SpinBox_Xaxis_p->setValue(_ZoneXaxis) ;
362 SpinBox_Yaxis_p->setValue(_ZoneYaxis) ;
363 SpinBox_Zaxis_p->setValue(_ZoneZaxis) ;
364 SpinBox_Haut_p->setValue(_ZoneHaut) ;
367 { SpinBox_Xaxis_p->setVisible(0) ;
368 SpinBox_Yaxis_p->setVisible(0) ;
369 SpinBox_Zaxis_p->setVisible(0) ;
370 SpinBox_Haut_p->setVisible(0) ;
371 TLXaxis_p->setVisible(0) ;
372 TLYaxis_p->setVisible(0) ;
373 TLZaxis_p->setVisible(0) ;
374 TLHaut_p->setVisible(0) ;
375 if ( _Type == 62 ) { SpinBox_Xbase_p->setDisabled(true) ; }
376 else if ( _Type == 63 ) { SpinBox_Ybase_p->setDisabled(true) ; }
377 else if ( _Type == 61 ) { SpinBox_Zbase_p->setDisabled(true) ; }
382 // ---------------------------------------------------
383 bool MonEditZone::CreateOrUpdateZone()
384 //----------------------------------------------------
385 // Pas de Creation de la zone
386 // Mise a jour des attributs de la Zone
392 case 11 : // il s agit d un rectangle
394 case 12 : // il s agit d un rectangle
396 case 13 : // il s agit d un rectangle
398 case 2 : // il s agit d un parallelepipede
399 { aZone->SetBox( _ZoneXmin, _ZoneXmax, _ZoneYmin, _ZoneYmax, _ZoneZmin, _ZoneZmax );
402 case 4 : // il s agit d une sphere
403 { aZone->SetSphere( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneRayon );
406 case 31 : // il s agit d un disque issu d'un cylindre
408 case 32 : // il s agit d un disque issu d'un cylindre
410 case 33 : // il s agit d un disque issu d'un cylindre
412 case 5 : // il s agit d un cylindre
413 { aZone->SetCylinder( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut );
416 case 61 : // il s agit d un disque issu d'un cylindre
418 case 62 : // il s agit d un disque issu d'un cylindre
420 case 63 : // il s agit d un disque issu d'un cylindre
422 case 7 : // il s agit d un tuyau
423 { aZone->SetPipe( _ZoneXcentre, _ZoneYcentre, _ZoneZcentre, _ZoneXaxis, _ZoneYaxis, _ZoneZaxis, _ZoneRayon, _ZoneHaut, _ZoneRayonInt );
427 if (Chgt) myHomardGen->InvalideZone(_Name.toStdString().c_str());
428 HOMARD_UTILS::updateObjBrowser();
430 catch( const SALOME::SALOME_Exception& S_ex ) {
431 SalomeApp_Tools::QtCatchCorbaException( S_ex );