diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index 8d019c8f5..887babeab 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -55,6 +55,7 @@ #include #include +#include #include #include @@ -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; diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h index 07795db7c..786cc9d22 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h @@ -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 #include @@ -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();