Commit 6c59f5f4 authored by John Tapsell's avatar John Tapsell

Add an XY plot widget

This allows you to add XY graph plots of any data.  For example,
x,y position data of a servo.
parent 00a7baae
......@@ -301,7 +301,8 @@ FORMS += src/ui/MainWindow.ui \
src/ui/configuration/ApmFirmwareConfig.ui \
src/ui/px4_configuration/QGCPX4AirframeConfig.ui \
src/ui/px4_configuration/QGCPX4MulticopterConfig.ui \
src/ui/px4_configuration/QGCPX4SensorCalibration.ui
src/ui/px4_configuration/QGCPX4SensorCalibration.ui \
src/ui/designer/QGCXYPlot.ui
INCLUDEPATH += src \
src/ui \
......@@ -506,6 +507,7 @@ HEADERS += src/MG.h \
src/ui/QGCBaseParamWidget.h \
src/ui/px4_configuration/QGCPX4MulticopterConfig.h \
src/ui/px4_configuration/QGCPX4SensorCalibration.h \
src/ui/designer/QGCXYPlot.h \
src/ui/menuactionhelper.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
......@@ -728,6 +730,7 @@ SOURCES += src/main.cc \
src/ui/QGCBaseParamWidget.cc \
src/ui/px4_configuration/QGCPX4MulticopterConfig.cc \
src/ui/px4_configuration/QGCPX4SensorCalibration.cc \
src/ui/designer/QGCXYPlot.cc \
src/ui/menuactionhelper.cpp
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
......
......@@ -480,6 +480,8 @@ void MainWindow::buildCommonWidgets()
{
// Add generic MAVLink decoder
mavlinkDecoder = new MAVLinkDecoder(mavlink, this);
connect(mavlinkDecoder, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)),
this, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)));
// Log player
logPlayer = new QGCMAVLinkLogPlayer(mavlink, customStatusBar);
......@@ -1641,6 +1643,7 @@ void MainWindow::UASCreated(UASInterface* uas)
connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(UASSpecsChanged(int)));
connect(uas, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)), this, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)));
// HIL
showHILConfigurationWidget(uas);
......
......@@ -301,6 +301,9 @@ protected slots:
signals:
void styleChanged(MainWindow::QGC_MAINWINDOW_STYLE newTheme);
void initStatusChanged(const QString& message, int alignment, const QColor &color);
/** Emitted when any value changes from any source */
void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec);
#ifdef MOUSE_ENABLED_LINUX
/** @brief Forward X11Event to catch 3DMouse inputs */
void x11EventOccured(XEvent *event);
......
......@@ -13,6 +13,7 @@
#include "QGCParamSlider.h"
#include "QGCComboBox.h"
#include "QGCTextLabel.h"
#include "QGCXYPlot.h"
#include "QGCCommandButton.h"
#include "UASManager.h"
......@@ -272,6 +273,11 @@ void QGCToolWidget::loadSettings(QVariantMap& settings)
item = new QGCComboBox(this);
//qDebug() << "CREATED COMBOBOX";
}
else if (type == "XYPLOT")
{
item = new QGCXYPlot(this);
//qDebug() << "CREATED XYPlot";
}
if (item)
{
// Configure and add to layout
......@@ -330,6 +336,11 @@ void QGCToolWidget::loadSettings(QSettings& settings)
item->setObjectName(settings.value("QGC_TEXT_ID").toString());
item->setActiveUAS(mav);
}
else if (type == "XYPLOT")
{
item = new QGCXYPlot(this);
item->setActiveUAS(mav);
}
if (item)
{
......@@ -428,6 +439,7 @@ void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
menu.addAction(addParamAction);
menu.addAction(addCommandAction);
menu.addAction(addLabelAction);
menu.addAction(addPlotAction);
menu.addSeparator();
menu.addAction(setTitleAction);
menu.addAction(exportAction);
......@@ -467,6 +479,10 @@ void QGCToolWidget::createActions()
addLabelAction->setStatusTip(tr("Add a new label to the tool"));
connect(addLabelAction, SIGNAL(triggered()), this, SLOT(addLabel()));
addPlotAction = new QAction(tr("New &XY Plot"), this);
addPlotAction->setStatusTip(tr("Add a XY Plot to the tool"));
connect(addPlotAction, SIGNAL(triggered()), this, SLOT(addPlot()));
setTitleAction = new QAction(tr("Set Widget Title"), this);
setTitleAction->setStatusTip(tr("Set the title caption of this tool widget"));
connect(setTitleAction, SIGNAL(triggered()), this, SLOT(setTitle()));
......@@ -515,6 +531,11 @@ void QGCToolWidget::addLabel()
addToolWidgetAndEdit(new QGCTextLabel(this));
}
void QGCToolWidget::addPlot()
{
addToolWidgetAndEdit(new QGCXYPlot(this));
}
void QGCToolWidget::addToolWidgetAndEdit(QGCToolWidgetItem* widget)
{
addToolWidget(widget);
......
......@@ -74,6 +74,7 @@ protected:
QVariantMap settingsMap;
QAction* addParamAction;
QAction* addCommandAction;
QAction* addPlotAction;
QAction* addLabelAction;
QAction* setTitleAction;
QAction* deleteAction;
......@@ -100,6 +101,7 @@ public slots:
protected slots:
void addParam();
void addCommand();
void addPlot();
void addLabel();
void setTitle();
void widgetRemoved();
......
This diff is collapsed.
#ifndef QGCXYPLOT_H
#define QGCXYPLOT_H
#include "QGCToolWidgetItem.h"
#include "MainWindow.h"
namespace Ui
{
class QGCXYPlot;
}
class UASInterface;
class QwtPlot;
class XYPlotCurve;
class QGCXYPlot : public QGCToolWidgetItem
{
Q_OBJECT
public:
explicit QGCXYPlot(QWidget *parent = 0);
~QGCXYPlot();
virtual void setEditMode(bool editMode);
public slots:
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
void readSettings(const QString& pre,const QVariantMap& settings);
void appendData(int uasId, const QString& curve, const QString& unit, const QVariant& variant, quint64 usec);
void clearPlot();
void styleChanged(MainWindow::QGC_MAINWINDOW_STYLE style);
void updateMinMaxSettings();
private:
Ui::QGCXYPlot *ui;
QwtPlot *plot;
XYPlotCurve* xycurve;
int maxElementsToDraw;
double x; /**< Last unused value for the x-coordinate */
quint64 x_timestamp_us; /**< Timestamp that we last recieved a value for x */
bool x_valid; /**< Whether we have recieved an x value but so far no corresponding y value */
double y; /**< Last unused value for the x-coordinate */
quint64 y_timestamp_us; /**< Timestamp that we last recieved a value for x */
bool y_valid; /**< Whether we have recieved an x value but so far no corresponding y value */
int max_timestamp_diff_us; /**< Only combine x and y to a data point if the timestamp for both doesn't differ by more than this */
};
#endif // QGCXYPLOT_H
This diff is collapsed.
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