mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 02:07:51 -06:00
Convert doxygen to rst for UM3NetworkPrinting
This commit is contained in:
parent
de82406782
commit
5eb5ffd916
38 changed files with 797 additions and 487 deletions
|
@ -51,15 +51,17 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
self._setInterfaceElements()
|
||||
self._active_camera_url = QUrl() # type: QUrl
|
||||
|
||||
## Set all the interface elements and texts for this output device.
|
||||
def _setInterfaceElements(self) -> None:
|
||||
"""Set all the interface elements and texts for this output device."""
|
||||
|
||||
self.setPriority(3) # Make sure the output device gets selected above local file output
|
||||
self.setShortDescription(I18N_CATALOG.i18nc("@action:button Preceded by 'Ready to'.", "Print over network"))
|
||||
self.setDescription(I18N_CATALOG.i18nc("@properties:tooltip", "Print over network"))
|
||||
self.setConnectionText(I18N_CATALOG.i18nc("@info:status", "Connected over the network"))
|
||||
|
||||
## Called when the connection to the cluster changes.
|
||||
def connect(self) -> None:
|
||||
"""Called when the connection to the cluster changes."""
|
||||
|
||||
super().connect()
|
||||
self._update()
|
||||
self.sendMaterialProfiles()
|
||||
|
@ -94,10 +96,13 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
def forceSendJob(self, print_job_uuid: str) -> None:
|
||||
self._getApiClient().forcePrintJob(print_job_uuid)
|
||||
|
||||
## Set the remote print job state.
|
||||
# \param print_job_uuid: The UUID of the print job to set the state for.
|
||||
# \param action: The action to undertake ('pause', 'resume', 'abort').
|
||||
def setJobState(self, print_job_uuid: str, action: str) -> None:
|
||||
"""Set the remote print job state.
|
||||
|
||||
:param print_job_uuid: The UUID of the print job to set the state for.
|
||||
:param action: The action to undertake ('pause', 'resume', 'abort').
|
||||
"""
|
||||
|
||||
self._getApiClient().setPrintJobState(print_job_uuid, action)
|
||||
|
||||
def _update(self) -> None:
|
||||
|
@ -106,19 +111,22 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
self._getApiClient().getPrintJobs(self._updatePrintJobs)
|
||||
self._updatePrintJobPreviewImages()
|
||||
|
||||
## Get a list of materials that are installed on the cluster host.
|
||||
def getMaterials(self, on_finished: Callable[[List[ClusterMaterial]], Any]) -> None:
|
||||
"""Get a list of materials that are installed on the cluster host."""
|
||||
|
||||
self._getApiClient().getMaterials(on_finished = on_finished)
|
||||
|
||||
## Sync the material profiles in Cura with the printer.
|
||||
# This gets called when connecting to a printer as well as when sending a print.
|
||||
def sendMaterialProfiles(self) -> None:
|
||||
"""Sync the material profiles in Cura with the printer.
|
||||
|
||||
This gets called when connecting to a printer as well as when sending a print.
|
||||
"""
|
||||
job = SendMaterialJob(device = self)
|
||||
job.run()
|
||||
|
||||
## Send a print job to the cluster.
|
||||
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False,
|
||||
file_handler: Optional[FileHandler] = None, filter_by_machine: bool = False, **kwargs) -> None:
|
||||
"""Send a print job to the cluster."""
|
||||
|
||||
# Show an error message if we're already sending a job.
|
||||
if self._progress.visible:
|
||||
|
@ -132,15 +140,20 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
job.finished.connect(self._onPrintJobCreated)
|
||||
job.start()
|
||||
|
||||
## Allows the user to choose a printer to print with from the printer selection dialogue.
|
||||
# \param unique_name: The unique name of the printer to target.
|
||||
@pyqtSlot(str, name="selectTargetPrinter")
|
||||
def selectTargetPrinter(self, unique_name: str = "") -> None:
|
||||
"""Allows the user to choose a printer to print with from the printer selection dialogue.
|
||||
|
||||
:param unique_name: The unique name of the printer to target.
|
||||
"""
|
||||
self._startPrintJobUpload(unique_name if unique_name != "" else None)
|
||||
|
||||
## Handler for when the print job was created locally.
|
||||
# It can now be sent over the network.
|
||||
def _onPrintJobCreated(self, job: ExportFileJob) -> None:
|
||||
"""Handler for when the print job was created locally.
|
||||
|
||||
It can now be sent over the network.
|
||||
"""
|
||||
|
||||
self._active_exported_job = job
|
||||
# TODO: add preference to enable/disable this feature?
|
||||
if self.clusterSize > 1:
|
||||
|
@ -148,8 +161,9 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
return
|
||||
self._startPrintJobUpload()
|
||||
|
||||
## Shows a dialog allowing the user to select which printer in a group to send a job to.
|
||||
def _showPrinterSelectionDialog(self) -> None:
|
||||
"""Shows a dialog allowing the user to select which printer in a group to send a job to."""
|
||||
|
||||
if not self._printer_select_dialog:
|
||||
plugin_path = CuraApplication.getInstance().getPluginRegistry().getPluginPath("UM3NetworkPrinting") or ""
|
||||
path = os.path.join(plugin_path, "resources", "qml", "PrintWindow.qml")
|
||||
|
@ -157,8 +171,9 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
if self._printer_select_dialog is not None:
|
||||
self._printer_select_dialog.show()
|
||||
|
||||
## Upload the print job to the group.
|
||||
def _startPrintJobUpload(self, unique_name: str = None) -> None:
|
||||
"""Upload the print job to the group."""
|
||||
|
||||
if not self._active_exported_job:
|
||||
Logger.log("e", "No active exported job to upload!")
|
||||
return
|
||||
|
@ -177,33 +192,40 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
on_progress=self._onPrintJobUploadProgress)
|
||||
self._active_exported_job = None
|
||||
|
||||
## Handler for print job upload progress.
|
||||
def _onPrintJobUploadProgress(self, bytes_sent: int, bytes_total: int) -> None:
|
||||
"""Handler for print job upload progress."""
|
||||
|
||||
percentage = (bytes_sent / bytes_total) if bytes_total else 0
|
||||
self._progress.setProgress(percentage * 100)
|
||||
self.writeProgress.emit()
|
||||
|
||||
## Handler for when the print job was fully uploaded to the cluster.
|
||||
def _onPrintUploadCompleted(self, _: QNetworkReply) -> None:
|
||||
"""Handler for when the print job was fully uploaded to the cluster."""
|
||||
|
||||
self._progress.hide()
|
||||
PrintJobUploadSuccessMessage().show()
|
||||
self.writeFinished.emit()
|
||||
|
||||
## Displays the given message if uploading the mesh has failed
|
||||
# \param message: The message to display.
|
||||
def _onUploadError(self, message: str = None) -> None:
|
||||
"""Displays the given message if uploading the mesh has failed
|
||||
|
||||
:param message: The message to display.
|
||||
"""
|
||||
|
||||
self._progress.hide()
|
||||
PrintJobUploadErrorMessage(message).show()
|
||||
self.writeError.emit()
|
||||
|
||||
## Download all the images from the cluster and load their data in the print job models.
|
||||
def _updatePrintJobPreviewImages(self):
|
||||
"""Download all the images from the cluster and load their data in the print job models."""
|
||||
|
||||
for print_job in self._print_jobs:
|
||||
if print_job.getPreviewImage() is None:
|
||||
self._getApiClient().getPrintJobPreviewImage(print_job.key, print_job.updatePreviewImageData)
|
||||
|
||||
## Get the API client instance.
|
||||
def _getApiClient(self) -> ClusterApiClient:
|
||||
"""Get the API client instance."""
|
||||
|
||||
if not self._cluster_api:
|
||||
self._cluster_api = ClusterApiClient(self.address, on_error = lambda error: Logger.log("e", str(error)))
|
||||
return self._cluster_api
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue