Commit c58f1378 authored by Don Gagne's avatar Don Gagne

Merge pull request #2349 from DonLakeFlyer/ItemAltitude

Show altitude in mission item
parents e1deebcf 3a4849b3
......@@ -59,18 +59,6 @@ FlightMap {
Component.onCompleted: start(false /* editMode */)
}
// Home position
MissionItemIndicator {
label: "H"
coordinate: (_activeVehicle && _activeVehicle.homePositionAvailable) ? _activeVehicle.homePosition : QtPositioning.coordinate(0, 0)
visible: {
if(!_mainIsMap)
return false;
return _activeVehicle ? _activeVehicle.homePositionAvailable : false
}
z: QGroundControl.zOrderMapItems
}
// Add trajectory points to the map
MapItemView {
model: _mainIsMap ? multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.trajectoryPoints : 0 : 0
......
......@@ -32,18 +32,37 @@ import QGroundControl.Vehicle 1.0
MapQuickItem {
id: _item
property alias label: _label.label
property alias isCurrentItem: _label.isCurrentItem
property var missionItem
signal clicked
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
onClicked: _item.clicked()
}
}
......@@ -39,11 +39,10 @@ MapItemView {
delegate: MissionItemIndicator {
id: itemIndicator
label: object.homePosition ? "H" : object.sequenceNumber
isCurrentItem: object.isCurrentItem
coordinate: object.coordinate
visible: object.specifiesCoordinate && (!object.homePosition || object.homePositionValid)
z: QGroundControl.zOrderMapItems
missionItem: object
onClicked: setCurrentItem(object.sequenceNumber)
......@@ -71,6 +70,9 @@ MapItemView {
}
}
/*
Turned off for now
// These are the non-coordinate child mission items attached to this item
Row {
anchors.top: parent.top
......@@ -88,5 +90,6 @@ MapItemView {
}
}
}
*/
}
}
......@@ -313,11 +313,10 @@ QGCView {
MissionItemIndicator {
id: itemIndicator
label: object.homePosition ? "H" : object.sequenceNumber
isCurrentItem: object.isCurrentItem
coordinate: object.coordinate
visible: object.specifiesCoordinate && (!object.homePosition || object.homePositionValid)
z: QGroundControl.zOrderMapItems
missionItem: object
onClicked: setCurrentItem(object.sequenceNumber)
......@@ -348,6 +347,9 @@ 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
......@@ -365,6 +367,7 @@ QGCView {
}
}
}
*/
}
}
......@@ -414,282 +417,6 @@ QGCView {
} // ListView
} // Item - Mission Item editor
/*
Home Position Manager temporarily disbled till more work is done on it
// Home Position Manager
Rectangle {
id: homePositionManager
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
width: _rightPanelWidth
visible: homePositionManagerButton.checked
color: qgcPal.window
opacity: _rightPanelOpacity
z: QGroundControl.zOrderTopMost
Column {
anchors.margins: _margin
anchors.fill: parent
visible: !liveHomePositionAvailable
QGCLabel {
font.pixelSize: ScreenTools.mediumFontPixelSize
text: "Flying Field Manager"
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight
}
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: "This is used to save locations associated with your flying field for use while creating missions with no vehicle connection."
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight
}
QGCLabel {
text: "Select field to use:"
}
QGCComboBox {
id: homePosCombo
width: parent.width
textRole: "text"
model: _homePositionManager.homePositions
onCurrentIndexChanged: {
if (currentIndex != -1) {
var homePos = _homePositionManager.homePositions.get(currentIndex)
_homePositionName = homePos.name
offlineHomePosition = homePos.coordinate
editorMap.latitude = offlineHomePosition.latitude
editorMap.longitude = offlineHomePosition.longitude
}
}
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight
}
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: "To add a new flying field, click on the Map to set the position. " +
"Then give it a new name and click Add/Update. " +
"To change the current field position, click on the Map to set the new position. " +
"Then click Add/Update without changing the name."
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight / 3
}
Item {
width: parent.width
height: nameField.height
QGCLabel {
anchors.baseline: nameField.baseline
text: "Name:"
}
QGCTextField {
id: nameField
anchors.right: parent.right
width: _editFieldWidth
text: _homePositionName
}
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight / 3
}
Item {
width: parent.width
height: offlineLatitudeField.height
QGCLabel {
anchors.baseline: offlineLatitudeField.baseline
text: "Lat:"
}
QGCTextField {
id: offlineLatitudeField
anchors.right: parent.right
width: _editFieldWidth
text: offlineHomePosition.latitude
}
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight / 3
}
Item {
width: parent.width
height: offlineLongitudeField.height
QGCLabel {
anchors.baseline: offlineLongitudeField.baseline
text: "Lon:"
}
QGCTextField {
id: offlineLongitudeField
anchors.right: parent.right
width: _editFieldWidth
text: offlineHomePosition.longitude
}
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight / 3
}
Item {
width: parent.width
height: offlineAltitudeField.height
QGCLabel {
anchors.baseline: offlineAltitudeField.baseline
text: "Alt:"
}
QGCTextField {
id: offlineAltitudeField
anchors.right: parent.right
width: _editFieldWidth
text: offlineHomePosition.altitude
}
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCButton {
text: "Add/Update"
onClicked: {
offlineHomePosition = QtPositioning.coordinate(latitudeField.text, longitudeField.text, altitudeField.text)
_homePositionManager.updateHomePosition(nameField.text, offlineHomePosition)
homePosCombo.currentIndex = homePosCombo.find(nameField.text)
}
}
QGCButton {
text: "Delete"
onClicked: {
homePosCombo.currentIndex = -1
_homePositionManager.deleteHomePosition(nameField.text)
homePosCombo.currentIndex = 0
var homePos = _homePositionManager.homePositions.get(0)
_homePositionName = homePos.name
offlineHomePosition = homePos.coordinate
}
}
}
} // Column - Offline view
Column {
anchors.margins: _margin
anchors.fill: parent
visible: liveHomePositionAvailable
QGCLabel {
font.pixelSize: ScreenTools.mediumFontPixelSize
text: "Vehicle Home Position"
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight
}
Item {
width: parent.width
height: liveLatitudeField.height
QGCLabel {
anchors.baseline: liveLatitudeField.baseline
text: "Lat:"
}
QGCLabel {
id: liveLatitudeField
anchors.right: parent.right
width: _editFieldWidth
text: liveHomePosition.latitude
}
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight / 3
}
Item {
width: parent.width
height: liveLongitudeField.height
QGCLabel {
anchors.baseline: liveLongitudeField.baseline
text: "Lon:"
}
QGCLabel {
id: liveLongitudeField
anchors.right: parent.right
width: _editFieldWidth
text: liveHomePosition.longitude
}
}
Item {
width: 10
height: ScreenTools.defaultFontPixelHeight / 3
}
Item {
width: parent.width
height: liveAltitudeField.height
QGCLabel {
anchors.baseline: liveAltitudeField.baseline
text: "Alt:"
}
QGCLabel {
id: liveAltitudeField
anchors.right: parent.right
width: _editFieldWidth
text: liveHomePosition.altitude
}
}
} // Column - Online view
} // Item - Home Position Manager
*/
//-- Dismiss Drop Down (if any)
MouseArea {
anchors.fill: parent
......
......@@ -431,6 +431,10 @@ void MissionController::_initAllMissionItems(void)
// Add the home position item to the front
homeItem = new MissionItem(this);
homeItem->setHomePositionSpecialCase(true);
if (_activeVehicle) {
homeItem->setCoordinate(_activeVehicle->homePosition());
homeItem->setHomePositionValid(_activeVehicle->homePositionAvailable());
}
homeItem->setCommand(MavlinkQmlSingleton::MAV_CMD_NAV_LAST);
homeItem->setFrame(MAV_FRAME_GLOBAL_RELATIVE_ALT);
homeItem->setSequenceNumber(0);
......@@ -548,6 +552,7 @@ void MissionController::_activeVehicleHomePositionAvailableChanged(bool homePosi
_liveHomePositionAvailable = homePositionAvailable;
qobject_cast<MissionItem*>(_missionItems->get(0))->setHomePositionValid(homePositionAvailable);
emit liveHomePositionAvailableChanged(_liveHomePositionAvailable);
_recalcWaypointLines();
}
void MissionController::_activeVehicleHomePositionChanged(const QGeoCoordinate& homePosition)
......@@ -555,6 +560,7 @@ void MissionController::_activeVehicleHomePositionChanged(const QGeoCoordinate&
_liveHomePosition = homePosition;
qobject_cast<MissionItem*>(_missionItems->get(0))->setCoordinate(_liveHomePosition);
emit liveHomePositionChanged(_liveHomePosition);
_recalcWaypointLines();
}
void MissionController::deleteCurrentMissionItem(void)
......
......@@ -82,6 +82,7 @@ public:
Q_PROPERTY(bool homePositionValid READ homePositionValid WRITE setHomePositionValid NOTIFY homePositionValidChanged) ///< true: Home position should be shown
Q_PROPERTY(bool isCurrentItem READ isCurrentItem WRITE setIsCurrentItem NOTIFY isCurrentItemChanged)
Q_PROPERTY(bool rawEdit READ rawEdit WRITE setRawEdit NOTIFY rawEditChanged) ///< true: raw item editing with all params
Q_PROPERTY(bool relativeAltitude READ relativeAltitude NOTIFY frameChanged)
Q_PROPERTY(int sequenceNumber READ sequenceNumber WRITE setSequenceNumber NOTIFY sequenceNumberChanged)
Q_PROPERTY(bool standaloneCoordinate READ standaloneCoordinate NOTIFY commandChanged)
Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate NOTIFY commandChanged)
......
......@@ -49,11 +49,11 @@ Rectangle {
onClicked: _root.clicked()
}
MissionItemIndexLabel {
QGCLabel {
id: label
anchors.verticalCenter: commandPicker.verticalCenter
isCurrentItem: missionItem.isCurrentItem
label: missionItem.sequenceNumber == 0 ? "H" : missionItem.sequenceNumber
color: missionItem.isCurrentItem ? qgcPal.buttonHighlightText : qgcPal.buttonText
text: missionItem.sequenceNumber == 0 ? "H" : missionItem.sequenceNumber
}
Image {
......@@ -92,19 +92,13 @@ Rectangle {
onClicked: qgcView.showDialog(commandDialog, "Select Mission Command", 40, StandardButton.Cancel)
}
Rectangle {
QGCLabel {
anchors.fill: commandPicker
color: qgcPal.button
visible: missionItem.sequenceNumber == 0 || !missionItem.isCurrentItem
QGCLabel {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
text: missionItem.sequenceNumber == 0 ? "Home" : missionItem.commandName
color: qgcPal.buttonText
}
}
Rectangle {
id: valuesRect
......
......@@ -11,27 +11,28 @@ Rectangle {
signal clicked
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 4
QGCPalette { id: qgcPal }
width: ScreenTools.mediumFontPixelSize * 1.5
height: width
radius: width / 2
border.width: 2
width: _label.width + (_margin * 2)
height: _label.height + (_margin * 2)
radius: _margin
border.width: 1
border.color: "white"
color: isCurrentItem ? "green" : qgcPal.mapButtonHighlight
MouseArea {
anchors.fill: parent
onClicked: parent.clicked()
}
QGCLabel {
id: _label
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.margins: _margin
anchors.left: parent.left
anchors.top: parent.top
color: "white"
font.pixelSize: ScreenTools.mediumFontPixelSize
font.pixelSize: ScreenTools.defaultFontPixelSize
}
}
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