mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
We now recieve material estimation per extruder
CURA-1687
This commit is contained in:
parent
90fa0f0564
commit
318182495a
5 changed files with 29 additions and 19 deletions
|
@ -44,7 +44,7 @@ class PrintInformation(QObject):
|
||||||
|
|
||||||
self._current_print_time = Duration(None, self)
|
self._current_print_time = Duration(None, self)
|
||||||
|
|
||||||
self._material_amount = -1
|
self._material_amounts = []
|
||||||
|
|
||||||
self._backend = Application.getInstance().getBackend()
|
self._backend = Application.getInstance().getBackend()
|
||||||
if self._backend:
|
if self._backend:
|
||||||
|
@ -62,21 +62,22 @@ class PrintInformation(QObject):
|
||||||
def currentPrintTime(self):
|
def currentPrintTime(self):
|
||||||
return self._current_print_time
|
return self._current_print_time
|
||||||
|
|
||||||
materialAmountChanged = pyqtSignal()
|
materialAmountsChanged = pyqtSignal()
|
||||||
|
|
||||||
@pyqtProperty(float, notify = materialAmountChanged)
|
@pyqtProperty("QVariantList", notify = materialAmountsChanged)
|
||||||
def materialAmount(self):
|
def materialAmounts(self):
|
||||||
return self._material_amount
|
return self._material_amounts
|
||||||
|
|
||||||
def _onPrintDurationMessage(self, time, amount):
|
def _onPrintDurationMessage(self, total_time, material_amounts):
|
||||||
#if self._slice_pass == self.SlicePass.CurrentSettings:
|
self._current_print_time.setDuration(total_time)
|
||||||
self._current_print_time.setDuration(time)
|
|
||||||
self.currentPrintTimeChanged.emit()
|
self.currentPrintTimeChanged.emit()
|
||||||
|
|
||||||
# Material amount is sent as an amount of mm^3, so calculate length from that
|
# Material amount is sent as an amount of mm^3, so calculate length from that
|
||||||
r = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "value") / 2
|
r = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "value") / 2
|
||||||
self._material_amount = round((amount / (math.pi * r ** 2)) / 1000, 2)
|
self._material_amounts = []
|
||||||
self.materialAmountChanged.emit()
|
for amount in material_amounts:
|
||||||
|
self._material_amounts.append(round((amount / (math.pi * r ** 2)) / 1000, 2))
|
||||||
|
self.materialAmountsChanged.emit()
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def setJobName(self, name):
|
def setJobName(self, name):
|
||||||
|
|
|
@ -65,10 +65,15 @@ message GCodeLayer {
|
||||||
bytes data = 2;
|
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;
|
int64 id = 1;
|
||||||
float time = 2; // Total time estimate
|
float material_amount = 2; // material used in the extruder
|
||||||
float material_amount = 3; // material used in the first extruder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message SettingList {
|
message SettingList {
|
||||||
|
|
|
@ -79,7 +79,8 @@ class CuraEngineBackend(Backend):
|
||||||
self._message_handlers["cura.proto.Progress"] = self._onProgressMessage
|
self._message_handlers["cura.proto.Progress"] = self._onProgressMessage
|
||||||
self._message_handlers["cura.proto.GCodeLayer"] = self._onGCodeLayerMessage
|
self._message_handlers["cura.proto.GCodeLayer"] = self._onGCodeLayerMessage
|
||||||
self._message_handlers["cura.proto.GCodePrefix"] = self._onGCodePrefixMessage
|
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._message_handlers["cura.proto.SlicingFinished"] = self._onSlicingFinishedMessage
|
||||||
|
|
||||||
self._start_slice_job = None
|
self._start_slice_job = None
|
||||||
|
@ -294,9 +295,12 @@ class CuraEngineBackend(Backend):
|
||||||
## Called when a print time message is received from the engine.
|
## Called when a print time message is received from the engine.
|
||||||
#
|
#
|
||||||
# \param message The protobuf message containing the print time and
|
# \param message The protobuf message containing the print time and
|
||||||
# material amount.
|
# material amount per extruder
|
||||||
def _onObjectPrintTimeMessage(self, message):
|
def _onPrintTimeMaterialEstimates(self, message):
|
||||||
self.printDurationMessage.emit(message.time, message.material_amount)
|
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.
|
## Creates a new socket connection.
|
||||||
def _createSocket(self):
|
def _createSocket(self):
|
||||||
|
|
|
@ -54,7 +54,7 @@ class SliceInfo(Extension):
|
||||||
# Get total material used (in mm^3)
|
# Get total material used (in mm^3)
|
||||||
print_information = Application.getInstance().getPrintInformation()
|
print_information = Application.getInstance().getPrintInformation()
|
||||||
material_radius = 0.5 * global_container_stack.getProperty("material_diameter", "value")
|
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)
|
# Get model information (bounding boxes, hashes and transformation matrix)
|
||||||
models_info = []
|
models_info = []
|
||||||
|
|
|
@ -24,7 +24,7 @@ Rectangle {
|
||||||
UM.I18nCatalog { id: catalog; name:"cura"}
|
UM.I18nCatalog { id: catalog; name:"cura"}
|
||||||
|
|
||||||
property variant printDuration: PrintInformation.currentPrintTime
|
property variant printDuration: PrintInformation.currentPrintTime
|
||||||
property real printMaterialAmount: PrintInformation.materialAmount
|
property real printMaterialAmount: PrintInformation.materialAmounts[0]
|
||||||
|
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue