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
1b04f783
Commit
1b04f783
authored
Mar 13, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support user configurable unit conversion
parent
dcd55081
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
21 deletions
+98
-21
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+44
-0
FactMetaData.h
src/FactSystem/FactMetaData.h
+21
-9
FlightDisplayViewWidgets.qml
src/FlightDisplay/FlightDisplayViewWidgets.qml
+18
-10
MissionItemStatus.qml
src/MissionEditor/MissionItemStatus.qml
+3
-2
QGroundControlQmlGlobal.h
src/QmlControls/QGroundControlQmlGlobal.h
+12
-0
No files found.
src/FactSystem/FactMetaData.cc
View file @
1b04f783
...
@@ -534,3 +534,47 @@ void FactMetaData::setAppSettingsTranslators(void)
...
@@ -534,3 +534,47 @@ void FactMetaData::setAppSettingsTranslators(void)
}
}
}
}
}
}
const
FactMetaData
::
AppSettingsTranslation_s
*
FactMetaData
::
_findAppSettingsDistanceUnitsTranslation
(
const
QString
&
rawUnits
)
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgAppSettingsTranslations
)
/
sizeof
(
_rgAppSettingsTranslations
[
0
]);
i
++
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
&
_rgAppSettingsTranslations
[
i
];
if
(
pAppSettingsTranslation
->
rawUnits
==
rawUnits
&&
(
!
pAppSettingsTranslation
->
speed
&&
pAppSettingsTranslation
->
speedOrDistanceUnits
==
QGroundControlQmlGlobal
::
distanceUnits
()
->
rawValue
().
toUInt
()))
{
return
pAppSettingsTranslation
;
}
}
return
NULL
;
}
QVariant
FactMetaData
::
metersToAppSettingsDistanceUnits
(
const
QVariant
&
meters
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
_findAppSettingsDistanceUnitsTranslation
(
"m"
);
if
(
pAppSettingsTranslation
)
{
return
pAppSettingsTranslation
->
rawTranslator
(
meters
);
}
else
{
return
meters
;
}
}
QVariant
FactMetaData
::
appSettingsDistanceUnitsToMeters
(
const
QVariant
&
distance
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
_findAppSettingsDistanceUnitsTranslation
(
"m"
);
if
(
pAppSettingsTranslation
)
{
return
pAppSettingsTranslation
->
cookedTranslator
(
distance
);
}
else
{
return
distance
;
}
}
QString
FactMetaData
::
appSettingsDistanceUnitsString
(
void
)
{
const
AppSettingsTranslation_s
*
pAppSettingsTranslation
=
_findAppSettingsDistanceUnitsTranslation
(
"m"
);
if
(
pAppSettingsTranslation
)
{
return
pAppSettingsTranslation
->
cookedUnits
;
}
else
{
return
QStringLiteral
(
"m"
);
}
}
src/FactSystem/FactMetaData.h
View file @
1b04f783
...
@@ -61,6 +61,15 @@ public:
...
@@ -61,6 +61,15 @@ public:
const
FactMetaData
&
operator
=
(
const
FactMetaData
&
other
);
const
FactMetaData
&
operator
=
(
const
FactMetaData
&
other
);
/// Converts from meters to the user specified distance unit
static
QVariant
metersToAppSettingsDistanceUnits
(
const
QVariant
&
meters
);
/// Converts from user specified distance unit to meters
static
QVariant
appSettingsDistanceUnitsToMeters
(
const
QVariant
&
distance
);
/// Returns the string for distance units which has configued by user
static
QString
appSettingsDistanceUnitsString
(
void
);
int
decimalPlaces
(
void
)
const
{
return
_decimalPlaces
;
}
int
decimalPlaces
(
void
)
const
{
return
_decimalPlaces
;
}
QVariant
rawDefaultValue
(
void
)
const
;
QVariant
rawDefaultValue
(
void
)
const
;
QVariant
cookedDefaultValue
(
void
)
const
{
return
_rawTranslator
(
rawDefaultValue
());
}
QVariant
cookedDefaultValue
(
void
)
const
{
return
_rawTranslator
(
rawDefaultValue
());
}
...
@@ -154,6 +163,18 @@ private:
...
@@ -154,6 +163,18 @@ private:
static
QVariant
_metersPerSecondToKnots
(
const
QVariant
&
metersPerSecond
);
static
QVariant
_metersPerSecondToKnots
(
const
QVariant
&
metersPerSecond
);
static
QVariant
_knotsToMetersPerSecond
(
const
QVariant
&
knots
);
static
QVariant
_knotsToMetersPerSecond
(
const
QVariant
&
knots
);
struct
AppSettingsTranslation_s
{
const
char
*
rawUnits
;
const
char
*
cookedUnits
;
bool
speed
;
uint32_t
speedOrDistanceUnits
;
Translator
rawTranslator
;
Translator
cookedTranslator
;
};
static
const
AppSettingsTranslation_s
*
_findAppSettingsDistanceUnitsTranslation
(
const
QString
&
rawUnits
);
ValueType_t
_type
;
// must be first for correct constructor init
ValueType_t
_type
;
// must be first for correct constructor init
int
_decimalPlaces
;
int
_decimalPlaces
;
QVariant
_rawDefaultValue
;
QVariant
_rawDefaultValue
;
...
@@ -186,15 +207,6 @@ private:
...
@@ -186,15 +207,6 @@ private:
};
};
static
const
BuiltInTranslation_s
_rgBuiltInTranslations
[];
static
const
BuiltInTranslation_s
_rgBuiltInTranslations
[];
struct
AppSettingsTranslation_s
{
const
char
*
rawUnits
;
const
char
*
cookedUnits
;
bool
speed
;
uint32_t
speedOrDistanceUnits
;
Translator
rawTranslator
;
Translator
cookedTranslator
;
};
static
const
AppSettingsTranslation_s
_rgAppSettingsTranslations
[];
static
const
AppSettingsTranslation_s
_rgAppSettingsTranslations
[];
};
};
...
...
src/FlightDisplay/FlightDisplayViewWidgets.qml
View file @
1b04f783
...
@@ -341,7 +341,7 @@ Item {
...
@@ -341,7 +341,7 @@ Item {
break
;
break
;
case
confirmTakeoff
:
case
confirmTakeoff
:
altitudeSlider
.
visible
=
true
altitudeSlider
.
visible
=
true
altitudeSlider
.
initialValue
=
10
altitudeSlider
.
setInitialValueMeters
(
10
)
_guidedModeBar
.
confirmText
=
"
takeoff
"
_guidedModeBar
.
confirmText
=
"
takeoff
"
break
;
break
;
case
confirmLand
:
case
confirmLand
:
...
@@ -349,7 +349,7 @@ Item {
...
@@ -349,7 +349,7 @@ Item {
break
;
break
;
case
confirmChangeAlt
:
case
confirmChangeAlt
:
altitudeSlider
.
visible
=
true
altitudeSlider
.
visible
=
true
altitudeSlider
.
initialValue
=
_activeVehicle
.
altitudeAMSL
.
value
altitudeSlider
.
setInitialValueAppSettingsDistanceUnits
(
_activeVehicle
.
altitudeAMSL
.
value
)
_guidedModeBar
.
confirmText
=
"
altitude change
"
_guidedModeBar
.
confirmText
=
"
altitude change
"
break
;
break
;
case
confirmGoTo
:
case
confirmGoTo
:
...
@@ -444,14 +444,24 @@ Item {
...
@@ -444,14 +444,24 @@ Item {
opacity
:
0.8
opacity
:
0.8
visible
:
false
visible
:
false
property
alias
initialValue
:
altSlider
.
value
function
setInitialValueMeters
(
meters
)
{
altSlider
.
value
=
QGroundControl
.
metersToAppSettingsDistanceUnits
(
meters
)
}
function
setInitialValueAppSettingsDistanceUnits
(
height
)
{
altSlider
.
value
=
height
}
/// Returns NaN for bad value
/// Returns NaN for bad value
function
getValue
()
{
function
getValue
()
{
return
parseFloat
(
altField
.
text
)
var
value
=
parseFloat
(
altField
.
text
)
if
(
!
isNaN
(
value
))
{
return
QGroundControl
.
appSettingsDistanceUnitsToMeters
(
value
);
}
else
{
return
value
;
}
}
}
Column
{
Column
{
id
:
headerColumn
id
:
headerColumn
anchors.margins
:
_margins
anchors.margins
:
_margins
...
@@ -461,12 +471,12 @@ Item {
...
@@ -461,12 +471,12 @@ Item {
QGCLabel
{
QGCLabel
{
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
text
:
"
Alt
itude
"
text
:
"
Alt
(rel)
"
}
}
QGCLabel
{
QGCLabel
{
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
text
:
"
meters (rel)
"
text
:
QGroundControl
.
appSettingsDistanceUnitsString
}
}
QGCTextField
{
QGCTextField
{
...
@@ -486,9 +496,7 @@ Item {
...
@@ -486,9 +496,7 @@ Item {
anchors.right
:
parent
.
right
anchors.right
:
parent
.
right
orientation
:
Qt
.
Vertical
orientation
:
Qt
.
Vertical
minimumValue
:
0
minimumValue
:
0
maximumValue
:
100
maximumValue
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
100
)
value
:
30
//anchors.horizontalCenter: parent.horizontalCenter
}
}
}
}
}
}
src/MissionEditor/MissionItemStatus.qml
View file @
1b04f783
...
@@ -27,6 +27,7 @@ import QtQuick.Controls 1.3
...
@@ -27,6 +27,7 @@ import QtQuick.Controls 1.3
import
QGroundControl
.
ScreenTools
1.0
import
QGroundControl
.
ScreenTools
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
1.0
Rectangle
{
Rectangle
{
property
var
currentMissionItem
///< Mission item to display status for
property
var
currentMissionItem
///< Mission item to display status for
...
@@ -50,8 +51,8 @@ Rectangle {
...
@@ -50,8 +51,8 @@ Rectangle {
property
real
_gradientPercent
:
isNaN
(
_gradient
)
?
0
:
_gradient
*
100
property
real
_gradientPercent
:
isNaN
(
_gradient
)
?
0
:
_gradient
*
100
property
real
_azimuth
:
_statusValid
?
_currentMissionItem
.
azimuth
:
-
1
property
real
_azimuth
:
_statusValid
?
_currentMissionItem
.
azimuth
:
-
1
property
bool
_statusValid
:
currentMissionItem
!=
undefined
property
bool
_statusValid
:
currentMissionItem
!=
undefined
property
string
_distanceText
:
_statusValid
?
_distance
.
toFixed
(
2
)
+
"
m
"
:
""
property
string
_distanceText
:
_statusValid
?
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_distance
).
toFixed
(
2
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
:
""
property
string
_altText
:
_statusValid
?
_altDifference
.
toFixed
(
2
)
+
"
m
"
:
""
property
string
_altText
:
_statusValid
?
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_altDifference
).
toFixed
(
2
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
:
""
property
string
_gradientText
:
_statusValid
?
_gradientPercent
.
toFixed
(
0
)
+
"
%
"
:
""
property
string
_gradientText
:
_statusValid
?
_gradientPercent
.
toFixed
(
0
)
+
"
%
"
:
""
property
string
_azimuthText
:
_statusValid
?
Math
.
round
(
_azimuth
)
:
""
property
string
_azimuthText
:
_statusValid
?
Math
.
round
(
_azimuth
)
:
""
...
...
src/QmlControls/QGroundControlQmlGlobal.h
View file @
1b04f783
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "FlightMapSettings.h"
#include "FlightMapSettings.h"
#include "MissionCommands.h"
#include "MissionCommands.h"
#include "SettingsFact.h"
#include "SettingsFact.h"
#include "FactMetaData.h"
#ifdef QT_DEBUG
#ifdef QT_DEBUG
#include "MockLink.h"
#include "MockLink.h"
...
@@ -104,6 +105,9 @@ public:
...
@@ -104,6 +105,9 @@ public:
/// @ return: true: experimental survey ip code is turned on
/// @ return: true: experimental survey ip code is turned on
Q_PROPERTY
(
bool
experimentalSurvey
READ
experimentalSurvey
WRITE
setExperimentalSurvey
NOTIFY
experimentalSurveyChanged
)
Q_PROPERTY
(
bool
experimentalSurvey
READ
experimentalSurvey
WRITE
setExperimentalSurvey
NOTIFY
experimentalSurveyChanged
)
/// Returns the string for distance units which has configued by user
Q_PROPERTY
(
QString
appSettingsDistanceUnitsString
READ
appSettingsDistanceUnitsString
CONSTANT
)
Q_INVOKABLE
void
saveGlobalSetting
(
const
QString
&
key
,
const
QString
&
value
);
Q_INVOKABLE
void
saveGlobalSetting
(
const
QString
&
key
,
const
QString
&
value
);
Q_INVOKABLE
QString
loadGlobalSetting
(
const
QString
&
key
,
const
QString
&
defaultValue
);
Q_INVOKABLE
QString
loadGlobalSetting
(
const
QString
&
key
,
const
QString
&
defaultValue
);
Q_INVOKABLE
void
saveBoolGlobalSetting
(
const
QString
&
key
,
bool
value
);
Q_INVOKABLE
void
saveBoolGlobalSetting
(
const
QString
&
key
,
bool
value
);
...
@@ -118,6 +122,14 @@ public:
...
@@ -118,6 +122,14 @@ public:
Q_INVOKABLE
void
startAPMArduPlaneMockLink
(
bool
sendStatusText
);
Q_INVOKABLE
void
startAPMArduPlaneMockLink
(
bool
sendStatusText
);
Q_INVOKABLE
void
stopAllMockLinks
(
void
);
Q_INVOKABLE
void
stopAllMockLinks
(
void
);
/// Converts from meters to the user specified distance unit
Q_INVOKABLE
QVariant
metersToAppSettingsDistanceUnits
(
const
QVariant
&
meters
)
const
{
return
FactMetaData
::
metersToAppSettingsDistanceUnits
(
meters
);
}
/// Converts from user specified distance unit to meters
Q_INVOKABLE
QVariant
appSettingsDistanceUnitsToMeters
(
const
QVariant
&
distance
)
const
{
return
FactMetaData
::
appSettingsDistanceUnitsToMeters
(
distance
);
}
QString
appSettingsDistanceUnitsString
(
void
)
const
{
return
FactMetaData
::
appSettingsDistanceUnitsString
();
}
// Property accesors
// Property accesors
FlightMapSettings
*
flightMapSettings
()
{
return
_flightMapSettings
;
}
FlightMapSettings
*
flightMapSettings
()
{
return
_flightMapSettings
;
}
...
...
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