diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..d25d71bcc9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.github +resources/materials +CuraEngine \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..68255c56b9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +FROM ultimaker/cura-build-environment:1 + +# Environment vars for easy configuration +ENV CURA_APP_DIR=/srv/cura + +# Ensure our sources dir exists +RUN mkdir $CURA_APP_DIR + +# Setup CuraEngine +ENV CURA_ENGINE_BRANCH=master +WORKDIR $CURA_APP_DIR +RUN git clone -b $CURA_ENGINE_BRANCH --depth 1 https://github.com/Ultimaker/CuraEngine +WORKDIR $CURA_APP_DIR/CuraEngine +RUN mkdir build +WORKDIR $CURA_APP_DIR/CuraEngine/build +RUN cmake3 .. +RUN make +RUN make install + +# TODO: setup libCharon + +# Setup Uranium +ENV URANIUM_BRANCH=master +WORKDIR $CURA_APP_DIR +RUN git clone -b $URANIUM_BRANCH --depth 1 https://github.com/Ultimaker/Uranium + +# Setup materials +ENV MATERIALS_BRANCH=master +WORKDIR $CURA_APP_DIR +RUN git clone -b $MATERIALS_BRANCH --depth 1 https://github.com/Ultimaker/fdm_materials materials + +# Setup Cura +WORKDIR $CURA_APP_DIR/Cura +ADD . . +RUN mv $CURA_APP_DIR/materials resources/materials + +# Make sure Cura can find CuraEngine +RUN ln -s /usr/local/bin/CuraEngine $CURA_APP_DIR/Cura + +# Run Cura +WORKDIR $CURA_APP_DIR/Cura +ENV PYTHONPATH=${PYTHONPATH}:$CURA_APP_DIR/Uranium +RUN chmod +x ./CuraEngine +RUN chmod +x ./run_in_docker.sh +CMD "./run_in_docker.sh" diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 8cc25b0ccc..f7483ae38b 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -306,6 +306,14 @@ class MachineManager(QObject): self.__emitChangedSignals() + @staticmethod + def getMachine(definition_id: str) -> Optional["GlobalStack"]: + machines = ContainerRegistry.getInstance().findContainerStacks(type = "machine") + for machine in machines: + if machine.definition.getId() == definition_id: + return machine + return None + @pyqtSlot(str, str) def addMachine(self, name: str, definition_id: str) -> None: new_stack = CuraStackBuilder.createMachine(name, definition_id) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 3982a0ad06..ffeddf21cc 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -33,6 +33,9 @@ from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") class CuraEngineBackend(QObject, Backend): + + backendError = Signal() + ## Starts the back-end plug-in. # # This registers all the signal listeners and prepares for communication @@ -289,6 +292,7 @@ class CuraEngineBackend(QObject, Backend): if job.isCancelled() or job.getError() or job.getResult() == StartSliceJob.StartJobResult.Error: self.backendStateChange.emit(BackendState.Error) + self.backendError.emit(job) return if job.getResult() == StartSliceJob.StartJobResult.MaterialIncompatible: @@ -297,6 +301,7 @@ class CuraEngineBackend(QObject, Backend): "Unable to slice with the current material as it is incompatible with the selected machine or configuration."), title = catalog.i18nc("@info:title", "Unable to slice")) self._error_message.show() self.backendStateChange.emit(BackendState.Error) + self.backendError.emit(job) else: self.backendStateChange.emit(BackendState.NotStarted) return @@ -325,6 +330,7 @@ class CuraEngineBackend(QObject, Backend): title = catalog.i18nc("@info:title", "Unable to slice")) self._error_message.show() self.backendStateChange.emit(BackendState.Error) + self.backendError.emit(job) else: self.backendStateChange.emit(BackendState.NotStarted) return @@ -347,6 +353,7 @@ class CuraEngineBackend(QObject, Backend): title = catalog.i18nc("@info:title", "Unable to slice")) self._error_message.show() self.backendStateChange.emit(BackendState.Error) + self.backendError.emit(job) return if job.getResult() == StartSliceJob.StartJobResult.BuildPlateError: @@ -355,6 +362,7 @@ class CuraEngineBackend(QObject, Backend): title = catalog.i18nc("@info:title", "Unable to slice")) self._error_message.show() self.backendStateChange.emit(BackendState.Error) + self.backendError.emit(job) else: self.backendStateChange.emit(BackendState.NotStarted) @@ -364,6 +372,7 @@ class CuraEngineBackend(QObject, Backend): title = catalog.i18nc("@info:title", "Unable to slice")) self._error_message.show() self.backendStateChange.emit(BackendState.Error) + self.backendError.emit(job) else: self.backendStateChange.emit(BackendState.NotStarted) self._invokeSlice() diff --git a/run_in_docker.sh b/run_in_docker.sh new file mode 100644 index 0000000000..eb364fd887 --- /dev/null +++ b/run_in_docker.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +Xvfb :1 -screen 0 1280x800x16 & +export DISPLAY=:1.0 +python3 cura_app.py --headless \ No newline at end of file