Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
eb935daa
Commit
eb935daa
authored
Apr 26, 2016
by
Gus Grubba
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3281 from dogmaphobic/mapScale
Map scale
parents
42045439
7c6155de
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
197 additions
and
153 deletions
+197
-153
qgcresources.qrc
qgcresources.qrc
+2
-0
FlightDisplayViewMap.qml
src/FlightDisplay/FlightDisplayViewMap.qml
+1
-0
FlightMap.qml
src/FlightMap/FlightMap.qml
+124
-120
FlightMapSettings.cc
src/FlightMap/FlightMapSettings.cc
+21
-4
FlightMapSettings.h
src/FlightMap/FlightMapSettings.h
+15
-8
scaleLight.png
src/FlightMap/Images/scaleLight.png
+0
-0
scale_endLight.png
src/FlightMap/Images/scale_endLight.png
+0
-0
GeneralSettings.qml
src/ui/preferences/GeneralSettings.qml
+34
-21
No files found.
qgcresources.qrc
View file @
eb935daa
...
...
@@ -99,6 +99,8 @@
<file alias="rollPointerWhite.svg">src/FlightMap/Images/rollPointerWhite.svg</file>
<file alias="scale.png">src/FlightMap/Images/scale.png</file>
<file alias="scale_end.png">src/FlightMap/Images/scale_end.png</file>
<file alias="scaleLight.png">src/FlightMap/Images/scaleLight.png</file>
<file alias="scale_endLight.png">src/FlightMap/Images/scale_endLight.png</file>
<file alias="airplaneOutline.svg">src/FlightMap/Images/airplaneOutline.svg</file>
<file alias="airplaneOpaque.svg">src/FlightMap/Images/airplaneOpaque.svg</file>
<file alias="ZoomPlus.svg">src/FlightMap/Images/ZoomPlus.svg</file>
...
...
src/FlightDisplay/FlightDisplayViewMap.qml
View file @
eb935daa
...
...
@@ -39,6 +39,7 @@ FlightMap {
id
:
flightMap
anchors.fill
:
parent
mapName
:
_mapName
showScale
:
QGroundControl
.
flightMapSettings
.
showScaleOnFlyView
property
alias
missionController
:
_missionController
property
var
flightWidgets
...
...
src/FlightMap/FlightMap.qml
View file @
eb935daa
...
...
@@ -33,6 +33,7 @@ import QtLocation 5.3
import
QtPositioning
5.3
import
QGroundControl
1.0
import
QGroundControl
.
FactSystem
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
FlightMap
1.0
import
QGroundControl
.
ScreenTools
1.0
...
...
@@ -47,14 +48,59 @@ Map {
property
string
mapType
:
QGroundControl
.
flightMapSettings
.
mapTypeForMapName
(
mapName
)
// property alias mapWidgets: controlWidgets
property
bool
isSatelliteMap
:
mapType
==
"
Satellite Map
"
||
mapType
==
"
Hybrid Map
"
property
bool
showScale
:
false
readonly
property
real
maxZoomLevel
:
20
readonly
property
real
maxZoomLevel
:
20
property
variant
scaleLengths
:
[
5
,
10
,
25
,
50
,
100
,
150
,
250
,
500
,
1000
,
2000
,
5000
,
10000
,
20000
,
50000
,
100000
,
200000
,
500000
,
1000000
,
2000000
]
function
formatDistance
(
meters
)
{
var
dist
=
Math
.
round
(
meters
)
if
(
dist
>
1000
){
if
(
dist
>
100000
){
dist
=
Math
.
round
(
dist
/
1000
)
}
else
{
dist
=
Math
.
round
(
dist
/
100
)
dist
=
dist
/
10
}
dist
=
dist
+
"
km
"
}
else
{
dist
=
dist
+
"
m
"
}
return
dist
}
function
calculateScale
()
{
var
coord1
,
coord2
,
dist
,
text
,
f
f
=
0
coord1
=
_map
.
toCoordinate
(
Qt
.
point
(
0
,
scale
.
y
))
coord2
=
_map
.
toCoordinate
(
Qt
.
point
(
0
+
scaleImage
.
sourceSize
.
width
,
scale
.
y
))
dist
=
Math
.
round
(
coord1
.
distanceTo
(
coord2
))
if
(
dist
===
0
)
{
// not visible
}
else
{
for
(
var
i
=
0
;
i
<
scaleLengths
.
length
-
1
;
i
++
)
{
if
(
dist
<
(
scaleLengths
[
i
]
+
scaleLengths
[
i
+
1
])
/
2
)
{
f
=
scaleLengths
[
i
]
/
dist
dist
=
scaleLengths
[
i
]
break
;
}
}
if
(
f
===
0
)
{
f
=
dist
/
scaleLengths
[
i
]
dist
=
scaleLengths
[
i
]
}
}
text
=
formatDistance
(
dist
)
scaleImage
.
width
=
(
scaleImage
.
sourceSize
.
width
*
f
)
-
2
*
scaleImageLeft
.
sourceSize
.
width
scaleText
.
text
=
text
}
zoomLevel
:
18
center
:
QGroundControl
.
lastKnownHomePosition
gesture.flickDeceleration
:
3000
// This no longer exists in Qt 5.6. The options below also happen the be the default anyway.
//gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
plugin
:
Plugin
{
name
:
"
QGroundControl
"
}
...
...
@@ -63,9 +109,9 @@ Map {
Component.onCompleted
:
onMapTypeChanged
property
bool
_initialMapPositionSet
:
false
Connections
{
target
:
mainWindow
onGcsPositionChanged
:
{
if
(
!
_initialMapPositionSet
)
{
_initialMapPositionSet
=
true
...
...
@@ -90,12 +136,83 @@ Map {
anchorPoint.y
:
sourceItem
.
height
/
2
visible
:
mainWindow
.
gcsPosition
.
isValid
coordinate
:
mainWindow
.
gcsPosition
sourceItem
:
MissionItemIndexLabel
{
sourceItem
:
MissionItemIndexLabel
{
label
:
"
Q
"
}
}
onWidthChanged
:
{
if
(
_map
.
showScale
)
scaleTimer
.
restart
()
}
onHeightChanged
:
{
if
(
_map
.
showScale
)
scaleTimer
.
restart
()
}
onZoomLevelChanged
:{
if
(
_map
.
showScale
)
scaleTimer
.
restart
()
}
Timer
{
id
:
scaleTimer
interval
:
100
running
:
false
repeat
:
false
onTriggered
:
{
_map
.
calculateScale
()
}
}
/*
Scale
*/
Item
{
id
:
scale
visible
:
_map
.
showScale
&&
scaleText
.
text
!==
"
0 m
"
z
:
_map
.
z
+
20
width
:
scaleImageLeft
.
width
+
scaleImage
.
width
+
scaleImageRight
.
width
anchors
{
bottom
:
parent
.
bottom
bottomMargin
:
ScreenTools
.
defaultFontPixelSize
*
(
0.66
)
right
:
parent
.
right
rightMargin
:
ScreenTools
.
defaultFontPixelSize
*
(
0.33
)
}
Image
{
id
:
scaleImageLeft
source
:
isSatelliteMap
?
"
/qmlimages/scale_end.png
"
:
"
/qmlimages/scale_endLight.png
"
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
}
Image
{
id
:
scaleImage
source
:
isSatelliteMap
?
"
/qmlimages/scale.png
"
:
"
/qmlimages/scaleLight.png
"
anchors.bottom
:
parent
.
bottom
anchors.left
:
scaleImageLeft
.
right
}
Image
{
id
:
scaleImageRight
source
:
isSatelliteMap
?
"
/qmlimages/scale_end.png
"
:
"
/qmlimages/scale_endLight.png
"
anchors.bottom
:
parent
.
bottom
anchors.left
:
scaleImage
.
right
}
QGCLabel
{
id
:
scaleText
color
:
isSatelliteMap
?
"
white
"
:
"
black
"
font.weight
:
Font
.
DemiBold
horizontalAlignment
:
Text
.
AlignHCenter
anchors.bottom
:
parent
.
bottom
anchors.right
:
parent
.
right
anchors.bottomMargin
:
ScreenTools
.
defaultFontPixelSize
*
(
0.83
)
text
:
"
0 m
"
}
Component.onCompleted
:
{
if
(
_map
.
showScale
)
_map
.
calculateScale
();
}
}
/*********************************************
/// Map control widgets
Column {
...
...
@@ -174,65 +291,6 @@ Map {
The slider and scale display are commented out for now to try to save real estate - DonLakeFlyer
Not sure if I'll bring them back or not. Need room for waypoint list at bottom
property variant scaleLengths: [5, 10, 25, 50, 100, 150, 250, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000]
function formatDistance(meters)
{
var dist = Math.round(meters)
if (dist > 1000 ){
if (dist > 100000){
dist = Math.round(dist / 1000)
}
else{
dist = Math.round(dist / 100)
dist = dist / 10
}
dist = dist + " km"
}
else{
dist = dist + " m"
}
return dist
}
onWidthChanged: {
scaleTimer.restart()
}
onHeightChanged: {
scaleTimer.restart()
}
onZoomLevelChanged:{
scaleTimer.restart()
}
function calculateScale() {
var coord1, coord2, dist, text, f
f = 0
coord1 = map.toCoordinate(Qt.point(0,scale.y))
coord2 = map.toCoordinate(Qt.point(0+scaleImage.sourceSize.width,scale.y))
dist = Math.round(coord1.distanceTo(coord2))
if (dist === 0) {
// not visible
} else {
for (var i = 0; i < scaleLengths.length-1; i++) {
if (dist < (scaleLengths[i] + scaleLengths[i+1]) / 2 ) {
f = scaleLengths[i] / dist
dist = scaleLengths[i]
break;
}
}
if (f === 0) {
f = dist / scaleLengths[i]
dist = scaleLengths[i]
}
}
text = formatDistance(dist)
scaleImage.width = (scaleImage.sourceSize.width * f) - 2 * scaleImageLeft.sourceSize.width
scaleText.text = text
}
QGCSlider {
id: zoomSlider;
minimum: map.minimumZoomLevel;
...
...
@@ -256,60 +314,6 @@ Map {
map.zoomLevel = value
}
}
Item {
id: scale
parent: zoomSlider.parent
visible: scaleText.text !== "0 m"
z: map.z + 20
opacity: 1
anchors {
bottom: zoomSlider.top;
bottomMargin: ScreenTools.defaultFontPixelSize * (0.66);
left: zoomSlider.left
leftMargin: ScreenTools.defaultFontPixelSize * (0.33)
}
Image {
id: scaleImageLeft
source: "/qmlimages/scale_end.png"
anchors.bottom: parent.bottom
anchors.left: parent.left
}
Image {
id: scaleImage
source: "/qmlimages/scale.png"
anchors.bottom: parent.bottom
anchors.left: scaleImageLeft.right
}
Image {
id: scaleImageRight
source: "/qmlimages/scale_end.png"
anchors.bottom: parent.bottom
anchors.left: scaleImage.right
}
QGCLabel {
id: scaleText
color: "white"
font.weight: Font.DemiBold
horizontalAlignment: Text.AlignHCenter
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.bottomMargin: ScreenTools.defaultFontPixelSize * (0.83)
text: "0 m"
}
Component.onCompleted: {
map.calculateScale();
}
}
Timer {
id: scaleTimer
interval: 100
running: false
repeat: false
onTriggered: {
map.calculateScale()
}
}
*/
}
// Map
src/FlightMap/FlightMapSettings.cc
View file @
eb935daa
...
...
@@ -26,10 +26,11 @@
#include <QSettings>
#include <QtQml>
const
char
*
FlightMapSettings
::
_defaultMapProvider
=
"Bing"
;
// Bing is default since it support full street/satellite/hybrid set
const
char
*
FlightMapSettings
::
_settingsGroup
=
"FlightMapSettings"
;
const
char
*
FlightMapSettings
::
_mapProviderKey
=
"MapProvider"
;
const
char
*
FlightMapSettings
::
_mapTypeKey
=
"MapType"
;
const
char
*
FlightMapSettings
::
_defaultMapProvider
=
"Bing"
;
// Bing is default since it support full street/satellite/hybrid set
const
char
*
FlightMapSettings
::
_settingsGroup
=
"FlightMapSettings"
;
const
char
*
FlightMapSettings
::
_mapProviderKey
=
"MapProvider"
;
const
char
*
FlightMapSettings
::
_mapTypeKey
=
"MapType"
;
const
char
*
FlightMapSettings
::
_showScaleOnFlyViewKey
=
"ShowScaleOnFlyView"
;
FlightMapSettings
::
FlightMapSettings
(
QGCApplication
*
app
)
:
QGCTool
(
app
)
...
...
@@ -157,3 +158,19 @@ bool FlightMapSettings::loadBoolMapSetting (const QString &mapName, const QStrin
settings
.
beginGroup
(
mapName
);
return
settings
.
value
(
key
,
defaultValue
).
toBool
();
}
bool
FlightMapSettings
::
showScaleOnFlyView
()
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
bool
show
=
settings
.
value
(
_showScaleOnFlyViewKey
,
true
).
toBool
();
return
show
;
}
void
FlightMapSettings
::
setShowScaleOnFlyView
(
bool
show
)
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
settings
.
setValue
(
_showScaleOnFlyViewKey
,
show
);
emit
showScaleOnFlyViewChanged
();
}
src/FlightMap/FlightMapSettings.h
View file @
eb935daa
...
...
@@ -37,13 +37,15 @@ public:
FlightMapSettings
(
QGCApplication
*
app
);
/// mapProvider is either Bing, Google or Open to specify to set of maps available
Q_PROPERTY
(
QString
mapProvider
READ
mapProvider
WRITE
setMapProvider
NOTIFY
mapProviderChanged
)
Q_PROPERTY
(
QString
mapProvider
READ
mapProvider
WRITE
setMapProvider
NOTIFY
mapProviderChanged
)
/// Map providers
Q_PROPERTY
(
QStringList
mapProviders
READ
mapProviders
CONSTANT
)
Q_PROPERTY
(
QStringList
mapProviders
READ
mapProviders
CONSTANT
)
/// Map types associated with current map provider
Q_PROPERTY
(
QStringList
mapTypes
MEMBER
_mapTypes
NOTIFY
mapTypesChanged
)
Q_PROPERTY
(
QStringList
mapTypes
MEMBER
_mapTypes
NOTIFY
mapTypesChanged
)
Q_PROPERTY
(
bool
showScaleOnFlyView
READ
showScaleOnFlyView
WRITE
setShowScaleOnFlyView
NOTIFY
showScaleOnFlyViewChanged
)
Q_INVOKABLE
QString
mapTypeForMapName
(
const
QString
&
mapName
);
Q_INVOKABLE
void
setMapTypeForMapName
(
const
QString
&
mapName
,
const
QString
&
mapType
);
...
...
@@ -63,15 +65,19 @@ public:
QStringList
mapProviders
()
{
return
_supportedMapProviders
;
}
bool
showScaleOnFlyView
();
void
setShowScaleOnFlyView
(
bool
show
);
signals:
void
mapProviderChanged
(
const
QString
&
mapProvider
);
void
mapTypesChanged
(
const
QStringList
&
mapTypes
);
void
mapProviderChanged
(
const
QString
&
mapProvider
);
void
mapTypesChanged
(
const
QStringList
&
mapTypes
);
void
showScaleOnFlyViewChanged
();
private:
void
_storeSettings
(
void
);
void
_loadSettings
(
void
);
void
_storeSettings
(
void
);
void
_loadSettings
(
void
);
void
_setMapTypesForCurrentProvider
(
void
);
void
_setMapTypesForCurrentProvider
(
void
);
QString
_mapProvider
;
///< Current map provider
QStringList
_supportedMapProviders
;
...
...
@@ -81,6 +87,7 @@ private:
static
const
char
*
_settingsGroup
;
static
const
char
*
_mapProviderKey
;
static
const
char
*
_mapTypeKey
;
static
const
char
*
_showScaleOnFlyViewKey
;
};
#endif
src/FlightMap/Images/scaleLight.png
0 → 100644
View file @
eb935daa
15.1 KB
src/FlightMap/Images/scale_endLight.png
0 → 100644
View file @
eb935daa
15.1 KB
src/ui/preferences/GeneralSettings.qml
View file @
eb935daa
...
...
@@ -40,7 +40,9 @@ Rectangle {
anchors.fill
:
parent
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
property
Fact
_percentRemainingAnnounce
:
QGroundControl
.
multiVehicleManager
.
disconnectedVehicle
.
battery
.
percentRemainingAnnounce
property
Fact
_percentRemainingAnnounce
:
QGroundControl
.
multiVehicleManager
.
disconnectedVehicle
.
battery
.
percentRemainingAnnounce
property
real
_firstLabelWidth
:
ScreenTools
.
defaultFontPixelWidth
*
16
property
real
_editFieldWidth
:
ScreenTools
.
defaultFontPixelWidth
*
22
QGCPalette
{
id
:
qgcPal
}
...
...
@@ -76,16 +78,16 @@ Rectangle {
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
id
:
distanceUnitsLabel
width
:
_firstLabelWidth
anchors.baseline
:
distanceUnitsCombo
.
baseline
text
:
qsTr
(
"
Distance units:
"
)
}
FactComboBox
{
id
:
distanceUnitsCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
10
fact
:
QGroundControl
.
distanceUnits
indexModel
:
false
id
:
distanceUnitsCombo
width
:
_editFieldWidth
fact
:
QGroundControl
.
distanceUnits
indexModel
:
false
}
QGCLabel
{
...
...
@@ -96,19 +98,19 @@ Rectangle {
}
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
anchors.baseline
:
speedUnitsCombo
.
baseline
width
:
distanceUnitsLabel
.
w
idth
width
:
_firstLabelW
idth
text
:
qsTr
(
"
Speed units:
"
)
}
FactComboBox
{
id
:
speedUnitsCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
fact
:
QGroundControl
.
speedUnits
indexModel
:
false
id
:
speedUnitsCombo
width
:
_editFieldWidth
fact
:
QGroundControl
.
speedUnits
indexModel
:
false
}
QGCLabel
{
...
...
@@ -117,6 +119,17 @@ Rectangle {
}
}
//-----------------------------------------------------------------
//-- Scale on Flight View
QGCCheckBox
{
text
:
qsTr
(
"
Show scale on Fly View
"
)
onClicked
:
{
QGroundControl
.
flightMapSettings
.
showScaleOnFlyView
=
checked
}
Component.onCompleted
:
{
checked
=
QGroundControl
.
flightMapSettings
.
showScaleOnFlyView
}
}
//-----------------------------------------------------------------
//-- Audio preferences
QGCCheckBox
{
...
...
@@ -211,13 +224,13 @@ Rectangle {
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
anchors.baseline
:
mapProviders
.
baseline
width
:
ScreenTools
.
defaultFontPixelWidth
*
16
width
:
_firstLabelWidth
text
:
qsTr
(
"
Map Providers:
"
)
}
QGCComboBox
{
id
:
mapProviders
width
:
ScreenTools
.
defaultFontPixelWidth
*
16
model
:
QGroundControl
.
flightMapSettings
.
mapProviders
id
:
mapProviders
width
:
_editFieldWidth
model
:
QGroundControl
.
flightMapSettings
.
mapProviders
Component.onCompleted
:
{
var
index
=
mapProviders
.
find
(
QGroundControl
.
flightMapSettings
.
mapProvider
)
if
(
index
<
0
)
{
...
...
@@ -241,14 +254,14 @@ Rectangle {
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
anchors.baseline
:
paletteCombo
.
baseline
width
:
ScreenTools
.
defaultFontPixelWidth
*
16
width
:
_firstLabelWidth
text
:
qsTr
(
"
Style:
"
)
}
QGCComboBox
{
id
:
paletteCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
16
model
:
[
qsTr
(
"
Indoor
"
),
qsTr
(
"
Outdoor
"
)
]
currentIndex
:
QGroundControl
.
isDarkStyle
?
0
:
1
id
:
paletteCombo
width
:
_editFieldWidth
model
:
[
qsTr
(
"
Indoor
"
),
qsTr
(
"
Outdoor
"
)
]
currentIndex
:
QGroundControl
.
isDarkStyle
?
0
:
1
onActivated
:
{
if
(
index
!=
-
1
)
{
currentIndex
=
index
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment