From 9d1168226c0296d8f8646a2937e48cd2b0c6e325 Mon Sep 17 00:00:00 2001 From: banigreyling Date: Wed, 1 Sep 2010 21:29:24 +0000 Subject: [PATCH] OP-42 GCS/Scope: Added UAVField units to curve legend git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1500 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/plugins/scope/scopegadgetwidget.cpp | 30 +++++++++++-------- ground/src/plugins/scope/scopegadgetwidget.h | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ground/src/plugins/scope/scopegadgetwidget.cpp b/ground/src/plugins/scope/scopegadgetwidget.cpp index 20e27fda8..2ca06f06f 100644 --- a/ground/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/src/plugins/scope/scopegadgetwidget.cpp @@ -50,8 +50,8 @@ TestDataGen* ScopeGadgetWidget::testDataGen; ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent) { - // if(testDataGen == 0) - // testDataGen = new TestDataGen(); + //if(testDataGen == 0) + // testDataGen = new TestDataGen(); //Setup the timer that replots data replotTimer = new QTimer(this); @@ -142,14 +142,14 @@ void ScopeGadgetWidget::setupChronoPlot() scaleWidget->setMinBorderDist(0, fmh / 2); } -void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int scaleOrderFactor, QPen pen) +void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor, QPen pen) { PlotData* plotData; if (m_plotType == SequencialPlot) - plotData = new SequencialPlotData(uavObject, uavField); + plotData = new SequencialPlotData(uavObject, uavFieldSubField); else if (m_plotType == ChronoPlot) - plotData = new ChronoPlotData(uavObject, uavField); + plotData = new ChronoPlotData(uavObject, uavFieldSubField); //else if (m_plotType == UAVObjectPlot) // plotData = new UAVObjectPlotData(uavObject, uavField); @@ -165,11 +165,22 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int sc if(plotData->haveSubField) curveName = curveName.append("." + plotData->uavSubField); + //Get the uav object + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + UAVDataObject* obj = dynamic_cast(objManager->getObject((plotData->uavObject))); + + UAVObjectField* field = obj->getField(plotData->uavField); + QString units = field->getUnits(); + + if(units == 0) + units = QString(); + QString curveNameScaled; if(scaleOrderFactor == 0) - curveNameScaled = curveName; + curveNameScaled = curveName + "(" + units + ")"; else - curveNameScaled = curveName + "(E" + QString::number(scaleOrderFactor) + ")"; + curveNameScaled = curveName + "(x10^" + QString::number(scaleOrderFactor) + " " + units + ")"; QwtPlotCurve* plotCurve = new QwtPlotCurve(curveNameScaled); plotCurve->setPen(pen); @@ -180,11 +191,6 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int sc //Keep the curve details for later m_curvesData.insert(curveNameScaled, plotData); - //Get the object to monitor - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - UAVDataObject* obj = dynamic_cast(objManager->getObject((plotData->uavObject))); - //Link to the signal of new data only if this UAVObject has not been to connected yet if (!m_connectedUAVObjects.contains(obj->getName())) { m_connectedUAVObjects.append(obj->getName()); diff --git a/ground/src/plugins/scope/scopegadgetwidget.h b/ground/src/plugins/scope/scopegadgetwidget.h index 0713a9487..7bddb1aab 100644 --- a/ground/src/plugins/scope/scopegadgetwidget.h +++ b/ground/src/plugins/scope/scopegadgetwidget.h @@ -113,7 +113,7 @@ public: int refreshInterval(){return m_refreshInterval;} - void addCurvePlot(QString uavObject, QString uavField, int scaleOrderFactor = 0, QPen pen = QPen(Qt::black)); + void addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor = 0, QPen pen = QPen(Qt::black)); //void removeCurvePlot(QString uavObject, QString uavField); void clearCurvePlots();