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
8cf5f75c
Commit
8cf5f75c
authored
Apr 12, 2020
by
DoinLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
1aba5c4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
3 deletions
+135
-3
InstrumentValue.cc
src/FlightMap/Widgets/InstrumentValue.cc
+97
-1
InstrumentValue.h
src/FlightMap/Widgets/InstrumentValue.h
+14
-0
ValuePageWidget.qml
src/FlightMap/Widgets/ValuePageWidget.qml
+24
-2
No files found.
src/FlightMap/Widgets/InstrumentValue.cc
View file @
8cf5f75c
...
...
@@ -65,11 +65,21 @@ InstrumentValue::InstrumentValue(Vehicle* activeVehicle, FontSize fontSize, QmlO
}
activeVehicleChanged
(
_activeVehicle
);
connect
(
this
,
&
InstrumentValue
::
rangeTypeChanged
,
this
,
&
InstrumentValue
::
_resetRangeInfo
);
connect
(
this
,
&
InstrumentValue
::
rangeTypeChanged
,
this
,
&
InstrumentValue
::
_resetRangeInfo
);
connect
(
this
,
&
InstrumentValue
::
rangeTypeChanged
,
this
,
&
InstrumentValue
::
_updateRanges
);
connect
(
this
,
&
InstrumentValue
::
rangeValuesChanged
,
this
,
&
InstrumentValue
::
_updateRanges
);
connect
(
this
,
&
InstrumentValue
::
rangeColorsChanged
,
this
,
&
InstrumentValue
::
_updateRanges
);
connect
(
this
,
&
InstrumentValue
::
rangeOpacitiesChanged
,
this
,
&
InstrumentValue
::
_updateRanges
);
connect
(
this
,
&
InstrumentValue
::
rangeIconsChanged
,
this
,
&
InstrumentValue
::
_updateRanges
);
}
void
InstrumentValue
::
activeVehicleChanged
(
Vehicle
*
activeVehicle
)
{
if
(
_fact
)
{
disconnect
(
_fact
,
&
Fact
::
rawValueChanged
,
this
,
&
InstrumentValue
::
_updateColor
);
}
_activeVehicle
=
activeVehicle
;
_factGroupNames
.
clear
();
...
...
@@ -94,12 +104,17 @@ void InstrumentValue::activeVehicleChanged(Vehicle* activeVehicle)
_fact
=
factGroup
->
getFact
(
_factName
);
}
emit
factChanged
(
_fact
);
connect
(
_fact
,
&
Fact
::
rawValueChanged
,
this
,
&
InstrumentValue
::
_updateRanges
);
}
_updateRanges
();
}
void
InstrumentValue
::
setFact
(
const
QString
&
factGroupName
,
const
QString
&
factName
)
{
if
(
_fact
)
{
disconnect
(
_fact
,
&
Fact
::
rawValueChanged
,
this
,
&
InstrumentValue
::
_updateRanges
);
_fact
=
nullptr
;
}
...
...
@@ -129,6 +144,8 @@ void InstrumentValue::setFact(const QString& factGroupName, const QString& factN
if
(
_fact
)
{
_factGroupName
=
factGroupName
;
_factName
=
nonEmptyFactName
;
connect
(
_fact
,
&
Fact
::
rawValueChanged
,
this
,
&
InstrumentValue
::
_updateRanges
);
}
else
{
_factName
.
clear
();
_factGroupName
.
clear
();
...
...
@@ -138,6 +155,8 @@ void InstrumentValue::setFact(const QString& factGroupName, const QString& factN
emit
factNameChanged
(
_factName
);
emit
factGroupNameChanged
(
_factGroupName
);
emit
factValueNamesChanged
(
_factValueNames
);
_updateRanges
();
}
void
InstrumentValue
::
_setFontSize
(
FontSize
fontSize
)
...
...
@@ -412,3 +431,80 @@ void InstrumentValue::removeRangeValue(int index)
emit
rangeOpacitiesChanged
(
_rangeOpacities
);
emit
rangeIconsChanged
(
_rangeIcons
);
}
void
InstrumentValue
::
_updateRanges
(
void
)
{
_updateColor
();
_updateIcon
();
_updateOpacity
();
}
void
InstrumentValue
::
_updateColor
(
void
)
{
QColor
newColor
;
int
rangeIndex
=
-
1
;
if
(
_rangeType
==
ColorRange
&&
_fact
)
{
rangeIndex
=
_currentRangeIndex
(
_fact
->
rawValue
().
toDouble
());
}
if
(
rangeIndex
!=
-
1
)
{
newColor
=
_rangeColors
[
rangeIndex
].
value
<
QColor
>
();
}
if
(
newColor
!=
_currentColor
)
{
_currentColor
=
newColor
;
emit
currentColorChanged
(
_currentColor
);
}
}
void
InstrumentValue
::
_updateOpacity
(
void
)
{
double
newOpacity
=
1.0
;
int
rangeIndex
=
-
1
;
if
(
_rangeType
==
OpacityRange
&&
_fact
)
{
rangeIndex
=
_currentRangeIndex
(
_fact
->
rawValue
().
toDouble
());
}
if
(
rangeIndex
!=
-
1
)
{
newOpacity
=
_rangeOpacities
[
rangeIndex
].
toDouble
();
}
if
(
!
qFuzzyCompare
(
newOpacity
,
_currentOpacity
))
{
_currentOpacity
=
newOpacity
;
emit
currentOpacityChanged
(
newOpacity
);
}
}
void
InstrumentValue
::
_updateIcon
(
void
)
{
QString
newIcon
;
int
rangeIndex
=
-
1
;
if
(
_rangeType
==
IconSelectRange
&&
_fact
)
{
rangeIndex
=
_currentRangeIndex
(
_fact
->
rawValue
().
toDouble
());
}
if
(
rangeIndex
!=
-
1
)
{
newIcon
=
_rangeIcons
[
rangeIndex
].
toString
();
}
if
(
newIcon
!=
_currentIcon
)
{
_currentIcon
=
newIcon
;
emit
currentIconChanged
(
newIcon
);
}
}
int
InstrumentValue
::
_currentRangeIndex
(
const
QVariant
&
value
)
{
if
(
qIsNaN
(
value
.
toDouble
()))
{
return
0
;
}
for
(
int
i
=
0
;
i
<
_rangeValues
.
count
();
i
++
)
{
if
(
value
.
toDouble
()
<=
_rangeValues
[
i
].
toDouble
())
{
return
i
;
}
}
return
_rangeValues
.
count
();
}
src/FlightMap/Widgets/InstrumentValue.h
View file @
8cf5f75c
...
...
@@ -63,6 +63,9 @@ public:
Q_PROPERTY
(
QVariantList
rangeColors
READ
rangeColors
WRITE
setRangeColors
NOTIFY
rangeColorsChanged
)
Q_PROPERTY
(
QVariantList
rangeIcons
READ
rangeIcons
WRITE
setRangeIcons
NOTIFY
rangeIconsChanged
)
Q_PROPERTY
(
QVariantList
rangeOpacities
READ
rangeOpacities
WRITE
setRangeOpacities
NOTIFY
rangeOpacitiesChanged
)
Q_PROPERTY
(
QColor
currentColor
MEMBER
_currentColor
NOTIFY
currentColorChanged
)
Q_PROPERTY
(
double
currentOpacity
MEMBER
_currentOpacity
NOTIFY
currentOpacityChanged
)
Q_PROPERTY
(
QString
currentIcon
MEMBER
_currentIcon
NOTIFY
currentIconChanged
)
Q_INVOKABLE
void
setFact
(
const
QString
&
factGroupName
,
const
QString
&
factName
);
Q_INVOKABLE
void
clearFact
(
void
);
...
...
@@ -112,12 +115,20 @@ signals:
void
rangeColorsChanged
(
const
QVariantList
&
rangeColors
);
void
rangeIconsChanged
(
const
QVariantList
&
rangeIcons
);
void
rangeOpacitiesChanged
(
const
QVariantList
&
rangeOpacities
);
void
currentColorChanged
(
const
QColor
&
currentColor
);
void
currentOpacityChanged
(
double
currentOpacity
);
void
currentIconChanged
(
const
QString
&
currentIcon
);
private
slots
:
void
_resetRangeInfo
(
void
);
void
_updateRanges
(
void
);
private:
void
_setFontSize
(
FontSize
fontSize
);
int
_currentRangeIndex
(
const
QVariant
&
value
);
void
_updateColor
(
void
);
void
_updateIcon
(
void
);
void
_updateOpacity
(
void
);
Vehicle
*
_activeVehicle
=
nullptr
;
QmlObjectListModel
*
_rowModel
=
nullptr
;
...
...
@@ -131,6 +142,9 @@ private:
IconPosition
_iconPosition
=
IconLeft
;
QStringList
_factGroupNames
;
QStringList
_factValueNames
;
QColor
_currentColor
;
double
_currentOpacity
=
1
.
0
;
QString
_currentIcon
;
// Ranges allow you to specifiy semantics to apply when a value is within a certain range.
// The limits for each section of the range are specified in _rangeValues. With the first
...
...
src/FlightMap/Widgets/ValuePageWidget.qml
View file @
8cf5f75c
...
...
@@ -166,15 +166,37 @@ Column {
id
:
valueIcon
height
:
_rgFontSizeTightHeights
[
object
.
fontSize
]
width
:
height
source
:
object
.
icon
?
"
/InstrumentValueIcons/
"
+
object
.
icon
:
""
source
:
icon
sourceSize.height
:
height
fillMode
:
Image
.
PreserveAspectFit
mipmap
:
true
smooth
:
true
color
:
qgcPal
.
text
color
:
object
.
isValidColor
(
object
.
currentColor
)
?
object
.
currentColor
:
qgcPal
.
text
opacity
:
object
.
currentOpacity
visible
:
object
.
icon
onWidthChanged
:
columnItem
.
recalcPositions
()
onHeightChanged
:
columnItem
.
recalcPositions
()
property
string
icon
readonly
property
string
iconPrefix
:
"
/InstrumentValueIcons/
"
function
updateIcon
()
{
if
(
object
.
rangeType
==
InstrumentValue
.
IconSelectRange
)
{
icon
=
iconPrefix
+
object
.
currentIcon
}
else
if
(
object
.
icon
)
{
icon
=
iconPrefix
+
object
.
icon
}
else
{
icon
=
""
}
}
Connections
{
target
:
object
onRangeTypeChanged
:
valueIcon
.
updateIcon
()
onCurrentIconChanged
:
valueIcon
.
updateIcon
()
onIconChanged
:
valueIcon
.
updateIcon
()
}
Component.onCompleted
:
updateIcon
();
}
QGCLabel
{
...
...
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