Commit c344f24b authored by DonLakeFlyer's avatar DonLakeFlyer

Better mission item indicators, fix click to set waypoint

parent e5af2eae
......@@ -32,6 +32,7 @@ MapQuickItem {
id: _label
checked: _isCurrentItem
label: missionItem ? missionItem.abbreviation : ""
index: missionItem ? missionItem.sequenceNumber : 0
gimbalYaw: missionItem.missionGimbalYaw
vehicleYaw: missionItem.missionVehicleYaw
showGimbalYaw: missionItem.showMissionGimbalYaw
......
......@@ -204,6 +204,7 @@ Item {
sourceItem:
MissionItemIndexLabel {
index: _missionItem.sequenceNumber
label: "Loiter"
checked: _missionItem.isCurrentItem
......@@ -238,6 +239,7 @@ Item {
sourceItem:
MissionItemIndexLabel {
index: _missionItem.lastSequenceNumber
label: "Land"
checked: _missionItem.isCurrentItem
......
......@@ -51,7 +51,7 @@ Rectangle {
anchors.verticalCenter: commandPicker.verticalCenter
anchors.leftMargin: _margin
anchors.left: parent.left
text: missionItem.abbreviation
text: missionItem.abbreviation.charAt(0)
color: _outerTextColor
}
......
......@@ -84,7 +84,8 @@ Rectangle {
y: availableHeight - (availableHeight * object.altPercent)
small: true
checked: object.isCurrentItem
label: object.abbreviation
label: object.abbreviation.charAt(0)
index: object.sequenceNumber
visible: object.relativeAltitude ? true : (object.homePosition || graphAbsolute)
}
}
......
......@@ -114,7 +114,7 @@ Item {
model: _missionItem.childItems
delegate: MissionItemIndexLabel {
label: object.abbreviation
label: object.abbreviation.length === 0 ? object.sequenceNumber : object.abbreviation.charAt(0)
checked: object.isCurrentItem
z: 2
specifiesCoordinate: false
......
......@@ -116,7 +116,7 @@ Item {
delegate: MissionItemIndexLabel {
z: 2
label: object.abbreviation
label: object.abbreviation.length === 0 ? object.sequenceNumber : object.abbreviation.charAt(0)
checked: object.isCurrentItem
specifiesCoordinate: false
......
......@@ -150,6 +150,7 @@ Item {
sourceItem:
MissionItemIndexLabel {
index: _missionItem.sequenceNumber
label: "Entry"
checked: _missionItem.isCurrentItem
......@@ -171,6 +172,7 @@ Item {
sourceItem:
MissionItemIndexLabel {
index: _missionItem.lastSequenceNumber
label: "Exit"
checked: _missionItem.isCurrentItem
......
......@@ -336,15 +336,15 @@ QString SimpleMissionItem::abbreviation() const
switch(command()) {
default:
return QString::number(sequenceNumber());
return QString();
case MavlinkQmlSingleton::MAV_CMD_NAV_TAKEOFF:
return QStringLiteral("T");
return QStringLiteral("Takeoff");
case MavlinkQmlSingleton::MAV_CMD_NAV_LAND:
return QStringLiteral("L");
return QStringLiteral("Land");
case MavlinkQmlSingleton::MAV_CMD_NAV_VTOL_TAKEOFF:
return QStringLiteral("VT");
return QStringLiteral("VTOL Takeoff");
case MavlinkQmlSingleton::MAV_CMD_NAV_VTOL_LAND:
return QStringLiteral("VL");
return QStringLiteral("VTOL Land");
}
}
......
......@@ -56,6 +56,7 @@ public:
Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged) ///< Item is dirty and requires save/send
Q_PROPERTY(bool isCurrentItem READ isCurrentItem WRITE setIsCurrentItem NOTIFY isCurrentItemChanged)
Q_PROPERTY(int sequenceNumber READ sequenceNumber WRITE setSequenceNumber NOTIFY sequenceNumberChanged)
Q_PROPERTY(int lastSequenceNumber READ lastSequenceNumber NOTIFY lastSequenceNumberChanged)
Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate NOTIFY specifiesCoordinateChanged) ///< true: Item is associated with a coordinate position
Q_PROPERTY(bool isStandaloneCoordinate READ isStandaloneCoordinate NOTIFY isStandaloneCoordinateChanged) ///< true: Waypoint line does not go through item
Q_PROPERTY(bool specifiesAltitudeOnly READ specifiesAltitudeOnly NOTIFY specifiesAltitudeOnlyChanged) ///< true: Item has altitude only, no full coordinate
......
......@@ -7,27 +7,34 @@ import QGroundControl.Palette 1.0
Canvas {
id: root
width: _width
height: width
height: _height
signal clicked
property string label
property string label ///< Label to show to the side of the index indicator
property int index: 0 ///< Index to show in the indicator, 0 will show label instead
property bool checked: false
property bool small: false
property var color: checked ? "green" : qgcPal.mapButtonHighlight
property real anchorPointX: _width / 2
property real anchorPointY: _width / 2
property real anchorPointX: _height / 2
property real anchorPointY: _height / 2
property bool specifiesCoordinate: true
property real gimbalYaw
property real vehicleYaw
property bool showGimbalYaw: false
property real _width: showGimbalYaw ? _gimbalYawRadius * 2 : _indicatorRadius * 2
property bool _singleChar: _label.text.length <= 1
property real _width: showGimbalYaw ? Math.max(_gimbalWidth, labelControl.visible ? labelControl.width : indicator.width) : (labelControl.visible ? labelControl.width : indicator.width)
property real _height: showGimbalYaw ? _gimbalYawWidth : (labelControl.visible ? labelControl.height : indicator.height)
property real _gimbalYawRadius: ScreenTools.defaultFontPixelHeight
property real _gimbalYawWidth: _gimbalYawRadius * 2
property real _indicatorRadius: small ? (ScreenTools.defaultFontPixelHeight * ScreenTools.smallFontPointRatio * 1.25 / 2) : (ScreenTools.defaultFontPixelHeight * 0.66)
property real _gimbalRadians: degreesToRadians(vehicleYaw + gimbalYaw - 90)
property real _labelMargin: 2
property real _labelRadius: _indicatorRadius + _labelMargin
property string _label: index === 0 ? "" : label
property string _index: index === 0 ? label : index
onColorChanged: requestPaint()
onShowGimbalYawChanged: requestPaint()
......@@ -54,63 +61,62 @@ Canvas {
}
}
function paintSingleCoordinate(context) {
context.beginPath()
context.arc(_width / 2, _width / 2, _width / 2, (Math.PI / 8) * 7, Math.PI / 8);
context.lineTo(_width / 2, _width * 1.5)
context.closePath()
context.fillStyle = color
context.fill()
}
function paintSingleNoCoordinate(context) {
context.save()
context.beginPath()
context.translate(anchorPointX, anchorPointY)
context.arc(0, 0, _indicatorRadius, Math.PI * 2, 0);
context.closePath()
context.fillStyle = color
context.fill()
context.restore()
}
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.clearRect(0, 0, width, height)
paintGimbalYaw(context)
/*
if (_singleChar) {
if (specifiesCoordinate) {
paintSingleCoordinate(context)
} else {
paintSingleNoCoordinate(context)
}
} else {
paintMultipleCoordinate(context)
}
*/
paintSingleNoCoordinate(context)
Rectangle {
id: labelControl
anchors.leftMargin: -_labelMargin
anchors.topMargin: -_labelMargin
anchors.left: indicator.left
anchors.top: indicator.top
height: _labelRadius * 2
width: labelControlLabel.contentWidth + (_labelMargin * 3) + indicator.width
color: "white"
opacity: 0.5
radius: _labelRadius
visible: _label.length !== 0
}
QGCLabel {
id: _label
anchors.centerIn: parent
id: labelControlLabel
anchors.leftMargin: indicator.width + _labelMargin
anchors.left: labelControl.left
anchors.rightMargin: _labelMargin
anchors.right: labelControl.right
anchors.top: labelControl.top
anchors.bottom: labelControl.bottom
verticalAlignment: Text.AlignVCenter
color: "white"
font.pointSize: ScreenTools.defaultFontPointSize
fontSizeMode: Text.HorizontalFit
text: _label
}
Rectangle {
id: indicator
anchors.horizontalCenter: parent.left
anchors.verticalCenter: parent.top
anchors.horizontalCenterOffset: anchorPointX
anchors.verticalCenterOffset: anchorPointY
width: _indicatorRadius * 2
height: width
color: root.color
radius: _indicatorRadius
QGCLabel {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "white"
font.pointSize: ScreenTools.defaultFontPointSize
fontSizeMode: Text.HorizontalFit
text: label
text: _index
}
}
QGCMouseArea {
......
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