Fleshing out of bedleveling action

CURA-1385
This commit is contained in:
Jaime van Kessel 2016-06-21 13:30:36 +02:00
parent 81602e9ccd
commit 924af37dff
4 changed files with 142 additions and 1 deletions

View file

@ -17,7 +17,7 @@ class MachineAction(QObject, PluginObject):
super().__init__()
self._key = key
self._label = label
self._qml_url = ""
self._qml_url = ""
self._component = None
self._context = None
@ -41,6 +41,18 @@ class MachineAction(QObject, PluginObject):
def execute(self):
self._execute()
## Reset the action to it's default state.
# This should not be re-implemented by child classes, instead re-implement _reset.
# /sa _reset
@pyqtSlot()
def reset(self):
self._reset()
## Protected implementation of reset.
# /sa reset()
def _reset(self):
pass
def _execute(self):
raise NotImplementedError("Execute() must be implemented")

View file

@ -1,9 +1,53 @@
from cura.MachineAction import MachineAction
from PyQt5.QtCore import pyqtSlot
from UM.Application import Application
from cura.PrinterOutputDevice import PrinterOutputDevice
class BedLevelMachineAction(MachineAction):
def __init__(self):
super().__init__("BedLevel", "Level bed")
self._qml_url = "BedLevelMachineAction.qml"
self._bed_level_position = 0
def _execute(self):
pass
def _reset(self):
self._bed_level_position = 0
printer_output_devices = self._getPrinterOutputDevices()
if printer_output_devices:
printer_output_devices[0].homeBed()
printer_output_devices[0].moveHead(0, 0, 3)
printer_output_devices[0].homeHead()
def _getPrinterOutputDevices(self):
return [printer_output_device for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices() if isinstance(printer_output_device, PrinterOutputDevice)]
@pyqtSlot()
def moveToNextLevelPosition(self):
output_devices = self._getPrinterOutputDevices()
if output_devices: # We found at least one output device
output_device = output_devices[0]
if self._bed_level_position == 0:
output_device.moveHead(0, 0, 3)
output_device.homeHead()
output_device.moveHead(0, 0, 3)
output_device.moveHead(Application.getInstance().getGlobalContainerStack().getProperty("machine_width") - 10, 0, 0)
output_device.moveHead(0, 0, -3)
self._bed_level_position += 1
elif self._bed_level_position == 1:
output_device.moveHead(0, 0, 3)
output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width") / 2, Application.getInstance().getGlobalContainerStack().getProperty("machine_depth") - 10, 0)
output_device.moveHead(0, 0, -3)
self._bed_level_position += 1
elif self._bed_level_position == 2:
output_device.moveHead(0, 0, 3)
output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width") / 2 + 10, -(Application.getInstance().getGlobalContainerStack().getProperty("machine_depth") + 10), 0)
output_device.moveHead(0, 0, -3)
self._bed_level_position += 1
elif self._bed_level_position >= 3:
pass

View file

@ -0,0 +1,82 @@
// Copyright (c) 2015 Ultimaker B.V.
// Cura is released under the terms of the AGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import UM 1.2 as UM
import Cura 1.0 as Cura
// The action items always need to be wrapped in a component.
Component
{
Item
{
id: wizardPage
anchors.fill: parent;
UM.I18nCatalog { id: catalog; name: "cura"; }
Label
{
id: pageTitle
width: parent.width
text: catalog.i18nc("@title", "Bed Leveling")
wrapMode: Text.WordWrap
font.pointSize: 18;
}
Label
{
id: pageDescription
anchors.top: pageTitle.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
width: parent.width
wrapMode: Text.WordWrap
text: catalog.i18nc("@label", "To make sure your prints will come out great, you can now adjust your buildplate. When you click 'Move to Next Position' the nozzle will move to the different positions that can be adjusted.")
}
Label
{
id: bedlevelingText
anchors.top: pageDescription.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
width: parent.width
wrapMode: Text.WordWrap
text: catalog.i18nc("@label", "For every position; insert a piece of paper under the nozzle and adjust the print bed height. The print bed height is right when the paper is slightly gripped by the tip of the nozzle.")
}
Item
{
id: bedlevelingWrapper
anchors.top: bedlevelingText.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
anchors.horizontalCenter: parent.horizontalCenter
height: skipBedlevelingButton.height
width: bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height < wizardPage.width ? bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height : wizardPage.width
Button
{
id: bedlevelingButton
anchors.top: parent.top
anchors.left: parent.left
text: catalog.i18nc("@action:button","Move to Next Position");
onClicked:
{
}
}
Button
{
id: skipBedlevelingButton
anchors.top: parent.width < wizardPage.width ? parent.top : bedlevelingButton.bottom
anchors.topMargin: parent.width < wizardPage.width ? 0 : UM.Theme.getSize("default_margin").height/2
anchors.left: parent.width < wizardPage.width ? bedlevelingButton.right : parent.left
anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0
text: catalog.i18nc("@action:button","Skip bed leveling");
onClicked: {}
}
}
}
}

View file

@ -47,6 +47,7 @@ UM.ManagementPage
{
id: machineActionRepeater
model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.activeDefinitionId)
Button
{
text: machineActionRepeater.model[index].label;
@ -54,6 +55,8 @@ UM.ManagementPage
}
}
Label
{
text: base.currentItem && base.currentItem.name ? base.currentItem.name : ""