mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Convert doxygen to rst for Prepare, Preview, RemovableOutputDevice
This commit is contained in:
parent
a4fe3d7685
commit
a09cd0e63e
6 changed files with 74 additions and 57 deletions
|
@ -6,8 +6,10 @@ from UM.Application import Application
|
|||
from UM.PluginRegistry import PluginRegistry
|
||||
from cura.Stages.CuraStage import CuraStage
|
||||
|
||||
## Stage for preparing model (slicing).
|
||||
|
||||
class PrepareStage(CuraStage):
|
||||
"""Stage for preparing model (slicing)."""
|
||||
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
|
||||
|
|
|
@ -12,37 +12,45 @@ if TYPE_CHECKING:
|
|||
from UM.View.View import View
|
||||
|
||||
|
||||
## Displays a preview of what you're about to print.
|
||||
#
|
||||
# The Python component of this stage just loads PreviewMain.qml for display
|
||||
# when the stage is selected, and makes sure that it reverts to the previous
|
||||
# view when the previous stage is activated.
|
||||
class PreviewStage(CuraStage):
|
||||
"""Displays a preview of what you're about to print.
|
||||
|
||||
The Python component of this stage just loads PreviewMain.qml for display
|
||||
when the stage is selected, and makes sure that it reverts to the previous
|
||||
view when the previous stage is activated.
|
||||
"""
|
||||
|
||||
def __init__(self, application: QtApplication, parent = None) -> None:
|
||||
super().__init__(parent)
|
||||
self._application = application
|
||||
self._application.engineCreatedSignal.connect(self._engineCreated)
|
||||
self._previously_active_view = None # type: Optional[View]
|
||||
|
||||
## When selecting the stage, remember which was the previous view so that
|
||||
# we can revert to that view when we go out of the stage later.
|
||||
def onStageSelected(self) -> None:
|
||||
"""When selecting the stage, remember which was the previous view so that
|
||||
|
||||
we can revert to that view when we go out of the stage later.
|
||||
"""
|
||||
self._previously_active_view = self._application.getController().getActiveView()
|
||||
|
||||
## Called when going to a different stage (away from the Preview Stage).
|
||||
#
|
||||
# When going to a different stage, the view should be reverted to what it
|
||||
# was before. Normally, that just reverts it to solid view.
|
||||
def onStageDeselected(self) -> None:
|
||||
"""Called when going to a different stage (away from the Preview Stage).
|
||||
|
||||
When going to a different stage, the view should be reverted to what it
|
||||
was before. Normally, that just reverts it to solid view.
|
||||
"""
|
||||
|
||||
if self._previously_active_view is not None:
|
||||
self._application.getController().setActiveView(self._previously_active_view.getPluginId())
|
||||
self._previously_active_view = None
|
||||
|
||||
## Delayed load of the QML files.
|
||||
#
|
||||
# We need to make sure that the QML engine is running before we can load
|
||||
# these.
|
||||
def _engineCreated(self) -> None:
|
||||
"""Delayed load of the QML files.
|
||||
|
||||
We need to make sure that the QML engine is running before we can load
|
||||
these.
|
||||
"""
|
||||
|
||||
plugin_path = self._application.getPluginRegistry().getPluginPath(self.getPluginId())
|
||||
if plugin_path is not None:
|
||||
menu_component_path = os.path.join(plugin_path, "PreviewMenu.qml")
|
||||
|
|
|
@ -10,12 +10,14 @@ import glob
|
|||
import os
|
||||
import subprocess
|
||||
|
||||
## Support for removable devices on Linux.
|
||||
#
|
||||
# TODO: This code uses the most basic interfaces for handling this.
|
||||
# We should instead use UDisks2 to handle mount/unmount and hotplugging events.
|
||||
#
|
||||
|
||||
class LinuxRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
||||
"""Support for removable devices on Linux.
|
||||
|
||||
TODO: This code uses the most basic interfaces for handling this.
|
||||
We should instead use UDisks2 to handle mount/unmount and hotplugging events.
|
||||
"""
|
||||
|
||||
def checkRemovableDrives(self):
|
||||
drives = {}
|
||||
for volume in glob.glob("/media/*"):
|
||||
|
|
|
@ -9,8 +9,10 @@ import os
|
|||
|
||||
import plistlib
|
||||
|
||||
## Support for removable devices on Mac OSX
|
||||
|
||||
class OSXRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
||||
"""Support for removable devices on Mac OSX"""
|
||||
|
||||
def checkRemovableDrives(self):
|
||||
drives = {}
|
||||
p = subprocess.Popen(["system_profiler", "SPUSBDataType", "-xml"], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||
|
|
|
@ -28,17 +28,19 @@ class RemovableDriveOutputDevice(OutputDevice):
|
|||
self._writing = False
|
||||
self._stream = None
|
||||
|
||||
## Request the specified nodes to be written to the removable drive.
|
||||
#
|
||||
# \param nodes A collection of scene nodes that should be written to the
|
||||
# removable drive.
|
||||
# \param file_name \type{string} A suggestion for the file name to write
|
||||
# to. If none is provided, a file name will be made from the names of the
|
||||
# meshes.
|
||||
# \param limit_mimetypes Should we limit the available MIME types to the
|
||||
# MIME types available to the currently active machine?
|
||||
#
|
||||
def requestWrite(self, nodes, file_name = None, filter_by_machine = False, file_handler = None, **kwargs):
|
||||
"""Request the specified nodes to be written to the removable drive.
|
||||
|
||||
:param nodes: A collection of scene nodes that should be written to the
|
||||
removable drive.
|
||||
:param file_name: :type{string} A suggestion for the file name to write to.
|
||||
If none is provided, a file name will be made from the names of the
|
||||
meshes.
|
||||
:param limit_mimetypes: Should we limit the available MIME types to the
|
||||
MIME types available to the currently active machine?
|
||||
|
||||
"""
|
||||
|
||||
filter_by_machine = True # This plugin is intended to be used by machine (regardless of what it was told to do)
|
||||
if self._writing:
|
||||
raise OutputDeviceError.DeviceBusyError()
|
||||
|
@ -106,14 +108,14 @@ class RemovableDriveOutputDevice(OutputDevice):
|
|||
Logger.log("e", "Operating system would not let us write to %s: %s", file_name, str(e))
|
||||
raise OutputDeviceError.WriteRequestFailedError(catalog.i18nc("@info:status Don't translate the XML tags <filename> or <message>!", "Could not save to <filename>{0}</filename>: <message>{1}</message>").format(file_name, str(e))) from e
|
||||
|
||||
## Generate a file name automatically for the specified nodes to be saved
|
||||
# in.
|
||||
#
|
||||
# The name generated will be the name of one of the nodes. Which node that
|
||||
# is can not be guaranteed.
|
||||
#
|
||||
# \param nodes A collection of nodes for which to generate a file name.
|
||||
def _automaticFileName(self, nodes):
|
||||
"""Generate a file name automatically for the specified nodes to be saved in.
|
||||
|
||||
The name generated will be the name of one of the nodes. Which node that
|
||||
is can not be guaranteed.
|
||||
|
||||
:param nodes: A collection of nodes for which to generate a file name.
|
||||
"""
|
||||
for root in nodes:
|
||||
for child in BreadthFirstIterator(root):
|
||||
if child.getMeshData():
|
||||
|
|
|
@ -42,8 +42,9 @@ ctypes.windll.kernel32.DeviceIoControl.argtypes = [ #type: ignore
|
|||
ctypes.windll.kernel32.DeviceIoControl.restype = wintypes.BOOL #type: ignore
|
||||
|
||||
|
||||
## Removable drive support for windows
|
||||
class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
||||
"""Removable drive support for windows"""
|
||||
|
||||
def checkRemovableDrives(self):
|
||||
drives = {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue