From 84b736df07e8699faa5ca8667191529d76f30486 Mon Sep 17 00:00:00 2001 From: "U-ULTIMAKER\\j.ha" Date: Mon, 4 Jul 2016 17:08:35 +0200 Subject: [PATCH 1/2] first commit in Cura! fix CURA-1085, time estimate is reset before every slice action --- plugins/CuraEngineBackend/CuraEngineBackend.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index c91e414a13..89be5fef08 100644 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -126,6 +126,8 @@ class CuraEngineBackend(Backend): ## Perform a slice of the scene. def slice(self): + self.printDurationMessage.emit(0, 0) + self._stored_layer_data = [] if not self._enabled or not self._global_container_stack: #We shouldn't be slicing. From 318182495ae4874a6fa18b8ffbb992782f1ade80 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 4 Jul 2016 17:11:03 +0200 Subject: [PATCH 2/2] We now recieve material estimation per extruder CURA-1687 --- cura/PrintInformation.py | 21 ++++++++++--------- plugins/CuraEngineBackend/Cura.proto | 11 +++++++--- .../CuraEngineBackend/CuraEngineBackend.py | 12 +++++++---- plugins/SliceInfoPlugin/SliceInfo.py | 2 +- resources/qml/JobSpecs.qml | 2 +- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index f1eb93de0e..5432da5dcc 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -44,7 +44,7 @@ class PrintInformation(QObject): self._current_print_time = Duration(None, self) - self._material_amount = -1 + self._material_amounts = [] self._backend = Application.getInstance().getBackend() if self._backend: @@ -62,21 +62,22 @@ class PrintInformation(QObject): def currentPrintTime(self): return self._current_print_time - materialAmountChanged = pyqtSignal() + materialAmountsChanged = pyqtSignal() - @pyqtProperty(float, notify = materialAmountChanged) - def materialAmount(self): - return self._material_amount + @pyqtProperty("QVariantList", notify = materialAmountsChanged) + def materialAmounts(self): + return self._material_amounts - def _onPrintDurationMessage(self, time, amount): - #if self._slice_pass == self.SlicePass.CurrentSettings: - self._current_print_time.setDuration(time) + def _onPrintDurationMessage(self, total_time, material_amounts): + self._current_print_time.setDuration(total_time) self.currentPrintTimeChanged.emit() # Material amount is sent as an amount of mm^3, so calculate length from that r = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "value") / 2 - self._material_amount = round((amount / (math.pi * r ** 2)) / 1000, 2) - self.materialAmountChanged.emit() + self._material_amounts = [] + for amount in material_amounts: + self._material_amounts.append(round((amount / (math.pi * r ** 2)) / 1000, 2)) + self.materialAmountsChanged.emit() @pyqtSlot(str) def setJobName(self, name): diff --git a/plugins/CuraEngineBackend/Cura.proto b/plugins/CuraEngineBackend/Cura.proto index 38753fd804..5f95a4d4a8 100644 --- a/plugins/CuraEngineBackend/Cura.proto +++ b/plugins/CuraEngineBackend/Cura.proto @@ -65,10 +65,15 @@ message GCodeLayer { bytes data = 2; } -message ObjectPrintTime { // The print time for the whole print and material estimates for the first extruder + +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 MaterialEstimates { int64 id = 1; - float time = 2; // Total time estimate - float material_amount = 3; // material used in the first extruder + float material_amount = 2; // material used in the extruder } message SettingList { diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index c91e414a13..82815bccb7 100644 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -79,7 +79,8 @@ class CuraEngineBackend(Backend): self._message_handlers["cura.proto.Progress"] = self._onProgressMessage self._message_handlers["cura.proto.GCodeLayer"] = self._onGCodeLayerMessage self._message_handlers["cura.proto.GCodePrefix"] = self._onGCodePrefixMessage - self._message_handlers["cura.proto.ObjectPrintTime"] = self._onObjectPrintTimeMessage + self._message_handlers["cura.proto.PrintTimeMaterialEstimates"] = self._onPrintTimeMaterialEstimates + #self._message_handlers["cura.proto.ObjectPrintTime"] = self._onObjectPrintTimeMessage self._message_handlers["cura.proto.SlicingFinished"] = self._onSlicingFinishedMessage self._start_slice_job = None @@ -294,9 +295,12 @@ class CuraEngineBackend(Backend): ## Called when a print time message is received from the engine. # # \param message The protobuf message containing the print time and - # material amount. - def _onObjectPrintTimeMessage(self, message): - self.printDurationMessage.emit(message.time, message.material_amount) + # 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) ## Creates a new socket connection. def _createSocket(self): diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index 50b6275bf0..863eaa5166 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -54,7 +54,7 @@ class SliceInfo(Extension): # Get total material used (in mm^3) print_information = Application.getInstance().getPrintInformation() material_radius = 0.5 * global_container_stack.getProperty("material_diameter", "value") - material_used = math.pi * material_radius * material_radius * print_information.materialAmount #Volume of material used + material_used = math.pi * material_radius * material_radius * print_information.materialAmounts #Volume of material used # Get model information (bounding boxes, hashes and transformation matrix) models_info = [] diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index e73bf145de..0dec471a1c 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -24,7 +24,7 @@ Rectangle { UM.I18nCatalog { id: catalog; name:"cura"} property variant printDuration: PrintInformation.currentPrintTime - property real printMaterialAmount: PrintInformation.materialAmount + property real printMaterialAmount: PrintInformation.materialAmounts[0] height: childrenRect.height color: "transparent"