mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 10:47:49 -06:00
Updated documentation for MachineActions
This commit is contained in:
parent
5aa394b197
commit
3e54c86c88
5 changed files with 22 additions and 5 deletions
|
@ -6,13 +6,21 @@ from PyQt5.QtQml import QQmlComponent, QQmlContext
|
||||||
|
|
||||||
from UM.PluginObject import PluginObject
|
from UM.PluginObject import PluginObject
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
|
from UM.Logger import Logger
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
## Machine actions are actions that are added to a specific machine type. Examples of such actions are
|
||||||
|
# updating the firmware, connecting with remote devices or doing bed leveling. A machine action can also have a
|
||||||
|
# qml, which should contain a "Cura.MachineAction" item. When activated, the item will be displayed in a dialog
|
||||||
|
# and this object will be added as "manager" (so all pyqtSlot() functions can be called by calling manager.func())
|
||||||
class MachineAction(QObject, PluginObject):
|
class MachineAction(QObject, PluginObject):
|
||||||
|
|
||||||
|
## Create a new Machine action.
|
||||||
|
# \param key unique key of the machine action
|
||||||
|
# \param label Human readable label used to identify the machine action.
|
||||||
def __init__(self, key, label = ""):
|
def __init__(self, key, label = ""):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._key = key
|
self._key = key
|
||||||
|
@ -63,13 +71,16 @@ class MachineAction(QObject, PluginObject):
|
||||||
def finished(self):
|
def finished(self):
|
||||||
return self._finished
|
return self._finished
|
||||||
|
|
||||||
|
## Protected helper to create a view object based on provided QML.
|
||||||
def _createViewFromQML(self):
|
def _createViewFromQML(self):
|
||||||
path = QUrl.fromLocalFile(
|
path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._qml_url))
|
||||||
os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._qml_url))
|
|
||||||
self._component = QQmlComponent(Application.getInstance()._engine, path)
|
self._component = QQmlComponent(Application.getInstance()._engine, path)
|
||||||
self._context = QQmlContext(Application.getInstance()._engine.rootContext())
|
self._context = QQmlContext(Application.getInstance()._engine.rootContext())
|
||||||
self._context.setContextProperty("manager", self)
|
self._context.setContextProperty("manager", self)
|
||||||
self._view = self._component.create(self._context)
|
self._view = self._component.create(self._context)
|
||||||
|
if self._view is None:
|
||||||
|
Logger.log("c", "QQmlComponent status %s", self._component.status())
|
||||||
|
Logger.log("c", "QQmlComponent error string %s", self._component.errorString())
|
||||||
|
|
||||||
@pyqtProperty(QObject, constant = True)
|
@pyqtProperty(QObject, constant = True)
|
||||||
def displayItem(self):
|
def displayItem(self):
|
||||||
|
|
|
@ -8,6 +8,8 @@ from UM.i18n import i18nCatalog
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
|
## A simple action to handle manual bed leveling procedure for printers that don't have it on the firmware.
|
||||||
|
# This is currently only used by the Ultimaker Original+
|
||||||
class BedLevelMachineAction(MachineAction):
|
class BedLevelMachineAction(MachineAction):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("BedLevel", catalog.i18nc("@action", "Level build plate"))
|
super().__init__("BedLevel", catalog.i18nc("@action", "Level build plate"))
|
||||||
|
|
|
@ -8,6 +8,7 @@ from UM.i18n import i18nCatalog
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
|
## Action to check up if the self-built UMO was done correctly.
|
||||||
class UMOCheckupMachineAction(MachineAction):
|
class UMOCheckupMachineAction(MachineAction):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("UMOCheckup", catalog.i18nc("@action", "Checkup"))
|
super().__init__("UMOCheckup", catalog.i18nc("@action", "Checkup"))
|
||||||
|
@ -27,7 +28,6 @@ class UMOCheckupMachineAction(MachineAction):
|
||||||
|
|
||||||
Application.getInstance().getOutputDeviceManager().outputDevicesChanged.connect(self._onOutputDevicesChanged)
|
Application.getInstance().getOutputDeviceManager().outputDevicesChanged.connect(self._onOutputDevicesChanged)
|
||||||
|
|
||||||
|
|
||||||
onBedTestCompleted = pyqtSignal()
|
onBedTestCompleted = pyqtSignal()
|
||||||
onHotendTestCompleted = pyqtSignal()
|
onHotendTestCompleted = pyqtSignal()
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
import UM.Settings.InstanceContainer
|
import UM.Settings.InstanceContainer
|
||||||
|
|
||||||
|
|
||||||
|
## The Ultimaker Original can have a few revisions & upgrades. This action helps with selecting them, so they are added
|
||||||
|
# as a variant.
|
||||||
class UMOUpgradeSelection(MachineAction):
|
class UMOUpgradeSelection(MachineAction):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades"))
|
super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades"))
|
||||||
|
|
|
@ -5,6 +5,7 @@ import UM.Settings.DefinitionContainer
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
|
## Upgrade the firmware of a machine by USB with this action.
|
||||||
class UpgradeFirmwareMachineAction(MachineAction):
|
class UpgradeFirmwareMachineAction(MachineAction):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("UpgradeFirmware", catalog.i18nc("@action", "Upgrade Firmware"))
|
super().__init__("UpgradeFirmware", catalog.i18nc("@action", "Upgrade Firmware"))
|
||||||
|
@ -12,6 +13,6 @@ class UpgradeFirmwareMachineAction(MachineAction):
|
||||||
cura.Settings.CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
|
cura.Settings.CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
|
||||||
|
|
||||||
def _onContainerAdded(self, container):
|
def _onContainerAdded(self, container):
|
||||||
# Add this action as a supported action to all machine definitions
|
# Add this action as a supported action to all machine definitions if they support USB connection
|
||||||
if isinstance(container, UM.Settings.DefinitionContainer) and container.getMetaDataEntry("type") == "machine" and container.getMetaDataEntry("supports_usb_connection"):
|
if isinstance(container, UM.Settings.DefinitionContainer) and container.getMetaDataEntry("type") == "machine" and container.getMetaDataEntry("supports_usb_connection"):
|
||||||
UM.Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey())
|
UM.Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue