|
@@ -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):
|
|
|
+ def setToZeroPrintInformation(self, build_plate):
|
|
|
+
|
|
|
+ # Construct the 0-time message
|
|
|
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():
|
|
|
+ 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)
|