From 0825be1c90aee45890f3feb765ce7944741663dd Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Tue, 1 Sep 2015 14:21:39 -0400 Subject: [PATCH] Handle different vehicle position graphics based on the current map type. --- qgroundcontrol.qrc | 2 ++ src/FlightMap/FlightMap.qml | 26 ++++++++++++++++++++++- src/FlightMap/Images/airplaneOpaque.svg | 10 +++++++++ src/FlightMap/Images/airplaneOutline.svg | 10 +++++++++ src/FlightMap/MapItems/VehicleMapItem.qml | 5 +++-- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/FlightMap/Images/airplaneOpaque.svg create mode 100644 src/FlightMap/Images/airplaneOutline.svg diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 36df1d219..795ddb432 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -59,6 +59,8 @@ src/FlightMap/Images/rollPointerWhite.svg src/FlightMap/Images/scale.png src/FlightMap/Images/scale_end.png + src/FlightMap/Images/airplaneOutline.svg + src/FlightMap/Images/airplaneOpaque.svg src/test.qml diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index a32c4ee91..38fb13c6c 100644 --- a/src/FlightMap/FlightMap.qml +++ b/src/FlightMap/FlightMap.qml @@ -53,6 +53,7 @@ Item { property alias mapMenu: mapTypeMenu property bool showVehicles: false property bool showMissionItems: false + property bool isSatelliteMap: false Component.onCompleted: { map.zoomLevel = 18 @@ -62,6 +63,15 @@ Item { updateMissionItems() } + function updateMapType(type) { + var isSatellite = (type === MapType.SatelliteMapDay || type === MapType.SatelliteMapNight) + if(isSatelliteMap !== isSatellite) { + isSatelliteMap = isSatellite; + removeAllVehicles() + addExistingVehicles() + } + } + //-- Menu to select supported map types Menu { id: mapTypeMenu @@ -72,6 +82,7 @@ Item { for (var i = 0; i < map.supportedMapTypes.length; i++) { if (mapID === map.supportedMapTypes[i].name) { map.activeMapType = map.supportedMapTypes[i] + updateMapType(map.supportedMapTypes[i].style) multiVehicleManager.saveSetting(root.mapName + "/currentMapType", mapID); return; } @@ -164,7 +175,8 @@ Item { var qmlItemTemplate = "VehicleMapItem { " + "coordinate: _vehicles[%1].coordinate; " + - "heading: _vehicles[%1].heading " + + "heading: _vehicles[%1].heading; " + + "isSatellite: root.isSatelliteMap; " + "}" var i = _vehicles.length @@ -194,6 +206,18 @@ Item { } } + function removeAllVehicles() { + if (!showVehicles) { + return + } + + for (var i=0; i<_vehicles.length; i++) { + _vehicles[i] = undefined + map.removeMapItem(_vehicleMapItems[i]) + _vehicleMapItems[i] = undefined + } + } + function addExistingVehicles() { if (!showVehicles) { return diff --git a/src/FlightMap/Images/airplaneOpaque.svg b/src/FlightMap/Images/airplaneOpaque.svg new file mode 100644 index 000000000..c9ac663f1 --- /dev/null +++ b/src/FlightMap/Images/airplaneOpaque.svg @@ -0,0 +1,10 @@ + + + +Layer 1 + + diff --git a/src/FlightMap/Images/airplaneOutline.svg b/src/FlightMap/Images/airplaneOutline.svg new file mode 100644 index 000000000..686381d43 --- /dev/null +++ b/src/FlightMap/Images/airplaneOutline.svg @@ -0,0 +1,10 @@ + + + +Layer 1 + + diff --git a/src/FlightMap/MapItems/VehicleMapItem.qml b/src/FlightMap/MapItems/VehicleMapItem.qml index 0dab13fbc..2da49863e 100644 --- a/src/FlightMap/MapItems/VehicleMapItem.qml +++ b/src/FlightMap/MapItems/VehicleMapItem.qml @@ -32,15 +32,16 @@ import QGroundControl.ScreenTools 1.0 /// Marker for displaying a vehicle location on the map MapQuickItem { property real heading: 0 + property bool isSatellite: false anchorPoint.x: vehicleIcon.width / 2 anchorPoint.y: vehicleIcon.height / 2 sourceItem: Image { id: vehicleIcon - source: "/qmlimages/compassInstrumentAirplane.svg" + source: isSatellite ? "/qmlimages/airplaneOpaque.svg" : "/qmlimages/airplaneOutline.svg" mipmap: true - width: ScreenTools.defaultFontPixelHeight * 4 + width: ScreenTools.defaultFontPixelHeight * 5 fillMode: Image.PreserveAspectFit transform: Rotation { -- 2.22.0