diff --git a/src/MissionManager/QGCMapPolygon.cc b/src/MissionManager/QGCMapPolygon.cc index 6b607e3862eb5c7333ab4e6441f612e3d57dc67f..eecb5069d2f60cc5f91357f28dbd46681fd5e459 100644 --- a/src/MissionManager/QGCMapPolygon.cc +++ b/src/MissionManager/QGCMapPolygon.cc @@ -56,9 +56,11 @@ const QGCMapPolygon& QGCMapPolygon::operator=(const QGCMapPolygon& other) clear(); QVariantList vertices = other.path(); - for (int i=0; i()); + QList rgCoord; + foreach (const QVariant& vertexVar, vertices) { + rgCoord.append(vertexVar.value()); } + appendVertices(rgCoord); setDirty(true); @@ -270,7 +272,6 @@ void QGCMapPolygon::appendVertices(const QList& coordinates) emit pathChanged(); } - void QGCMapPolygon::_polygonModelDirtyChanged(bool dirty) { if (dirty) { @@ -447,9 +448,7 @@ void QGCMapPolygon::offset(double distance) // Update internals clear(); - for (int i=0; ishowMessage(tr("Unable to find Polygon node in KML")); + qgcApp()->showMessage(tr("Unable to find LineString node in KML")); return false; } - QDomNode coordinatesNode = rgNodes.item(0).namedItem("outerBoundaryIs").namedItem("LinearRing").namedItem("coordinates"); + QDomNode coordinatesNode = rgNodes.item(0).namedItem("coordinates"); if (coordinatesNode.isNull()) { qgcApp()->showMessage(tr("Internal error: Unable to find coordinates node in KML")); return false; @@ -386,29 +386,8 @@ bool QGCMapPolyline::loadKMLFile(const QString& kmlFile) rgCoords.append(coord); } - // Determine winding, reverse if needed - double sum = 0; - for (int i=0; i rgReversed; - - for (int i=0; i& coordinates) +{ + QList objects; + + foreach (const QGeoCoordinate& coordinate, coordinates) { + objects.append(new QGCQGeoCoordinate(coordinate, this)); + _polylinePath.append(QVariant::fromValue(coordinate)); + } + _polylineModel.append(objects); + emit pathChanged(); +} diff --git a/src/MissionManager/QGCMapPolyline.h b/src/MissionManager/QGCMapPolyline.h index f4ec936b2e2bebaab59f84c0d08d4f7b970d4ad3..08389a0416eda69e18996b0e2515e129206dc272 100644 --- a/src/MissionManager/QGCMapPolyline.h +++ b/src/MissionManager/QGCMapPolyline.h @@ -34,6 +34,7 @@ public: Q_INVOKABLE void clear(void); Q_INVOKABLE void appendVertex(const QGeoCoordinate& coordinate); Q_INVOKABLE void removeVertex(int vertexIndex); + Q_INVOKABLE void appendVertices(const QList& coordinates); /// Adjust the value for the specified coordinate /// @param vertexIndex Polygon point index to modify (0-based) diff --git a/src/MissionManager/QGCMapPolylineVisuals.qml b/src/MissionManager/QGCMapPolylineVisuals.qml index 27f9ed8a787b0fb76effea19e02e4ed687fc69b4..07a25aee02990aaa1c42dc53315ff721e0990c40 100644 --- a/src/MissionManager/QGCMapPolylineVisuals.qml +++ b/src/MissionManager/QGCMapPolylineVisuals.qml @@ -120,13 +120,28 @@ Item { selectExisting: true nameFilters: [ qsTr("KML files (*.kml)") ] - onAcceptedForLoad: { mapPolyline.loadKMLFile(file) close() } } + Menu { + id: menu + + property int removeVertex + + MenuItem { + text: qsTr("Remove vertex" ) + onTriggered: mapPolyline.removeVertex(parent.removeVertex) + } + + MenuItem { + text: qsTr("Load KML...") + onTriggered: kmlLoadDialog.openForLoad() + } + } + Component { id: polylineComponent @@ -227,7 +242,15 @@ Item { } } - onClicked: mapPolyline.removeVertex(polylineVertex) + onClicked: { + if (polylineVertex == 0) { + menu.removeVertex = polylineVertex + menu.popup() + } else { + mapPolyline.removeVertex(polylineVertex) + } + } + } } @@ -249,6 +272,14 @@ Item { radius: width / 2 color: "white" opacity: .90 + + QGCLabel { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + text: "..." + color: "black" + visible: polylineVertex == 0 + } } } } diff --git a/src/MissionManager/TransectStyle.SettingsGroup.json b/src/MissionManager/TransectStyle.SettingsGroup.json index f1bdf254f0bde0e4c7a6e3fc624e7ce1422b18b9..fe86299eab363ec46080c5fdf63628ec168b68e8 100644 --- a/src/MissionManager/TransectStyle.SettingsGroup.json +++ b/src/MissionManager/TransectStyle.SettingsGroup.json @@ -37,7 +37,7 @@ }, { "name": "TerrainAdjustTolerance", - "shortDescription": "TerrainAdjustTolerance", + "shortDescription": "If adjacent terrain waypoints are within this tolerence they will be removed.", "type": "double", "decimalPlaces": 2, "min": 0, @@ -46,7 +46,7 @@ }, { "name": "TerrainAdjustMaxClimbRate", - "shortDescription": "TerrainAdjustMaxClimbRate", + "shortDescription": "The maximum climb rate from one waypoint to another when adjusting for terrain. Set to 0 for no max.", "type": "double", "decimalPlaces": 2, "min": 0, @@ -55,7 +55,7 @@ }, { "name": "TerrainAdjustMaxDescentRate", - "shortDescription": "TerrainAdjustMaxDescentRate", + "shortDescription": "The maximum descent rate from one waypoint to another when adjusting for terrain. Set to 0 for no max.", "type": "double", "decimalPlaces": 2, "min": 0, diff --git a/src/MissionManager/TransectStyleComplexItem.cc b/src/MissionManager/TransectStyleComplexItem.cc index 842199ee0f37c27d18cff0f870e752d9f3139857..966408cfb9f14023a057cd3db9c71584dffff1e4 100644 --- a/src/MissionManager/TransectStyleComplexItem.cc +++ b/src/MissionManager/TransectStyleComplexItem.cc @@ -500,7 +500,7 @@ int TransectStyleComplexItem::_maxPathHeight(const TerrainPathQuery::PathHeightI void TransectStyleComplexItem::_adjustForMaxRates(QList& transect) { double maxClimbRate = _terrainAdjustMaxClimbRateFact.rawValue().toDouble(); - double maxDescentRate = -_terrainAdjustMaxDescentRateFact.rawValue().toDouble(); + double maxDescentRate = _terrainAdjustMaxDescentRateFact.rawValue().toDouble(); double flightSpeed = _missionFlightStatus.vehicleSpeed; if (qIsNaN(flightSpeed) || (maxClimbRate == 0 && maxDescentRate == 0)) { @@ -510,55 +510,60 @@ void TransectStyleComplexItem::_adjustForMaxRates(QList& transect) return; } - // Adjust climb rates - bool climbRateAdjusted; - do { - //qDebug() << "climbrate pass"; - climbRateAdjusted = false; - for (int i=0; i 0 && climbRate - maxClimbRate > 0.1) { - double maxAltitudeDelta = maxClimbRate * seconds; - fromCoord.setAltitude(toCoord.altitude() - maxAltitudeDelta); - //qDebug() << "Adjusting"; - climbRateAdjusted = true; + if (maxClimbRate > 0) { + // Adjust climb rates + bool climbRateAdjusted; + do { + //qDebug() << "climbrate pass"; + climbRateAdjusted = false; + for (int i=0; i 0 && climbRate - maxClimbRate > 0.1) { + double maxAltitudeDelta = maxClimbRate * seconds; + fromCoord.setAltitude(toCoord.altitude() - maxAltitudeDelta); + //qDebug() << "Adjusting"; + climbRateAdjusted = true; + } } - } - } while (climbRateAdjusted); - - // Adjust descent rates - bool descentRateAdjusted; - do { - //qDebug() << "descent rate pass"; - descentRateAdjusted = false; - for (int i=1; i 0) { + // Adjust descent rates + bool descentRateAdjusted; + maxDescentRate = -maxDescentRate; + do { + //qDebug() << "descent rate pass"; + descentRateAdjusted = false; + for (int i=1; i& transect)