Merge branch 'master' into feature_intent

This commit is contained in:
Diego Prado Gesto 2019-09-13 09:02:30 +02:00
commit d38e60ce06
232 changed files with 25907 additions and 9339 deletions

View file

@ -69,6 +69,7 @@ from cura.Scene.BuildPlateDecorator import BuildPlateDecorator
from cura.Scene.ConvexHullDecorator import ConvexHullDecorator
from cura.Scene.CuraSceneController import CuraSceneController
from cura.Scene.CuraSceneNode import CuraSceneNode
from cura.Scene.GCodeListDecorator import GCodeListDecorator
from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator
from cura.Scene import ZOffsetDecorator
@ -1344,7 +1345,13 @@ class CuraApplication(QtApplication):
Logger.log("i", "Reloading all loaded mesh data.")
nodes = []
has_merged_nodes = False
gcode_filename = None # type: Optional[str]
for node in DepthFirstIterator(self.getController().getScene().getRoot()):
# Objects loaded from Gcode should also be included.
gcode_filename = node.callDecoration("getGcodeFileName")
if gcode_filename is not None:
break
if not isinstance(node, CuraSceneNode) or not node.getMeshData():
if node.getName() == "MergedMesh":
has_merged_nodes = True
@ -1352,6 +1359,11 @@ class CuraApplication(QtApplication):
nodes.append(node)
# We can open only one gcode file at the same time. If the current view has a gcode file open, just reopen it
# for reloading.
if gcode_filename:
self._openFile(gcode_filename)
if not nodes:
return
@ -1826,3 +1838,40 @@ class CuraApplication(QtApplication):
return main_window.height()
else:
return 0
@pyqtSlot()
def deleteAll(self, only_selectable: bool = True) -> None:
super().deleteAll(only_selectable = only_selectable)
# Also remove nodes with LayerData
self._removeNodesWithLayerData(only_selectable = only_selectable)
def _removeNodesWithLayerData(self, only_selectable: bool = True) -> None:
Logger.log("i", "Clearing scene")
nodes = []
for node in DepthFirstIterator(self.getController().getScene().getRoot()):
if not isinstance(node, SceneNode):
continue
if not node.isEnabled():
continue
if (not node.getMeshData() and not node.callDecoration("getLayerData")) and not node.callDecoration("isGroup"):
continue # Node that doesnt have a mesh and is not a group.
if only_selectable and not node.isSelectable():
continue # Only remove nodes that are selectable.
if not node.callDecoration("isSliceable") and not node.callDecoration("getLayerData") and not node.callDecoration("isGroup"):
continue # Grouped nodes don't need resetting as their parent (the group) is resetted)
nodes.append(node)
if nodes:
from UM.Operations.GroupedOperation import GroupedOperation
op = GroupedOperation()
for node in nodes:
from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
op.addOperation(RemoveSceneNodeOperation(node))
# Reset the print information
self.getController().getScene().sceneChanged.emit(node)
op.push()
from UM.Scene.Selection import Selection
Selection.clear()