...
 
Commits (7)
#include "MeasurementComplexItem.h"
#include "AreaData.h"
#include "CircularGenerator.h"
#include "LinearGenerator.h"
#include "NemoInterface.h"
......@@ -331,8 +332,7 @@ bool MeasurementComplexItem::load(const QJsonObject &complexObject,
const auto jsonVariant = valueRef.toArray();
Variant variant;
QString e;
if (JsonHelper::loadGeoCoordinateArray(jsonVariant, false, variant,
e)) {
if (JsonHelper::loadGeoCoordinateArray(jsonVariant, true, variant, e)) {
if (variant.size() > 0) {
variantVector.append(std::move(variant));
} else {
......@@ -496,7 +496,7 @@ void MeasurementComplexItem::save(QJsonArray &planItems) {
// Variant names.
QJsonArray jsonVariantNames;
for (auto const &name : _variantNames) {
for (auto &&name : _variantNames) {
jsonVariantNames.append(name);
}
saveObject[variantNamesKey] = jsonVariantNames;
......@@ -533,9 +533,9 @@ void MeasurementComplexItem::save(QJsonArray &planItems) {
for (auto const &route : _variantVector) {
QJsonValue variant;
if (route.size() > 0) {
JsonHelper::saveGeoCoordinateArray(route, false, variant);
JsonHelper::saveGeoCoordinateArray(route, true, variant);
} else {
JsonHelper::saveGeoCoordinateArray(_route, false, variant);
JsonHelper::saveGeoCoordinateArray(_route, true, variant);
}
variantsArray.append(variant);
}
......@@ -1208,7 +1208,7 @@ bool MeasurementComplexItem::stopEditing(bool doUpdate) {
_updateRoute();
}
if (correct && isDifferent) {
if (correct) {
_syncTiles();
}
......
......@@ -9,9 +9,9 @@
#include "QGCQGeoCoordinate.h"
#include "SettingsFact.h"
#include "AreaData.h"
#include "geometry/ProgressArray.h"
class AreaData;
class RoutingThread;
class RoutingResult;
......
......@@ -13,8 +13,6 @@
#include "TilePtrArray.h"
#include "geometry/ProgressArray.h"
// Singelton class used to interface measurement devices implementing the nemo
// interface.
class NemoInterface : public QObject {
Q_OBJECT
class Impl;
......
......@@ -40,8 +40,15 @@ bool GeoArea::loadFromJson(const QJsonObject &json, QString &errorString) {
errorString)) {
qWarning() << errorString;
return false;
}
} else {
// set altitude to 0
for (int i = 0; i < this->count(); ++i) {
auto vertex = this->vertexCoordinate(i);
vertex.setAltitude(0);
this->adjustVertex(i, vertex);
}
}
return true;
}
......
......@@ -15,6 +15,8 @@
#include "QGCLoggingCategory.h"
#include "QmlObjectListHelper.h"
#include "MeasurementComplexItem/nemo_interface/MeasurementTile.h"
#ifndef MAX_TILES
#define MAX_TILES 1000
#endif
......@@ -324,7 +326,13 @@ bool MeasurementArea::loadFromJson(const QJsonObject &json,
bool MeasurementArea::isCorrect() {
if (GeoArea::isCorrect()) {
if (ready()) {
return true;
if (_tiles->count() > 0) {
return true;
} else {
setErrorString(tr("Not able to create tiles. This indicates that the "
"tile parameters must be adjusted. Reducing the Min. "
"Area parameter might deliver the desired result."));
}
} else if (_toManyTiles) {
setErrorString(
tr("Calculation would yield to many tiles, please adjust the tile "
......@@ -602,27 +610,6 @@ void MeasurementArea::setState(MeasurementArea::STATE s) {
}
}
void MeasurementArea::updateIds(const QList<TileDiff> &array) {
for (const auto &diff : array) {
auto it = _indexMap.find(diff.oldTile.id());
if (it != _indexMap.end()) {
int tileIndex = it->second;
auto *tile = _tiles->value<MeasurementTile *>(tileIndex);
if (diff.oldTile.coordinateList() == tile->coordinateList()) {
// Change id and update _tileMap.
const auto newId = diff.newTile.id();
tile->setId(newId);
_indexMap.erase(it);
auto ret = _indexMap.insert(std::make_pair(newId, tileIndex));
Q_ASSERT(ret.second == true /*insert success?*/);
Q_UNUSED(ret);
}
}
}
}
bool getTiles(const FPolygon &area, Length tileHeight, Length tileWidth,
Area minTileArea, std::vector<FPolygon> &tiles,
BoundingBox &bbox) {
......@@ -646,8 +633,10 @@ bool getTiles(const FPolygon &area, Length tileHeight, Length tileWidth,
minimalBoundingBox(area, bbox);
}
if (bbox.corners.outer().size() < 5)
if (bbox.corners.outer().size() < 5) {
return false;
}
double bboxWidth = bbox.width;
double bboxHeight = bbox.height;
FPoint origin = bbox.corners.outer()[0];
......
......@@ -6,10 +6,8 @@
#include <QTimer>
#include "GeoArea.h"
#include "MeasurementComplexItem/nemo_interface/MeasurementTile.h"
#include "ProgressArray.h"
#include "TileDiff.h"
#include "ProgressArray.h"
#include "SettingsFact.h"
class MeasurementArea : public GeoArea {
......@@ -61,7 +59,6 @@ signals:
void progressChanged();
public slots:
void updateIds(const QList<TileDiff> &array);
void updateProgress(const ProgressArray &array);
Q_INVOKABLE void randomProgress();
Q_INVOKABLE void resetProgress();
......
......@@ -2,7 +2,6 @@
#define PROGRESSARRAY_H
#include <QVector>
#include <tuple>
#include "comm/ros_bridge/include/messages/nemo_msgs/labeled_progress.h"
......
......@@ -52,11 +52,7 @@ void TaskDispatcher::start() {
ULock lk1(this->_mutex);
if (!_running) {
this->_running = true;
auto p = std::make_shared<std::promise<void>>();
_threadFuture = p->get_future();
QtConcurrent::run([this, p = std::move(p)]() mutable {
return this->run(std::move(*p));
});
QtConcurrent::run([this]() mutable { return this->run(); });
lk1.unlock();
}
}
......@@ -65,7 +61,6 @@ void TaskDispatcher::stop() {
ULock lk1(this->_mutex);
if (_running) {
this->_running = false;
_threadFuture.wait();
lk1.unlock();
}
}
......@@ -92,7 +87,7 @@ std::size_t TaskDispatcher::pendingTasks() {
bool TaskDispatcher::idle() { return this->pendingTasks() == 0; }
void TaskDispatcher::run(std::promise<void> p) {
void TaskDispatcher::run() {
while (true) {
ULock lk1(this->_mutex);
......@@ -116,7 +111,6 @@ void TaskDispatcher::run(std::promise<void> p) {
break;
}
}
p.set_value();
}
} // namespace nemo_interface
......@@ -56,12 +56,11 @@ public:
bool idle();
protected:
void run(std::promise<void> p);
void run();
private:
std::deque<std::unique_ptr<Task>> _taskQueue;
std::deque<std::promise<QVariant>> _promiseQueue;
std::future<void> _threadFuture;
bool _running;
std::mutex _mutex;
};
......
......@@ -218,8 +218,8 @@ Rectangle {
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignLeft
text: qsTr("Use the Intersection button to clip the Measurement Area(s).
Use the Reset button to restore the areas to the state before entering this tab.
Use the Abort button to reset the areas and leave the tab.")
Use the Reset button to restore the areas to the state before entering this tab."
)
Layout.fillWidth: true
Layout.columnSpan: parent.columns
}
......
......@@ -43,6 +43,7 @@ Rectangle {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
QGCTabBar {
id: tabBar
......@@ -78,11 +79,6 @@ Rectangle {
visible: tabBar.currentIndex === tabBar.areaEditorIndex
missionItem: _root._missionItem
availableWidth: mainColumn.width
onVisibleChanged:{
if (visible){
_missionItem.startEditing()
}
}
}
MCI.ParameterEditor {
......
......@@ -179,7 +179,7 @@ Rectangle {
id: hintLabel
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignLeft
text: qsTr("Use this tab to connect to a device implementing the Nemo Interface.
text: qsTr("Use this tab to connect to a device implementing the Nemointerface.
Use the Random button to simulate measurement progress.")
Layout.fillWidth: true
Layout.columnSpan: parent.columns
......
......@@ -105,7 +105,7 @@ template <class T> bool toJson(const T &p, QJsonObject &value) {
p, traits::Type2Type<Components>()); // If T has no member altitude()
// replace it by 0.0;
value[altKey] = altitude;
value[altKey] = double(altitude);
return true;
}
......