|
|
|
@ -110,70 +110,69 @@ Item {
@@ -110,70 +110,69 @@ Item {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function calculateScale() { |
|
|
|
|
var scaleLinePixelLength = 100 |
|
|
|
|
var leftCoord = mapControl.toCoordinate(Qt.point(0, scale.y), false /* clipToViewPort */) |
|
|
|
|
var rightCoord = mapControl.toCoordinate(Qt.point(scaleLinePixelLength, scale.y), false /* clipToViewPort */) |
|
|
|
|
var scaleLineMeters = Math.round(leftCoord.distanceTo(rightCoord)) |
|
|
|
|
|
|
|
|
|
if (QGroundControl.settingsManager.unitsSettings.distanceUnits.value === UnitsSettings.DistanceUnitsFeet) { |
|
|
|
|
calculateFeetRatio(scaleLineMeters, scaleLinePixelLength) |
|
|
|
|
} else { |
|
|
|
|
calculateMetersRatio(scaleLineMeters, scaleLinePixelLength) |
|
|
|
|
if(mapControl) { |
|
|
|
|
var scaleLinePixelLength = 100 |
|
|
|
|
var leftCoord = mapControl.toCoordinate(Qt.point(0, scale.y), false /* clipToViewPort */) |
|
|
|
|
var rightCoord = mapControl.toCoordinate(Qt.point(scaleLinePixelLength, scale.y), false /* clipToViewPort */) |
|
|
|
|
var scaleLineMeters = Math.round(leftCoord.distanceTo(rightCoord)) |
|
|
|
|
if (QGroundControl.settingsManager.unitsSettings.distanceUnits.value === UnitsSettings.DistanceUnitsFeet) { |
|
|
|
|
calculateFeetRatio(scaleLineMeters, scaleLinePixelLength) |
|
|
|
|
} else { |
|
|
|
|
calculateMetersRatio(scaleLineMeters, scaleLinePixelLength) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Connections { |
|
|
|
|
target: mapControl |
|
|
|
|
|
|
|
|
|
onWidthChanged: scaleTimer.restart() |
|
|
|
|
onHeightChanged: scaleTimer.restart() |
|
|
|
|
target: mapControl |
|
|
|
|
onWidthChanged: scaleTimer.restart() |
|
|
|
|
onHeightChanged: scaleTimer.restart() |
|
|
|
|
onZoomLevelChanged: scaleTimer.restart() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Timer { |
|
|
|
|
id: scaleTimer |
|
|
|
|
interval: 100 |
|
|
|
|
running: false |
|
|
|
|
repeat: false |
|
|
|
|
|
|
|
|
|
onTriggered: calculateScale() |
|
|
|
|
id: scaleTimer |
|
|
|
|
interval: 100 |
|
|
|
|
running: false |
|
|
|
|
repeat: false |
|
|
|
|
onTriggered: calculateScale() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QGCMapLabel { |
|
|
|
|
id: scaleText |
|
|
|
|
map: mapControl |
|
|
|
|
font.family: ScreenTools.demiboldFontFamily |
|
|
|
|
anchors.left: parent.left |
|
|
|
|
anchors.right: parent.right |
|
|
|
|
horizontalAlignment: Text.AlignRight |
|
|
|
|
text: "0 m" |
|
|
|
|
id: scaleText |
|
|
|
|
map: mapControl |
|
|
|
|
font.family: ScreenTools.demiboldFontFamily |
|
|
|
|
anchors.left: parent.left |
|
|
|
|
anchors.right: parent.right |
|
|
|
|
horizontalAlignment:Text.AlignRight |
|
|
|
|
text: "0 m" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Rectangle { |
|
|
|
|
id: leftEnd |
|
|
|
|
anchors.top: scaleText.bottom |
|
|
|
|
anchors.left: parent.left |
|
|
|
|
width: 2 |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight |
|
|
|
|
color: _color |
|
|
|
|
id: leftEnd |
|
|
|
|
anchors.top: scaleText.bottom |
|
|
|
|
anchors.left: parent.left |
|
|
|
|
width: 2 |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight |
|
|
|
|
color: _color |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Rectangle { |
|
|
|
|
id: centerLine |
|
|
|
|
id: centerLine |
|
|
|
|
anchors.bottomMargin: 2 |
|
|
|
|
anchors.bottom: leftEnd.bottom |
|
|
|
|
anchors.left: leftEnd.right |
|
|
|
|
height: 2 |
|
|
|
|
color: _color |
|
|
|
|
anchors.bottom: leftEnd.bottom |
|
|
|
|
anchors.left: leftEnd.right |
|
|
|
|
height: 2 |
|
|
|
|
color: _color |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Rectangle { |
|
|
|
|
id: rightEnd |
|
|
|
|
anchors.top: leftEnd.top |
|
|
|
|
anchors.left: centerLine.right |
|
|
|
|
width: 2 |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight |
|
|
|
|
color: _color |
|
|
|
|
id: rightEnd |
|
|
|
|
anchors.top: leftEnd.top |
|
|
|
|
anchors.left: centerLine.right |
|
|
|
|
width: 2 |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight |
|
|
|
|
color: _color |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Component.onCompleted: { |
|
|
|
|