diff --git a/ToDo.txt b/ToDo.txt index 826c69f1dd444b493478e2255c5ab93166a21ac1..a286f8f35f1238f54ca70c6d03501169e40fdb01 100644 --- a/ToDo.txt +++ b/ToDo.txt @@ -1,4 +1,5 @@ -optimize circular survey +(improve) optimisation circular survey profile survey add dijkstra to flight view +add save and load to circular survey diff --git a/src/PlanView/CircularSurveyItemEditor.qml b/src/PlanView/CircularSurveyItemEditor.qml index 0caff7599d5ad774e8606b5db782d79b446908cd..f7f8eada54cb4e0a8732a303845a13f583b88842 100644 --- a/src/PlanView/CircularSurveyItemEditor.qml +++ b/src/PlanView/CircularSurveyItemEditor.qml @@ -110,7 +110,7 @@ Rectangle { Layout.columnSpan: 2 Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 1.5 onValueChanged: missionItem.deltaAlpha.value = value - Component.onCompleted: value = missionItem.deltaAlpha.defaultValue + Component.onCompleted: value = missionItem.deltaAlpha.value updateValueWhileDragging: true } } diff --git a/src/Wima/CircularSurveyComplexItem.cc b/src/Wima/CircularSurveyComplexItem.cc index 839c216b6a599ab671bf44f63de1691f223472b3..d6cd83206806b587a013eae898cb8c44df543c61 100644 --- a/src/Wima/CircularSurveyComplexItem.cc +++ b/src/Wima/CircularSurveyComplexItem.cc @@ -247,43 +247,47 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1() } } -// // optimize path to lawn pattern -// if (fullPath.size() == 0) -// return; -// QList currentSection = fullPath.takeFirst(); -// QList> optiPath; // optimized path -// while( !fullPath.empty() ) { -// optiPath.append(currentSection); -// QPointF endVertex = currentSection.last(); -// double minDist = std::numeric_limits::infinity(); -// int index = 0; -// bool reversePath = false; - -// // iterate over all paths in fullPath and assign the one with the shortest distance to endVertex to currentSection -// for (int i = 0; i < fullPath.size(); i++) { -// auto iteratorPath = fullPath[i]; -// double dist = PlanimetryCalculus::distance(endVertex, iteratorPath.first()); -// if ( dist < minDist ) { -// minDist = dist; -// index = i; -// } -// dist = PlanimetryCalculus::distance(endVertex, iteratorPath.last()); -// if (dist < minDist) { -// minDist = dist; -// index = i; -// reversePath = true; -// } -// } -// currentSection = fullPath.takeAt(index); -// if (reversePath) { -// PolygonCalculus::reversePath(currentSection); -// } -// } + // optimize path to lawn pattern + if (fullPath.size() == 0) + return; + QList currentSection = fullPath.takeFirst(); + if ( currentSection.isEmpty() ) + return; + QList> optiPath; // optimized path + while( !fullPath.empty() ) { + optiPath.append(currentSection); + QPointF endVertex = currentSection.last(); + double minDist = std::numeric_limits::infinity(); + int index = 0; + bool reversePath = false; + + // iterate over all paths in fullPath and assign the one with the shortest distance to endVertex to currentSection + for (int i = 0; i < fullPath.size(); i++) { + auto iteratorPath = fullPath[i]; + double dist = PlanimetryCalculus::distance(endVertex, iteratorPath.first()); + if ( dist < minDist ) { + minDist = dist; + index = i; + } + dist = PlanimetryCalculus::distance(endVertex, iteratorPath.last()); + if (dist < minDist) { + minDist = dist; + index = i; + reversePath = true; + } + } + currentSection = fullPath.takeAt(index); + if (reversePath) { + PolygonCalculus::reversePath(currentSection); + } + } + + optiPath.append(currentSection); // append last section // convert to CoordInfo_t -// for ( const QList &transect : optiPath) { - for ( const QList &transect : fullPath) { + for ( const QList &transect : optiPath) { +// for ( const QList &transect : fullPath) { QList geoPath = toGeo(transect, _referencePoint); QList transectList; for ( const QGeoCoordinate &coordinate : geoPath) { diff --git a/src/Wima/WimaPlaner.cc b/src/Wima/WimaPlaner.cc index 902ce28e1e62090ce83b400e06a41823a1b0b99c..349f809a75f89e3286da2cde082c0547794d43da 100644 --- a/src/Wima/WimaPlaner.cc +++ b/src/Wima/WimaPlaner.cc @@ -299,8 +299,11 @@ bool WimaPlaner::updateMission() } QGeoCoordinate start = _serviceArea.center(); QGeoCoordinate end = survey->coordinate(); + +#ifdef QT_DEBUG if (!_visualItems.contains(&_joinedArea)) _visualItems.append(&_joinedArea); +#endif QList path; if ( !calcShortestPath(start, end, path)) { diff --git a/src/WimaView/CoordinateIndicator.qml b/src/WimaView/CoordinateIndicator.qml index 72b94dfa1ada6c837dd0e69ad05eff5303251b00..cc6442c16eb515c79d6828d0ff0f5661de42cb92 100644 --- a/src/WimaView/CoordinateIndicator.qml +++ b/src/WimaView/CoordinateIndicator.qml @@ -11,7 +11,7 @@ MapQuickItem { property int sequenceNumber property string label - //property bool visible + property bool checked signal clicked @@ -21,7 +21,7 @@ MapQuickItem { sourceItem: MissionItemIndexLabel { id: _label - checked: _item.visible + checked: _item.checked label: _item.label index: _item.sequenceNumber gimbalYaw: 0 diff --git a/src/WimaView/DragCoordinate.qml b/src/WimaView/DragCoordinate.qml index 4bc6dd0e7bfbf9ae01410d7c878081c103387ecd..c4f6e1677560ee1aba647a5f7c7e08c7f0f9069c 100644 --- a/src/WimaView/DragCoordinate.qml +++ b/src/WimaView/DragCoordinate.qml @@ -22,11 +22,11 @@ import QGroundControl.FlightMap 1.0 Item { id: _root - property var map ///< Map control to place item in - property var qgcView ///< QGCView to use for popping dialogs - //property var visible - property var coordinate - property int sequenceNumber + property var map ///< Map control to place item in + property var qgcView ///< QGCView to use for popping dialogs + property var coordinate + property int sequenceNumber + property bool checked property var _itemVisual property bool _itemVisualShowing: false @@ -66,7 +66,7 @@ Item { Component.onCompleted: { showItemVisuals() - if (visible && map.planView) { + if (checked && map.planView) { showDragArea() } } @@ -76,8 +76,8 @@ Item { hideItemVisuals() } - onVisibleChanged: { - if (visible) { + onCheckedChanged: { + if (checked) { showDragArea() } else { hideDragArea() @@ -102,7 +102,7 @@ Item { CoordinateIndicator { label: "Reference" - visible: _root.visible + checked: _root.checked z: QGroundControl.zOrderMapItems sequenceNumber: _root.sequenceNumber coordinate: _root.coordinate diff --git a/src/WimaView/SphericalSurveyMapVisual.qml b/src/WimaView/SphericalSurveyMapVisual.qml index d1f96e3a2b22a7abfba3ac935c948f7862a38f33..907afa6e80b7caddb7d329dc0d4a6a4b06d13648 100644 --- a/src/WimaView/SphericalSurveyMapVisual.qml +++ b/src/WimaView/SphericalSurveyMapVisual.qml @@ -173,10 +173,11 @@ Item { map: _root.map qgcView: _root.qgcView z: QGroundControl.zOrderMapItems - visible: _missionItem.isCurrentItem + checked: _missionItem.isCurrentItem coordinate: _missionItem.refPoint - onCoordinateChanged: _missionItem.refPoint = coordinate + onCoordinateChanged: _missionItem.refPoint = coordinate + onClicked: _root.clicked(_missionItem.sequenceNumber) } } }