Commit a6cffd54 authored by Don Gagne's avatar Don Gagne

Merge pull request #2841 from DonLakeFlyer/Gradient

Plan: Add Gradient to bottom item status
parents f1075263 fd7afab6
...@@ -34,7 +34,7 @@ Rectangle { ...@@ -34,7 +34,7 @@ Rectangle {
property real expandedWidth ///< Width of control when expanded property real expandedWidth ///< Width of control when expanded
width: _expanded ? expandedWidth : _collapsedWidth width: _expanded ? expandedWidth : _collapsedWidth
height: expandLabel.y + expandLabel.height + _margins height: azimuthLabel.y + azimuthLabel.height + _margins
radius: ScreenTools.defaultFontPixelWidth radius: ScreenTools.defaultFontPixelWidth
color: qgcPal.window color: qgcPal.window
opacity: 0.80 opacity: 0.80
...@@ -44,13 +44,16 @@ Rectangle { ...@@ -44,13 +44,16 @@ Rectangle {
property real _collapsedWidth: distanceLabel.width + (margins * 2) property real _collapsedWidth: distanceLabel.width + (margins * 2)
property bool _expanded: true property bool _expanded: true
property real _distance: _currentMissionItem ? _currentMissionItem.distance : -1 property real _distance: _statusValid ? _currentMissionItem.distance : 0
property real _altDifference: _currentMissionItem ? _currentMissionItem.altDifference : -1 property real _altDifference: _statusValid ? _currentMissionItem.altDifference : 0
property real _azimuth: _currentMissionItem ? _currentMissionItem.azimuth : -1 property real _gradient: _statusValid ? Math.atan(_currentMissionItem.altDifference / _currentMissionItem.distance) : 0
property real _isHomePosition: _currentMissionItem ? _currentMissionItem.homePosition : false property real _gradientPercent: isNaN(_gradient) ? 0 : _gradient * 100
property bool _statusValid: _distance != -1 property real _azimuth: _statusValid ? _currentMissionItem.azimuth : -1
property string _distanceText: _statusValid ? Math.round(_distance) + " meters" : "" property real _isHomePosition: _statusValid ? _currentMissionItem.homePosition : false
property string _altText: _statusValid ? Math.round(_altDifference) + " meters" : "" property bool _statusValid: currentMissionItem != undefined
property string _distanceText: _statusValid ? _distance.toFixed(2) + " m" : ""
property string _altText: _statusValid ? _altDifference.toFixed(2) + " m" : ""
property string _gradientText: _statusValid ? _gradientPercent.toFixed(0) + "%" : ""
property string _azimuthText: _statusValid ? Math.round(_azimuth) : "" property string _azimuthText: _statusValid ? Math.round(_azimuth) : ""
readonly property real _margins: ScreenTools.defaultFontPixelWidth readonly property real _margins: ScreenTools.defaultFontPixelWidth
...@@ -76,17 +79,17 @@ Rectangle { ...@@ -76,17 +79,17 @@ Rectangle {
} }
QGCLabel { QGCLabel {
id: azimuthLabel id: gradientLabel
anchors.left: altLabel.left anchors.left: distanceLabel.left
anchors.top: altLabel.bottom anchors.top: altLabel.bottom
text: "Azimuth: " + _azimuthText text: "Gradient: " + _gradientText
} }
QGCLabel { QGCLabel {
id: expandLabel id: azimuthLabel
anchors.left: azimuthLabel.left anchors.left: distanceLabel.left
anchors.top: azimuthLabel.bottom anchors.top: gradientLabel.bottom
text: _expanded ? "<<" : ">>" text: "Azimuth: " + _azimuthText
} }
QGCFlickable { QGCFlickable {
...@@ -128,12 +131,15 @@ Rectangle { ...@@ -128,12 +131,15 @@ Rectangle {
visible: object.relativeAltitude ? true : (object.homePosition || graphAbsolute) visible: object.relativeAltitude ? true : (object.homePosition || graphAbsolute)
} }
/*
Taking these off for now since there really isn't room for the numbers
QGCLabel { QGCLabel {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: ScreenTools.smallFontPixelSize font.pixelSize: ScreenTools.smallFontPixelSize
text: (object.relativeAltitude ? "" : "=") + object.coordinate.altitude text: (object.relativeAltitude ? "" : "=") + object.coordinate.altitude.toFixed(0)
} }
*/
} }
} }
......
...@@ -778,7 +778,8 @@ bool MissionController::_findLastAltitude(double* lastAltitude) ...@@ -778,7 +778,8 @@ bool MissionController::_findLastAltitude(double* lastAltitude)
bool found = false; bool found = false;
double foundAltitude; double foundAltitude;
for (int i=0; i<_missionItems->count(); i++) { // Don't use home position
for (int i=1; i<_missionItems->count(); i++) {
MissionItem* item = qobject_cast<MissionItem*>(_missionItems->get(i)); MissionItem* item = qobject_cast<MissionItem*>(_missionItems->get(i));
if (item->specifiesCoordinate() && !item->standaloneCoordinate()) { if (item->specifiesCoordinate() && !item->standaloneCoordinate()) {
......
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