From 8a11c588a6bf81d669d9b3533b94e47b398db696 Mon Sep 17 00:00:00 2001 From: m_thread Date: Sat, 15 Nov 2014 11:04:19 +0100 Subject: [PATCH] OP-1611 Addressed some review comments and changed logic around plots wanting initial data. --- ground/openpilotgcs/src/plugins/scope/plotdata.cpp | 8 ++++++++ ground/openpilotgcs/src/plugins/scope/scopegadget.cpp | 2 +- .../src/plugins/scope/scopegadgetwidget.cpp | 11 ++++++----- .../src/plugins/scope/scopegadgetwidget.h | 2 -- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp index b930e3cbd..b20cf4f1f 100644 --- a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp +++ b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp @@ -201,6 +201,10 @@ QwtPlotMarker *PlotData::createMarker(QString value) bool SequentialPlotData::append(UAVObject *obj) { + if (obj == NULL) { + obj = m_object; + } + if (m_object == obj && m_field) { if (!m_isEnumPlot) { double currentValue = m_field->getValue(m_element).toDouble() * pow(10, m_scalePower); @@ -241,6 +245,10 @@ bool SequentialPlotData::append(UAVObject *obj) bool ChronoPlotData::append(UAVObject *obj) { + if (obj == NULL) { + obj = m_object; + } + if (m_object == obj && m_field) { // Get the field of interest // THINK ABOUT REIMPLEMENTING THIS TO SHOW UAVO TIME, NOT SYSTEM TIME diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp index e5b36d170..5531897d1 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp @@ -47,7 +47,7 @@ void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration *config) ScopeGadgetConfiguration *sgConfig = qobject_cast(config); ScopeGadgetWidget *widget = qobject_cast(m_widget); - widget->setName(config->name()); + widget->setObjectName(config->name()); widget->setPlotDataSize(sgConfig->dataSize()); widget->setRefreshInterval(sgConfig->refreshInterval()); diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index 0f5f00d69..94344ab7e 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -195,6 +195,11 @@ void ScopeGadgetWidget::showEvent(QShowEvent *e) void ScopeGadgetWidget::startPlotting() { if (replotTimer && !replotTimer->isActive()) { + foreach (PlotData *plot, m_curvesData.values()) { + if (plot->wantsInitialData()) { + plot->append(NULL); + } + } replotTimer->start(m_refreshInterval); } } @@ -378,10 +383,6 @@ void ScopeGadgetWidget::addCurvePlot(QString objectName, QString fieldPlusSubFie connect(this, SIGNAL(visibilityChanged(QwtPlotItem *)), plotData, SLOT(visibilityChanged(QwtPlotItem *))); plotData->attach(this); - if (plotData->wantsInitialData()) { - plotData->append(object); - } - // Keep the curve details for later m_curvesData.insert(plotData->plotName(), plotData); @@ -671,5 +672,5 @@ void ScopeGadgetWidget::copyToClipboardAsImage() void ScopeGadgetWidget::showOptionDialog() { - Core::ICore::instance()->showOptionsDialog("ScopeGadget", m_name); + Core::ICore::instance()->showOptionsDialog("ScopeGadget", objectName()); } diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h index 1b8302055..07795db7c 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h @@ -69,7 +69,6 @@ public: ScopeGadgetWidget(QWidget *parent = 0); ~ScopeGadgetWidget(); - void setName (QString name) { m_name = name; } void setupSequentialPlot(); void setupChronoPlot(); void setupUAVObjectPlot(); @@ -148,7 +147,6 @@ private: void preparePlot(PlotType plotType); void setupExamplePlot(); - QString m_name; PlotType m_plotType; double m_plotDataSize;