1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2006-2020 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # if you already have plugins defined in a salome_plugins.py file, add this file at the end.
23 # if not, copy this file as ${HOME}/Plugins/smesh_plugins.py or ${APPLI}/Plugins/smesh_plugins.py
30 from blocFissure import gmu
33 def fissureCoudeDlg(context):
34 # get context study, salomeGui
40 from qtsalome import QFileDialog, QMessageBox, QPalette, QColor, QDialog
41 from blocFissure.ihm.fissureCoude_ui import Ui_Dialog
43 class fissureCoudeDialog(QDialog):
46 QDialog.__init__(self)
47 # Set up the user interface from Designer.
51 self.blackPalette = self.ui.dsb_angle.palette()
52 self.redPalette = QPalette()
53 self.redPalette.setColor(QPalette.Text, QColor(255,0,0))
57 self.initDialog(self.defaut)
58 self.ui.dsb_angle.setSpecialValueText("saisie_obligatoire")
59 self.ui.dsb_rCintr.setSpecialValueText("saisie_obligatoire")
60 self.ui.dsb_lTubeP1.setSpecialValueText("saisie_obligatoire")
61 self.ui.dsb_lTubeP2.setSpecialValueText("saisie_obligatoire")
62 self.ui.dsb_epais.setSpecialValueText("saisie_obligatoire")
63 self.ui.dsb_dext.setSpecialValueText("saisie_obligatoire")
64 self.ui.dsb_profondeur.setSpecialValueText("saisie_obligatoire")
65 self.ui.dsb_longueur.setSpecialValueText("saisie_obligatoire")
66 self.ui.dsb_azimut.setSpecialValueText("saisie_obligatoire")
67 self.ui.dsb_orientation.setSpecialValueText("saisie_obligatoire")
68 self.ui.dsb_posiAngul.setSpecialValueText("saisie_obligatoire")
69 self.ui.dsb_absCurv.setSpecialValueText("saisie_obligatoire")
70 self.ui.sb_nbTranches.setSpecialValueText("saisie_obligatoire")
71 self.ui.sb_nbCouronne.setSpecialValueText("saisie_obligatoire")
72 self.ui.sb_nbSecteur.setSpecialValueText("saisie_obligatoire")
73 self.ui.dsb_aretesFaceFissure.setSpecialValueText("automatique")
74 self.ui.dsb_influence.setSpecialValueText("automatique")
75 self.ui.lb_calcul.hide()
77 # Connect up the buttons.
78 self.ui.pb_valPrec.clicked.connect(self.readValPrec)
79 self.ui.pb_reset.clicked.connect(self.resetVal)
80 self.ui.pb_recharger.clicked.connect(self.recharger)
81 self.ui.pb_sauver.clicked.connect(self.sauver)
82 self.ui.buttonBox.accepted.disconnect(self.accept)
83 self.ui.buttonBox.accepted.connect(self.execute)
102 cbOptDiscrSain = False, \
103 cbOptDiscrFiss = False, \
104 rbPosiAngul = True, \
106 cbForceEllipse = False, \
113 aretesFaceFissure = 0.0, \
117 def initDialog(self, dico):
118 self.ui.dsb_angle.setValue(dico['angle'])
119 self.ui.dsb_rCintr.setValue(dico['rCintr'])
120 self.ui.dsb_lTubeP1.setValue(dico['lTubeP1'])
121 self.ui.dsb_lTubeP2.setValue(dico['lTubeP2'])
122 self.ui.dsb_epais.setValue(dico['epais'])
123 self.ui.dsb_dext.setValue(dico['dext'])
124 self.ui.dsb_profondeur.setValue(dico['profondeur'])
125 self.ui.dsb_longueur.setValue(dico['longueur'])
126 self.ui.dsb_azimut.setValue(dico['azimut'])
127 self.ui.dsb_orientation.setValue(dico['orientation'])
128 self.ui.dsb_posiAngul.setValue(dico['posiAngul'])
129 self.ui.dsb_absCurv.setValue(dico['absCurv'])
130 self.ui.sb_nbTranches.setValue(dico['nbTranches'])
131 self.ui.sb_nbCouronne.setValue(dico['nbCouronnes'])
132 self.ui.sb_nbSecteur.setValue(dico['nbSecteurs'])
133 self.ui.dsb_aretesFaceFissure.setValue(dico['aretesFaceFissure'])
134 self.ui.dsb_influence.setValue(dico['influence'])
135 self.ui.sb_nbAxeTubeP1.setValue(dico['nbAxeTubeP1'])
136 self.ui.sb_nbAxeTubeP2.setValue(dico['nbAxeTubeP2'])
137 self.ui.sb_nbAxeCoude.setValue(dico['nbAxeCoude'])
138 self.ui.sb_nbCirconf.setValue(dico['nbCirconf'])
139 self.ui.sb_nbEpaisseur.setValue(dico['nbEpaisseur'])
140 self.ui.dsb_rayonTore.setValue(dico['rayonTore'])
141 #self.ui.cb_optDiscrSain.setChecked(False)
142 #self.ui.gb_discrSain.setShown(False)
143 self.ui.cb_optDiscrSain.setChecked(not(dico['cbOptDiscrSain']))
144 self.ui.cb_optDiscrSain.click()
145 self.ui.cb_optDiscrFiss.setChecked(not(dico['cbOptDiscrFiss']))
146 self.ui.cb_optDiscrFiss.click()
147 if dico['rbPosiAngul']:
148 self.ui.dsb_absCurv.setEnabled(False)
149 self.ui.dsb_posiAngul.setEnabled(True)
150 self.ui.rb_posiAngul.setChecked(True)
151 #self.ui.rb_posiAngul.click()
153 self.ui.dsb_absCurv.setEnabled(True)
154 self.ui.dsb_posiAngul.setEnabled(False)
155 self.ui.rb_absCurv.setChecked(True)
156 #self.ui.rb_absCurv.click()
157 self.ui.rb_fissExt.setChecked(dico['rbFissExt'])
158 self.ui.cb_forceEllipse.setChecked(dico['cbForceEllipse'])
159 incomplet = self.testval(dico)
162 def testval(self, dico):
164 if dico['angle'] < -180.0:
165 self.ui.dsb_angle.setPalette(self.redPalette)
168 self.ui.dsb_angle.setPalette(self.blackPalette)
170 if dico['rCintr'] == 0.0:
171 self.ui.dsb_rCintr.setPalette(self.redPalette)
174 self.ui.dsb_rCintr.setPalette(self.blackPalette)
176 if dico['lTubeP1'] == 0.0:
177 self.ui.dsb_lTubeP1.setPalette(self.redPalette)
180 self.ui.dsb_lTubeP1.setPalette(self.blackPalette)
182 if dico['lTubeP2'] == 0.0:
183 self.ui.dsb_lTubeP2.setPalette(self.redPalette)
186 self.ui.dsb_lTubeP2.setPalette(self.blackPalette)
188 if dico['epais'] == 0.0:
189 self.ui.dsb_epais.setPalette(self.redPalette)
192 self.ui.dsb_epais.setPalette(self.blackPalette)
194 if dico['dext'] == 0.0:
195 self.ui.dsb_dext.setPalette(self.redPalette)
198 self.ui.dsb_dext.setPalette(self.blackPalette)
200 if dico['profondeur'] == 0.0:
201 self.ui.dsb_profondeur.setPalette(self.redPalette)
204 self.ui.dsb_profondeur.setPalette(self.blackPalette)
206 if dico['longueur'] == 0.0:
207 self.ui.dsb_longueur.setPalette(self.redPalette)
210 self.ui.dsb_longueur.setPalette(self.blackPalette)
212 if dico['azimut'] < -180.0:
213 self.ui.dsb_azimut.setPalette(self.redPalette)
216 self.ui.dsb_azimut.setPalette(self.blackPalette)
218 if dico['orientation'] < 0.0:
219 self.ui.dsb_orientation.setPalette(self.redPalette)
222 self.ui.dsb_orientation.setPalette(self.blackPalette)
224 if ( ( dico['posiAngul'] < -180.0 ) and dico['rbPosiAngul'] ):
225 self.ui.dsb_posiAngul.setPalette(self.redPalette)
228 self.ui.dsb_posiAngul.setPalette(self.blackPalette)
230 if ( ( dico['absCurv'] == 0.0 ) and ( not dico['rbPosiAngul'] ) ):
231 self.ui.dsb_absCurv.setPalette(self.redPalette)
234 self.ui.dsb_absCurv.setPalette(self.blackPalette)
236 if dico['nbTranches'] == 7:
237 self.ui.sb_nbTranches.setPalette(self.redPalette)
240 self.ui.sb_nbTranches.setPalette(self.blackPalette)
242 if dico['nbCouronnes'] == 1:
243 self.ui.sb_nbCouronne.setPalette(self.redPalette)
246 self.ui.sb_nbCouronne.setPalette(self.blackPalette)
248 if dico['nbSecteurs'] == 3:
249 self.ui.sb_nbSecteur.setPalette(self.redPalette)
252 self.ui.sb_nbSecteur.setPalette(self.blackPalette)
254 print("incomplet: ", incomplet)
257 def fileDefault(self):
258 filedef = os.path.expanduser( os.path.join(os.environ["HOME"],".config", "salome", "dialogFissureCoude.dic") )
262 def writeDefault(self, dico):
263 filedef = self.fileDefault()
264 with open(filedef, 'w') as f:
267 def readValPrec(self):
268 filedef = self.fileDefault()
269 if os.path.exists(filedef):
270 with open(filedef, 'r') as f:
274 self.initDialog(dico)
278 self.initDialog(self.defaut)
282 fileDiag = QFileDialog(self)
283 fileDiag.setFileMode(QFileDialog.AnyFile)
284 fileDiag.setNameFilter("Parametres *.dic (*.dic)")
285 fileDiag.setViewMode(QFileDialog.List)
286 if fileDiag.exec_() :
287 fileNames = fileDiag.selectedFiles()
288 filedef = fileNames[0]
289 dico = self.creeDico()
290 with open(filedef, 'w') as f:
295 fileDiag = QFileDialog(self)
296 fileDiag.setFileMode(QFileDialog.ExistingFile)
297 fileDiag.setNameFilter("Parametres *.dic (*.dic)")
298 fileDiag.setViewMode(QFileDialog.Detail)
299 if fileDiag.exec_() :
300 fileNames = fileDiag.selectedFiles()
301 filedef = fileNames[0]
303 if os.path.exists(filedef):
304 with open(filedef, 'r') as f:
308 self.initDialog(dico)
312 angle = self.ui.dsb_angle.value(), \
313 rCintr = self.ui.dsb_rCintr.value(), \
314 lTubeP1 = self.ui.dsb_lTubeP1.value(), \
315 lTubeP2 = self.ui.dsb_lTubeP2.value(), \
316 epais = self.ui.dsb_epais.value(), \
317 dext = self.ui.dsb_dext.value(), \
318 profondeur = self.ui.dsb_profondeur.value(), \
319 longueur = self.ui.dsb_longueur.value(), \
320 azimut = self.ui.dsb_azimut.value(), \
321 orientation = self.ui.dsb_orientation.value(), \
322 posiAngul = self.ui.dsb_posiAngul.value(), \
323 absCurv = self.ui.dsb_absCurv.value(), \
324 nbTranches = self.ui.sb_nbTranches.value(), \
325 nbCouronnes = self.ui.sb_nbCouronne.value(), \
326 nbSecteurs = self.ui.sb_nbSecteur.value(), \
327 cbOptDiscrSain = self.ui.cb_optDiscrSain.isChecked(), \
328 cbOptDiscrFiss = self.ui.cb_optDiscrFiss.isChecked(), \
329 rbPosiAngul = self.ui.rb_posiAngul.isChecked(), \
330 rbFissExt = self.ui.rb_fissExt.isChecked(), \
331 cbForceEllipse = self.ui.cb_forceEllipse.isChecked(), \
332 nbAxeTubeP1 = self.ui.sb_nbAxeTubeP1.value(), \
333 nbAxeTubeP2 = self.ui.sb_nbAxeTubeP2.value(), \
334 nbAxeCoude = self.ui.sb_nbAxeCoude.value(), \
335 nbCirconf = self.ui.sb_nbCirconf.value(), \
336 nbEpaisseur = self.ui.sb_nbEpaisseur.value(), \
337 rayonTore = self.ui.dsb_rayonTore.value(), \
338 aretesFaceFissure = self.ui.dsb_aretesFaceFissure.value(), \
339 influence = self.ui.dsb_influence.value(), \
344 def checkValues(self):
348 from blocFissure.gmu import initLog
350 initLog.setVerbose() # don't set the level too early, to be able to modify it
351 from blocFissure.gmu import geomsmesh
352 from blocFissure.gmu.casStandard import casStandard
353 from blocFissure.ihm.fissureCoude_ihm import fissureCoude_ihm
355 dico = self.creeDico()
356 NOK = self.testval(dico)
358 dico['lenSegPipe'] = (dico['longueur'] + math.pi*dico['profondeur'])/dico['nbTranches']
359 print('lenSegPipe', dico['lenSegPipe'])
360 areteMinAngle = (dico['rCintr'] -dico['dext']/2.0)*(dico['angle']*math.pi/180.0)/dico['nbAxeCoude']
361 print('areteMinAngle', areteMinAngle)
362 areteMinCirco = dico['dext']*math.pi/(2*dico['nbCirconf'])
363 print('areteMinCirco', areteMinCirco)
364 areteMinEpais = dico['epais']/dico['nbEpaisseur']
365 print('areteMinEpais', areteMinEpais)
366 if dico['influence'] == 0:
367 dico['influence'] = max(areteMinAngle, areteMinCirco, areteMinEpais)
368 print('influence', dico['influence'])
369 if dico['aretesFaceFissure'] == 0:
370 dico['aretesFaceFissure'] = (areteMinAngle + areteMinCirco)/2.0
371 print('aretesFaceFissure', dico['aretesFaceFissure'])
372 if not dico['rbPosiAngul']:
373 rmoy = (dico['dext'] - dico['epais'])/2.0
375 if not dico['rbFissExt']:
377 dico['posiAngul'] = (180.0/math.pi)*dico['absCurv']/(dico['rCintr']+(rmoy+eta*dico['epais']/2.0)*math.cos(math.pi*dico['azimut']/180.))
378 print('posiAngul' , dico['posiAngul'])
380 self.writeDefault(dico)
381 self.ui.lb_calcul.show()
382 probleme = fissureCoude_ihm(0)
383 probleme.setDicoParams(dico)
384 probleme.executeProbleme()
388 # ----------------------------------------------------------------------------
390 window = fissureCoudeDialog()
391 # window.ui.dsb_tolerance.setValue(0.01)
396 result = window.result()
399 print("dialog accepted, check")
400 retry = window.checkValues()
402 print("dialog rejected, exit")