[FEM] fix Gmsh deletion handling

- fixes the issue that one could accidentally delete a mesh despite it has submeshes

- also a coding style improvement
This commit is contained in:
Uwe
2022-03-25 05:50:31 +01:00
parent 5482c4be95
commit 1baf3f2bfa
2 changed files with 13 additions and 8 deletions

View File

@@ -33,6 +33,7 @@ import FreeCAD
import FreeCADGui
import FemGui
from PySide import QtGui
from femtaskpanels import task_mesh_gmsh
from femtools.femutils import is_of_type
# from . import view_base_femobject
@@ -204,11 +205,17 @@ class VPMeshGmsh:
def onDelete(self, feature, subelements):
children = self.claimChildren()
if len(children) > 0:
try:
for obj in children:
obj.ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: {0} \n".format(err))
# issue a warning
bodyMessage = "The mesh contains submesh objects, therefore the\nfollowing referencing objects might be lost:\n"
for obj in children:
bodyMessage += "\n" + obj.Label
bodyMessage += "\n\nAre you sure you want to continue?"
reply = QtGui.QMessageBox.warning(None, "Object dependencies", bodyMessage,
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
return True
else:
return False
return True
def canDragObjects(self):

View File

@@ -73,8 +73,6 @@ class VPResultMechanical(view_base_femconstraint.VPBaseFemConstraint):
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
return True
pass
if reply == QtGui.QMessageBox.No:
else:
return False
pass
return True