mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Added CameraImageProvider & camera handling
CURA-1036 and CURA-338
This commit is contained in:
parent
8160f8d5e6
commit
3a46bb8d8a
3 changed files with 23 additions and 3 deletions
18
cura/CameraImageProvider.py
Normal file
18
cura/CameraImageProvider.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
from PyQt5.QtGui import QImage
|
||||||
|
from PyQt5.QtQuick import QQuickImageProvider
|
||||||
|
from PyQt5.QtCore import QSize
|
||||||
|
|
||||||
|
from UM.Application import Application
|
||||||
|
|
||||||
|
class CameraImageProvider(QQuickImageProvider):
|
||||||
|
def __init__(self):
|
||||||
|
QQuickImageProvider.__init__(self, QQuickImageProvider.Image)
|
||||||
|
|
||||||
|
## Request a new image.
|
||||||
|
def requestImage(self, id, size):
|
||||||
|
for output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices():
|
||||||
|
try:
|
||||||
|
return output_device.getCameraImage(), QSize(15, 15)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
return QImage(), QSize(15, 15)
|
|
@ -43,6 +43,7 @@ from . import ZOffsetDecorator
|
||||||
from . import CuraSplashScreen
|
from . import CuraSplashScreen
|
||||||
from . import MachineManagerModel
|
from . import MachineManagerModel
|
||||||
from . import ContainerSettingsModel
|
from . import ContainerSettingsModel
|
||||||
|
from . import CameraImageProvider
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
||||||
from PyQt5.QtGui import QColor, QIcon
|
from PyQt5.QtGui import QColor, QIcon
|
||||||
|
@ -222,7 +223,7 @@ class CuraApplication(QtApplication):
|
||||||
JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
|
JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
|
||||||
|
|
||||||
self.applicationShuttingDown.connect(self.saveSettings)
|
self.applicationShuttingDown.connect(self.saveSettings)
|
||||||
|
self.engineCreatedSignal.connect(self._onEngineCreated)
|
||||||
self._recent_files = []
|
self._recent_files = []
|
||||||
files = Preferences.getInstance().getValue("cura/recent_files").split(";")
|
files = Preferences.getInstance().getValue("cura/recent_files").split(";")
|
||||||
for f in files:
|
for f in files:
|
||||||
|
@ -231,6 +232,9 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
self._recent_files.append(QUrl.fromLocalFile(f))
|
self._recent_files.append(QUrl.fromLocalFile(f))
|
||||||
|
|
||||||
|
def _onEngineCreated(self):
|
||||||
|
self._engine.addImageProvider("camera", CameraImageProvider.CameraImageProvider())
|
||||||
|
|
||||||
## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
|
## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
|
||||||
#
|
#
|
||||||
# Note that the AutoSave plugin also calls this method.
|
# Note that the AutoSave plugin also calls this method.
|
||||||
|
|
|
@ -281,8 +281,6 @@ Rectangle
|
||||||
text: " " + Cura.MachineManager.printerOutputDevices[0].bedTemperature
|
text: " " + Cura.MachineManager.printerOutputDevices[0].bedTemperature
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Spacers
|
// Spacers
|
||||||
Label { text: " "}
|
Label { text: " "}
|
||||||
Label { text: " "}
|
Label { text: " "}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue