From d1eac7fef5aca355be7a466e247afc398254e3d9 Mon Sep 17 00:00:00 2001 From: Valentin Platzgummer Date: Wed, 14 Oct 2020 21:14:10 +0200 Subject: [PATCH] wima planer and wima controller edited --- qgroundcontrol.pro | 2 + qgroundcontrol.qrc | 5 + src/FlightDisplay/FlightDisplayViewMap.qml | 96 +---- src/FlightDisplay/FlightDisplayWimaMenu.qml | 42 ++- src/Wima/Geometry/WimaAreaData.h | 3 + src/Wima/Geometry/WimaCorridorData.cpp | 60 ++-- src/Wima/Geometry/WimaCorridorData.h | 27 +- src/Wima/Geometry/WimaJoinedAreaData.cc | 4 + src/Wima/Geometry/WimaJoinedAreaData.h | 29 +- src/Wima/Geometry/WimaMeasurementAreaData.cc | 26 +- src/Wima/Geometry/WimaMeasurementAreaData.h | 15 +- src/Wima/Geometry/WimaServiceAreaData.cc | 4 + src/Wima/Geometry/WimaServiceAreaData.h | 2 + src/Wima/Snake/SnakeTile.cpp | 4 + src/Wima/Snake/SnakeTile.h | 2 + src/Wima/Snake/WimaAreaNoVisual.qml | 12 + src/Wima/StateMachine.cpp | 2 +- src/Wima/WaypointManager/EmptyManager.cpp | 18 + src/Wima/WaypointManager/EmptyManager.h | 31 ++ src/Wima/WimaController.cc | 330 +----------------- src/Wima/WimaController.h | 108 +----- src/WimaView/CircularSurveyMapVisual.qml | 8 +- src/WimaView/WimaCorridorDataVisual.qml | 58 +++ src/WimaView/WimaJoinedAreaDataVisual.qml | 58 +++ .../WimaMeasurementAreaDataVisual.qml | 124 +++++++ src/WimaView/WimaServiceAreaDataVisual.qml | 58 +++ src/WimaView/WimaToolBar.qml | 3 +- 27 files changed, 550 insertions(+), 581 deletions(-) create mode 100644 src/Wima/Snake/WimaAreaNoVisual.qml create mode 100644 src/Wima/WaypointManager/EmptyManager.cpp create mode 100644 src/Wima/WaypointManager/EmptyManager.h create mode 100644 src/WimaView/WimaCorridorDataVisual.qml create mode 100644 src/WimaView/WimaJoinedAreaDataVisual.qml create mode 100644 src/WimaView/WimaMeasurementAreaDataVisual.qml create mode 100644 src/WimaView/WimaServiceAreaDataVisual.qml diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 2def2ccee..1422176f1 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -457,6 +457,7 @@ HEADERS += \ src/Wima/StateMachine.h \ src/Wima/WaypointManager/AreaInterface.h \ src/Wima/WaypointManager/DefaultManager.h \ + src/Wima/WaypointManager/EmptyManager.h \ src/Wima/WaypointManager/GenericWaypointManager.h \ src/Wima/WaypointManager/RTLManager.h \ src/Wima/WaypointManager/Settings.h \ @@ -519,6 +520,7 @@ SOURCES += \ src/Wima/StateMachine.cpp \ src/Wima/WaypointManager/AreaInterface.cpp \ src/Wima/WaypointManager/DefaultManager.cpp \ + src/Wima/WaypointManager/EmptyManager.cpp \ src/Wima/WaypointManager/GenericWaypointManager.cpp \ src/Wima/WaypointManager/RTLManager.cpp \ src/Wima/WaypointManager/Settings.cpp \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 537b434da..2711db9d7 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -232,6 +232,11 @@ src/WimaView/CircularSurveyMapVisual.qml src/FlightDisplay/SmallValue.qml src/WimaView/ProgressIndicator.qml + src/WimaView/WimaServiceAreaDataVisual.qml + src/WimaView/WimaCorridorDataVisual.qml + src/WimaView/WimaJoinedAreaDataVisual.qml + src/Wima/Snake/WimaAreaNoVisual.qml + src/WimaView/WimaMeasurementAreaDataVisual.qml src/Settings/APMMavlinkStreamRate.SettingsGroup.json diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml index b0318dfc3..cb2bb45af 100644 --- a/src/FlightDisplay/FlightDisplayViewMap.qml +++ b/src/FlightDisplay/FlightDisplayViewMap.qml @@ -59,8 +59,6 @@ FlightMap { property bool _keepVehicleCentered: _mainIsMap ? false : true property bool _wimaEnabled: wimaController.enableWimaController.value - property bool _showAllWimaItems: wimaController.showAllMissionItems.value - property bool _showCurrentWimaItems: wimaController.showCurrentMissionItems.value function updateAirspace(reset) { if(_airspaceEnabled) { @@ -200,109 +198,29 @@ FlightMap { } // Add wima Areas to the Map - MapItemView { + Repeater { property bool _enableWima: wimaController.enableWimaController.value - model: _enableWima ? wimaController.visualItems : 0 - - delegate: MapPolygon{ - path: object.path; - border.color: "black" - color: object.type === "WimaJoinedAreaData" ? "gray" - : object.type === "WimaServiceAreaData" ? "yellow" - : object.type === "WimaMeasurementAreaData" ? "green" - : "transparent" - opacity: 0.25 - z: 0 + delegate: WimaMapVisual{ + map: flightMap + qgcView: flightMap.qgcView + visible: true } } - // Add mission items generated by wima planer to the map + // Add missionItems generated by wima planer to the map // all Items WimaPlanMapItems { map: flightMap largeMapView: _mainIsMap missionItems: wimaController.missionItems path: wimaController.waypointPath - showItems: _wimaEnabled && _showAllWimaItems + showItems: _wimaEnabled zOrderWP: QGroundControl.zOrderWimaAllWaypointIndicators zOrderLines: QGroundControl.zOrderWimaAllWaypointLines - color: "gray" - } - // current Items - WimaPlanMapItems { - map: flightMap - largeMapView: _mainIsMap - missionItems: wimaController.currentMissionItems - path: wimaController.currentWaypointPath - showItems: _wimaEnabled && _showCurrentWimaItems - zOrderWP: QGroundControl.zOrderWimaCurrentWaypointIndicators - zOrderLines: QGroundControl.zOrderWimaCurrentWaypointLines color: "green" } -// // Add Snake tile center points to the map -// MapItemView { -// id:progressView -// property bool _enable: wimaController.enableWimaController.value -// && wimaController.enableSnake.value -// property bool valid: wimaController.snakeTileCenterPoints.length -// === wimaController.nemoProgress.length -// model: _enable ? wimaController.snakeTileCenterPoints : 0 - -// delegate: ProgressIndicator{ -// coordinate: modelData -// currentValue: getProgress() -// z: 1 - -// function getProgress() { -// var progress = 0 -// if (progressView.valid){ -// progress = wimaController.nemoProgress[index] -// } -// if (progress < 0) -// progress = 0 -// if (progress > 100) -// progress = 100 -// return progress -// } -// } -// } - - // Add Snake tiles to the map - MapItemView { - id: tileView - property bool _enable: wimaController.enableWimaController.value - property bool valid: wimaController.snakeTileCenterPoints.length - === wimaController.nemoProgress.length - model: _enable ? wimaController.snakeTiles : 0 - - delegate: MapPolygon{ - path: object.path; - border.color: "black" - border.width: 1 - color: getColor() - opacity: 0.6 - z: 2 - - function getColor() { - var progress = 0 - if (tileView.valid){ - progress = wimaController.nemoProgress[index] - } - if (progress < 25) - return "transparent" - if (progress < 50) - return "orange" - if (progress < 75) - return "yellow" - if (progress < 100) - return "greenyellow" - return "limegreen" - } - } - } - // Add trajectory points to the map MapItemView { model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0 diff --git a/src/FlightDisplay/FlightDisplayWimaMenu.qml b/src/FlightDisplay/FlightDisplayWimaMenu.qml index 58896b918..6ad66b702 100644 --- a/src/FlightDisplay/FlightDisplayWimaMenu.qml +++ b/src/FlightDisplay/FlightDisplayWimaMenu.qml @@ -171,11 +171,11 @@ Item { id: mainColumn spacing: ScreenTools.defaultFontPixelHeight * 0.3 + SectionHeader{ id: vehicleHeader text: qsTr("Vehicle") } - GridLayout { columns: 2 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 @@ -183,6 +183,17 @@ Item { visible: vehicleHeader.checked width: parent.width + QGCButton { + id: buttonUpload + text: qsTr("Upload") + onClicked: { + if (!planMasterController.offline) { + wimaController.upload() + } + } + Layout.fillWidth: true + } + QGCButton { id: buttonRemoveFromVehicle text: qsTr("Remove") @@ -194,6 +205,7 @@ Item { id: buttonSmartRTL text: qsTr("Smart RTL") onClicked: wimaController.requestSmartRTL(); + Layout.columnSpan: 2 Layout.fillWidth: true } @@ -204,7 +216,32 @@ Item { Layout.columnSpan: 2 Layout.fillWidth: true } + } + GridLayout { + columns: 2 + rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 + columnSpacing: ScreenTools.defaultFontPixelHeight * 0.5 + visible: vehicleHeader.checked + width: parent.width + + QGCLabel { + text: qsTr("Speed") + Layout.fillWidth: true + } + FactTextField { + fact: wimaController.flightSpeed + Layout.fillWidth: true + } + + QGCLabel { + text: qsTr("Altitude") + Layout.fillWidth: true + } + FactTextField { + fact: wimaController.altitude + Layout.fillWidth: true + } // progess bar Rectangle { @@ -223,7 +260,7 @@ Item { Layout.columnSpan: 2 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - text: "Upload Complete" + text: "Done" visible: false Layout.fillWidth: true } @@ -233,7 +270,6 @@ Item { id: statsHeader text: qsTr("Statistics") } - GridLayout { columns: 3 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 diff --git a/src/Wima/Geometry/WimaAreaData.h b/src/Wima/Geometry/WimaAreaData.h index 5003f89ed..ffbc4c612 100644 --- a/src/Wima/Geometry/WimaAreaData.h +++ b/src/Wima/Geometry/WimaAreaData.h @@ -13,6 +13,7 @@ class WimaAreaData public: Q_PROPERTY(const QVariantList path READ path NOTIFY pathChanged) Q_PROPERTY(QString type READ type CONSTANT) + Q_PROPERTY(QString mapVisualQML READ mapVisualQML CONSTANT) WimaAreaData(QObject *parent = nullptr); ~WimaAreaData(); @@ -23,6 +24,8 @@ public: bool operator==(const WimaAreaData &data) const; bool operator!=(const WimaAreaData &data) const; + virtual QString mapVisualQML(void) const = 0; + QVariantList path() const; QGeoCoordinate center() const; const QList &coordinateList() const; diff --git a/src/Wima/Geometry/WimaCorridorData.cpp b/src/Wima/Geometry/WimaCorridorData.cpp index 7d64e4eb4..23abae3b7 100644 --- a/src/Wima/Geometry/WimaCorridorData.cpp +++ b/src/Wima/Geometry/WimaCorridorData.cpp @@ -2,22 +2,17 @@ const char *WimaCorridorData::typeString = "WimaCorridorData"; -WimaCorridorData::WimaCorridorData(QObject *parent) - :WimaAreaData (parent) -{ +WimaCorridorData::WimaCorridorData(QObject *parent) : WimaAreaData(parent) {} -} - -WimaCorridorData::WimaCorridorData(const WimaCorridorData &other, QObject *parent) - : WimaAreaData (parent) -{ - *this = other; +WimaCorridorData::WimaCorridorData(const WimaCorridorData &other, + QObject *parent) + : WimaAreaData(parent) { + *this = other; } WimaCorridorData::WimaCorridorData(const WimaCorridor &other, QObject *parent) - : WimaAreaData (parent) -{ - *this = other; + : WimaAreaData(parent) { + *this = other; } /*! @@ -25,11 +20,10 @@ WimaCorridorData::WimaCorridorData(const WimaCorridor &other, QObject *parent) * * Assigns \a other to the invoking object. */ -WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other) -{ - this->assign(other); +WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other) { + this->assign(other); - return *this; + return *this; } /*! @@ -37,36 +31,34 @@ WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other) * * Assigns \a other to the invoking object. */ -WimaCorridorData &WimaCorridorData::operator=(const WimaCorridor &other) -{ - this->assign(other); +WimaCorridorData &WimaCorridorData::operator=(const WimaCorridor &other) { + this->assign(other); - return *this; + return *this; } -QString WimaCorridorData::type() const -{ - return this->typeString; +QString WimaCorridorData::mapVisualQML() const { + return QStringLiteral("WimaAreaDataVisual.qml"); } -void WimaCorridorData::assign(const WimaCorridorData &corridorData) -{ - WimaAreaData::assign(corridorData); -} +QString WimaCorridorData::type() const { return this->typeString; } -void WimaCorridorData::assign(const WimaCorridor &corridor) -{ - WimaAreaData::assign(corridor); +void WimaCorridorData::assign(const WimaCorridorData &corridorData) { + WimaAreaData::assign(corridorData); } +void WimaCorridorData::assign(const WimaCorridor &corridor) { + WimaAreaData::assign(corridor); +} /*! * \class WimaAreaData::WimaCorridorData * \brief Class to store and exchange data of a \c WimaCorridorData Object. - * Class to store and exchange data of a \c WimaCorridor Object. In contrast to \c WimaCorridor this class - * does not provied any interface to a grafical user interface, neiter it uses the QGC Fact System. - * It is designed to exchange data between the \c WimaPlaner and the \c WimaController class. And it - * is the derived from WimaAreaData. + * Class to store and exchange data of a \c WimaCorridor Object. In contrast to + * \c WimaCorridor this class does not provied any interface to a grafical user + * interface, neiter it uses the QGC Fact System. It is designed to exchange + * data between the \c WimaPlaner and the \c WimaController class. And it is the + * derived from WimaAreaData. * * \sa WimaCorridor, WimaAreaData */ diff --git a/src/Wima/Geometry/WimaCorridorData.h b/src/Wima/Geometry/WimaCorridorData.h index d270b393d..b5557a599 100644 --- a/src/Wima/Geometry/WimaCorridorData.h +++ b/src/Wima/Geometry/WimaCorridorData.h @@ -7,31 +7,30 @@ #include "QGeoCoordinate" -class WimaCorridorData : public WimaAreaData -{ - Q_OBJECT +class WimaCorridorData : public WimaAreaData { + Q_OBJECT public: - WimaCorridorData(QObject *parent = nullptr); - WimaCorridorData(const WimaCorridorData &other, QObject *parent = nullptr); - WimaCorridorData(const WimaCorridor &other, QObject *parent = nullptr); - WimaCorridorData &operator=(const WimaCorridorData &other); - WimaCorridorData &operator=(const WimaCorridor &other); + WimaCorridorData(QObject *parent = nullptr); + WimaCorridorData(const WimaCorridorData &other, QObject *parent = nullptr); + WimaCorridorData(const WimaCorridor &other, QObject *parent = nullptr); + WimaCorridorData &operator=(const WimaCorridorData &other); + WimaCorridorData &operator=(const WimaCorridor &other); - QString type() const; - WimaCorridorData *Clone() const {return new WimaCorridorData(*this);} + virtual QString mapVisualQML() const override; - static const char* typeString; + QString type() const; + WimaCorridorData *Clone() const { return new WimaCorridorData(*this); } + static const char *typeString; signals: public slots: protected: - void assign(const WimaCorridorData &corridorData); - void assign(const WimaCorridor &corridor); + void assign(const WimaCorridorData &corridorData); + void assign(const WimaCorridor &corridor); private: }; - diff --git a/src/Wima/Geometry/WimaJoinedAreaData.cc b/src/Wima/Geometry/WimaJoinedAreaData.cc index 411142076..2929a0d84 100644 --- a/src/Wima/Geometry/WimaJoinedAreaData.cc +++ b/src/Wima/Geometry/WimaJoinedAreaData.cc @@ -39,6 +39,10 @@ WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedArea &other) { return *this; } +QString WimaJoinedAreaData::mapVisualQML() const { + return QStringLiteral("WimaJoinedAreaDataVisual.qml"); +} + QString WimaJoinedAreaData::type() const { return this->typeString; } void WimaJoinedAreaData::assign(const WimaJoinedAreaData &other) { diff --git a/src/Wima/Geometry/WimaJoinedAreaData.h b/src/Wima/Geometry/WimaJoinedAreaData.h index f00bd73a3..1d205dcb1 100644 --- a/src/Wima/Geometry/WimaJoinedAreaData.h +++ b/src/Wima/Geometry/WimaJoinedAreaData.h @@ -7,26 +7,27 @@ #include "QGeoCoordinate" -class WimaJoinedAreaData : public WimaAreaData -{ - Q_OBJECT +class WimaJoinedAreaData : public WimaAreaData { + Q_OBJECT public: - WimaJoinedAreaData(QObject *parent = nullptr); - WimaJoinedAreaData(const WimaJoinedAreaData &other, QObject *parent = nullptr); - WimaJoinedAreaData(const WimaJoinedArea &other, QObject *parent = nullptr); - WimaJoinedAreaData &operator=(const WimaJoinedAreaData &other); - WimaJoinedAreaData &operator=(const WimaJoinedArea &other); + WimaJoinedAreaData(QObject *parent = nullptr); + WimaJoinedAreaData(const WimaJoinedAreaData &other, + QObject *parent = nullptr); + WimaJoinedAreaData(const WimaJoinedArea &other, QObject *parent = nullptr); + WimaJoinedAreaData &operator=(const WimaJoinedAreaData &other); + WimaJoinedAreaData &operator=(const WimaJoinedArea &other); - QString type() const; - WimaJoinedAreaData *Clone() const {return new WimaJoinedAreaData(*this);} + virtual QString mapVisualQML() const override; - static const char* typeString; + QString type() const; + WimaJoinedAreaData *Clone() const { return new WimaJoinedAreaData(*this); } + + static const char *typeString; protected: - void assign(const WimaJoinedAreaData &other); - void assign(const WimaJoinedArea &other); + void assign(const WimaJoinedAreaData &other); + void assign(const WimaJoinedArea &other); private: }; - diff --git a/src/Wima/Geometry/WimaMeasurementAreaData.cc b/src/Wima/Geometry/WimaMeasurementAreaData.cc index dcdc5debf..72c49d252 100644 --- a/src/Wima/Geometry/WimaMeasurementAreaData.cc +++ b/src/Wima/Geometry/WimaMeasurementAreaData.cc @@ -30,6 +30,20 @@ operator!=(const WimaMeasurementAreaData &other) const { return !(*this == other); } +void WimaMeasurementAreaData::setTileData(const TileData &d) { + if (this->_tileData != d) { + this->_tileData = d; + emit tileDataChanged(); + } +} + +void WimaMeasurementAreaData::setProgress(const QVector &d) { + if (this->_progress != d) { + this->_progress = d; + emit progressChanged(); + } +} + /*! * \overload operator=(); * @@ -54,6 +68,10 @@ operator=(const WimaMeasurementArea &other) { return *this; } +QString WimaMeasurementAreaData::mapVisualQML() const { + return QStringLiteral("WimaMeasurementAreaDataVisual.qml"); +} + QString WimaMeasurementAreaData::type() const { return this->typeString; } QmlObjectListModel *WimaMeasurementAreaData::tiles() { @@ -86,15 +104,15 @@ QVector &WimaMeasurementAreaData::progress() { return this->_progress; } void WimaMeasurementAreaData::assign(const WimaMeasurementAreaData &other) { WimaAreaData::assign(other); - this->_tileData = other._tileData; - this->_progress = other._progress; + setTileData(other._tileData); + setProgress(other._progress); } void WimaMeasurementAreaData::assign(const WimaMeasurementArea &other) { WimaAreaData::assign(other); if (other.ready()) { - this->_tileData = other.tileData(); - this->_progress = other.progress(); + setTileData(other.tileData()); + setProgress(other.progress()); } else { qWarning() << "WimaMeasurementAreaData::assign(): WimaMeasurementArea not ready."; diff --git a/src/Wima/Geometry/WimaMeasurementAreaData.h b/src/Wima/Geometry/WimaMeasurementAreaData.h index 5211d0686..68481ffb6 100644 --- a/src/Wima/Geometry/WimaMeasurementAreaData.h +++ b/src/Wima/Geometry/WimaMeasurementAreaData.h @@ -18,14 +18,23 @@ public: WimaMeasurementAreaData &operator=(const WimaMeasurementAreaData &other); WimaMeasurementAreaData &operator=(const WimaMeasurementArea &other); + Q_PROPERTY(QmlObjectListModel *tiles READ tiles NOTIFY tileDataChanged) + Q_PROPERTY(QVector progress READ progress NOTIFY progressChanged) + + virtual QString mapVisualQML() const override; + bool operator==(const WimaMeasurementAreaData &other) const; bool operator!=(const WimaMeasurementAreaData &other) const; + // Property setters. + void setTileData(const TileData &d); + void setProgress(const QVector &d); + + // Property getters. QString type() const; WimaMeasurementAreaData *Clone() const { return new WimaMeasurementAreaData(*this); } - QmlObjectListModel *tiles(); const QmlObjectListModel *tiles() const; const QVariantList &tileCenterPoints() const; @@ -37,6 +46,10 @@ public: static const char *typeString; +signals: + void tileDataChanged(); + void progressChanged(); + protected: void assign(const WimaMeasurementAreaData &other); void assign(const WimaMeasurementArea &other); diff --git a/src/Wima/Geometry/WimaServiceAreaData.cc b/src/Wima/Geometry/WimaServiceAreaData.cc index 718a4b095..7496e9095 100644 --- a/src/Wima/Geometry/WimaServiceAreaData.cc +++ b/src/Wima/Geometry/WimaServiceAreaData.cc @@ -31,6 +31,10 @@ operator=(const WimaServiceArea &otherArea) { return *this; } +QString WimaServiceAreaData::mapVisualQML() const { + return QStringLiteral("WimaServiceAreaDataVisual.qml"); +} + /*! * \fn const QGeoCoordinate &WimaServiceAreaData::takeOffPosition() const * Returns a constant reference to the takeOffPosition. diff --git a/src/Wima/Geometry/WimaServiceAreaData.h b/src/Wima/Geometry/WimaServiceAreaData.h index 7792bfb27..08f616e4b 100644 --- a/src/Wima/Geometry/WimaServiceAreaData.h +++ b/src/Wima/Geometry/WimaServiceAreaData.h @@ -17,6 +17,8 @@ public: WimaServiceAreaData &operator=(const WimaServiceAreaData &otherData); WimaServiceAreaData &operator=(const WimaServiceArea &otherArea); + virtual QString mapVisualQML() const override; + const QGeoCoordinate &depot() const; QString type() const; diff --git a/src/Wima/Snake/SnakeTile.cpp b/src/Wima/Snake/SnakeTile.cpp index e960609f3..ba2ffcbaf 100644 --- a/src/Wima/Snake/SnakeTile.cpp +++ b/src/Wima/Snake/SnakeTile.cpp @@ -9,6 +9,10 @@ SnakeTile::SnakeTile(const SnakeTile &other, QObject *parent) SnakeTile::~SnakeTile() {} +QString SnakeTile::mapVisualQML() const { + return QStringLiteral("WimaAreaNoVisual.qml"); +} + QString SnakeTile::type() const { return "Tile"; } SnakeTile *SnakeTile::Clone() const { return new SnakeTile(*this); } diff --git a/src/Wima/Snake/SnakeTile.h b/src/Wima/Snake/SnakeTile.h index e16950864..8117048fa 100644 --- a/src/Wima/Snake/SnakeTile.h +++ b/src/Wima/Snake/SnakeTile.h @@ -9,6 +9,8 @@ public: SnakeTile(const SnakeTile &other, QObject *parent = nullptr); ~SnakeTile(); + virtual QString mapVisualQML() const override; + QString type() const override; SnakeTile *Clone() const; diff --git a/src/Wima/Snake/WimaAreaNoVisual.qml b/src/Wima/Snake/WimaAreaNoVisual.qml new file mode 100644 index 000000000..12b271a23 --- /dev/null +++ b/src/Wima/Snake/WimaAreaNoVisual.qml @@ -0,0 +1,12 @@ +import QtQuick 2.3 +Item { + id: _root + + property var map ///< Map control to place item in + property var qgcView ///< QGCView to use for popping dialogs + + Component.onCompleted: { + console.log("WimaAreaNoVisual.qml is a place holder and not meant to be instanciated.") + } + +} diff --git a/src/Wima/StateMachine.cpp b/src/Wima/StateMachine.cpp index b6fb708a8..5b4f85760 100644 --- a/src/Wima/StateMachine.cpp +++ b/src/Wima/StateMachine.cpp @@ -253,7 +253,7 @@ void StateMachine::setState(STATE s) { emit upToDateChanged(); } if (surveyReady(oldState) != surveyReady(s)) { - emit surveyReady(); + emit surveyReadyChanged(); } qCDebug(WimaPlanerLog) << "StateMachine::setState():" << oldState << "->" << s; diff --git a/src/Wima/WaypointManager/EmptyManager.cpp b/src/Wima/WaypointManager/EmptyManager.cpp new file mode 100644 index 000000000..c892c0f99 --- /dev/null +++ b/src/Wima/WaypointManager/EmptyManager.cpp @@ -0,0 +1,18 @@ +#include "EmptyManager.h" + +namespace WaypointManager { + +WaypointManager::EmptyManager::EmptyManager(Settings &settings, AreaInterface &) + : ManagerBase(settings) {} + +void WaypointManager::EmptyManager::clear() {} + +bool WaypointManager::EmptyManager::update() {} + +bool WaypointManager::EmptyManager::next() {} + +bool WaypointManager::EmptyManager::previous() {} + +bool WaypointManager::EmptyManager::reset() {} + +} // namespace WaypointManager diff --git a/src/Wima/WaypointManager/EmptyManager.h b/src/Wima/WaypointManager/EmptyManager.h new file mode 100644 index 000000000..8ddfc1c3d --- /dev/null +++ b/src/Wima/WaypointManager/EmptyManager.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +#include "AreaInterface.h" +#include "GenericWaypointManager.h" +#include "QmlObjectListModel.h" +#include "Settings.h" + +namespace WaypointManager { + +typedef GenericWaypointManager + ManagerBase; + +//! +//! \brief The EmptyManager is a place holder and does noting. +class EmptyManager : public ManagerBase { +public: + EmptyManager() = delete; + EmptyManager(Settings &settings, AreaInterface &); + + void clear() override; + virtual bool update() override; + virtual bool next() override; + virtual bool previous() override; + virtual bool reset() override; +}; + +} // namespace WaypointManager diff --git a/src/Wima/WimaController.cc b/src/Wima/WimaController.cc index 5956b78b1..8d299ebba 100644 --- a/src/Wima/WimaController.cc +++ b/src/Wima/WimaController.cc @@ -6,6 +6,7 @@ #include "MissionSettingsItem.h" #include "PlanMasterController.h" #include "QGCApplication.h" +#include "QGCLoggingCategory.h" #include "SettingsManager.h" #include "SimpleMissionItem.h" @@ -23,6 +24,8 @@ #include +QGC_LOGGING_CATEGORY(WimaControllerLog, "WimaControllerLog") + template constexpr typename std::underlying_type::type integral(T value) { return static_cast::type>(value); @@ -36,80 +39,32 @@ const char *WimaController::areaItemsName = "AreaItems"; const char *WimaController::missionItemsName = "MissionItems"; const char *WimaController::settingsGroup = "WimaController"; const char *WimaController::enableWimaControllerName = "EnableWimaController"; -const char *WimaController::overlapWaypointsName = "OverlapWaypoints"; -const char *WimaController::maxWaypointsPerPhaseName = "MaxWaypointsPerPhase"; -const char *WimaController::startWaypointIndexName = "StartWaypointIndex"; -const char *WimaController::showAllMissionItemsName = "ShowAllMissionItems"; -const char *WimaController::showCurrentMissionItemsName = - "ShowCurrentMissionItems"; const char *WimaController::flightSpeedName = "FlightSpeed"; -const char *WimaController::arrivalReturnSpeedName = "ArrivalReturnSpeed"; const char *WimaController::altitudeName = "Altitude"; -WimaController::StatusMap WimaController::_nemoStatusMap{ - std::make_pair(0, "No Heartbeat"), - std::make_pair(1, "Connected"), - std::make_pair(-1, "Timeout"), - std::make_pair(-2, "Error")}; - WimaController::WimaController(QObject *parent) : QObject(parent), _joinedArea(), _measurementArea(), _serviceArea(), _corridor(), _planDataValid(false), _areaInterface(&_measurementArea, &_serviceArea, &_corridor, &_joinedArea), - _WMSettings(), _defaultWM(_WMSettings, _areaInterface), + _WMSettings(), _emptyWM(_WMSettings, _areaInterface), _rtlWM(_WMSettings, _areaInterface), - _currentWM(&_defaultWM), _WMList{&_defaultWM, &_rtlWM}, + _currentWM(&_emptyWM), _WMList{&_emptyWM, &_rtlWM}, _metaDataMap(FactMetaData::createMapFromJsonFile( QStringLiteral(":/json/WimaController.SettingsGroup.json"), this)), _enableWimaController(settingsGroup, _metaDataMap[enableWimaControllerName]), - _overlapWaypoints(settingsGroup, _metaDataMap[overlapWaypointsName]), - _maxWaypointsPerPhase(settingsGroup, - _metaDataMap[maxWaypointsPerPhaseName]), - _nextPhaseStartWaypointIndex(settingsGroup, - _metaDataMap[startWaypointIndexName]), - _showAllMissionItems(settingsGroup, - _metaDataMap[showAllMissionItemsName]), - _showCurrentMissionItems(settingsGroup, - _metaDataMap[showCurrentMissionItemsName]), _flightSpeed(settingsGroup, _metaDataMap[flightSpeedName]), - _arrivalReturnSpeed(settingsGroup, _metaDataMap[arrivalReturnSpeedName]), _altitude(settingsGroup, _metaDataMap[altitudeName]), - _lowBatteryHandlingTriggered(false), _measurementPathLength(-1), + _lowBatteryHandlingTriggered(false), _batteryLevelTicker(EVENT_TIMER_INTERVAL, 1000 /*ms*/) { // Set up facts for waypoint manager. - _showAllMissionItems.setRawValue(true); - _showCurrentMissionItems.setRawValue(true); - connect(&_overlapWaypoints, &Fact::rawValueChanged, this, - &WimaController::_updateOverlap); - connect(&_maxWaypointsPerPhase, &Fact::rawValueChanged, this, - &WimaController::_updateMaxWaypoints); - connect(&_nextPhaseStartWaypointIndex, &Fact::rawValueChanged, this, - &WimaController::_setStartIndex); connect(&_flightSpeed, &Fact::rawValueChanged, this, &WimaController::_updateflightSpeed); - connect(&_arrivalReturnSpeed, &Fact::rawValueChanged, this, - &WimaController::_updateArrivalReturnSpeed); connect(&_altitude, &Fact::rawValueChanged, this, &WimaController::_updateAltitude); - // Init waypoint managers. - bool value; - size_t overlap = _overlapWaypoints.rawValue().toUInt(&value); - Q_ASSERT(value); - size_t N = _maxWaypointsPerPhase.rawValue().toUInt(&value); - Q_ASSERT(value); - size_t startIdx = _nextPhaseStartWaypointIndex.rawValue().toUInt(&value); - Q_ASSERT(value); - (void)value; - for (auto manager : _WMList) { - manager->setOverlap(overlap); - manager->setN(N); - manager->setStartIndex(startIdx); - } - // Periodic. connect(&_eventTimer, &QTimer::timeout, this, &WimaController::_eventTimerHandler); @@ -130,70 +85,16 @@ QmlObjectListModel *WimaController::missionItems() { return const_cast(&_currentWM->missionItems()); } -QmlObjectListModel *WimaController::currentMissionItems() { - return const_cast(&_currentWM->currentMissionItems()); -} - QVariantList WimaController::waypointPath() { return const_cast(_currentWM->waypointsVariant()); } -QVariantList WimaController::currentWaypointPath() { - return const_cast(_currentWM->currentWaypointsVariant()); -} - Fact *WimaController::enableWimaController() { return &_enableWimaController; } -Fact *WimaController::overlapWaypoints() { return &_overlapWaypoints; } - -Fact *WimaController::maxWaypointsPerPhase() { return &_maxWaypointsPerPhase; } - -Fact *WimaController::startWaypointIndex() { - return &_nextPhaseStartWaypointIndex; -} - -Fact *WimaController::showAllMissionItems() { return &_showAllMissionItems; } - -Fact *WimaController::showCurrentMissionItems() { - return &_showCurrentMissionItems; -} - Fact *WimaController::flightSpeed() { return &_flightSpeed; } -Fact *WimaController::arrivalReturnSpeed() { return &_arrivalReturnSpeed; } - Fact *WimaController::altitude() { return &_altitude; } -QmlObjectListModel *WimaController::snakeTiles() { - return this->_measurementArea.tiles(); -} - -QVariantList WimaController::snakeTileCenterPoints() { - return this->_measurementArea.tileCenterPoints(); -} - -QVector WimaController::nemoProgress() { - return this->_measurementArea.progress(); -} - -double WimaController::phaseDistance() const { - qWarning() << "using phaseDistance dummy"; - return 0.0; -} - -double WimaController::phaseDuration() const { - qWarning() << "using phaseDuration dummy"; - return 0.0; -} - -int WimaController::nemoStatus() const { - return integral(NemoInterface::STATUS::NOT_CONNECTED); -} - -QString WimaController::nemoStatusString() const { - return _nemoStatusMap.at(nemoStatus()); -} - void WimaController::setMasterController(PlanMasterController *masterC) { _masterController = masterC; _WMSettings.setMasterController(masterC); @@ -206,34 +107,8 @@ void WimaController::setMissionController(MissionController *missionC) { emit missionControllerChanged(); } -void WimaController::nextPhase() { _calcNextPhase(); } - -void WimaController::previousPhase() { - if (!_currentWM->previous()) { - Q_ASSERT(false); - } - - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); - emit waypointPathChanged(); -} - -void WimaController::resetPhase() { - if (!_currentWM->reset()) { - Q_ASSERT(false); - } - - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); - emit waypointPathChanged(); -} - void WimaController::requestSmartRTL() { -#ifdef DEBUG_SRTL - qWarning() << "WimaController::requestSmartRTL() called"; -#endif + qCWarning(WimaControllerLog) << "requestSmartRTL() called"; QString errorString("Smart RTL requested."); if (!_SRTLPrecondition(errorString)) { qgcApp()->showMessage(errorString); @@ -262,11 +137,11 @@ bool WimaController::forceUpload() { auto ¤tMissionItems = _currentWM->currentMissionItems(); if (currentMissionItems.count() < 1 || !_missionController || !_masterController) { - qWarning() << "WimaController::forceUpload(): error:"; - qWarning() << "currentMissionItems.count(): " - << currentMissionItems.count(); - qWarning() << "_missionController: " << _missionController; - qWarning() << "_masterController: " << _masterController; + qCWarning(WimaControllerLog) + << "forceUpload(): error:" + << "currentMissionItems.count(): " << currentMissionItems.count() + << "_missionController: " << _missionController + << "_masterController: " << _masterController; return false; } else { _missionController->removeAll(); @@ -276,7 +151,7 @@ bool WimaController::forceUpload() { visuals->value(0); if (settingsItem == nullptr) { Q_ASSERT(false); - qWarning("WimaController::updateCurrentMissionItems(): nullptr"); + qCWarning(WimaControllerLog) << "updateCurrentMissionItems(): nullptr"; return false; } else { settingsItem->setCoordinate(_WMSettings.homePosition()); @@ -300,9 +175,7 @@ void WimaController::removeFromVehicle() { } void WimaController::executeSmartRTL() { -#ifdef DEBUG_SRTL - qWarning() << "WimaController::executeSmartRTL() called"; -#endif + qCWarning(WimaControllerLog) << "executeSmartRTL() called"; if (_masterController && _masterController->managerVehicle()) { forceUpload(); _masterController->managerVehicle()->startMission(); @@ -310,9 +183,7 @@ void WimaController::executeSmartRTL() { } void WimaController::initSmartRTL() { -#ifdef DEBUG_SRTL - qWarning() << "WimaController::initSmartRTL() called"; -#endif + qCWarning(WimaControllerLog) << "initSmartRTL() called"; _initSmartRTL(); } @@ -346,7 +217,6 @@ bool WimaController::_calcShortestPath(const QGeoCoordinate &start, bool WimaController::setWimaPlanData(QSharedPointer planData) { // reset visual items _areas.clear(); - _defaultWM.clear(); _measurementArea = WimaMeasurementAreaData(); _serviceArea = WimaServiceAreaData(); _corridor = WimaCorridorData(); @@ -354,11 +224,7 @@ bool WimaController::setWimaPlanData(QSharedPointer planData) { emit visualItemsChanged(); emit missionItemsChanged(); - emit currentMissionItemsChanged(); emit waypointPathChanged(); - emit currentWaypointPathChanged(); - emit snakeTilesChanged(); - emit nemoProgressChanged(); _planDataValid = false; @@ -417,32 +283,9 @@ bool WimaController::setWimaPlanData(QSharedPointer planData) { } emit visualItemsChanged(); - emit snakeTilesChanged(); - - // Copy missionItems. - auto tempMissionItems = planData->missionItems(); - if (tempMissionItems.size() < 1) { - qWarning("WimaController: Mission items from WimaPlaner empty!"); - return false; - } - for (auto *item : tempMissionItems) { - _defaultWM.push_back(item->coordinate()); - } _WMSettings.setHomePosition(QGeoCoordinate( _serviceArea.depot().latitude(), _serviceArea.depot().longitude(), 0)); - // auto tempMissionItems = planData->missionItems(); - if (!_defaultWM.reset()) { - Q_ASSERT(false); - return false; - } - - if (_currentWM == &_defaultWM) { - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit waypointPathChanged(); - emit currentWaypointPathChanged(); - } _planDataValid = true; return true; @@ -450,83 +293,6 @@ bool WimaController::setWimaPlanData(QSharedPointer planData) { WimaController *WimaController::thisPointer() { return this; } -bool WimaController::_calcNextPhase() { - if (!_currentWM->next()) { - Q_ASSERT(false); - return false; - } - - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); - emit waypointPathChanged(); - - return true; -} - -bool WimaController::_setStartIndex() { - bool value; - _currentWM->setStartIndex( - _nextPhaseStartWaypointIndex.rawValue().toUInt(&value) - 1); - Q_ASSERT(value); - (void)value; - - if (!_currentWM->update()) { - Q_ASSERT(false); - return false; - } - - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); - emit waypointPathChanged(); - - return true; -} - -void WimaController::_recalcCurrentPhase() { - if (!_currentWM->update()) { - Q_ASSERT(false); - } - - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); - emit waypointPathChanged(); -} - -void WimaController::_updateOverlap() { - bool value; - _currentWM->setOverlap(_overlapWaypoints.rawValue().toUInt(&value)); - Q_ASSERT(value); - (void)value; - - if (!_currentWM->update()) { - assert(false); - } - - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); - emit waypointPathChanged(); -} - -void WimaController::_updateMaxWaypoints() { - bool value; - _currentWM->setN(_maxWaypointsPerPhase.rawValue().toUInt(&value)); - Q_ASSERT(value); - (void)value; - - if (!_currentWM->update()) { - Q_ASSERT(false); - } - - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); - emit waypointPathChanged(); -} - void WimaController::_updateflightSpeed() { bool value; _WMSettings.setFlightSpeed(_flightSpeed.rawValue().toDouble(&value)); @@ -538,25 +304,6 @@ void WimaController::_updateflightSpeed() { } emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); - emit waypointPathChanged(); -} - -void WimaController::_updateArrivalReturnSpeed() { - bool value; - _WMSettings.setArrivalReturnSpeed( - _arrivalReturnSpeed.rawValue().toDouble(&value)); - Q_ASSERT(value); - (void)value; - - if (!_currentWM->update()) { - Q_ASSERT(false); - } - - emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); emit waypointPathChanged(); } @@ -571,8 +318,6 @@ void WimaController::_updateAltitude() { } emit missionItemsChanged(); - emit currentMissionItemsChanged(); - emit currentWaypointPathChanged(); emit waypointPathChanged(); } @@ -624,31 +369,13 @@ void WimaController::_eventTimerHandler() { void WimaController::_smartRTLCleanUp(bool flying) { if (!flying && _missionController) { // vehicle has landed - _switchWaypointManager(_defaultWM); + _switchWaypointManager(_emptyWM); _missionController->removeAll(); disconnect(masterController()->managerVehicle(), &Vehicle::flyingChanged, this, &WimaController::_smartRTLCleanUp); } } -void WimaController::_setPhaseDistance(double distance) { - (void)distance; - // if (!qFuzzyCompare(distance, _phaseDistance)) { - // _phaseDistance = distance; - - // emit phaseDistanceChanged(); - // } -} - -void WimaController::_setPhaseDuration(double duration) { - (void)duration; - // if (!qFuzzyCompare(duration, _phaseDuration)) { - // _phaseDuration = duration; - - // emit phaseDurationChanged(); - // } -} - bool WimaController::_SRTLPrecondition(QString &errorString) { if (!_planDataValid) { errorString.append(tr("No WiMA data available. Please define at least a " @@ -663,32 +390,11 @@ void WimaController::_switchWaypointManager( WaypointManager::ManagerBase &manager) { if (_currentWM != &manager) { _currentWM = &manager; - - disconnect(&_overlapWaypoints, &Fact::rawValueChanged, this, - &WimaController::_updateOverlap); - disconnect(&_maxWaypointsPerPhase, &Fact::rawValueChanged, this, - &WimaController::_updateMaxWaypoints); - disconnect(&_nextPhaseStartWaypointIndex, &Fact::rawValueChanged, this, - &WimaController::_setStartIndex); - - _maxWaypointsPerPhase.setRawValue(_currentWM->N()); - _overlapWaypoints.setRawValue(_currentWM->overlap()); - _nextPhaseStartWaypointIndex.setRawValue(_currentWM->startIndex()); - - connect(&_overlapWaypoints, &Fact::rawValueChanged, this, - &WimaController::_updateOverlap); - connect(&_maxWaypointsPerPhase, &Fact::rawValueChanged, this, - &WimaController::_updateMaxWaypoints); - connect(&_nextPhaseStartWaypointIndex, &Fact::rawValueChanged, this, - &WimaController::_setStartIndex); - emit missionItemsChanged(); - emit currentMissionItemsChanged(); emit waypointPathChanged(); - emit currentWaypointPathChanged(); - qWarning() << "WimaController::_switchWaypointManager: statistics update " - "missing."; + qCWarning(WimaControllerLog) << "_switchWaypointManager: statistics update " + "missing."; } } diff --git a/src/Wima/WimaController.h b/src/Wima/WimaController.h index e7d966472..51ce1ae4d 100644 --- a/src/Wima/WimaController.h +++ b/src/Wima/WimaController.h @@ -18,7 +18,7 @@ #include "RoutingThread.h" #include "Snake/NemoInterface.h" -#include "WaypointManager/DefaultManager.h" +#include "WaypointManager/EmptyManager.h" #include "WaypointManager/RTLManager.h" #include "utilities.h" @@ -42,42 +42,13 @@ public: visualItemsChanged) Q_PROPERTY(QmlObjectListModel *missionItems READ missionItems NOTIFY missionItemsChanged) - Q_PROPERTY(QmlObjectListModel *currentMissionItems READ currentMissionItems - NOTIFY currentMissionItemsChanged) Q_PROPERTY( QVariantList waypointPath READ waypointPath NOTIFY waypointPathChanged) - Q_PROPERTY(QVariantList currentWaypointPath READ currentWaypointPath NOTIFY - currentWaypointPathChanged) Q_PROPERTY(Fact *enableWimaController READ enableWimaController CONSTANT) // Waypoint navigaton. - Q_PROPERTY(Fact *overlapWaypoints READ overlapWaypoints CONSTANT) - Q_PROPERTY(Fact *maxWaypointsPerPhase READ maxWaypointsPerPhase CONSTANT) - Q_PROPERTY(Fact *startWaypointIndex READ startWaypointIndex CONSTANT) - Q_PROPERTY(Fact *showAllMissionItems READ showAllMissionItems CONSTANT) - Q_PROPERTY( - Fact *showCurrentMissionItems READ showCurrentMissionItems CONSTANT) - // Waypoint settings. Q_PROPERTY(Fact *flightSpeed READ flightSpeed CONSTANT) Q_PROPERTY(Fact *altitude READ altitude CONSTANT) - Q_PROPERTY(Fact *arrivalReturnSpeed READ arrivalReturnSpeed CONSTANT) - // Waypoint statistics. - Q_PROPERTY( - double phaseDistance READ phaseDistance NOTIFY phaseDistanceChanged) - Q_PROPERTY( - double phaseDuration READ phaseDuration NOTIFY phaseDurationChanged) - // Snake - Q_PROPERTY(int nemoStatus READ nemoStatus NOTIFY nemoStatusChanged) - Q_PROPERTY(QString nemoStatusString READ nemoStatusString NOTIFY - nemoStatusStringChanged) - Q_PROPERTY( - QmlObjectListModel *snakeTiles READ snakeTiles NOTIFY snakeTilesChanged) - Q_PROPERTY(QVariantList snakeTileCenterPoints READ snakeTileCenterPoints - NOTIFY snakeTilesChanged) - Q_PROPERTY( - QVector nemoProgress READ nemoProgress NOTIFY nemoProgressChanged) - - // Property accessors // Controllers. PlanMasterController *masterController(void); MissionController *missionController(void); @@ -86,31 +57,14 @@ public: QGCMapPolygon joinedArea(void) const; // Waypoints. QmlObjectListModel *missionItems(void); - QmlObjectListModel *currentMissionItems(void); QVariantList waypointPath(void); - QVariantList currentWaypointPath(void); // Settings facts. Fact *enableWimaController(void); - Fact *overlapWaypoints(void); - Fact *maxWaypointsPerPhase(void); - Fact *startWaypointIndex(void); - Fact *showAllMissionItems(void); - Fact *showCurrentMissionItems(void); Fact *flightSpeed(void); - Fact *arrivalReturnSpeed(void); Fact *altitude(void); - // Snake data. - QmlObjectListModel *snakeTiles(void); - QVariantList snakeTileCenterPoints(void); - QVector nemoProgress(void); - int nemoStatus(void) const; - QString nemoStatusString(void) const; bool uploadOverrideRequired(void) const; bool vehicleHasLowBattery(void) const; - // Waypoint statistics. - double phaseDistance(void) const; - double phaseDuration(void) const; // Property setters void setMasterController(PlanMasterController *masterController); @@ -119,10 +73,6 @@ public: // Member Methodes Q_INVOKABLE WimaController *thisPointer(); - // Waypoint navigation. - Q_INVOKABLE void nextPhase(); - Q_INVOKABLE void previousPhase(); - Q_INVOKABLE void resetPhase(); // Smart RTL. Q_INVOKABLE void requestSmartRTL(); Q_INVOKABLE void initSmartRTL(); @@ -137,15 +87,8 @@ public: static const char *areaItemsName; static const char *missionItemsName; static const char *settingsGroup; - static const char *endWaypointIndexName; static const char *enableWimaControllerName; - static const char *overlapWaypointsName; - static const char *maxWaypointsPerPhaseName; - static const char *startWaypointIndexName; - static const char *showAllMissionItemsName; - static const char *showCurrentMissionItemsName; static const char *flightSpeedName; - static const char *arrivalReturnSpeedName; static const char *altitudeName; signals: @@ -156,42 +99,20 @@ signals: void visualItemsChanged(void); // Waypoints. void missionItemsChanged(void); - void currentMissionItemsChanged(void); void waypointPathChanged(void); - void currentWaypointPathChanged(void); // Smart RTL. void smartRTLRequestConfirm(void); void smartRTLPathConfirm(void); // Upload. void forceUploadConfirm(void); - // Waypoint statistics. - void phaseDistanceChanged(void); - void phaseDurationChanged(void); - // Snake. - void snakeTilesChanged(void); - void nemoProgressChanged(void); - void nemoStatusChanged(void); - void nemoStatusStringChanged(void); private slots: - // Waypoint navigation / helper. - bool _calcNextPhase(void); - void _recalcCurrentPhase(void); bool _calcShortestPath(const QGeoCoordinate &start, const QGeoCoordinate &destination, QVector &path); - // Slicing parameters - bool _setStartIndex(void); - void _updateOverlap(void); - void _updateMaxWaypoints(void); - // Waypoint settings. void _updateflightSpeed(void); - void _updateArrivalReturnSpeed(void); void _updateAltitude(void); - // Waypoint Statistics. - void _setPhaseDistance(double distance); - void _setPhaseDuration(double duration); // SMART RTL void _checkBatteryLevel(void); bool _SRTLPrecondition(QString &errorString); @@ -219,7 +140,7 @@ private: // Waypoint Managers. WaypointManager::AreaInterface _areaInterface; WaypointManager::Settings _WMSettings; // Waypoint Manager Settings - WaypointManager::DefaultManager _defaultWM; + WaypointManager::EmptyManager _emptyWM; WaypointManager::RTLManager _rtlWM; WaypointManager::ManagerBase *_currentWM; using ManagerList = QList; @@ -230,34 +151,13 @@ private: SettingsFact _enableWimaController; // enables or disables the wimaControler // determines the number of overlapping waypoints between two consecutive // mission phases - SettingsFact _overlapWaypoints; - // determines the maximum number waypoints per phase - SettingsFact _maxWaypointsPerPhase; - SettingsFact - _nextPhaseStartWaypointIndex; // index (displayed on the map, -1 to get - // index of item in _missionItems) of the - // mission item defining the first element - // of the next phase - SettingsFact - _showAllMissionItems; // bool value, Determines whether the mission items - // of the overall mission are displayed or not. - SettingsFact _showCurrentMissionItems; // bool value, Determines whether the - // mission items of the current mission - // phase are displayed or not. - SettingsFact _flightSpeed; // mission flight speed - SettingsFact _arrivalReturnSpeed; // arrival and return path speed - SettingsFact _altitude; // mission altitude + SettingsFact _flightSpeed; // mission flight speed + SettingsFact _altitude; // mission altitude // Smart RTL. QTimer _smartRTLTimer; bool _lowBatteryHandlingTriggered; - // Waypoint statistics. - double _measurementPathLength; // the lenght of the phase in meters - - using StatusMap = std::map; - static StatusMap _nemoStatusMap; - // Periodic tasks. QTimer _eventTimer; EventTicker _batteryLevelTicker; diff --git a/src/WimaView/CircularSurveyMapVisual.qml b/src/WimaView/CircularSurveyMapVisual.qml index 83f949795..9aa783792 100644 --- a/src/WimaView/CircularSurveyMapVisual.qml +++ b/src/WimaView/CircularSurveyMapVisual.qml @@ -37,28 +37,28 @@ Item { function _addTransectsComponent(){ if (!_transectsComponent){ - _transectsComponent = visualTransectsComponent.createObject(map) + _transectsComponent = visualTransectsComponent.createObject(_root) map.addMapItem(_transectsComponent) } } function _addExitCoordinate(){ if (!_exitCoordinate){ - _exitCoordinate = exitPointComponent.createObject(map) + _exitCoordinate = exitPointComponent.createObject(_root) map.addMapItem(_exitCoordinate) } } function _addEntryCoordinate(){ if (!_entryCoordinate){ - _entryCoordinate = entryPointComponent.createObject(map) + _entryCoordinate = entryPointComponent.createObject(_root) map.addMapItem(_entryCoordinate) } } function _addRefPoint(){ if (!_refPoint){ - _refPoint = refPointComponent.createObject(map) + _refPoint = refPointComponent.createObject(_root) map.addMapItem(_refPoint) } } diff --git a/src/WimaView/WimaCorridorDataVisual.qml b/src/WimaView/WimaCorridorDataVisual.qml new file mode 100644 index 000000000..86b323bbe --- /dev/null +++ b/src/WimaView/WimaCorridorDataVisual.qml @@ -0,0 +1,58 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtLocation 5.3 +import QtPositioning 5.3 + +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FlightMap 1.0 + +/// Wima Measurement Area Data visuals +Item { + id: _root + + property var map ///< Map control to place item in + property var qgcView ///< QGCView to use for popping dialogs + + property var areaItem: object + signal clicked(int sequenceNumber) + + property var _polygonComponent + + + function _addPolygon(){ + if(!_polygonComponent){ + _polygonComponent = polygon.createObject(_root) + map.addMapItem(_polygonComponent) + } + } + + function _destroyPolygon(){ + if(_polygonComponent){ + map.removeMapItem(_polygonComponent) + _polygonComponent.destroy() + } + } + + Component.onCompleted: { + _addPolygon() + } + + Component.onDestruction: { + _destroyPolygon() + } + + // Polygon component. + Component{ + id:polygon + + MapPolygon { + path: object.path; + border.color: "black" + color: "blue" + opacity: 0.25 + } + } +} diff --git a/src/WimaView/WimaJoinedAreaDataVisual.qml b/src/WimaView/WimaJoinedAreaDataVisual.qml new file mode 100644 index 000000000..8564d85f1 --- /dev/null +++ b/src/WimaView/WimaJoinedAreaDataVisual.qml @@ -0,0 +1,58 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtLocation 5.3 +import QtPositioning 5.3 + +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FlightMap 1.0 + +/// Wima Measurement Area Data visuals +Item { + id: _root + + property var map ///< Map control to place item in + property var qgcView ///< QGCView to use for popping dialogs + + property var areaItem: object + signal clicked(int sequenceNumber) + + property var _polygonComponent + + + function _addPolygon(){ + if(!_polygonComponent){ + _polygonComponent = polygon.createObject(_root) + map.addMapItem(_polygonComponent) + } + } + + function _destroyPolygon(){ + if(_polygonComponent){ + map.removeMapItem(_polygonComponent) + _polygonComponent.destroy() + } + } + + Component.onCompleted: { + _addPolygon() + } + + Component.onDestruction: { + _destroyPolygon() + } + + // Polygon component. + Component{ + id:polygon + + MapPolygon { + path: object.path; + border.color: "black" + color: "gray" + opacity: 0.25 + } + } +} diff --git a/src/WimaView/WimaMeasurementAreaDataVisual.qml b/src/WimaView/WimaMeasurementAreaDataVisual.qml new file mode 100644 index 000000000..f9bbb829f --- /dev/null +++ b/src/WimaView/WimaMeasurementAreaDataVisual.qml @@ -0,0 +1,124 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtLocation 5.3 +import QtPositioning 5.3 + +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FlightMap 1.0 + +/// Wima Measurement Area Data visuals +Item { + id: _root + + property var map ///< Map control to place item in + property var qgcView ///< QGCView to use for popping dialogs + + property var areaItem: object + signal clicked(int sequenceNumber) + + property var _polygonComponent + + + function _addPolygon(){ + if(!_polygonComponent){ + _polygonComponent = polygon.createObject(_root) + map.addMapItem(_polygonComponent) + } + } + + function _destroyPolygon(){ + if(_polygonComponent){ + map.removeMapItem(_polygonComponent) + _polygonComponent.destroy() + } + } + + Component.onCompleted: { + _addPolygon() + } + + Component.onDestruction: { + _destroyPolygon() + } + + // Add tiles. + Repeater { + id: progressRepeater + model: areaItem.tiles + + Item{ + property var _tileComponent + property int _progress: _root.areaItem.progress[index] ? + _root.areaItem.progress[index] : 0 + + Component.onCompleted: { + _tileComponent = tileComponent.createObject(map) + + _tileComponent.polygon.path = + Qt.binding(function(){return object.path}) + _tileComponent.polygon.opacity = 0.6 + _tileComponent.polygon.border.color = "black" + _tileComponent.polygon.border.width = 1 + _tileComponent.polygon.color = + Qt.binding(function(){return getColor(_progress)}) + } + + Component.onDestruction: { + _tileComponent.destroy() + } + + } + } + + // Polygon component. + Component{ + id:polygon + + MapPolygon { + path: object.path; + border.color: "black" + color: "green" + opacity: 0.25 + } + } + + // Tile component. + Component { + id: tileComponent + Item{ + id: root + + property MapPolygon polygon + + MapPolygon{ + id:mapPolygon + path: [] + } + + Component.onCompleted: { + polygon = mapPolygon + map.addMapItem(mapPolygon) + } + + Component.onDestruction: { + map.removeMapItem(mapPolygon) + } + } + } + + function getColor(progress) { + if (progress === 0) + return "transparent" + if (progress < 33) + return "orange" + if (progress < 66) + return "yellow" + if (progress < 100) + return "greenyellow" + return "limegreen" + } + +} diff --git a/src/WimaView/WimaServiceAreaDataVisual.qml b/src/WimaView/WimaServiceAreaDataVisual.qml new file mode 100644 index 000000000..705bebb29 --- /dev/null +++ b/src/WimaView/WimaServiceAreaDataVisual.qml @@ -0,0 +1,58 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtLocation 5.3 +import QtPositioning 5.3 + +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FlightMap 1.0 + +/// Wima Measurement Area Data visuals +Item { + id: _root + + property var map ///< Map control to place item in + property var qgcView ///< QGCView to use for popping dialogs + + property var areaItem: object + signal clicked(int sequenceNumber) + + property var _polygonComponent + + + function _addPolygon(){ + if(!_polygonComponent){ + _polygonComponent = polygon.createObject(_root) + map.addMapItem(_polygonComponent) + } + } + + function _destroyPolygon(){ + if(_polygonComponent){ + map.removeMapItem(_polygonComponent) + _polygonComponent.destroy() + } + } + + Component.onCompleted: { + _addPolygon() + } + + Component.onDestruction: { + _destroyPolygon() + } + + // Polygon component. + Component{ + id:polygon + + MapPolygon { + path: object.path; + border.color: "black" + color: "yellow" + opacity: 0.25 + } + } +} diff --git a/src/WimaView/WimaToolBar.qml b/src/WimaView/WimaToolBar.qml index 6aae85774..d3c007187 100644 --- a/src/WimaView/WimaToolBar.qml +++ b/src/WimaView/WimaToolBar.qml @@ -356,7 +356,8 @@ Rectangle { QGCButton { id: uploadButton text: qsTr("Upload") - enabled: true + enabled: wimaPlaner ? + wimaPlaner.readyForSynchronization : false onClicked: { if (wimaPlaner){ if (wimaPlaner.readyForSynchronization) { -- 2.22.0