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
4b69460c
Commit
4b69460c
authored
Apr 18, 2017
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow translation of cm/px units
parent
98db1bee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+15
-2
FactMetaData.h
src/FactSystem/FactMetaData.h
+3
-0
No files found.
src/FactSystem/FactMetaData.cc
View file @
4b69460c
...
...
@@ -28,8 +28,9 @@ const qreal FactMetaData::UnitConsts_s::secondsPerHour = 3600.0;
const
qreal
FactMetaData
::
UnitConsts_s
::
knotsToKPH
=
1.852
;
// exact, hence weird base for knotsToMetersPerSecond
// Length
const
qreal
FactMetaData
::
UnitConsts_s
::
milesToMeters
=
1609.344
;
const
qreal
FactMetaData
::
UnitConsts_s
::
feetToMeters
=
0.3048
;
const
qreal
FactMetaData
::
UnitConsts_s
::
milesToMeters
=
1609.344
;
const
qreal
FactMetaData
::
UnitConsts_s
::
feetToMeters
=
0.3048
;
const
qreal
FactMetaData
::
UnitConsts_s
::
inchesToCentimeters
=
2.54
;
// Built in translations for all Facts
const
FactMetaData
::
BuiltInTranslation_s
FactMetaData
::
_rgBuiltInTranslations
[]
=
{
...
...
@@ -42,10 +43,12 @@ const FactMetaData::BuiltInTranslation_s FactMetaData::_rgBuiltInTranslations[]
const
FactMetaData
::
AppSettingsTranslation_s
FactMetaData
::
_rgAppSettingsTranslations
[]
=
{
{
"m"
,
"m"
,
false
,
UnitsSettings
::
DistanceUnitsMeters
,
FactMetaData
::
_defaultTranslator
,
FactMetaData
::
_defaultTranslator
},
{
"meters"
,
"meters"
,
false
,
UnitsSettings
::
DistanceUnitsMeters
,
FactMetaData
::
_defaultTranslator
,
FactMetaData
::
_defaultTranslator
},
{
"cm/px"
,
"cm/px"
,
false
,
UnitsSettings
::
DistanceUnitsMeters
,
FactMetaData
::
_defaultTranslator
,
FactMetaData
::
_defaultTranslator
},
{
"m/s"
,
"m/s"
,
true
,
UnitsSettings
::
SpeedUnitsMetersPerSecond
,
FactMetaData
::
_defaultTranslator
,
FactMetaData
::
_defaultTranslator
},
{
"m^2"
,
"m^2"
,
false
,
UnitsSettings
::
AreaUnitsSquareMeters
,
FactMetaData
::
_defaultTranslator
,
FactMetaData
::
_defaultTranslator
},
{
"m"
,
"ft"
,
false
,
UnitsSettings
::
DistanceUnitsFeet
,
FactMetaData
::
_metersToFeet
,
FactMetaData
::
_feetToMeters
},
{
"meters"
,
"ft"
,
false
,
UnitsSettings
::
DistanceUnitsFeet
,
FactMetaData
::
_metersToFeet
,
FactMetaData
::
_feetToMeters
},
{
"cm/px"
,
"in/px"
,
false
,
UnitsSettings
::
DistanceUnitsFeet
,
FactMetaData
::
_centimetersToInches
,
FactMetaData
::
_inchesToCentimeters
},
{
"m^2"
,
"km^2"
,
false
,
UnitsSettings
::
AreaUnitsSquareKilometers
,
FactMetaData
::
_squareMetersToSquareKilometers
,
FactMetaData
::
_squareKilometersToSquareMeters
},
{
"m^2"
,
"ha"
,
false
,
UnitsSettings
::
AreaUnitsHectares
,
FactMetaData
::
_squareMetersToHectares
,
FactMetaData
::
_hectaresToSquareMeters
},
{
"m^2"
,
"ft^2"
,
false
,
UnitsSettings
::
AreaUnitsSquareFeet
,
FactMetaData
::
_squareMetersToSquareFeet
,
FactMetaData
::
_squareFeetToSquareMeters
},
...
...
@@ -552,6 +555,16 @@ QVariant FactMetaData::_normToPercent(const QVariant& normalized)
return
QVariant
(
normalized
.
toDouble
()
*
100.0
);
}
QVariant
FactMetaData
::
_centimetersToInches
(
const
QVariant
&
centimeters
)
{
return
QVariant
(
centimeters
.
toDouble
()
*
1.0
/
constants
.
inchesToCentimeters
);
}
QVariant
FactMetaData
::
_inchesToCentimeters
(
const
QVariant
&
inches
)
{
return
QVariant
(
inches
.
toDouble
()
*
constants
.
inchesToCentimeters
);
}
void
FactMetaData
::
setRawUnits
(
const
QString
&
rawUnits
)
{
_rawUnits
=
rawUnits
;
...
...
src/FactSystem/FactMetaData.h
View file @
4b69460c
...
...
@@ -175,6 +175,8 @@ private:
static
QVariant
_knotsToMetersPerSecond
(
const
QVariant
&
knots
);
static
QVariant
_percentToNorm
(
const
QVariant
&
percent
);
static
QVariant
_normToPercent
(
const
QVariant
&
normalized
);
static
QVariant
_centimetersToInches
(
const
QVariant
&
centimeters
);
static
QVariant
_inchesToCentimeters
(
const
QVariant
&
inches
);
struct
AppSettingsTranslation_s
{
const
char
*
rawUnits
;
...
...
@@ -218,6 +220,7 @@ private:
static
const
qreal
knotsToKPH
;
static
const
qreal
milesToMeters
;
static
const
qreal
feetToMeters
;
static
const
qreal
inchesToCentimeters
;
}
constants
;
struct
BuiltInTranslation_s
{
...
...
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