mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 10:47:49 -06:00
WIP: Add custom CameraView for UM camera feed
CURA-5821
This commit is contained in:
parent
be5c1c8596
commit
b00ea4719a
2 changed files with 44 additions and 0 deletions
|
@ -959,6 +959,9 @@ class CuraApplication(QtApplication):
|
||||||
qmlRegisterType(QualityManagementModel, "Cura", 1, 0, "QualityManagementModel")
|
qmlRegisterType(QualityManagementModel, "Cura", 1, 0, "QualityManagementModel")
|
||||||
qmlRegisterType(MachineManagementModel, "Cura", 1, 0, "MachineManagementModel")
|
qmlRegisterType(MachineManagementModel, "Cura", 1, 0, "MachineManagementModel")
|
||||||
|
|
||||||
|
from cura.PrinterOutput.CameraView import CameraView
|
||||||
|
qmlRegisterType(CameraView, "Cura", 1, 0, "CameraView")
|
||||||
|
|
||||||
qmlRegisterSingletonType(QualityProfilesDropDownMenuModel, "Cura", 1, 0,
|
qmlRegisterSingletonType(QualityProfilesDropDownMenuModel, "Cura", 1, 0,
|
||||||
"QualityProfilesDropDownMenuModel", self.getQualityProfilesDropDownMenuModel)
|
"QualityProfilesDropDownMenuModel", self.getQualityProfilesDropDownMenuModel)
|
||||||
qmlRegisterSingletonType(CustomQualityProfilesDropDownMenuModel, "Cura", 1, 0,
|
qmlRegisterSingletonType(CustomQualityProfilesDropDownMenuModel, "Cura", 1, 0,
|
||||||
|
|
41
cura/PrinterOutput/CameraView.py
Normal file
41
cura/PrinterOutput/CameraView.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# Copyright (c) 2018 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal
|
||||||
|
from PyQt5.QtGui import QImage
|
||||||
|
from PyQt5.QtQuick import QQuickPaintedItem
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# A custom camera view that uses QQuickPaintedItem to present (or "paint") the image frames from a printer's
|
||||||
|
# network camera feed.
|
||||||
|
#
|
||||||
|
class CameraView(QQuickPaintedItem):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self._image = QImage()
|
||||||
|
|
||||||
|
imageChanged = pyqtSignal()
|
||||||
|
|
||||||
|
def setImage(self, image: "QImage") -> None:
|
||||||
|
self._image = image
|
||||||
|
self.imageChanged.emit()
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def getImage(self) -> "QImage":
|
||||||
|
return self._image
|
||||||
|
|
||||||
|
image = pyqtProperty(QImage, fget = getImage, fset = setImage, notify = imageChanged)
|
||||||
|
|
||||||
|
@pyqtProperty(int, notify = imageChanged)
|
||||||
|
def imageWidth(self) -> int:
|
||||||
|
return self._image.width()
|
||||||
|
|
||||||
|
@pyqtProperty(int, notify = imageChanged)
|
||||||
|
def imageHeight(self) -> int:
|
||||||
|
return self._image.height()
|
||||||
|
|
||||||
|
def paint(self, painter):
|
||||||
|
painter.drawImage(self.contentsBoundingRect(), self._image)
|
Loading…
Add table
Add a link
Reference in a new issue