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
242d6519
Unverified
Commit
242d6519
authored
Aug 23, 2019
by
Gus Grubba
Committed by
GitHub
Aug 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7678 from mavlink/pr-add_gps_info
custom-example: Add GPS info to the Vehicle Indicator
parents
22132435
11cb2678
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
147 additions
and
62 deletions
+147
-62
CustomFlyView.qml
custom-example/res/CustomFlyView.qml
+123
-61
CustomQuickInterface.cc
custom-example/src/CustomQuickInterface.cc
+16
-1
CustomQuickInterface.h
custom-example/src/CustomQuickInterface.h
+8
-0
No files found.
custom-example/res/CustomFlyView.qml
View file @
242d6519
...
...
@@ -61,7 +61,6 @@ Item {
property
real
_distance
:
0.0
property
string
_messageTitle
:
""
property
string
_messageText
:
""
property
bool
_showAttitude
:
true
function
secondsToHHMMSS
(
timeS
)
{
var
sec_num
=
parseInt
(
timeS
,
10
);
...
...
@@ -260,74 +259,77 @@ Item {
anchors.bottomMargin
:
ScreenTools
.
defaultFontPixelWidth
anchors.right
:
attitudeIndicator
.
visible
?
attitudeIndicator
.
left
:
parent
.
right
anchors.rightMargin
:
attitudeIndicator
.
visible
?
-
ScreenTools
.
defaultFontPixelWidth
:
ScreenTools
.
defaultFontPixelWidth
GridLayout
{
id
:
vehicleStatusGrid
columnSpacing
:
ScreenTools
.
defaultFontPixelWidth
*
1.5
readonly
property
bool
_showGps
:
CustomQuickInterface
.
showAttitudeWidget
GridLayout
{
id
:
vehicleStatusGrid
columnSpacing
:
ScreenTools
.
defaultFontPixelWidth
*
1.5
rowSpacing
:
ScreenTools
.
defaultFontPixelHeight
*
0.5
columns
:
7
anchors.centerIn
:
parent
//-- Chronometer
QGCColoredImage
{
//-- Latitude
QGCLabel
{
height
:
_indicatorsHeight
width
:
height
source
:
"
/custom/img/chronometer.svg
"
fillMode
:
Image
.
PreserveAspectFit
sourceSize.height
:
height
Layout.alignment
:
Qt
.
AlignVCenter
|
Qt
.
AlignHCenter
color
:
qgcPal
.
text
}
QGCLabel
{
text
:
{
if
(
activeVehicle
)
return
secondsToHHMMSS
(
activeVehicle
.
getFact
(
"
flightTime
"
).
value
)
return
"
00:00:00
"
text
:
"
Lat:
"
visible
:
vehicleIndicator
.
_showGps
}
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
Text
.
AlignRight
}
//-- Ground Speed
QGCColoredImage
{
QGCLabel
{
id
:
firstLabel
text
:
activeVehicle
?
activeVehicle
.
gps
.
lat
.
value
.
toFixed
(
activeVehicle
.
gps
.
lat
.
decimalPlaces
)
:
"
-
"
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
Text
.
AlignLeft
visible
:
vehicleIndicator
.
_showGps
}
//-- Longitude
QGCLabel
{
height
:
_indicatorsHeight
width
:
height
source
:
"
/custom/img/horizontal_speed.svg
"
fillMode
:
Image
.
PreserveAspectFit
sourceSize.height
:
height
Layout.alignment
:
Qt
.
AlignVCenter
|
Qt
.
AlignHCenter
color
:
qgcPal
.
text
text
:
"
Lon:
"
visible
:
vehicleIndicator
.
_showGps
}
QGCLabel
{
text
:
activeVehicle
?
activeVehicle
.
g
roundSpeed
.
value
.
toFixed
(
1
)
+
'
'
+
activeVehicle
.
groundSpeed
.
units
:
"
0.0
"
text
:
activeVehicle
?
activeVehicle
.
g
ps
.
lon
.
value
.
toFixed
(
activeVehicle
.
gps
.
lon
.
decimalPlaces
)
:
"
-
"
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
Text
.
AlignRight
horizontalAlignment
:
firstLabel
.
horizontalAlignment
visible
:
vehicleIndicator
.
_showGps
}
//--
Vertical Speed
QGC
ColoredImage
{
//--
HDOP
QGC
Label
{
height
:
_indicatorsHeight
width
:
height
source
:
"
/custom/img/vertical_speed.svg
"
fillMode
:
Image
.
PreserveAspectFit
sourceSize.height
:
height
Layout.alignment
:
Qt
.
AlignVCenter
|
Qt
.
AlignHCenter
color
:
qgcPal
.
text
text
:
"
HDOP:
"
visible
:
vehicleIndicator
.
_showGps
}
QGCLabel
{
text
:
activeVehicle
?
activeVehicle
.
climbRate
.
value
.
toFixed
(
1
)
+
'
'
+
activeVehicle
.
climbRate
.
units
:
"
0.0
"
text
:
activeVehicle
?
activeVehicle
.
gps
.
hdop
.
value
.
toFixed
(
activeVehicle
.
gps
.
hdop
.
decimalPlaces
)
:
"
-
"
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
Text
.
AlignRight
horizontalAlignment
:
firstLabel
.
horizontalAlignment
visible
:
vehicleIndicator
.
_showGps
}
//-- Compass
Item
{
Layout.rowSpan
:
2
Layout.rowSpan
:
3
Layout.column
:
6
Layout.minimumWidth
:
mainIsMap
?
parent
.
height
*
1.25
:
0
Layout.fillHeight
:
true
Layout.fillWidth
:
true
...
...
@@ -395,6 +397,66 @@ Item {
}
}
//-- Second Row
//-- Chronometer
QGCColoredImage
{
height
:
_indicatorsHeight
width
:
height
source
:
"
/custom/img/chronometer.svg
"
fillMode
:
Image
.
PreserveAspectFit
sourceSize.height
:
height
Layout.alignment
:
Qt
.
AlignVCenter
|
Qt
.
AlignHCenter
color
:
qgcPal
.
text
}
QGCLabel
{
text
:
{
if
(
activeVehicle
)
return
secondsToHHMMSS
(
activeVehicle
.
getFact
(
"
flightTime
"
).
value
)
return
"
00:00:00
"
}
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
firstLabel
.
horizontalAlignment
}
//-- Ground Speed
QGCColoredImage
{
height
:
_indicatorsHeight
width
:
height
source
:
"
/custom/img/horizontal_speed.svg
"
fillMode
:
Image
.
PreserveAspectFit
sourceSize.height
:
height
Layout.alignment
:
Qt
.
AlignVCenter
|
Qt
.
AlignHCenter
color
:
qgcPal
.
text
}
QGCLabel
{
text
:
activeVehicle
?
activeVehicle
.
groundSpeed
.
value
.
toFixed
(
1
)
+
'
'
+
activeVehicle
.
groundSpeed
.
units
:
"
0.0
"
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
firstLabel
.
horizontalAlignment
}
//-- Vertical Speed
QGCColoredImage
{
height
:
_indicatorsHeight
width
:
height
source
:
"
/custom/img/vertical_speed.svg
"
fillMode
:
Image
.
PreserveAspectFit
sourceSize.height
:
height
Layout.alignment
:
Qt
.
AlignVCenter
|
Qt
.
AlignHCenter
color
:
qgcPal
.
text
}
QGCLabel
{
text
:
activeVehicle
?
activeVehicle
.
climbRate
.
value
.
toFixed
(
1
)
+
'
'
+
activeVehicle
.
climbRate
.
units
:
"
0.0
"
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
firstLabel
.
horizontalAlignment
}
//-- Third Row
//-- Odometer
QGCColoredImage
{
height
:
_indicatorsHeight
...
...
@@ -412,9 +474,9 @@ Item {
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
Text
.
AlignRigh
t
horizontalAlignment
:
firstLabel
.
horizontalAlignmen
t
}
//-- Altitude
//-- Altitude
QGCColoredImage
{
height
:
_indicatorsHeight
width
:
height
...
...
@@ -424,16 +486,16 @@ Item {
Layout.alignment
:
Qt
.
AlignVCenter
|
Qt
.
AlignHCenter
color
:
qgcPal
.
text
}
QGCLabel
{
text
:
_altitude
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
Text
.
AlignRigh
t
}
//-- Distance
}
QGCLabel
{
text
:
_altitude
color
:
_indicatorsColor
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
firstLabel
.
horizontalAlignmen
t
}
//-- Distance
QGCColoredImage
{
height
:
_indicatorsHeight
width
:
height
...
...
@@ -443,19 +505,19 @@ Item {
Layout.alignment
:
Qt
.
AlignVCenter
|
Qt
.
AlignHCenter
color
:
qgcPal
.
text
}
QGCLabel
{
text
:
_distance
?
_distanceStr
:
noGPS
color
:
_distance
?
_indicatorsColor
:
qgcPal
.
colorOrange
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
Text
.
AlignRigh
t
}
}
QGCLabel
{
text
:
_distance
?
_distanceStr
:
noGPS
color
:
_distance
?
_indicatorsColor
:
qgcPal
.
colorOrange
font.pointSize
:
ScreenTools
.
smallFontPointSize
Layout.fillWidth
:
true
Layout.minimumWidth
:
indicatorValueWidth
horizontalAlignment
:
firstLabel
.
horizontalAlignmen
t
}
}
MouseArea
{
anchors.fill
:
parent
onDoubleClicked
:
_showAttitude
=
!
_showAttitude
onDoubleClicked
:
CustomQuickInterface
.
showAttitudeWidget
=
!
CustomQuickInterface
.
showAttitudeWidget
}
}
//-------------------------------------------------------------------------
...
...
@@ -464,7 +526,7 @@ Item {
color
:
qgcPal
.
window
width
:
attitudeIndicator
.
width
*
0.5
height
:
vehicleIndicator
.
height
visible
:
_showAttitude
visible
:
CustomQuickInterface
.
showAttitudeWidget
anchors.top
:
vehicleIndicator
.
top
anchors.left
:
vehicleIndicator
.
right
}
...
...
@@ -478,7 +540,7 @@ Item {
width
:
height
radius
:
height
*
0.5
color
:
qgcPal
.
windowShade
visible
:
_showAttitude
visible
:
CustomQuickInterface
.
showAttitudeWidget
CustomAttitudeWidget
{
size
:
parent
.
height
*
0.95
vehicle
:
activeVehicle
...
...
custom-example/src/CustomQuickInterface.cc
View file @
242d6519
...
...
@@ -25,6 +25,7 @@
static
const
char
*
kGroupName
=
"CustomSettings"
;
static
const
char
*
kShowGimbalCtl
=
"ShowGimbalCtl"
;
static
const
char
*
kShowAttitudeWidget
=
"ShowAttitudeWidget"
;
//-----------------------------------------------------------------------------
CustomQuickInterface
::
CustomQuickInterface
(
QObject
*
parent
)
...
...
@@ -45,7 +46,8 @@ CustomQuickInterface::init()
{
QSettings
settings
;
settings
.
beginGroup
(
kGroupName
);
_showGimbalControl
=
settings
.
value
(
kShowGimbalCtl
,
true
).
toBool
();
_showGimbalControl
=
settings
.
value
(
kShowGimbalCtl
,
false
).
toBool
();
_showAttitudeWidget
=
settings
.
value
(
kShowAttitudeWidget
,
false
).
toBool
();
}
//-----------------------------------------------------------------------------
...
...
@@ -60,3 +62,16 @@ CustomQuickInterface::setShowGimbalControl(bool set)
emit
showGimbalControlChanged
();
}
}
//-----------------------------------------------------------------------------
void
CustomQuickInterface
::
setShowAttitudeWidget
(
bool
set
)
{
if
(
_showAttitudeWidget
!=
set
)
{
_showAttitudeWidget
=
set
;
QSettings
settings
;
settings
.
beginGroup
(
kGroupName
);
settings
.
setValue
(
kShowAttitudeWidget
,
set
);
emit
showAttitudeWidgetChanged
();
}
}
custom-example/src/CustomQuickInterface.h
View file @
242d6519
...
...
@@ -29,12 +29,20 @@ public:
CustomQuickInterface
(
QObject
*
parent
=
nullptr
);
~
CustomQuickInterface
();
Q_PROPERTY
(
bool
showGimbalControl
READ
showGimbalControl
WRITE
setShowGimbalControl
NOTIFY
showGimbalControlChanged
)
Q_PROPERTY
(
bool
showAttitudeWidget
READ
showAttitudeWidget
WRITE
setShowAttitudeWidget
NOTIFY
showAttitudeWidgetChanged
)
bool
showGimbalControl
()
{
return
_showGimbalControl
;
}
void
setShowGimbalControl
(
bool
set
);
void
init
();
bool
showAttitudeWidget
()
{
return
_showAttitudeWidget
;
}
void
setShowAttitudeWidget
(
bool
set
);
signals:
void
showGimbalControlChanged
();
void
showAttitudeWidgetChanged
();
private:
bool
_showGimbalControl
=
true
;
bool
_showAttitudeWidget
=
false
;
};
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