Commit e789e194 authored by Valentin Platzgummer's avatar Valentin Platzgummer

circular survey issues fixed

parent 9df678f1
...@@ -607,7 +607,7 @@ QGCView { ...@@ -607,7 +607,7 @@ QGCView {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.bottomMargin: ScreenTools.defaultFontPixelWidth anchors.bottomMargin: ScreenTools.defaultFontPixelWidth
maxWidth: 300 maxWidth: 300
maxHeight: 500 maxHeight: parent.height - toolStrip.height - ScreenTools.defaultFontPixelWidth*4
wimaController: wimaController wimaController: wimaController
......
...@@ -30,7 +30,7 @@ Item { ...@@ -30,7 +30,7 @@ Item {
property bool _controllerValid: planMasterController !== undefined property bool _controllerValid: planMasterController !== undefined
property real _controllerProgressPct: _controllerValid ? planMasterController.missionController.progressPct : 0 property real _controllerProgressPct: _controllerValid ? planMasterController.missionController.progressPct : 0
property real _margins: ScreenTools.defaultPixelWidth*0.3 property real _margins: ScreenTools.defaultFontPixelWidth / 2
signal initSmartRTL(); signal initSmartRTL();
...@@ -60,7 +60,7 @@ Item { ...@@ -60,7 +60,7 @@ Item {
// box containing all items // box containing all items
Rectangle { // maybe replace with column and remove anchors => dynamic height: Rectangle { // maybe replace with column and remove anchors => dynamic height:
id: mainFrame id: mainFrame
height: enableWima.height + flickable.height height: enableWima.height + flickable.height + _margins*2
width: Math.max(enableWima.width, flickable.width) width: Math.max(enableWima.width, flickable.width)
color: enableWima.enableWimaBoolean ? qgcPal.window : "transparent" color: enableWima.enableWimaBoolean ? qgcPal.window : "transparent"
radius: Math.min(height, width)/50 radius: Math.min(height, width)/50
...@@ -69,30 +69,9 @@ Item { ...@@ -69,30 +69,9 @@ Item {
property real _margins: _root._margins property real _margins: _root._margins
Component.onCompleted: { Component.onCompleted: {
console.log('onCompleted') console.log('mainFrame onCompleted')
console.log('height') console.log('_margins')
console.log(height) console.log(_margins)
console.log('width')
console.log(width)
console.log(enableWima.width)
console.log(enableWima.height)
console.log(flickable.contentWidth)
console.log(flickable.contentHeight)
width = enableWima.width + flickable.contentWidth + 2*_margins
console.log('width')
console.log(width)
}
onHeightChanged: {
console.log('height')
console.log(height)
//_root.height = mainFrame.height
}
onWidthChanged: {
console.log('width')
console.log(width)
//_root.width = mainFrame.width
} }
// checkbox to enable/ disable wima // checkbox to enable/ disable wima
...@@ -100,24 +79,13 @@ Item { ...@@ -100,24 +79,13 @@ Item {
id: enableWima id: enableWima
anchors.horizontalCenter: flickable.horizontalCenter anchors.horizontalCenter: flickable.horizontalCenter
anchors.bottom: flickable.top anchors.bottom: flickable.top
anchors.bottomMargin: _margins
confirmText: enableWimaBoolean ? qsTr("disable WiMA") : qsTr("enable WiMA") confirmText: enableWimaBoolean ? qsTr("disable WiMA") : qsTr("enable WiMA")
property var enableWimaFact: wimaController.enableWimaController property var enableWimaFact: wimaController.enableWimaController
property bool enableWimaBoolean: enableWimaFact.value property bool enableWimaBoolean: enableWimaFact.value
/*onXChanged: {
console.log('x')
}
onYChanged: {
console.log('y')
}
Component.onCompleted: {
enableWimaFact.value = true
}*/
onAccept: { onAccept: {
if (enableWimaBoolean) { if (enableWimaBoolean) {
enableWimaFact.value = false enableWimaFact.value = false
...@@ -145,8 +113,6 @@ Item { ...@@ -145,8 +113,6 @@ Item {
timer.start() timer.start()
} }
onExited: timer.start()
} }
Timer { Timer {
...@@ -180,19 +146,6 @@ Item { ...@@ -180,19 +146,6 @@ Item {
contentHeight: columnWrapper.height contentHeight: columnWrapper.height
contentWidth: columnWrapper.width contentWidth: columnWrapper.width
onContentHeightChanged: {
console.log('contentHeight')
console.log(contentHeight)
//mainFrame.height = enableWima.enableWimaBoolean ? Math.min(parent.maxHeight, enableWima.height + flickable.contentHeight + 2*_margins) : enableWima.height + _margins
}
onContentWidthChanged: {
console.log('contentWidth')
console.log(contentWidth)
//mainFrame.width = enableWima.enableWimaBoolean ? Math.min(parent.maxWidth, flickable.contentWidth + 2*_margins) : enableWima.width
}
Row { Row {
id: columnWrapper id: columnWrapper
Item{ // spacer Item{ // spacer
......
...@@ -131,7 +131,7 @@ Rectangle { ...@@ -131,7 +131,7 @@ Rectangle {
} }
} }
ColumnLayout { Column {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
spacing: _margin spacing: _margin
...@@ -144,7 +144,6 @@ Rectangle { ...@@ -144,7 +144,6 @@ Rectangle {
QGCCheckBox { QGCCheckBox {
id: relAlt id: relAlt
Layout.alignment: Qt.AlignLeft
text: qsTr("Relative altitude") text: qsTr("Relative altitude")
checked: missionItem.cameraCalc.distanceToSurfaceRelative checked: missionItem.cameraCalc.distanceToSurfaceRelative
enabled: missionItem.cameraCalc.isManualCamera && !missionItem.followTerrain enabled: missionItem.cameraCalc.isManualCamera && !missionItem.followTerrain
...@@ -157,15 +156,14 @@ Rectangle { ...@@ -157,15 +156,14 @@ Rectangle {
} }
} }
QGCButton { FactCheckBox {
text: qsTr("Reset Reference") text: qsTr("Reverse Path")
onClicked: missionItem.resetReference(); fact: missionItem.reverse
Layout.fillWidth: true
} }
QGCButton { QGCButton {
text: qsTr("Rotate Entry Point") text: qsTr("Reset Reference")
onClicked: missionItem.rotateEntryPoint(); onClicked: missionItem.resetReference();
Layout.fillWidth: true Layout.fillWidth: true
} }
...@@ -226,10 +224,10 @@ Rectangle { ...@@ -226,10 +224,10 @@ Rectangle {
} }
} }
SectionHeader { /*SectionHeader {
id: statsHeader id: statsHeader
text: qsTr("Statistics") text: qsTr("Statistics")
} }*/
//TransectStyleComplexItemStats { } //TransectStyleComplexItemStats { }
} // Column } // Column
......
...@@ -11,6 +11,9 @@ Canvas { ...@@ -11,6 +11,9 @@ Canvas {
height: _height height: _height
signal clicked signal clicked
signal released
signal entered
signal exited
property string label ///< Label to show to the side of the index indicator property string label ///< Label to show to the side of the index indicator
property int index: 0 ///< Index to show in the indicator, 0 will show single char label instead, -1 first char of label in indicator full label to the side property int index: 0 ///< Index to show in the indicator, 0 will show single char label instead, -1 first char of label in indicator full label to the side
...@@ -120,5 +123,14 @@ Canvas { ...@@ -120,5 +123,14 @@ Canvas {
focus = true focus = true
parent.clicked() parent.clicked()
} }
onReleased: {
parent.released()
}
onEntered: {
parent.entered()
}
onExited: {
parent.exited()
}
} }
} }
...@@ -32,5 +32,11 @@ ...@@ -32,5 +32,11 @@
"shortDescription": "Determines whether the transects are arranged in a snake or a zig-zag manner.", "shortDescription": "Determines whether the transects are arranged in a snake or a zig-zag manner.",
"type": "bool", "type": "bool",
"defaultValue": 1 "defaultValue": 1
},
{
"name": "Reverse",
"shortDescription": "Reverses the transect path",
"type": "bool",
"defaultValue": 0
} }
] ]
...@@ -8,6 +8,7 @@ const char* CircularSurveyComplexItem::deltaRName = "DeltaR"; ...@@ -8,6 +8,7 @@ const char* CircularSurveyComplexItem::deltaRName = "DeltaR";
const char* CircularSurveyComplexItem::deltaAlphaName = "DeltaAlpha"; const char* CircularSurveyComplexItem::deltaAlphaName = "DeltaAlpha";
const char* CircularSurveyComplexItem::transectMinLengthName = "TransectMinLength"; const char* CircularSurveyComplexItem::transectMinLengthName = "TransectMinLength";
const char* CircularSurveyComplexItem::isSnakePathName = "IsSnakePath"; const char* CircularSurveyComplexItem::isSnakePathName = "IsSnakePath";
const char* CircularSurveyComplexItem::reverseName = "Reverse";
const char* CircularSurveyComplexItem::jsonComplexItemTypeValue = "circularSurvey"; const char* CircularSurveyComplexItem::jsonComplexItemTypeValue = "circularSurvey";
...@@ -26,8 +27,11 @@ CircularSurveyComplexItem::CircularSurveyComplexItem(Vehicle *vehicle, bool flyV ...@@ -26,8 +27,11 @@ CircularSurveyComplexItem::CircularSurveyComplexItem(Vehicle *vehicle, bool flyV
, _deltaR (settingsGroup, _metaDataMap[deltaRName]) , _deltaR (settingsGroup, _metaDataMap[deltaRName])
, _deltaAlpha (settingsGroup, _metaDataMap[deltaAlphaName]) , _deltaAlpha (settingsGroup, _metaDataMap[deltaAlphaName])
, _transectMinLength (settingsGroup, _metaDataMap[transectMinLengthName]) , _transectMinLength (settingsGroup, _metaDataMap[transectMinLengthName])
, _isSnakePath (settingsGroup, _metaDataMap[isSnakePathName]) , _isSnakePath (settingsGroup, _metaDataMap[isSnakePathName])
, _reverse (settingsGroup, _metaDataMap[reverseName])
, _isInitialized (false) , _isInitialized (false)
, _reverseOnly (false)
, _referencePointBeingChanged (false)
, _updateCounter (0) , _updateCounter (0)
{ {
_editorQml = "qrc:/qml/CircularSurveyItemEditor.qml"; _editorQml = "qrc:/qml/CircularSurveyItemEditor.qml";
...@@ -35,6 +39,7 @@ CircularSurveyComplexItem::CircularSurveyComplexItem(Vehicle *vehicle, bool flyV ...@@ -35,6 +39,7 @@ CircularSurveyComplexItem::CircularSurveyComplexItem(Vehicle *vehicle, bool flyV
connect(&_deltaAlpha, &Fact::valueChanged, this, &CircularSurveyComplexItem::_rebuildTransects); connect(&_deltaAlpha, &Fact::valueChanged, this, &CircularSurveyComplexItem::_rebuildTransects);
connect(&_transectMinLength, &Fact::valueChanged, this, &CircularSurveyComplexItem::_rebuildTransects); connect(&_transectMinLength, &Fact::valueChanged, this, &CircularSurveyComplexItem::_rebuildTransects);
connect(&_isSnakePath, &Fact::valueChanged, this, &CircularSurveyComplexItem::_rebuildTransects); connect(&_isSnakePath, &Fact::valueChanged, this, &CircularSurveyComplexItem::_rebuildTransects);
connect(&_reverse, &Fact::valueChanged, this, &CircularSurveyComplexItem::_reverseTransects);
connect(this, &CircularSurveyComplexItem::refPointChanged, this, &CircularSurveyComplexItem::_rebuildTransects); connect(this, &CircularSurveyComplexItem::refPointChanged, this, &CircularSurveyComplexItem::_rebuildTransects);
//connect(&_cameraCalc.distanceToSurface(), &Fact::rawValueChanged, this->) //connect(&_cameraCalc.distanceToSurface(), &Fact::rawValueChanged, this->)
...@@ -45,6 +50,11 @@ void CircularSurveyComplexItem::resetReference() ...@@ -45,6 +50,11 @@ void CircularSurveyComplexItem::resetReference()
setRefPoint(_surveyAreaPolygon.center()); setRefPoint(_surveyAreaPolygon.center());
} }
void CircularSurveyComplexItem::setReferencePointBeingChanged(bool changeing)
{
_referencePointBeingChanged = changeing;
}
void CircularSurveyComplexItem::setRefPoint(const QGeoCoordinate &refPt) void CircularSurveyComplexItem::setRefPoint(const QGeoCoordinate &refPt)
{ {
if (refPt != _referencePoint){ if (refPt != _referencePoint){
...@@ -83,6 +93,11 @@ bool CircularSurveyComplexItem::isInitialized() ...@@ -83,6 +93,11 @@ bool CircularSurveyComplexItem::isInitialized()
return _isInitialized; return _isInitialized;
} }
bool CircularSurveyComplexItem::referencePointBeingChanged()
{
return _referencePointBeingChanged;
}
bool CircularSurveyComplexItem::load(const QJsonObject &complexObject, int sequenceNumber, QString &errorString) bool CircularSurveyComplexItem::load(const QJsonObject &complexObject, int sequenceNumber, QString &errorString)
{ {
// We need to pull version first to determine what validation/conversion needs to be performed // We need to pull version first to determine what validation/conversion needs to be performed
...@@ -350,7 +365,7 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1() ...@@ -350,7 +365,7 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
using namespace PolygonCalculus; using namespace PolygonCalculus;
using namespace PlanimetryCalculus; using namespace PlanimetryCalculus;
if (!_isInitialized) if (!_isInitialized || _referencePointBeingChanged)
return; return;
_updateCounter++; _updateCounter++;
...@@ -369,6 +384,25 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1() ...@@ -369,6 +384,25 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
return; return;
} }
// reverse transects and return
if (_reverseOnly) {
QList<QList<CoordInfo_t>> transectsReverse;
for (auto list : _transects) {
QList<CoordInfo_t> listReverse;
for (auto coordinate : list)
listReverse.prepend(coordinate);
transectsReverse.prepend(listReverse);
}
_transects.clear();
_transects.append(transectsReverse);
_reverseOnly = false;
return;
}
_transects.clear(); _transects.clear();
QPolygonF surveyPolygon = toQPolygonF(toCartesian2D(_surveyAreaPolygon.coordinateList(), _referencePoint)); QPolygonF surveyPolygon = toQPolygonF(toCartesian2D(_surveyAreaPolygon.coordinateList(), _referencePoint));
...@@ -579,8 +613,11 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1() ...@@ -579,8 +613,11 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
// convert to CoordInfo_t // convert to CoordInfo_t
for ( const QList<QPointF> &transect : optiPath) { for ( QList<QPointF> &transect : optiPath) {
// for ( const QList<QPointF> &transect : fullPath) { // for ( const QList<QPointF> &transect : fullPath) {
if (_reverse.rawValue().toBool())
PolygonCalculus::reversePath(transect);
QList<QGeoCoordinate> geoPath = toGeo(transect, _referencePoint); QList<QGeoCoordinate> geoPath = toGeo(transect, _referencePoint);
QList<CoordInfo_t> transectList; QList<CoordInfo_t> transectList;
for ( const QGeoCoordinate &coordinate : geoPath) { for ( const QGeoCoordinate &coordinate : geoPath) {
...@@ -609,6 +646,13 @@ void CircularSurveyComplexItem::_recalcCameraShots() ...@@ -609,6 +646,13 @@ void CircularSurveyComplexItem::_recalcCameraShots()
_cameraShots = 0; _cameraShots = 0;
} }
void CircularSurveyComplexItem::_reverseTransects()
{
_reverseOnly = true;
_rebuildTransects();
}
Fact *CircularSurveyComplexItem::transectMinLength() Fact *CircularSurveyComplexItem::transectMinLength()
{ {
...@@ -620,6 +664,11 @@ Fact *CircularSurveyComplexItem::isSnakePath() ...@@ -620,6 +664,11 @@ Fact *CircularSurveyComplexItem::isSnakePath()
return &_isSnakePath; return &_isSnakePath;
} }
Fact *CircularSurveyComplexItem::reverse()
{
return &_reverse;
}
......
...@@ -23,9 +23,11 @@ public: ...@@ -23,9 +23,11 @@ public:
Q_PROPERTY(Fact* deltaAlpha READ deltaAlpha CONSTANT) Q_PROPERTY(Fact* deltaAlpha READ deltaAlpha CONSTANT)
Q_PROPERTY(Fact* transectMinLength READ transectMinLength CONSTANT) Q_PROPERTY(Fact* transectMinLength READ transectMinLength CONSTANT)
Q_PROPERTY(Fact* isSnakePath READ isSnakePath CONSTANT) Q_PROPERTY(Fact* isSnakePath READ isSnakePath CONSTANT)
Q_PROPERTY(Fact* reverse READ reverse CONSTANT)
Q_PROPERTY(bool isInitialized READ isInitialized WRITE setIsInitialized NOTIFY isInitializedChanged) Q_PROPERTY(bool isInitialized READ isInitialized WRITE setIsInitialized NOTIFY isInitializedChanged)
Q_INVOKABLE void resetReference(void); Q_INVOKABLE void resetReference(void);
Q_INVOKABLE void setReferencePointBeingChanged(bool changeing); // used by gui to indicate a changeing reference point (dagging by user)
// Property setters // Property setters
void setRefPoint(const QGeoCoordinate &refPt); void setRefPoint(const QGeoCoordinate &refPt);
...@@ -38,8 +40,10 @@ public: ...@@ -38,8 +40,10 @@ public:
Fact *deltaAlpha(); Fact *deltaAlpha();
Fact *transectMinLength(); Fact *transectMinLength();
Fact *isSnakePath(); Fact *isSnakePath();
Fact *reverse();
// Is true if survey was automatically generated, prevents initialisation from gui. // Is true if survey was automatically generated, prevents initialisation from gui.
bool isInitialized(); bool isInitialized();
bool referencePointBeingChanged(); // returns true if the referencepoint is being changed (dragged by user)
// Overrides from ComplexMissionItem // Overrides from ComplexMissionItem
bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final; bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final;
...@@ -64,6 +68,7 @@ public: ...@@ -64,6 +68,7 @@ public:
static const char* deltaAlphaName; static const char* deltaAlphaName;
static const char* transectMinLengthName; static const char* transectMinLengthName;
static const char* isSnakePathName; static const char* isSnakePathName;
static const char* reverseName;
static const char* jsonComplexItemTypeValue; static const char* jsonComplexItemTypeValue;
static const char* jsonDeltaRKey; static const char* jsonDeltaRKey;
...@@ -80,12 +85,14 @@ signals: ...@@ -80,12 +85,14 @@ signals:
private slots: private slots:
// Overrides from TransectStyleComplexItem // Overrides from TransectStyleComplexItem
void _rebuildTransectsPhase1 (void) final; void _rebuildTransectsPhase1 (void) final; // do not call this function, it is called by TransectStyleComplexItem::_rebuildTransects()
void _recalcComplexDistance (void) final; void _recalcComplexDistance (void) final;
void _recalcCameraShots (void) final; void _recalcCameraShots (void) final;
void _reverseTransects (void);
signals: signals:
private: private:
void _appendLoadedMissionItems(QList<MissionItem*>& items, QObject* missionItemParent); void _appendLoadedMissionItems(QList<MissionItem*>& items, QObject* missionItemParent);
void _buildAndAppendMissionItems(QList<MissionItem*>& items, QObject* missionItemParent); void _buildAndAppendMissionItems(QList<MissionItem*>& items, QObject* missionItemParent);
...@@ -100,10 +107,13 @@ private: ...@@ -100,10 +107,13 @@ private:
SettingsFact _deltaAlpha; // angle discretisation of the circles SettingsFact _deltaAlpha; // angle discretisation of the circles
SettingsFact _transectMinLength; // minimal transect lenght, transects are rejected if they are shorter than this value SettingsFact _transectMinLength; // minimal transect lenght, transects are rejected if they are shorter than this value
SettingsFact _isSnakePath; // bool value, determining if transects are connected in a snake like or zig zag like manner SettingsFact _isSnakePath; // bool value, determining if transects are connected in a snake like or zig zag like manner
SettingsFact _reverse; // reverses the _transects path
QTimer _updateTimer; QTimer _updateTimer;
bool _isInitialized; // indicates if the polygon and refpoint etc. are initialized, prevents reinitialisation from gui and execution of _rebuildTransectsPhase1 during init from gui bool _isInitialized; // indicates if the polygon and refpoint etc. are initialized, prevents reinitialisation from gui and execution of _rebuildTransectsPhase1 during init from gui
bool _reverseOnly; // if this is true _rebuildTransectsPhase1() will reverse the path only, _rebuildTransectsPhase1() resets _reverseOnly
bool _referencePointBeingChanged; // is set to true by gui, if user is changeing the reference point
int _updateCounter; int _updateCounter;
......
...@@ -40,6 +40,11 @@ WimaPlaner::WimaPlaner(QObject *parent) ...@@ -40,6 +40,11 @@ WimaPlaner::WimaPlaner(QObject *parent)
connect(&_autoLoadTimer, &QTimer::timeout, this, &WimaPlaner::autoLoadMission); connect(&_autoLoadTimer, &QTimer::timeout, this, &WimaPlaner::autoLoadMission);
_autoLoadTimer.setSingleShot(true); _autoLoadTimer.setSingleShot(true);
_autoLoadTimer.start(300); _autoLoadTimer.start(300);
_calcArrivalAndReturnPathTimer.setInterval(100);
_calcArrivalAndReturnPathTimer.setSingleShot(true);
connect(&_calcArrivalAndReturnPathTimer, &QTimer::timeout, this, &WimaPlaner::calcArrivalAndReturnPath);
} }
QmlObjectListModel* WimaPlaner::visualItems() QmlObjectListModel* WimaPlaner::visualItems()
...@@ -237,17 +242,19 @@ bool WimaPlaner::updateMission() ...@@ -237,17 +242,19 @@ bool WimaPlaner::updateMission()
_lastSurveyRefPoint = _measurementArea.center(); _lastSurveyRefPoint = _measurementArea.center();
_surveyRefChanging = false; _surveyRefChanging = false;
_circularSurvey->setIsInitialized(true); // prevents reinitialisation from gui _circularSurvey->setIsInitialized(true); // prevents reinitialisation from gui
connect(_circularSurvey->deltaR(), &Fact::rawValueChanged, this, &WimaPlaner::calcArrivalAndReturnPath); // connect(_circularSurvey->deltaR(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
connect(_circularSurvey->deltaAlpha(), &Fact::rawValueChanged, this, &WimaPlaner::calcArrivalAndReturnPath); // connect(_circularSurvey->deltaAlpha(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
connect(_circularSurvey->isSnakePath(), &Fact::rawValueChanged, this, &WimaPlaner::calcArrivalAndReturnPath); // connect(_circularSurvey->isSnakePath(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
connect(_circularSurvey->transectMinLength(), &Fact::rawValueChanged, this, &WimaPlaner::calcArrivalAndReturnPath); // connect(_circularSurvey->transectMinLength(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
// connect(_circularSurvey->reverse(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
connect(_circularSurvey, &TransectStyleComplexItem::visualTransectPointsChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
} }
// update survey area // update survey area
_circularSurvey->surveyAreaPolygon()->clear(); _circularSurvey->surveyAreaPolygon()->clear();
_circularSurvey->surveyAreaPolygon()->appendVertices(_measurementArea.coordinateList()); _circularSurvey->surveyAreaPolygon()->appendVertices(_measurementArea.coordinateList());
calcArrivalAndReturnPath(); //calcArrivalAndReturnPath();
setReadyForSync(true); setReadyForSync(true);
return true; return true;
...@@ -438,10 +445,12 @@ bool WimaPlaner::loadFromFile(const QString &filename) ...@@ -438,10 +445,12 @@ bool WimaPlaner::loadFromFile(const QString &filename)
_lastSurveyRefPoint = _circularSurvey->refPoint(); _lastSurveyRefPoint = _circularSurvey->refPoint();
_surveyRefChanging = false; _surveyRefChanging = false;
_circularSurvey->setIsInitialized(true); // prevents reinitialisation from gui _circularSurvey->setIsInitialized(true); // prevents reinitialisation from gui
connect(_circularSurvey->deltaR(), &Fact::rawValueChanged, this, &WimaPlaner::calcArrivalAndReturnPath); // connect(_circularSurvey->deltaR(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
connect(_circularSurvey->deltaAlpha(), &Fact::rawValueChanged, this, &WimaPlaner::calcArrivalAndReturnPath); // connect(_circularSurvey->deltaAlpha(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
connect(_circularSurvey->isSnakePath(), &Fact::rawValueChanged, this, &WimaPlaner::calcArrivalAndReturnPath); // connect(_circularSurvey->isSnakePath(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
connect(_circularSurvey->transectMinLength(), &Fact::rawValueChanged, this, &WimaPlaner::calcArrivalAndReturnPath); // connect(_circularSurvey->transectMinLength(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
// connect(_circularSurvey->reverse(), &Fact::rawValueChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
connect(_circularSurvey, &TransectStyleComplexItem::visualTransectPointsChanged, this, &WimaPlaner::startCalcArrivalAndReturnTimer);
break; break;
} }
} }
...@@ -481,6 +490,7 @@ void WimaPlaner::recalcPolygonInteractivity(int index) ...@@ -481,6 +490,7 @@ void WimaPlaner::recalcPolygonInteractivity(int index)
bool WimaPlaner::calcArrivalAndReturnPath() bool WimaPlaner::calcArrivalAndReturnPath()
{ {
static int counter = 0;
setReadyForSync(false); setReadyForSync(false);
// extract old survey data // extract old survey data
...@@ -595,6 +605,9 @@ bool WimaPlaner::calcArrivalAndReturnPath() ...@@ -595,6 +605,9 @@ bool WimaPlaner::calcArrivalAndReturnPath()
_missionController->setCurrentPlanViewIndex(missionItems->indexOf(_circularSurvey), false); _missionController->setCurrentPlanViewIndex(missionItems->indexOf(_circularSurvey), false);
setSyncronizedWithControllerFalse(); setSyncronizedWithControllerFalse();
setReadyForSync(true); setReadyForSync(true);
counter++;
qWarning() << "WimaPlaner::calcArrivalAndReturnPath(): " << counter;
return true; return true;
} }
...@@ -752,20 +765,20 @@ void WimaPlaner::updateTimerSlot() ...@@ -752,20 +765,20 @@ void WimaPlaner::updateTimerSlot()
// Check if parameter has changed, wait until it stops changing, update mission // Check if parameter has changed, wait until it stops changing, update mission
// circular survey reference point // circular survey reference point
if (_missionController != nullptr // if (_missionController != nullptr
&& _missionController->visualItems()->indexOf(_circularSurvey) != -1 // && _missionController->visualItems()->indexOf(_circularSurvey) != -1
&& _circularSurvey != nullptr) // && _circularSurvey != nullptr)
{ // {
if (_surveyRefChanging) { // if (_surveyRefChanging) {
if (_circularSurvey->refPoint() == _lastSurveyRefPoint) { // is it still changing? // if (_circularSurvey->refPoint() == _lastSurveyRefPoint) { // is it still changing?
calcArrivalAndReturnPath(); // calcArrivalAndReturnPath();
_surveyRefChanging = false; // _surveyRefChanging = false;
} // }
} else { // } else {
if (_circularSurvey->refPoint() != _lastSurveyRefPoint) // does it started changing? // if (_circularSurvey->refPoint() != _lastSurveyRefPoint) // does it started changing?
_surveyRefChanging = true; // _surveyRefChanging = true;
} // }
} // }
// measurementArea // measurementArea
if (_measurementAreaChanging) { if (_measurementAreaChanging) {
...@@ -802,10 +815,10 @@ void WimaPlaner::updateTimerSlot() ...@@ -802,10 +815,10 @@ void WimaPlaner::updateTimerSlot()
// update old values // update old values
if (_missionController != nullptr // if (_missionController != nullptr
&& _missionController->visualItems()->indexOf(_circularSurvey) != -1 // && _missionController->visualItems()->indexOf(_circularSurvey) != -1
&& _circularSurvey != nullptr) // && _circularSurvey != nullptr)
_lastSurveyRefPoint = _circularSurvey->refPoint(); // _lastSurveyRefPoint = _circularSurvey->refPoint();
_lastMeasurementAreaPath = _measurementArea.path(); _lastMeasurementAreaPath = _measurementArea.path();
_lastCorridorPath = _corridor.path(); _lastCorridorPath = _corridor.path();
...@@ -823,6 +836,11 @@ void WimaPlaner::autoLoadMission() ...@@ -823,6 +836,11 @@ void WimaPlaner::autoLoadMission()
pushToContainer(); pushToContainer();
} }
void WimaPlaner::startCalcArrivalAndReturnTimer()
{
_calcArrivalAndReturnPathTimer.start();
}
QJsonDocument WimaPlaner::saveToJson(FileType fileType) QJsonDocument WimaPlaner::saveToJson(FileType fileType)
{ {
/// This function save all areas (of WimaPlaner) and all mission items (of MissionController) to a QJsonDocument /// This function save all areas (of WimaPlaner) and all mission items (of MissionController) to a QJsonDocument
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "PlanimetryCalculus.h" #include "PlanimetryCalculus.h"
#include "GeoUtilities.h" #include "GeoUtilities.h"
#include "QSignalBlocker"
#define TEST_FUN 0 #define TEST_FUN 0
#if TEST_FUN #if TEST_FUN
...@@ -134,6 +136,7 @@ private slots: ...@@ -134,6 +136,7 @@ private slots:
void updateTimerSlot (); void updateTimerSlot ();
void setSyncronizedWithControllerFalse (void); void setSyncronizedWithControllerFalse (void);
void autoLoadMission (void); void autoLoadMission (void);
void startCalcArrivalAndReturnTimer (void);
private: private:
signals: signals:
void joinedAreaValidChanged(); void joinedAreaValidChanged();
...@@ -177,4 +180,5 @@ private: ...@@ -177,4 +180,5 @@ private:
bool _readyForSync; // gets set by updateMission and calcArrivalAndReturnPath bool _readyForSync; // gets set by updateMission and calcArrivalAndReturnPath
QTimer _autoLoadTimer; // timer to auto load mission after some time, prevents seg. faults QTimer _autoLoadTimer; // timer to auto load mission after some time, prevents seg. faults
QTimer _calcArrivalAndReturnPathTimer;
}; };
...@@ -14,6 +14,9 @@ MapQuickItem { ...@@ -14,6 +14,9 @@ MapQuickItem {
property bool checked property bool checked
signal clicked signal clicked
signal released
signal entered
signal exited
anchorPoint.x: sourceItem.anchorPointX anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.anchorPointY anchorPoint.y: sourceItem.anchorPointY
...@@ -27,6 +30,9 @@ MapQuickItem { ...@@ -27,6 +30,9 @@ MapQuickItem {
gimbalYaw: 0 gimbalYaw: 0
vehicleYaw: 0 vehicleYaw: 0
showGimbalYaw: false showGimbalYaw: false
onClicked: _item.clicked() onClicked: _item.clicked()
onReleased: _item.released()
onEntered: _item.entered()
onExited: _item.exited()
} }
} }
...@@ -32,6 +32,7 @@ Rectangle { ...@@ -32,6 +32,7 @@ Rectangle {
signal clicked signal clicked
signal dragStart signal dragStart
signal dragStop signal dragStop
signal released
property bool _preventCoordinateBindingLoop: false property bool _preventCoordinateBindingLoop: false
...@@ -77,6 +78,10 @@ Rectangle { ...@@ -77,6 +78,10 @@ Rectangle {
itemDragger.clicked() itemDragger.clicked()
} }
onReleased: {
itemDragger.released()
}
property bool dragActive: drag.active property bool dragActive: drag.active
onDragActiveChanged: { onDragActiveChanged: {
if (dragActive) { if (dragActive) {
......
...@@ -34,6 +34,14 @@ Item { ...@@ -34,6 +34,14 @@ Item {
property bool _dragAreaShowing: false property bool _dragAreaShowing: false
signal clicked(int sequenceNumber) signal clicked(int sequenceNumber)
signal released(int sequenceNumber)
signal entered(int sequenceNumber)
signal exited(int sequenceNumber)
signal dragStart()
signal dragStop()
signal dragClicked()
signal dragReleased()
function hideItemVisuals() { function hideItemVisuals() {
if (_itemVisualShowing) { if (_itemVisualShowing) {
...@@ -94,6 +102,11 @@ Item { ...@@ -94,6 +102,11 @@ Item {
Component.onCompleted: itemCoordinate = _root.coordinate Component.onCompleted: itemCoordinate = _root.coordinate
onItemCoordinateChanged: _root.coordinate = itemCoordinate onItemCoordinateChanged: _root.coordinate = itemCoordinate
onDragStart: _root.dragStart()
onDragStop: _root.dragStop()
onClicked: _root.dragClicked()
onReleased: _root.dragReleased()
} }
} }
...@@ -107,7 +120,10 @@ Item { ...@@ -107,7 +120,10 @@ Item {
sequenceNumber: _root.sequenceNumber sequenceNumber: _root.sequenceNumber
coordinate: _root.coordinate coordinate: _root.coordinate
onClicked: _root.clicked(_missionItem.sequenceNumber) onClicked: _root.clicked(_missionItem.sequenceNumber)
onReleased: _root.released(_missionItem.sequenceNumber)
onEntered: _root.entered(_missionItem.sequenceNumber)
onExited: _root.exited(_missionItem.sequenceNumber)
} }
} }
} }
...@@ -186,7 +186,20 @@ Item { ...@@ -186,7 +186,20 @@ Item {
} }
} }
onClicked: _root.clicked(_missionItem.sequenceNumber) onClicked: {
_root.clicked(_missionItem.sequenceNumber)
_missionItem.setReferencePointBeingChanged(true)
}
onDragClicked: {// replace with entered
_missionItem.setReferencePointBeingChanged(true)
console.log('onDragClicked')
}
onDragReleased: { // replace with exited
_missionItem.setReferencePointBeingChanged(false)
console.log('onDragReleased')
}
} }
} }
} }
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