Commit e9e9ae63 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4669 from DonLakeFlyer/MapItemIndicators

New waypoint coordinate indicators
parents 55ba335e 139157ff
...@@ -234,7 +234,8 @@ FlightMap { ...@@ -234,7 +234,8 @@ FlightMap {
// GeoFence breach return point // GeoFence breach return point
MapQuickItem { MapQuickItem {
anchorPoint: Qt.point(sourceItem.width / 2, sourceItem.height / 2) anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.anchorPointY
coordinate: geoFenceController.breachReturnPoint coordinate: geoFenceController.breachReturnPoint
visible: geoFenceController.breachReturnEnabled visible: geoFenceController.breachReturnEnabled
sourceItem: MissionItemIndexLabel { label: "F" } sourceItem: MissionItemIndexLabel { label: "F" }
...@@ -247,7 +248,8 @@ FlightMap { ...@@ -247,7 +248,8 @@ FlightMap {
delegate: MapQuickItem { delegate: MapQuickItem {
id: itemIndicator id: itemIndicator
anchorPoint: Qt.point(sourceItem.width / 2, sourceItem.height / 2) anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.anchorPointY
coordinate: object.coordinate coordinate: object.coordinate
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
...@@ -263,8 +265,8 @@ FlightMap { ...@@ -263,8 +265,8 @@ FlightMap {
coordinate: _gotoHereCoordinate coordinate: _gotoHereCoordinate
visible: _activeVehicle && _activeVehicle.guidedMode && _gotoHereCoordinate.isValid visible: _activeVehicle && _activeVehicle.guidedMode && _gotoHereCoordinate.isValid
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
anchorPoint.x: sourceItem.width / 2 anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.height / 2 anchorPoint.y: sourceItem.anchorPointY
sourceItem: MissionItemIndexLabel { sourceItem: MissionItemIndexLabel {
checked: true checked: true
......
...@@ -129,8 +129,8 @@ Map { ...@@ -129,8 +129,8 @@ Map {
/// Ground Station location /// Ground Station location
MapQuickItem { MapQuickItem {
anchorPoint.x: sourceItem.width / 2 anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.height / 2 anchorPoint.y: sourceItem.anchorPointY
visible: mainWindow.gcsPosition.isValid visible: mainWindow.gcsPosition.isValid
coordinate: mainWindow.gcsPosition coordinate: mainWindow.gcsPosition
sourceItem: MissionItemIndexLabel { sourceItem: MissionItemIndexLabel {
......
...@@ -24,8 +24,8 @@ MapQuickItem { ...@@ -24,8 +24,8 @@ MapQuickItem {
signal clicked signal clicked
anchorPoint.x: sourceItem.width / 2 anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.height / 2 anchorPoint.y: sourceItem.anchorPointY
sourceItem: sourceItem:
MissionItemIndexLabel { MissionItemIndexLabel {
......
...@@ -214,14 +214,17 @@ Item { ...@@ -214,14 +214,17 @@ Item {
id: loiterPointComponent id: loiterPointComponent
MapQuickItem { MapQuickItem {
anchorPoint.x: sourceItem.width / 2 anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.height / 2 anchorPoint.y: sourceItem.anchorPointY
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
coordinate: _missionItem.loiterCoordinate coordinate: _missionItem.loiterCoordinate
sourceItem: sourceItem:
MissionItemIndexLabel { MissionItemIndexLabel {
label: "L" label: "Loiter"
checked: _missionItem.isCurrentItem
onClicked: setCurrentItem(_missionItem.sequenceNumber)
} }
} }
} }
...@@ -245,15 +248,17 @@ Item { ...@@ -245,15 +248,17 @@ Item {
id: landPointComponent id: landPointComponent
MapQuickItem { MapQuickItem {
anchorPoint.x: sourceItem.width / 2 anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.height / 2 anchorPoint.y: sourceItem.anchorPointY
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
coordinate: _missionItem.landingCoordinate coordinate: _missionItem.landingCoordinate
sourceItem: sourceItem:
MissionItemIndexLabel { MissionItemIndexLabel {
label: "L" label: "Land"
checked: _missionItem.isCurrentItem checked: _missionItem.isCurrentItem
onClicked: setCurrentItem(_missionItem.sequenceNumber)
} }
} }
} }
......
...@@ -403,8 +403,8 @@ QGCView { ...@@ -403,8 +403,8 @@ QGCView {
id: itemDragger id: itemDragger
x: mapCoordinateIndicator ? (mapCoordinateIndicator.x + mapCoordinateIndicator.anchorPoint.x - (itemDragger.width / 2)) : 100 x: mapCoordinateIndicator ? (mapCoordinateIndicator.x + mapCoordinateIndicator.anchorPoint.x - (itemDragger.width / 2)) : 100
y: mapCoordinateIndicator ? (mapCoordinateIndicator.y + mapCoordinateIndicator.anchorPoint.y - (itemDragger.height / 2)) : 100 y: mapCoordinateIndicator ? (mapCoordinateIndicator.y + mapCoordinateIndicator.anchorPoint.y - (itemDragger.height / 2)) : 100
width: ScreenTools.defaultFontPixelHeight * 2 width: ScreenTools.defaultFontPixelHeight * 3
height: ScreenTools.defaultFontPixelHeight * 2 height: ScreenTools.defaultFontPixelHeight * 3
color: "transparent" color: "transparent"
visible: false visible: false
z: QGroundControl.zOrderMapItems + 1 // Above item icons z: QGroundControl.zOrderMapItems + 1 // Above item icons
...@@ -504,9 +504,10 @@ QGCView { ...@@ -504,9 +504,10 @@ QGCView {
model: object.isSimpleItem ? object.childItems : 0 model: object.isSimpleItem ? object.childItems : 0
delegate: MissionItemIndexLabel { delegate: MissionItemIndexLabel {
label: object.abbreviation label: object.abbreviation
checked: object.isCurrentItem checked: object.isCurrentItem
z: 2 z: 2
specifiesCoordinate: false
onClicked: setCurrentItem(object.sequenceNumber) onClicked: setCurrentItem(object.sequenceNumber)
} }
...@@ -689,7 +690,8 @@ QGCView { ...@@ -689,7 +690,8 @@ QGCView {
// GeoFence breach return point // GeoFence breach return point
MapQuickItem { MapQuickItem {
anchorPoint: Qt.point(sourceItem.width / 2, sourceItem.height / 2) anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.anchorPointY
coordinate: geoFenceController.breachReturnPoint coordinate: geoFenceController.breachReturnPoint
visible: geoFenceController.breachReturnEnabled visible: geoFenceController.breachReturnEnabled
sourceItem: MissionItemIndexLabel { label: "F" } sourceItem: MissionItemIndexLabel { label: "F" }
...@@ -730,7 +732,8 @@ QGCView { ...@@ -730,7 +732,8 @@ QGCView {
delegate: MapQuickItem { delegate: MapQuickItem {
id: itemIndicator id: itemIndicator
anchorPoint: Qt.point(sourceItem.width / 2, sourceItem.height / 2) anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.anchorPointY
coordinate: object.coordinate coordinate: object.coordinate
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
......
...@@ -72,14 +72,17 @@ Item { ...@@ -72,14 +72,17 @@ Item {
id: entryPointComponent id: entryPointComponent
MapQuickItem { MapQuickItem {
anchorPoint.x: sourceItem.width / 2 anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.height / 2 anchorPoint.y: sourceItem.anchorPointY
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
coordinate: _missionItem.coordinate coordinate: _missionItem.coordinate
sourceItem: sourceItem:
MissionItemIndexLabel { MissionItemIndexLabel {
label: "S" label: "Entry"
checked: _missionItem.isCurrentItem
onClicked: setCurrentItem(_missionItem.sequenceNumber)
} }
} }
} }
...@@ -89,14 +92,17 @@ Item { ...@@ -89,14 +92,17 @@ Item {
id: exitPointComponent id: exitPointComponent
MapQuickItem { MapQuickItem {
anchorPoint.x: sourceItem.width / 2 anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.height / 2 anchorPoint.y: sourceItem.anchorPointY
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
coordinate: _missionItem.exitCoordinate coordinate: _missionItem.exitCoordinate
sourceItem: sourceItem:
MissionItemIndexLabel { MissionItemIndexLabel {
label: "S" label: "Exit"
checked: _missionItem.isCurrentItem
onClicked: setCurrentItem(_missionItem.sequenceNumber)
} }
} }
} }
......
...@@ -5,38 +5,75 @@ import QtQuick.Controls.Styles 1.2 ...@@ -5,38 +5,75 @@ import QtQuick.Controls.Styles 1.2
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
Rectangle { Canvas {
id: root id: root
width: _width + (_singleChar ? 0 : _label.width)
property alias label: _label.text height: specifiesCoordinate ? (_width * 1.5) : _width
property bool checked: false
property bool small: false
signal clicked signal clicked
width: _width property alias label: _label.text
height: _width property bool checked: false
radius: _width / 2 property bool small: false
border.width: small ? 1 : 2 property var color: checked ? "green" : qgcPal.mapButtonHighlight
border.color: "white" property real anchorPointX: _width / 2
color: checked ? "green" : qgcPal.mapButtonHighlight property real anchorPointY: _width * 1.5
property bool specifiesCoordinate: true
property real _width: small ? ScreenTools.defaultFontPixelHeight * ScreenTools.smallFontPointRatio * 1.25 : ScreenTools.defaultFontPixelHeight * 1.25
property bool _singleChar: _label.text.length <= 1
property real _width: small ? ScreenTools.defaultFontPixelHeight * ScreenTools.smallFontPointRatio * 1.75 : ScreenTools.defaultFontPixelHeight * 1.75 onColorChanged: requestPaint()
QGCPalette { id: qgcPal } QGCPalette { id: qgcPal }
function paintSingleCoordinate(context) {
context.arc(_width / 2, _width / 2, _width / 2, (Math.PI / 8) * 7, Math.PI / 8);
context.lineTo(_width / 2, _width * 1.5)
}
function paintSingleNoCoordinate(context) {
context.arc(_width / 2, _width / 2, _width / 2, Math.PI * 2, 0);
}
function paintMultipleCoordinate(context) {
context.arc(_width / 2, _width / 2, _width / 2, (Math.PI / 8) * 7, (Math.PI / 2) * 3);
context.lineTo(_label.width, 0)
context.arc(_label.width, _width / 2, _width / 2, (Math.PI / 2) * 3, Math.PI / 2);
context.lineTo((_width / 4) * 3, _width)
context.lineTo(_width / 2, _width * 1.5)
}
onPaint: {
var context = getContext("2d")
context.reset()
context.beginPath()
if (_singleChar) {
if (specifiesCoordinate) {
paintSingleCoordinate(context)
} else {
paintSingleNoCoordinate(context)
}
} else {
paintMultipleCoordinate(context)
}
context.closePath()
context.fillStyle = color
context.fill()
}
QGCLabel { QGCLabel {
id: _label id: _label
anchors.fill: parent x: Math.round((_width / 2) - (_singleChar ? (width / 2) : (ScreenTools.defaultFontPixelWidth / 2)))
horizontalAlignment: Text.AlignHCenter y: Math.round((_width / 2) - (height / 2))
verticalAlignment: Text.AlignVCenter color: "white"
color: "white" font.pointSize: small ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
font.pointSize: small ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
onWidthChanged: requestPaint()
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: parent.clicked() onClicked: parent.clicked()
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment