Commit 00cf60ca authored by Gus Grubba's avatar Gus Grubba Committed by Lorenz Meier

UI tweaks and adding time scale.

parent 8b0fe775
...@@ -28,6 +28,13 @@ QGCMAVLinkMessageField::QGCMAVLinkMessageField(QGCMAVLinkMessage *parent, QStrin ...@@ -28,6 +28,13 @@ QGCMAVLinkMessageField::QGCMAVLinkMessageField(QGCMAVLinkMessage *parent, QStrin
qCDebug(MAVLinkInspectorLog) << "Field:" << name << type; qCDebug(MAVLinkInspectorLog) << "Field:" << name << type;
} }
//-----------------------------------------------------------------------------
QString
QGCMAVLinkMessageField::label()
{
return QString(_msg->name() + ": " + _name);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
QGCMAVLinkMessageField::setSelectable(bool sel) QGCMAVLinkMessageField::setSelectable(bool sel)
...@@ -486,6 +493,12 @@ MAVLinkInspectorController::MAVLinkInspectorController() ...@@ -486,6 +493,12 @@ MAVLinkInspectorController::MAVLinkInspectorController()
connect(manager, &MultiVehicleManager::activeVehicleChanged, this, &MAVLinkInspectorController::_setActiveVehicle); connect(manager, &MultiVehicleManager::activeVehicleChanged, this, &MAVLinkInspectorController::_setActiveVehicle);
_rangeXMax = QDateTime::fromMSecsSinceEpoch(0); _rangeXMax = QDateTime::fromMSecsSinceEpoch(0);
_rangeXMin = QDateTime::fromMSecsSinceEpoch(std::numeric_limits<qint64>::max()); _rangeXMin = QDateTime::fromMSecsSinceEpoch(std::numeric_limits<qint64>::max());
_timeScales << tr("5 Sec");
_timeScales << tr("10 Sec");
_timeScales << tr("30 Sec");
_timeScales << tr("1 Min");
_timeScales << tr("2 Min");
_timeScales << tr("5 Min");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -649,13 +662,30 @@ MAVLinkInspectorController::updateSeries(int index, QAbstractSeries* series) ...@@ -649,13 +662,30 @@ MAVLinkInspectorController::updateSeries(int index, QAbstractSeries* series)
} }
} }
//-----------------------------------------------------------------------------
void
MAVLinkInspectorController::setTimeScale(quint32 t)
{
_timeScale = t;
emit timeScaleChanged();
updateXRange();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MAVLinkInspectorController::updateXRange() 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;
case 4: ts = 2 * 60 * 1000; break;
case 5: ts = 5 * 60 * 1000; break;
}
qint64 t = static_cast<qint64>(QGC::groundTimeMilliseconds()); qint64 t = static_cast<qint64>(QGC::groundTimeMilliseconds());
_rangeXMax = QDateTime::fromMSecsSinceEpoch(t); _rangeXMax = QDateTime::fromMSecsSinceEpoch(t);
_rangeXMin = QDateTime::fromMSecsSinceEpoch(t - (60 * 1000)); _rangeXMin = QDateTime::fromMSecsSinceEpoch(t - ts);
emit rangeMinXChanged(); emit rangeMinXChanged();
emit rangeMaxXChanged(); emit rangeMaxXChanged();
} }
...@@ -29,6 +29,7 @@ class MAVLinkInspectorController; ...@@ -29,6 +29,7 @@ class MAVLinkInspectorController;
class QGCMAVLinkMessageField : public QObject { class QGCMAVLinkMessageField : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(QString label READ label CONSTANT)
Q_PROPERTY(QString type READ type CONSTANT) Q_PROPERTY(QString type READ type CONSTANT)
Q_PROPERTY(QString value READ value NOTIFY valueChanged) Q_PROPERTY(QString value READ value NOTIFY valueChanged)
Q_PROPERTY(qreal rangeMin READ rangeMin NOTIFY rangeMinChanged) Q_PROPERTY(qreal rangeMin READ rangeMin NOTIFY rangeMinChanged)
...@@ -40,6 +41,7 @@ public: ...@@ -40,6 +41,7 @@ public:
QGCMAVLinkMessageField(QGCMAVLinkMessage* parent, QString name, QString type); QGCMAVLinkMessageField(QGCMAVLinkMessage* parent, QString name, QString type);
QString name () { return _name; } QString name () { return _name; }
QString label ();
QString type () { return _type; } QString type () { return _type; }
QString value () { return _value; } QString value () { return _value; }
qreal rangeMin () { return _rangeMin; } qreal rangeMin () { return _rangeMin; }
...@@ -173,6 +175,7 @@ public: ...@@ -173,6 +175,7 @@ public:
Q_PROPERTY(QDateTime rangeXMin READ rangeXMin NOTIFY rangeMinXChanged) Q_PROPERTY(QDateTime rangeXMin READ rangeXMin NOTIFY rangeMinXChanged)
Q_PROPERTY(QDateTime rangeXMax READ rangeXMax NOTIFY rangeMaxXChanged) Q_PROPERTY(QDateTime rangeXMax READ rangeXMax NOTIFY rangeMaxXChanged)
Q_PROPERTY(QStringList timeScales READ timeScales CONSTANT)
Q_PROPERTY(quint32 timeScale READ timeScale WRITE setTimeScale NOTIFY timeScaleChanged) Q_PROPERTY(quint32 timeScale READ timeScale WRITE setTimeScale NOTIFY timeScaleChanged)
Q_INVOKABLE void updateSeries (int index, QAbstractSeries *series); Q_INVOKABLE void updateSeries (int index, QAbstractSeries *series);
...@@ -180,12 +183,13 @@ public: ...@@ -180,12 +183,13 @@ public:
QmlObjectListModel* vehicles () { return &_vehicles; } QmlObjectListModel* vehicles () { return &_vehicles; }
QGCMAVLinkVehicle* activeVehicle () { return _activeVehicle; } QGCMAVLinkVehicle* activeVehicle () { return _activeVehicle; }
QStringList vehicleNames () { return _vehicleNames; } QStringList vehicleNames () { return _vehicleNames; }
quint32 timeScale () { return _timeScale; } quint32 timeScale () { return _timeScale; }
QVariantList chartFields () { return _chartFields; } QStringList timeScales () { return _timeScales; }
QDateTime rangeXMin () { return _rangeXMin; } QVariantList chartFields () { return _chartFields; }
QDateTime rangeXMax () { return _rangeXMax; } QDateTime rangeXMin () { return _rangeXMin; }
QDateTime rangeXMax () { return _rangeXMax; }
void setTimeScale (quint32 t) { _timeScale = t; emit timeScaleChanged(); } void setTimeScale (quint32 t);
int chartFieldCount () { return _chartFields.count(); } int chartFieldCount () { return _chartFields.count(); }
void addChartField (QGCMAVLinkMessageField* field); void addChartField (QGCMAVLinkMessageField* field);
void delChartField (QGCMAVLinkMessageField* field); void delChartField (QGCMAVLinkMessageField* field);
...@@ -212,15 +216,15 @@ private: ...@@ -212,15 +216,15 @@ private:
QGCMAVLinkVehicle* _findVehicle (uint8_t id); QGCMAVLinkVehicle* _findVehicle (uint8_t id);
private: private:
int _selectedSystemID = 0; ///< Currently selected system int _selectedSystemID = 0; ///< Currently selected system
int _selectedComponentID = 0; ///< Currently selected component int _selectedComponentID = 0; ///< Currently selected component
quint32 _timeScale = 10; ///< 10 Seconds QStringList _timeScales;
QDateTime _rangeXMin; quint32 _timeScale = 0; ///< 5 Seconds
QDateTime _rangeXMax; QDateTime _rangeXMin;
QDateTime _rangeXMax;
QGCMAVLinkVehicle* _activeVehicle = nullptr; QGCMAVLinkVehicle* _activeVehicle = nullptr;
QTimer _updateTimer; QTimer _updateTimer;
QStringList _vehicleNames; QStringList _vehicleNames;
QmlObjectListModel _vehicles; //-- List of QGCMAVLinkVehicle QmlObjectListModel _vehicles; ///< List of QGCMAVLinkVehicle
QVariantList _chartFields; QVariantList _chartFields;
}; };
...@@ -44,50 +44,64 @@ AnalyzePage { ...@@ -44,50 +44,64 @@ AnalyzePage {
Rectangle { Rectangle {
color: qgcPal.window color: qgcPal.window
anchors.fill: parent anchors.fill: parent
QGCComboBox {
id: timeScaleSelector
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
anchors.top: parent.top
width: ScreenTools.defaultFontPixelWidth * 10
height: ScreenTools.defaultFontPixelHeight * 1.5
model: controller.timeScales
currentIndex: controller.timeScale
onActivated: controller.timeScale = index
}
ChartView { ChartView {
id: chartView id: chartView
anchors.fill: parent anchors.right: parent.right
anchors.left: parent.left
anchors.top: timeScaleSelector.bottom
anchors.bottom: parent.bottom
theme: ChartView.ChartThemeDark theme: ChartView.ChartThemeDark
antialiasing: true antialiasing: true
animationOptions: ChartView.NoAnimation animationOptions: ChartView.NoAnimation
ValueAxis { ValueAxis {
id: axisY1 id: axisY1
min: visible ? controller.chartFields[0].rangeMin : 0 min: visible ? controller.chartFields[0].rangeMin : 0
max: visible ? controller.chartFields[0].rangeMax : 0 max: visible ? controller.chartFields[0].rangeMax : 0
visible: controller.chartFieldCount > 0 visible: controller.chartFieldCount > 0
} }
ValueAxis { ValueAxis {
id: axisY2 id: axisY2
min: visible ? controller.chartFields[1].rangeMin : 0 min: visible ? controller.chartFields[1].rangeMin : 0
max: visible ? controller.chartFields[1].rangeMax : 0 max: visible ? controller.chartFields[1].rangeMax : 0
visible: controller.chartFieldCount > 1 visible: controller.chartFieldCount > 1
} }
DateTimeAxis { DateTimeAxis {
id: axisX id: axisX
min: visible ? controller.rangeXMin : new Date() min: visible ? controller.rangeXMin : new Date()
max: visible ? controller.rangeXMax : new Date() max: visible ? controller.rangeXMax : new Date()
format: "hh:mm:ss.zzz" visible: controller.chartFieldCount > 0
tickCount: 6
visible: controller.chartFieldCount > 0
} }
LineSeries { LineSeries {
id: lineSeries1 id: lineSeries1
name: controller.chartFieldCount ? controller.chartFields[0].name : "" name: controller.chartFieldCount ? controller.chartFields[0].label : ""
axisX: axisX axisX: axisX
axisY: axisY1 axisY: axisY1
useOpenGL: true color: qgcPal.colorRed
useOpenGL: true
} }
LineSeries { LineSeries {
id: lineSeries2 id: lineSeries2
name: controller.chartFieldCount > 1 ? controller.chartFields[1].name : "" name: controller.chartFieldCount > 1 ? controller.chartFields[1].label : ""
axisX: axisX axisX: axisX
axisYRight: axisY2 axisYRight: axisY2
useOpenGL: true color: qgcPal.colorGreen
useOpenGL: true
} }
} }
......
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