Commit 9d2ac99e authored by Valentin Platzgummer's avatar Valentin Platzgummer

generators working, wima planer still issues

parent 67cbe3f7
......@@ -195,9 +195,9 @@
<file alias="QGroundControl/Controls/ViewWidget.qml">src/ViewWidgets/ViewWidget.qml</file>
<file alias="Wima/WimaAreaNoVisual.qml">src/Wima/Snake/WimaAreaNoVisual.qml</file>
<file alias="CircularGeneratorEditor.qml">src/WimaView/CircularGeneratorEditor.qml</file>
<file alias="Wima/CircularGeneratorMapVisual.qml">src/WimaView/CircularGeneratorMapVisual.qml</file>
<file alias="QGroundControl/Controls/CircularGeneratorMapVisual.qml">src/WimaView/CircularGeneratorMapVisual.qml</file>
<file alias="CircularSurveyItemEditor.qml">src/WimaView/CircularSurveyItemEditor.qml</file>
<file alias="Wima/CircularSurveyMapVisual.qml">src/WimaView/CircularSurveyMapVisual.qml</file>
<file alias="QGroundControl/Controls/CircularSurveyMapVisual.qml">src/WimaView/CircularSurveyMapVisual.qml</file>
<file alias="Wima/CoordinateIndicator.qml">src/WimaView/CoordinateIndicator.qml</file>
<file alias="Wima/CoordinateIndicatorDrag.qml">src/WimaView/CoordinateIndicatorDrag.qml</file>
<file alias="Wima/DragCoordinate.qml">src/WimaView/DragCoordinate.qml</file>
......
......@@ -30,5 +30,9 @@ MapItemView {
object.coordinate1,
object.coordinate2,
] : []
// onParentChanged: {
// console.log("MapItemView, path:" + path)
// }
}
}
......@@ -15,7 +15,7 @@ import QtPositioning 5.3
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import Wima 1.0
/// Mission item map visual
Item {
......
This diff is collapsed.
......@@ -104,7 +104,6 @@ private slots:
void _updateWorker();
void _changeVariantWorker();
void _reverseWorker();
void _storeWorker();
private:
void _appendLoadedMissionItems(QList<MissionItem *> &items,
......@@ -117,7 +116,7 @@ private:
// State.
enum class STATE {
IDLE,
STORE,
SKIPP,
REVERSE,
VARIANT_CHANGE,
RUN_CHANGE,
......@@ -137,11 +136,8 @@ private:
QStringList _generatorNameList;
PtrGenerator _pGenerator;
// Worker
PtrWorker _pWorker;
PtrRoutingData _pRoutingData; // remove this, not necessary.
// Routing data.
// Routing.
using Variant = Transects;
QVector<Variant> _variantVector;
PtrWorker _pWorker;
};
......@@ -2,7 +2,14 @@
WimaAreaData::WimaAreaData(QObject *parent) : QObject(parent) {}
WimaAreaData::~WimaAreaData() {}
WimaAreaData::WimaAreaData(const WimaAreaData &other, QObject *parent)
: QObject(parent), _path(other._path), _list(other._list),
_center(other._center) {}
WimaAreaData::WimaAreaData(const WimaArea &otherData, QObject *parent)
: QObject(parent), _center(otherData.center()) {
_setPathImpl(otherData.path());
}
bool WimaAreaData::operator==(const WimaAreaData &data) const {
return this->_path == data._path && this->_center == data._center;
......@@ -25,7 +32,7 @@ bool WimaAreaData::containsCoordinate(const QGeoCoordinate &coordinate) const {
using namespace PolygonCalculus;
using namespace GeoUtilities;
if (_path.size() > 2) {
if (this->coordinateList().size() > 2) {
QPolygonF polygon;
toCartesianList(this->coordinateList(), coordinate, polygon);
return PlanimetryCalculus::contains(polygon, QPointF(0, 0));
......@@ -36,44 +43,60 @@ bool WimaAreaData::containsCoordinate(const QGeoCoordinate &coordinate) const {
void WimaAreaData::append(const QGeoCoordinate &c) {
_list.append(c);
_path.push_back(QVariant::fromValue(c));
emit pathChanged();
}
void WimaAreaData::push_back(const QGeoCoordinate &c) { append(c); }
void WimaAreaData::clear() {
_list.clear();
_path.clear();
if (_list.size() > 0 || _path.size() > 0) {
_list.clear();
_path.clear();
emit pathChanged();
}
}
void WimaAreaData::setPath(const QVariantList &coordinateList) {
_path = coordinateList;
_list.clear();
for (auto variant : coordinateList) {
_list.push_back(variant.value<QGeoCoordinate>());
if (_path != coordinateList) {
_setPathImpl(coordinateList);
emit pathChanged();
}
}
void WimaAreaData::setCenter(const QGeoCoordinate &center) {
if (_center != center) {
_center = center;
emit centerChanged();
}
}
/*!
* \fn void WimaAreaData::assign(const WimaAreaData &other)
*
* Assigns \a other to the invoking object
*/
void WimaAreaData::assign(const WimaAreaData &other) {
setPath(other.path());
setCenter(other.center());
WimaAreaData &WimaAreaData::operator=(const WimaAreaData &otherData) {
setPath(otherData._list);
setCenter(otherData._center);
return *this;
}
void WimaAreaData::assign(const WimaArea &other) {
setPath(other.path());
setCenter(other.center());
WimaAreaData &WimaAreaData::operator=(const WimaArea &otherData) {
setPath(otherData.path());
setCenter(otherData.center());
return *this;
}
void WimaAreaData::_setPathImpl(const QList<QGeoCoordinate> &coordinateList) {
_list = coordinateList;
_path.clear();
// copy all coordinates to _path
for (const auto &vertex : coordinateList) {
_path.append(QVariant::fromValue(vertex));
}
}
void WimaAreaData::_setPathImpl(const QVariantList &coordinateList) {
_path = coordinateList;
_list.clear();
for (const auto &variant : coordinateList) {
_list.push_back(variant.value<QGeoCoordinate>());
}
}
/*!
......@@ -83,24 +106,26 @@ void WimaAreaData::assign(const WimaArea &other) {
* coordinateList. Emits the \c pathChanged() signal.
*/
void WimaAreaData::setPath(const QList<QGeoCoordinate> &coordinateList) {
_list = coordinateList;
_path.clear();
// copy all coordinates to _path
for (int i = 0; i < coordinateList.size(); i++) {
_path.append(QVariant::fromValue(coordinateList.value(i)));
if (_list != coordinateList) {
_setPathImpl(coordinateList);
emit pathChanged();
}
emit pathChanged(_path);
}
bool operator==(const WimaAreaData &m1, const WimaArea &m2) {
return m1.path() == m2.path() && m1.center() == m2.center();
}
bool operator!=(const WimaAreaData &m1, const WimaArea &m2) {
return !operator==(m1, m2);
}
bool operator==(const WimaArea &m1, const WimaAreaData &m2) { return m2 == m1; }
bool operator!=(const WimaArea &m1, const WimaAreaData &m2) {
return !operator==(m2, m1);
}
/*!
* \class WimaArea::WimaAreaData
* \brief Class to store and exchange data of a \c WimaArea Object.
......
#pragma once
#pragma once
#include <QObject>
......@@ -11,16 +11,12 @@ class WimaAreaData
{
Q_OBJECT
public:
WimaAreaData(QObject *parent = nullptr);
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();
WimaAreaData(const WimaAreaData &otherData) = delete; // avoid slicing
WimaAreaData &
operator=(const WimaAreaData &otherData) = delete; // avoid slicing
bool operator==(const WimaAreaData &data) const;
bool operator!=(const WimaAreaData &data) const;
......@@ -37,8 +33,8 @@ public:
void clear();
signals:
void pathChanged(const QVariantList &coordinateList);
void centerChanged(void);
void pathChanged();
void centerChanged();
public slots:
void setPath(const QList<QGeoCoordinate> &coordinateList);
......@@ -46,18 +42,21 @@ public slots:
void setCenter(const QGeoCoordinate &center);
protected:
void assign(const WimaAreaData &other);
void assign(const WimaArea &other);
WimaAreaData(const WimaAreaData &otherData, QObject *parent);
WimaAreaData(const WimaArea &otherData, QObject *parent);
WimaAreaData &operator=(const WimaAreaData &otherData);
WimaAreaData &operator=(const WimaArea &otherData);
private:
// Member Functions
void _setPathImpl(const QList<QGeoCoordinate> &coordinateList);
void _setPathImpl(const QVariantList &coordinateList);
// Member Variables
// see WimaArea.h for explanation
QVariantList _path;
mutable QList<QGeoCoordinate> _list;
mutable QVariantList _path;
QList<QGeoCoordinate> _list;
QGeoCoordinate _center;
};
bool operator==(const WimaAreaData &m1, const WimaArea &m2);
bool operator!=(const WimaAreaData &m1, const WimaArea &m2);
bool operator==(const WimaArea &m1, const WimaAreaData &m2);
bool operator!=(const WimaArea &m1, const WimaAreaData &m2);
......@@ -6,14 +6,10 @@ WimaCorridorData::WimaCorridorData(QObject *parent) : WimaAreaData(parent) {}
WimaCorridorData::WimaCorridorData(const WimaCorridorData &other,
QObject *parent)
: WimaAreaData(parent) {
*this = other;
}
: WimaAreaData(other, parent) {}
WimaCorridorData::WimaCorridorData(const WimaCorridor &other, QObject *parent)
: WimaAreaData(parent) {
*this = other;
}
: WimaAreaData(other, parent) {}
/*!
* \overload operator=()
......@@ -21,8 +17,7 @@ WimaCorridorData::WimaCorridorData(const WimaCorridor &other, QObject *parent)
* Assigns \a other to the invoking object.
*/
WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other) {
this->assign(other);
WimaAreaData::operator=(other);
return *this;
}
......@@ -32,8 +27,7 @@ WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other) {
* Assigns \a other to the invoking object.
*/
WimaCorridorData &WimaCorridorData::operator=(const WimaCorridor &other) {
this->assign(other);
WimaAreaData::operator=(other);
return *this;
}
......@@ -43,14 +37,6 @@ QString WimaCorridorData::mapVisualQML() const {
QString WimaCorridorData::type() const { return this->typeString; }
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.
......
......@@ -23,14 +23,4 @@ public:
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);
private:
};
......@@ -7,15 +7,11 @@ WimaJoinedAreaData::WimaJoinedAreaData(QObject *parent)
WimaJoinedAreaData::WimaJoinedAreaData(const WimaJoinedAreaData &other,
QObject *parent)
: WimaAreaData(parent) {
*this = other;
}
: WimaAreaData(other, parent) {}
WimaJoinedAreaData::WimaJoinedAreaData(const WimaJoinedArea &other,
QObject *parent)
: WimaAreaData(parent) {
*this = other;
}
: WimaAreaData(other, parent) {}
/*!
* \overload operator=()
......@@ -24,8 +20,7 @@ WimaJoinedAreaData::WimaJoinedAreaData(const WimaJoinedArea &other,
*/
WimaJoinedAreaData &WimaJoinedAreaData::
operator=(const WimaJoinedAreaData &other) {
assign(other);
WimaAreaData::operator=(other);
return *this;
}
......@@ -35,7 +30,7 @@ operator=(const WimaJoinedAreaData &other) {
* Assigns \a other to the invoking object.
*/
WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedArea &other) {
assign(other);
WimaAreaData::operator=(other);
return *this;
}
......@@ -45,14 +40,6 @@ QString WimaJoinedAreaData::mapVisualQML() const {
QString WimaJoinedAreaData::type() const { return this->typeString; }
void WimaJoinedAreaData::assign(const WimaJoinedAreaData &other) {
WimaAreaData::assign(other);
}
void WimaJoinedAreaData::assign(const WimaJoinedArea &other) {
WimaAreaData::assign(other);
}
/*!
* \class WimaAreaData::WimaJoinedAreaData
* \brief Class to store and exchange data of a \c WimaJoinedAreaData Object.
......
......@@ -24,10 +24,4 @@ public:
WimaJoinedAreaData *Clone() const { return new WimaJoinedAreaData(*this); }
static const char *typeString;
protected:
void assign(const WimaJoinedAreaData &other);
void assign(const WimaJoinedArea &other);
private:
};
......@@ -22,6 +22,7 @@ bool WimaMeasurementAreaData::
operator==(const WimaMeasurementAreaData &other) const {
return this->WimaAreaData::operator==(other) &&
this->_tileData == other.tileData() &&
this->_progress == other.progress() &&
this->center() == other.center();
}
......@@ -33,6 +34,8 @@ operator!=(const WimaMeasurementAreaData &other) const {
void WimaMeasurementAreaData::setTileData(const TileData &d) {
if (this->_tileData != d) {
this->_tileData = d;
this->_progress.fill(0, d.size());
emit progressChanged();
emit tileDataChanged();
}
}
......@@ -51,7 +54,9 @@ void WimaMeasurementAreaData::setProgress(const QVector<int> &d) {
*/
WimaMeasurementAreaData &WimaMeasurementAreaData::
operator=(const WimaMeasurementAreaData &other) {
assign(other);
WimaAreaData::operator=(other);
setTileData(other._tileData);
setProgress(other._progress);
return *this;
}
......@@ -63,7 +68,14 @@ operator=(const WimaMeasurementAreaData &other) {
*/
WimaMeasurementAreaData &WimaMeasurementAreaData::
operator=(const WimaMeasurementArea &other) {
assign(other);
WimaAreaData::operator=(other);
if (other.ready()) {
setTileData(other.tileData());
setProgress(other.progress());
} else {
qWarning() << "WimaMeasurementAreaData::operator=(): WimaMeasurementArea "
"not ready.";
}
return *this;
}
......@@ -102,23 +114,6 @@ const QVector<int> &WimaMeasurementAreaData::progress() const {
QVector<int> &WimaMeasurementAreaData::progress() { return this->_progress; }
void WimaMeasurementAreaData::assign(const WimaMeasurementAreaData &other) {
WimaAreaData::assign(other);
setTileData(other._tileData);
setProgress(other._progress);
}
void WimaMeasurementAreaData::assign(const WimaMeasurementArea &other) {
WimaAreaData::assign(other);
if (other.ready()) {
setTileData(other.tileData());
setProgress(other.progress());
} else {
qWarning()
<< "WimaMeasurementAreaData::assign(): WimaMeasurementArea not ready.";
}
}
bool operator==(const WimaMeasurementAreaData &m1,
const WimaMeasurementArea &m2) {
return operator==(*static_cast<const WimaAreaData *>(&m1),
......
......@@ -50,10 +50,6 @@ signals:
void tileDataChanged();
void progressChanged();
protected:
void assign(const WimaMeasurementAreaData &other);
void assign(const WimaMeasurementArea &other);
private:
TileData _tileData;
QVector<int> _progress;
......
......@@ -7,26 +7,22 @@ WimaServiceAreaData::WimaServiceAreaData(QObject *parent)
WimaServiceAreaData::WimaServiceAreaData(const WimaServiceAreaData &other,
QObject *parent)
: WimaAreaData(parent) {
*this = other;
}
: WimaAreaData(other, parent), _depot(other._depot) {}
WimaServiceAreaData::WimaServiceAreaData(const WimaServiceArea &other,
QObject *parent)
: WimaAreaData(parent) {
*this = other;
}
: WimaAreaData(other, parent), _depot(other.depot()) {}
WimaServiceAreaData &WimaServiceAreaData::
operator=(const WimaServiceAreaData &otherData) {
this->assign(otherData);
WimaAreaData::operator=(otherData);
this->setDepot(otherData.depot());
return *this;
}
WimaServiceAreaData &WimaServiceAreaData::
operator=(const WimaServiceArea &otherArea) {
this->assign(otherArea);
WimaAreaData::operator=(otherArea);
this->setDepot(otherArea.depot());
return *this;
}
......@@ -57,16 +53,6 @@ void WimaServiceAreaData::setDepot(const QGeoCoordinate &newCoordinate) {
}
}
void WimaServiceAreaData::assign(const WimaServiceAreaData &other) {
WimaAreaData::assign(other);
setDepot(other.depot());
}
void WimaServiceAreaData::assign(const WimaServiceArea &other) {
WimaAreaData::assign(other);
setDepot(other.depot());
}
/*!
* \class WimaAreaData::WimaServiceAreaData
* \brief Class to store and exchange data of a \c WimaServiceArea Object.
......
......@@ -31,10 +31,6 @@ signals:
public slots:
void setDepot(const QGeoCoordinate &newCoordinate);
protected:
void assign(const WimaServiceAreaData &other);
void assign(const WimaServiceArea &other);
private:
// see WimaServieArea.h for explanation
QGeoCoordinate _depot;
......
......@@ -5,7 +5,7 @@
#include <QDebug>
#include "QGCLoggingCategory.h"
QGC_LOGGING_CATEGORY(RoutingWorkerLog, "RoutingWorkerLog")
QGC_LOGGING_CATEGORY(RoutingThreadLog, "RoutingThreadLog")
RoutingThread::RoutingThread(QObject *parent)
: QThread(parent), _calculating(false), _stop(false), _restart(false) {
......@@ -44,10 +44,10 @@ void RoutingThread::route(const RoutingParameter &par,
}
void RoutingThread::run() {
qCWarning(RoutingWorkerLog) << "run(): thread start.";
qCDebug(RoutingThreadLog) << "run(): thread start.";
while (!this->_stop) {
qCWarning(RoutingWorkerLog) << "run(): calculation "
"started.";
qCDebug(RoutingThreadLog) << "run(): calculation "
"started.";
// Copy input.
auto start = std::chrono::high_resolution_clock::now();
......@@ -67,8 +67,8 @@ void RoutingThread::run() {
if (generator(transectsENU)) {
// Check if generation was successful.
if (transectsENU.size() == 0) {
qCWarning(RoutingWorkerLog) << "run(): "
"not able to generate transects.";
qCDebug(RoutingThreadLog) << "run(): "
"not able to generate transects.";
} else {
// Prepare data for routing.
auto &solutionVector = pRouteData->solutionVector;
......@@ -93,24 +93,24 @@ void RoutingThread::run() {
// Check if routing was successful.
if ((!success || solutionVector.size() < 1) && !this->_restart) {
qCWarning(RoutingWorkerLog) << "run(): "
"routing failed. "
<< snakePar.errorString.c_str();
qCDebug(RoutingThreadLog) << "run(): "
"routing failed. "
<< snakePar.errorString.c_str();
} else if (this->_restart) {
qCWarning(RoutingWorkerLog) << "run(): "
"restart requested.";
qCDebug(RoutingThreadLog) << "run(): "
"restart requested.";
} else {
// Notify main thread.
emit result(pRouteData);
qCWarning(RoutingWorkerLog) << "run(): "
"concurrent update success.";
qCDebug(RoutingThreadLog) << "run(): "
"concurrent update success.";
}
}
} // end calculation
else {
qCWarning(RoutingWorkerLog) << "run(): generator() failed.";
qCDebug(RoutingThreadLog) << "run(): generator() failed.";
}
qCWarning(RoutingWorkerLog)
qCDebug(RoutingThreadLog)
<< "run(): execution time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - start)
......@@ -125,5 +125,5 @@ void RoutingThread::run() {
}
this->_restart = false;
} // main loop
qCWarning(RoutingWorkerLog) << "run(): thread end.";
qCDebug(RoutingThreadLog) << "run(): thread end.";
}
......@@ -64,14 +64,14 @@ bool CircularGenerator::get(Generator &generator) {
auto origin = this->_d->origin();
origin.setAltitude(0);
if (!origin.isValid()) {
qCWarning(CircularGeneratorLog) << "get(): origin invalid." << origin;
qCDebug(CircularGeneratorLog) << "get(): origin invalid." << origin;
return false;
}
auto ref = this->_reference;
ref.setAltitude(0);
if (!ref.isValid()) {
qCWarning(CircularGeneratorLog) << "get(): reference invalid." << ref;
qCDebug(CircularGeneratorLog) << "get(): reference invalid." << ref;
return false;
}
snake::FPoint reference;
......@@ -82,9 +82,9 @@ bool CircularGenerator::get(Generator &generator) {
if (v.isValid()) {
v.setAltitude(0);
} else {
qCWarning(CircularGeneratorLog) << "get(): measurement area invalid.";
qCDebug(CircularGeneratorLog) << "get(): measurement area invalid.";
for (const auto &w : geoPolygon) {
qCWarning(CircularGeneratorLog) << w;
qCDebug(CircularGeneratorLog) << w;
}
return false;
}
......@@ -105,21 +105,21 @@ bool CircularGenerator::get(Generator &generator) {
snake::areaToEnu(origin, tile->coordinateList(), tileENU);
pTiles->push_back(std::move(tileENU));
} else {
qCWarning(CircularGeneratorLog)
qCDebug(CircularGeneratorLog)
<< "get(): progress.size() != tiles->count().";
return false;
}
}
}
} else {
qCWarning(CircularGeneratorLog)
qCDebug(CircularGeneratorLog)
<< "get(): progress.size() != tiles->count().";
return false;
}
auto geoDepot = this->_d->serviceArea().depot();
if (!geoDepot.isValid()) {
qCWarning(CircularGeneratorLog) << "get(): depot invalid." << geoDepot;
qCDebug(CircularGeneratorLog) << "get(): depot invalid." << geoDepot;
return false;
}
snake::FPoint depot;
......@@ -142,11 +142,11 @@ bool CircularGenerator::get(Generator &generator) {
};
return true;
} else {
qCWarning(CircularGeneratorLog) << "get(): data invalid.";
qCDebug(CircularGeneratorLog) << "get(): data invalid.";
return false;
}
} else {
qCWarning(CircularGeneratorLog) << "get(): data member not set.";
qCDebug(CircularGeneratorLog) << "get(): data member not set.";
return false;
}
}
......@@ -160,22 +160,29 @@ void CircularGenerator::setReference(const QGeoCoordinate &reference) {
}
}
void CircularGenerator::resetReferenceIfInvalid() {
if (!this->_reference.isValid()) {
resetReference();
}
}
void CircularGenerator::resetReference() {
setReference(_d->measurementArea().center());
if (this->_d->measurementArea().center().isValid()) {
setReference(this->_d->measurementArea().center());
}
}
void CircularGenerator::establishConnections() {
if (this->_d && !this->_connectionsEstablished) {
connect(this->_d.get(), &WimaPlanData::measurementAreaChanged, this,
&GeneratorBase::generatorChanged);
connect(this->_d.get(), &WimaPlanData::originChanged, this,
&GeneratorBase::generatorChanged);
connect(&this->_d->measurementArea(),
&WimaMeasurementAreaData::progressChanged, this,
&GeneratorBase::generatorChanged);
connect(&this->_d->measurementArea(),
&WimaMeasurementAreaData::tileDataChanged, this,
&GeneratorBase::generatorChanged);
connect(&this->_d->measurementArea(), &WimaMeasurementAreaData::pathChanged,
this, &CircularGenerator::resetReferenceIfInvalid);
connect(&this->_d->measurementArea(), &WimaMeasurementAreaData::pathChanged,
this, &GeneratorBase::generatorChanged);
connect(&this->_d->serviceArea(), &WimaServiceAreaData::depotChanged, this,
&GeneratorBase::generatorChanged);
connect(this->distance(), &Fact::rawValueChanged, this,
......@@ -192,8 +199,6 @@ void CircularGenerator::establishConnections() {
void CircularGenerator::deleteConnections() {
if (this->_d && this->_connectionsEstablished) {
disconnect(this->_d.get(), &WimaPlanData::measurementAreaChanged, this,
&GeneratorBase::generatorChanged);
disconnect(this->_d.get(), &WimaPlanData::originChanged, this,
&GeneratorBase::generatorChanged);
disconnect(&this->_d->measurementArea(),
......@@ -202,6 +207,12 @@ void CircularGenerator::deleteConnections() {
disconnect(&this->_d->measurementArea(),
&WimaMeasurementAreaData::tileDataChanged, this,
&GeneratorBase::generatorChanged);
disconnect(&this->_d->measurementArea(),
&WimaMeasurementAreaData::pathChanged, this,
&CircularGenerator::resetReferenceIfInvalid);
disconnect(&this->_d->measurementArea(),
&WimaMeasurementAreaData::pathChanged, this,
&GeneratorBase::generatorChanged);
disconnect(&this->_d->serviceArea(), &WimaServiceAreaData::depotChanged,
this, &GeneratorBase::generatorChanged);
disconnect(this->distance(), &Fact::rawValueChanged, this,
......@@ -236,12 +247,12 @@ bool circularTransects(const snake::FPoint &reference,
std::string error;
// Check validity.
if (!bg::is_valid(polygon, error)) {
qCWarning(CircularGeneratorLog) << "circularTransects(): "
"invalid polygon.";
qCWarning(CircularGeneratorLog) << error.c_str();
qCDebug(CircularGeneratorLog) << "circularTransects(): "
"invalid polygon.";
qCDebug(CircularGeneratorLog) << error.c_str();
std::stringstream ss;
ss << bg::wkt(polygon);
qCWarning(CircularGeneratorLog) << ss.str().c_str();
qCDebug(CircularGeneratorLog) << ss.str().c_str();
} else {
// Calculate polygon distances and angles.
std::vector<snake::Length> distances;
......@@ -249,7 +260,7 @@ bool circularTransects(const snake::FPoint &reference,
std::vector<snake::Angle> angles;
angles.reserve(polygon.outer().size());
//#ifdef DEBUG_CIRCULAR_SURVEY
// qCWarning(CircularGeneratorLog) << "circularTransects():";
// qCDebug(CircularGeneratorLog) << "circularTransects():";
//#endif
for (const auto &p : polygon.outer()) {
snake::Length distance = bg::distance(reference, p) * si::meter;
......@@ -258,11 +269,11 @@ bool circularTransects(const snake::FPoint &reference,
alpha = alpha < 0 * si::radian ? alpha + 2 * M_PI * si::radian : alpha;
angles.push_back(alpha);
//#ifdef DEBUG_CIRCULAR_SURVEY
// qCWarning(CircularGeneratorLog) << "distances, angles,
// coordinates:"; qCWarning(CircularGeneratorLog) <<
// to_string(distance).c_str(); qCWarning(CircularGeneratorLog)
// qCDebug(CircularGeneratorLog) << "distances, angles,
// coordinates:"; qCDebug(CircularGeneratorLog) <<
// to_string(distance).c_str(); qCDebug(CircularGeneratorLog)
// << to_string(snake::Degree(alpha)).c_str();
// qCWarning(CircularGeneratorLog) << "x = " << p.get<0>() << "y
// qCDebug(CircularGeneratorLog) << "x = " << p.get<0>() << "y
// = "
// << p.get<1>();
//#endif
......@@ -285,8 +296,8 @@ bool circularTransects(const snake::FPoint &reference,
const auto deltaRScaled =
ClipperLib::cInt(std::round(deltaR.value() * CLIPPER_SCALE));
auto referenceScaled = ClipperLib::IntPoint{
ClipperLib::cInt(std::round(reference.get<0>())),
ClipperLib::cInt(std::round(reference.get<1>()))};
ClipperLib::cInt(std::round(reference.get<0>() * CLIPPER_SCALE)),
ClipperLib::cInt(std::round(reference.get<1>() * CLIPPER_SCALE))};
// Generate circle sectors.
auto rScaled = rMinScaled;
......@@ -295,20 +306,20 @@ bool circularTransects(const snake::FPoint &reference,
const auto nSectors =
long(std::round(((alpha2 - alpha1) / deltaAlpha).value()));
//#ifdef DEBUG_CIRCULAR_SURVEY
// qCWarning(CircularGeneratorLog) << "circularTransects(): sector
// parameres:"; qCWarning(CircularGeneratorLog) << "alpha1: " <<
// qCDebug(CircularGeneratorLog) << "circularTransects(): sector
// parameres:"; qCDebug(CircularGeneratorLog) << "alpha1: " <<
// to_string(snake::Degree(alpha1)).c_str();
// qCWarning(CircularGeneratorLog) << "alpha2:
// qCDebug(CircularGeneratorLog) << "alpha2:
// "
// << to_string(snake::Degree(alpha2)).c_str();
// qCWarning(CircularGeneratorLog) << "n: "
// qCDebug(CircularGeneratorLog) << "n: "
// << to_string((alpha2 - alpha1) / deltaAlpha).c_str();
// qCWarning(CircularGeneratorLog)
// << "nSectors: " << nSectors; qCWarning(CircularGeneratorLog) <<
// qCDebug(CircularGeneratorLog)
// << "nSectors: " << nSectors; qCDebug(CircularGeneratorLog) <<
// "rMin: " << to_string(rMin).c_str();
// qCWarning(CircularGeneratorLog)
// qCDebug(CircularGeneratorLog)
// << "rMax: " << to_string(rMax).c_str();
// qCWarning(CircularGeneratorLog) << "nTran: " << nTran;
// qCDebug(CircularGeneratorLog) << "nTran: " << nTran;
//#endif
using ClipperCircle =
GenericCircle<ClipperLib::cInt, ClipperLib::IntPoint>;
......@@ -427,7 +438,7 @@ bool circularTransects(const snake::FPoint &reference,
}
}
qCWarning(CircularGeneratorLog)
qCDebug(CircularGeneratorLog)
<< "circularTransects(): transect gen. time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - s1)
......
......@@ -30,7 +30,6 @@ public:
Fact *minLength();
void setReference(const QGeoCoordinate &reference);
Q_INVOKABLE void resetReference();
static const char *settingsGroup;
static const char *distanceName;
......@@ -43,6 +42,10 @@ public:
signals:
void referenceChanged();
public slots:
Q_INVOKABLE void resetReferenceIfInvalid();
Q_INVOKABLE void resetReference();
protected:
virtual void establishConnections() override;
virtual void deleteConnections() override;
......
......@@ -12,13 +12,9 @@ GeneratorBase::GeneratorBase(GeneratorBase::Data d, QObject *parent)
GeneratorBase::~GeneratorBase() {}
QString GeneratorBase::editorQml() {
return QStringLiteral("EmptyGeneratorEditor.qml");
}
QString GeneratorBase::editorQml() { return QStringLiteral(""); }
QString GeneratorBase::mapVisualQml() {
return QStringLiteral("EmptyGeneratorMapVisual.qml");
}
QString GeneratorBase::mapVisualQml() { return QStringLiteral(""); }
GeneratorBase::Data GeneratorBase::data() const { return _d; }
......
......@@ -49,7 +49,7 @@ bool LinearGenerator::get(Generator &generator) {
auto origin = this->_d->origin();
origin.setAltitude(0);
if (!origin.isValid()) {
qCWarning(LinearGeneratorLog) << "get(): origin invalid.";
qCDebug(LinearGeneratorLog) << "get(): origin invalid." << origin;
}
auto geoPolygon = this->_d->measurementArea().coordinateList();
......@@ -57,9 +57,9 @@ bool LinearGenerator::get(Generator &generator) {
if (v.isValid()) {
v.setAltitude(0);
} else {
qCWarning(LinearGeneratorLog) << "get(): measurement area invalid.";
qCDebug(LinearGeneratorLog) << "get(): measurement area invalid.";
for (const auto &w : geoPolygon) {
qCWarning(LinearGeneratorLog) << w;
qCDebug(LinearGeneratorLog) << w;
}
return false;
}
......@@ -80,21 +80,20 @@ bool LinearGenerator::get(Generator &generator) {
snake::areaToEnu(origin, tile->coordinateList(), tileENU);
pTiles->push_back(std::move(tileENU));
} else {
qCWarning(LinearGeneratorLog)
<< "get(): progress.size() != tiles->count().";
qCDebug(LinearGeneratorLog) << "get(): tile == nullptr";
return false;
}
}
}
} else {
qCWarning(LinearGeneratorLog)
qCDebug(LinearGeneratorLog)
<< "get(): progress.size() != tiles->count().";
return false;
}
auto geoDepot = this->_d->serviceArea().depot();
if (!geoDepot.isValid()) {
qCWarning(LinearGeneratorLog) << "get(): depot invalid." << geoDepot;
qCDebug(LinearGeneratorLog) << "get(): depot invalid." << geoDepot;
return false;
}
snake::FPoint depot;
......@@ -116,11 +115,11 @@ bool LinearGenerator::get(Generator &generator) {
};
return true;
} else {
qCWarning(LinearGeneratorLog) << "get(): data invalid.";
qCDebug(LinearGeneratorLog) << "get(): data invalid.";
return false;
}
} else {
qCWarning(LinearGeneratorLog) << "get(): data member not set.";
qCDebug(LinearGeneratorLog) << "get(): data member not set.";
return false;
}
}
......@@ -133,8 +132,6 @@ Fact *LinearGenerator::minLength() { return &_minLength; }
void LinearGenerator::establishConnections() {
if (this->_d && !this->_connectionsEstablished) {
connect(this->_d.get(), &WimaPlanData::measurementAreaChanged, this,
&GeneratorBase::generatorChanged);
connect(this->_d.get(), &WimaPlanData::originChanged, this,
&GeneratorBase::generatorChanged);
connect(&this->_d->measurementArea(),
......@@ -143,6 +140,8 @@ void LinearGenerator::establishConnections() {
connect(&this->_d->measurementArea(),
&WimaMeasurementAreaData::tileDataChanged, this,
&GeneratorBase::generatorChanged);
connect(&this->_d->measurementArea(), &WimaMeasurementAreaData::pathChanged,
this, &GeneratorBase::generatorChanged);
connect(&this->_d->serviceArea(), &WimaServiceAreaData::depotChanged, this,
&GeneratorBase::generatorChanged);
connect(this->distance(), &Fact::rawValueChanged, this,
......@@ -167,6 +166,9 @@ void LinearGenerator::deleteConnections() {
disconnect(&this->_d->measurementArea(),
&WimaMeasurementAreaData::tileDataChanged, this,
&GeneratorBase::generatorChanged);
disconnect(&this->_d->measurementArea(),
&WimaMeasurementAreaData::pathChanged, this,
&GeneratorBase::generatorChanged);
disconnect(&this->_d->serviceArea(), &WimaServiceAreaData::depotChanged,
this, &GeneratorBase::generatorChanged);
disconnect(this->distance(), &Fact::rawValueChanged, this,
......@@ -195,9 +197,9 @@ bool linearTransects(const snake::FPolygon &polygon,
std::stringstream ss;
ss << bg::wkt(polygon);
qCWarning(LinearGeneratorLog) << "linearTransects(): "
"invalid polygon. "
<< error.c_str() << ss.str().c_str();
qCDebug(LinearGeneratorLog) << "linearTransects(): "
"invalid polygon. "
<< error.c_str() << ss.str().c_str();
} else {
tr::rotate_transformer<bg::degree, double, 2, 2> rotate(angle.value() *
180 / M_PI);
......@@ -244,7 +246,7 @@ bool linearTransects(const snake::FPolygon &polygon,
std::stringstream ss;
ss << "Not able to generate transects. Parameter: distance = "
<< distance << std::endl;
qCWarning(LinearGeneratorLog)
qCDebug(LinearGeneratorLog)
<< "linearTransects(): " << ss.str().c_str();
return false;
}
......@@ -312,12 +314,12 @@ bool linearTransects(const snake::FPolygon &polygon,
std::stringstream ss;
ss << "Not able to generatetransects. Parameter: minLength = "
<< minLength << std::endl;
qCWarning(LinearGeneratorLog)
qCDebug(LinearGeneratorLog)
<< "linearTransects(): " << ss.str().c_str();
return false;
}
qCWarning(LinearGeneratorLog)
qCDebug(LinearGeneratorLog)
<< "linearTransects(): time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - s1)
......
......@@ -2,6 +2,7 @@
#include "SnakeTilesLocal.h"
#include "QGCApplication.h"
#include "QGCLoggingCategory.h"
#include "QGCToolbox.h"
#include "SettingsFact.h"
#include "SettingsManager.h"
......@@ -26,6 +27,8 @@
#include "ros_bridge/rapidjson/include/rapidjson/ostreamwrapper.h"
#include "ros_bridge/rapidjson/include/rapidjson/writer.h"
QGC_LOGGING_CATEGORY(NemoInterfaceLog, "NemoInterfaceLog")
#define EVENT_TIMER_INTERVAL 100 // ms
auto static timeoutInterval = std::chrono::milliseconds(3000);
......@@ -171,15 +174,15 @@ void NemoInterface::Impl::setTileData(const TileData &tileData) {
snake::areaToEnu(origin, tile->coordinateList(), tileENU.path());
this->tilesENU.polygons().push_back(std::move(tileENU));
} else {
qWarning() << "NemoInterface::Impl::setTileData(): nullptr.";
qCDebug(NemoInterfaceLog) << "Impl::setTileData(): nullptr.";
break;
}
}
} else {
qWarning() << "NemoInterface::Impl::setTileData(): Origin invalid.";
qCDebug(NemoInterfaceLog) << "Impl::setTileData(): Origin invalid.";
}
} else {
qWarning() << "NemoInterface::Impl::setTileData(): tile empty.";
qCDebug(NemoInterfaceLog) << "Impl::setTileData(): tile empty.";
}
}
} else {
......@@ -300,12 +303,17 @@ void NemoInterface::Impl::doTopicServiceSetup() {
std::make_unique<rapidjson::Document>(rapidjson::kObjectType));
auto &origin = this->ENUOrigin;
rapidjson::Value jOrigin(rapidjson::kObjectType);
bool ret = geographic_msgs::geo_point::toJson(origin, jOrigin,
pDoc->GetAllocator());
lk.unlock();
Q_ASSERT(ret);
(void)ret;
pDoc->AddMember("origin", jOrigin, pDoc->GetAllocator());
if (geographic_msgs::geo_point::toJson(origin, jOrigin,
pDoc->GetAllocator())) {
lk.unlock();
pDoc->AddMember("origin", jOrigin, pDoc->GetAllocator());
} else {
lk.unlock();
qCWarning(NemoInterfaceLog)
<< "/snake/get_origin service: could not create json document.";
}
return pDoc;
});
......@@ -318,11 +326,17 @@ void NemoInterface::Impl::doTopicServiceSetup() {
JsonDocUPtr pDoc(
std::make_unique<rapidjson::Document>(rapidjson::kObjectType));
rapidjson::Value jSnakeTiles(rapidjson::kObjectType);
bool ret = jsk_recognition_msgs::polygon_array::toJson(
this->tilesENU, jSnakeTiles, pDoc->GetAllocator());
Q_ASSERT(ret);
(void)ret;
pDoc->AddMember("tiles", jSnakeTiles, pDoc->GetAllocator());
if (jsk_recognition_msgs::polygon_array::toJson(
this->tilesENU, jSnakeTiles, pDoc->GetAllocator())) {
lk.unlock();
pDoc->AddMember("tiles", jSnakeTiles, pDoc->GetAllocator());
} else {
lk.unlock();
qCWarning(NemoInterfaceLog)
<< "/snake/get_tiles service: could not create json document.";
}
return pDoc;
});
}
......@@ -379,22 +393,26 @@ void NemoInterface::Impl::publishTilesENU() {
using namespace ros_bridge::messages;
JsonDocUPtr jSnakeTiles(
std::make_unique<rapidjson::Document>(rapidjson::kObjectType));
bool ret = jsk_recognition_msgs::polygon_array::toJson(
this->tilesENU, *jSnakeTiles, jSnakeTiles->GetAllocator());
Q_ASSERT(ret);
(void)ret;
this->pRosBridge->publish(std::move(jSnakeTiles), "/snake/tiles");
if (jsk_recognition_msgs::polygon_array::toJson(
this->tilesENU, *jSnakeTiles, jSnakeTiles->GetAllocator())) {
this->pRosBridge->publish(std::move(jSnakeTiles), "/snake/tiles");
} else {
qCWarning(NemoInterfaceLog)
<< "Impl::publishTilesENU: could not create json document.";
}
}
void NemoInterface::Impl::publishENUOrigin() {
using namespace ros_bridge::messages;
JsonDocUPtr jOrigin(
std::make_unique<rapidjson::Document>(rapidjson::kObjectType));
bool ret = geographic_msgs::geo_point::toJson(this->ENUOrigin, *jOrigin,
jOrigin->GetAllocator());
Q_ASSERT(ret);
(void)ret;
this->pRosBridge->publish(std::move(jOrigin), "/snake/origin");
if (geographic_msgs::geo_point::toJson(this->ENUOrigin, *jOrigin,
jOrigin->GetAllocator())) {
this->pRosBridge->publish(std::move(jOrigin), "/snake/origin");
} else {
qCWarning(NemoInterfaceLog)
<< "Impl::publishENUOrigin: could not create json document.";
}
}
bool NemoInterface::Impl::setStatus(NemoInterface::STATUS s) {
......@@ -421,7 +439,7 @@ void NemoInterface::stop() { this->pImpl->stop(); }
void NemoInterface::publishTileData() { this->pImpl->publishTileData(); }
void NemoInterface::requestProgress() {
qWarning() << "NemoInterface::requestProgress(): dummy.";
qCWarning(NemoInterfaceLog) << "requestProgress(): dummy.";
}
void NemoInterface::setTileData(const TileData &tileData) {
......
......@@ -18,8 +18,6 @@ QString SnakeTile::type() const { return "Tile"; }
SnakeTile *SnakeTile::Clone() const { return new SnakeTile(*this); }
SnakeTile &SnakeTile::operator=(const SnakeTile &other) {
this->assign(other);
this->WimaAreaData::operator=(other);
return *this;
}
void SnakeTile::assign(const SnakeTile &other) { WimaAreaData::assign(other); }
......@@ -8,8 +8,7 @@ import QGroundControl.ScreenTools 1.0
GridLayout {
// Item must be loaded, expects the following properties:
// property var generator
property var generator // CircularGenerator
property real _margin: ScreenTools.defaultFontPixelWidth / 2
......
import QtQuick 2.0
import QtQuick 2.0
import Wima 1.0
import QGroundControl 1.0
Item {
id: _root
visible: true
// Expects the following properties:
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var generator
property bool checked: false
property var _referenceComponent
property var _referenceComponent: undefined
signal clicked()
function _addRefPoint(){
if (!_referenceComponent){
_referenceComponent = refPointComponent.createObject(_root)
map.addMapItem(_referenceComponent)
}
}
function _destroyRefPoint(){
if (_referenceComponent){
map.removeMapItem(_referenceComponent)
_referenceComponent.destroy()
_referenceComponent = undefined
}
}
onVisibleChanged: {
if (visible){
_addRefPoint()
......@@ -41,28 +31,56 @@ Item {
}
}
Component.onDestroyed: {
Component.onDestruction: {
_destroyRefPoint()
}
function _addRefPoint(){
if (!_referenceComponent){
_referenceComponent = refPointComponent.createObject(_root)
map.addMapItem(_referenceComponent)
}
}
function _destroyRefPoint(){
if (_referenceComponent){
map.removeMapItem(_referenceComponent)
_referenceComponent.destroy()
_referenceComponent = undefined
}
}
// Ref. point (Base Station)
Component {
id: refPointComponent
DragCoordinate {
id: dragCoordinate
property var ref: _root.generator.reference
map: _root.map
qgcView: _root.qgcView
z: QGroundControl.zOrderMapItems
checked: _root.checked
coordinate: _root.generator.reference
coordinate: ref
onDragReleased: {
syncAndBind()
}
Component.onCompleted: {
syncAndBind()
}
onClicked: {
_root.clicked()
}
onDragReleased: {
_root.generator.reference = coordinate
coordinate = Qt.binding(function (){return _root.generator.reference})
function syncAndBind(){
if (coordinate.latitude !== ref.latitude ||
coordinate.longitude !== ref.longitude){
_root.generator.reference = coordinate
}
coordinate = Qt.binding(function(){return _root.generator.reference})
}
}
}
......
......@@ -25,31 +25,24 @@ Rectangle {
//property real availableWidth ///< Width for control
//property var missionItem ///< Mission Item for editor
property real _margin: ScreenTools.defaultFontPixelWidth / 2
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
property real _cameraMinTriggerInterval: missionItem.cameraCalc.minTriggerInterval.rawValue
property real _margin: ScreenTools.defaultFontPixelWidth / 2
property var _generator: missionItem.generator
property var _generator: missionItem.generator
property var _generatorEditor: undefined
function polygonCaptureStarted() {
missionItem.clearPolygon()
}
QGCPalette { id: qgcPal; colorGroupEnabled: true }
function polygonCaptureFinished(coordinates) {
for (var i=0; i<coordinates.length; i++) {
missionItem.addPolygonCoordinate(coordinates[i])
}
Component.onCompleted: {
_addGeneratorEditor()
}
function polygonAdjustVertex(vertexIndex, vertexCoordinate) {
missionItem.adjustPolygonCoordinate(vertexIndex, vertexCoordinate)
Component.onDestruction: {
_destroyGeneratorEditor()
}
function polygonAdjustStarted() { }
function polygonAdjustFinished() { }
QGCPalette { id: qgcPal; colorGroupEnabled: true }
on_GeneratorChanged: {
_destroyGeneratorEditor()
_addGeneratorEditor()
}
Column {
id: editorColumn
......@@ -156,13 +149,11 @@ Rectangle {
id: transectsHeader
text: qsTr("Generator")
}
Loader{
source: _generator.editorQml
property var generator: _generator
property real margin: _margin
visible: transectsHeader.checked
}
Column{
id:generatorEditorParent
visible: transectsHeader.checked
}
Column{
anchors.left: parent.left
......@@ -178,7 +169,7 @@ Rectangle {
onCalculatingChanged: {
if(!calculating){
// defer hideing
// defer hiding
timer.restart()
}
}
......@@ -192,4 +183,27 @@ Rectangle {
}
}
} // Column
function _addGeneratorEditor(){
if (_generator.editorQml && !_generatorEditor) {
var component = Qt.createComponent(_generator.editorQml)
if (component.status === Component.Error) {
console.log("Error loading Qml: ",
_generator.editorQml, component.errorString())
} else {
_generatorEditor =
component.createObject(
generatorEditorParent, {
"generator": _root._generator,
})
}
}
}
function _destroyGeneratorEditor(){
if (_generatorEditor){
_generatorEditor.destroy()
_generatorEditor = undefined
}
}
} // Rectangle
......@@ -26,67 +26,34 @@ Item {
property var qgcView ///< QGCView to use for popping dialogs
property var _missionItem: object
property var _transectsComponent
property var _entryCoordinate
property var _exitCoordinate
property var _generator: _missionItem.generator
signal clicked(int sequenceNumber)
function _addTransectsComponent(){
if (!_transectsComponent){
_transectsComponent = visualTransectsComponent.createObject(_root)
map.addMapItem(_transectsComponent)
}
}
function _addExitCoordinate(){
if (!_exitCoordinate){
_exitCoordinate = exitPointComponent.createObject(_root)
map.addMapItem(_exitCoordinate)
}
}
property var _transectsComponent: undefined
property var _entryCoordinate: undefined
property var _exitCoordinate: undefined
property var _generatorVisuals: undefined
function _addEntryCoordinate(){
if (!_entryCoordinate){
_entryCoordinate = entryPointComponent.createObject(_root)
map.addMapItem(_entryCoordinate)
}
}
property bool _isCurrentItem: _missionItem.isCurrentItem
function _destroyEntryCoordinate(){
if (_entryCoordinate){
map.removeMapItem(_entryCoordinate)
_entryCoordinate.destroy()
_entryCoordinate = undefined
}
}
function _destroyExitCoordinate(){
if (_exitCoordinate){
map.removeMapItem(_exitCoordinate)
_exitCoordinate.destroy()
_exitCoordinate = undefined
}
}
function _destroyTransectsComponent(){
if (_transectsComponent){
map.removeMapItem(_transectsComponent)
_transectsComponent.destroy()
_transectsComponent = undefined
}
}
signal clicked(int sequenceNumber)
Component.onCompleted: {
_addEntryCoordinate()
_addExitCoordinate()
_addTransectsComponent()
_addGeneratorVisuals()
}
Component.onDestruction: {
_destroyEntryCoordinate()
_destroyExitCoordinate()
_destroyTransectsComponent()
_destroyGeneratorVisuals()
}
on_GeneratorChanged: {
_destroyGeneratorVisuals()
_addGeneratorVisuals()
}
// Transect lines
......@@ -140,4 +107,82 @@ Item {
}
}
}
// Generator visuals
function _addGeneratorVisuals(){
if (_generator.mapVisualQml && !_generatorVisuals) {
var component = Qt.createComponent(_generator.mapVisualQml)
if (component.status === Component.Error) {
console.log("Error loading Qml: ",
_generator.mapVisualQml, component.errorString())
} else {
_generatorVisuals =
component.createObject(_root, {
"map": _root.map,
"qgcView": _root.qgcView ,
"generator": _root._generator,
"checked": Qt.binding(
function(){
return _root._isCurrentItem
})
})
_generatorVisuals.clicked.connect(
function(){_root.clicked(_missionItem.sequenceNumber)})
}
}
}
function _destroyGeneratorVisuals(){
if(_generatorVisuals){
_generatorVisuals.destroy()
_generatorVisuals = undefined
}
}
function _addTransectsComponent(){
if (!_transectsComponent){
_transectsComponent = visualTransectsComponent.createObject(_root)
map.addMapItem(_transectsComponent)
}
}
function _addExitCoordinate(){
if (!_exitCoordinate){
_exitCoordinate = exitPointComponent.createObject(_root)
map.addMapItem(_exitCoordinate)
}
}
function _addEntryCoordinate(){
if (!_entryCoordinate){
_entryCoordinate = entryPointComponent.createObject(_root)
map.addMapItem(_entryCoordinate)
}
}
function _destroyEntryCoordinate(){
if (_entryCoordinate){
map.removeMapItem(_entryCoordinate)
_entryCoordinate.destroy()
_entryCoordinate = undefined
}
}
function _destroyExitCoordinate(){
if (_exitCoordinate){
map.removeMapItem(_exitCoordinate)
_exitCoordinate.destroy()
_exitCoordinate = undefined
}
}
function _destroyTransectsComponent(){
if (_transectsComponent){
map.removeMapItem(_transectsComponent)
_transectsComponent.destroy()
_transectsComponent = undefined
}
}
}
......@@ -8,8 +8,7 @@ import QGroundControl.ScreenTools 1.0
GridLayout {
// Item must be loaded, expects the following properties:
// property var generator
property var generator ///< LinearGenerator
property real _margin: ScreenTools.defaultFontPixelWidth / 2
......@@ -23,7 +22,14 @@ GridLayout {
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Alpha") }
QGCLabel {
text: qsTr("Alpha: ")
Layout.fillWidth: true
}
FactTextField {
fact: generator.alpha
Layout.fillWidth: true
}
QGCSlider {
id: rSlider
minimumValue: 0
......@@ -33,8 +39,11 @@ GridLayout {
Layout.fillWidth: true
Layout.columnSpan: 2
Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 1.5
onValueChanged: generator.alpha.value = value
Component.onCompleted: value = 0
onValueChanged: {
generator.alpha.value = value
value = Qt.binding(function(){return generator.alpha.value})
}
Component.onCompleted: value = generator.alpha.value
updateValueWhileDragging: true
}
......
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