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
833c3e9c
Commit
833c3e9c
authored
Apr 11, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1445 from dogmaphobic/mapWork
Map Display Tweaks
parents
9a1ca95a
826f01d2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
302 additions
and
11 deletions
+302
-11
qgroundcontrol.qrc
qgroundcontrol.qrc
+3
-0
qgeomapreplyqgc.cpp
src/QtLocationPlugin/qgeomapreplyqgc.cpp
+12
-0
qgeotiledmappingmanagerengineqgc.cpp
src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.cpp
+3
-2
FlightDisplay.qml
src/ui/flightdisplay/FlightDisplay.qml
+2
-0
QGCMapBackground.qml
src/ui/flightdisplay/components/QGCMapBackground.qml
+157
-9
QGCSlider.qml
src/ui/flightdisplay/components/QGCSlider.qml
+124
-0
qmldir
src/ui/flightdisplay/components/qmldir
+1
-0
scale.png
src/ui/flightdisplay/components/scale.png
+0
-0
scale_end.png
src/ui/flightdisplay/components/scale_end.png
+0
-0
No files found.
qgroundcontrol.qrc
View file @
833c3e9c
...
...
@@ -99,6 +99,7 @@
<file alias="QGroundControl/HUDControls/QGCMapBackground.qml">src/ui/flightdisplay/components/QGCMapBackground.qml</file>
<file alias="QGroundControl/HUDControls/QGCPitchWidget.qml">src/ui/flightdisplay/components/QGCPitchWidget.qml</file>
<file alias="QGroundControl/HUDControls/QGCSpeedWidget.qml">src/ui/flightdisplay/components/QGCSpeedWidget.qml</file>
<file alias="QGroundControl/HUDControls/QGCSlider.qml">src/ui/flightdisplay/components/QGCSlider.qml</file>
<file alias="compass.svg">src/ui/flightdisplay/components/compass.svg</file>
<file alias="compassNeedle.svg">src/ui/flightdisplay/components/compassNeedle.svg</file>
<file alias="crossHair.svg">src/ui/flightdisplay/components/crossHair.svg</file>
...
...
@@ -106,6 +107,8 @@
<file alias="rollDialWhite.svg">src/ui/flightdisplay/components/rollDialWhite.svg</file>
<file alias="rollPointer.svg">src/ui/flightdisplay/components/rollPointer.svg</file>
<file alias="rollPointerWhite.svg">src/ui/flightdisplay/components/rollPointerWhite.svg</file>
<file alias="scale.png">src/ui/flightdisplay/components/scale.png</file>
<file alias="scale_end.png">src/ui/flightdisplay/components/scale_end.png</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
...
...
src/QtLocationPlugin/qgeomapreplyqgc.cpp
View file @
833c3e9c
...
...
@@ -86,10 +86,16 @@ void QGeoMapReplyQGC::replyDestroyed()
void
QGeoMapReplyQGC
::
networkReplyFinished
()
{
if
(
!
m_reply
)
{
qWarning
()
<<
"NULL Map request reply"
;
return
;
}
if
(
m_reply
->
error
()
!=
QNetworkReply
::
NoError
)
{
qWarning
()
<<
"Map request reply error:"
<<
m_reply
->
error
();
return
;
}
QByteArray
a
=
m_reply
->
readAll
();
setMapImageData
(
a
);
...
...
@@ -131,10 +137,16 @@ void QGeoMapReplyQGC::networkReplyFinished()
void
QGeoMapReplyQGC
::
networkReplyError
(
QNetworkReply
::
NetworkError
error
)
{
if
(
!
m_reply
)
{
qWarning
()
<<
"NULL Map request error"
;
return
;
}
if
(
error
!=
QNetworkReply
::
OperationCanceledError
)
{
setError
(
QGeoTiledMapReply
::
CommunicationError
,
m_reply
->
errorString
());
qWarning
()
<<
"Map request reply error:"
<<
m_reply
->
errorString
();
}
setFinished
(
true
);
m_reply
->
deleteLater
();
...
...
src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.cpp
View file @
833c3e9c
...
...
@@ -58,8 +58,9 @@ QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVarian
:
QGeoTiledMappingManagerEngine
()
{
QGeoCameraCapabilities
cameraCaps
;
cameraCaps
.
setMinimumZoomLevel
(
0.0
);
cameraCaps
.
setMaximumZoomLevel
(
22.0
);
cameraCaps
.
setMinimumZoomLevel
(
2.0
);
cameraCaps
.
setMaximumZoomLevel
(
20.0
);
cameraCaps
.
setSupportsBearing
(
true
);
setCameraCapabilities
(
cameraCaps
);
setTileSize
(
QSize
(
256
,
256
));
...
...
src/ui/flightdisplay/FlightDisplay.qml
View file @
833c3e9c
...
...
@@ -200,6 +200,7 @@ Rectangle {
}
}
/*
MenuItem {
text: "Map Always Points North"
checkable: true
...
...
@@ -210,6 +211,7 @@ Rectangle {
flightDisplay.saveSetting("mapAlwaysPointsNorth", setBool(mapBackground.alwaysNorth));
}
}
*/
Menu
{
id
:
mapTypeMenu
...
...
src/ui/flightdisplay/components/QGCMapBackground.qml
View file @
833c3e9c
...
...
@@ -31,11 +31,13 @@ import QtQuick 2.4
import
QtPositioning
5.3
import
QtLocation
5.3
import
QGroundControl
.
HUDControls
1.0
Rectangle
{
id
:
root
property
real
latitude
:
37.803784
property
real
longitude
:
-
122.462276
property
real
zoomLevel
:
1
2
property
real
zoomLevel
:
(
map
.
maximumZoomLevel
-
map
.
minimumZoomLevel
)
/
2
property
real
heading
:
0
property
bool
alwaysNorth
:
true
property
alias
mapItem
:
map
...
...
@@ -46,7 +48,7 @@ Rectangle {
function
adjustSize
()
{
if
(
root
.
visible
)
{
if
(
alwaysNorth
)
{
if
(
true
/*alwaysNorth*/
)
{
map
.
width
=
root
.
width
;
map
.
height
=
root
.
height
;
}
else
{
...
...
@@ -60,6 +62,25 @@ Rectangle {
}
}
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
}
Plugin
{
id
:
mapPlugin
name
:
"
QGroundControl
"
...
...
@@ -67,26 +88,153 @@ Rectangle {
Map
{
id
:
map
property
real
lon
:
(
longitude
>
-
180.1
&&
longitude
<
180.1
)
?
longitude
:
0
property
real
lat
:
(
latitude
>
-
180.1
&&
latitude
<
180.1
)
?
latitude
:
0
property
real
lon
:
(
longitude
>=
-
180
&&
longitude
<=
180
)
?
longitude
:
0
property
real
lat
:
(
latitude
>=
-
90
&&
latitude
<=
90
)
?
latitude
:
0
property
variant
scaleLengths
:
[
5
,
10
,
25
,
50
,
100
,
150
,
250
,
500
,
1000
,
2000
,
5000
,
10000
,
20000
,
50000
,
100000
,
200000
,
500000
,
1000000
,
2000000
]
plugin
:
mapPlugin
width
:
1
height
:
1
zoomLevel
:
zoomLevel
zoomLevel
:
root
.
zoomLevel
anchors.centerIn
:
parent
center
:
map
.
visible
?
QtPositioning
.
coordinate
(
lat
,
lon
)
:
QtPositioning
.
coordinate
(
0
,
0
)
/*
transform: Rotation {
origin.x: map.width / 2
origin.y: map.height / 2
angle: map.visible ? (alwaysNorth ? 0 : -heading) : 0
}
*/
gesture.flickDeceleration
:
3000
gesture.enabled
:
true
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
}
}
onVisibleChanged
:
adjustSize
();
onWidthChanged
:
adjustSize
();
onHeightChanged
:
adjustSize
();
onAlwaysNorthChanged
:
adjustSize
();
QGCSlider
{
id
:
zoomSlider
;
minimum
:
map
.
minimumZoomLevel
;
maximum
:
map
.
maximumZoomLevel
;
opacity
:
1
visible
:
parent
.
visible
z
:
map
.
z
+
3
anchors
{
bottom
:
parent
.
bottom
;
bottomMargin
:
15
;
rightMargin
:
20
;
leftMargin
:
20
left
:
parent
.
left
}
width
:
parent
.
width
-
anchors
.
rightMargin
-
anchors
.
leftMargin
value
:
map
.
zoomLevel
Binding
{
target
:
zoomSlider
;
property
:
"
value
"
;
value
:
map
.
zoomLevel
}
onValueChanged
:
{
map
.
zoomLevel
=
value
}
}
Item
{
id
:
scale
parent
:
zoomSlider
.
parent
visible
:
scaleText
.
text
!=
"
0 m
"
z
:
map
.
z
+
2
opacity
:
1
anchors
{
bottom
:
zoomSlider
.
top
;
bottomMargin
:
8
;
left
:
zoomSlider
.
left
}
Image
{
id
:
scaleImageLeft
source
:
"
/qml/scale_end.png
"
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
}
Image
{
id
:
scaleImage
source
:
"
/qml/scale.png
"
anchors.bottom
:
parent
.
bottom
anchors.left
:
scaleImageLeft
.
right
}
Image
{
id
:
scaleImageRight
source
:
"
/qml/scale_end.png
"
anchors.bottom
:
parent
.
bottom
anchors.left
:
scaleImage
.
right
}
Text
{
id
:
scaleText
color
:
"
white
"
font.weight
:
Font
.
DemiBold
horizontalAlignment
:
Text
.
AlignHCenter
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
anchors.bottomMargin
:
8
text
:
"
0 m
"
}
Component.onCompleted
:
{
map
.
calculateScale
();
}
}
Timer
{
id
:
scaleTimer
interval
:
100
running
:
false
repeat
:
false
onTriggered
:
{
map
.
calculateScale
()
}
}
onVisibleChanged
:
{
adjustSize
();
}
onAlwaysNorthChanged
:
{
adjustSize
();
}
onWidthChanged
:
{
adjustSize
();
}
onHeightChanged
:
{
adjustSize
();
}
}
src/ui/flightdisplay/components/QGCSlider.qml
0 → 100644
View file @
833c3e9c
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import
QtQuick
2.0
Item
{
id
:
slider
;
height
:
10
property
real
value
// value is read/write.
property
real
minimum
:
0
property
real
maximum
:
1
property
int
length
:
width
-
handle
.
width
Rectangle
{
anchors.fill
:
parent
border.width
:
1
;
border.color
:
"
lightgrey
"
radius
:
8
color
:
"
white
"
opacity
:
1
}
Rectangle
{
anchors.left
:
parent
.
left
anchors.leftMargin
:
4
anchors.top
:
parent
.
top
anchors.topMargin
:
(
parent
.
height
-
height
)
/
2
height
:
3
width
:
handle
.
x
-
x
color
:
"
#1c94fc
"
}
Rectangle
{
id
:
labelRect
width
:
label
.
width
height
:
label
.
height
+
4
radius
:
4
smooth
:
true
color
:
"
white
"
border.color
:
"
lightgrey
"
anchors.bottom
:
handle
.
top
anchors.bottomMargin
:
4
x
:
Math
.
max
(
Math
.
min
(
handle
.
x
+
(
handle
.
width
-
width
)
/
2
,
slider
.
width
-
width
),
0
)
visible
:
mouseRegion
.
pressed
Text
{
id
:
label
color
:
"
darkgrey
"
text
:
slider
.
value
.
toFixed
(
2
)
width
:
font
.
pointSize
*
3.5
anchors.horizontalCenter
:
labelRect
.
horizontalCenter
horizontalAlignment
:
Text
.
AlignHCenter
anchors.baseline
:
parent
.
bottom
anchors.baselineOffset
:
-
6
font.pixelSize
:
14
}
}
Rectangle
{
id
:
handle
;
smooth
:
true
width
:
26
;
y
:
(
slider
.
height
-
height
)
/
2
;
x
:
(
slider
.
value
-
slider
.
minimum
)
*
slider
.
length
/
(
slider
.
maximum
-
slider
.
minimum
)
height
:
width
;
radius
:
width
/
2
gradient
:
normalGradient
border.width
:
2
border.color
:
"
white
"
Gradient
{
id
:
normalGradient
GradientStop
{
position
:
0.0
;
color
:
"
#b0b0b0
"
}
GradientStop
{
position
:
0.66
;
color
:
"
#909090
"
}
GradientStop
{
position
:
1.0
;
color
:
"
#545454
"
}
}
MouseArea
{
id
:
mouseRegion
hoverEnabled
:
false
anchors.fill
:
parent
;
drag.target
:
parent
drag.axis
:
Drag
.
XAxis
;
drag.minimumX
:
0
;
drag.maximumX
:
slider
.
length
preventStealing
:
true
onPositionChanged
:
{
slider
.
value
=
(
slider
.
maximum
-
slider
.
minimum
)
*
handle
.
x
/
slider
.
length
+
slider
.
minimum
;
}
}
}
}
src/ui/flightdisplay/components/qmldir
View file @
833c3e9c
...
...
@@ -8,3 +8,4 @@ QGCCurrentSpeed 1.0 QGCCurrentSpeed.qml
QGCMapBackground 1.0 QGCMapBackground.qml
QGCPitchWidget 1.0 QGCPitchWidget.qml
QGCSpeedWidget 1.0 QGCSpeedWidget.qml
QGCSlider 1.0 QGCSlider.qml
\ No newline at end of file
src/ui/flightdisplay/components/scale.png
0 → 100644
View file @
833c3e9c
15.1 KB
src/ui/flightdisplay/components/scale_end.png
0 → 100644
View file @
833c3e9c
14.6 KB
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