mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
Added camera view back to cluster screen
CL-893
This commit is contained in:
parent
6bfa2fed96
commit
fc83520ad9
5 changed files with 51 additions and 13 deletions
|
@ -19,5 +19,11 @@ class CameraImageProvider(QQuickImageProvider):
|
||||||
|
|
||||||
return image, QSize(15, 15)
|
return image, QSize(15, 15)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
try:
|
||||||
|
image = output_device.activeCamera.getImage()
|
||||||
|
|
||||||
|
return image, QSize(15, 15)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
return QImage(), QSize(15, 15)
|
return QImage(), QSize(15, 15)
|
||||||
|
|
|
@ -278,6 +278,14 @@ Component
|
||||||
anchors.rightMargin: parent.rightMargin
|
anchors.rightMargin: parent.rightMargin
|
||||||
source: "camera-icon.svg"
|
source: "camera-icon.svg"
|
||||||
}
|
}
|
||||||
|
MouseArea
|
||||||
|
{
|
||||||
|
anchors.fill:parent
|
||||||
|
onClicked:
|
||||||
|
{
|
||||||
|
OutputDevice.setActiveCamera(modelData.camera)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,17 +89,18 @@ Component
|
||||||
|
|
||||||
PrinterVideoStream
|
PrinterVideoStream
|
||||||
{
|
{
|
||||||
visible: OutputDevice.activePrinter != null
|
visible: OutputDevice.activeCamera != null
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
camera: OutputDevice.activeCamera
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged:
|
onVisibleChanged:
|
||||||
{
|
{
|
||||||
if (!monitorFrame.visible)
|
if (monitorFrame != null && !monitorFrame.visible)
|
||||||
{
|
{
|
||||||
// After switching the Tab ensure that active printer is Null, the video stream image
|
// After switching the Tab ensure that active printer is Null, the video stream image
|
||||||
// might be active
|
// might be active
|
||||||
OutputDevice.setActivePrinter(null)
|
OutputDevice.setActiveCamera(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ i18n_catalog = i18nCatalog("cura")
|
||||||
class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
printJobsChanged = pyqtSignal()
|
printJobsChanged = pyqtSignal()
|
||||||
activePrinterChanged = pyqtSignal()
|
activePrinterChanged = pyqtSignal()
|
||||||
|
activeCameraChanged = pyqtSignal()
|
||||||
|
|
||||||
# This is a bit of a hack, as the notify can only use signals that are defined by the class that they are in.
|
# This is a bit of a hack, as the notify can only use signals that are defined by the class that they are in.
|
||||||
# Inheritance doesn't seem to work. Tying them together does work, but i'm open for better suggestions.
|
# Inheritance doesn't seem to work. Tying them together does work, but i'm open for better suggestions.
|
||||||
|
@ -96,6 +97,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
self._latest_reply_handler = None # type: Optional[QNetworkReply]
|
self._latest_reply_handler = None # type: Optional[QNetworkReply]
|
||||||
self._sending_job = None
|
self._sending_job = None
|
||||||
|
|
||||||
|
self._active_camera = None # type: Optional[NetworkCamera]
|
||||||
|
|
||||||
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
|
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
|
||||||
self.writeStarted.emit(self)
|
self.writeStarted.emit(self)
|
||||||
|
|
||||||
|
@ -256,6 +259,10 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
def activePrinter(self) -> Optional[PrinterOutputModel]:
|
def activePrinter(self) -> Optional[PrinterOutputModel]:
|
||||||
return self._active_printer
|
return self._active_printer
|
||||||
|
|
||||||
|
@pyqtProperty(QObject, notify=activeCameraChanged)
|
||||||
|
def activeCamera(self) -> Optional[NetworkCamera]:
|
||||||
|
return self._active_camera
|
||||||
|
|
||||||
@pyqtSlot(QObject)
|
@pyqtSlot(QObject)
|
||||||
def setActivePrinter(self, printer: Optional[PrinterOutputModel]) -> None:
|
def setActivePrinter(self, printer: Optional[PrinterOutputModel]) -> None:
|
||||||
if self._active_printer != printer:
|
if self._active_printer != printer:
|
||||||
|
@ -264,6 +271,19 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
self._active_printer = printer
|
self._active_printer = printer
|
||||||
self.activePrinterChanged.emit()
|
self.activePrinterChanged.emit()
|
||||||
|
|
||||||
|
@pyqtSlot(QObject)
|
||||||
|
def setActiveCamera(self, camera: Optional[NetworkCamera]) -> None:
|
||||||
|
if self._active_camera != camera:
|
||||||
|
if self._active_camera:
|
||||||
|
self._active_camera.stop()
|
||||||
|
|
||||||
|
self._active_camera = camera
|
||||||
|
|
||||||
|
if self._active_camera:
|
||||||
|
self._active_camera.start()
|
||||||
|
|
||||||
|
self.activeCameraChanged.emit()
|
||||||
|
|
||||||
def _onPostPrintJobFinished(self, reply: QNetworkReply) -> None:
|
def _onPostPrintJobFinished(self, reply: QNetworkReply) -> None:
|
||||||
if self._progress_message:
|
if self._progress_message:
|
||||||
self._progress_message.hide()
|
self._progress_message.hide()
|
||||||
|
|
|
@ -7,6 +7,8 @@ import UM 1.3 as UM
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
|
property var camera: null
|
||||||
|
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
anchors.fill:parent
|
anchors.fill:parent
|
||||||
|
@ -17,7 +19,7 @@ Item
|
||||||
MouseArea
|
MouseArea
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: OutputDevice.setActivePrinter(null)
|
onClicked: OutputDevice.setActiveCamera(null)
|
||||||
z: 0
|
z: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ Item
|
||||||
width: 20 * screenScaleFactor
|
width: 20 * screenScaleFactor
|
||||||
height: 20 * screenScaleFactor
|
height: 20 * screenScaleFactor
|
||||||
|
|
||||||
onClicked: OutputDevice.setActivePrinter(null)
|
onClicked: OutputDevice.setActiveCamera(null)
|
||||||
|
|
||||||
style: ButtonStyle
|
style: ButtonStyle
|
||||||
{
|
{
|
||||||
|
@ -65,23 +67,24 @@ Item
|
||||||
{
|
{
|
||||||
if(visible)
|
if(visible)
|
||||||
{
|
{
|
||||||
if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null)
|
if(camera != null)
|
||||||
{
|
{
|
||||||
OutputDevice.activePrinter.camera.start()
|
camera.start()
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null)
|
if(camera != null)
|
||||||
{
|
{
|
||||||
OutputDevice.activePrinter.camera.stop()
|
camera.stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
source:
|
source:
|
||||||
{
|
{
|
||||||
if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null && OutputDevice.activePrinter.camera.latestImage)
|
if(camera != null && camera.latestImage != null)
|
||||||
{
|
{
|
||||||
return OutputDevice.activePrinter.camera.latestImage;
|
return camera.latestImage;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -92,7 +95,7 @@ Item
|
||||||
anchors.fill: cameraImage
|
anchors.fill: cameraImage
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
OutputDevice.setActivePrinter(null)
|
OutputDevice.setActiveCamera(null)
|
||||||
}
|
}
|
||||||
z: 1
|
z: 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue