From 6c9d7b5a2ef29f0d022d09d66c216e85e38053c9 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 23 Jan 2018 09:49:26 +0100 Subject: [PATCH] Fixes for resetting print time information when removing all or last model, reduce signals being used for print time resetting - CURA-4852 --- cura/CuraActions.py | 4 ++++ cura/CuraApplication.py | 6 +++--- cura/PrintInformation.py | 31 +++++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/cura/CuraActions.py b/cura/CuraActions.py index f5aace805b..f517ec4217 100644 --- a/cura/CuraActions.py +++ b/cura/CuraActions.py @@ -94,6 +94,10 @@ class CuraActions(QObject): removed_group_nodes.append(group_node) op.addOperation(SetParentOperation(remaining_nodes_in_group[0], group_node.getParent())) op.addOperation(RemoveSceneNodeOperation(group_node)) + + # Reset the print information + Application.getInstance().getController().getScene().sceneChanged.emit(node) + op.push() ## Set the extruder that should be used to print the selection. diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index bfcbe529f7..8df9f01e91 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1066,12 +1066,12 @@ class CuraApplication(QtApplication): for node in nodes: op.addOperation(RemoveSceneNodeOperation(node)) + # Reset the print information + self.getController().getScene().sceneChanged.emit(node) + op.push() Selection.clear() - # Reset the print information: - self.getController().getScene().sceneChanged.emit(node) - ## Reset all translation on nodes with mesh data. @pyqtSlot() def resetAllTranslation(self): diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index 5d5d59ed3b..c03cafe667 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -8,7 +8,9 @@ from UM.Application import Application from UM.Logger import Logger from UM.Qt.Duration import Duration from UM.Preferences import Preferences +from UM.Scene.SceneNode import SceneNode from UM.Settings.ContainerRegistry import ContainerRegistry +from cura.Scene.CuraSceneNode import CuraSceneNode from cura.Settings.ExtruderManager import ExtruderManager from typing import Dict @@ -65,7 +67,7 @@ class PrintInformation(QObject): self._backend = Application.getInstance().getBackend() if self._backend: self._backend.printDurationMessage.connect(self._onPrintDurationMessage) - Application.getInstance().getController().getScene().sceneChanged.connect(self.setToZeroPrintInformation) + Application.getInstance().getController().getScene().sceneChanged.connect(self._onSceneChanged) self._base_name = "" self._abbr_machine = "" @@ -395,12 +397,25 @@ class PrintInformation(QObject): return result # Simulate message with zero time duration - def setToZeroPrintInformation(self, build_plate_number): - temp_message = {} - if build_plate_number not in self._print_time_message_values: - self._print_time_message_values[build_plate_number] = {} - for key in self._print_time_message_values[build_plate_number].keys(): - temp_message[key] = 0 + def setToZeroPrintInformation(self, build_plate): + # Construct the 0-time message + temp_message = {} + if build_plate not in self._print_time_message_values: + self._print_time_message_values[build_plate] = {} + for key in self._print_time_message_values[build_plate].keys(): + temp_message[key] = 0 temp_material_amounts = [0] - self._onPrintDurationMessage(build_plate_number, temp_message, temp_material_amounts) + + self._onPrintDurationMessage(build_plate, temp_message, temp_material_amounts) + + ## Listen to scene changes to check if we need to reset the print information + def _onSceneChanged(self, scene_node): + + # Ignore any changes that are not related to sliceable objects + if not isinstance(scene_node, SceneNode)\ + or not scene_node.callDecoration("isSliceable")\ + or not scene_node.callDecoration("getBuildPlateNumber") == self._active_build_plate: + return + + self.setToZeroPrintInformation(self._active_build_plate)