Merge branch 'master' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2017-05-11 11:08:47 +02:00
commit 8e7637ae62
4 changed files with 113 additions and 19 deletions

View File

@ -52,6 +52,19 @@ class PrintInformation(QObject):
super().__init__(parent) super().__init__(parent)
self._current_print_time = Duration(None, self) self._current_print_time = Duration(None, self)
self._print_times_per_feature = {
"none": Duration(None, self),
"inset_0": Duration(None, self),
"inset_x": Duration(None, self),
"skin": Duration(None, self),
"support": Duration(None, self),
"skirt": Duration(None, self),
"infill": Duration(None, self),
"support_infill": Duration(None, self),
"travel": Duration(None, self),
"retract": Duration(None, self),
"support_interface": Duration(None, self)
}
self._material_lengths = [] self._material_lengths = []
self._material_weights = [] self._material_weights = []
@ -93,6 +106,10 @@ class PrintInformation(QObject):
def currentPrintTime(self): def currentPrintTime(self):
return self._current_print_time return self._current_print_time
@pyqtProperty("QVariantMap", notify = currentPrintTimeChanged)
def printTimesPerFeature(self):
return self._print_times_per_feature
materialLengthsChanged = pyqtSignal() materialLengthsChanged = pyqtSignal()
@pyqtProperty("QVariantList", notify = materialLengthsChanged) @pyqtProperty("QVariantList", notify = materialLengthsChanged)
@ -111,12 +128,16 @@ class PrintInformation(QObject):
def materialCosts(self): def materialCosts(self):
return self._material_costs return self._material_costs
def _onPrintDurationMessage(self, total_time, material_amounts): def _onPrintDurationMessage(self, time_per_feature, material_amounts):
if total_time != total_time: # Check for NaN. Engine can sometimes give us weird values. total_time = 0
Logger.log("w", "Received NaN for print duration message") for feature, time in time_per_feature.items():
self._current_print_time.setDuration(0) if time != time: # Check for NaN. Engine can sometimes give us weird values.
else: self._print_times_per_feature[feature].setDuration(0)
self._current_print_time.setDuration(total_time) Logger.log("w", "Received NaN for print duration message")
continue
total_time += time
self._print_times_per_feature[feature].setDuration(time)
self._current_print_time.setDuration(total_time)
self.currentPrintTimeChanged.emit() self.currentPrintTimeChanged.emit()

View File

@ -90,9 +90,21 @@ message GCodeLayer {
} }
message PrintTimeMaterialEstimates { // The print time for the whole print and material estimates for the extruder message PrintTimeMaterialEstimates { // The print time for each feature and material estimates for the extruder
float time = 1; // Total time estimate // Time estimate in each feature
repeated MaterialEstimates materialEstimates = 2; // materialEstimates data 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 { message MaterialEstimates {
@ -121,4 +133,4 @@ message GCodePrefix {
} }
message SlicingFinished { message SlicingFinished {
} }

View File

@ -187,7 +187,19 @@ class CuraEngineBackend(QObject, Backend):
Logger.log("w", "Slice unnecessary, nothing has changed that needs reslicing.") Logger.log("w", "Slice unnecessary, nothing has changed that needs reslicing.")
return 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_layer_data = []
self._stored_optimized_layer_data = [] self._stored_optimized_layer_data = []
@ -481,13 +493,26 @@ class CuraEngineBackend(QObject, 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 protobuff message containing the print time and # \param message The protobuf message containing the print time per feature and
# material amount per extruder # material amount per extruder
def _onPrintTimeMaterialEstimates(self, message): def _onPrintTimeMaterialEstimates(self, message):
material_amounts = [] material_amounts = []
for index in range(message.repeatedMessageCount("materialEstimates")): for index in range(message.repeatedMessageCount("materialEstimates")):
material_amounts.append(message.getRepeatedMessage("materialEstimates", index).material_amount) 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. ## Creates a new socket connection.
def _createSocket(self): def _createSocket(self):

View File

@ -24,6 +24,7 @@ Item {
UM.I18nCatalog { id: catalog; name:"cura"} UM.I18nCatalog { id: catalog; name:"cura"}
property variant printDuration: PrintInformation.currentPrintTime property variant printDuration: PrintInformation.currentPrintTime
property variant printDurationPerFeature: PrintInformation.printTimesPerFeature
property variant printMaterialLengths: PrintInformation.materialLengths property variant printMaterialLengths: PrintInformation.materialLengths
property variant printMaterialWeights: PrintInformation.materialWeights property variant printMaterialWeights: PrintInformation.materialWeights
property variant printMaterialCosts: PrintInformation.materialCosts property variant printMaterialCosts: PrintInformation.materialCosts
@ -159,7 +160,7 @@ Item {
UM.RecolorImage UM.RecolorImage
{ {
id: timeIcon id: timeIcon
anchors.right: timeSpec.left anchors.right: timeSpecPerFeatureTooltipArea.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width/2 anchors.rightMargin: UM.Theme.getSize("default_margin").width/2
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: UM.Theme.getSize("save_button_specs_icons").width width: UM.Theme.getSize("save_button_specs_icons").width
@ -169,15 +170,50 @@ Item {
color: UM.Theme.getColor("text_subtext") color: UM.Theme.getColor("text_subtext")
source: UM.Theme.getIcon("print_time") source: UM.Theme.getIcon("print_time")
} }
Text UM.TooltipArea
{ {
id: timeSpec id: timeSpecPerFeatureTooltipArea
text: {
var order = ["inset_0", "inset_x", "skin", "infill", "support_infill", "support_interface", "support", "travel", "retract", "none"];
var visible_names = {
"inset_0": catalog.i18nc("@tooltip", "Outer Wall"),
"inset_x": catalog.i18nc("@tooltip", "Inner Walls"),
"skin": catalog.i18nc("@tooltip", "Skin"),
"infill": catalog.i18nc("@tooltip", "Infill"),
"support_infill": catalog.i18nc("@tooltip", "Support Infill"),
"support_interface": catalog.i18nc("@tooltip", "Support Interface"),
"support": catalog.i18nc("@tooltip", "Support"),
"travel": catalog.i18nc("@tooltip", "Travel"),
"retract": catalog.i18nc("@tooltip", "Retractions"),
"none": catalog.i18nc("@tooltip", "Other")
};
var result = "";
for(var feature in order)
{
feature = order[feature];
if(base.printDurationPerFeature[feature] && base.printDurationPerFeature[feature].totalSeconds > 0)
{
result += "<br/>" + visible_names[feature] + ": " + base.printDurationPerFeature[feature].getDisplayString(UM.DurationFormat.Short);
}
}
result = result.replace(/^\<br\/\>/, ""); // remove newline before first item
return result;
}
width: childrenRect.width
height: childrenRect.height
anchors.right: lengthIcon.left anchors.right: lengthIcon.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.rightMargin: UM.Theme.getSize("default_margin").width
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
font: UM.Theme.getFont("small")
color: UM.Theme.getColor("text_subtext") Text
text: (!base.printDuration || !base.printDuration.valid) ? catalog.i18nc("@label", "00h 00min") : base.printDuration.getDisplayString(UM.DurationFormat.Short) {
id: timeSpec
anchors.left: parent.left
anchors.top: parent.top
font: UM.Theme.getFont("small")
color: UM.Theme.getColor("text_subtext")
text: (!base.printDuration || !base.printDuration.valid) ? catalog.i18nc("@label", "00h 00min") : base.printDuration.getDisplayString(UM.DurationFormat.Short)
}
} }
UM.RecolorImage UM.RecolorImage
{ {