Commit 0f3a3ee2 authored by Don Gagne's avatar Don Gagne

Add Mission Items to Fly View

parent 81621c14
......@@ -70,6 +70,9 @@
<file alias="QGroundControl/FactControls/FactCheckBox.qml">src/FactSystem/FactControls/FactCheckBox.qml</file>
<file alias="QGroundControl/FactControls/FactComboBox.qml">src/FactSystem/FactControls/FactComboBox.qml</file>
<file alias="QGroundControl/Controls/qmldir">src/QmlControls/QGroundControl.Controls.qmldir</file>
<!-- Controls module -->
<file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file>
<file alias="QGroundControl/Controls/QGCRadioButton.qml">src/QmlControls/QGCRadioButton.qml</file>
<file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file>
......@@ -81,7 +84,6 @@
<file alias="QGroundControl/Controls/QGCMovableItem.qml">src/QmlControls/QGCMovableItem.qml</file>
<file alias="QGroundControl/ScreenTools/qmldir">src/QmlControls/QGroundControl.ScreenTools.qmldir</file>
<file alias="QGroundControl/ScreenTools/ScreenTools.qml">src/QmlControls/ScreenTools.qml</file>
<file alias="ScreenToolsFontQuery.qml">src/QmlControls/ScreenToolsFontQuery.qml</file>
<file alias="QGroundControl/Controls/SubMenuButton.qml">src/QmlControls/SubMenuButton.qml</file>
<file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
<file alias="QGroundControl/Controls/VehicleRotationCal.qml">src/QmlControls/VehicleRotationCal.qml</file>
......@@ -94,6 +96,10 @@
<file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file>
<file alias="QGroundControl/Controls/ParameterEditorDialog.qml">src/QmlControls/ParameterEditorDialog.qml</file>
<file alias="QGroundControl/Controls/ModeSwitchDisplay.qml">src/QmlControls/ModeSwitchDisplay.qml</file>
<file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">src/QmlControls/MissionItemIndexLabel.qml</file>
<file alias="QGroundControl/Controls/MissionItemSummary.qml">src/QmlControls/MissionItemSummary.qml</file>
<file alias="ScreenToolsFontQuery.qml">src/QmlControls/ScreenToolsFontQuery.qml</file>
<file alias="ParameterEditorWidget.qml">src/ViewWidgets/ParameterEditorWidget.qml</file>
<file alias="CustomCommandWidget.qml">src/ViewWidgets/CustomCommandWidget.qml</file>
<file alias="SetupView.qml">src/VehicleSetup/SetupView.qml</file>
......@@ -125,6 +131,7 @@
<file alias="QGroundControl/FlightMap/FlightMap.qml">src/FlightMap/FlightMap.qml</file>
<file alias="QGroundControl/FlightMap/QGCVideoBackground.qml">src/FlightMap/QGCVideoBackground.qml</file>
<!-- FlightMap Widgets -->
<file alias="QGroundControl/FlightMap/QGCAltitudeWidget.qml">src/FlightMap/Widgets/QGCAltitudeWidget.qml</file>
<file alias="QGroundControl/FlightMap/QGCArtificialHorizon.qml">src/FlightMap/Widgets/QGCArtificialHorizon.qml</file>
<file alias="QGroundControl/FlightMap/QGCAttitudeWidget.qml">src/FlightMap/Widgets/QGCAttitudeWidget.qml</file>
......@@ -138,8 +145,11 @@
<file alias="QGroundControl/FlightMap/QGCSlider.qml">src/FlightMap/Widgets/QGCSlider.qml</file>
<file alias="QGroundControl/FlightMap/QGCSpeedWidget.qml">src/FlightMap/Widgets/QGCSpeedWidget.qml</file>
<file alias="QGroundControl/FlightMap/QGCWaypointEditor.qml">src/FlightMap/Widgets/QGCWaypointEditor.qml</file>
<file alias="QGroundControl/FlightMap/QGCWaypoint.qml">src/FlightMap/MapItems/QGCWaypoint.qml</file>
<!-- FlightMap MapQuickItems -->
<file alias="QGroundControl/FlightMap/MissionMapItem.qml">src/FlightMap/MapItems/MissionMapItem.qml</file>
<file alias="QGroundControl/FlightMap/VehicleMapItem.qml">src/FlightMap/MapItems/VehicleMapItem.qml</file>
</qresource>
<qresource prefix="/res">
<file alias="LeftArrow">resources/LeftArrow.svg</file>
......
......@@ -52,9 +52,11 @@ Item {
property real _roll: _activeVehicle ? (isNaN(_activeVehicle.roll) ? _defaultRoll : _activeVehicle.roll) : _defaultRoll
property real _pitch: _activeVehicle ? (isNaN(_activeVehicle.pitch) ? _defaultPitch : _activeVehicle.pitch) : _defaultPitch
property real _heading: _activeVehicle ? (isNaN(_activeVehicle.heading) ? _defaultHeading : _activeVehicle.heading) : _defaultHeading
property real _latitude: _activeVehicle ? ((_activeVehicle.latitude === 0) ? _defaultLatitude : _activeVehicle.latitude) : _defaultLatitude
property real _longitude: _activeVehicle ? ((_activeVehicle.longitude === 0) ? _defaultLongitude : _activeVehicle.longitude) : _defaultLongitude
property real _heading: _activeVehicle ? (isNaN(_activeVehicle.heading) ? _defaultHeading : _activeVehicle.heading) : _defaultHeading
property real _altitudeWGS84: _activeVehicle ? _activeVehicle.altitudeWGS84 : _defaultAltitudeWGS84
property real _groundSpeed: _activeVehicle ? _activeVehicle.groundSpeed : _defaultGroundSpeed
property real _airSpeed: _activeVehicle ? _activeVehicle.airSpeed : _defaultAirSpeed
......@@ -72,17 +74,18 @@ Item {
id: flightMap
anchors.fill: parent
mapName: "FlightDisplayView"
latitude: _latitude
longitude: _longitude
latitude: parent._latitude
longitude: parent._longitude
z: 10
showVehicles: true
showMissionItems: true
}
QGCCompassWidget {
x: ScreenTools.defaultFontPixelSize * (7.1)
y: ScreenTools.defaultFontPixelSize * (0.42)
size: ScreenTools.defaultFontPixelSize * (13.3)
heading: _heading
heading: parent._heading
active: multiVehicleManager.activeVehicleAvailable
z: flightMap.z + 2
}
......@@ -92,8 +95,8 @@ Item {
anchors.right: parent.right
y: ScreenTools.defaultFontPixelSize * (0.42)
size: ScreenTools.defaultFontPixelSize * (13.3)
rollAngle: _roll
pitchAngle: _pitch
rollAngle: parent._roll
pitchAngle: parent._pitch
active: multiVehicleManager.activeVehicleAvailable
z: flightMap.z + 2
}
......@@ -102,7 +105,7 @@ Item {
anchors.right: parent.right
height: parent.height * 0.65 > ScreenTools.defaultFontPixelSize * (23.4) ? ScreenTools.defaultFontPixelSize * (23.4) : parent.height * 0.65
width: ScreenTools.defaultFontPixelSize * (5)
altitude: _altitudeWGS84
altitude: parent._altitudeWGS84
z: 30
}
......@@ -110,15 +113,15 @@ Item {
anchors.left: parent.left
width: ScreenTools.defaultFontPixelSize * (5)
height: parent.height * 0.65 > ScreenTools.defaultFontPixelSize * (23.4) ? ScreenTools.defaultFontPixelSize * (23.4) : parent.height * 0.65
speed: _groundSpeed
speed: parent._groundSpeed
z: 40
}
QGCCurrentSpeed {
anchors.left: parent.left
width: ScreenTools.defaultFontPixelSize * (6.25)
airspeed: _airSpeed
groundspeed: _groundSpeed
airspeed: parent._airSpeed
groundspeed: parent._groundSpeed
active: multiVehicleManager.activeVehicleAvailable
z: 50
}
......@@ -126,8 +129,8 @@ Item {
QGCCurrentAltitude {
anchors.right: parent.right
width: ScreenTools.defaultFontPixelSize * (6.25)
altitude: _altitudeWGS84
vertZ: _climbRate
altitude: parent._altitudeWGS84
vertZ: parent._climbRate
active: multiVehicleManager.activeVehicleAvailable
z: 60
}
......
......@@ -51,11 +51,14 @@ Item {
property alias mapItem: map
property alias mapMenu: mapTypeMenu
property bool showVehicles: false
property bool showMissionItems: false
Component.onCompleted: {
map.zoomLevel = 18
mapTypeMenu.update();
addExistingVehicles()
updateMissionItemsConnections()
updateMissionItems()
}
//-- Menu to select supported map types
......@@ -143,7 +146,6 @@ Item {
// we need to keep a separate array of Vehicles which must be at the top level of the object
// hierarchy in order for the dynamically added object to see it.
property var _vehicles: [] ///< List of known vehicles
property var _vehicleMapItems: [] ///< List of known vehicle map items
......@@ -155,6 +157,10 @@ Item {
}
function addVehicle(vehicle) {
if (!showVehicles) {
return
}
var qmlItemTemplate = "VehicleMapItem { " +
"coordinate: _vehicles[%1].coordinate; " +
"heading: _vehicles[%1].heading " +
......@@ -173,6 +179,10 @@ Item {
}
function removeVehicle(vehicle) {
if (!showVehicles) {
return
}
for (var i=0; i<_vehicles.length; i++) {
if (_vehicles[i] == vehicle) {
_vehicles[i] = undefined
......@@ -184,11 +194,102 @@ Item {
}
function addExistingVehicles() {
if (!showVehicles) {
return
}
for (var i=0; i<multiVehicleManager.vehicles.length; i++) {
addVehicle(multiVehicleManager.vehicles[i])
}
}
// The following code is used to show mission items on the FlightMap
property var _missionItems: [] ///< List of known vehicles
property var _missionMapItems: [] ///< List of known vehicle map items
Connections {
target: multiVehicleManager
onActiveVehicleAvailableChanged: updateMissionItemsConnections()
}
function updateMissionItemsConnections() {
if (multiVehicleManager.activeVehicleAvailable) {
multiVehicleManager.activeVehicle.missionItemsChanged.connect(updateMissionItems)
} else {
// Previously active vehicle is about to go away, disconnect signals
if (multiVehicleManager.activeVehicle) {
multiVehicleManager.activeVehicle.missionItemsChanged.disconnect(updateMissionItems)
}
}
}
function addMissionItem(missionItem, index) {
if (!showMissionItems) {
console.warning("Shouldn't be called with showMissionItems=false")
return
}
var qmlItemTemplate = "MissionMapItem { " +
"coordinate: _missionItems[%1].coordinate; " +
"index: %2" +
"}"
var i = _missionItems.length
qmlItemTemplate = qmlItemTemplate.replace("%1", i)
qmlItemTemplate = qmlItemTemplate.replace("%2", index + 1)
_missionItems.push(missionItem)
var mapItem = Qt.createQmlObject (qmlItemTemplate, map)
_missionMapItems.push(mapItem)
mapItem.z = map.z + 1
map.addMapItem(mapItem)
}
function removeMissionItem(missionItem) {
if (!showMissionItems) {
console.warning("Shouldn't be called with showMissionItems=false")
return
}
for (var i=0; i<_missionItems.length; i++) {
if (_missionItems[i] == missionItem) {
// Qml has an annoying habit of not destroying remove Qml item until it hits the main loop.
// Because of that we need to leave the the mission item references even though we have
// removed the items, otherwise we'll get references to undefined errors until we hit the main
// loop again.
//_missionItems[i] = undefined
map.removeMapItem(_missionMapItems[i])
_missionMapItems[i] = undefined
break
}
}
}
function updateMissionItems() {
if (!showMissionItems) {
return
}
var vehicle = multiVehicleManager.activeVehicle
if (!vehicle) {
console.warning("Why no active vehicle?")
return
}
// Remove previous items
for (var i=0; i<_missionItems.length; i++) {
removeMissionItem(_missionItems[i])
}
_missionMapItems = []
// Add new items
for (var i=0; i<vehicle.missionItems.length; i++) {
addMissionItem(vehicle.missionItems[i], i)
}
}
Plugin {
id: mapPlugin
......@@ -268,7 +369,27 @@ Item {
*/
}
/// Mission item list
Row {
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
anchors.right: controlWidgets.left
anchors.bottom: parent.bottom
spacing: ScreenTools.defaultFontPixelWidth
Repeater {
model: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.missionItems : 0
MissionItemSummary {
missionItem: modelData
missionItemIndex: index + 1
}
}
}
/// Map control widgets
Column {
id: controlWidgets
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
anchors.bottom: parent.bottom
......@@ -284,18 +405,55 @@ Item {
layoutDirection: Qt.RightToLeft
spacing: ScreenTools.defaultFontPixelWidth / 2
property real zoomIncrement: 1.0
property real buttonWidth: (optionsButton.width - spacing) / 2
readonly property real _zoomIncrement: 1.0
property real _buttonWidth: (optionsButton.width - spacing) / 2
NumberAnimation {
id: animateZoom
property real startZoom
property real endZoom
target: map
properties: "zoomLevel"
from: startZoom
to: endZoom
duration: 500
easing {
type: Easing.OutExpo
}
}
QGCButton {
width: parent.buttonWidth
width: parent._buttonWidth
text: "+"
onClicked: map.zoomLevel = map.zoomLevel + parent.zoomIncrement
onClicked: {
var endZoomLevel = map.zoomLevel + parent._zoomIncrement
if (endZoomLevel > map.maximumZoomLevel) {
endZoomLevel = map.maximumZoomLevel
}
animateZoom.startZoom = map.zoomLevel
animateZoom.endZoom = endZoomLevel
animateZoom.start()
}
}
QGCButton {
width: parent.buttonWidth
width: parent._buttonWidth
text: "-"
onClicked: map.zoomLevel = map.zoomLevel - parent.zoomIncrement
onClicked: {
var endZoomLevel = map.zoomLevel - parent._zoomIncrement
if (endZoomLevel < map.minimumZoomLevel) {
endZoomLevel = map.minimumZoomLevel
}
animateZoom.startZoom = map.zoomLevel
animateZoom.endZoom = endZoomLevel
animateZoom.start()
}
}
}
}
......
......@@ -21,61 +21,21 @@ This file is part of the QGROUNDCONTROL project
======================================================================*/
/**
* @file
* @brief QGC Waypoint Marker
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.4
import QtLocation 5.3
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
/// Marker for displaying a mission item on the map
MapQuickItem {
id: marker
property int waypointID: 0
anchorPoint.x: markerIcon.width / 2
anchorPoint.y: markerIcon.height / 2
sourceItem: Rectangle {
id: markerIcon
width: 30
height: 30
color: markerMouseArea.containsMouse ? (markerMouseArea.pressed ? Qt.rgba(0.69,0.2,0.68,0.25) : Qt.rgba(0.69,0.2,0.68,0.75)) : Qt.rgba(0,0,0,0.5)
radius: 8
border.color: Qt.rgba(0,0,0,0.75)
Text {
id: number
anchors.centerIn: parent
font.pixelSize: 11
font.weight: Font.DemiBold
color: "white"
text: marker.waypointID
}
MouseArea {
id: markerMouseArea
enabled: !map.readOnly
anchors.fill: parent
hoverEnabled: true
drag.target: marker
preventStealing: true
property int pressX : -1
property int pressY : -1
property int jitterThreshold : 4
onPressed : {
pressX = mouse.x;
pressY = mouse.y;
map.currentMarker = -1;
for (var i = 0; i < map.markers.length; i++) {
if (marker === map.markers[i]) {
map.currentMarker = i;
break;
}
}
}
onPositionChanged: {
if (Math.abs(pressX - mouse.x ) < jitterThreshold && Math.abs(pressY - mouse.y) < jitterThreshold) {
map.updateMarker(marker.coordinate, marker.waypointID)
}
}
}
property int index
anchorPoint.x: sourceItem.width / 2
anchorPoint.y: sourceItem.height / 2
sourceItem:
MissionItemIndexLabel {
missionItemIndex: index
}
}
......@@ -21,4 +21,4 @@ QGCWaypointEditor 1.0 QGCWaypointEditor.qml
# MapQuickItems
VehicleMapItem 1.0 VehicleMapItem.qml
QGCWaypoint 1.0 QGCWaypoint.qml
MissioMapItem 1.0 MissionMapItem.qml
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.ScreenTools 1.0
Rectangle {
property int missionItemIndex ///< Index to show in label
width: ScreenTools.defaultFontPixelHeight * 1.5
height: width
radius: width / 2
border.width: 2
border.color: "white"
color: "orange"
QGCLabel {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "white"
text: missionItemIndex
}
}
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.ScreenTools 1.0
/// Mission item summary display control
Rectangle {
property var missionItem ///< Mission Item object
property int missionItemIndex ///< Index for this item
width: ScreenTools.defaultFontPixelWidth * 15
height: ScreenTools.defaultFontPixelWidth * 3
border.width: 2
border.color: "white"
color: "white"
opacity: 0.75
radius: ScreenTools.defaultFontPixelWidth
QGCLabel {
anchors.margins: parent.radius / 2
anchors.left: parent.left
anchors.top: parent.top
color: "black"
horizontalAlignment: Text.AlignTop
text: missionItem.type
}
MissionItemIndexLabel {
anchors.top: parent.top
anchors.right: parent.right
missionItemIndex: parent.missionItemIndex + 1
}
}
......@@ -26,3 +26,6 @@ QGCViewPanel 1.0 QGCViewPanel.qml
QGCViewDialog 1.0 QGCViewDialog.qml
QGCViewMessage 1.0 QGCViewMessage.qml
MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml
MissionItemSummary 1.0 MissionItemSummary.qml
......@@ -714,7 +714,7 @@ void Vehicle::_waypointViewOnlyListChanged()
Waypoint* wp = waypoints[i];
_waypoints.append(new Waypoint(*wp));
}
emit waypointsChanged();
emit missionItemsChanged();
/*
if(_longitude == DEFAULT_LON && _latitude == DEFAULT_LAT && _waypoints.length()) {
_longitude = _waypoints[0]->getLongitude();
......
......@@ -87,8 +87,9 @@ public:
Q_PROPERTY(double waypointDistance READ waypointDistance NOTIFY waypointDistanceChanged)
Q_PROPERTY(uint16_t currentWaypoint READ currentWaypoint NOTIFY currentWaypointChanged)
Q_PROPERTY(unsigned int heartbeatTimeout READ heartbeatTimeout NOTIFY heartbeatTimeoutChanged)
//-- Waypoint management
Q_PROPERTY(QQmlListProperty<Waypoint> waypoints READ waypoints NOTIFY waypointsChanged)
Q_PROPERTY(QQmlListProperty<Waypoint> missionItems READ missionItems NOTIFY missionItemsChanged)
// Property accesors
int id(void) { return _id; }
......@@ -161,7 +162,7 @@ public:
uint16_t currentWaypoint () { return _currentWaypoint; }
unsigned int heartbeatTimeout () { return _currentHeartbeatTimeout; }
QQmlListProperty<Waypoint> waypoints() {return QQmlListProperty<Waypoint>(this, _waypoints); }
QQmlListProperty<Waypoint> missionItems() {return QQmlListProperty<Waypoint>(this, _waypoints); }
public slots:
void setLatitude(double latitude);
......@@ -203,7 +204,7 @@ signals:
void satelliteLockChanged ();
void waypointDistanceChanged();
void currentWaypointChanged ();
void waypointsChanged ();
void missionItemsChanged ();
private slots:
void _mavlinkMessageReceived(LinkInterface* link, mavlink_message_t message);
......
This diff is collapsed.
......@@ -37,6 +37,8 @@ This file is part of the PIXHAWK project
#include <QString>
#include <QtQml>
#include <QTextStream>
#include <QGeoCoordinate>
#include "QGCMAVLink.h"
#include "QGC.h"
......@@ -65,6 +67,9 @@ public:
const Waypoint& operator=(const Waypoint& other);
Q_PROPERTY(QGeoCoordinate coordinate READ coordinate NOTIFY coordinateChanged)
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
Q_PROPERTY(double longitude READ longitude NOTIFY longitudeChanged)
Q_PROPERTY(double latitude READ latitude NOTIFY latitudeChanged)
Q_PROPERTY(double altitude READ altitude NOTIFY altitudeChanged)
......@@ -162,6 +167,8 @@ public:
void save(QTextStream &saveStream);
bool load(QTextStream &loadStream);
QGeoCoordinate coordinate(void);
QString type(void);
protected:
quint16 _id;
......@@ -227,7 +234,8 @@ signals:
void latitudeChanged ();
void longitudeChanged ();
void altitudeChanged ();
void coordinateChanged(void);
void typeChanged(QString type);
};
QML_DECLARE_TYPE(Waypoint)
......
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