mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -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
|
@ -17,7 +17,13 @@ class CameraImageProvider(QQuickImageProvider):
|
|||
if image.isNull():
|
||||
image = QImage()
|
||||
|
||||
return image, QSize(15, 15)
|
||||
except AttributeError:
|
||||
try:
|
||||
image = output_device.activeCamera.getImage()
|
||||
|
||||
return image, QSize(15, 15)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
return QImage(), QSize(15, 15)
|
||||
|
|
|
@ -278,6 +278,14 @@ Component
|
|||
anchors.rightMargin: parent.rightMargin
|
||||
source: "camera-icon.svg"
|
||||
}
|
||||
MouseArea
|
||||
{
|
||||
anchors.fill:parent
|
||||
onClicked:
|
||||
{
|
||||
OutputDevice.setActiveCamera(modelData.camera)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,17 +89,18 @@ Component
|
|||
|
||||
PrinterVideoStream
|
||||
{
|
||||
visible: OutputDevice.activePrinter != null
|
||||
visible: OutputDevice.activeCamera != null
|
||||
anchors.fill: parent
|
||||
camera: OutputDevice.activeCamera
|
||||
}
|
||||
|
||||
onVisibleChanged:
|
||||
{
|
||||
if (!monitorFrame.visible)
|
||||
if (monitorFrame != null && !monitorFrame.visible)
|
||||
{
|
||||
// After switching the Tab ensure that active printer is Null, the video stream image
|
||||
// might be active
|
||||
OutputDevice.setActivePrinter(null)
|
||||
OutputDevice.setActiveCamera(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ i18n_catalog = i18nCatalog("cura")
|
|||
class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||
printJobsChanged = 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.
|
||||
# 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._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:
|
||||
self.writeStarted.emit(self)
|
||||
|
||||
|
@ -256,6 +259,10 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
|||
def activePrinter(self) -> Optional[PrinterOutputModel]:
|
||||
return self._active_printer
|
||||
|
||||
@pyqtProperty(QObject, notify=activeCameraChanged)
|
||||
def activeCamera(self) -> Optional[NetworkCamera]:
|
||||
return self._active_camera
|
||||
|
||||
@pyqtSlot(QObject)
|
||||
def setActivePrinter(self, printer: Optional[PrinterOutputModel]) -> None:
|
||||
if self._active_printer != printer:
|
||||
|
@ -264,6 +271,19 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
|||
self._active_printer = printer
|
||||
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:
|
||||
if self._progress_message:
|
||||
self._progress_message.hide()
|
||||
|
|
|
@ -7,6 +7,8 @@ import UM 1.3 as UM
|
|||
|
||||
Item
|
||||
{
|
||||
property var camera: null
|
||||
|
||||
Rectangle
|
||||
{
|
||||
anchors.fill:parent
|
||||
|
@ -17,7 +19,7 @@ Item
|
|||
MouseArea
|
||||
{
|
||||
anchors.fill: parent
|
||||
onClicked: OutputDevice.setActivePrinter(null)
|
||||
onClicked: OutputDevice.setActiveCamera(null)
|
||||
z: 0
|
||||
}
|
||||
|
||||
|
@ -32,7 +34,7 @@ Item
|
|||
width: 20 * screenScaleFactor
|
||||
height: 20 * screenScaleFactor
|
||||
|
||||
onClicked: OutputDevice.setActivePrinter(null)
|
||||
onClicked: OutputDevice.setActiveCamera(null)
|
||||
|
||||
style: ButtonStyle
|
||||
{
|
||||
|
@ -65,23 +67,24 @@ Item
|
|||
{
|
||||
if(visible)
|
||||
{
|
||||
if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null)
|
||||
if(camera != null)
|
||||
{
|
||||
OutputDevice.activePrinter.camera.start()
|
||||
camera.start()
|
||||
}
|
||||
} else
|
||||
{
|
||||
if(OutputDevice.activePrinter != null && OutputDevice.activePrinter.camera != null)
|
||||
if(camera != null)
|
||||
{
|
||||
OutputDevice.activePrinter.camera.stop()
|
||||
camera.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 "";
|
||||
}
|
||||
|
@ -92,7 +95,7 @@ Item
|
|||
anchors.fill: cameraImage
|
||||
onClicked:
|
||||
{
|
||||
OutputDevice.setActivePrinter(null)
|
||||
OutputDevice.setActiveCamera(null)
|
||||
}
|
||||
z: 1
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue