From cae53915d3d00ae57cbf042cf6a5430d6bad53ea Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 00:34:29 +0300 Subject: [PATCH 1/8] Fixed small typo: "sequencial" vs. "sequential" --- ground/openpilotgcs/src/plugins/scope/plotdata.cpp | 2 +- ground/openpilotgcs/src/plugins/scope/plotdata.h | 12 ++++++------ .../openpilotgcs/src/plugins/scope/scopegadget.cpp | 4 ++-- .../src/plugins/scope/scopegadgetoptionspage.cpp | 2 +- .../src/plugins/scope/scopegadgetwidget.cpp | 10 +++++----- .../src/plugins/scope/scopegadgetwidget.h | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp index e05bf7a1b..f3c9a0567 100644 --- a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp +++ b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp @@ -87,7 +87,7 @@ PlotData::~PlotData() } -bool SequencialPlotData::append(UAVObject* obj) +bool SequentialPlotData::append(UAVObject* obj) { if (uavObject == obj->getName()) { diff --git a/ground/openpilotgcs/src/plugins/scope/plotdata.h b/ground/openpilotgcs/src/plugins/scope/plotdata.h index 76112baf1..846ff1329 100644 --- a/ground/openpilotgcs/src/plugins/scope/plotdata.h +++ b/ground/openpilotgcs/src/plugins/scope/plotdata.h @@ -44,7 +44,7 @@ \brief Defines the different type of plots. */ enum PlotType { - SequencialPlot, + SequentialPlot, ChronoPlot, UAVObjectPlot, @@ -93,16 +93,16 @@ signals: }; /*! - \brief The sequencial plot have a fixed size buffer of data. All the curves in one plot + \brief The sequential plot have a fixed size buffer of data. All the curves in one plot have the same size buffer. */ -class SequencialPlotData : public PlotData +class SequentialPlotData : public PlotData { Q_OBJECT public: - SequencialPlotData(QString uavObject, QString uavField) + SequentialPlotData(QString uavObject, QString uavField) : PlotData(uavObject, uavField) {} - ~SequencialPlotData() {} + ~SequentialPlotData() {} /*! \brief Append new data to the plot @@ -113,7 +113,7 @@ public: \brief The type of plot */ virtual PlotType plotType() { - return SequencialPlot; + return SequentialPlot; } /*! diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp index b4b1f24fa..35ebd7229 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp @@ -49,8 +49,8 @@ void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration* config) widget->setXWindowSize(sgConfig->dataSize()); widget->setRefreshInterval(sgConfig->refreshInterval()); - if(sgConfig->plotType() == SequencialPlot ) - widget->setupSequencialPlot(); + if(sgConfig->plotType() == SequentialPlot ) + widget->setupSequentialPlot(); else if(sgConfig->plotType() == ChronoPlot) widget->setupChronoPlot(); // else if(sgConfig->plotType() == UAVObjectPlot) diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp index 8489811a5..ec17108ba 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp @@ -53,7 +53,7 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) //main layout options_page->setupUi(optionsPageWidget); - options_page->cmbPlotType->addItem("Sequencial Plot",""); + options_page->cmbPlotType->addItem("Sequential Plot",""); options_page->cmbPlotType->addItem("Chronological Plot",""); // Fills the combo boxes for the UAVObjects diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index 0631e398e..011cdb394 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -269,9 +269,9 @@ void ScopeGadgetWidget::showCurve(QwtPlotItem *item, bool on) mutex.unlock(); } -void ScopeGadgetWidget::setupSequencialPlot() +void ScopeGadgetWidget::setupSequentialPlot() { - preparePlot(SequencialPlot); + preparePlot(SequentialPlot); // QwtText title("Index"); //// title.setFont(QFont("Helvetica", 20)); @@ -356,8 +356,8 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField { PlotData* plotData; - if (m_plotType == SequencialPlot) - plotData = new SequencialPlotData(uavObject, uavFieldSubField); + if (m_plotType == SequentialPlot) + plotData = new SequentialPlotData(uavObject, uavFieldSubField); else if (m_plotType == ChronoPlot) plotData = new ChronoPlotData(uavObject, uavFieldSubField); //else if (m_plotType == UAVObjectPlot) @@ -471,7 +471,7 @@ void ScopeGadgetWidget::replotNewData() void ScopeGadgetWidget::setupExamplePlot() { - preparePlot(SequencialPlot); + preparePlot(SequentialPlot); // Show the axes diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h index 4dd3f42ee..b4e6ce113 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h @@ -70,7 +70,7 @@ public: ScopeGadgetWidget(QWidget *parent = 0); ~ScopeGadgetWidget(); - void setupSequencialPlot(); + void setupSequentialPlot(); void setupChronoPlot(); void setupUAVObjectPlot(); PlotType plotType(){return m_plotType;} From 3a1b15a65b708118478f39c9dda98c7578882a83 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 00:40:01 +0300 Subject: [PATCH 2/8] Reworked scale plot entry to have a more descriptive name and function. --- .../plugins/scope/scopegadgetoptionspage.cpp | 32 +++++++++---------- .../plugins/scope/scopegadgetoptionspage.ui | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp index ec17108ba..b9ed9191e 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp @@ -72,22 +72,22 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) if(options_page->cmbUAVObjects->currentIndex() >= 0) on_cmbUAVObjects_currentIndexChanged(options_page->cmbUAVObjects->currentText()); - options_page->cmbScale->addItem("E-9", -9); - options_page->cmbScale->addItem("E-6", -6); - options_page->cmbScale->addItem("E-5",-5); - options_page->cmbScale->addItem("E-4",-4); - options_page->cmbScale->addItem("E-3",-3); - options_page->cmbScale->addItem("E-2",-2); - options_page->cmbScale->addItem("E-1",-1); - options_page->cmbScale->addItem("E0",0); - options_page->cmbScale->addItem("E1",1); - options_page->cmbScale->addItem("E2",2); - options_page->cmbScale->addItem("E3",3); - options_page->cmbScale->addItem("E4",4); - options_page->cmbScale->addItem("E5",5); - options_page->cmbScale->addItem("E6",6); - options_page->cmbScale->addItem("E9",9); - options_page->cmbScale->addItem("E12",12); + options_page->cmbScale->addItem("10^-9", -9); + options_page->cmbScale->addItem("10^-6", -6); + options_page->cmbScale->addItem("10^-5",-5); + options_page->cmbScale->addItem("10^-4",-4); + options_page->cmbScale->addItem("10^-3",-3); + options_page->cmbScale->addItem("10^-2",-2); + options_page->cmbScale->addItem("10^-1",-1); + options_page->cmbScale->addItem("1",0); + options_page->cmbScale->addItem("10^1",1); + options_page->cmbScale->addItem("10^2",2); + options_page->cmbScale->addItem("10^3",3); + options_page->cmbScale->addItem("10^4",4); + options_page->cmbScale->addItem("10^5",5); + options_page->cmbScale->addItem("10^6",6); + options_page->cmbScale->addItem("10^9",9); + options_page->cmbScale->addItem("10^12",12); options_page->cmbScale->setCurrentIndex(7); //Set widget values from settings diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui index 320c3d314..64a331917 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui @@ -202,7 +202,7 @@ - Scale: + Y-axis scale factor: From f4376b344555489936d062af06a75568d9ae7e24 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 01:20:23 +0300 Subject: [PATCH 3/8] Corrected small typo: disbleMouseWheelEvents vs. disableMouseWheelEvents --- .../src/plugins/config/configcamerastabilizationwidget.cpp | 2 +- ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp | 2 +- .../openpilotgcs/src/plugins/config/configvehicletypewidget.cpp | 2 +- ground/openpilotgcs/src/plugins/config/inputchannelform.cpp | 2 +- ground/openpilotgcs/src/plugins/config/outputchannelform.cpp | 2 +- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 2 +- .../src/plugins/uavobjectwidgetutils/configtaskwidget.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 86ac30080..3e757de63 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -90,7 +90,7 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent connect(m_camerastabilization->camerastabilizationSaveSD, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(m_camerastabilization->camerastabilizationHelp, SIGNAL(clicked()), this, SLOT(openHelp())); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } ConfigCameraStabilizationWidget::~ConfigCameraStabilizationWidget() diff --git a/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp index 1d65eaf1c..30c87bd78 100644 --- a/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp @@ -68,7 +68,7 @@ ConfigTxPIDWidget::ConfigTxPIDWidget(QWidget *parent) : ConfigTaskWidget(parent) populateWidgets(); refreshWidgetsValues(); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } ConfigTxPIDWidget::~ConfigTxPIDWidget() diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index cc7b580b9..21d47a77a 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -233,7 +233,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi setupGroundVehicleUI( m_aircraft->groundVehicleType->currentText() ); setupFixedWingUI( m_aircraft->fixedWingType->currentText() ); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp index dbab48cac..212621d44 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp @@ -37,7 +37,7 @@ inputChannelForm::inputChannelForm(QWidget *parent,bool showlegend) : connect(ui->channelNumberDropdown,SIGNAL(currentIndexChanged(int)),this,SLOT(channelDropdownUpdated(int))); connect(ui->channelNumber,SIGNAL(valueChanged(int)),this,SLOT(channelNumberUpdated(int))); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } diff --git a/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp index 530244777..f2d039edb 100644 --- a/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp @@ -71,7 +71,7 @@ OutputChannelForm::OutputChannelForm(const int index, QWidget *parent, const boo connect(ui.actuatorLink, SIGNAL(toggled(bool)), this, SLOT(linkToggled(bool))); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } OutputChannelForm::~OutputChannelForm() diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 8bd2fe7b5..21d196be8 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -1158,7 +1158,7 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget * widget,UAVObjectField * field, } } -void ConfigTaskWidget::disbleMouseWheelEvents() +void ConfigTaskWidget::disableMouseWheelEvents() { //Disable mouse wheel events foreach( QSpinBox * sp, findChildren() ) { diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index f835a417d..1b5e0ca17 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -86,7 +86,7 @@ public: ConfigTaskWidget(QWidget *parent = 0); ~ConfigTaskWidget(); - void disbleMouseWheelEvents(); + void disableMouseWheelEvents(); bool eventFilter( QObject * obj, QEvent * evt ); void saveObjectToSD(UAVObject *obj); From ce139a12cc10f50daba7cc1c48c36ae2d0819398 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 01:22:47 +0300 Subject: [PATCH 4/8] Missed a final typo. --- .../src/plugins/config/configstabilizationwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index 7306475a4..3f2b4d216 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -53,7 +53,7 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa connect(this,SIGNAL(widgetContentsChanged(QWidget*)),this,SLOT(processLinkedWidgets(QWidget*))); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } From aeca5c6741d6e38b9288afc9e4c47b671540a9b4 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 05:21:11 +0300 Subject: [PATCH 5/8] Added Math Functions to the scope. Currently only support standard deviation. --- .../src/plugins/scope/plotdata.cpp | 118 ++++++++++++------ .../openpilotgcs/src/plugins/scope/plotdata.h | 5 +- .../src/plugins/scope/scopegadget.cpp | 6 +- .../scope/scopegadgetconfiguration.cpp | 78 +++++++----- .../plugins/scope/scopegadgetconfiguration.h | 8 +- .../plugins/scope/scopegadgetoptionspage.cpp | 47 ++++--- .../plugins/scope/scopegadgetoptionspage.h | 4 +- .../plugins/scope/scopegadgetoptionspage.ui | 30 +++-- .../src/plugins/scope/scopegadgetwidget.cpp | 5 +- .../src/plugins/scope/scopegadgetwidget.h | 2 +- 10 files changed, 195 insertions(+), 108 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp index f3c9a0567..da01fb48a 100644 --- a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp +++ b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp @@ -53,8 +53,9 @@ PlotData::PlotData(QString p_uavObject, QString p_uavField) curve = 0; scalePower = 0; - interpolationSamples = 1; - interpolationSum = 0.0f; + meanSamples = 1; + meanSum = 0.0f; +// mathFunction=0; correctionSum = 0.0f; correctionCount = 0; yMinimum = 0; @@ -96,28 +97,50 @@ bool SequentialPlotData::append(UAVObject* obj) if (field) { - //Shift data forward and put the new value at the front - - // calculate interpolated (smoothed) value double currentValue = valueAsDouble(obj, field) * pow(10, scalePower); - yDataHistory->append( currentValue ); - interpolationSum += currentValue; - if(yDataHistory->size() > interpolationSamples) { - interpolationSum -= yDataHistory->first(); - yDataHistory->pop_front(); + + //Compute boxcar average + if (meanSamples > 1){ + //Put the new value at the front + yDataHistory->append( currentValue ); + + // calculate average value + meanSum += currentValue; + if(yDataHistory->size() > meanSamples) { + meanSum -= yDataHistory->first(); + yDataHistory->pop_front(); + } + + // make sure to correct the sum every meanSamples steps to prevent it + // from running away due to floating point rounding errors + correctionSum+=currentValue; + if (++correctionCount >= meanSamples) { + meanSum = correctionSum; + correctionSum = 0.0f; + correctionCount = 0; + } + + double boxcarAvg=meanSum/yDataHistory->size(); + + if ( mathFunction == "Standard deviation" ){ + //Calculate square of sample standard deviation, with Bessel's correction + double stdSum=0; + for (int i=0; i < yDataHistory->size(); i++){ + stdSum+= pow(yDataHistory->at(i)- boxcarAvg,2)/(meanSamples-1); + } + yData->append(sqrt(stdSum)); + } + else { + yData->append(boxcarAvg); + } } - // make sure to correct the sum every interpolationSamples steps to prevent it - // from running away due to flouting point rounding errors - correctionSum += currentValue; - if (++correctionCount >= interpolationSamples) { - interpolationSum = correctionSum; - correctionSum = 0.0f; - correctionCount = 0; + else{ + yData->append( currentValue ); } - yData->append(interpolationSum/yDataHistory->size()); - if (yData->size() > m_xWindowSize) { + + if (yData->size() > m_xWindowSize) { //If new data overflows the window, remove old data... yData->pop_front(); - } else + } else //...otherwise, add a new y point at position xData xData->insert(xData->size(), xData->size()); //notify the gui of changes in the data @@ -137,30 +160,49 @@ bool ChronoPlotData::append(UAVObject* obj) //qDebug() << "uavObject: " << uavObject << ", uavField: " << uavField; if (field) { - //Put the new value at the front - QDateTime NOW = QDateTime::currentDateTime(); - - // calculate interpolated (smoothed) value + QDateTime NOW = QDateTime::currentDateTime(); //THINK ABOUT REIMPLEMENTING THIS TO SHOW UAVO TIME, NOT SYSTEM TIME double currentValue = valueAsDouble(obj, field) * pow(10, scalePower); - yDataHistory->append( currentValue ); - interpolationSum += currentValue; - if(yDataHistory->size() > interpolationSamples) { - interpolationSum -= yDataHistory->first(); - yDataHistory->pop_front(); + + //Compute boxcar average + if (meanSamples > 1){ + //Put the new value at the front + yDataHistory->append( currentValue ); + + // calculate average value + meanSum += currentValue; + if(yDataHistory->size() > meanSamples) { + meanSum -= yDataHistory->first(); + yDataHistory->pop_front(); + } + // make sure to correct the sum every meanSamples steps to prevent it + // from running away due to floating point rounding errors + correctionSum+=currentValue; + if (++correctionCount >= meanSamples) { + meanSum = correctionSum; + correctionSum = 0.0f; + correctionCount = 0; + } + + double boxcarAvg=meanSum/yDataHistory->size(); +//qDebug()<size(); i++){ + stdSum+= pow(yDataHistory->at(i)- boxcarAvg,2)/(meanSamples-1); + } + yData->append(sqrt(stdSum)); + } + else { + yData->append(boxcarAvg); + } } - // make sure to correct the sum every interpolationSamples steps to prevent it - // from running away due to flouting point rounding errors - correctionSum += currentValue; - if (++correctionCount >= interpolationSamples) { - interpolationSum = correctionSum; - correctionSum = 0.0f; - correctionCount = 0; + else{ + yData->append( currentValue ); } double valueX = NOW.toTime_t() + NOW.time().msec() / 1000.0; - double valueY = interpolationSum/yDataHistory->size(); xData->append(valueX); - yData->append(valueY); //qDebug() << "Data " << uavObject << "." << field->getName() << " X,Y:" << valueX << "," << valueY; diff --git a/ground/openpilotgcs/src/plugins/scope/plotdata.h b/ground/openpilotgcs/src/plugins/scope/plotdata.h index 846ff1329..204f1a7bd 100644 --- a/ground/openpilotgcs/src/plugins/scope/plotdata.h +++ b/ground/openpilotgcs/src/plugins/scope/plotdata.h @@ -67,8 +67,9 @@ public: QString uavSubField; bool haveSubField; int scalePower; //This is the power to which each value must be raised - int interpolationSamples; - double interpolationSum; + int meanSamples; + double meanSum; + QString mathFunction; double correctionSum; int correctionCount; double yMinimum; diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp index 35ebd7229..d9b33b185 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadget.cpp @@ -61,14 +61,16 @@ void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration* config) QString uavObject = plotCurveConfig->uavObject; QString uavField = plotCurveConfig->uavField; int scale = plotCurveConfig->yScalePower; - int interpolation = plotCurveConfig->yInterpolationSamples; + int mean = plotCurveConfig->yMeanSamples; + QString mathFunction = plotCurveConfig->mathFunction; QRgb color = plotCurveConfig->color; widget->addCurvePlot( uavObject, uavField, scale, - interpolation, + mean, + mathFunction, QPen( QBrush(QColor(color),Qt::SolidPattern), // (qreal)2, (qreal)1, diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.cpp index 3228497f3..0178b385b 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.cpp @@ -31,7 +31,8 @@ ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings* q IUAVGadgetConfiguration(classId, parent), m_plotType((int)ChronoPlot), m_dataSize(60), - m_refreshInterval(1000) + m_refreshInterval(1000), + m_mathFunctionType(0) { uint currentStreamVersion = 0; int plotCurveCount = 0; @@ -65,8 +66,11 @@ ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings* q color = qSettings->value("color").value(); plotCurveConf->color = color; plotCurveConf->yScalePower = qSettings->value("yScalePower").toInt(); - plotCurveConf->yInterpolationSamples = qSettings->value("yInterpolationSamples").toInt(); - if (!plotCurveConf->yInterpolationSamples) plotCurveConf->yInterpolationSamples = 1; // fallback for backward compatibility with earlier versions + plotCurveConf->mathFunction = qSettings->value("mathFunction").toString(); + plotCurveConf->yMeanSamples = qSettings->value("yMeanSamples").toInt(); + + if (!plotCurveConf->yMeanSamples) plotCurveConf->yMeanSamples = 1; // fallback for backward compatibility with earlier versions //IS THIS STILL NECESSARY? + plotCurveConf->yMinimum = qSettings->value("yMinimum").toDouble(); plotCurveConf->yMaximum = qSettings->value("yMaximum").toDouble(); @@ -105,8 +109,9 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone() int plotDatasLoadIndex = 0; ScopeGadgetConfiguration *m = new ScopeGadgetConfiguration(this->classId()); - m->setPlotType(m_plotType); + m->setPlotType( m_plotType); m->setDataSize( m_dataSize); + m->setMathFunctionType( m_mathFunctionType); m->setRefreashInterval( m_refreshInterval); plotCurveCount = m_PlotCurveConfigs.size(); @@ -120,7 +125,9 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone() newPlotCurveConf->uavField = currentPlotCurveConf->uavField; newPlotCurveConf->color = currentPlotCurveConf->color; newPlotCurveConf->yScalePower = currentPlotCurveConf->yScalePower; - newPlotCurveConf->yInterpolationSamples = currentPlotCurveConf->yInterpolationSamples; + newPlotCurveConf->yMeanSamples = currentPlotCurveConf->yMeanSamples; + newPlotCurveConf->mathFunction = currentPlotCurveConf->mathFunction; + newPlotCurveConf->yMinimum = currentPlotCurveConf->yMinimum; newPlotCurveConf->yMaximum = currentPlotCurveConf->yMaximum; @@ -136,43 +143,46 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone() return m; } -/** - * Saves a configuration. - * - */ -void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const { - int plotCurveCount = m_PlotCurveConfigs.size(); - int plotDatasLoadIndex = 0; +////THIS SEEMS TO BE UNUSED +///** +// * Saves a configuration. +// * +// */ +//void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const { - qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion); - qSettings->setValue("plotType", m_plotType); - qSettings->setValue("dataSize", m_dataSize); - qSettings->setValue("refreshInterval", m_refreshInterval); - qSettings->setValue("plotCurveCount", plotCurveCount); +// int plotCurveCount = m_PlotCurveConfigs.size(); +// int plotDatasLoadIndex = 0; - for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) - { - qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex)); +// qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion); +// qSettings->setValue("plotType", m_plotType); +// qSettings->setValue("dataSize", m_dataSize); +// qSettings->setValue("refreshInterval", m_refreshInterval); +// qSettings->setValue("plotCurveCount", plotCurveCount); - PlotCurveConfiguration* plotCurveConf = m_PlotCurveConfigs.at(plotDatasLoadIndex); - qSettings->setValue("uavObject", plotCurveConf->uavObject); - qSettings->setValue("uavField", plotCurveConf->uavField); - qSettings->setValue("color", plotCurveConf->color); - qSettings->setValue("yScalePower", plotCurveConf->yScalePower); - qSettings->setValue("yInterpolationSamples", plotCurveConf->yInterpolationSamples); - qSettings->setValue("yMinimum", plotCurveConf->yMinimum); - qSettings->setValue("yMaximum", plotCurveConf->yMaximum); +// for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) +// { +// qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex)); - qSettings->endGroup(); - } +// PlotCurveConfiguration* plotCurveConf = m_PlotCurveConfigs.at(plotDatasLoadIndex); +// qSettings->setValue("uavObject", plotCurveConf->uavObject); +// qSettings->setValue("uavField", plotCurveConf->uavField); +// qSettings->setValue("color", plotCurveConf->color); +// qSettings->setValue("mathFunction", plotCurveConf->mathFunction); +// qSettings->setValue("yScalePower", plotCurveConf->yScalePower); +// qSettings->setValue("yMeanSamples", plotCurveConf->yMeanSamples); +// qSettings->setValue("yMinimum", plotCurveConf->yMinimum); +// qSettings->setValue("yMaximum", plotCurveConf->yMaximum); - qSettings->setValue("LoggingEnabled", m_LoggingEnabled); - qSettings->setValue("LoggingNewFileOnConnect", m_LoggingNewFileOnConnect); - qSettings->setValue("LoggingPath", m_LoggingPath); +// qSettings->endGroup(); +// } + +// qSettings->setValue("LoggingEnabled", m_LoggingEnabled); +// qSettings->setValue("LoggingNewFileOnConnect", m_LoggingNewFileOnConnect); +// qSettings->setValue("LoggingPath", m_LoggingPath); -} +//} void ScopeGadgetConfiguration::replacePlotCurveConfig(QList newPlotCurveConfigs) { diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.h index 570ebe1f9..be1bf2426 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.h @@ -41,7 +41,8 @@ struct PlotCurveConfiguration QString uavField; int yScalePower; //This is the power to which each value must be raised QRgb color; - int yInterpolationSamples; + int yMeanSamples; + QString mathFunction; double yMinimum; double yMaximum; }; @@ -56,6 +57,7 @@ public: //configuration setter functions void setPlotType(int value){m_plotType = value;} + void setMathFunctionType(int value){m_mathFunctionType = value;} void setDataSize(int value){m_dataSize = value;} void setRefreashInterval(int value){m_refreshInterval = value;} void addPlotCurveConfig(PlotCurveConfiguration* value){m_PlotCurveConfigs.append(value);} @@ -64,11 +66,12 @@ public: //configurations getter functions int plotType(){return m_plotType;} + int mathFunctionType(){return m_mathFunctionType;} int dataSize(){return m_dataSize;} int refreshInterval(){return m_refreshInterval;} QList plotCurveConfigs(){return m_PlotCurveConfigs;} - void saveConfig(QSettings* settings) const; +// void saveConfig(QSettings* settings) const; //THIS SEEMS TO BE UNUSED IUAVGadgetConfiguration *clone(); bool getLoggingEnabled(){return m_LoggingEnabled;}; @@ -84,6 +87,7 @@ private: int m_plotType; //The type of the plot int m_dataSize; //The size of the data buffer to render in the curve plot int m_refreshInterval; //The interval to replot the curve widget. The data buffer is refresh as the data comes in. + int m_mathFunctionType; //The type of math function to be used in the scope analysis QList m_PlotCurveConfigs; void clearPlotData(); diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp index b9ed9191e..c9bf72a41 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp @@ -69,6 +69,9 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) //Connect signals to slots cmbUAVObjects.currentIndexChanged connect(options_page->cmbUAVObjects, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_cmbUAVObjects_currentIndexChanged(QString))); + options_page->mathFunctionComboBox->addItem("None"); + options_page->mathFunctionComboBox->addItem("Standard deviation"); + if(options_page->cmbUAVObjects->currentIndex() >= 0) on_cmbUAVObjects_currentIndexChanged(options_page->cmbUAVObjects->currentText()); @@ -92,6 +95,7 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) //Set widget values from settings options_page->cmbPlotType->setCurrentIndex(m_config->plotType()); + options_page->mathFunctionComboBox->setCurrentIndex(m_config->mathFunctionType()); options_page->spnDataSize->setValue(m_config->dataSize()); options_page->spnRefreshInterval->setValue(m_config->refreshInterval()); @@ -101,10 +105,11 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) QString uavObject = plotData->uavObject; QString uavField = plotData->uavField; int scale = plotData->yScalePower; - int interpolation = plotData->yInterpolationSamples; + int mean = plotData->yMeanSamples; + QString mathFunction = plotData->mathFunction; QVariant varColor = plotData->color; - addPlotCurveConfig(uavObject,uavField,scale,interpolation,varColor); + addPlotCurveConfig(uavObject,uavField,scale,mean,mathFunction,varColor); } if(m_config->plotCurveConfigs().count() > 0) @@ -152,6 +157,7 @@ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve() if(listItem == 0) return; + //WHAT IS UserRole DOING? int currentIndex = options_page->cmbUAVObjects->findText( listItem->data(Qt::UserRole + 0).toString()); options_page->cmbUAVObjects->setCurrentIndex(currentIndex); @@ -166,9 +172,13 @@ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve() setButtonColor(QColor((QRgb)rgb)); - int interpolation = listItem->data(Qt::UserRole + 4).toInt(&parseOK); - if(!parseOK) interpolation = 1; - options_page->spnInterpolationSamples->setValue(interpolation); + int mean = listItem->data(Qt::UserRole + 4).toInt(&parseOK); + if(!parseOK) mean = 1; + options_page->spnMeanSamples->setValue(mean); + + currentIndex = options_page->mathFunctionComboBox->findData( listItem->data(Qt::UserRole + 5).toString()); + options_page->mathFunctionComboBox->setCurrentIndex(currentIndex); + } void ScopeGadgetOptionsPage::setButtonColor(const QColor &color) @@ -221,6 +231,7 @@ void ScopeGadgetOptionsPage::apply() //Apply configuration changes m_config->setPlotType(options_page->cmbPlotType->currentIndex()); + m_config->setMathFunctionType(options_page->mathFunctionComboBox->currentIndex()); m_config->setDataSize(options_page->spnDataSize->value()); m_config->setRefreashInterval(options_page->spnRefreshInterval->value()); @@ -241,10 +252,13 @@ void ScopeGadgetOptionsPage::apply() newPlotCurveConfigs->color = QColor(Qt::black).rgb(); else newPlotCurveConfigs->color = (QRgb)rgb; - - newPlotCurveConfigs->yInterpolationSamples = listItem->data(Qt::UserRole + 4).toInt(&parseOK); + + newPlotCurveConfigs->yMeanSamples = listItem->data(Qt::UserRole + 4).toInt(&parseOK); if(!parseOK) - newPlotCurveConfigs->yInterpolationSamples = 1; + newPlotCurveConfigs->yMeanSamples = 1; + + newPlotCurveConfigs->mathFunction = listItem->data(Qt::UserRole + 5).toString(); + plotCurveConfigs.append(newPlotCurveConfigs); } @@ -271,7 +285,9 @@ void ScopeGadgetOptionsPage::on_btnAddCurve_clicked() if(!parseOK) scale = 0; - int interpolation = options_page->spnInterpolationSamples->value(); + int mean = options_page->spnMeanSamples->value(); + QString mathFunction = options_page->mathFunctionComboBox->currentText(); + QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb(); @@ -281,27 +297,27 @@ void ScopeGadgetOptionsPage::on_btnAddCurve_clicked() options_page->lstCurves->currentItem()->text() == uavObject + "." + uavField) { QListWidgetItem *listWidgetItem = options_page->lstCurves->currentItem(); - setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,interpolation,varColor); + setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,mean,mathFunction,varColor); }else { - addPlotCurveConfig(uavObject,uavField,scale,interpolation,varColor); + addPlotCurveConfig(uavObject,uavField,scale,mean,mathFunction,varColor); options_page->lstCurves->setCurrentRow(options_page->lstCurves->count() - 1); } } -void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor) +void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor) { //Add a new curve config to the list QString listItemDisplayText = uavObject + "." + uavField; options_page->lstCurves->addItem(listItemDisplayText); QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1); - setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,interpolation,varColor); + setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,mean,mathFunction,varColor); } -void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetItem,QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor) +void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetItem,QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor) { bool parseOK = false; @@ -317,7 +333,8 @@ void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetI listWidgetItem->setData(Qt::UserRole + 1,QVariant(uavField)); listWidgetItem->setData(Qt::UserRole + 2,QVariant(scale)); listWidgetItem->setData(Qt::UserRole + 3,varColor); - listWidgetItem->setData(Qt::UserRole + 4,QVariant(interpolation)); + listWidgetItem->setData(Qt::UserRole + 4,QVariant(mean)); + listWidgetItem->setData(Qt::UserRole + 5,QVariant(mathFunction)); } /*! diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h index 54042741e..528dad22c 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h @@ -66,8 +66,8 @@ private: Ui::ScopeGadgetOptionsPage *options_page; ScopeGadgetConfiguration *m_config; - void addPlotCurveConfig(QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor); - void setCurvePlotProperties(QListWidgetItem *listWidgetItem, QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor); + void addPlotCurveConfig(QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor); + void setCurvePlotProperties(QListWidgetItem *listWidgetItem, QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor); void setYAxisWidgetFromPlotCurve(); void setButtonColor(const QColor &color); void validateRefreshInterval(); diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui index 64a331917..89ffa8af1 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui @@ -6,8 +6,8 @@ 0 0 - 544 - 342 + 548 + 457 @@ -185,43 +185,43 @@ - + Color: - + Choose - + Y-axis scale factor: - + false - + - Display smoothed interpolation: + Display moving average: - - + + samples @@ -239,6 +239,16 @@ + + + + Math function: + + + + + + diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index 011cdb394..50de038c7 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -352,7 +352,7 @@ void ScopeGadgetWidget::setupChronoPlot() // scaleWidget->setMinBorderDist(0, fmw); } -void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor, int interpolationSamples, QPen pen) +void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor, int meanSamples, QString mathFunction, QPen pen) { PlotData* plotData; @@ -365,7 +365,8 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField plotData->m_xWindowSize = m_xWindowSize; plotData->scalePower = scaleOrderFactor; - plotData->interpolationSamples = interpolationSamples; + plotData->meanSamples = meanSamples; + plotData->mathFunction = mathFunction; //If the y-bounds are supplied, set them if (plotData->yMinimum != plotData->yMaximum) diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h index b4e6ce113..f812e6fa6 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.h @@ -81,7 +81,7 @@ public: int refreshInterval(){return m_refreshInterval;} - void addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor = 0, int interpolationSamples = 1, QPen pen = QPen(Qt::black)); + void addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor = 0, int meanSamples = 1, QString mathFunction= "None", QPen pen = QPen(Qt::black)); //void removeCurvePlot(QString uavObject, QString uavField); void clearCurvePlots(); int csvLoggingStart(); From a210b790b431bf811a5cf82c33f85e84486f26f1 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 12:19:20 +0300 Subject: [PATCH 6/8] Added combo boxes to the mouse wheel filter. --- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 21d196be8..cd891aa3d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -1170,12 +1170,17 @@ void ConfigTaskWidget::disableMouseWheelEvents() foreach( QSlider * sp, findChildren() ) { sp->installEventFilter( this ); } + foreach( QComboBox * sp, findChildren() ) { + sp->installEventFilter( this ); + } } bool ConfigTaskWidget::eventFilter( QObject * obj, QEvent * evt ) { //Filter all wheel events, and ignore them if ( evt->type() == QEvent::Wheel && - (qobject_cast( obj ) || qobject_cast( obj ) )) + (qobject_cast( obj ) || + qobject_cast( obj ) || + qobject_cast( obj ) )) { evt->ignore(); return true; From 6003d2d5748640d748a12cbf4e1f309ad8d2a207 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 12:34:01 +0300 Subject: [PATCH 7/8] Changed order of scope math functions to be more logical. Added "Average" as scope math function. Changed averaging window size text edit box to be active only when math functions are selected. Fixed bug introduced immediately prior by removing child redefinition of saveConfig. Tried installing scroll wheel event filter for scope config plugin, but is not currently working. --- .../src/plugins/scope/plotdata.cpp | 2 +- .../scope/scopegadgetconfiguration.cpp | 61 +++++++------- .../plugins/scope/scopegadgetconfiguration.h | 2 +- .../plugins/scope/scopegadgetoptionspage.cpp | 38 +++++++++ .../plugins/scope/scopegadgetoptionspage.h | 2 + .../plugins/scope/scopegadgetoptionspage.ui | 80 ++++++++++++++++--- .../src/plugins/scope/scopegadgetwidget.cpp | 2 +- 7 files changed, 141 insertions(+), 46 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp index da01fb48a..154a9aa06 100644 --- a/ground/openpilotgcs/src/plugins/scope/plotdata.cpp +++ b/ground/openpilotgcs/src/plugins/scope/plotdata.cpp @@ -100,7 +100,7 @@ bool SequentialPlotData::append(UAVObject* obj) double currentValue = valueAsDouble(obj, field) * pow(10, scalePower); //Compute boxcar average - if (meanSamples > 1){ + if (mathFunction == "Boxcar average" || mathFunction == "Standard deviation"){ //Put the new value at the front yDataHistory->append( currentValue ); diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.cpp index 0178b385b..57b1c134f 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.cpp @@ -144,45 +144,44 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone() } -////THIS SEEMS TO BE UNUSED -///** -// * Saves a configuration. -// * -// */ -//void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const { +/** + * Saves a configuration. //REDEFINES saveConfig CHILD BEHAVIOR? + * + */ +void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const { -// int plotCurveCount = m_PlotCurveConfigs.size(); -// int plotDatasLoadIndex = 0; + int plotCurveCount = m_PlotCurveConfigs.size(); + int plotDatasLoadIndex = 0; -// qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion); -// qSettings->setValue("plotType", m_plotType); -// qSettings->setValue("dataSize", m_dataSize); -// qSettings->setValue("refreshInterval", m_refreshInterval); -// qSettings->setValue("plotCurveCount", plotCurveCount); + qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion); + qSettings->setValue("plotType", m_plotType); + qSettings->setValue("dataSize", m_dataSize); + qSettings->setValue("refreshInterval", m_refreshInterval); + qSettings->setValue("plotCurveCount", plotCurveCount); -// for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) -// { -// qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex)); + for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) + { + qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex)); -// PlotCurveConfiguration* plotCurveConf = m_PlotCurveConfigs.at(plotDatasLoadIndex); -// qSettings->setValue("uavObject", plotCurveConf->uavObject); -// qSettings->setValue("uavField", plotCurveConf->uavField); -// qSettings->setValue("color", plotCurveConf->color); -// qSettings->setValue("mathFunction", plotCurveConf->mathFunction); -// qSettings->setValue("yScalePower", plotCurveConf->yScalePower); -// qSettings->setValue("yMeanSamples", plotCurveConf->yMeanSamples); -// qSettings->setValue("yMinimum", plotCurveConf->yMinimum); -// qSettings->setValue("yMaximum", plotCurveConf->yMaximum); + PlotCurveConfiguration* plotCurveConf = m_PlotCurveConfigs.at(plotDatasLoadIndex); + qSettings->setValue("uavObject", plotCurveConf->uavObject); + qSettings->setValue("uavField", plotCurveConf->uavField); + qSettings->setValue("color", plotCurveConf->color); + qSettings->setValue("mathFunction", plotCurveConf->mathFunction); + qSettings->setValue("yScalePower", plotCurveConf->yScalePower); + qSettings->setValue("yMeanSamples", plotCurveConf->yMeanSamples); + qSettings->setValue("yMinimum", plotCurveConf->yMinimum); + qSettings->setValue("yMaximum", plotCurveConf->yMaximum); -// qSettings->endGroup(); -// } + qSettings->endGroup(); + } -// qSettings->setValue("LoggingEnabled", m_LoggingEnabled); -// qSettings->setValue("LoggingNewFileOnConnect", m_LoggingNewFileOnConnect); -// qSettings->setValue("LoggingPath", m_LoggingPath); + qSettings->setValue("LoggingEnabled", m_LoggingEnabled); + qSettings->setValue("LoggingNewFileOnConnect", m_LoggingNewFileOnConnect); + qSettings->setValue("LoggingPath", m_LoggingPath); -//} +} void ScopeGadgetConfiguration::replacePlotCurveConfig(QList newPlotCurveConfigs) { diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.h index be1bf2426..5fcb488e2 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetconfiguration.h @@ -71,7 +71,7 @@ public: int refreshInterval(){return m_refreshInterval;} QList plotCurveConfigs(){return m_PlotCurveConfigs;} -// void saveConfig(QSettings* settings) const; //THIS SEEMS TO BE UNUSED + void saveConfig(QSettings* settings) const; //THIS SEEMS TO BE UNUSED IUAVGadgetConfiguration *clone(); bool getLoggingEnabled(){return m_LoggingEnabled;}; diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp index c9bf72a41..9e3b7e301 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp @@ -70,6 +70,7 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) connect(options_page->cmbUAVObjects, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_cmbUAVObjects_currentIndexChanged(QString))); options_page->mathFunctionComboBox->addItem("None"); + options_page->mathFunctionComboBox->addItem("Boxcar average"); options_page->mathFunctionComboBox->addItem("Standard deviation"); if(options_page->cmbUAVObjects->currentIndex() >= 0) @@ -119,6 +120,7 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) connect(options_page->btnRemoveCurve, SIGNAL(clicked()), this, SLOT(on_btnRemoveCurve_clicked())); connect(options_page->lstCurves, SIGNAL(currentRowChanged(int)), this, SLOT(on_lstCurves_currentRowChanged(int))); connect(options_page->btnColor, SIGNAL(clicked()), this, SLOT(on_btnColor_clicked())); + connect(options_page->mathFunctionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_mathFunctionComboBox_currentIndexChanged(int))); connect(options_page->spnRefreshInterval, SIGNAL(valueChanged(int )), this, SLOT(on_spnRefreshInterval_valueChanged(int))); setYAxisWidgetFromPlotCurve(); @@ -132,11 +134,47 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) connect(options_page->LoggingEnable, SIGNAL(clicked()), this, SLOT(on_loggingEnable_clicked())); on_loggingEnable_clicked(); + //Disable mouse wheel events + foreach( QSpinBox * sp, findChildren() ) { + sp->installEventFilter( this ); + } + foreach( QDoubleSpinBox * sp, findChildren() ) { + sp->installEventFilter( this ); + } + foreach( QSlider * sp, findChildren() ) { + sp->installEventFilter( this ); + } + foreach( QComboBox * sp, findChildren() ) { + sp->installEventFilter( this ); + } return optionsPageWidget; } +bool ScopeGadgetOptionsPage::eventFilter( QObject * obj, QEvent * evt ) { + //Filter all wheel events, and ignore them + if ( evt->type() == QEvent::Wheel && + (qobject_cast( obj ) || + qobject_cast( obj ) || + qobject_cast( obj ) )) + { + evt->ignore(); + return true; + } + return ScopeGadgetOptionsPage::eventFilter( obj, evt ); +} + +void ScopeGadgetOptionsPage::on_mathFunctionComboBox_currentIndexChanged(int currentIndex){ + if (currentIndex > 0){ + options_page->spnMeanSamples->setEnabled(true); + } + else{ + options_page->spnMeanSamples->setEnabled(false); + } + +} + void ScopeGadgetOptionsPage::on_btnColor_clicked() { QColor color = QColorDialog::getColor( QColor(options_page->btnColor->text())); diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h index 528dad22c..009f02337 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.h @@ -71,6 +71,7 @@ private: void setYAxisWidgetFromPlotCurve(); void setButtonColor(const QColor &color); void validateRefreshInterval(); + bool eventFilter( QObject * obj, QEvent * evt ); private slots: void on_spnRefreshInterval_valueChanged(int ); @@ -79,6 +80,7 @@ private slots: void on_btnAddCurve_clicked(); void on_cmbUAVObjects_currentIndexChanged(QString val); void on_btnColor_clicked(); + void on_mathFunctionComboBox_currentIndexChanged(int currentIndex); void on_loggingEnable_clicked(); }; diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui index 89ffa8af1..c120544aa 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.ui @@ -100,7 +100,11 @@ - + + + Qt::StrongFocus + + @@ -111,6 +115,9 @@ + + Qt::StrongFocus + seconds @@ -134,6 +141,9 @@ + + Qt::StrongFocus + ms @@ -161,7 +171,7 @@ - Plot curves + Y-axis @@ -173,7 +183,11 @@ - + + + Qt::StrongFocus + + @@ -183,45 +197,67 @@ - + + + Qt::StrongFocus + + - + Color: - + + + Qt::StrongFocus + Choose - + Y-axis scale factor: - + + + Qt::StrongFocus + false - + - Display moving average: + Math window size - + + + false + + + + 16777215 + 16777215 + + + + Qt::StrongFocus + samples @@ -247,7 +283,11 @@ - + + + Qt::StrongFocus + + @@ -400,6 +440,22 @@ Update 1 + + cmbPlotType + spnDataSize + spnRefreshInterval + cmbUAVObjects + cmbUAVField + mathFunctionComboBox + spnMeanSamples + btnColor + cmbScale + btnAddCurve + btnRemoveCurve + lstCurves + LoggingEnable + LoggingConnect + diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index 50de038c7..967ede982 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -142,7 +142,7 @@ void ScopeGadgetWidget::mouseMoveEvent(QMouseEvent *e) void ScopeGadgetWidget::wheelEvent(QWheelEvent *e) { - QwtPlot::wheelEvent(e); + QwtPlot::wheelEvent(e); } /** From 5f7944bff1d86f851bf8c6ada868ffada8b5bc5a Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 18:14:21 +0300 Subject: [PATCH 8/8] Fixed display problem for in scope for math function type. Updated OpenPilotGCS.xml to include default of "None" for scope math type. --- .../src/plugins/coreplugin/OpenPilotGCS.xml | 44 +++++++++++++++++++ .../plugins/scope/scopegadgetoptionspage.cpp | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/OpenPilotGCS.xml b/ground/openpilotgcs/src/plugins/coreplugin/OpenPilotGCS.xml index 05ce6a7ea..64c653f23 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/OpenPilotGCS.xml +++ b/ground/openpilotgcs/src/plugins/coreplugin/OpenPilotGCS.xml @@ -1734,6 +1734,7 @@ 60 4294901760 + None x Accels 0 @@ -1742,6 +1743,7 @@ 4283782655 + None y Accels 0 @@ -1750,6 +1752,7 @@ 4283804160 + None z Accels 0 @@ -1774,6 +1777,7 @@ 20 4294901760 + None Channel-4 ActuatorCommand 0 @@ -1782,6 +1786,7 @@ 4294901760 + None Channel-5 ActuatorCommand 0 @@ -1790,6 +1795,7 @@ 4289374847 + None Channel-6 ActuatorCommand 0 @@ -1798,6 +1804,7 @@ 4289374847 + None Channel-7 ActuatorCommand 0 @@ -1822,6 +1829,7 @@ 60 4283760895 + None Roll AttitudeActual 0 @@ -1830,6 +1838,7 @@ 4278233600 + None Yaw AttitudeActual 0 @@ -1838,6 +1847,7 @@ 4294901760 + None Pitch AttitudeActual 0 @@ -1862,6 +1872,7 @@ 60 4278190080 + None Pressure BaroAltitude 0 @@ -1886,6 +1897,7 @@ 40 4278190207 + None Channel-1 ManualControlCommand 0 @@ -1894,6 +1906,7 @@ 4294901760 + None Channel-4 ManualControlCommand 0 @@ -1902,6 +1915,7 @@ 4294901760 + None Channel-5 ManualControlCommand 0 @@ -1910,6 +1924,7 @@ 4294901760 + None Channel-6 ManualControlCommand 0 @@ -1918,6 +1933,7 @@ 4294901760 + None Channel-7 ManualControlCommand 0 @@ -1926,6 +1942,7 @@ 4283825920 + None Channel-2 ManualControlCommand 0 @@ -1934,6 +1951,7 @@ 4294923520 + None Channel-3 ManualControlCommand 0 @@ -1942,6 +1960,7 @@ 4294967040 + None Channel-0 ManualControlCommand 0 @@ -1966,6 +1985,7 @@ 60 4294901760 + None x Accels 0 @@ -1974,6 +1994,7 @@ 4283782655 + None y Accels 0 @@ -1982,6 +2003,7 @@ 4283804160 + None z Accels 0 @@ -2006,6 +2028,7 @@ 60 4283804160 + None z Gyros 0 @@ -2014,6 +2037,7 @@ 4283782655 + None y Gyros 0 @@ -2022,6 +2046,7 @@ 4294901760 + None x Gyros 0 @@ -2046,6 +2071,7 @@ 60 4294901760 + None X Magnetometer 0 @@ -2054,6 +2080,7 @@ 4283782655 + None Y Magnetometer 0 @@ -2062,6 +2089,7 @@ 4283804160 + None Z Magnetometer 0 @@ -2086,6 +2114,7 @@ 240 4294945280 + None StackRemaining-System TaskInfo 0 @@ -2094,6 +2123,7 @@ 4294945280 + None StackRemaining-Actuator TaskInfo 0 @@ -2102,6 +2132,7 @@ 4294945280 + None StackRemaining-Guidance TaskInfo 0 @@ -2110,6 +2141,7 @@ 4294945280 + None StackRemaining-Watchdog TaskInfo 0 @@ -2118,6 +2150,7 @@ 4294945280 + None StackRemaining-TelemetryTx TaskInfo 0 @@ -2126,6 +2159,7 @@ 4294945280 + None StackRemaining-TelemetryTxPri TaskInfo 0 @@ -2134,6 +2168,7 @@ 4294945280 + None StackRemaining-TelemetryRx TaskInfo 0 @@ -2142,6 +2177,7 @@ 4294945280 + None StackRemaining-GPS TaskInfo 0 @@ -2150,6 +2186,7 @@ 4294945280 + None StackRemaining-ManualControl TaskInfo 0 @@ -2158,6 +2195,7 @@ 4294945280 + None StackRemaining-Altitude TaskInfo 0 @@ -2166,6 +2204,7 @@ 4294945280 + None StackRemaining-AHRSComms TaskInfo 0 @@ -2174,6 +2213,7 @@ 4294945280 + None StackRemaining-Stabilization TaskInfo 0 @@ -2198,6 +2238,7 @@ 20 4289374847 + None TxFailures GCSTelemetryStats 0 @@ -2206,6 +2247,7 @@ 4283782655 + None RxFailures GCSTelemetryStats 0 @@ -2214,6 +2256,7 @@ 4294901760 + None TxRetries GCSTelemetryStats 0 @@ -2238,6 +2281,7 @@ 240 4294945407 + None FlightTime SystemStats 0 diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp index 9e3b7e301..06111931f 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetoptionspage.cpp @@ -214,7 +214,7 @@ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve() if(!parseOK) mean = 1; options_page->spnMeanSamples->setValue(mean); - currentIndex = options_page->mathFunctionComboBox->findData( listItem->data(Qt::UserRole + 5).toString()); + currentIndex = options_page->mathFunctionComboBox->findText( listItem->data(Qt::UserRole + 5).toString()); options_page->mathFunctionComboBox->setCurrentIndex(currentIndex); }