Commit fb9b1767 authored by Valentin Platzgummer's avatar Valentin Platzgummer

plan creator added, area editor improved

parent 42fe8ce4
...@@ -195,5 +195,6 @@ ...@@ -195,5 +195,6 @@
<file alias="Yield.svg">src/ui/toolbar/Images/Yield.svg</file> <file alias="Yield.svg">src/ui/toolbar/Images/Yield.svg</file>
<file alias="ZoomMinus.svg">src/FlightMap/Images/ZoomMinus.svg</file> <file alias="ZoomMinus.svg">src/FlightMap/Images/ZoomMinus.svg</file>
<file alias="ZoomPlus.svg">src/FlightMap/Images/ZoomPlus.svg</file> <file alias="ZoomPlus.svg">src/FlightMap/Images/ZoomPlus.svg</file>
<file alias="PlanCreator/MeasurementPlanCreator.png">src/MeasurementComplexItem/MeasurementPlanCreator.png</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -447,6 +447,7 @@ contains (DEFINES, QGC_ENABLE_PAIRING) { ...@@ -447,6 +447,7 @@ contains (DEFINES, QGC_ENABLE_PAIRING) {
HEADERS += \ HEADERS += \
src/MeasurementComplexItem/IDArray.h \ src/MeasurementComplexItem/IDArray.h \
src/MeasurementComplexItem/LogicalArray.h \ src/MeasurementComplexItem/LogicalArray.h \
src/MeasurementComplexItem/MeasurementPlanCreator.h \
src/MeasurementComplexItem/TileArray.h \ src/MeasurementComplexItem/TileArray.h \
src/MeasurementComplexItem/TilePtrArray.h \ src/MeasurementComplexItem/TilePtrArray.h \
src/MeasurementComplexItem/geometry/ProgressArray.h \ src/MeasurementComplexItem/geometry/ProgressArray.h \
...@@ -527,6 +528,7 @@ contains (DEFINES, QGC_ENABLE_PAIRING) { ...@@ -527,6 +528,7 @@ contains (DEFINES, QGC_ENABLE_PAIRING) {
} }
SOURCES += \ SOURCES += \
src/MeasurementComplexItem/MeasurementPlanCreator.cpp \
src/MeasurementComplexItem/geometry/GeoArea.cc \ src/MeasurementComplexItem/geometry/GeoArea.cc \
src/MeasurementComplexItem/geometry/MeasurementArea.cc \ src/MeasurementComplexItem/geometry/MeasurementArea.cc \
src/MeasurementComplexItem/geometry/SafeArea.cc \ src/MeasurementComplexItem/geometry/SafeArea.cc \
......
#include "MeasurementPlanCreator.h"
#include "MeasurementComplexItem.h"
#include "PlanMasterController.h"
MeasurementPlanCreator::MeasurementPlanCreator(
PlanMasterController *planMasterController, QObject *parent)
: PlanCreator(
planMasterController, MeasurementComplexItem::name,
QStringLiteral("/qmlimages/PlanCreator/MeasurementPlanCreator.png"),
parent) {}
void MeasurementPlanCreator::createPlan(const QGeoCoordinate &mapCenterCoord) {
_planMasterController->removeAll();
VisualMissionItem *takeoffItem =
_missionController->insertTakeoffItem(mapCenterCoord, -1);
_missionController->insertComplexMissionItem(MeasurementComplexItem::name,
mapCenterCoord, -1);
_missionController->insertLandItem(mapCenterCoord, -1);
_missionController->setCurrentPlanViewSeqNum(takeoffItem->sequenceNumber(),
true);
}
#ifndef MEASUREMENTCOMPLEXITEMPLANCREATOR_H
#define MEASUREMENTCOMPLEXITEMPLANCREATOR_H
#include "PlanCreator.h"
class MeasurementPlanCreator : public PlanCreator {
Q_OBJECT
public:
MeasurementPlanCreator(PlanMasterController *planMasterController,
QObject *parent = nullptr);
Q_INVOKABLE void createPlan(const QGeoCoordinate &mapCenterCoord) final;
};
#endif // MEASUREMENTCOMPLEXITEMPLANCREATOR_H
...@@ -251,7 +251,7 @@ std::shared_future<QVariant> ...@@ -251,7 +251,7 @@ std::shared_future<QVariant>
NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) { NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
using namespace nemo_interface; using namespace nemo_interface;
qDebug() << "addTiles called"; // qDebug() << "addTiles called";
if (tileArray.size() > 0) { if (tileArray.size() > 0) {
...@@ -318,7 +318,7 @@ std::shared_future<QVariant> ...@@ -318,7 +318,7 @@ std::shared_future<QVariant>
NemoInterface::Impl::removeTiles(const IDArray &idArray) { NemoInterface::Impl::removeTiles(const IDArray &idArray) {
using namespace nemo_interface; using namespace nemo_interface;
qDebug() << "removeTiles called"; // qDebug() << "removeTiles called";
if (idArray.size() > 0) { if (idArray.size() > 0) {
...@@ -364,7 +364,7 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) { ...@@ -364,7 +364,7 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
std::shared_future<QVariant> NemoInterface::Impl::clearTiles() { std::shared_future<QVariant> NemoInterface::Impl::clearTiles() {
using namespace nemo_interface; using namespace nemo_interface;
qDebug() << "clearTiles called"; // qDebug() << "clearTiles called";
// clear local tiles (_localTiles) // clear local tiles (_localTiles)
if (!_localTiles.empty()) { if (!_localTiles.empty()) {
...@@ -396,6 +396,18 @@ std::shared_future<QVariant> NemoInterface::Impl::clearTiles() { ...@@ -396,6 +396,18 @@ std::shared_future<QVariant> NemoInterface::Impl::clearTiles() {
TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const { TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const {
TileArray tileArray; TileArray tileArray;
if (this->ready()) {
for (const auto &id : idArray) {
const auto it = _remoteTiles.find(id);
if (it != _remoteTiles.end()) {
MeasurementTile copy;
copy.setId(it->second->id());
copy.setProgress(it->second->progress());
copy.setPath(it->second->tile());
tileArray.append(std::move(copy));
}
}
} else {
for (const auto &id : idArray) { for (const auto &id : idArray) {
const auto it = _localTiles.find(id); const auto it = _localTiles.find(id);
if (it != _localTiles.end()) { if (it != _localTiles.end()) {
...@@ -406,6 +418,7 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const { ...@@ -406,6 +418,7 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const {
tileArray.append(std::move(copy)); tileArray.append(std::move(copy));
} }
} }
}
return tileArray; return tileArray;
} }
...@@ -413,6 +426,17 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const { ...@@ -413,6 +426,17 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const {
TileArray NemoInterface::Impl::getAllTiles() const { TileArray NemoInterface::Impl::getAllTiles() const {
TileArray tileArray; TileArray tileArray;
if (this->ready()) {
for (const auto &entry : _remoteTiles) {
auto pTile = entry.second;
MeasurementTile copy;
copy.setId(pTile->id());
copy.setProgress(pTile->progress());
copy.setPath(pTile->tile());
tileArray.append(std::move(copy));
}
} else {
for (const auto &entry : _localTiles) { for (const auto &entry : _localTiles) {
auto pTile = entry.second; auto pTile = entry.second;
MeasurementTile copy; MeasurementTile copy;
...@@ -421,6 +445,7 @@ TileArray NemoInterface::Impl::getAllTiles() const { ...@@ -421,6 +445,7 @@ TileArray NemoInterface::Impl::getAllTiles() const {
copy.setPath(pTile->tile()); copy.setPath(pTile->tile());
tileArray.append(std::move(copy)); tileArray.append(std::move(copy));
} }
}
return tileArray; return tileArray;
} }
...@@ -518,7 +543,7 @@ const QString &NemoInterface::Impl::warningString() const { ...@@ -518,7 +543,7 @@ const QString &NemoInterface::Impl::warningString() const {
void NemoInterface::Impl::_updateProgress(std::shared_ptr<ProgressArray> pArray, void NemoInterface::Impl::_updateProgress(std::shared_ptr<ProgressArray> pArray,
std::promise<bool> promise) { std::promise<bool> promise) {
qDebug() << "_updateProgress called"; // qDebug() << "_updateProgress called";
bool error = false; bool error = false;
for (auto itLP = pArray->begin(); itLP != pArray->end();) { for (auto itLP = pArray->begin(); itLP != pArray->end();) {
...@@ -799,7 +824,7 @@ void NemoInterface::Impl::_doAction() { ...@@ -799,7 +824,7 @@ void NemoInterface::Impl::_doAction() {
QVariant NemoInterface::Impl::_callAddTiles( QVariant NemoInterface::Impl::_callAddTiles(
std::shared_ptr<QVector<std::shared_ptr<const Tile>>> pTileArray) { std::shared_ptr<QVector<std::shared_ptr<const Tile>>> pTileArray) {
qDebug() << "_callAddTiles called"; // qDebug() << "_callAddTiles called";
this->_lastCall = CALL_NAME::ADD_TILES; this->_lastCall = CALL_NAME::ADD_TILES;
...@@ -900,7 +925,7 @@ QVariant NemoInterface::Impl::_callAddTiles( ...@@ -900,7 +925,7 @@ QVariant NemoInterface::Impl::_callAddTiles(
QVariant QVariant
NemoInterface::Impl::_callRemoveTiles(std::shared_ptr<IDArray> pIdArray) { NemoInterface::Impl::_callRemoveTiles(std::shared_ptr<IDArray> pIdArray) {
qDebug() << "_callRemoveTiles called"; // qDebug() << "_callRemoveTiles called";
this->_lastCall = CALL_NAME::REMOVE_TILES; this->_lastCall = CALL_NAME::REMOVE_TILES;
...@@ -995,7 +1020,7 @@ NemoInterface::Impl::_callRemoveTiles(std::shared_ptr<IDArray> pIdArray) { ...@@ -995,7 +1020,7 @@ NemoInterface::Impl::_callRemoveTiles(std::shared_ptr<IDArray> pIdArray) {
QVariant NemoInterface::Impl::_callClearTiles() { QVariant NemoInterface::Impl::_callClearTiles() {
qDebug() << "_callClearTiles called"; // qDebug() << "_callClearTiles called";
this->_lastCall = CALL_NAME::CLEAR_TILES; this->_lastCall = CALL_NAME::CLEAR_TILES;
// create response handler. // create response handler.
...@@ -1068,7 +1093,7 @@ QVariant NemoInterface::Impl::_callClearTiles() { ...@@ -1068,7 +1093,7 @@ QVariant NemoInterface::Impl::_callClearTiles() {
QVariant QVariant
NemoInterface::Impl::_callGetProgress(std::shared_ptr<IDArray> pIdArray) { NemoInterface::Impl::_callGetProgress(std::shared_ptr<IDArray> pIdArray) {
qDebug() << "_callGetProgress called"; // qDebug() << "_callGetProgress called";
this->_lastCall = CALL_NAME::GET_PROGRESS; this->_lastCall = CALL_NAME::GET_PROGRESS;
...@@ -1168,7 +1193,7 @@ NemoInterface::Impl::_callGetProgress(std::shared_ptr<IDArray> pIdArray) { ...@@ -1168,7 +1193,7 @@ NemoInterface::Impl::_callGetProgress(std::shared_ptr<IDArray> pIdArray) {
} }
QVariant NemoInterface::Impl::_callGetAllProgress() { QVariant NemoInterface::Impl::_callGetAllProgress() {
qDebug() << "_callGetAllProgress called"; // qDebug() << "_callGetAllProgress called";
this->_lastCall = CALL_NAME::GET_ALL_PROGRESS; this->_lastCall = CALL_NAME::GET_ALL_PROGRESS;
...@@ -1279,7 +1304,7 @@ void NemoInterface::Impl::_addTilesRemote( ...@@ -1279,7 +1304,7 @@ void NemoInterface::Impl::_addTilesRemote(
std::shared_ptr<QVector<std::shared_ptr<const Tile>>> pTileArray, std::shared_ptr<QVector<std::shared_ptr<const Tile>>> pTileArray,
std::promise<bool> promise) { std::promise<bool> promise) {
qDebug() << "_addTilesRemote called"; // qDebug() << "_addTilesRemote called";
auto pArrayDup = std::make_shared<QVector<std::shared_ptr<Tile>>>(); auto pArrayDup = std::make_shared<QVector<std::shared_ptr<Tile>>>();
for (auto pTile : *pTileArray) { for (auto pTile : *pTileArray) {
...@@ -1292,7 +1317,7 @@ void NemoInterface::Impl::_addTilesRemote2( ...@@ -1292,7 +1317,7 @@ void NemoInterface::Impl::_addTilesRemote2(
std::shared_ptr<QVector<std::shared_ptr<Tile>>> pTileArray, std::shared_ptr<QVector<std::shared_ptr<Tile>>> pTileArray,
std::promise<bool> promise) { std::promise<bool> promise) {
qDebug() << "_addTilesRemote2 called"; // qDebug() << "_addTilesRemote2 called";
bool anyChange = false; bool anyChange = false;
bool error = false; bool error = false;
...@@ -1326,7 +1351,7 @@ void NemoInterface::Impl::_addTilesRemote2( ...@@ -1326,7 +1351,7 @@ void NemoInterface::Impl::_addTilesRemote2(
void NemoInterface::Impl::_removeTilesRemote(std::shared_ptr<IDArray> idArray, void NemoInterface::Impl::_removeTilesRemote(std::shared_ptr<IDArray> idArray,
std::promise<bool> promise) { std::promise<bool> promise) {
qDebug() << "_removeTilesRemote called"; // qDebug() << "_removeTilesRemote called";
bool anyChange = false; bool anyChange = false;
for (const auto id : *idArray) { for (const auto id : *idArray) {
...@@ -1351,7 +1376,7 @@ void NemoInterface::Impl::_removeTilesRemote(std::shared_ptr<IDArray> idArray, ...@@ -1351,7 +1376,7 @@ void NemoInterface::Impl::_removeTilesRemote(std::shared_ptr<IDArray> idArray,
} }
void NemoInterface::Impl::_clearTilesRemote(std::promise<bool> promise) { void NemoInterface::Impl::_clearTilesRemote(std::promise<bool> promise) {
qDebug() << "_clearTilesRemote called"; // qDebug() << "_clearTilesRemote called";
if (_remoteTiles.size() > 0) { if (_remoteTiles.size() > 0) {
_remoteTiles.clear(); _remoteTiles.clear();
if (this->_isSynchronized()) { if (this->_isSynchronized()) {
......
...@@ -12,44 +12,62 @@ import QGroundControl.Palette 1.0 ...@@ -12,44 +12,62 @@ import QGroundControl.Palette 1.0
Rectangle { Rectangle {
id: _root id: _root
width: mainGrid.width width: mainColumn.width
height: mainGrid.height height: mainColumn.height
color: qgcPal.windowShadeDark color: qgcPal.windowShadeDark
property bool checked: true property bool editing: missionItem.editing
property var missionItem: undefined property var missionItem: undefined
property int availableWidth: 300 property int availableWidth: 300
property bool areasCorrect: false property bool areasCorrect: false
property string errorString: "" property string errorString: ""
signal abort
property var _areaData: missionItem.areaData property var _areaData: missionItem.areaData
property real _margin: ScreenTools.defaultFontPixelWidth / 2 property real _margin: ScreenTools.defaultFontPixelWidth / 2
Component.onCompleted: { Component.onCompleted: {
console.assert(missionItem !== undefined, console.assert(missionItem !== undefined,
"please set the missionItem property") "please set the missionItem property")
if (checked) { if (editing) {
areasCorrectTimer.start() areasCorrectTimer.start()
} }
} }
onCheckedChanged: { onEditingChanged: {
if (checked) { if (editing){
areasCorrectTimer.start() areasCorrectTimer.start()
} else { } else {
areasCorrectTimer.stop() areasCorrectTimer.stop()
} }
} }
ColumnLayout {
id: mainColumn
width: availableWidth
spacing: _margin
QGCButton {
id: editButton
text: _root.editing ? qsTr("Done") : qsTr("Edit")
enabled: (_root.editing && _root.areasCorrect) || !_root.editing
onClicked: {
if (_root.editing) {
_root.missionItem.stopEditing()
} else {
_root.missionItem.startEditing()
}
}
Layout.fillWidth: true
}
GridLayout { GridLayout {
id: mainGrid
width: availableWidth width: availableWidth
columnSpacing: _margin columnSpacing: _margin
Layout.fillWidth: true
rowSpacing: _margin rowSpacing: _margin
columns: 2 columns: 2
enabled: _root.editing
QGCLabel { QGCLabel {
text: _root.errorString text: _root.errorString
...@@ -73,7 +91,6 @@ Rectangle { ...@@ -73,7 +91,6 @@ Rectangle {
model: _missionItem.areaData.areaList model: _missionItem.areaData.areaList
delegate: QGCRadioButton { delegate: QGCRadioButton {
text: object.objectName text: object.objectName
checkable: _root.checked
Layout.fillWidth: true Layout.fillWidth: true
Layout.columnSpan: 2 Layout.columnSpan: 2
...@@ -88,7 +105,7 @@ Rectangle { ...@@ -88,7 +105,7 @@ Rectangle {
checked = true checked = true
} }
object.interactive = Qt.binding(function () { object.interactive = Qt.binding(function () {
return checked && _root.checked return checked && _root.editing && _missionItem.isCurrentItem
}) })
} }
} }
...@@ -116,19 +133,22 @@ Rectangle { ...@@ -116,19 +133,22 @@ Rectangle {
Component.onCompleted: { Component.onCompleted: {
if (geoArea.editorQML && !_visualItem) { if (geoArea.editorQML && !_visualItem) {
var component = Qt.createComponent(geoArea.editorQML) var component = Qt.createComponent(
geoArea.editorQML)
if (component.status === Component.Error) { if (component.status === Component.Error) {
console.log("Error loading Qml: ", console.log("Error loading Qml: ",
geoArea.editorQML, geoArea.editorQML,
component.errorString()) component.errorString())
} else { } else {
_visualItem = component.createObject(editorParent, { _visualItem = component.createObject(
editorParent, {
"geoArea": editor.geoArea, "geoArea": editor.geoArea,
"visible": Qt.binding( "visible": Qt.binding(
function () { function () {
return editor.visible return editor.visible
}), }),
"availableWidth": Qt.binding(function () { "availableWidth": Qt.binding(
function () {
return editorParent.width return editorParent.width
}) })
}) })
...@@ -161,7 +181,6 @@ Rectangle { ...@@ -161,7 +181,6 @@ Rectangle {
QGCButton { QGCButton {
text: "Intersection" text: "Intersection"
enabled: _root.checked
Layout.fillWidth: true Layout.fillWidth: true
Layout.columnSpan: parent.columns Layout.columnSpan: parent.columns
onClicked: { onClicked: {
...@@ -171,18 +190,11 @@ Rectangle { ...@@ -171,18 +190,11 @@ Rectangle {
QGCButton { QGCButton {
text: "Reset" text: "Reset"
onClicked: {
missionItem.reset()
}
Layout.fillWidth: true Layout.fillWidth: true
} Layout.columnSpan: parent.columns
QGCButton {
text: "Abort"
onClicked: { onClicked: {
_root.abort() missionItem.reset()
} }
Layout.fillWidth: true
} }
} }
...@@ -235,4 +247,5 @@ Use the Abort button to reset the areas and leave the tab.") ...@@ -235,4 +247,5 @@ Use the Abort button to reset the areas and leave the tab.")
property alias showHint: hintHeader.checked property alias showHint: hintHeader.checked
} }
} // GridLayout } // GridLayout
} // GridLayout
} // Rectangle } // Rectangle
...@@ -49,13 +49,12 @@ Rectangle { ...@@ -49,13 +49,12 @@ Rectangle {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
enabled: !editing || editing && correct enabled: !editing
readonly property int areaEditorIndex: 0 readonly property int areaEditorIndex: 0
readonly property int parameterEditorIndex: 1 readonly property int parameterEditorIndex: 1
readonly property int nemoEditorIndex: 2 readonly property int nemoEditorIndex: 2
property bool editing: _missionItem.editing property bool editing: _missionItem.editing
property bool correct: false
Component.onCompleted: currentIndex = editing ? areaEditorIndex : parameterEditorIndex Component.onCompleted: currentIndex = editing ? areaEditorIndex : parameterEditorIndex
...@@ -71,47 +70,18 @@ Rectangle { ...@@ -71,47 +70,18 @@ Rectangle {
icon.source: "qrc:/res/fish.svg" icon.source: "qrc:/res/fish.svg"
icon.height: ScreenTools.defaultFontPixelHeight icon.height: ScreenTools.defaultFontPixelHeight
} }
onEditingChanged: {
if (editing) {
areasCorrectTimer.start()
} else {
areasCorrectTimer.stop()
}
}
onCurrentIndexChanged: {
if (currentIndex === areaEditorIndex) {
_missionItem.startEditing()
} else {
_missionItem.stopEditing()
}
}
Timer {
id: areasCorrectTimer
running: false
interval: 100
repeat: true
onTriggered: {
tabBar.correct = _missionItem.areaData.isCorrect(
false /*show gui message*/
)
}
}
} }
MCI.AreaDataEditor { MCI.AreaDataEditor {
id: areaEditor id: areaEditor
visible: tabBar.currentIndex === tabBar.areaEditorIndex visible: tabBar.currentIndex === tabBar.areaEditorIndex
checked: visible
missionItem: _root._missionItem missionItem: _root._missionItem
availableWidth: mainColumn.width availableWidth: mainColumn.width
onAbort: { onVisibleChanged:{
missionItem.abortEditing() if (visible){
tabBar.currentIndex = tabBar.parameterEditorIndex _missionItem.startEditing()
}
} }
} }
...@@ -119,7 +89,6 @@ Rectangle { ...@@ -119,7 +89,6 @@ Rectangle {
id: parameterEditor id: parameterEditor
visible: tabBar.currentIndex === tabBar.parameterEditorIndex visible: tabBar.currentIndex === tabBar.parameterEditorIndex
checked: visible
missionItem: _root._missionItem missionItem: _root._missionItem
availableWidth: mainColumn.width availableWidth: mainColumn.width
} }
...@@ -128,7 +97,6 @@ Rectangle { ...@@ -128,7 +97,6 @@ Rectangle {
id: nemoEditor id: nemoEditor
visible: tabBar.currentIndex === tabBar.nemoEditorIndex visible: tabBar.currentIndex === tabBar.nemoEditorIndex
checked: visible
missionItem: _root._missionItem missionItem: _root._missionItem
availableWidth: mainColumn.width availableWidth: mainColumn.width
} }
......
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