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
783476cb
Commit
783476cb
authored
Aug 18, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use app settings translators on params
parent
589046c1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
15 deletions
+15
-15
FactGroup.cc
src/FactSystem/FactGroup.cc
+0
-3
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+14
-7
FactMetaData.h
src/FactSystem/FactMetaData.h
+1
-3
SimpleMissionItem.cc
src/MissionManager/SimpleMissionItem.cc
+0
-2
No files found.
src/FactSystem/FactGroup.cc
View file @
783476cb
...
...
@@ -234,9 +234,6 @@ void FactGroup::_loadMetaData(const QString& jsonFilename)
}
}
// All FactGroup Facts use translator based on app settings
metaData
->
setAppSettingsTranslators
();
_nameToFactMetaDataMap
[
name
]
=
metaData
;
}
}
src/FactSystem/FactMetaData.cc
View file @
783476cb
...
...
@@ -37,7 +37,7 @@ const qreal FactMetaData::UnitConsts_s::feetToMeters = 0.3048;
const
FactMetaData
::
BuiltInTranslation_s
FactMetaData
::
_rgBuiltInTranslations
[]
=
{
{
"centi-degrees"
,
"deg"
,
FactMetaData
::
_centiDegreesToDegrees
,
FactMetaData
::
_degreesToCentiDegrees
},
{
"radians"
,
"deg"
,
FactMetaData
::
_radiansToDegrees
,
FactMetaData
::
_degreesToRadians
},
{
"norm"
,
"%"
,
FactMetaData
::
_normToPercent
,
FactMetaData
::
_percentToNorm
},
{
"norm"
,
"%"
,
FactMetaData
::
_normToPercent
,
FactMetaData
::
_percentToNorm
},
};
// Translations driven by app settings
...
...
@@ -48,11 +48,11 @@ const FactMetaData::AppSettingsTranslation_s FactMetaData::_rgAppSettingsTransla
{
"m^2"
,
"m^2"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsSquareMeters
,
FactMetaData
::
_defaultTranslator
,
FactMetaData
::
_defaultTranslator
},
{
"m"
,
"ft"
,
false
,
QGroundControlQmlGlobal
::
DistanceUnitsFeet
,
FactMetaData
::
_metersToFeet
,
FactMetaData
::
_feetToMeters
},
{
"meters"
,
"ft"
,
false
,
QGroundControlQmlGlobal
::
DistanceUnitsFeet
,
FactMetaData
::
_metersToFeet
,
FactMetaData
::
_feetToMeters
},
{
"m^2"
,
"km^2"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsSquareKilometers
,
FactMetaData
::
_squareMetersToSquareKilometers
,
FactMetaData
::
_squareKilometersToSquareMeters
},
{
"m^2"
,
"ha"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsHectares
,
FactMetaData
::
_squareMetersToHectares
,
FactMetaData
::
_hectaresToSquareMeters
},
{
"m^2"
,
"ft^2"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsSquareFeet
,
FactMetaData
::
_squareMetersToSquareFeet
,
FactMetaData
::
_squareFeetToSquareMeters
},
{
"m^2"
,
"ac"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsAcres
,
FactMetaData
::
_squareMetersToAcres
,
FactMetaData
::
_acresToSquareMeters
},
{
"m^2"
,
"mi^2"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsSquareMiles
,
FactMetaData
::
_squareMetersToSquareMiles
,
FactMetaData
::
_squareMilesToSquareMeters
},
{
"m^2"
,
"km^2"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsSquareKilometers
,
FactMetaData
::
_squareMetersToSquareKilometers
,
FactMetaData
::
_squareKilometersToSquareMeters
},
{
"m^2"
,
"ha"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsHectares
,
FactMetaData
::
_squareMetersToHectares
,
FactMetaData
::
_hectaresToSquareMeters
},
{
"m^2"
,
"ft^2"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsSquareFeet
,
FactMetaData
::
_squareMetersToSquareFeet
,
FactMetaData
::
_squareFeetToSquareMeters
},
{
"m^2"
,
"ac"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsAcres
,
FactMetaData
::
_squareMetersToAcres
,
FactMetaData
::
_acresToSquareMeters
},
{
"m^2"
,
"mi^2"
,
false
,
QGroundControlQmlGlobal
::
AreaUnitsSquareMiles
,
FactMetaData
::
_squareMetersToSquareMiles
,
FactMetaData
::
_squareMilesToSquareMeters
},
{
"m/s"
,
"ft/s"
,
true
,
QGroundControlQmlGlobal
::
SpeedUnitsFeetPerSecond
,
FactMetaData
::
_metersToFeet
,
FactMetaData
::
_feetToMeters
},
{
"m/s"
,
"mph"
,
true
,
QGroundControlQmlGlobal
::
SpeedUnitsMilesPerHour
,
FactMetaData
::
_metersPerSecondToMilesPerHour
,
FactMetaData
::
_milesPerHourToMetersPerSecond
},
{
"m/s"
,
"km/h"
,
true
,
QGroundControlQmlGlobal
::
SpeedUnitsKilometersPerHour
,
FactMetaData
::
_metersPerSecondToKilometersPerHour
,
FactMetaData
::
_kilometersPerHourToMetersPerSecond
},
...
...
@@ -383,6 +383,7 @@ void FactMetaData::setBuiltInTranslator(void)
// No translation if enum
setTranslators
(
_defaultTranslator
,
_defaultTranslator
);
_cookedUnits
=
_rawUnits
;
return
;
}
else
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgBuiltInTranslations
)
/
sizeof
(
_rgBuiltInTranslations
[
0
]);
i
++
)
{
const
BuiltInTranslation_s
*
pBuiltInTranslation
=
&
_rgBuiltInTranslations
[
i
];
...
...
@@ -390,9 +391,13 @@ void FactMetaData::setBuiltInTranslator(void)
if
(
pBuiltInTranslation
->
rawUnits
==
_rawUnits
.
toLower
())
{
_cookedUnits
=
pBuiltInTranslation
->
cookedUnits
;
setTranslators
(
pBuiltInTranslation
->
rawTranslator
,
pBuiltInTranslation
->
cookedTranslator
);
return
;
}
}
}
// Translator not yet set, try app settings translators
_setAppSettingsTranslators
();
}
QVariant
FactMetaData
::
_degreesToRadians
(
const
QVariant
&
degrees
)
...
...
@@ -584,7 +589,9 @@ size_t FactMetaData::typeToSize(ValueType_t type)
}
}
void
FactMetaData
::
setAppSettingsTranslators
(
void
)
/// Set translators according to app settings
void
FactMetaData
::
_setAppSettingsTranslators
(
void
)
{
if
(
!
_enumStrings
.
count
())
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
_rgAppSettingsTranslations
)
/
sizeof
(
_rgAppSettingsTranslations
[
0
]);
i
++
)
{
...
...
src/FactSystem/FactMetaData.h
View file @
783476cb
...
...
@@ -121,9 +121,6 @@ public:
/// Set the translators to the standard built in versions
void
setBuiltInTranslator
(
void
);
/// Set translators according to app settings
void
setAppSettingsTranslators
(
void
);
/// Converts the specified raw value, validating against meta data
/// @param rawValue Value to convert, can be string
/// @param convertOnly true: convert to correct type only, do not validate against meta data
...
...
@@ -144,6 +141,7 @@ public:
private:
QVariant
_minForType
(
void
)
const
;
QVariant
_maxForType
(
void
)
const
;
void
_setAppSettingsTranslators
(
void
);
// Built in translators
static
QVariant
_defaultTranslator
(
const
QVariant
&
from
)
{
return
from
;
}
...
...
src/MissionManager/SimpleMissionItem.cc
View file @
783476cb
...
...
@@ -193,7 +193,6 @@ void SimpleMissionItem::_setupMetaData(void)
_altitudeMetaData
=
new
FactMetaData
(
FactMetaData
::
valueTypeDouble
);
_altitudeMetaData
->
setRawUnits
(
"m"
);
_altitudeMetaData
->
setDecimalPlaces
(
2
);
_altitudeMetaData
->
setAppSettingsTranslators
();
enumStrings
.
clear
();
enumValues
.
clear
();
...
...
@@ -375,7 +374,6 @@ QmlObjectListModel* SimpleMissionItem::textFieldFacts(void)
paramMetaData
->
setDecimalPlaces
(
paramInfo
->
decimalPlaces
());
paramMetaData
->
setEnumInfo
(
paramInfo
->
enumStrings
(),
paramInfo
->
enumValues
());
paramMetaData
->
setRawUnits
(
paramInfo
->
units
());
paramMetaData
->
setAppSettingsTranslators
();
paramFact
->
setMetaData
(
paramMetaData
);
model
->
append
(
paramFact
);
...
...
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