Commit b159b443 authored by dogmaphobic's avatar dogmaphobic

Added MavManager QML Interface

Initial rendering of Waypoints
parent 9c058ce8
......@@ -356,6 +356,7 @@ HEADERS += \
src/ViewWidgets/CustomCommandWidgetController.h \
src/ViewWidgets/ViewWidgetController.h \
src/Waypoint.h \
src/QmlControls/QGCMavManager.h
!AndroidBuild {
HEADERS += \
......@@ -485,6 +486,7 @@ SOURCES += \
src/ViewWidgets/CustomCommandWidgetController.cc \
src/ViewWidgets/ViewWidgetController.cc \
src/Waypoint.cc \
src/QmlControls/QGCMavManager.cc
!AndroidBuild {
SOURCES += \
......
......@@ -118,6 +118,8 @@
<file alias="QGroundControl/FlightControls/QGCWaypointEditor.qml">src/ui/qmlcommon/QGCWaypointEditor.qml</file>
<file alias="QGroundControl/FlightControls/QGCMapToolButton.qml">src/ui/qmlcommon/QGCMapToolButton.qml</file>
<file alias="QGroundControl/FlightControls/QGCArtificialHorizon.qml">src/ui/qmlcommon/QGCArtificialHorizon.qml</file>
<!-- QML Map Resources -->
<file alias="QGroundControl/FlightControls/QGCWaypoint.qml">src/ui/qmlcommon/QGCWaypoint.qml</file>
<!-- QML Main UI Resources -->
<file alias="compass.svg">src/ui/qmlcommon/compass.svg</file>
<file alias="compassNeedle.svg">src/ui/qmlcommon/compassNeedle.svg</file>
......
......@@ -58,12 +58,14 @@
#include "QGCTemporaryFile.h"
#include "QGCFileDialog.h"
#include "QGCPalette.h"
#include "ScreenTools.h"
#include "QGCLoggingCategory.h"
#include "ViewWidgetController.h"
#include "ParameterEditorController.h"
#include "CustomCommandWidgetController.h"
#include "ScreenTools.h"
#include "QGCMavManager.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
#endif
......@@ -96,6 +98,18 @@ static QObject* screenToolsSingletonFactory(QQmlEngine*, QJSEngine*)
return screenTools;
}
/**
* @brief MavManager creation callback
*
* This is called by the QtQuick engine for creating the singleton
**/
static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*)
{
MavManager* mavManager = new MavManager;
return mavManager;
}
/**
* @brief Constructor for the main application.
*
......@@ -287,9 +301,11 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<ViewWidgetController>("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController>("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
qmlRegisterType<CustomCommandWidgetController>("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
//-- Create QML Singleton Interfaces
qmlRegisterSingletonType<ScreenTools>("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory);
qmlRegisterSingletonType<MavManager>("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory);
//-- Register Waypoint Interface
qmlRegisterInterface<Waypoint>("Waypoint");
}
bool QGCApplication::_initForNormalAppBoot(void)
......
This diff is collapsed.
This diff is collapsed.
......@@ -45,6 +45,10 @@ class ScreenTools : public QObject
public:
ScreenTools();
Q_PROPERTY(bool isAndroid READ isAndroid CONSTANT)
Q_PROPERTY(bool isiOS READ isiOS CONSTANT)
Q_PROPERTY(bool isMobile READ isMobile CONSTANT)
//! Returns the global mouse X position
Q_PROPERTY(int mouseX READ mouseX)
//! Returns the global mouse Y position
......@@ -110,6 +114,16 @@ public:
double pixelSizeFactor ();
double defaultFontPointSize(void);
#if defined (__android__)
bool isAndroid () { return true; }
bool isiOS () { return false; }
bool isMobile () { return true; }
#else
bool isAndroid () { return false; }
bool isiOS () { return false; }
bool isMobile () { return false; }
#endif
signals:
void repaintRequestedChanged();
void pixelSizeFactorChanged();
......
This diff is collapsed.
......@@ -35,6 +35,7 @@ This file is part of the PIXHAWK project
#include <QObject>
#include <QString>
#include <QtQml>
#include <QTextStream>
#include "QGCMAVLink.h"
#include "QGC.h"
......@@ -42,157 +43,192 @@ This file is part of the PIXHAWK project
class Waypoint : public QObject
{
Q_OBJECT
public:
Waypoint(quint16 id = 0, double x = 0.0, double y = 0.0, double z = 0.0, double param1 = 0.0, double param2 = 0.0, double param3 = 0.0, double param4 = 0.0,
bool autocontinue = true, bool current = false, MAV_FRAME frame=MAV_FRAME_GLOBAL, MAV_CMD action=MAV_CMD_NAV_WAYPOINT, const QString& description=QString(""));
Waypoint(
quint16 id = 0,
double x = 0.0,
double y = 0.0,
double z = 0.0,
double param1 = 0.0,
double param2 = 0.0,
double param3 = 0.0,
double param4 = 0.0,
bool autocontinue = true,
bool current = false,
int frame = MAV_FRAME_GLOBAL,
int action = MAV_CMD_NAV_WAYPOINT,
const QString& description=QString(""));
Waypoint(const Waypoint& other);
~Waypoint();
const Waypoint& operator=(const Waypoint& other);
Q_PROPERTY(double longitude READ longitude NOTIFY longitudeChanged)
Q_PROPERTY(double latitude READ latitude NOTIFY latitudeChanged)
Q_PROPERTY(double altitude READ altitude NOTIFY altitudeChanged)
Q_PROPERTY(quint16 id READ id CONSTANT)
double latitude() { return _x; }
double longitude() { return _y; }
double altitude() { return _z; }
quint16 id() { return _id; }
quint16 getId() const {
return id;
return _id;
}
double getX() const {
return x;
return _x;
}
double getY() const {
return y;
return _y;
}
double getZ() const {
return z;
return _z;
}
double getLatitude() const {
return x;
return _x;
}
double getLongitude() const {
return y;
return _y;
}
double getAltitude() const {
return z;
return _z;
}
double getYaw() const {
return yaw;
return _yaw;
}
bool getAutoContinue() const {
return autocontinue;
return _autocontinue;
}
bool getCurrent() const {
return current;
return _current;
}
double getLoiterOrbit() const {
return orbit;
return _orbit;
}
double getAcceptanceRadius() const {
return param2;
return _param2;
}
double getHoldTime() const {
return param1;
return _param1;
}
double getParam1() const {
return param1;
return _param1;
}
double getParam2() const {
return param2;
return _param2;
}
double getParam3() const {
return orbit;
return _orbit;
}
double getParam4() const {
return yaw;
return _yaw;
}
double getParam5() const {
return x;
return _x;
}
double getParam6() const {
return y;
return _y;
}
double getParam7() const {
return z;
return _z;
}
int getTurns() const {
return param1;
return _param1;
}
MAV_FRAME getFrame() const {
return frame;
// MAV_FRAME
int getFrame() const {
return _frame;
}
MAV_CMD getAction() const {
return action;
// MAV_CMD
int getAction() const {
return _action;
}
const QString& getName() const {
return name;
return _name;
}
const QString& getDescription() const {
return description;
return _description;
}
/** @brief Returns true if x, y, z contain reasonable navigation data */
bool isNavigationType();
/** @brief Get the time this waypoint was reached */
quint64 getReachedTime() const { return _reachedTime; }
void save(QTextStream &saveStream);
bool load(QTextStream &loadStream);
protected:
quint16 id;
double x;
double y;
double z;
double yaw;
MAV_FRAME frame;
MAV_CMD action;
bool autocontinue;
bool current;
double orbit;
double param1;
double param2;
int turns;
QString name;
QString description;
quint64 reachedTime;
public slots:
void setId(quint16 id);
void setX(double x);
void setY(double y);
void setZ(double z);
void setLatitude(double lat);
void setLongitude(double lon);
void setAltitude(double alt);
quint16 _id;
double _x;
double _y;
double _z;
double _yaw;
int _frame;
int _action;
bool _autocontinue;
bool _current;
double _orbit;
double _param1;
double _param2;
int _turns;
QString _name;
QString _description;
quint64 _reachedTime;
public:
void setId (quint16 _id);
void setX (double _x);
void setY (double _y);
void setZ (double _z);
void setLatitude (double lat);
void setLongitude (double lon);
void setAltitude (double alt);
/** @brief Yaw angle in COMPASS DEGREES: 0-360 */
void setYaw(int yaw);
void setYaw (int _yaw);
/** @brief Yaw angle in COMPASS DEGREES: 0-360 */
void setYaw(double yaw);
void setYaw (double _yaw);
/** @brief Set the waypoint action */
void setAction(int action);
void setAction(MAV_CMD action);
void setFrame(MAV_FRAME frame);
void setAction (int _action);
void setFrame (int _frame);
void setAutocontinue(bool autoContinue);
void setCurrent(bool current);
void setLoiterOrbit(double orbit);
void setParam1(double param1);
void setParam2(double param2);
void setParam3(double param3);
void setParam4(double param4);
void setParam5(double param5);
void setParam6(double param6);
void setParam7(double param7);
void setCurrent (bool _current);
void setLoiterOrbit (double _orbit);
void setParam1 (double _param1);
void setParam2 (double _param2);
void setParam3 (double param3);
void setParam4 (double param4);
void setParam5 (double param5);
void setParam6 (double param6);
void setParam7 (double param7);
void setAcceptanceRadius(double radius);
void setHoldTime(int holdTime);
void setHoldTime(double holdTime);
void setHoldTime (int holdTime);
void setHoldTime (double holdTime);
/** @brief Number of turns for loiter waypoints */
void setTurns(int turns);
void setTurns (int _turns);
/** @brief Set waypoint as reached */
void setReached() { reachedTime = QGC::groundTimeMilliseconds(); }
void setReached () { _reachedTime = QGC::groundTimeMilliseconds(); }
/** @brief Wether this waypoint has been reached yet */
bool isReached() { return (reachedTime > 0); }
/** @brief Get the time this waypoint was reached */
quint64 getReachedTime() { return reachedTime; }
bool isReached () { return (_reachedTime > 0); }
void setChanged() {
emit changed(this);
}
signals:
/** @brief Announces a change to the waypoint data */
void changed(Waypoint* wp);
void changed(Waypoint* wp);
void latitudeChanged ();
void longitudeChanged ();
void altitudeChanged ();
};
QML_DECLARE_TYPE(Waypoint)
#endif // WAYPOINT_H
......@@ -417,14 +417,14 @@ void WaypointEditableView::updateValues()
// update frame
MAV_FRAME frame = wp->getFrame();
MAV_FRAME frame = (MAV_FRAME)wp->getFrame();
int frame_index = m_ui->comboBox_frame->findData(frame);
if (m_ui->comboBox_frame->currentIndex() != frame_index) {
m_ui->comboBox_frame->setCurrentIndex(frame_index);
}
// Update action
MAV_CMD action = wp->getAction();
MAV_CMD action = (MAV_CMD)wp->getAction();
int action_index = m_ui->comboBox_action->findData(action);
if (m_ui->comboBox_action->currentIndex() != action_index)
{
......@@ -441,7 +441,7 @@ void WaypointEditableView::updateValues()
}
emit commandBroadcast(wp->getAction());
emit frameBroadcast(wp->getFrame());
emit frameBroadcast((MAV_FRAME)wp->getFrame());
emit param1Broadcast(wp->getParam1());
emit param2Broadcast(wp->getParam2());
emit param3Broadcast(wp->getParam3());
......
This diff is collapsed.
This diff is collapsed.
......@@ -41,120 +41,15 @@ public:
QGCFlightDisplay(QWidget* parent = NULL);
~QGCFlightDisplay();
enum {
ROLL_CHANGED,
PITCH_CHANGED,
HEADING_CHANGED,
GROUNDSPEED_CHANGED,
AIRSPEED_CHANGED,
CLIMBRATE_CHANGED,
ALTITUDERELATIVE_CHANGED,
ALTITUDEWGS84_CHANGED,
ALTITUDEAMSL_CHANGED
};
/// @brief Invokes the Flight Display Options menu
void showOptionsMenu() { emit showOptionsMenuChanged(); }
Q_PROPERTY(float roll READ roll NOTIFY rollChanged)
Q_PROPERTY(float pitch READ pitch NOTIFY pitchChanged)
Q_PROPERTY(float heading READ heading NOTIFY headingChanged)
Q_PROPERTY(float groundSpeed READ groundSpeed NOTIFY groundSpeedChanged)
Q_PROPERTY(float airSpeed READ airSpeed NOTIFY airSpeedChanged)
Q_PROPERTY(float climbRate READ climbRate NOTIFY climbRateChanged)
Q_PROPERTY(float altitudeRelative READ altitudeRelative NOTIFY altitudeRelativeChanged)
Q_PROPERTY(float altitudeWGS84 READ altitudeWGS84 NOTIFY altitudeWGS84Changed)
Q_PROPERTY(float altitudeAMSL READ altitudeAMSL NOTIFY altitudeAMSLChanged)
Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged)
Q_PROPERTY(float latitude READ latitude NOTIFY latitudeChanged)
Q_PROPERTY(float longitude READ longitude NOTIFY longitudeChanged)
Q_PROPERTY(bool mavPresent READ mavPresent NOTIFY mavPresentChanged)
Q_INVOKABLE void saveSetting (const QString &key, const QString& value);
Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue);
float roll () { return _roll; }
float pitch () { return _pitch; }
float heading () { return _heading; }
float groundSpeed () { return _groundSpeed; }
float airSpeed () { return _airSpeed; }
float climbRate () { return _climbRate; }
float altitudeRelative () { return _altitudeRelative; }
float altitudeWGS84 () { return _altitudeWGS84; }
float altitudeAMSL () { return _altitudeAMSL; }
float latitude () { return _latitude; }
float longitude () { return _longitude; }
bool repaintRequested () { return true; }
bool mavPresent () { return _mav != NULL; }
/** @brief Start updating widget */
void showEvent(QShowEvent* event);
/** @brief Stop updating widget */
void hideEvent(QHideEvent* event);
signals:
void rollChanged ();
void pitchChanged ();
void headingChanged ();
void groundSpeedChanged ();
void airSpeedChanged ();
void climbRateChanged ();
void altitudeRelativeChanged();
void altitudeWGS84Changed ();
void altitudeAMSLChanged ();
void repaintRequestedChanged();
void latitudeChanged ();
void longitudeChanged ();
void mavPresentChanged ();
void showOptionsMenuChanged ();
private slots:
/** @brief Attitude from main autopilot / system state */
void _updateAttitude (UASInterface* uas, double roll, double pitch, double yaw, quint64 timestamp);
/** @brief Attitude from one specific component / redundant autopilot */
void _updateAttitude (UASInterface* uas, int component, double roll, double pitch, double yaw, quint64 timestamp);
/** @brief Speed */
void _updateSpeed (UASInterface* uas, double _groundSpeed, double _airSpeed, quint64 timestamp);
/** @brief Altitude */
void _updateAltitude (UASInterface* uas, double _altitudeAMSL, double _altitudeWGS84, double _altitudeRelative, double _climbRate, quint64 timestamp);
void _updateNavigationControllerErrors (UASInterface* uas, double altitudeError, double speedError, double xtrackError);
void _updateNavigationControllerData (UASInterface *uas, float navRoll, float navPitch, float navBearing, float targetBearing, float targetDistance);
void _forgetUAS (UASInterface* uas);
void _setActiveUAS (UASInterface* uas);
void _checkUpdate ();
private:
bool _isAirplane ();
bool _shouldDisplayNavigationData ();
void _addChange (int id);
float _oneDecimal (float value);
private:
UASInterface* _mav;
float _roll;
float _pitch;
float _heading;
float _altitudeAMSL;
float _altitudeWGS84;
float _altitudeRelative;
float _groundSpeed;
float _airSpeed;
float _climbRate;
float _navigationAltitudeError;
float _navigationSpeedError;
float _navigationCrosstrackError;
float _navigationTargetBearing;
float _latitude;
float _longitude;
QTimer* _refreshTimer;
QList<int> _changes;
};
#endif // QGCFLIGHTDISPLAY_H
......@@ -45,56 +45,6 @@ Rectangle {
property real pitch: isNaN(mapEngine.pitch) ? 0 : mapEngine.pitch
property bool showWaypointEditor: true
function getBool(value) {
return value === '0' ? false : true;
}
function setBool(value) {
return value ? "1" : "0";
}
Component.onCompleted:
{
mapTypeMenu.update();
}
Menu {
id: mapTypeMenu
title: "Map Type..."
ExclusiveGroup { id: currentMapType }
function setCurrentMap(map) {
for (var i = 0; i < mapBackground.mapItem.supportedMapTypes.length; i++) {
if (map === mapBackground.mapItem.supportedMapTypes[i].name) {
mapBackground.mapItem.activeMapType = mapBackground.mapItem.supportedMapTypes[i]
mapEngine.saveSetting("currentMapType", map);
return;
}
}
}
function addMap(map, checked) {
var mItem = mapTypeMenu.addItem(map);
mItem.checkable = true
mItem.checked = checked
mItem.exclusiveGroup = currentMapType
var menuSlot = function() {setCurrentMap(map);};
mItem.triggered.connect(menuSlot);
}
function update() {
clear()
var map = ''
if (mapBackground.mapItem.supportedMapTypes.length > 0)
map = mapBackground.mapItem.activeMapType.name;
map = mapEngine.loadSetting("currentMapType", map);
for (var i = 0; i < mapBackground.mapItem.supportedMapTypes.length; i++) {
var name = mapBackground.mapItem.supportedMapTypes[i].name;
addMap(name, map === name);
}
if(map != '')
setCurrentMap(map);
}
}
SplitView {
id: splitView
anchors.fill: parent
......@@ -117,6 +67,9 @@ Rectangle {
heading: isNaN(mapEngine.heading) ? 0 : mapEngine.heading
latitude: 37.803784 // mapEngine.latitude
longitude: -122.462276 // mapEngine.longitude
showWaypoints: true
mapName: 'MainMapDisplay'
// Chevron button at upper right corner of Map Display
Item {
id: openWaypoints
......@@ -164,7 +117,7 @@ Rectangle {
onClicked: {
if (mouse.button == Qt.RightButton)
{
mapTypeMenu.popup()
mapBackground.mapMenu.popup()
}
}
z: splitView.z + 5
......
......@@ -28,25 +28,73 @@ This file is part of the QGROUNDCONTROL project
*/
import QtQuick 2.4
import QtPositioning 5.3
import QtQuick.Controls 1.3
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl.Controls 1.0
import QGroundControl.FlightControls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.MavManager 1.0
Item {
id: root
clip: true
Rectangle {
id: root
property real latitude: 37.803784
property real longitude : -122.462276
property real zoomLevel: 18
property real heading: 0
property bool alwaysNorth: true
property bool interactive: true
property alias mapItem: map
property real latitude: 0
property real longitude: 0
property real zoomLevel: 18
property real heading: 0
property bool alwaysNorth: true
property bool interactive: true
property bool showWaypoints: false
property string mapName: 'defaultMap'
property alias mapItem: map
property alias waypoints: polyLine
property alias mapMenu: mapTypeMenu
Component.onCompleted: {
map.zoomLevel = 18
map.markers = []
mapTypeMenu.update();
}
color: Qt.rgba(0,0,0,0)
clip: true
//-- Menu to select supported map types
Menu {
id: mapTypeMenu
title: "Map Type..."
ExclusiveGroup { id: currMapType }
function setCurrentMap(mapID) {
for (var i = 0; i < map.supportedMapTypes.length; i++) {
if (mapID === map.supportedMapTypes[i].name) {
map.activeMapType = map.supportedMapTypes[i]
MavManager.saveSetting(root.mapName + "/currentMapType", mapID);
return;
}
}
}
function addMap(mapID, checked) {
var mItem = mapTypeMenu.addItem(mapID);
mItem.checkable = true
mItem.checked = checked
mItem.exclusiveGroup = currMapType
var menuSlot = function() {setCurrentMap(mapID);};
mItem.triggered.connect(menuSlot);
}
function update() {
clear()
var mapID = ''
if (map.supportedMapTypes.length > 0)
mapID = map.activeMapType.name;
mapID = MavManager.loadSetting(root.mapName + "/currentMapType", mapID);
for (var i = 0; i < map.supportedMapTypes.length; i++) {
var name = map.supportedMapTypes[i].name;
addMap(name, mapID === name);
}
if(mapID != '')
setCurrentMap(mapID);
}
}
function adjustSize() {
if(root.visible) {
......@@ -83,34 +131,65 @@ Rectangle {
return dist
}
function updateWaypoints() {
polyLine.path = []
// Are we initialized?
if (typeof map.markers != 'undefined' && typeof root.longitude != 'undefined') {
map.deleteMarkers()
if(root.showWaypoints) {
for(var i = 0; i < MavManager.waypoints.length; i++) {
var coord = QtPositioning.coordinate(MavManager.waypoints[i].latitude, MavManager.waypoints[i].longitude, MavManager.waypoints[i].altitude);
polyLine.addCoordinate(coord);
map.addMarker(coord, MavManager.waypoints[i].id);
}
root.longitude = MavManager.waypoints[0].longitude
root.latitude = MavManager.waypoints[0].latitude
}
}
}
Plugin {
id: mapPlugin
name: "QGroundControl"
}
Connections {
target: MavManager
onWaypointsChanged: {
root.updateWaypoints();
}
}
onShowWaypointsChanged: {
root.updateWaypoints();
}
Map {
id: map
property real lon: (longitude >= -180 && longitude <= 180) ? longitude : 0
property real lat: (latitude >= -90 && latitude <= 90) ? latitude : 0
property variant scaleLengths: [5, 10, 25, 50, 100, 150, 250, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000]
property variant markers
plugin: mapPlugin
width: 1
height: 1
zoomLevel: root.zoomLevel
anchors.centerIn: parent
center: QtPositioning.coordinate(lat, lon)
gesture.flickDeceleration: 3000
gesture.enabled: root.interactive
/*
// There is a bug currently in Qt where it fails to render a map taller than 6 tiles high. Until
// that's fixed, we can't rotate the map as it would require a larger map, which can easely grow
// larger than 6 tiles high.
// https://bugreports.qt.io/browse/QTBUG-45508
transform: Rotation {
origin.x: map.width / 2
origin.y: map.height / 2
angle: map.visible ? (alwaysNorth ? 0 : -heading) : 0
}
*/
gesture.flickDeceleration: 3000
gesture.enabled: root.interactive
onWidthChanged: {
scaleTimer.restart()
......@@ -124,8 +203,32 @@ Rectangle {
scaleTimer.restart()
}
Component.onCompleted: {
map.zoomLevel = 18
function addMarker(coord, wpid)
{
var marker = Qt.createQmlObject ('QGCWaypoint {}', map)
map.addMapItem(marker)
marker.z = map.z + 1
marker.coordinate = coord
marker.waypointID.text = wpid
// Update list of markers
var count = map.markers.length
var myArray = []
for (var i = 0; i < count; i++){
myArray.push(markers[i])
}
myArray.push(marker)
markers = myArray
}
function deleteMarkers()
{
if (typeof map.markers != 'undefined') {
var count = map.markers.length
for (var i = 0; i < count; i++) {
map.markers[i].destroy()
}
}
map.markers = []
}
function calculateScale() {
......@@ -153,6 +256,15 @@ Rectangle {
scaleImage.width = (scaleImage.sourceSize.width * f) - 2 * scaleImageLeft.sourceSize.width
scaleText.text = text
}
MapPolyline {
id: polyLine
visible: path.length > 1 && root.showWaypoints
line.width: 3
line.color: "#e35cd8"
smooth: true
antialiasing: true
}
}
QGCSlider {
......@@ -161,7 +273,7 @@ Rectangle {
maximum: map.maximumZoomLevel;
opacity: 1
visible: parent.visible
z: map.z + 20
z: 1000
anchors {
bottom: parent.bottom;
bottomMargin: ScreenTools.pixelSizeFactor * (15)
......
/*=====================================================================
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/>.
======================================================================*/
/**
* @file
* @brief QGC Waypoint Marker
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.4
import QtLocation 5.3
MapQuickItem {
id: marker
property alias waypointID: number
anchorPoint.x: image.width / 2
anchorPoint.y: image.height / 2
sourceItem: Rectangle {
id: image
width: 24
height: 24
border.color: Qt.rgba(0,0,0,0.75)
color: Qt.rgba(0,0,0,0.5)
Text {
id: number
anchors.centerIn: parent
font.pointSize: 10
color: "white"
}
}
}
......@@ -14,3 +14,4 @@ QGCMapToolButton 1.0 QGCMapToolButton.qml
QGCAttitudeInstrument 1.0 QGCAttitudeInstrument.qml
QGCCompassInstrument 1.0 QGCCompassInstrument.qml
QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml
QGCWaypoint 1.0 QGCWaypoint.qml
This diff is collapsed.
......@@ -37,7 +37,7 @@ This file is part of the QGROUNDCONTROL project
#define TOOL_BAR_SHOW_GPS "ShowGPS"
#define TOOL_BAR_SHOW_MAV "ShowMav"
#define TOOL_BAR_SHOW_MESSAGES "ShowMessages"
#define TOOL_BAR_SHOW_RSSI "ShowRSSI"
#define TOOL_BAR_SHOW_RSSI "ShowRSSI"
class UASInterface;
class UASMessage;
......@@ -52,6 +52,13 @@ public:
MainToolBar(QWidget* parent = NULL);
~MainToolBar();
typedef enum {
MessageNone,
MessageNormal,
MessageWarning,
MessageError
} MessageType_t;
typedef enum {
ViewNone = -1,
ViewAnalyze, // MainWindow::VIEW_ENGINEER
......@@ -60,13 +67,6 @@ public:
ViewSetup , // MainWindow::VIEW_SETUP
} ViewType_t;
typedef enum {
MessageNone,
MessageNormal,
MessageWarning,
MessageError
} MessageType_t;
Q_INVOKABLE void onSetupView();
Q_INVOKABLE void onPlanView();
Q_INVOKABLE void onFlyView();
......@@ -75,25 +75,14 @@ public:
Q_INVOKABLE void onConnect(QString conf);
Q_INVOKABLE void onDisconnect(QString conf);
Q_INVOKABLE void onEnterMessageArea(int x, int y);
Q_INVOKABLE QString getMavIconColor();
Q_PROPERTY(int connectionCount MEMBER _connectionCount NOTIFY connectionCountChanged)
Q_PROPERTY(double batteryVoltage MEMBER _batteryVoltage NOTIFY batteryVoltageChanged)
Q_PROPERTY(double batteryPercent MEMBER _batteryPercent NOTIFY batteryPercentChanged)
Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged)
Q_PROPERTY(QStringList configList MEMBER _linkConfigurations NOTIFY configListChanged)
Q_PROPERTY(bool systemArmed MEMBER _systemArmed NOTIFY systemArmedChanged)
Q_PROPERTY(unsigned int heartbeatTimeout MEMBER _currentHeartbeatTimeout NOTIFY heartbeatTimeoutChanged)
Q_PROPERTY(QString currentMode MEMBER _currentMode NOTIFY currentModeChanged)
Q_PROPERTY(MessageType_t messageType MEMBER _currentMessageType NOTIFY messageTypeChanged)
Q_PROPERTY(int newMessageCount MEMBER _currentMessageCount NOTIFY newMessageCountChanged)
Q_PROPERTY(int messageCount MEMBER _messageCount NOTIFY messageCountChanged)
Q_PROPERTY(QString systemPixmap MEMBER _systemPixmap NOTIFY systemPixmapChanged)
Q_PROPERTY(int satelliteCount READ satelliteCount NOTIFY satelliteCountChanged)
Q_PROPERTY(int connectionCount READ connectionCount NOTIFY connectionCountChanged)
Q_PROPERTY(QStringList connectedList MEMBER _connectedList NOTIFY connectedListChanged)
Q_PROPERTY(bool mavPresent READ mavPresent NOTIFY mavPresentChanged)
Q_PROPERTY(QString currentState MEMBER _currentState NOTIFY currentStateChanged)
Q_PROPERTY(int satelliteLock MEMBER _satelliteLock NOTIFY satelliteLockChanged)
Q_PROPERTY(bool showGPS MEMBER _showGPS NOTIFY showGPSChanged)
Q_PROPERTY(bool showMav MEMBER _showMav NOTIFY showMavChanged)
Q_PROPERTY(bool showMessages MEMBER _showMessages NOTIFY showMessagesChanged)
......@@ -103,48 +92,22 @@ public:
Q_PROPERTY(int remoteRSSI READ remoteRSSI NOTIFY remoteRSSIChanged)
Q_PROPERTY(int telemetryRRSSI READ telemetryRRSSI NOTIFY telemetryRRSSIChanged)
Q_PROPERTY(int telemetryLRSSI READ telemetryLRSSI NOTIFY telemetryLRSSIChanged)
Q_PROPERTY(bool isAndroid READ isAndroid CONSTANT)
Q_PROPERTY(bool isiOS READ isiOS CONSTANT)
Q_PROPERTY(bool isMobile READ isMobile CONSTANT)
bool mavPresent () { return _mav != NULL; }
int satelliteCount () { return _satelliteCount; }
void setCurrentView (int currentView);
void viewStateChanged (const QString& key, bool value);
int remoteRSSI () { return _remoteRSSI; }
int telemetryRRSSI () { return _telemetryRRSSI; }
int telemetryLRSSI () { return _telemetryLRSSI; }
#if defined (__android__)
bool isAndroid () { return true; }
bool isiOS () { return false; }
bool isMobile () { return true; }
#else
bool isAndroid () { return false; }
bool isiOS () { return false; }
bool isMobile () { return false; }
#endif
void setCurrentView (int currentView);
void viewStateChanged (const QString& key, bool value);
int connectionCount () { return _connectionCount; }
signals:
void connectionCountChanged (int count);
void batteryVoltageChanged (double value);
void batteryPercentChanged (double value);
void currentViewChanged ();
void configListChanged ();
void systemArmedChanged (bool systemArmed);
void heartbeatTimeoutChanged (unsigned int hbTimeout);
void currentModeChanged ();
void messageTypeChanged (MessageType_t type);
void newMessageCountChanged (int count);
void messageCountChanged (int count);
void currentConfigChanged (QString config);
void systemPixmapChanged (QPixmap pix);
void satelliteCountChanged (int count);
void connectedListChanged (QStringList connectedList);
void mavPresentChanged (bool present);
void currentStateChanged (QString state);
void satelliteLockChanged (int lock);
void showGPSChanged (bool value);
void showMavChanged (bool value);
void showMessagesChanged (bool value);
......@@ -156,27 +119,17 @@ signals:
void telemetryLRSSIChanged (int value);
private slots:
void _setActiveUAS (UASInterface* active);
void _updateBatteryRemaining (UASInterface*, double voltage, double, double percent, int);
void _updateArmingState (bool armed);
void _forgetUAS (UASInterface* uas);
void _setActiveUAS (UASInterface* uas);
void _updateConfigurations ();
void _linkConnected (LinkInterface* link);
void _linkDisconnected (LinkInterface* link);
void _updateState (UASInterface* system, QString name, QString description);
void _updateMode (int system, QString name, QString description);
void _updateName (const QString& name);
void _setSystemType (UASInterface* uas, unsigned int systemType);
void _heartbeatTimeout (bool timeout, unsigned int ms);
void _handleTextMessage (int newCount);
void _updateCurrentWaypoint (quint16 id);
void _updateWaypointDistance (double distance);
void _setSatelliteCount (double val, QString name);
void _leaveMessageView ();
void _setSatLoc (UASInterface* uas, int fix);
void _setProgressBarValue (float value);
void _updatePixelSize ();
void _remoteControlRSSIChanged (uint8_t rssi);
void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise);
void _updatePixelSize ();
private:
void _updateConnection (LinkInterface *disconnectedLink = NULL);
......@@ -186,27 +139,15 @@ private:
UASInterface* _mav;
QQuickItem* _toolBar;
ViewType_t _currentView;
double _batteryVoltage;
double _batteryPercent;
QStringList _linkConfigurations;
int _connectionCount;
bool _systemArmed;
QString _currentState;
QString _currentMode;
QString _systemName;
QString _systemPixmap;
unsigned int _currentHeartbeatTimeout;
double _waypointDistance;
quint16 _currentWaypoint;
int _currentMessageCount;
int _messageCount;
int _currentErrorCount;
int _currentWarningCount;
int _currentNormalCount;
MessageType_t _currentMessageType;
int _satelliteCount;
QStringList _connectedList;
int _satelliteLock;
bool _showGPS;
bool _showMav;
bool _showMessages;
......
......@@ -35,6 +35,7 @@ import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.MainToolBar 1.0
import QGroundControl.MavManager 1.0
import QGroundControl.ScreenTools 1.0
Rectangle {
......@@ -42,7 +43,7 @@ Rectangle {
property var qgcPal: QGCPalette { id: palette; colorGroupEnabled: true }
property int cellSpacerSize: mainToolBar.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4)
property int cellSpacerSize: ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4)
property int cellHeight: getProportionalDimmension(30)
property var colorBlue: "#1a6eaa"
......@@ -83,24 +84,24 @@ Rectangle {
}
function getBatteryIcon() {
if(mainToolBar.batteryPercent < 20.0)
if(MavManager.batteryPercent < 20.0)
return "qrc:/res/Battery_0";
else if(mainToolBar.batteryPercent < 40.0)
else if(MavManager.batteryPercent < 40.0)
return "qrc:/res/Battery_20";
else if(mainToolBar.batteryPercent < 60.0)
else if(MavManager.batteryPercent < 60.0)
return "qrc:/res/Battery_40";
else if(mainToolBar.batteryPercent < 80.0)
else if(MavManager.batteryPercent < 80.0)
return "qrc:/res/Battery_60";
else if(mainToolBar.batteryPercent < 90.0)
else if(MavManager.batteryPercent < 90.0)
return "qrc:/res/Battery_80";
else
return "qrc:/res/Battery_100";
}
function getBatteryColor() {
if (mainToolBar.batteryPercent > 40.0)
if (MavManager.batteryPercent > 40.0)
return colorGreen;
if(mainToolBar.batteryPercent > 0.01)
if(MavManager.batteryPercent > 0.01)
return colorRed;
// This means there is no battery level data
return colorBlue;
......@@ -108,13 +109,13 @@ Rectangle {
function getSatelliteColor() {
// No GPS data
if (mainToolBar.satelliteCount < 0)
if (MavManager.satelliteCount < 0)
return qgcPal.button
// No Lock
if(mainToolBar.satelliteLock < 2)
if(MavManager.satelliteLock < 2)
return colorRed;
// 2D Lock
if(mainToolBar.satelliteLock === 2)
if(MavManager.satelliteLock === 2)
return colorBlue;
// Lock is 3D or more
return colorGreen;
......@@ -129,7 +130,7 @@ Rectangle {
}
function showMavStatus() {
return (mainToolBar.mavPresent && mainToolBar.heartbeatTimeout === 0 && mainToolBar.connectionCount > 0);
return (MavManager.mavPresent && MavManager.heartbeatTimeout === 0 && mainToolBar.connectionCount > 0);
}
//-------------------------------------------------------------------------
......@@ -193,7 +194,7 @@ Rectangle {
height: cellHeight
spacing: -getProportionalDimmension(12)
anchors.verticalCenter: parent.verticalCenter
visible: !mainToolBar.isMobile
visible: !ScreenTools.isMobile
Connections {
target: ScreenTools
onRepaintRequestedChanged: {
......@@ -275,7 +276,7 @@ Rectangle {
//-- "Hamburger" menu for Mobile Devices
Item {
id: actionButton
visible: mainToolBar.isMobile
visible: ScreenTools.isMobile
height: cellHeight
width: cellHeight
Image {
......@@ -391,7 +392,7 @@ Rectangle {
border.color: "#00000000"
border.width: 0
Image {
source: mainToolBar.systemPixmap
source: MavManager.systemPixmap
height: cellHeight * 0.75
fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
......@@ -422,8 +423,8 @@ Rectangle {
QGCLabel {
id: satelitteText
text: mainToolBar.satelliteCount >= 0 ? mainToolBar.satelliteCount : 'NA'
font.pointSize: mainToolBar.satelliteCount >= 0 ? ScreenTools.fontPointFactor * (14) : ScreenTools.fontPointFactor * (10)
text: MavManager.satelliteCount >= 0 ? MavManager.satelliteCount : 'NA'
font.pointSize: MavManager.satelliteCount >= 0 ? ScreenTools.fontPointFactor * (14) : ScreenTools.fontPointFactor * (10)
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
......@@ -547,7 +548,7 @@ Rectangle {
QGCLabel {
id: batteryText
text: mainToolBar.batteryVoltage.toFixed(1) + 'V';
text: MavManager.batteryVoltage.toFixed(1) + 'V';
font.pointSize: ScreenTools.fontPointFactor * (11);
font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter
......@@ -575,11 +576,11 @@ Rectangle {
QGCLabel {
id: armedStatusText
text: (mainToolBar.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED")
text: (MavManager.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED")
font.pointSize: ScreenTools.fontPointFactor * (12);
font.weight: Font.DemiBold
anchors.centerIn: parent
color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText
color: (MavManager.systemArmed) ? colorOrangeText : colorGreenText
}
}
......@@ -594,11 +595,11 @@ Rectangle {
QGCLabel {
id: stateStatusText
text: mainToolBar.currentState
text: MavManager.currentState
font.pointSize: ScreenTools.fontPointFactor * (12);
font.weight: Font.DemiBold
anchors.centerIn: parent
color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText
color: (MavManager.currentState === "STANDBY") ? colorGreenText : colorRedText
}
}
......@@ -615,7 +616,7 @@ Rectangle {
QGCLabel {
id: modeStatusText
text: mainToolBar.currentMode
text: MavManager.currentMode
font.pointSize: ScreenTools.fontPointFactor * (12);
font.weight: Font.DemiBold
anchors.horizontalCenter: parent.horizontalCenter
......@@ -628,7 +629,7 @@ Rectangle {
id: connectionStatus
width: getProportionalDimmension(160)
height: cellHeight
visible: (mainToolBar.connectionCount > 0 && mainToolBar.mavPresent && mainToolBar.heartbeatTimeout != 0)
visible: (mainToolBar.connectionCount > 0 && MavManager.mavPresent && MavManager.heartbeatTimeout != 0)
anchors.verticalCenter: parent.verticalCenter
color: "#00000000"
border.color: "#00000000"
......
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