Account for the changes to BackendState in Uranium

Contributes to CURA-1278
This commit is contained in:
Arjen Hiemstra 2016-05-30 12:22:12 +02:00
parent 472012a5b9
commit c63eb3871c
2 changed files with 31 additions and 18 deletions

View file

@ -1,13 +1,12 @@
# Copyright (c) 2015 Ultimaker B.V. # Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
from UM.Backend.Backend import Backend from UM.Backend.Backend import Backend, BackendState
from UM.Application import Application from UM.Application import Application
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
from UM.Preferences import Preferences from UM.Preferences import Preferences
from UM.Signal import Signal from UM.Signal import Signal
from UM.Logger import Logger from UM.Logger import Logger
from UM.Qt.Bindings.BackendProxy import BackendState #To determine the state of the slicing job.
from UM.Message import Message from UM.Message import Message
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from UM.Resources import Resources from UM.Resources import Resources
@ -156,12 +155,12 @@ class CuraEngineBackend(Backend):
# return # return
self.processingProgress.emit(0.0) self.processingProgress.emit(0.0)
self.backendStateChange.emit(BackendState.NOT_STARTED)
if self._message: if self._message:
self._message.setProgress(-1) self._message.setProgress(-1)
else: else:
self._message = Message(catalog.i18nc("@info:status", "Slicing..."), 0, False, -1) self._message = Message(catalog.i18nc("@info:status", "Slicing..."), 0, False, -1)
self._message.show() self._message.show()
self.backendStateChange.emit(BackendState.NotStarted)
self._scene.gcode_list = [] self._scene.gcode_list = []
self._slicing = True self._slicing = True
@ -274,13 +273,13 @@ class CuraEngineBackend(Backend):
self._message.setProgress(round(message.amount * 100)) self._message.setProgress(round(message.amount * 100))
self.processingProgress.emit(message.amount) self.processingProgress.emit(message.amount)
self.backendStateChange.emit(BackendState.PROCESSING) self.backendStateChange.emit(BackendState.Processing)
## Called when the engine sends a message that slicing is finished. ## Called when the engine sends a message that slicing is finished.
# #
# \param message The protobuf message signalling that slicing is finished. # \param message The protobuf message signalling that slicing is finished.
def _onSlicingFinishedMessage(self, message): def _onSlicingFinishedMessage(self, message):
self.backendStateChange.emit(BackendState.DONE) self.backendStateChange.emit(BackendState.Done)
self.processingProgress.emit(1.0) self.processingProgress.emit(1.0)
self._slicing = False self._slicing = False

View file

@ -14,21 +14,35 @@ Rectangle {
property real progress: UM.Backend.progress; property real progress: UM.Backend.progress;
property int backendState: UM.Backend.state; property int backendState: UM.Backend.state;
property bool activity: Printer.getPlatformActivity; property bool activity: Printer.getPlatformActivity;
//Behavior on progress { NumberAnimation { duration: 250; } } //Behavior on progress { NumberAnimation { duration: 250; } }
property int totalHeight: childrenRect.height + UM.Theme.getSize("default_margin").height property int totalHeight: childrenRect.height + UM.Theme.getSize("default_margin").height
property string fileBaseName property string fileBaseName
property string statusText: { property string statusText:
if(base.backendState == 0) { {
if(!activity) { if(base.backendState == 1)
return catalog.i18nc("@label:PrintjobStatus","Please load a 3d model"); {
} else { if(!activity)
return catalog.i18nc("@label:PrintjobStatus","Preparing to slice..."); {
return catalog.i18nc("@label:PrintjobStatus", "Please load a 3d model");
} }
} else if(base.backendState == 1) { else
return catalog.i18nc("@label:PrintjobStatus","Slicing..."); {
} else { return catalog.i18nc("@label:PrintjobStatus", "Preparing to slice...");
return catalog.i18nc("@label:PrintjobStatus","Ready to ") + UM.OutputDeviceManager.activeDeviceShortDescription; }
}
else if(base.backendState == 2)
{
return catalog.i18nc("@label:PrintjobStatus", "Slicing...");
}
else if(base.backendState == 3)
{
return catalog.i18nc("@label:PrintjobStatus %1 is target operation","Ready to %1").arg(UM.OutputDeviceManager.activeDeviceShortDescription);
}
else if(base.backendState == 4)
{
return catalog.i18nc("@label:PrintjobStatus", "Unable to slice due to errors")
} }
} }
@ -60,7 +74,7 @@ Rectangle {
height: parent.height height: parent.height
color: UM.Theme.getColor("progressbar_control") color: UM.Theme.getColor("progressbar_control")
radius: UM.Theme.getSize("progressbar_radius").width radius: UM.Theme.getSize("progressbar_radius").width
visible: base.backendState == 1 ? true : false visible: base.backendState == 2 ? true : false
} }
} }
@ -76,7 +90,7 @@ Rectangle {
id: saveToButton id: saveToButton
tooltip: UM.OutputDeviceManager.activeDeviceDescription; tooltip: UM.OutputDeviceManager.activeDeviceDescription;
enabled: base.backendState == 2 && base.activity == true enabled: base.backendState == 3 && base.activity == true
height: UM.Theme.getSize("save_button_save_to_button").height height: UM.Theme.getSize("save_button_save_to_button").height
anchors.top: parent.top anchors.top: parent.top
@ -127,7 +141,7 @@ Rectangle {
anchors.rightMargin: UM.Theme.getSize("default_margin").width anchors.rightMargin: UM.Theme.getSize("default_margin").width
width: UM.Theme.getSize("save_button_save_to_button").height width: UM.Theme.getSize("save_button_save_to_button").height
height: UM.Theme.getSize("save_button_save_to_button").height height: UM.Theme.getSize("save_button_save_to_button").height
enabled: base.backendState == 2 && base.activity == true enabled: base.backendState == 3 && base.activity == true
visible: devicesModel.deviceCount > 1 visible: devicesModel.deviceCount > 1