diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index ab63e4034d..cd1a194254 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -111,12 +111,14 @@ class PrintInformation(QObject): def materialCosts(self): return self._material_costs - def _onPrintDurationMessage(self, total_time, material_amounts): - if total_time != total_time: # Check for NaN. Engine can sometimes give us weird values. - Logger.log("w", "Received NaN for print duration message") - self._current_print_time.setDuration(0) - else: - self._current_print_time.setDuration(total_time) + def _onPrintDurationMessage(self, time_per_feature, material_amounts): + total_time = 0 + for feature, time in time_per_feature.items(): + if time != time: # Check for NaN. Engine can sometimes give us weird values. + Logger.log("w", "Received NaN for print duration message") + continue + total_time += time + self._current_print_time.setDuration(total_time) self.currentPrintTimeChanged.emit() diff --git a/plugins/CuraEngineBackend/Cura.proto b/plugins/CuraEngineBackend/Cura.proto index 4eab500f0a..c2e4e5bb5f 100644 --- a/plugins/CuraEngineBackend/Cura.proto +++ b/plugins/CuraEngineBackend/Cura.proto @@ -90,9 +90,21 @@ message GCodeLayer { } -message PrintTimeMaterialEstimates { // The print time for the whole print and material estimates for the extruder - float time = 1; // Total time estimate - repeated MaterialEstimates materialEstimates = 2; // materialEstimates data +message PrintTimeMaterialEstimates { // The print time for each feature and material estimates for the extruder + // Time estimate in each feature + float time_none = 1; + float time_inset_0 = 2; + float time_inset_x = 3; + float time_skin = 4; + float time_support = 5; + float time_skirt = 6; + float time_infill = 7; + float time_support_infill = 8; + float time_travel = 9; + float time_retract = 10; + float time_support_interface = 11; + + repeated MaterialEstimates materialEstimates = 12; // materialEstimates data } message MaterialEstimates { @@ -121,4 +133,4 @@ message GCodePrefix { } message SlicingFinished { -} \ No newline at end of file +} diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index f32993fd20..c13cb72864 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -187,7 +187,19 @@ class CuraEngineBackend(QObject, Backend): Logger.log("w", "Slice unnecessary, nothing has changed that needs reslicing.") return - self.printDurationMessage.emit(0, [0]) + self.printDurationMessage.emit({ + "none": 0, + "inset_0": 0, + "inset_x": 0, + "skin": 0, + "support": 0, + "skirt": 0, + "infill": 0, + "support_infill": 0, + "travel": 0, + "retract": 0, + "support_interface": 0 + }, [0]) self._stored_layer_data = [] self._stored_optimized_layer_data = [] @@ -475,13 +487,26 @@ class CuraEngineBackend(QObject, Backend): ## Called when a print time message is received from the engine. # - # \param message The protobuff message containing the print time and + # \param message The protobuf message containing the print time per feature and # material amount per extruder def _onPrintTimeMaterialEstimates(self, message): material_amounts = [] for index in range(message.repeatedMessageCount("materialEstimates")): material_amounts.append(message.getRepeatedMessage("materialEstimates", index).material_amount) - self.printDurationMessage.emit(message.time, material_amounts) + feature_times = { + "none": message.time_none, + "inset_0": message.time_inset_0, + "inset_x": message.time_inset_x, + "skin": message.time_skin, + "support": message.time_support, + "skirt": message.time_skirt, + "infill": message.time_infill, + "support_infill": message.time_support_infill, + "travel": message.time_travel, + "retract": message.time_retract, + "support_interface": message.time_support_interface + } + self.printDurationMessage.emit(feature_times, material_amounts) ## Creates a new socket connection. def _createSocket(self):