Merge remote-tracking branch 'origin/3.6'

This commit is contained in:
Lipu Fei 2018-10-29 08:13:23 +01:00
commit 261a3976d7
7 changed files with 85 additions and 29 deletions

View File

@ -959,6 +959,9 @@ class CuraApplication(QtApplication):
qmlRegisterType(QualityManagementModel, "Cura", 1, 0, "QualityManagementModel")
qmlRegisterType(MachineManagementModel, "Cura", 1, 0, "MachineManagementModel")
from cura.PrinterOutput.CameraView import CameraView
qmlRegisterType(CameraView, "Cura", 1, 0, "CameraView")
qmlRegisterSingletonType(QualityProfilesDropDownMenuModel, "Cura", 1, 0,
"QualityProfilesDropDownMenuModel", self.getQualityProfilesDropDownMenuModel)
qmlRegisterSingletonType(CustomQualityProfilesDropDownMenuModel, "Cura", 1, 0,

View 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)

View File

@ -16,7 +16,6 @@ class NetworkCamera(QObject):
self._image_request = None
self._image_reply = None
self._image = QImage()
self._image_id = 0
self._target = target
self._started = False
@ -33,15 +32,9 @@ class NetworkCamera(QObject):
if restart_required:
self.start()
@pyqtProperty(QUrl, notify=newImage)
@pyqtProperty(QImage, notify=newImage)
def latestImage(self):
self._image_id += 1
# There is an image provider that is called "camera". In order to ensure that the image qml object, that
# requires a QUrl to function, updates correctly we add an increasing number. This causes to see the QUrl
# as new (instead of relying on cached version and thus forces an update.
temp = "image://camera/" + str(self._image_id)
return QUrl(temp, QUrl.TolerantMode)
return self._image
@pyqtSlot()
def start(self):
@ -116,4 +109,4 @@ class NetworkCamera(QObject):
self._stream_buffer_start_index = -1
self._image.loadFromData(jpg_data)
self.newImage.emit()
self.newImage.emit()

View File

@ -405,12 +405,16 @@ Cura.MachineAction
{
if (settingsTabs.currentIndex > 0)
{
manager.updateMaterialForDiameter(settingsTabs.currentIndex - 1);
manager.updateMaterialForDiameter(settingsTabs.currentIndex - 1)
}
}
function setValueFunction(value)
{
Cura.MachineManager.activeStack.compatibleMaterialDiameter = value
if (settingsTabs.currentIndex > 0)
{
var extruderIndex = (settingsTabs.currentIndex - 1).toString()
Cura.MachineManager.activeMachine.extruders[extruderIndex].compatibleMaterialDiameter = value
}
}
property bool isExtruderSetting: true
}

View File

@ -10,7 +10,7 @@ Component {
height: maximumHeight;
width: maximumWidth;
Image {
Cura.CameraView {
id: cameraImage;
anchors {
horizontalCenter: parent.horizontalCenter;
@ -21,7 +21,7 @@ Component {
OutputDevice.activePrinter.camera.start();
}
}
height: Math.floor((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width);
height: Math.floor((imageHeight === 0 ? 600 * screenScaleFactor : imageHeight) * width / imageWidth);
onVisibleChanged: {
if (visible) {
if (OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null) {
@ -33,14 +33,20 @@ Component {
}
}
}
source: {
if (OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null && OutputDevice.activePrinter.camera.latestImage) {
return OutputDevice.activePrinter.camera.latestImage;
}
return "";
}
width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth);
width: Math.min(imageWidth === 0 ? 800 * screenScaleFactor : imageWidth, maximumWidth);
z: 1;
Connections
{
target: OutputDevice.activePrinter.camera;
onNewImage:
{
if (cameraImage.visible) {
cameraImage.image = OutputDevice.activePrinter.camera.latestImage;
cameraImage.update();
}
}
}
}
}
}

View File

@ -118,7 +118,10 @@ Item {
Item {
id: machineNameLabel;
height: UM.Theme.getSize("monitor_text_line").height;
width: Math.round(parent.width * 0.3);
width: {
var percent = printer ? 0.75 : 0.3;
return Math.round(parent.width * percent);
}
// Skeleton
Rectangle {

View File

@ -5,6 +5,7 @@ import QtQuick 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import UM 1.3 as UM
import Cura 1.0 as Cura
Item {
property var camera: null;
@ -33,11 +34,11 @@ Item {
z: 999;
}
Image {
Cura.CameraView {
id: cameraImage
anchors.horizontalCenter: parent.horizontalCenter;
anchors.verticalCenter: parent.verticalCenter;
height: Math.round((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width);
height: Math.round((imageHeight === 0 ? 600 * screenScaleFactor : imageHeight) * width / imageWidth);
onVisibleChanged: {
if (visible) {
if (camera != null) {
@ -49,13 +50,18 @@ Item {
}
}
}
source: {
if (camera != null && camera.latestImage != null) {
return camera.latestImage;
Connections
{
target: camera
onNewImage: {
if (cameraImage.visible) {
cameraImage.image = camera.latestImage;
cameraImage.update();
}
}
return "";
}
width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth);
width: Math.min(imageWidth === 0 ? 800 * screenScaleFactor : imageWidth, maximumWidth);
z: 1
}