general crack dialog, user message mecanism for some errors

This commit is contained in:
Paul RASCLE 2016-02-29 15:12:14 +01:00
parent 4370e1798b
commit fe678b8dc0
4 changed files with 50 additions and 2 deletions

View File

@ -51,6 +51,7 @@ SET(plugin_SCRIPTS
facesVolumesToriques.py
findWireEndVertices.py
findWireIntermediateVertices.py
fissError.py
fissureCoude.py
fissureGenerique.py
fusionMaillageAttributionDefaut.py

View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
class fissError(Exception):
"""
usage:
try:
instructions()
except:
raise fissError(traceback.extract_stack(),"mon message")
"""
def __init__(self, pile, msg):
self.pile = pile
self.msg = msg
def __str__(self):
return 'msg=%s\npile=%s\n'%(self.msg, repr(self.pile))

View File

@ -6,8 +6,10 @@ from geomsmesh import geompy
from geomsmesh import geomPublish
from geomsmesh import geomPublishInFather
import initLog
import traceback
from findWireEndVertices import findWireEndVertices
from prolongeWire import prolongeWire
from fissError import fissError
def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
"""
@ -33,7 +35,12 @@ def partitionneFissureParPipe(shapesFissure, elementsDefaut, rayonPipe):
cercle = geompy.MakeRotation(cercle, norms[0], math.pi/3.0 ) # éviter d'avoir l'arête de couture du pipe presque confondue avec la face fissure
geomPublish(initLog.debug, cercle, 'cercle')
fondFissProlonge = prolongeWire(fondFiss, extrem, norms, 2*rayonPipe)
pipeFiss = geompy.MakePipe(cercle, fondFissProlonge)
try:
pipeFiss = geompy.MakePipe(cercle, fondFissProlonge)
except:
texte = "génération du pipe le long de la ligne de fond de fissure prolongée impossible. "
texte += "Cause éventuelle : la ligne s'autointersecte lorsqu'on la prolonge."
raise fissError(traceback.extract_stack(),texte)
geomPublish(initLog.debug, pipeFiss, 'pipeFiss')
partFissPipe = geompy.MakePartition([shapeDefaut, pipeFiss], [], [], [], geompy.ShapeType["FACE"], 0, [], 1)
geomPublish(initLog.debug, partFissPipe, 'partFissPipe')

View File

@ -41,6 +41,7 @@ def fissureGeneraleDlg(context):
from PyQt4.QtGui import QMessageBox
from PyQt4.QtGui import QPalette
from PyQt4.QtGui import QColor
from PyQt4.QtCore import QString
from fissureGenerale_ui import Ui_Dialog
class fissureGeneraleDialog(QtGui.QDialog):
@ -307,6 +308,7 @@ def fissureGeneraleDlg(context):
areteFaceFissure = self.ui.dsb_areteFaceFissure.value(),
reptrav = str(self.ui.le_reptrav.text()),
nomres = str(self.ui.le_nomres.text()),
verbosite = self.ui.cb_log.currentIndex()
)
print dico
return dico
@ -325,7 +327,28 @@ def fissureGeneraleDlg(context):
self.setLogVerbosity(logfile)
from blocFissure.gmu import geomsmesh # après intialisation log dans setLogVerbosity
from blocFissure.gmu.casStandard import casStandard # après intialisation log dans setLogVerbosity
execInstance = casStandard(dico)
from blocFissure.gmu.fissError import fissError
try:
execInstance = casStandard(dico)
except fissError as erreur:
print '-'*60
print type(erreur)
print '-'*60
print erreur.msg
print '-'*60
for ligne in erreur.pile:
print repr(ligne)
print '-'*60
texte = erreur.msg
# texte += +"<br>" +'-'*60 +"<br>"
# for ligne in erreur.pile:
# texte += repr(ligne) +"<br>"
mbox = QMessageBox(self)
mbox.setWindowTitle("erreur blocFissure")
mbox.setText(QString.fromUtf8(texte))
mbox.exec_()
# except Exception as erreur:
# print "exception non répertoriée"
self.NOK = NOK
self.accept()