1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

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
This commit is contained in:
banigreyling 2010-09-01 21:29:24 +00:00 committed by banigreyling
parent 66e009a861
commit 9d1168226c
2 changed files with 19 additions and 13 deletions

View File

@ -50,8 +50,8 @@ TestDataGen* ScopeGadgetWidget::testDataGen;
ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent) ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
{ {
// if(testDataGen == 0) //if(testDataGen == 0)
// testDataGen = new TestDataGen(); // testDataGen = new TestDataGen();
//Setup the timer that replots data //Setup the timer that replots data
replotTimer = new QTimer(this); replotTimer = new QTimer(this);
@ -142,14 +142,14 @@ void ScopeGadgetWidget::setupChronoPlot()
scaleWidget->setMinBorderDist(0, fmh / 2); 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; PlotData* plotData;
if (m_plotType == SequencialPlot) if (m_plotType == SequencialPlot)
plotData = new SequencialPlotData(uavObject, uavField); plotData = new SequencialPlotData(uavObject, uavFieldSubField);
else if (m_plotType == ChronoPlot) else if (m_plotType == ChronoPlot)
plotData = new ChronoPlotData(uavObject, uavField); plotData = new ChronoPlotData(uavObject, uavFieldSubField);
//else if (m_plotType == UAVObjectPlot) //else if (m_plotType == UAVObjectPlot)
// plotData = new UAVObjectPlotData(uavObject, uavField); // plotData = new UAVObjectPlotData(uavObject, uavField);
@ -165,11 +165,22 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int sc
if(plotData->haveSubField) if(plotData->haveSubField)
curveName = curveName.append("." + plotData->uavSubField); curveName = curveName.append("." + plotData->uavSubField);
//Get the uav object
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject((plotData->uavObject)));
UAVObjectField* field = obj->getField(plotData->uavField);
QString units = field->getUnits();
if(units == 0)
units = QString();
QString curveNameScaled; QString curveNameScaled;
if(scaleOrderFactor == 0) if(scaleOrderFactor == 0)
curveNameScaled = curveName; curveNameScaled = curveName + "(" + units + ")";
else else
curveNameScaled = curveName + "(E" + QString::number(scaleOrderFactor) + ")"; curveNameScaled = curveName + "(x10^" + QString::number(scaleOrderFactor) + " " + units + ")";
QwtPlotCurve* plotCurve = new QwtPlotCurve(curveNameScaled); QwtPlotCurve* plotCurve = new QwtPlotCurve(curveNameScaled);
plotCurve->setPen(pen); plotCurve->setPen(pen);
@ -180,11 +191,6 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int sc
//Keep the curve details for later //Keep the curve details for later
m_curvesData.insert(curveNameScaled, plotData); m_curvesData.insert(curveNameScaled, plotData);
//Get the object to monitor
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject((plotData->uavObject)));
//Link to the signal of new data only if this UAVObject has not been to connected yet //Link to the signal of new data only if this UAVObject has not been to connected yet
if (!m_connectedUAVObjects.contains(obj->getName())) { if (!m_connectedUAVObjects.contains(obj->getName())) {
m_connectedUAVObjects.append(obj->getName()); m_connectedUAVObjects.append(obj->getName());

View File

@ -113,7 +113,7 @@ public:
int refreshInterval(){return m_refreshInterval;} 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 removeCurvePlot(QString uavObject, QString uavField);
void clearCurvePlots(); void clearCurvePlots();