Commit 42fe8ce4 authored by Valentin Platzgummer's avatar Valentin Platzgummer

nemo interface working

parent 47586728
......@@ -54,7 +54,7 @@ MeasurementComplexItem::MeasurementComplexItem(
_altitude(settingsGroup, _metaDataMap[altitudeKey]),
_variantIndex(settingsGroup, _metaDataMap[variantIndexKey]),
_pAreaData(new AreaData(this)), _pEditorData(new AreaData(this)),
_pCurrentData(_pAreaData), _pGenerator(nullptr),
_pCurrentData(_pAreaData), _holdProgress(false), _pGenerator(nullptr),
_pWorker(new RoutingThread(this)) {
// Setup altitude.
......@@ -772,6 +772,24 @@ void MeasurementComplexItem::_onAltitudeChanged() {
emit routeChanged();
}
}
bool MeasurementComplexItem::holdProgress() const { return _holdProgress; }
void MeasurementComplexItem::setHoldProgress(bool holdProgress) {
if (_holdProgress != holdProgress) {
_holdProgress = holdProgress;
emit holdProgressChanged();
if (_holdProgress) {
disconnect(pNemoInterface, &NemoInterface::progressChanged, this,
&MeasurementComplexItem::_onNewProgress);
} else {
connect(pNemoInterface, &NemoInterface::progressChanged, this,
&MeasurementComplexItem::_onNewProgress);
_onNewProgress(pNemoInterface->getProgress());
}
}
}
void MeasurementComplexItem::_setAreaData(
MeasurementComplexItem::PtrAreaData data) {
if (_pCurrentData != data) {
......@@ -940,30 +958,9 @@ void MeasurementComplexItem::_syncTiles() {
}
if (tilePtrArray.size() > 0) {
// create id array
IDArray idArray;
for (const auto *pTile : tilePtrArray) {
idArray.push_back(pTile->id());
}
// sync. necessary?
bool doSync = false;
auto contains = pNemoInterface->containsTiles(idArray);
for (auto &&logical : contains) {
if (logical == false) {
doSync = true;
break;
}
}
if (doSync) {
if (!pNemoInterface->empty()) {
(void)pNemoInterface->clearTiles();
}
(void)pNemoInterface->addTiles(tilePtrArray);
return;
}
(void)pNemoInterface->clearTiles();
(void)pNemoInterface->addTiles(tilePtrArray);
return;
} else {
clear = true;
}
......@@ -972,9 +969,7 @@ void MeasurementComplexItem::_syncTiles() {
}
if (clear) {
if (!pNemoInterface->empty()) {
(void)pNemoInterface->clearTiles();
}
(void)pNemoInterface->clearTiles();
}
}
......
......@@ -43,6 +43,8 @@ public:
generatorListChanged)
Q_PROPERTY(bool calculating READ calculating NOTIFY calculatingChanged)
Q_PROPERTY(bool editing READ editing NOTIFY editingChanged)
Q_PROPERTY(bool holdProgress READ holdProgress WRITE setHoldProgress NOTIFY
holdProgressChanged)
Q_PROPERTY(bool idle READ idle NOTIFY idleChanged)
Q_PROPERTY(
routing::GeneratorBase *generator READ generator NOTIFY generatorChanged)
......@@ -219,6 +221,9 @@ public:
static const char *jsonComplexItemTypeValue;
static const QString name;
bool holdProgress() const;
void setHoldProgress(bool holdProgress);
signals:
void variantNamesChanged();
......@@ -231,6 +236,7 @@ signals:
void areaDataChanged();
void routeChanged();
void holdProgressChanged();
private slots:
......@@ -269,6 +275,7 @@ private:
PtrAreaData _pAreaData;
PtrAreaData _pEditorData;
PtrAreaData _pCurrentData;
bool _holdProgress;
// Generators
QList<PtrGenerator> _generatorList;
......
......@@ -73,22 +73,22 @@ public:
//!
std::shared_future<QVariant> clearTiles();
TileArray getTiles(const IDArray &idArray);
TileArray getAllTiles();
LogicalArray containsTiles(const IDArray &idArray);
std::size_t size();
bool empty();
TileArray getTiles(const IDArray &idArray) const;
TileArray getAllTiles() const;
LogicalArray containsTiles(const IDArray &idArray) const;
std::size_t size() const;
bool empty() const;
// Progress.
ProgressArray getProgress();
ProgressArray getProgress(const IDArray &idArray);
ProgressArray getProgress() const;
ProgressArray getProgress(const IDArray &idArray) const;
// Status.
STATUS status() const;
QString statusString() const;
QString infoString() const;
QString warningString() const;
bool running();
bool running() const;
signals:
void statusChanged();
......
......@@ -55,8 +55,7 @@ MeasurementArea::MeasurementArea(QObject *parent)
this /* QObject parent */)),
_showTiles(SettingsFact(settingsGroup, _metaDataMap[showTilesKey],
this /* QObject parent */)),
_tiles(new QmlObjectListModel()), _holdProgress(false),
_state(STATE::IDLE) {
_tiles(new QmlObjectListModel()), _state(STATE::IDLE) {
init();
}
......@@ -74,8 +73,7 @@ MeasurementArea::MeasurementArea(const MeasurementArea &other, QObject *parent)
this /* QObject parent */)),
_showTiles(SettingsFact(settingsGroup, _metaDataMap[showTilesKey],
this /* QObject parent */)),
_tiles(new QmlObjectListModel()), _holdProgress(false),
_state(STATE::IDLE) {
_tiles(new QmlObjectListModel()), _state(STATE::IDLE) {
init();
disableUpdate();
......@@ -323,7 +321,7 @@ bool MeasurementArea::isCorrect() {
}
void MeasurementArea::updateProgress(const ProgressArray &array) {
if (ready() && !_holdProgress && array.size() > 0) {
if (ready() && array.size() > 0) {
bool anyChanges = false;
for (const auto &lp : array) {
auto it = _indexMap.find(lp.id());
......@@ -589,15 +587,6 @@ void MeasurementArea::setState(MeasurementArea::STATE s) {
}
}
bool MeasurementArea::holdProgress() const { return _holdProgress; }
void MeasurementArea::setHoldProgress(bool holdProgress) {
if (_holdProgress != holdProgress) {
_holdProgress = holdProgress;
emit holdProgressChanged();
}
}
void MeasurementArea::updateIds(const QList<TileDiff> &array) {
for (const auto &diff : array) {
......
......@@ -48,8 +48,6 @@ public:
Q_PROPERTY(Fact *showTiles READ showTiles CONSTANT)
Q_PROPERTY(QmlObjectListModel *tiles READ tiles NOTIFY tilesChanged)
Q_PROPERTY(int maxTiles READ maxTiles NOTIFY maxTilesChanged)
Q_PROPERTY(bool holdProgress READ holdProgress WRITE setHoldProgress NOTIFY
holdProgressChanged)
// Overrides from GeoArea
QString mapVisualQML(void) const override;
......@@ -75,23 +73,10 @@ public:
static const char *settingsGroup;
static const char *nameString;
//!
//! \brief holdProgress
//! \return Returns a copy of the holdProgress variable.
//!
bool holdProgress() const;
//!
//! \brief setHoldProgress Sets the holdProgress variable to \p holdProgress.
//! \note If holdProgress() == true, than setProgress() will do nothing, but
//! return false and emit the progressNotAccepted() signal.
//!
void setHoldProgress(bool holdProgress);
signals:
void tilesChanged();
void maxTilesChanged();
void readyChanged();
void holdProgressChanged();
void progressChanged();
public slots:
......@@ -123,7 +108,6 @@ private:
// Tile stuff.
TilePtr _tiles;
std::map<std::int64_t /*id*/, int> _indexMap;
bool _holdProgress;
QTimer _timer;
STATE _state;
QFutureWatcher<TilePtr> _watcher;
......
......@@ -29,13 +29,10 @@ Rectangle {
property var _areaData: missionItem.areaData
property real _margin: ScreenTools.defaultFontPixelWidth / 2
property var _nemoInterface: MCI.NemoInterface
property bool _holding
Component.onCompleted: {
console.assert(missionItem !== undefined,
"please set the missionItem property")
_holding = false
_stopHolding()
}
GridLayout {
......@@ -93,16 +90,14 @@ Rectangle {
visible: progressHeader.checked
QGCButton {
text: !_holding ? qsTr("Hold") : qsTr("Stop Holding")
text: !missionItem.holdProgress ? qsTr("Hold") : qsTr("Stop Holding")
Layout.fillWidth: true
Layout.columnSpan: parent.columns
onPressed: {
if (_holding) {
_stopHolding()
_holding = false
if (missionItem.holdProgress) {
missionItem.holdProgress = false
} else {
_holdProgress()
_holding = true
missionItem.holdProgress = true
}
}
}
......@@ -187,30 +182,6 @@ Use the Random button to simulate measurement progress.")
}
} // GridLayout
function _holdProgress() {
var areaArray = _areaData.measurementAreaList
for (var i = 0; i < areaArray.count; ++i) {
var area = areaArray.get(i)
if (area) {
area.holdProgress = true
} else {
console.log("empty area!")
}
}
}
function _stopHolding() {
var areaArray = _areaData.measurementAreaList
for (var i = 0; i < areaArray.count; ++i) {
var area = areaArray.get(i)
if (area) {
area.holdProgress = false
} else {
console.log("empty area!")
}
}
}
function _randomProgress() {
var areaArray = _areaData.measurementAreaList
for (var i = 0; i < areaArray.count; ++i) {
......
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