Commit 9f86fc06 authored by Don Gagne's avatar Don Gagne

Merge pull request #2370 from DonLakeFlyer/AltDisplay

Mission: Switch back to item #, plus alt display
parents 8ec600aa ad760d1b
......@@ -50,6 +50,7 @@
<file alias="QGroundControl/Controls/MainToolBarIndicators.qml">src/ui/toolbar/MainToolBarIndicators.qml</file>
<file alias="QGroundControl/Controls/MissionItemEditor.qml">src/QmlControls/MissionItemEditor.qml</file>
<file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">src/QmlControls/MissionItemIndexLabel.qml</file>
<file alias="QGroundControl/Controls/MissionItemStatus.qml">src/MissionEditor/MissionItemStatus.qml</file>
<file alias="QGroundControl/Controls/MissionCommandDialog.qml">src/QmlControls/MissionCommandDialog.qml</file>
<file alias="QGroundControl/Controls/ModeSwitchDisplay.qml">src/QmlControls/ModeSwitchDisplay.qml</file>
<file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file>
......
......@@ -39,30 +39,11 @@ MapQuickItem {
anchorPoint.x: sourceItem.width / 2
anchorPoint.y: sourceItem.height / 2
Connections {
target: missionItem
onCoordinateChanged: recalcLabel()
onRelativeAltitudeChanged: recalcLabel()
}
Component.onCompleted: recalcLabel()
function recalcLabel() {
var label = Math.round(object.coordinate.altitude)
if (!object.relativeAltitude) {
label = "=" + label
}
if (object.homePosition) {
label = "H" + label
}
_label.label = label
}
sourceItem:
MissionItemIndexLabel {
id: _label
isCurrentItem: missionItem.isCurrentItem
label: missionItem.sequenceNumber
onClicked: _item.clicked()
}
}
......@@ -70,9 +70,6 @@ MapItemView {
}
}
/*
Turned off for now
// These are the non-coordinate child mission items attached to this item
Row {
anchors.top: parent.top
......@@ -90,6 +87,5 @@ MapItemView {
}
}
}
*/
}
}
......@@ -285,9 +285,6 @@ QGCView {
onCommandChanged: updateItemIndicator()
}
/*
Disabled for now: Not sure if they will come back
// These are the non-coordinate child mission items attached to this item
Row {
anchors.top: parent.top
......@@ -305,7 +302,6 @@ QGCView {
}
}
}
*/
}
}
......@@ -424,16 +420,6 @@ QGCView {
}
}
/*
Home Position manager temporarily disable
RoundButton {
id: homePositionManagerButton
buttonImage: "/qmlimages/MapHome.svg"
//exclusiveGroup: _dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets
}
*/
DropButton {
id: syncButton
dropDirection: dropRight
......@@ -558,48 +544,16 @@ QGCView {
}
}
Rectangle {
MissionItemStatus {
id: waypointValuesDisplay
anchors.margins: margins
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
anchors.bottom: parent.bottom
width: distanceLabel.width + (margins * 2)
height: valuesColumn.height + (margins * 2)
radius: ScreenTools.defaultFontPixelWidth
color: qgcPal.window
opacity: 0.80
visible: _currentMissionItem ? _currentMissionItem.distance != -1 : false
readonly property real margins: ScreenTools.defaultFontPixelWidth
property real _altDifference: _currentMissionItem ? _currentMissionItem.altDifference : 0
property real _azimuth: _currentMissionItem ? _currentMissionItem.azimuth : 0
property real _distance: _currentMissionItem ? _currentMissionItem.distance : 0
Column {
id: valuesColumn
anchors.leftMargin: parent.margins
anchors.topMargin: parent.margins
anchors.left: parent.left
anchors.top: parent.top
QGCLabel {
id: distanceLabel
color: qgcPal.text
text: "Distance: " + Math.round(waypointValuesDisplay._distance) + " meters"
}
QGCLabel {
color: qgcPal.text
text: "Alt diff: " + Math.round(waypointValuesDisplay._altDifference) + " meters"
}
QGCLabel {
color: qgcPal.text
text: "Azimuth: " + Math.round(waypointValuesDisplay._azimuth)
}
}
z: QGroundControl.zOrderTopMost
currentMissionItem: _currentMissionItem
missionItems: controller.missionItems
expandedWidth: missionItemEditor.x - (ScreenTools.defaultFontPixelWidth * 2)
homePositionValid: liveHomePositionAvailable
}
} // FlightMap
} // Item - split view container
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.5
import QtQuick.Controls 1.3
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
Rectangle {
property var currentMissionItem ///< Mission item to display status for
property var missionItems ///< List of all available mission items
property real expandedWidth ///< Width of control when expanded
property bool homePositionValid: false /// true: home position in missionItems[0] is valid
width: _expanded ? expandedWidth : _collapsedWidth
height: expandLabel.y + expandLabel.height + _margins
radius: ScreenTools.defaultFontPixelWidth
color: qgcPal.window
opacity: 0.80
clip: true
readonly property real margins: ScreenTools.defaultFontPixelWidth
property real _collapsedWidth: distanceLabel.width + (margins * 2)
property bool _expanded: true
property real _distance: _currentMissionItem ? _currentMissionItem.distance : -1
property real _altDifference: _currentMissionItem ? _currentMissionItem.altDifference : -1
property real _azimuth: _currentMissionItem ? _currentMissionItem.azimuth : -1
property real _isHomePosition: _currentMissionItem ? _currentMissionItem.homePosition : false
property bool _statusValid: _distance != -1 && ((_isHomePosition && homePositionValid) || !_isHomePosition)
property string _distanceText: _statusValid ? Math.round(_distance) + " meters" : ""
property string _altText: _statusValid ? Math.round(_altDifference) + " meters" : ""
property string _azimuthText: _statusValid ? Math.round(_azimuth) : ""
readonly property real _margins: ScreenTools.defaultFontPixelWidth
MouseArea {
anchors.fill: parent
onClicked: _expanded = !_expanded
}
QGCLabel {
id: distanceLabel
anchors.margins: _margins
anchors.left: parent.left
anchors.top: parent.top
text: "Distance: " + _distanceText
}
QGCLabel {
id: altLabel
anchors.left: distanceLabel.left
anchors.top: distanceLabel.bottom
text: "Alt diff: " + _altText
}
QGCLabel {
id: azimuthLabel
anchors.left: altLabel.left
anchors.top: altLabel.bottom
text: "Azimuth: " + _azimuthText
}
QGCLabel {
id: expandLabel
anchors.left: azimuthLabel.left
anchors.top: azimuthLabel.bottom
text: _expanded ? "<<" : ">>"
}
Flickable {
anchors.leftMargin: _margins
anchors.rightMargin: _margins
anchors.left: distanceLabel.right
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
Row {
id: graphRow
anchors.top: parent.top
anchors.bottom: parent.bottom
spacing: ScreenTools.smallFontPixelWidth
Repeater {
model: missionItems
Item {
height: graphRow.height
width: ScreenTools.smallFontPixelWidth * 2
property real availableHeight: height - ScreenTools.smallFontPixelHeight - indicator.height
// If home position is not valid we are graphing relative based on a home alt of 0. Because of this
// we cannot graph absolute altitudes since we have no basis for comparison against the relative values.
property bool graphAbsolute: homePositionValid
MissionItemIndexLabel {
id: indicator
anchors.horizontalCenter: parent.horizontalCenter
y: availableHeight - (availableHeight * object.altPercent)
small: true
isCurrentItem: object.isCurrentItem
label: object.homePosition ? "H" : object.sequenceNumber
visible: object.relativeAltitude ? true : (object.homePosition || graphAbsolute)
}
QGCLabel {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: ScreenTools.smallFontPixelSize
text: (object.relativeAltitude ? "" : "=") + object.coordinate.altitude
}
}
}
}
}
}
......@@ -341,9 +341,15 @@ void MissionController::_recalcWaypointLines(void)
// both relative altitude.
// No values for first item
lastCoordinateItem->setAltDifference(0.0);
lastCoordinateItem->setAzimuth(0.0);
lastCoordinateItem->setDistance(-1.0);
double minAltSeen = 0.0;
double maxAltSeen = 0.0;
double homePositionAltitude = homeItem->coordinate().altitude();
minAltSeen = maxAltSeen = homeItem->coordinate().altitude();
_waypointLines.clear();
for (int i=1; i<_missionItems->count(); i++) {
......@@ -353,35 +359,62 @@ void MissionController::_recalcWaypointLines(void)
item->setAzimuth(0.0);
item->setDistance(-1.0);
if (item->specifiesCoordinate() && !item->standaloneCoordinate()) {
if (firstCoordinateItem) {
if (item->command() == MavlinkQmlSingleton::MAV_CMD_NAV_TAKEOFF) {
// The first coordinate we hit is a takeoff command so link back to home position if valid
if (homePositionValid) {
double azimuth, distance, altDifference;
_waypointLines.append(new CoordinateVector(homeItem->coordinate(), item->coordinate()));
_calcPrevWaypointValues(homePositionValid, homeAlt, item, homeItem, &azimuth, &distance, &altDifference);
item->setAltDifference(altDifference);
item->setAzimuth(azimuth);
item->setDistance(distance);
if (item->specifiesCoordinate()) {
double absoluteAltitude = item->coordinate().altitude();
if (item->relativeAltitude() && homePositionValid) {
absoluteAltitude += homePositionAltitude;
}
minAltSeen = std::min(minAltSeen, absoluteAltitude);
maxAltSeen = std::max(maxAltSeen, absoluteAltitude);
if (!item->standaloneCoordinate()) {
if (firstCoordinateItem) {
if (item->command() == MavlinkQmlSingleton::MAV_CMD_NAV_TAKEOFF) {
// The first coordinate we hit is a takeoff command so link back to home position if valid
if (homePositionValid) {
double azimuth, distance, altDifference;
_waypointLines.append(new CoordinateVector(homeItem->coordinate(), item->coordinate()));
_calcPrevWaypointValues(homePositionValid, homeAlt, item, homeItem, &azimuth, &distance, &altDifference);
item->setAltDifference(altDifference);
item->setAzimuth(azimuth);
item->setDistance(distance);
}
} else {
// First coordiante is not a takeoff command, it does not link backwards to anything
}
} else {
// First coordiante is not a takeoff command, it does not link backwards to anything
firstCoordinateItem = false;
} else if (!lastCoordinateItem->homePosition() || lastCoordinateItem->homePositionValid()) {
double azimuth, distance, altDifference;
// Subsequent coordinate items link to last coordinate item. If the last coordinate item
// is an invalid home position we skip the line
_calcPrevWaypointValues(homePositionValid, homeAlt, item, lastCoordinateItem, &azimuth, &distance, &altDifference);
item->setAltDifference(altDifference);
item->setAzimuth(azimuth);
item->setDistance(distance);
_waypointLines.append(new CoordinateVector(lastCoordinateItem->coordinate(), item->coordinate()));
}
firstCoordinateItem = false;
} else if (!lastCoordinateItem->homePosition() || lastCoordinateItem->homePositionValid()) {
double azimuth, distance, altDifference;
// Subsequent coordinate items link to last coordinate item. If the last coordinate item
// is an invalid home position we skip the line
_calcPrevWaypointValues(homePositionValid, homeAlt, item, lastCoordinateItem, &azimuth, &distance, &altDifference);
item->setAltDifference(altDifference);
item->setAzimuth(azimuth);
item->setDistance(distance);
_waypointLines.append(new CoordinateVector(lastCoordinateItem->coordinate(), item->coordinate()));
lastCoordinateItem = item;
}
}
}
// Walk the list again calculating altitude percentages
double altRange = maxAltSeen - minAltSeen;
for (int i=0; i<_missionItems->count(); i++) {
MissionItem* item = qobject_cast<MissionItem*>(_missionItems->get(i));
if (item->specifiesCoordinate()) {
double absoluteAltitude = item->coordinate().altitude();
if (item->relativeAltitude() && homePositionValid) {
absoluteAltitude += homePositionAltitude;
}
if (altRange == 0.0) {
item->setAltPercent(0.0);
} else {
item->setAltPercent((absoluteAltitude - minAltSeen) / altRange);
}
lastCoordinateItem = item;
}
}
......@@ -448,6 +481,11 @@ void MissionController::_initAllMissionItems(void)
}
homeItem->setCommand(MAV_CMD_NAV_WAYPOINT);
homeItem->setFrame(MAV_FRAME_GLOBAL);
if (!homeItem->homePositionValid()) {
QGeoCoordinate homeCoord = homeItem->coordinate();
homeCoord.setAltitude(0.0);
homeItem->setCoordinate(homeCoord);
}
for (int i=0; i<_missionItems->count(); i++) {
_initMissionItem(qobject_cast<MissionItem*>(_missionItems->get(i)));
......
......@@ -81,6 +81,8 @@ MissionItem::MissionItem(QObject* parent)
, _dirty(false)
, _sequenceNumber(0)
, _isCurrentItem(false)
, _altDifference(0.0)
, _altPercent(0.0)
, _azimuth(0.0)
, _distance(0.0)
, _homePositionSpecialCase(false)
......@@ -140,6 +142,7 @@ MissionItem::MissionItem(int sequenceNumber,
, _sequenceNumber(sequenceNumber)
, _isCurrentItem(isCurrentItem)
, _altDifference(0.0)
, _altPercent(0.0)
, _azimuth(0.0)
, _distance(0.0)
, _homePositionSpecialCase(false)
......@@ -198,6 +201,7 @@ MissionItem::MissionItem(const MissionItem& other, QObject* parent)
, _sequenceNumber(0)
, _isCurrentItem(false)
, _altDifference(0.0)
, _altPercent(0.0)
, _azimuth(0.0)
, _distance(0.0)
, _homePositionSpecialCase(false)
......@@ -243,6 +247,7 @@ const MissionItem& MissionItem::operator=(const MissionItem& other)
setAutoContinue(other.autoContinue());
setIsCurrentItem(other._isCurrentItem);
setAltDifference(other._altDifference);
setAltPercent(other._altPercent);
setAzimuth(other._azimuth);
setDistance(other._distance);
setHomePositionSpecialCase(other._homePositionSpecialCase);
......@@ -734,6 +739,12 @@ void MissionItem::setAltDifference(double altDifference)
emit altDifferenceChanged(_altDifference);
}
void MissionItem::setAltPercent(double altPercent)
{
_altPercent = altPercent;
emit altPercentChanged(_altPercent);
}
void MissionItem::setAzimuth(double azimuth)
{
_azimuth = azimuth;
......
......@@ -69,6 +69,7 @@ public:
const MissionItem& operator=(const MissionItem& other);
Q_PROPERTY(double altDifference READ altDifference WRITE setAltDifference NOTIFY altDifferenceChanged) ///< Change in altitude from previous waypoint
Q_PROPERTY(double altPercent READ altPercent WRITE setAltPercent NOTIFY altPercentChanged) ///< Percent of total altitude change in mission altitude
Q_PROPERTY(double azimuth READ azimuth WRITE setAzimuth NOTIFY azimuthChanged) ///< Azimuth to previous waypoint
Q_PROPERTY(QString category READ category NOTIFY commandChanged)
Q_PROPERTY(MavlinkQmlSingleton::Qml_MAV_CMD command READ command WRITE setCommand NOTIFY commandChanged)
......@@ -100,6 +101,7 @@ public:
// Property accesors
double altDifference (void) const { return _altDifference; }
double altPercent (void) const { return _altPercent; }
double azimuth (void) const { return _azimuth; }
QString category (void) const;
MavlinkQmlSingleton::Qml_MAV_CMD command(void) const { return (MavlinkQmlSingleton::Qml_MAV_CMD)_commandFact.cookedValue().toInt(); };
......@@ -139,9 +141,10 @@ public:
void setHomePositionValid(bool homePositionValid);
void setHomePositionSpecialCase(bool homePositionSpecialCase) { _homePositionSpecialCase = homePositionSpecialCase; }
void setAltDifference(double altDifference);
void setAzimuth(double azimuth);
void setDistance(double distance);
void setAltDifference (double altDifference);
void setAltPercent (double altPercent);
void setAzimuth (double azimuth);
void setDistance (double distance);
// C++ only methods
......@@ -180,6 +183,7 @@ public slots:
signals:
void altDifferenceChanged (double altDifference);
void altPercentChanged (double altPercent);
void azimuthChanged (double azimuth);
void commandChanged (MavlinkQmlSingleton::Qml_MAV_CMD command);
void coordinateChanged (const QGeoCoordinate& coordinate);
......@@ -220,6 +224,7 @@ private:
int _sequenceNumber;
bool _isCurrentItem;
double _altDifference; ///< Difference in altitude from previous waypoint
double _altPercent; ///< Percent of total altitude change in mission
double _azimuth; ///< Azimuth to previous waypoint
double _distance; ///< Distance to previous waypoint
bool _homePositionSpecialCase; ///< true: This item is being used as a ui home position indicator
......
import QtQuick 2.2
import QtQuick 2.5
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
......@@ -8,31 +8,33 @@ import QGroundControl.Palette 1.0
Rectangle {
property alias label: _label.text
property bool isCurrentItem: false
property bool small: false
signal clicked
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 4
QGCPalette { id: qgcPal }
width: _label.width + (_margin * 2)
height: _label.height + (_margin * 2)
radius: _margin
border.width: 1
width: _width
height: _width
radius: _width / 2
border.width: small ? 1 : 2
border.color: "white"
color: isCurrentItem ? "green" : qgcPal.mapButtonHighlight
property real _width: small ? ScreenTools.smallFontPixelSize * 1.5 : ScreenTools.mediumFontPixelSize * 1.5
QGCPalette { id: qgcPal }
MouseArea {
anchors.fill: parent
onClicked: parent.clicked()
anchors.fill: parent
onClicked: parent.clicked()
}
QGCLabel {
id: _label
anchors.margins: _margin
anchors.left: parent.left
anchors.top: parent.top
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "white"
font.pixelSize: ScreenTools.defaultFontPixelSize
font.pixelSize: small ? ScreenTools.smallFontPixelSize : ScreenTools.mediumFontPixelSize
}
}
......@@ -9,6 +9,7 @@ MainToolBar 1.0 MainToolBar.qml
MissionCommandDialog 1.0 MissionCommandDialog.qml
MissionItemEditor 1.0 MissionItemEditor.qml
MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml
MissionItemStatus 1.0 MissionItemStatus.qml
ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml
ParameterEditor 1.0 ParameterEditor.qml
ParameterEditorDialog 1.0 ParameterEditorDialog.qml
......
......@@ -13,6 +13,8 @@ Item {
readonly property real defaultFontPixelHeight: defaultFontPixelSize
readonly property real defaultFontPixelWidth: _textMeasure.fontWidth
readonly property real smallFontPixelSize: defaultFontPixelSize * ScreenToolsController.smallFontPixelSizeRatio
readonly property real smallFontPixelHeight: smallFontPixelSize
readonly property real smallFontPixelWidth: defaultFontPixelWidth * ScreenToolsController.smallFontPixelSizeRatio
// To proportionally scale fonts
......
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