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
6aecdf7c
Commit
6aecdf7c
authored
Apr 12, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3211 from DonLakeFlyer/ValidateDecimalPlaces
Validate/Set decimal places against increment value
parents
db59e0bb
12db07d7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
9 deletions
+40
-9
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+32
-2
FactMetaData.h
src/FactSystem/FactMetaData.h
+3
-2
MissionCommandList.cc
src/MissionManager/MissionCommandList.cc
+1
-1
SimpleMissionItem.cc
src/MissionManager/SimpleMissionItem.cc
+4
-4
No files found.
src/FactSystem/FactMetaData.cc
View file @
6aecdf7c
...
...
@@ -56,7 +56,7 @@ const FactMetaData::AppSettingsTranslation_s FactMetaData::_rgAppSettingsTransla
FactMetaData
::
FactMetaData
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_type
(
valueTypeInt32
)
,
_decimalPlaces
(
default
DecimalPlaces
)
,
_decimalPlaces
(
unknown
DecimalPlaces
)
,
_rawDefaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_group
(
"*Default Group"
)
...
...
@@ -75,7 +75,7 @@ FactMetaData::FactMetaData(QObject* parent)
FactMetaData
::
FactMetaData
(
ValueType_t
type
,
QObject
*
parent
)
:
QObject
(
parent
)
,
_type
(
type
)
,
_decimalPlaces
(
default
DecimalPlaces
)
,
_decimalPlaces
(
unknown
DecimalPlaces
)
,
_rawDefaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_group
(
"*Default Group"
)
...
...
@@ -578,3 +578,33 @@ QString FactMetaData::appSettingsDistanceUnitsString(void)
return
QStringLiteral
(
"m"
);
}
}
int
FactMetaData
::
decimalPlaces
(
void
)
const
{
int
actualDecimalPlaces
=
defaultDecimalPlaces
;
int
incrementDecimalPlaces
=
unknownDecimalPlaces
;
// First determine decimal places from increment
double
increment
=
this
->
increment
();
if
(
!
qIsNaN
(
increment
))
{
double
integralPart
;
// Get the fractional part only
increment
=
fabs
(
modf
(
increment
,
&
integralPart
));
if
(
increment
==
0.0
)
{
// No fractional part, so no decimal places
incrementDecimalPlaces
=
0
;
}
else
{
incrementDecimalPlaces
=
-
ceil
(
log10
(
increment
));
}
}
// Correct decimal places is the larger of the two, increment or meta data value
if
(
incrementDecimalPlaces
!=
unknownDecimalPlaces
&&
_decimalPlaces
==
unknownDecimalPlaces
)
{
actualDecimalPlaces
=
incrementDecimalPlaces
;
}
else
{
actualDecimalPlaces
=
qMax
(
_decimalPlaces
,
incrementDecimalPlaces
);
}
return
actualDecimalPlaces
;
}
src/FactSystem/FactMetaData.h
View file @
6aecdf7c
...
...
@@ -70,7 +70,7 @@ public:
/// 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
;
QVariant
rawDefaultValue
(
void
)
const
;
QVariant
cookedDefaultValue
(
void
)
const
{
return
_rawTranslator
(
rawDefaultValue
());
}
bool
defaultValueAvailable
(
void
)
const
{
return
_defaultValueAvailable
;
}
...
...
@@ -139,7 +139,8 @@ public:
/// Same as convertAndValidateRaw except for cookedValue input
bool
convertAndValidateCooked
(
const
QVariant
&
cookedValue
,
bool
convertOnly
,
QVariant
&
typedValue
,
QString
&
errorString
);
static
const
int
defaultDecimalPlaces
=
3
;
static
const
int
defaultDecimalPlaces
=
3
;
///< Default value for decimal places if not specified/known
static
const
int
unknownDecimalPlaces
=
-
1
;
///< Number of decimal places to specify is not known
static
ValueType_t
stringToType
(
const
QString
&
typeString
,
bool
&
unknownType
);
static
size_t
typeToSize
(
ValueType_t
type
);
...
...
src/MissionManager/MissionCommandList.cc
View file @
6aecdf7c
...
...
@@ -187,7 +187,7 @@ void MissionCommandList::_loadMavCmdInfoJson(const QString& jsonFilename)
paramInfo
->
_label
=
paramObject
.
value
(
_labelJsonKey
).
toString
();
paramInfo
->
_defaultValue
=
paramObject
.
value
(
_defaultJsonKey
).
toDouble
(
0.0
);
paramInfo
->
_decimalPlaces
=
paramObject
.
value
(
_decimalPlacesJsonKey
).
toInt
(
FactMetaData
::
default
DecimalPlaces
);
paramInfo
->
_decimalPlaces
=
paramObject
.
value
(
_decimalPlacesJsonKey
).
toInt
(
FactMetaData
::
unknown
DecimalPlaces
);
paramInfo
->
_enumStrings
=
paramObject
.
value
(
_enumStringsJsonKey
).
toString
().
split
(
","
,
QString
::
SkipEmptyParts
);
paramInfo
->
_param
=
i
;
paramInfo
->
_units
=
paramObject
.
value
(
_unitsJsonKey
).
toString
();
...
...
src/MissionManager/SimpleMissionItem.cc
View file @
6aecdf7c
...
...
@@ -322,16 +322,16 @@ QString SimpleMissionItem::abbreviation() const
void
SimpleMissionItem
::
_clearParamMetaData
(
void
)
{
_param1MetaData
.
setRawUnits
(
""
);
_param1MetaData
.
setDecimalPlaces
(
FactMetaData
::
default
DecimalPlaces
);
_param1MetaData
.
setDecimalPlaces
(
FactMetaData
::
unknown
DecimalPlaces
);
_param1MetaData
.
setBuiltInTranslator
();
_param2MetaData
.
setRawUnits
(
""
);
_param2MetaData
.
setDecimalPlaces
(
FactMetaData
::
default
DecimalPlaces
);
_param2MetaData
.
setDecimalPlaces
(
FactMetaData
::
unknown
DecimalPlaces
);
_param2MetaData
.
setBuiltInTranslator
();
_param3MetaData
.
setRawUnits
(
""
);
_param3MetaData
.
setDecimalPlaces
(
FactMetaData
::
default
DecimalPlaces
);
_param3MetaData
.
setDecimalPlaces
(
FactMetaData
::
unknown
DecimalPlaces
);
_param3MetaData
.
setBuiltInTranslator
();
_param4MetaData
.
setRawUnits
(
""
);
_param4MetaData
.
setDecimalPlaces
(
FactMetaData
::
default
DecimalPlaces
);
_param4MetaData
.
setDecimalPlaces
(
FactMetaData
::
unknown
DecimalPlaces
);
_param4MetaData
.
setBuiltInTranslator
();
}
...
...
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