Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
5c4a5821
Commit
5c4a5821
authored
Dec 30, 2019
by
Gus Grubba
Committed by
Lorenz Meier
Jan 03, 2020
Browse files
Allow defining series range
Add custom chart header
parent
a556d873
Changes
3
Show whitespace changes
Inline
Side-by-side
src/AnalyzeView/MAVLinkInspectorController.cc
View file @
5c4a5821
...
...
@@ -18,6 +18,14 @@ QT_CHARTS_USE_NAMESPACE
Q_DECLARE_METATYPE
(
QAbstractSeries
*
)
//-----------------------------------------------------------------------------
QGCMAVLinkMessageField
::
Range_st
::
Range_st
(
QObject
*
parent
,
const
QString
&
l
,
qreal
r
)
:
QObject
(
parent
)
,
label
(
l
)
,
range
(
r
)
{
}
//-----------------------------------------------------------------------------
QGCMAVLinkMessageField
::
QGCMAVLinkMessageField
(
QGCMAVLinkMessage
*
parent
,
QString
name
,
QString
type
)
:
QObject
(
parent
)
...
...
@@ -26,6 +34,47 @@ QGCMAVLinkMessageField::QGCMAVLinkMessageField(QGCMAVLinkMessage *parent, QStrin
,
_msg
(
parent
)
{
qCDebug
(
MAVLinkInspectorLog
)
<<
"Field:"
<<
name
<<
type
;
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"Auto"
),
0
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"10,000"
),
10000
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"1,000"
),
1000
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"100"
),
100
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"10"
),
10
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"1"
),
1
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"0.1"
),
0.1
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"0.01"
),
0.01
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"0.001"
),
0.001
));
_rangeSt
.
append
(
new
Range_st
(
this
,
tr
(
"0.0001"
),
0.0001
));
emit
rangeListChanged
();
}
//----------------------------------------------------------------------------------------
QStringList
QGCMAVLinkMessageField
::
rangeList
()
{
if
(
!
_rangeList
.
count
())
{
for
(
int
i
=
0
;
i
<
_rangeSt
.
count
();
i
++
)
{
_rangeList
<<
_rangeSt
[
i
]
->
label
;
}
}
return
_rangeList
;
}
//-----------------------------------------------------------------------------
void
QGCMAVLinkMessageField
::
setRange
(
quint32
r
)
{
if
(
r
<
static_cast
<
quint32
>
(
_rangeSt
.
count
()))
{
_rangeIndex
=
r
;
_range
=
_rangeSt
[
static_cast
<
int
>
(
r
)]
->
range
;
emit
rangeChanged
();
//-- If not Auto, use defined range
if
(
_rangeIndex
>
0
)
{
_rangeMin
=
-
_range
;
emit
rangeMinChanged
();
_rangeMax
=
_range
;
emit
rangeMaxChanged
();
}
}
}
//-----------------------------------------------------------------------------
...
...
@@ -88,6 +137,8 @@ QGCMAVLinkMessageField::updateValue(QString newValue, qreal v)
_times
[
_dataIndex
]
=
QGC
::
groundTimeMilliseconds
();
_dataIndex
++
;
}
//-- Auto Range
if
(
_rangeIndex
==
0
)
{
qreal
vmin
=
std
::
numeric_limits
<
qreal
>::
max
();
qreal
vmax
=
std
::
numeric_limits
<
qreal
>::
min
();
for
(
int
i
=
0
;
i
<
_values
.
count
();
i
++
)
{
...
...
@@ -103,6 +154,7 @@ QGCMAVLinkMessageField::updateValue(QString newValue, qreal v)
_rangeMax
=
vmax
;
emit
rangeMaxChanged
();
}
}
_msg
->
msgCtl
()
->
updateXRange
();
_updateSeries
();
}
...
...
@@ -479,6 +531,14 @@ QGCMAVLinkVehicle::_checkCompID(QGCMAVLinkMessage* message)
}
}
//-----------------------------------------------------------------------------
MAVLinkInspectorController
::
TimeScale_st
::
TimeScale_st
(
QObject
*
parent
,
const
QString
&
l
,
uint32_t
t
)
:
QObject
(
parent
)
,
label
(
l
)
,
timeScale
(
t
)
{
}
//-----------------------------------------------------------------------------
MAVLinkInspectorController
::
MAVLinkInspectorController
()
{
...
...
@@ -493,10 +553,11 @@ MAVLinkInspectorController::MAVLinkInspectorController()
connect
(
manager
,
&
MultiVehicleManager
::
activeVehicleChanged
,
this
,
&
MAVLinkInspectorController
::
_setActiveVehicle
);
_rangeXMax
=
QDateTime
::
fromMSecsSinceEpoch
(
0
);
_rangeXMin
=
QDateTime
::
fromMSecsSinceEpoch
(
std
::
numeric_limits
<
qint64
>::
max
());
_timeScales
<<
tr
(
"5 Sec"
);
_timeScales
<<
tr
(
"10 Sec"
);
_timeScales
<<
tr
(
"30 Sec"
);
_timeScales
<<
tr
(
"60 Sec"
);
_timeScaleSt
.
append
(
new
TimeScale_st
(
this
,
tr
(
"5 Sec"
),
5
*
1000
));
_timeScaleSt
.
append
(
new
TimeScale_st
(
this
,
tr
(
"10 Sec"
),
10
*
1000
));
_timeScaleSt
.
append
(
new
TimeScale_st
(
this
,
tr
(
"30 Sec"
),
30
*
1000
));
_timeScaleSt
.
append
(
new
TimeScale_st
(
this
,
tr
(
"60 Sec"
),
60
*
1000
));
emit
timeScalesChanged
();
}
//-----------------------------------------------------------------------------
...
...
@@ -506,6 +567,18 @@ MAVLinkInspectorController::~MAVLinkInspectorController()
}
//----------------------------------------------------------------------------------------
QStringList
MAVLinkInspectorController
::
timeScales
()
{
if
(
!
_timeScales
.
count
())
{
for
(
int
i
=
0
;
i
<
_timeScaleSt
.
count
();
i
++
)
{
_timeScales
<<
_timeScaleSt
[
i
]
->
label
;
}
}
return
_timeScales
;
}
//----------------------------------------------------------------------------------------
void
MAVLinkInspectorController
::
_setActiveVehicle
(
Vehicle
*
vehicle
)
...
...
@@ -673,15 +746,11 @@ MAVLinkInspectorController::setTimeScale(quint32 t)
void
MAVLinkInspectorController
::
updateXRange
()
{
int
ts
=
5
*
1000
;
switch
(
_timeScale
)
{
case
1
:
ts
=
10
*
1000
;
break
;
case
2
:
ts
=
30
*
1000
;
break
;
case
3
:
ts
=
60
*
1000
;
break
;
}
if
(
_timeScale
<
static_cast
<
quint32
>
(
_timeScaleSt
.
count
()))
{
qint64
t
=
static_cast
<
qint64
>
(
QGC
::
groundTimeMilliseconds
());
_rangeXMax
=
QDateTime
::
fromMSecsSinceEpoch
(
t
);
_rangeXMin
=
QDateTime
::
fromMSecsSinceEpoch
(
t
-
ts
);
_rangeXMin
=
QDateTime
::
fromMSecsSinceEpoch
(
t
-
_timeScaleSt
[
static_cast
<
int
>
(
_timeScale
)]
->
timeScale
);
emit
rangeMinXChanged
();
emit
rangeMaxXChanged
();
}
}
src/AnalyzeView/MAVLinkInspectorController.h
View file @
5c4a5821
...
...
@@ -32,10 +32,12 @@ class QGCMAVLinkMessageField : public QObject {
Q_PROPERTY
(
QString
label
READ
label
CONSTANT
)
Q_PROPERTY
(
QString
type
READ
type
CONSTANT
)
Q_PROPERTY
(
QString
value
READ
value
NOTIFY
valueChanged
)
Q_PROPERTY
(
QStringList
rangeList
READ
rangeList
NOTIFY
rangeListChanged
)
Q_PROPERTY
(
qreal
rangeMin
READ
rangeMin
NOTIFY
rangeMinChanged
)
Q_PROPERTY
(
qreal
rangeMax
READ
rangeMax
NOTIFY
rangeMaxChanged
)
Q_PROPERTY
(
bool
selectable
READ
selectable
NOTIFY
selectableChanged
)
Q_PROPERTY
(
bool
selected
READ
selected
WRITE
setSelected
NOTIFY
selectedChanged
)
Q_PROPERTY
(
quint32
range
READ
range
WRITE
setRange
NOTIFY
rangeChanged
)
public:
QGCMAVLinkMessageField
(
QGCMAVLinkMessage
*
parent
,
QString
name
,
QString
type
);
...
...
@@ -44,14 +46,17 @@ public:
QString
label
();
QString
type
()
{
return
_type
;
}
QString
value
()
{
return
_value
;
}
QStringList
rangeList
();
qreal
rangeMin
()
{
return
_rangeMin
;
}
qreal
rangeMax
()
{
return
_rangeMax
;
}
QList
<
QPointF
>
series
()
{
return
_series
;
}
bool
selectable
()
{
return
_selectable
;
}
bool
selected
()
{
return
_selected
;
}
quint32
range
()
{
return
_rangeIndex
;
}
void
setSelectable
(
bool
sel
);
void
setSelected
(
bool
sel
);
void
setRange
(
quint32
r
);
void
updateValue
(
QString
newValue
,
qreal
v
);
signals:
...
...
@@ -61,11 +66,21 @@ signals:
void
selectableChanged
();
void
selectedChanged
();
void
valueChanged
();
void
rangeListChanged
();
void
rangeChanged
();
private:
void
_updateSeries
();
private:
class
Range_st
:
public
QObject
{
public:
Range_st
(
QObject
*
parent
,
const
QString
&
l
,
qreal
r
);
QString
label
;
qreal
range
;
};
QString
_type
;
QString
_name
;
QString
_value
;
...
...
@@ -75,9 +90,13 @@ private:
int
_dataIndex
=
0
;
qreal
_rangeMin
=
0
;
qreal
_rangeMax
=
0
;
quint32
_rangeIndex
=
0
;
///> Auto Range
qreal
_range
=
0
;
QStringList
_rangeList
;
QVector
<
qreal
>
_values
;
QVector
<
quint64
>
_times
;
QList
<
QPointF
>
_series
;
QList
<
Range_st
*>
_rangeSt
;
};
//-----------------------------------------------------------------------------
...
...
@@ -174,8 +193,7 @@ public:
Q_PROPERTY
(
QVariantList
chartFields
READ
chartFields
NOTIFY
chartFieldCountChanged
)
Q_PROPERTY
(
QDateTime
rangeXMin
READ
rangeXMin
NOTIFY
rangeMinXChanged
)
Q_PROPERTY
(
QDateTime
rangeXMax
READ
rangeXMax
NOTIFY
rangeMaxXChanged
)
Q_PROPERTY
(
QStringList
timeScales
READ
timeScales
CONSTANT
)
Q_PROPERTY
(
QStringList
timeScales
READ
timeScales
NOTIFY
timeScalesChanged
)
Q_PROPERTY
(
quint32
timeScale
READ
timeScale
WRITE
setTimeScale
NOTIFY
timeScaleChanged
)
Q_INVOKABLE
void
updateSeries
(
int
index
,
QAbstractSeries
*
series
);
...
...
@@ -184,7 +202,7 @@ public:
QGCMAVLinkVehicle
*
activeVehicle
()
{
return
_activeVehicle
;
}
QStringList
vehicleNames
()
{
return
_vehicleNames
;
}
quint32
timeScale
()
{
return
_timeScale
;
}
QStringList
timeScales
()
{
return
_timeScales
;
}
QStringList
timeScales
()
;
QVariantList
chartFields
()
{
return
_chartFields
;
}
QDateTime
rangeXMin
()
{
return
_rangeXMin
;
}
QDateTime
rangeXMax
()
{
return
_rangeXMax
;
}
...
...
@@ -202,6 +220,7 @@ signals:
void
timeScaleChanged
();
void
rangeMinXChanged
();
void
rangeMaxXChanged
();
void
timeScalesChanged
();
private
slots
:
void
_receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
);
...
...
@@ -212,10 +231,17 @@ private slots:
private:
void
_reset
();
QGCMAVLinkVehicle
*
_findVehicle
(
uint8_t
id
);
private:
class
TimeScale_st
:
public
QObject
{
public:
TimeScale_st
(
QObject
*
parent
,
const
QString
&
l
,
uint32_t
t
);
QString
label
;
uint32_t
timeScale
;
};
int
_selectedSystemID
=
0
;
///< Currently selected system
int
_selectedComponentID
=
0
;
///< Currently selected component
QStringList
_timeScales
;
...
...
@@ -227,4 +253,5 @@ private:
QStringList
_vehicleNames
;
QmlObjectListModel
_vehicles
;
///< List of QGCMAVLinkVehicle
QVariantList
_chartFields
;
QList
<
TimeScale_st
*>
_timeScaleSt
;
};
src/AnalyzeView/MAVLinkInspectorPage.qml
View file @
5c4a5821
...
...
@@ -314,9 +314,9 @@ AnalyzePage {
antialiasing
:
true
visible
:
controller
.
chartFieldCount
>
0
animationOptions
:
ChartView
.
NoAnimation
legend.
font.pixelSize
:
ScreenTools
.
smallFontPointSiz
e
legend.
visible
:
fals
e
margins.bottom
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
margins.top
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
margins.top
:
chartHeader
.
height
+
(
ScreenTools
.
defaultFontPixelHeight
*
2
)
DateTimeAxis
{
id
:
axisX
...
...
@@ -336,6 +336,7 @@ AnalyzePage {
visible
:
controller
.
chartFieldCount
>
0
lineVisible
:
false
labelsFont.pixelSize
:
ScreenTools
.
smallFontPointSize
labelsColor
:
qgcPal
.
colorRed
}
ValueAxis
{
...
...
@@ -345,6 +346,7 @@ AnalyzePage {
visible
:
controller
.
chartFieldCount
>
1
lineVisible
:
false
labelsFont.pixelSize
:
ScreenTools
.
smallFontPointSize
labelsColor
:
qgcPal
.
colorGreen
}
LineSeries
{
...
...
@@ -390,17 +392,72 @@ AnalyzePage {
}
}
}
QGCComboBox
{
id
:
timeScaleSelecto
r
RowLayout
{
id
:
chartHeade
r
anchors.left
:
parent
.
left
anchors.leftMargin
:
ScreenTools
.
defaultFontPixelWidth
*
4
anchors.right
:
parent
.
right
anchors.rightMargin
:
ScreenTools
.
defaultFontPixelWidth
*
4
anchors.top
:
parent
.
top
anchors.topMargin
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
spacing
:
0
QGCLabel
{
text
:
qsTr
(
"
Scale:
"
);
font.pixelSize
:
ScreenTools
.
smallFontPointSize
Layout.alignment
:
Qt
.
AlignVCenter
}
QGCComboBox
{
id
:
timeScaleSelector
width
:
ScreenTools
.
defaultFontPixelWidth
*
10
height
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
height
:
ScreenTools
.
defaultFontPixelHeight
model
:
controller
.
timeScales
currentIndex
:
controller
.
timeScale
onActivated
:
controller
.
timeScale
=
index
font.pixelSize
:
ScreenTools
.
smallFontPointSize
Layout.alignment
:
Qt
.
AlignVCenter
}
GridLayout
{
columns
:
3
columnSpacing
:
ScreenTools
.
defaultFontPixelWidth
rowSpacing
:
ScreenTools
.
defaultFontPixelHeight
*
0.25
Layout.alignment
:
Qt
.
AlignRight
|
Qt
.
AlignVCenter
Layout.fillWidth
:
true
Repeater
{
model
:
controller
.
chartFieldCount
?
controller
.
chartFields
:
[]
delegate
:
QGCLabel
{
text
:
chartView
.
series
(
index
).
name
color
:
chartView
.
series
(
index
).
color
font.pixelSize
:
ScreenTools
.
smallFontPointSize
Layout.row
:
index
Layout.column
:
0
Layout.alignment
:
Qt
.
AlignVCenter
}
}
Repeater
{
model
:
controller
.
chartFieldCount
?
controller
.
chartFields
:
[]
delegate
:
QGCLabel
{
text
:
qsTr
(
"
Range:
"
);
font.pixelSize
:
ScreenTools
.
smallFontPointSize
Layout.row
:
index
Layout.column
:
1
Layout.alignment
:
Qt
.
AlignVCenter
}
}
Repeater
{
model
:
controller
.
chartFieldCount
?
controller
.
chartFields
:
[]
delegate
:
QGCComboBox
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
12
height
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
model
:
modelData
.
rangeList
currentIndex
:
modelData
.
range
onActivated
:
modelData
.
range
=
index
font.pixelSize
:
ScreenTools
.
smallFontPointSize
Layout.row
:
index
Layout.column
:
2
Layout.alignment
:
Qt
.
AlignVCenter
}
}
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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