1pragma ComponentBehavior: Bound
6import QGroundControl.Controls
8// The thermal stream over the main video, placed as the camera's thermal mode asks: fitting the view, blended over the
9// video, or as a picture-in-picture in the top left corner.
13 /// The camera whose thermal mode and opacity the overlay follows; any object with those properties will do.
14 property var camera: null
15 /// Height covered at the top of the view, which the picture-in-picture stays below.
16 property real pipTopInset: 0
17 /// The manager whose thermal stream is shown.
18 property VideoManager videoManager: QGroundControl.videoManager
20 // Whether the thermal mode shows the overlay. Not the item's visibility, which also goes with the view it is in:
21 // behind another view the stream keeps decoding, so that coming back doesn't wait for a keyframe.
22 readonly property bool _shown: root.videoManager.hasThermal && !!root.camera
23 && root.camera.thermalMode !== MavlinkCameraControlInterface.THERMAL_OFF
24 readonly property real _aspectRatio: root.videoManager.thermalAspectRatio
25 // Size of the thermal video blended over the main one, relative to the view.
26 readonly property real _blendSizeFactor: 0.85
27 // The view the overlay is placed in: none while it is created, and again while it is destroyed.
28 readonly property real _viewWidth: root.parent ? root.parent.width : 0
29 readonly property real _viewHeight: root.parent ? root.parent.height : 0
30 // The box the thermal video fits in, as the thermal mode asks.
31 readonly property size _box: {
35 switch (root.camera.thermalMode) {
36 case MavlinkCameraControlInterface.THERMAL_FULL:
37 return Qt.size(root._viewWidth, root._viewHeight)
38 case MavlinkCameraControlInterface.THERMAL_PIP:
39 return Qt.size(Math.max(0, root._viewWidth - root.anchors.leftMargin),
40 ScreenTools.defaultFontPixelHeight * 12)
42 return Qt.size(root._viewWidth * root._blendSizeFactor, root._viewHeight * root._blendSizeFactor)
46 width: Math.min(root._box.width, root._box.height * root._aspectRatio)
47 height: root.width / root._aspectRatio
51 horizontalCenter: root.parent ? root.parent.horizontalCenter : undefined
52 verticalCenter: root.parent ? root.parent.verticalCenter : undefined
53 // Apply only in the pip state, which anchors the top left corner instead.
54 topMargin: root.pipTopInset + (ScreenTools.defaultFontPixelHeight * 0.5)
55 leftMargin: ScreenTools.defaultFontPixelWidth * 12
58 // The stream decodes while it has an output: none while the overlay isn't shown.
62 opacity: !root.camera ? 0
63 : (root.camera.thermalMode === MavlinkCameraControlInterface.THERMAL_BLEND
64 ? root.camera.thermalOpacity / 100 : 1.0)
65 sourceComponent: thermalOutputComponent
68 id: thermalOutputComponent
71 stream: root.videoManager.thermalStream
76 // In a group of its own: an item's states are a list, which a user of this type would add to, not replace.
81 when: !!root.parent && !!root.camera
82 && root.camera.thermalMode === MavlinkCameraControlInterface.THERMAL_PIP
87 horizontalCenter: undefined
88 verticalCenter: undefined
90 left: root.parent.left