Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemco Burema <r.burema@ultimaker.com>2021-01-20 22:15:33 +0300
committerRemco Burema <r.burema@ultimaker.com>2021-01-21 10:19:17 +0300
commit4fc0612806bf361c7e85bb43db87577feb71caf9 (patch)
tree2e6b6f3d76aaa668f2bed09d1f93ed6dbf2005dc /plugins/CuraEngineBackend
parentcdedb56a9ae6db5479dc060b9254a0307b69ab55 (diff)
Make a snapshot on slice instead of write.
In some cases, UFP-writing is going to be done when the OpenGL-context is off the main window. This doesn't work. That unfortunately also goes for this commit, but it's a work in progress.
Diffstat (limited to 'plugins/CuraEngineBackend')
-rwxr-xr-xplugins/CuraEngineBackend/CuraEngineBackend.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py
index 4b196f7b5d..7a88618a7e 100755
--- a/plugins/CuraEngineBackend/CuraEngineBackend.py
+++ b/plugins/CuraEngineBackend/CuraEngineBackend.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Ultimaker B.V.
+# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import argparse #To run the engine in debug mode if the front-end is in debug mode.
@@ -9,6 +9,8 @@ import sys
from time import time
from typing import Any, cast, Dict, List, Optional, Set, TYPE_CHECKING
+from PyQt5.QtGui import QImage
+
from UM.Backend.Backend import Backend, BackendState
from UM.Scene.SceneNode import SceneNode
from UM.Signal import Signal
@@ -24,6 +26,8 @@ from UM.Tool import Tool #For typing.
from cura.CuraApplication import CuraApplication
from cura.Settings.ExtruderManager import ExtruderManager
+from cura.Snapshot import Snapshot
+from cura.Utils.Threading import call_on_qt_thread
from .ProcessSlicedLayersJob import ProcessSlicedLayersJob
from .StartSliceJob import StartSliceJob, StartJobResult
@@ -153,6 +157,8 @@ class CuraEngineBackend(QObject, Backend):
self.determineAutoSlicing()
application.getPreferences().preferenceChanged.connect(self._onPreferencesChanged)
+ self._snapshot = None #type: Optional[QImage]
+
application.initializationFinished.connect(self.initialize)
def initialize(self) -> None:
@@ -241,9 +247,24 @@ class CuraEngineBackend(QObject, Backend):
self.markSliceAll()
self.slice()
+ @call_on_qt_thread # must be called from the main thread because of OpenGL
+ def _createSnapshot(self) -> None:
+ self._snapshot = None
+ Logger.log("i", "Creating thumbnail image (just before slice)...")
+ try:
+ self._snapshot = Snapshot.snapshot(width = 300, height = 300)
+ except:
+ Logger.logException("w", "Failed to create snapshot image")
+ self._snapshot = None # Failing to create thumbnail should not fail creation of UFP
+
+ def getLatestSnapShot(self) -> Optional[QImage]:
+ return self._snapshot
+
def slice(self) -> None:
"""Perform a slice of the scene."""
+ self._createSnapshot()
+
Logger.log("i", "Starting to slice...")
self._slice_start_time = time()
if not self._build_plates_to_be_sliced:
@@ -331,7 +352,6 @@ class CuraEngineBackend(QObject, Backend):
def _onStartSliceCompleted(self, job: StartSliceJob) -> None:
"""Event handler to call when the job to initiate the slicing process is
-
completed.
When the start slice job is successfully completed, it will be happily