From 6003d2d5748640d748a12cbf4e1f309ad8d2a207 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Tue, 22 May 2012 12:34:01 +0300 Subject: [PATCH] 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); } /**