1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-1617 Added PlotPicker to get readings in numbers out of scope graphs.

This commit is contained in:
m_thread 2014-12-31 01:39:30 +01:00 committed by Alessio Morale
parent 28c257292f
commit 4f1ae4c25d
2 changed files with 19 additions and 2 deletions

View File

@ -55,6 +55,7 @@
#include <QApplication>
#include <qwt/src/qwt_legend_label.h>
#include <qwt/src/qwt_picker_machine.h>
#include <qwt/src/qwt_plot_canvas.h>
#include <qwt/src/qwt_plot_layout.h>
@ -66,7 +67,7 @@ ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent),
m_csvLoggingNewFileOnConnect(false),
m_csvLoggingStartTime(QDateTime::currentDateTime()),
m_csvLoggingPath("./csvlogging/"),
m_plotLegend(NULL)
m_plotLegend(NULL), m_picker(NULL)
{
setMouseTracking(true);
@ -79,6 +80,16 @@ ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent),
axisWidget(QwtPlot::yLeft)->setMargin(2);
axisWidget(QwtPlot::xBottom)->setMargin(2);
m_picker = new QwtPlotPicker(QwtPlot::xBottom,
QwtPlot::yLeft,
QwtPlotPicker::CrossRubberBand,
QwtPicker::ActiveOnly,
canvas());
m_picker->setStateMachine(new QwtPickerDragPointMachine());
m_picker->setRubberBandPen(QColor(Qt::darkMagenta));
m_picker->setRubberBand(QwtPicker::HLineRubberBand);
m_picker->setTrackerPen(QColor(Qt::green));
// Setup the timer that replots data
replotTimer = new QTimer(this);
connect(replotTimer, SIGNAL(timeout()), this, SLOT(replotNewData()));
@ -100,6 +111,11 @@ ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent),
ScopeGadgetWidget::~ScopeGadgetWidget()
{
if (m_picker) {
delete m_picker;
m_picker = NULL;
}
if (replotTimer) {
replotTimer->stop();
delete replotTimer;

View File

@ -36,6 +36,7 @@
#include "qwt/src/qwt_plot_curve.h"
#include "qwt/src/qwt_scale_draw.h"
#include "qwt/src/qwt_scale_widget.h"
#include "qwt/src/qwt_plot_picker.h"
#include <QTimer>
#include <QTime>
@ -143,7 +144,6 @@ private slots:
void showOptionDialog();
private:
void preparePlot(PlotType plotType);
void setupExamplePlot();
@ -175,6 +175,7 @@ private:
QMutex m_mutex;
QwtLegend *m_plotLegend;
QwtPlotPicker *m_picker;
int csvLoggingInsertHeader();
int csvLoggingAddData();