CURA-4821 loading gcode will now delete all existing models from all build plates and delete existing layer data to be processed

This commit is contained in:
Jack Ha 2018-01-22 12:57:50 +01:00
parent 93dbf93ee0
commit 8d8fa0269a
2 changed files with 9 additions and 7 deletions

View file

@ -1040,8 +1040,9 @@ class CuraApplication(QtApplication):
Selection.add(node)
## Delete all nodes containing mesh data in the scene.
# \param only_selectable. Set this to False to delete objects from all build plates
@pyqtSlot()
def deleteAll(self):
def deleteAll(self, only_selectable = True):
Logger.log("i", "Clearing scene")
if not self.getController().getToolsEnabled():
return
@ -1052,7 +1053,9 @@ class CuraApplication(QtApplication):
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 not node.isSelectable():
if only_selectable and not node.isSelectable():
continue
if not node.callDecoration("isSliceable"):
continue # Only remove nodes that are selectable.
if node.getParent() and node.getParent().callDecoration("isGroup"):
continue # Grouped nodes don't need resetting as their parent (the group) is resetted)
@ -1431,7 +1434,7 @@ class CuraApplication(QtApplication):
self._currently_loading_files.append(f)
if extension in self._non_sliceable_extensions:
self.deleteAll()
self.deleteAll(only_selectable = False)
job = ReadMeshJob(f)
job.finished.connect(self._readMeshFinished)

View file

@ -426,11 +426,10 @@ class CuraEngineBackend(QObject, Backend):
if not isinstance(source, SceneNode):
return
# This case checks if the source node is a node that contains a GCode. In this case the
# cached layer data is removed so the previous data is not rendered - CURA-4821
# This case checks if the source node is a node that contains GCode. In this case the
# current layer data is removed so the previous data is not rendered - CURA-4821
if source.callDecoration("isBlockSlicing") and source.callDecoration("getLayerData"):
if self._stored_optimized_layer_data:
del self._stored_optimized_layer_data[source.callDecoration("getBuildPlateNumber")]
self._stored_optimized_layer_data = {}
build_plate_changed = set()
source_build_plate_number = source.callDecoration("getBuildPlateNumber")