From a874cbbe162777ed2cd0eb00988962c28d933e7d Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Sat, 29 Aug 2026 14:10:42 +0100 Subject: [PATCH] Don't clip aircraft images when rotated --- plugins/channelrx/demodadsb/map/map.qml | 77 +++++++++-------- plugins/channelrx/demodadsb/map/map_6.qml | 85 ++++++++++--------- .../channelrx/demodadsb/map/map_6_strict.qml | 83 ++++++++++-------- 3 files changed, 136 insertions(+), 109 deletions(-) diff --git a/plugins/channelrx/demodadsb/map/map.qml b/plugins/channelrx/demodadsb/map/map.qml index 9202f3d11..7ac239a8d 100644 --- a/plugins/channelrx/demodadsb/map/map.qml +++ b/plugins/channelrx/demodadsb/map/map.qml @@ -244,8 +244,8 @@ Item { } MapQuickItem { id: aircraft - anchorPoint.x: image.width/2 - anchorPoint.y: image.height/2 + anchorPoint.x: imageBounds.width/2 + anchorPoint.y: imageBounds.height/2 coordinate: position zoomLevel: aircraftZoomLevel @@ -255,41 +255,50 @@ Item { layer.enabled: smoothing layer.smooth: smoothing horizontalItemAlignment: Grid.AlignHCenter - Image { - id: image - rotation: heading - source: aircraftImage - visible: !lightIcons - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button === Qt.LeftButton) { - highlighted = true - } else if (mouse.button === Qt.RightButton) { - contextMenu.popup() + // Sized to the rotated image's bounding box, so the smoothing layer + // doesn't clip wingtips and the bubble sits close at every heading + Item { + id: imageBounds + width: image.implicitWidth * Math.abs(Math.cos(heading * Math.PI / 180)) + image.implicitHeight * Math.abs(Math.sin(heading * Math.PI / 180)) + height: image.implicitWidth * Math.abs(Math.sin(heading * Math.PI / 180)) + image.implicitHeight * Math.abs(Math.cos(heading * Math.PI / 180)) + Image { + id: image + anchors.centerIn: parent + rotation: heading + source: aircraftImage + visible: !lightIcons + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button === Qt.LeftButton) { + highlighted = true + } else if (mouse.button === Qt.RightButton) { + contextMenu.popup() + } + } + onDoubleClicked: { + target = true } - } - onDoubleClicked: { - target = true } } - } - ColorOverlay { - cached: true - width: image.width - height: image.height - rotation: heading - source: image - color: "#c0ffffff" - visible: lightIcons - MouseArea { - anchors.fill: parent - onClicked: { - highlighted = true - } - onDoubleClicked: { - target = true + ColorOverlay { + cached: true + anchors.centerIn: parent + width: image.implicitWidth + height: image.implicitHeight + rotation: heading + source: image + color: "#c0ffffff" + visible: lightIcons + MouseArea { + anchors.fill: parent + onClicked: { + highlighted = true + } + onDoubleClicked: { + target = true + } } } } diff --git a/plugins/channelrx/demodadsb/map/map_6.qml b/plugins/channelrx/demodadsb/map/map_6.qml index 62be62381..b087ffdb4 100644 --- a/plugins/channelrx/demodadsb/map/map_6.qml +++ b/plugins/channelrx/demodadsb/map/map_6.qml @@ -8,8 +8,8 @@ import Qt5Compat.GraphicalEffects Item { id: qmlMap property real aircraftZoomLevel: 11 - property int aircraftMinZoomLevel: 11 - property int airportZoomLevel: 11 + property real aircraftMinZoomLevel: 11 + property real airportZoomLevel: 11 property string mapProvider: "osm" property variant mapPtr property string requestedMapType @@ -246,8 +246,8 @@ Item { id: aircraftComponent MapQuickItem { id: aircraft - anchorPoint.x: image.width/2 - anchorPoint.y: image.height/2 + anchorPoint.x: imageBounds.width/2 + anchorPoint.y: imageBounds.height/2 coordinate: position zoomLevel: aircraftZoomLevel @@ -257,43 +257,52 @@ Item { layer.enabled: smoothing layer.smooth: smoothing horizontalItemAlignment: Grid.AlignHCenter - Image { - id: image - rotation: heading - source: aircraftImage - visible: !lightIcons - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button === Qt.LeftButton) { - highlighted = true - console.log("z=" + aircraft.sourceItem.z) - aircraft.sourceItem.z = aircraft.sourceItem.z + 1 - } else if (mouse.button === Qt.RightButton) { - contextMenu.popup() + // Sized to the rotated image's bounding box, so the smoothing layer + // doesn't clip wingtips and the bubble sits close at every heading + Item { + id: imageBounds + width: image.implicitWidth * Math.abs(Math.cos(heading * Math.PI / 180)) + image.implicitHeight * Math.abs(Math.sin(heading * Math.PI / 180)) + height: image.implicitWidth * Math.abs(Math.sin(heading * Math.PI / 180)) + image.implicitHeight * Math.abs(Math.cos(heading * Math.PI / 180)) + Image { + id: image + anchors.centerIn: parent + rotation: heading + source: aircraftImage + visible: !lightIcons + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button === Qt.LeftButton) { + highlighted = true + console.log("z=" + aircraft.sourceItem.z) + aircraft.sourceItem.z = aircraft.sourceItem.z + 1 + } else if (mouse.button === Qt.RightButton) { + contextMenu.popup() + } + } + onDoubleClicked: { + target = true } - } - onDoubleClicked: { - target = true } } - } - ColorOverlay { - cached: true - width: image.width - height: image.height - rotation: heading - source: image - color: "#c0ffffff" - visible: lightIcons - MouseArea { - anchors.fill: parent - onClicked: { - highlighted = true - } - onDoubleClicked: { - target = true + ColorOverlay { + cached: true + anchors.centerIn: parent + width: image.implicitWidth + height: image.implicitHeight + rotation: heading + source: image + color: "#c0ffffff" + visible: lightIcons + MouseArea { + anchors.fill: parent + onClicked: { + highlighted = true + } + onDoubleClicked: { + target = true + } } } } diff --git a/plugins/channelrx/demodadsb/map/map_6_strict.qml b/plugins/channelrx/demodadsb/map/map_6_strict.qml index 1e7ee1bf0..cb0d428d8 100644 --- a/plugins/channelrx/demodadsb/map/map_6_strict.qml +++ b/plugins/channelrx/demodadsb/map/map_6_strict.qml @@ -250,8 +250,8 @@ Item { } MapQuickItem { id: aircraft - anchorPoint.x: image.width/2 - anchorPoint.y: image.height/2 + anchorPoint.x: imageBounds.width/2 + anchorPoint.y: imageBounds.height/2 coordinate: position zoomLevel: aircraftZoomLevel @@ -261,44 +261,53 @@ Item { layer.enabled: smoothing layer.smooth: smoothing horizontalItemAlignment: Grid.AlignHCenter - Image { - id: image - rotation: heading - source: aircraftImage - visible: !lightIcons - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: (mouse) => { - if (mouse.button === Qt.LeftButton) { - highlighted = true - console.log("z=" + aircraft.sourceItem.z) - aircraft.sourceItem.z = aircraft.sourceItem.z + 1 - } else if (mouse.button === Qt.RightButton) { - contextMenu.popup() + // Sized to the rotated image's bounding box, so the smoothing layer + // doesn't clip wingtips and the bubble sits close at every heading + Item { + id: imageBounds + width: image.implicitWidth * Math.abs(Math.cos(heading * Math.PI / 180)) + image.implicitHeight * Math.abs(Math.sin(heading * Math.PI / 180)) + height: image.implicitWidth * Math.abs(Math.sin(heading * Math.PI / 180)) + image.implicitHeight * Math.abs(Math.cos(heading * Math.PI / 180)) + Image { + id: image + anchors.centerIn: parent + rotation: heading + source: aircraftImage + visible: !lightIcons + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: (mouse) => { + if (mouse.button === Qt.LeftButton) { + highlighted = true + console.log("z=" + aircraft.sourceItem.z) + aircraft.sourceItem.z = aircraft.sourceItem.z + 1 + } else if (mouse.button === Qt.RightButton) { + contextMenu.popup() + } + } + onDoubleClicked: { + target = true } - } - onDoubleClicked: { - target = true } } - } - MultiEffect { - width: image.width - height: image.height - rotation: heading - source: image - brightness: 1.0 - colorization: 1.0 - colorizationColor: "#c0ffffff" - visible: lightIcons - MouseArea { - anchors.fill: parent - onClicked: { - highlighted = true - } - onDoubleClicked: { - target = true + MultiEffect { + anchors.centerIn: parent + width: image.implicitWidth + height: image.implicitHeight + rotation: heading + source: image + brightness: 1.0 + colorization: 1.0 + colorizationColor: "#c0ffffff" + visible: lightIcons + MouseArea { + anchors.fill: parent + onClicked: { + highlighted = true + } + onDoubleClicked: { + target = true + } } } }