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._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):
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue