Commit 724a0c8c authored by Don Gagne's avatar Don Gagne

All MavManager functionality now in Vehicle

- Moved all MavManager functionality to Vehicle
- Updated all code to use Vehicle instead of MavManager
- Removed MavManager
parent 5a18381d
......@@ -256,7 +256,6 @@ HEADERS += \
src/QGCQuickWidget.h \
src/QGCSingleton.h \
src/QGCTemporaryFile.h \
src/QmlControls/MavManager.h \
src/QmlControls/ParameterEditorController.h \
src/QmlControls/ScreenToolsController.h \
src/SerialPortIds.h \
......@@ -389,7 +388,6 @@ SOURCES += \
src/QGCQuickWidget.cc \
src/QGCSingleton.cc \
src/QGCTemporaryFile.cc \
src/QmlControls/MavManager.cc \
src/QmlControls/ParameterEditorController.cc \
src/QmlControls/ScreenToolsController.cc \
src/uas/FileManager.cc \
......
......@@ -132,7 +132,6 @@
<file alias="QGroundControl/FlightMap/QGCCompassHUD.qml">src/FlightMap/Widgets/QGCCompassHUD.qml</file>
<file alias="QGroundControl/FlightMap/QGCCurrentAltitude.qml">src/FlightMap/Widgets/QGCCurrentAltitude.qml</file>
<file alias="QGroundControl/FlightMap/QGCCurrentSpeed.qml">src/FlightMap/Widgets/QGCCurrentSpeed.qml</file>
<file alias="QGroundControl/FlightMap/QGCHudMessage.qml">src/FlightMap/Widgets/QGCHudMessage.qml</file>
<file alias="QGroundControl/FlightMap/QGCMapToolButton.qml">src/FlightMap/Widgets/QGCMapToolButton.qml</file>
<file alias="QGroundControl/FlightMap/QGCPitchIndicator.qml">src/FlightMap/Widgets/QGCPitchIndicator.qml</file>
<file alias="QGroundControl/FlightMap/QGCSlider.qml">src/FlightMap/Widgets/QGCSlider.qml</file>
......
......@@ -35,7 +35,6 @@ import QtPositioning 5.3
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.MavManager 1.0
import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.Vehicle 1.0
......@@ -50,16 +49,13 @@ Item {
property bool alwaysNorth: true
property bool interactive: true
property bool showVehicles: true
property bool showWaypoints: false
property string mapName: 'defaultMap'
property alias mapItem: map
property alias waypoints: polyLine
property alias mapMenu: mapTypeMenu
property alias readOnly: map.readOnly
Component.onCompleted: {
map.zoomLevel = 18
map.markers = []
mapTypeMenu.update();
if (showVehicles) {
addExistingVehicles()
......@@ -76,7 +72,7 @@ Item {
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);
multiVehicleManager.saveSetting(root.mapName + "/currentMapType", mapID);
return;
}
}
......@@ -94,7 +90,7 @@ Item {
var mapID = ''
if (map.supportedMapTypes.length > 0)
mapID = map.activeMapType.name;
mapID = MavManager.loadSetting(root.mapName + "/currentMapType", mapID);
mapID = multiVehicleManager.loadSetting(root.mapName + "/currentMapType", mapID);
for (var i = 0; i < map.supportedMapTypes.length; i++) {
var name = map.supportedMapTypes[i].name;
addMap(name, mapID === name);
......@@ -139,26 +135,6 @@ Item {
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);
}
if (typeof MavManager.waypoints != 'undefined' && MavManager.waypoints.length > 0) {
root.longitude = MavManager.waypoints[0].longitude
root.latitude = MavManager.waypoints[0].latitude
}
map.changed = false
}
}
}
property var vehicles: [] ///< List of known vehicles
property var vehicleMapItems: [] ///< List of know vehicle map items
......@@ -202,13 +178,6 @@ Item {
name: "QGroundControl"
}
Connections {
target: MavManager
onWaypointsChanged: {
root.updateWaypoints();
}
}
Connections {
target: multiVehicleManager
......@@ -216,10 +185,6 @@ Item {
onVehicleRemoved: removeVehicle(vehicle)
}
onShowWaypointsChanged: {
root.updateWaypoints();
}
Map {
id: map
......@@ -231,7 +196,6 @@ Item {
property bool changed: false
property bool readOnly: false
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
......@@ -276,44 +240,6 @@ Item {
}
}
function updateMarker(coord, wpid)
{
if(wpid < polyLine.path.length) {
var tmpPath = polyLine.path;
tmpPath[wpid] = coord;
polyLine.path = tmpPath;
map.changed = true;
}
}
function addMarker(coord, wpid)
{
var marker = Qt.createQmlObject ('QGCWaypoint {}', map)
map.addMapItem(marker)
marker.z = map.z + 1
marker.coordinate = coord
marker.waypointID = 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() {
var coord1, coord2, dist, text, f
f = 0
......@@ -339,15 +265,6 @@ Item {
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: map.changed ? "#f97a2e" : "#e35cd8"
smooth: true
antialiasing: true
}
}
QGCSlider {
......
/*=====================================================================
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 HUD Message
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.4
import QtQuick.Controls 1.3
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.MavManager 1.0
Item {
id: root
visible: MavManager.latestError !== ''
Rectangle {
anchors.fill: parent
color: Qt.rgba(0,0,0,0.75)
border.color: Qt.rgba(1,1,1,0.75)
radius: 4
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
font.weight: Font.DemiBold
text: MavManager.latestError
color: "#f84444"
}
OpacityAnimator {
id: vanish
target: root;
from: 1;
to: 0;
duration: 2000
running: false
}
}
Timer {
id: vanishTimer
interval: 30000
running: false
repeat: false
onTriggered: {
vanish.start();
}
}
MouseArea {
anchors.fill: parent
z: 1000
acceptedButtons: Qt.LeftButton
onClicked: {
if (mouse.button == Qt.LeftButton)
{
vanishTimer.stop();
vanish.stop();
root.opacity = 0;
}
}
}
Connections {
target: MavManager
onLatestErrorChanged: {
vanishTimer.stop();
vanish.stop();
vanishTimer.start();
root.opacity = 1;
}
}
}
......@@ -13,7 +13,6 @@ QGCCompassHUD 1.0 QGCCompassHUD.qml
QGCCompassWidget 1.0 QGCCompassWidget.qml
QGCCurrentAltitude 1.0 QGCCurrentAltitude.qml
QGCCurrentSpeed 1.0 QGCCurrentSpeed.qml
QGCHudMessage 1.0 QGCHudMessage.qml
QGCMapToolButton 1.0 QGCMapToolButton.qml
QGCPitchIndicator 1.0 QGCPitchIndicator.qml
QGCSlider 1.0 QGCSlider.qml
......
......@@ -83,7 +83,6 @@ G_END_DECLS
#endif
#include "AutoPilotPlugin.h"
#include "VehicleComponent.h"
#include "MavManager.h"
#include "FirmwarePluginManager.h"
#include "MultiVehicleManager.h"
#include "Generic/GenericFirmwarePlugin.h"
......@@ -122,19 +121,6 @@ static QObject* screenToolsControllerSingletonFactory(QQmlEngine*, QJSEngine*)
return screenToolsController;
}
/**
* @brief MavManager creation callback
*
* This is called by the QtQuick engine for creating the singleton
**/
static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*)
{
MavManager* mavManager = new MavManager;
qgcApp()->setMavManager(mavManager);
return mavManager;
}
#if defined(QGC_GST_STREAMING)
#ifdef Q_OS_MAC
#ifndef __ios__
......@@ -163,7 +149,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
: QApplication(argc, argv)
, _runningUnitTests(unitTesting)
, _styleIsDark(true)
, _pMavManager(NULL)
, _fakeMobile(false)
{
Q_ASSERT(_app == NULL);
......@@ -356,7 +341,6 @@ void QGCApplication::_initCommon(void)
//-- Create QML Singleton Interfaces
qmlRegisterSingletonType<ScreenToolsController>("QGroundControl.ScreenToolsController", 1, 0, "ScreenToolsController", screenToolsControllerSingletonFactory);
qmlRegisterSingletonType<MavManager>("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory);
//-- Register Waypoint Interface
qmlRegisterInterface<Waypoint>("Waypoint");
......@@ -788,17 +772,6 @@ void QGCApplication::_missingParamsDisplay(void)
"You should quit QGroundControl immediately and update your firmware.").arg(params));
}
void QGCApplication::setMavManager(MavManager* pMgr)
{
if(!_pMavManager)
_pMavManager = pMgr;
}
MavManager* QGCApplication::getMavManager()
{
return _pMavManager;
}
void QGCApplication::showToolBarMessage(const QString& message)
{
MainWindow* mainWindow = MainWindow::instance();
......
......@@ -44,7 +44,6 @@
// Work around circular header includes
class QGCSingleton;
class MainWindow;
class MavManager;
/**
* @brief The main application and management class.
......@@ -101,12 +100,6 @@ public:
/// multiple times.
void reportMissingParameter(int componentId, const QString& name);
/// When the singleton is created, it sets a pointer for subsequent use
void setMavManager(MavManager* pMgr);
/// MavManager accessor
MavManager* getMavManager();
/// Show a non-modal message to the user
void showToolBarMessage(const QString& message);
......@@ -179,7 +172,6 @@ private:
static const int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display
QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display
QStringList _missingParams; ///< List of missing facts to be displayed
MavManager* _pMavManager;
bool _fakeMobile; ///< true: Fake ui into displaying mobile interface
......
......@@ -240,3 +240,15 @@ QVariantList MultiVehicleManager::vehiclesAsVariants(void)
return list;
}
void MultiVehicleManager::saveSetting(const QString &name, const QString& value)
{
QSettings settings;
settings.setValue(name, value);
}
QString MultiVehicleManager::loadSetting(const QString &name, const QString& defaultValue)
{
QSettings settings;
return settings.value(name, defaultValue).toString();
}
......@@ -39,6 +39,9 @@ class MultiVehicleManager : public QGCSingleton
DECLARE_QGC_SINGLETON(MultiVehicleManager, MultiVehicleManager)
public:
Q_INVOKABLE void saveSetting (const QString &key, const QString& value);
Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue);
Q_PROPERTY(bool activeVehicleAvailable READ activeVehicleAvailable NOTIFY activeVehicleAvailableChanged)
Q_PROPERTY(bool parameterReadyVehicleAvailable READ parameterReadyVehicleAvailable NOTIFY parameterReadyVehicleAvailableChanged)
Q_PROPERTY(Vehicle* activeVehicle READ activeVehicle WRITE setActiveVehicle NOTIFY activeVehicleChanged)
......
This diff is collapsed.
This diff is collapsed.
......@@ -298,7 +298,6 @@ void UAS::readSettings()
QSettings settings;
settings.beginGroup(QString("MAV%1").arg(uasId));
this->name = settings.value("NAME", this->name).toString();
qDebug() << "Name" << name;
this->airframe = settings.value("AIRFRAME", this->airframe).toInt();
if (settings.contains("BATTERY_SPECS"))
{
......
......@@ -33,7 +33,6 @@ import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QGroundControl.FlightMap 1.0
import QGroundControl.MavManager 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
......@@ -43,8 +42,27 @@ Item {
property var __qgcPal: QGCPalette { colorGroupEnabled: enabled }
property real roll: isNaN(MavManager.roll) ? 0 : MavManager.roll
property real pitch: isNaN(MavManager.pitch) ? 0 : MavManager.pitch
property var activeVehicle: multiVehicleManager.activeVehicle
readonly property real defaultLatitude: 37.803784
readonly property real defaultLongitude: -122.462276
readonly property real defaultRoll: 0
readonly property real defaultPitch: 0
readonly property real defaultHeading: 0
readonly property real defaultAltitudeWGS84: 0
readonly property real defaultGroundSpeed: 0
readonly property real defaultAirSpeed: 0
readonly property real defaultClimbRate: 0
property real roll: activeVehicle ? (isNaN(activeVehicle.roll) ? defaultRoll : activeVehicle.roll) : defaultRoll
property real pitch: activeVehicle ? (isNaN(activeVehicle.pitch) ? defaultPitch : activeVehicle.pitch) : defaultPitch
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
property real climbRate: activeVehicle ? activeVehicle.climbRate : defaultClimbRate
property bool showPitchIndicator: true
......@@ -73,7 +91,6 @@ Item {
Component.onCompleted:
{
mapBackground.visible = getBool(flightDisplay.loadSetting("showMapBackground", "0"));
mapBackground.showWaypoints = getBool(flightDisplay.loadSetting("mapShowWaypoints", "0"));
mapBackground.alwaysNorth = getBool(flightDisplay.loadSetting("mapAlwaysPointsNorth", "0"));
videoBackground.visible = getBool(flightDisplay.loadSetting("showVideoBackground", "0"));
showPitchIndicator = getBool(flightDisplay.loadSetting("showPitchIndicator", "1"));
......@@ -126,18 +143,6 @@ Item {
}
}
MenuItem {
text: "Map Show Waypoints"
checkable: true
checked: mapBackground.showWaypoints
enabled: mapBackground.visible
onTriggered:
{
mapBackground.showWaypoints = !mapBackground.showWaypoints;
flightDisplay.saveSetting("mapShowWaypoints", setBool(mapBackground.showWaypoints));
}
}
/*
//-- Off until Qt 5.5.x, which fixes bug in 5.4.x
MenuItem {
......@@ -340,23 +345,12 @@ Item {
id: mapBackground
anchors.fill: parent
mapName: 'MainFlightDisplay'
heading: 0 // isNaN(MavManager.heading) ? 0 : MavManager.heading
latitude: mapBackground.visible ? ((MavManager.latitude === 0) ? 37.803784 : MavManager.latitude) : 37.803784
longitude: mapBackground.visible ? ((MavManager.longitude === 0) ? -122.462276 : MavManager.longitude) : -122.462276
latitude: mapBackground.visible ? root.latitude : root.defaultLatitude
longitude: mapBackground.visible ? root.longitude : root.defaultLongitude
readOnly: true
//interactive: !MavManager.mavPresent
z: 10
}
QGCHudMessage {
id: hudMessage
y: ScreenTools.defaultFontPizelSize * (0.42)
width: (parent.width - 520 > 200) ? parent.width - 520 : 200
height: ScreenTools.defaultFontPizelSize * (2.5)
anchors.horizontalCenter: parent.horizontalCenter
z: mapBackground.z + 1
}
// Floating (Top Left) Compass Widget
QGCCompassWidget {
......@@ -364,7 +358,7 @@ Item {
y: ScreenTools.defaultFontPixelSize * (0.42)
x: ScreenTools.defaultFontPixelSize * (7.1)
size: ScreenTools.defaultFontPixelSize * (13.3)
heading: isNaN(MavManager.heading) ? 0 : MavManager.heading
heading: root.heading
z: mapBackground.z + 2
onResetRequested: {
y = ScreenTools.defaultFontPixelSize * (0.42)
......@@ -383,7 +377,7 @@ Item {
x: root.width * 0.5 - ScreenTools.defaultFontPixelSize * (5)
width: ScreenTools.defaultFontPixelSize * (10)
height: ScreenTools.defaultFontPixelSize * (10)
heading: isNaN(MavManager.heading) ? 0 : MavManager.heading
heading: root.heading
z: 70
}
......@@ -436,7 +430,7 @@ Item {
anchors.right: parent.right
width: ScreenTools.defaultFontPixelSize * (5)
height: parent.height * 0.65 > ScreenTools.defaultFontPixelSize * (23.4) ? ScreenTools.defaultFontPixelSize * (23.4) : parent.height * 0.65
altitude: MavManager.altitudeWGS84
altitude: root.altitudeWGS84
z: 30
}
......@@ -445,7 +439,7 @@ 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: MavManager.groundSpeed
speed: root.groundSpeed
z: 40
}
......@@ -453,8 +447,8 @@ Item {
id: currentSpeed
anchors.left: parent.left
width: ScreenTools.defaultFontPixelSize * (6.25)
airspeed: MavManager.airSpeed
groundspeed: MavManager.groundSpeed
airspeed: root.airSpeed
groundspeed: root.groundSpeed
showAirSpeed: true
showGroundSpeed: true
visible: (currentSpeed.showGroundSpeed || currentSpeed.showAirSpeed)
......@@ -465,8 +459,8 @@ Item {
id: currentAltitude
anchors.right: parent.right
width: ScreenTools.defaultFontPixelSize * (6.25)
altitude: MavManager.altitudeWGS84
vertZ: MavManager.climbRate
altitude: root.altitudeWGS84
vertZ: root.climbRate
showAltitude: true
showClimbRate: true
visible: (currentAltitude.showAltitude || currentAltitude.showClimbRate)
......
......@@ -37,7 +37,6 @@ This file is part of the QGROUNDCONTROL project
#include "UASMessageHandler.h"
#include "FlightDisplay.h"
#include "QGCApplication.h"
#include "MavManager.h"
#include "MultiVehicleManager.h"
MainToolBar::MainToolBar(QWidget* parent)
......@@ -220,8 +219,8 @@ void MainToolBar::onEnterMessageArea(int x, int y)
// If not already there and messages are actually present
if(!_rollDownMessages && UASMessageHandler::instance()->messages().count())
{
if(qgcApp()->getMavManager())
qgcApp()->getMavManager()->resetMessages();
if (MultiVehicleManager::instance()->activeVehicle())
MultiVehicleManager::instance()->activeVehicle()->resetMessages();
// Show messages
int dialogWidth = 400;
x = x - (dialogWidth >> 1);
......
This diff is collapsed.
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