Commit e789e194 authored by Valentin Platzgummer's avatar Valentin Platzgummer

circular survey issues fixed

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