From: Paul RASCLE Date: Mon, 29 Feb 2016 14:12:14 +0000 (+0100) Subject: general crack dialog, user message mecanism for some errors X-Git-Tag: V7_8_0a2~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fe678b8dc0f994b3bfc0dc7ee681edcec466dbb0;p=modules%2Fsmesh.git general crack dialog, user message mecanism for some errors --- diff --git a/src/Tools/blocFissure/gmu/CMakeLists.txt b/src/Tools/blocFissure/gmu/CMakeLists.txt index c0afb86be..64c18760a 100644 --- a/src/Tools/blocFissure/gmu/CMakeLists.txt +++ b/src/Tools/blocFissure/gmu/CMakeLists.txt @@ -51,6 +51,7 @@ SET(plugin_SCRIPTS facesVolumesToriques.py findWireEndVertices.py findWireIntermediateVertices.py + fissError.py fissureCoude.py fissureGenerique.py fusionMaillageAttributionDefaut.py diff --git a/src/Tools/blocFissure/gmu/fissError.py b/src/Tools/blocFissure/gmu/fissError.py new file mode 100644 index 000000000..74b058740 --- /dev/null +++ b/src/Tools/blocFissure/gmu/fissError.py @@ -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)) + diff --git a/src/Tools/blocFissure/gmu/partitionneFissureParPipe.py b/src/Tools/blocFissure/gmu/partitionneFissureParPipe.py index 7d6289797..9ad26b854 100644 --- a/src/Tools/blocFissure/gmu/partitionneFissureParPipe.py +++ b/src/Tools/blocFissure/gmu/partitionneFissureParPipe.py @@ -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') diff --git a/src/Tools/blocFissure/ihm/fissureGenerale_plugin.py b/src/Tools/blocFissure/ihm/fissureGenerale_plugin.py index 9e602ed68..e2d5d9dc1 100644 --- a/src/Tools/blocFissure/ihm/fissureGenerale_plugin.py +++ b/src/Tools/blocFissure/ihm/fissureGenerale_plugin.py @@ -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 += +"
" +'-'*60 +"
" +# for ligne in erreur.pile: +# texte += repr(ligne) +"
" + 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()