diff --git a/src/ui/flightdisplay/FlightDisplay.qml b/src/ui/flightdisplay/FlightDisplay.qml index a3c6d68613aa233b564a8a99792a6a7c29089084..074f9a253031523fbb0dddb98fec8653f840465a 100644 --- a/src/ui/flightdisplay/FlightDisplay.qml +++ b/src/ui/flightdisplay/FlightDisplay.qml @@ -482,6 +482,7 @@ Item { heading: 0 // isNaN(MavManager.heading) ? 0 : MavManager.heading latitude: mapBackground.visible ? ((MavManager.latitude === 0) ? 37.803784 : MavManager.latitude) : 37.803784 longitude: mapBackground.visible ? ((MavManager.longitude === 0) ? -122.462276 : MavManager.longitude) : -122.462276 + readOnly: true //interactive: !MavManager.mavPresent z: 10 } diff --git a/src/ui/qmlcommon/QGCMapBackground.qml b/src/ui/qmlcommon/QGCMapBackground.qml index 4d6d51fe08842c664a6e05371ff4a7067ce72af0..98b5a92428c4204bbed28019144c7f82f07b7335 100644 --- a/src/ui/qmlcommon/QGCMapBackground.qml +++ b/src/ui/qmlcommon/QGCMapBackground.qml @@ -52,6 +52,7 @@ Item { property alias mapItem: map property alias waypoints: polyLine property alias mapMenu: mapTypeMenu + property alias readOnly: map.readOnly Component.onCompleted: { map.zoomLevel = 18 @@ -142,8 +143,11 @@ Item { polyLine.addCoordinate(coord); map.addMarker(coord, MavManager.waypoints[i].id); } - root.longitude = MavManager.waypoints[0].longitude - root.latitude = MavManager.waypoints[0].latitude + if (typeof MavManager.waypoints != 'undefined' && MavManager.waypoints.length > 0) { + root.longitude = MavManager.waypoints[0].longitude + root.latitude = MavManager.waypoints[0].latitude + } + map.changed = false } } } @@ -166,10 +170,17 @@ Item { Map { id: map - property real lon: (longitude >= -180 && longitude <= 180) ? longitude : 0 - property real lat: (latitude >= -90 && latitude <= 90) ? latitude : 0 + + property real lon: (longitude >= -180 && longitude <= 180) ? longitude : 0 + property real lat: (latitude >= -90 && latitude <= 90) ? latitude : 0 + property int currentMarker + property int pressX : -1 + property int pressY : -1 + property bool changed: false + property bool readOnly: false property variant scaleLengths: [5, 10, 25, 50, 100, 150, 250, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000] property variant markers + plugin: mapPlugin width: 1 height: 1 @@ -203,13 +214,23 @@ Item { scaleTimer.restart() } + function updateMarker(coord, wpid) + { + if(wpid < polyLine.path.length) { + var tmpPath = polyLine.path; + tmpPath[wpid] = coord; + polyLine.path = tmpPath; + map.changed = true; + } + } + function addMarker(coord, wpid) { var marker = Qt.createQmlObject ('QGCWaypoint {}', map) map.addMapItem(marker) marker.z = map.z + 1 marker.coordinate = coord - marker.waypointID.text = wpid + marker.waypointID = wpid // Update list of markers var count = map.markers.length var myArray = [] @@ -261,7 +282,7 @@ Item { id: polyLine visible: path.length > 1 && root.showWaypoints line.width: 3 - line.color: "#e35cd8" + line.color: map.changed ? "#f97a2e" : "#e35cd8" smooth: true antialiasing: true } diff --git a/src/ui/qmlcommon/QGCWaypoint.qml b/src/ui/qmlcommon/QGCWaypoint.qml index abc65b69518a860067a3c567c38c01a33bb13eb8..29d59ae38647fe1c62eac7b4fc43ee8d24013488 100644 --- a/src/ui/qmlcommon/QGCWaypoint.qml +++ b/src/ui/qmlcommon/QGCWaypoint.qml @@ -32,20 +32,50 @@ import QtLocation 5.3 MapQuickItem { id: marker - property alias waypointID: number - anchorPoint.x: image.width / 2 - anchorPoint.y: image.height / 2 + property int waypointID: 0 + anchorPoint.x: markerIcon.width / 2 + anchorPoint.y: markerIcon.height / 2 sourceItem: Rectangle { - id: image - width: 24 - height: 24 + id: markerIcon + width: 30 + height: 30 + color: markerMouseArea.containsMouse ? (markerMouseArea.pressed ? Qt.rgba(0.69,0.2,0.68,0.25) : Qt.rgba(0.69,0.2,0.68,0.75)) : Qt.rgba(0,0,0,0.5) + radius: 8 border.color: Qt.rgba(0,0,0,0.75) - color: Qt.rgba(0,0,0,0.5) Text { id: number anchors.centerIn: parent - font.pointSize: 10 + font.pointSize: 11 + font.weight: Font.DemiBold color: "white" + text: marker.waypointID + } + MouseArea { + id: markerMouseArea + enabled: !map.readOnly + anchors.fill: parent + hoverEnabled: true + drag.target: marker + preventStealing: true + property int pressX : -1 + property int pressY : -1 + property int jitterThreshold : 4 + onPressed : { + pressX = mouse.x; + pressY = mouse.y; + map.currentMarker = -1; + for (var i = 0; i < map.markers.length; i++) { + if (marker === map.markers[i]) { + map.currentMarker = i; + break; + } + } + } + onPositionChanged: { + if (Math.abs(pressX - mouse.x ) < jitterThreshold && Math.abs(pressY - mouse.y) < jitterThreshold) { + map.updateMarker(marker.coordinate, marker.waypointID) + } + } } } }