Commit a781d693 authored by Gus Grubba's avatar Gus Grubba Committed by Lorenz Meier

Make field aware of which chart index it belongs to.

parent 0de02e58
......@@ -263,6 +263,7 @@ QT += \
svg \
widgets \
xml \
charts \
texttospeech
# Multimedia only used if QVC is enabled
......@@ -277,7 +278,6 @@ AndroidBuild || iOSBuild {
QT += \
printsupport \
serialport \
charts \
}
contains(DEFINES, QGC_ENABLE_BLUETOOTH) {
......
......@@ -76,6 +76,15 @@ QGCMAVLinkMessageField::setSelectable(bool sel)
}
}
//-----------------------------------------------------------------------------
int
QGCMAVLinkMessageField::chartIndex()
{
if(_chart)
return _chart->chartIndex();
return 0;
}
//-----------------------------------------------------------------------------
void
QGCMAVLinkMessageField::updateValue(QString newValue, qreal v)
......@@ -494,8 +503,9 @@ QGCMAVLinkVehicle::_checkCompID(QGCMAVLinkMessage* message)
}
//-----------------------------------------------------------------------------
MAVLinkChartController::MAVLinkChartController(MAVLinkInspectorController *parent)
MAVLinkChartController::MAVLinkChartController(MAVLinkInspectorController *parent, int index)
: QObject(parent)
, _index(index)
, _controller(parent)
{
connect(&_updateSeriesTimer, &QTimer::timeout, this, &MAVLinkChartController::_refreshSeries);
......@@ -789,7 +799,7 @@ MAVLinkInspectorController::_receiveMessage(LinkInterface*, mavlink_message_t me
MAVLinkChartController*
MAVLinkInspectorController::createChart()
{
MAVLinkChartController* pChart = new MAVLinkChartController(this);
MAVLinkChartController* pChart = new MAVLinkChartController(this, _charts.count());
QQmlEngine::setObjectOwnership(pChart, QQmlEngine::CppOwnership);
_charts.append(pChart);
emit chartsChanged();
......
......@@ -35,6 +35,7 @@ public:
Q_PROPERTY(QString type READ type CONSTANT)
Q_PROPERTY(QString value READ value NOTIFY valueChanged)
Q_PROPERTY(bool selectable READ selectable NOTIFY selectableChanged)
Q_PROPERTY(int chartIndex READ chartIndex CONSTANT)
Q_PROPERTY(QAbstractSeries* series READ series NOTIFY seriesChanged)
QGCMAVLinkMessageField(QGCMAVLinkMessage* parent, QString name, QString type);
......@@ -49,6 +50,7 @@ public:
QList<QPointF>* values () { return &_values;}
qreal rangeMin () { return _rangeMin; }
qreal rangeMax () { return _rangeMax; }
int chartIndex ();
void setSelectable (bool sel);
void updateValue (QString newValue, qreal v);
......@@ -157,7 +159,7 @@ private:
class MAVLinkChartController : public QObject {
Q_OBJECT
public:
MAVLinkChartController(MAVLinkInspectorController* parent);
MAVLinkChartController(MAVLinkInspectorController* parent, int index);
Q_PROPERTY(QVariantList chartFields READ chartFields NOTIFY chartFieldsChanged)
Q_PROPERTY(QDateTime rangeXMin READ rangeXMin NOTIFY rangeXMinChanged)
......@@ -180,6 +182,7 @@ public:
qreal rangeYMax () { return _rangeYMax; }
quint32 rangeXIndex () { return _rangeXIndex; }
quint32 rangeYIndex () { return _rangeYIndex; }
int chartIndex () { return _index; }
void setRangeXIndex (quint32 t);
void setRangeYIndex (quint32 r);
......@@ -202,6 +205,7 @@ private:
QTimer _updateSeriesTimer;
QDateTime _rangeXMin;
QDateTime _rangeXMax;
int _index = 0;
qreal _rangeYMin = 0;
qreal _rangeYMax = 1;
quint32 _rangeXIndex = 0; ///< 5 Seconds
......
......@@ -302,8 +302,8 @@ AnalyzePage {
delegate: QGCCheckBox {
Layout.row: index
Layout.column: 3
enabled: (object.series !== null) || (object.selectable)
checked: enabled ? (object.series !== null) : false
enabled: checked || (object.selectable && object.series === null)
checked: object.series !== null && object.chartIndex === 0
onClicked: {
if(enabled) {
if(checked) {
......@@ -320,8 +320,8 @@ AnalyzePage {
delegate: QGCCheckBox {
Layout.row: index
Layout.column: 4
enabled: (object.series !== null) || (object.selectable)
checked: enabled ? (object.series !== null) : false
enabled: checked || (object.selectable && object.series === null)
checked: object.series !== null && object.chartIndex === 1
onClicked: {
if(enabled) {
if(checked) {
......
......@@ -53,8 +53,8 @@ ChartView {
DateTimeAxis {
id: axisX
min: chartController ? chartController.rangeXMin : 0
max: chartController ? chartController.rangeXMax : 0
min: chartController ? chartController.rangeXMin : new Date()
max: chartController ? chartController.rangeXMax : new Date()
format: "mm:ss.zzz"
tickCount: 5
gridVisible: true
......@@ -91,6 +91,7 @@ ChartView {
}
QGCComboBox {
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 10
Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 10
height: ScreenTools.defaultFontPixelHeight
model: controller.timeScales
currentIndex: chartController ? chartController.rangeXIndex : 0
......@@ -105,6 +106,7 @@ ChartView {
}
QGCComboBox {
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 10
Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 10
height: ScreenTools.defaultFontPixelHeight
model: controller.rangeList
currentIndex: chartController ? chartController.rangeYIndex : 0
......@@ -113,5 +115,17 @@ ChartView {
Layout.alignment: Qt.AlignVCenter
}
}
ColumnLayout {
Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: true
Repeater {
model: chartController ? chartController.chartFields : []
QGCLabel {
text: modelData.label
color: chartView.series(index).color
font.pixelSize: ScreenTools.smallFontPointSize
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment