mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-28 17:54:15 +01:00
OP-952 Adds settings per scope-plot if to draw the plot anti-aliased. Default setting is true. Adds a fix to not render the plots when they are not visible. Saves CPU.
This commit is contained in:
parent
b9601c3ad6
commit
c4adede7ac
@ -33,52 +33,47 @@
|
|||||||
#include <QtGui/qcolor.h>
|
#include <QtGui/qcolor.h>
|
||||||
|
|
||||||
ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent) :
|
ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent) :
|
||||||
IUAVGadget(classId, parent),
|
IUAVGadget(classId, parent),
|
||||||
m_widget(widget),
|
m_widget(widget),
|
||||||
configLoaded(false)
|
configLoaded(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||||
{
|
{
|
||||||
|
ScopeGadgetConfiguration *sgConfig = qobject_cast<ScopeGadgetConfiguration *>(config);
|
||||||
}
|
ScopeGadgetWidget *widget = qobject_cast<ScopeGadgetWidget *>(m_widget);
|
||||||
|
|
||||||
void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
|
||||||
{
|
|
||||||
|
|
||||||
ScopeGadgetConfiguration *sgConfig = qobject_cast<ScopeGadgetConfiguration*>(config);
|
|
||||||
ScopeGadgetWidget* widget = qobject_cast<ScopeGadgetWidget*>(m_widget);
|
|
||||||
|
|
||||||
widget->setXWindowSize(sgConfig->dataSize());
|
widget->setXWindowSize(sgConfig->dataSize());
|
||||||
widget->setRefreshInterval(sgConfig->refreshInterval());
|
widget->setRefreshInterval(sgConfig->refreshInterval());
|
||||||
|
|
||||||
if(sgConfig->plotType() == SequentialPlot )
|
if (sgConfig->plotType() == SequentialPlot) {
|
||||||
widget->setupSequentialPlot();
|
widget->setupSequentialPlot();
|
||||||
else if(sgConfig->plotType() == ChronoPlot)
|
} else if (sgConfig->plotType() == ChronoPlot) {
|
||||||
widget->setupChronoPlot();
|
widget->setupChronoPlot();
|
||||||
// else if(sgConfig->plotType() == UAVObjectPlot)
|
}
|
||||||
// widget->setupUAVObjectPlot();
|
|
||||||
|
|
||||||
foreach (PlotCurveConfiguration* plotCurveConfig, sgConfig->plotCurveConfigs()) {
|
foreach(PlotCurveConfiguration * plotCurveConfig, sgConfig->plotCurveConfigs()) {
|
||||||
|
QString uavObject = plotCurveConfig->uavObject;
|
||||||
QString uavObject = plotCurveConfig->uavObject;
|
QString uavField = plotCurveConfig->uavField;
|
||||||
QString uavField = plotCurveConfig->uavField;
|
|
||||||
int scale = plotCurveConfig->yScalePower;
|
int scale = plotCurveConfig->yScalePower;
|
||||||
int mean = plotCurveConfig->yMeanSamples;
|
int mean = plotCurveConfig->yMeanSamples;
|
||||||
QString mathFunction = plotCurveConfig->mathFunction;
|
QString mathFunction = plotCurveConfig->mathFunction;
|
||||||
QRgb color = plotCurveConfig->color;
|
QRgb color = plotCurveConfig->color;
|
||||||
|
bool antialiased = plotCurveConfig->drawAntialiased;
|
||||||
widget->addCurvePlot(
|
widget->addCurvePlot(
|
||||||
uavObject,
|
uavObject,
|
||||||
uavField,
|
uavField,
|
||||||
scale,
|
scale,
|
||||||
mean,
|
mean,
|
||||||
mathFunction,
|
mathFunction,
|
||||||
QPen( QBrush(QColor(color),Qt::SolidPattern),
|
QPen(QBrush(QColor(color), Qt::SolidPattern),
|
||||||
// (qreal)2,
|
(qreal)1,
|
||||||
(qreal)1,
|
Qt::SolidLine,
|
||||||
Qt::SolidLine,
|
Qt::SquareCap,
|
||||||
Qt::SquareCap,
|
Qt::BevelJoin),
|
||||||
Qt::BevelJoin)
|
antialiased
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->setLoggingEnabled(sgConfig->getLoggingEnabled());
|
widget->setLoggingEnabled(sgConfig->getLoggingEnabled());
|
||||||
widget->setLoggingNewFileOnConnect(sgConfig->getLoggingNewFileOnConnect());
|
widget->setLoggingNewFileOnConnect(sgConfig->getLoggingNewFileOnConnect());
|
||||||
@ -87,14 +82,13 @@ void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
|||||||
widget->csvLoggingStop();
|
widget->csvLoggingStop();
|
||||||
widget->csvLoggingSetName(sgConfig->name());
|
widget->csvLoggingSetName(sgConfig->name());
|
||||||
widget->csvLoggingStart();
|
widget->csvLoggingStart();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Scope gadget destructor: should delete the associated
|
Scope gadget destructor: should delete the associated
|
||||||
scope gadget widget too!
|
scope gadget widget too!
|
||||||
*/
|
*/
|
||||||
ScopeGadget::~ScopeGadget()
|
ScopeGadget::~ScopeGadget()
|
||||||
{
|
{
|
||||||
delete m_widget;
|
delete m_widget;
|
||||||
}
|
}
|
||||||
|
@ -27,75 +27,63 @@
|
|||||||
|
|
||||||
#include "scopegadgetconfiguration.h"
|
#include "scopegadgetconfiguration.h"
|
||||||
|
|
||||||
ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
||||||
IUAVGadgetConfiguration(classId, parent),
|
IUAVGadgetConfiguration(classId, parent),
|
||||||
m_plotType((int)ChronoPlot),
|
m_plotType((int)ChronoPlot),
|
||||||
m_dataSize(60),
|
m_dataSize(60),
|
||||||
m_refreshInterval(1000),
|
m_refreshInterval(1000),
|
||||||
m_mathFunctionType(0)
|
m_mathFunctionType(0)
|
||||||
{
|
{
|
||||||
uint currentStreamVersion = 0;
|
uint currentStreamVersion = 0;
|
||||||
int plotCurveCount = 0;
|
int plotCurveCount = 0;
|
||||||
|
|
||||||
|
|
||||||
//if a saved configuration exists load it
|
// If a saved configuration exists load it
|
||||||
if(qSettings != 0) {
|
if (qSettings != 0) {
|
||||||
currentStreamVersion = qSettings->value("configurationStreamVersion").toUInt();
|
currentStreamVersion = qSettings->value("configurationStreamVersion").toUInt();
|
||||||
|
|
||||||
if(currentStreamVersion != m_configurationStreamVersion)
|
if (currentStreamVersion != m_configurationStreamVersion) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_plotType = qSettings->value("plotType").toInt();
|
m_plotType = qSettings->value("plotType").toInt();
|
||||||
m_dataSize = qSettings->value("dataSize").toInt();
|
m_dataSize = qSettings->value("dataSize").toInt();
|
||||||
m_refreshInterval = qSettings->value("refreshInterval").toInt();
|
m_refreshInterval = qSettings->value("refreshInterval").toInt();
|
||||||
plotCurveCount = qSettings->value("plotCurveCount").toInt();
|
plotCurveCount = qSettings->value("plotCurveCount").toInt();
|
||||||
|
|
||||||
for(int plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++)
|
|
||||||
{
|
|
||||||
QString uavObject;
|
|
||||||
QString uavField;
|
|
||||||
QRgb color;
|
|
||||||
|
|
||||||
|
for (int plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) {
|
||||||
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
|
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
|
||||||
|
|
||||||
PlotCurveConfiguration* plotCurveConf = new PlotCurveConfiguration();
|
PlotCurveConfiguration *plotCurveConf = new PlotCurveConfiguration();
|
||||||
uavObject = qSettings->value("uavObject").toString();
|
plotCurveConf->uavObject = qSettings->value("uavObject").toString();
|
||||||
plotCurveConf->uavObject = uavObject;
|
plotCurveConf->uavField = qSettings->value("uavField").toString();
|
||||||
uavField = qSettings->value("uavField").toString();
|
plotCurveConf->color = qSettings->value("color").value<QRgb>();
|
||||||
plotCurveConf->uavField = uavField;
|
plotCurveConf->yScalePower = qSettings->value("yScalePower").toInt();
|
||||||
color = qSettings->value("color").value<QRgb>();
|
|
||||||
plotCurveConf->color = color;
|
|
||||||
plotCurveConf->yScalePower = qSettings->value("yScalePower").toInt();
|
|
||||||
plotCurveConf->mathFunction = qSettings->value("mathFunction").toString();
|
plotCurveConf->mathFunction = qSettings->value("mathFunction").toString();
|
||||||
plotCurveConf->yMeanSamples = qSettings->value("yMeanSamples").toInt();
|
plotCurveConf->yMeanSamples = qSettings->value("yMeanSamples", 1).toInt();
|
||||||
|
plotCurveConf->yMeanSamples = qSettings->value("yMeanSamples", 1).toInt();
|
||||||
if (!plotCurveConf->yMeanSamples) plotCurveConf->yMeanSamples = 1; // fallback for backward compatibility with earlier versions //IS THIS STILL NECESSARY?
|
plotCurveConf->drawAntialiased = qSettings->value("drawAntialiased", true).toBool();
|
||||||
|
|
||||||
plotCurveConf->yMinimum = qSettings->value("yMinimum").toDouble();
|
plotCurveConf->yMinimum = qSettings->value("yMinimum").toDouble();
|
||||||
plotCurveConf->yMaximum = qSettings->value("yMaximum").toDouble();
|
plotCurveConf->yMaximum = qSettings->value("yMaximum").toDouble();
|
||||||
|
m_plotCurveConfigs.append(plotCurveConf);
|
||||||
m_PlotCurveConfigs.append(plotCurveConf);
|
|
||||||
|
|
||||||
qSettings->endGroup();
|
qSettings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LoggingEnabled = qSettings->value("LoggingEnabled").toBool();
|
m_loggingEnabled = qSettings->value("LoggingEnabled").toBool();
|
||||||
m_LoggingNewFileOnConnect = qSettings->value("LoggingNewFileOnConnect").toBool();
|
m_loggingNewFileOnConnect = qSettings->value("LoggingNewFileOnConnect").toBool();
|
||||||
m_LoggingPath = qSettings->value("LoggingPath").toString();
|
m_loggingPath = qSettings->value("LoggingPath").toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetConfiguration::clearPlotData()
|
void ScopeGadgetConfiguration::clearPlotData()
|
||||||
{
|
{
|
||||||
PlotCurveConfiguration* poltCurveConfig;
|
PlotCurveConfiguration *plotCurveConfig;
|
||||||
|
|
||||||
while(m_PlotCurveConfigs.size() > 0)
|
while (m_plotCurveConfigs.size() > 0) {
|
||||||
{
|
plotCurveConfig = m_plotCurveConfigs.first();
|
||||||
poltCurveConfig = m_PlotCurveConfigs.first();
|
m_plotCurveConfigs.pop_front();
|
||||||
m_PlotCurveConfigs.pop_front();
|
delete plotCurveConfig;
|
||||||
|
|
||||||
delete poltCurveConfig;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,40 +93,38 @@ void ScopeGadgetConfiguration::clearPlotData()
|
|||||||
*/
|
*/
|
||||||
IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
|
IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
|
||||||
{
|
{
|
||||||
int plotCurveCount = 0;
|
int plotCurveCount = 0;
|
||||||
int plotDatasLoadIndex = 0;
|
int plotDatasLoadIndex = 0;
|
||||||
|
|
||||||
ScopeGadgetConfiguration *m = new ScopeGadgetConfiguration(this->classId());
|
ScopeGadgetConfiguration *m = new ScopeGadgetConfiguration(this->classId());
|
||||||
m->setPlotType( m_plotType);
|
|
||||||
m->setDataSize( m_dataSize);
|
|
||||||
m->setMathFunctionType( m_mathFunctionType);
|
|
||||||
m->setRefreashInterval( m_refreshInterval);
|
|
||||||
|
|
||||||
plotCurveCount = m_PlotCurveConfigs.size();
|
m->setPlotType(m_plotType);
|
||||||
|
m->setDataSize(m_dataSize);
|
||||||
|
m->setMathFunctionType(m_mathFunctionType);
|
||||||
|
m->setRefreashInterval(m_refreshInterval);
|
||||||
|
|
||||||
for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++)
|
plotCurveCount = m_plotCurveConfigs.size();
|
||||||
{
|
|
||||||
PlotCurveConfiguration* currentPlotCurveConf = m_PlotCurveConfigs.at(plotDatasLoadIndex);
|
|
||||||
|
|
||||||
PlotCurveConfiguration* newPlotCurveConf = new PlotCurveConfiguration();
|
for (plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) {
|
||||||
newPlotCurveConf->uavObject = currentPlotCurveConf->uavObject;
|
PlotCurveConfiguration *currentPlotCurveConf = m_plotCurveConfigs.at(plotDatasLoadIndex);
|
||||||
newPlotCurveConf->uavField = currentPlotCurveConf->uavField;
|
|
||||||
newPlotCurveConf->color = currentPlotCurveConf->color;
|
PlotCurveConfiguration *newPlotCurveConf = new PlotCurveConfiguration();
|
||||||
newPlotCurveConf->yScalePower = currentPlotCurveConf->yScalePower;
|
newPlotCurveConf->uavObject = currentPlotCurveConf->uavObject;
|
||||||
|
newPlotCurveConf->uavField = currentPlotCurveConf->uavField;
|
||||||
|
newPlotCurveConf->color = currentPlotCurveConf->color;
|
||||||
|
newPlotCurveConf->yScalePower = currentPlotCurveConf->yScalePower;
|
||||||
newPlotCurveConf->yMeanSamples = currentPlotCurveConf->yMeanSamples;
|
newPlotCurveConf->yMeanSamples = currentPlotCurveConf->yMeanSamples;
|
||||||
newPlotCurveConf->mathFunction = currentPlotCurveConf->mathFunction;
|
newPlotCurveConf->mathFunction = currentPlotCurveConf->mathFunction;
|
||||||
|
newPlotCurveConf->drawAntialiased = currentPlotCurveConf->drawAntialiased;
|
||||||
newPlotCurveConf->yMinimum = currentPlotCurveConf->yMinimum;
|
newPlotCurveConf->yMinimum = currentPlotCurveConf->yMinimum;
|
||||||
newPlotCurveConf->yMaximum = currentPlotCurveConf->yMaximum;
|
newPlotCurveConf->yMaximum = currentPlotCurveConf->yMaximum;
|
||||||
|
|
||||||
m->addPlotCurveConfig(newPlotCurveConf);
|
m->addPlotCurveConfig(newPlotCurveConf);
|
||||||
}
|
}
|
||||||
|
|
||||||
m->setLoggingEnabled(m_LoggingEnabled);
|
m->setLoggingEnabled(m_loggingEnabled);
|
||||||
m->setLoggingNewFileOnConnect(m_LoggingNewFileOnConnect);
|
m->setLoggingNewFileOnConnect(m_loggingNewFileOnConnect);
|
||||||
m->setLoggingPath(m_LoggingPath);
|
m->setLoggingPath(m_loggingPath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
@ -148,9 +134,9 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
|
|||||||
* Saves a configuration. //REDEFINES saveConfig CHILD BEHAVIOR?
|
* Saves a configuration. //REDEFINES saveConfig CHILD BEHAVIOR?
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
void ScopeGadgetConfiguration::saveConfig(QSettings *qSettings) const
|
||||||
|
{
|
||||||
int plotCurveCount = m_PlotCurveConfigs.size();
|
int plotCurveCount = m_plotCurveConfigs.size();
|
||||||
int plotDatasLoadIndex = 0;
|
int plotDatasLoadIndex = 0;
|
||||||
|
|
||||||
qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion);
|
qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion);
|
||||||
@ -159,35 +145,33 @@ void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
|||||||
qSettings->setValue("refreshInterval", m_refreshInterval);
|
qSettings->setValue("refreshInterval", m_refreshInterval);
|
||||||
qSettings->setValue("plotCurveCount", plotCurveCount);
|
qSettings->setValue("plotCurveCount", plotCurveCount);
|
||||||
|
|
||||||
for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++)
|
for (plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) {
|
||||||
{
|
|
||||||
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
|
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
|
||||||
|
|
||||||
PlotCurveConfiguration* plotCurveConf = m_PlotCurveConfigs.at(plotDatasLoadIndex);
|
PlotCurveConfiguration *plotCurveConf = m_plotCurveConfigs.at(plotDatasLoadIndex);
|
||||||
qSettings->setValue("uavObject", plotCurveConf->uavObject);
|
qSettings->setValue("uavObject", plotCurveConf->uavObject);
|
||||||
qSettings->setValue("uavField", plotCurveConf->uavField);
|
qSettings->setValue("uavField", plotCurveConf->uavField);
|
||||||
qSettings->setValue("color", plotCurveConf->color);
|
qSettings->setValue("color", plotCurveConf->color);
|
||||||
qSettings->setValue("mathFunction", plotCurveConf->mathFunction);
|
qSettings->setValue("mathFunction", plotCurveConf->mathFunction);
|
||||||
qSettings->setValue("yScalePower", plotCurveConf->yScalePower);
|
qSettings->setValue("yScalePower", plotCurveConf->yScalePower);
|
||||||
qSettings->setValue("yMeanSamples", plotCurveConf->yMeanSamples);
|
qSettings->setValue("yMeanSamples", plotCurveConf->yMeanSamples);
|
||||||
qSettings->setValue("yMinimum", plotCurveConf->yMinimum);
|
qSettings->setValue("yMinimum", plotCurveConf->yMinimum);
|
||||||
qSettings->setValue("yMaximum", plotCurveConf->yMaximum);
|
qSettings->setValue("yMaximum", plotCurveConf->yMaximum);
|
||||||
|
qSettings->setValue("drawAntialiased", plotCurveConf->drawAntialiased);
|
||||||
|
|
||||||
qSettings->endGroup();
|
qSettings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
qSettings->setValue("LoggingEnabled", m_LoggingEnabled);
|
qSettings->setValue("LoggingEnabled", m_loggingEnabled);
|
||||||
qSettings->setValue("LoggingNewFileOnConnect", m_LoggingNewFileOnConnect);
|
qSettings->setValue("LoggingNewFileOnConnect", m_loggingNewFileOnConnect);
|
||||||
qSettings->setValue("LoggingPath", m_LoggingPath);
|
qSettings->setValue("LoggingPath", m_loggingPath);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetConfiguration::replacePlotCurveConfig(QList<PlotCurveConfiguration*> newPlotCurveConfigs)
|
void ScopeGadgetConfiguration::replacePlotCurveConfig(QList<PlotCurveConfiguration *> newPlotCurveConfigs)
|
||||||
{
|
{
|
||||||
clearPlotData();
|
clearPlotData();
|
||||||
|
|
||||||
m_PlotCurveConfigs.append(newPlotCurveConfigs);
|
m_plotCurveConfigs.append(newPlotCurveConfigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopeGadgetConfiguration::~ScopeGadgetConfiguration()
|
ScopeGadgetConfiguration::~ScopeGadgetConfiguration()
|
||||||
|
@ -35,66 +35,117 @@
|
|||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
struct PlotCurveConfiguration
|
struct PlotCurveConfiguration {
|
||||||
{
|
|
||||||
QString uavObject;
|
QString uavObject;
|
||||||
QString uavField;
|
QString uavField;
|
||||||
int yScalePower; //This is the power to which each value must be raised
|
int yScalePower; // This is the power to which each value must be raised
|
||||||
QRgb color;
|
QRgb color;
|
||||||
int yMeanSamples;
|
int yMeanSamples;
|
||||||
QString mathFunction;
|
QString mathFunction;
|
||||||
double yMinimum;
|
double yMinimum;
|
||||||
double yMaximum;
|
double yMaximum;
|
||||||
|
bool drawAntialiased;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScopeGadgetConfiguration : public IUAVGadgetConfiguration
|
class ScopeGadgetConfiguration : public IUAVGadgetConfiguration {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ScopeGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
explicit ScopeGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
|
||||||
|
|
||||||
~ScopeGadgetConfiguration();
|
~ScopeGadgetConfiguration();
|
||||||
|
|
||||||
//configuration setter functions
|
// configuration setter functions
|
||||||
void setPlotType(int value){m_plotType = value;}
|
void setPlotType(int value)
|
||||||
void setMathFunctionType(int value){m_mathFunctionType = value;}
|
{
|
||||||
void setDataSize(int value){m_dataSize = value;}
|
m_plotType = value;
|
||||||
void setRefreashInterval(int value){m_refreshInterval = value;}
|
}
|
||||||
void addPlotCurveConfig(PlotCurveConfiguration* value){m_PlotCurveConfigs.append(value);}
|
void setMathFunctionType(int value)
|
||||||
void replacePlotCurveConfig(QList<PlotCurveConfiguration*> m_PlotCurveConfigs);
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
void replacePlotCurveConfig(QList<PlotCurveConfiguration *> m_plotCurveConfigs);
|
||||||
|
|
||||||
|
|
||||||
//configurations getter functions
|
// Configurations getter functions
|
||||||
int plotType(){return m_plotType;}
|
int plotType()
|
||||||
int mathFunctionType(){return m_mathFunctionType;}
|
{
|
||||||
int dataSize(){return m_dataSize;}
|
return m_plotType;
|
||||||
int refreshInterval(){return m_refreshInterval;}
|
}
|
||||||
QList<PlotCurveConfiguration*> plotCurveConfigs(){return m_PlotCurveConfigs;}
|
int mathFunctionType()
|
||||||
|
{
|
||||||
|
return m_mathFunctionType;
|
||||||
|
}
|
||||||
|
int dataSize()
|
||||||
|
{
|
||||||
|
return m_dataSize;
|
||||||
|
}
|
||||||
|
int refreshInterval()
|
||||||
|
{
|
||||||
|
return m_refreshInterval;
|
||||||
|
}
|
||||||
|
QList<PlotCurveConfiguration *> 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();
|
IUAVGadgetConfiguration *clone();
|
||||||
|
|
||||||
bool getLoggingEnabled(){return m_LoggingEnabled;};
|
bool getLoggingEnabled()
|
||||||
bool getLoggingNewFileOnConnect(){return m_LoggingNewFileOnConnect;};
|
{
|
||||||
QString getLoggingPath(){return m_LoggingPath;};
|
return m_loggingEnabled;
|
||||||
void setLoggingEnabled(bool value){m_LoggingEnabled=value;};
|
}
|
||||||
void setLoggingNewFileOnConnect(bool value){m_LoggingNewFileOnConnect=value;};
|
bool getLoggingNewFileOnConnect()
|
||||||
void setLoggingPath(QString value){m_LoggingPath=value;};
|
{
|
||||||
|
return m_loggingNewFileOnConnect;
|
||||||
|
}
|
||||||
|
QString getLoggingPath()
|
||||||
|
{
|
||||||
|
return m_loggingPath;
|
||||||
|
}
|
||||||
|
void setLoggingEnabled(bool value)
|
||||||
|
{
|
||||||
|
m_loggingEnabled = value;
|
||||||
|
}
|
||||||
|
void setLoggingNewFileOnConnect(bool value)
|
||||||
|
{
|
||||||
|
m_loggingNewFileOnConnect = value;
|
||||||
|
}
|
||||||
|
void setLoggingPath(QString value)
|
||||||
|
{
|
||||||
|
m_loggingPath = value;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static const uint m_configurationStreamVersion = 1000;//Increment this if the stream format is not compatible with previous versions. This would cause existing configs to be discarded.
|
// Increment this if the stream format is not compatible with previous versions. This would cause existing configs to be discarded.
|
||||||
int m_plotType; //The type of the plot
|
static const uint m_configurationStreamVersion = 1000;
|
||||||
int m_dataSize; //The size of the data buffer to render in the curve plot
|
// The type of the plot
|
||||||
int m_refreshInterval; //The interval to replot the curve widget. The data buffer is refresh as the data comes in.
|
int m_plotType;
|
||||||
int m_mathFunctionType; //The type of math function to be used in the scope analysis
|
// The size of the data buffer to render in the curve plot
|
||||||
QList<PlotCurveConfiguration*> m_PlotCurveConfigs;
|
int m_dataSize;
|
||||||
|
// The interval to replot the curve widget. The data buffer is refresh as the data comes in.
|
||||||
|
int m_refreshInterval;
|
||||||
|
// The type of math function to be used in the scope analysis
|
||||||
|
int m_mathFunctionType;
|
||||||
|
QList<PlotCurveConfiguration *> m_plotCurveConfigs;
|
||||||
|
|
||||||
void clearPlotData();
|
void clearPlotData();
|
||||||
bool m_LoggingEnabled;
|
bool m_loggingEnabled;
|
||||||
bool m_LoggingNewFileOnConnect;
|
bool m_loggingNewFileOnConnect;
|
||||||
QString m_LoggingPath;
|
QString m_loggingPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCOPEGADGETCONFIGURATION_H
|
#endif // SCOPEGADGETCONFIGURATION_H
|
||||||
|
@ -36,96 +36,98 @@
|
|||||||
|
|
||||||
|
|
||||||
ScopeGadgetOptionsPage::ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent) :
|
ScopeGadgetOptionsPage::ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent) :
|
||||||
IOptionsPage(parent),
|
IOptionsPage(parent),
|
||||||
m_config(config)
|
m_config(config)
|
||||||
{
|
{
|
||||||
//nothing to do here...
|
// nothing to do here...
|
||||||
}
|
}
|
||||||
|
|
||||||
//creates options page widget (uses the UI file)
|
// creates options page widget (uses the UI file)
|
||||||
QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent)
|
QWidget *ScopeGadgetOptionsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
|
||||||
options_page = new Ui::ScopeGadgetOptionsPage();
|
options_page = new Ui::ScopeGadgetOptionsPage();
|
||||||
//main widget
|
// main widget
|
||||||
QWidget *optionsPageWidget = new QWidget;
|
QWidget *optionsPageWidget = new QWidget;
|
||||||
//main layout
|
// main layout
|
||||||
options_page->setupUi(optionsPageWidget);
|
options_page->setupUi(optionsPageWidget);
|
||||||
|
|
||||||
options_page->cmbPlotType->addItem("Sequential Plot","");
|
options_page->cmbPlotType->addItem("Sequential Plot", "");
|
||||||
options_page->cmbPlotType->addItem("Chronological Plot","");
|
options_page->cmbPlotType->addItem("Chronological Plot", "");
|
||||||
|
|
||||||
// Fills the combo boxes for the UAVObjects
|
// Fills the combo boxes for the UAVObjects
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
QList< QList<UAVDataObject*> > objList = objManager->getDataObjects();
|
QList< QList<UAVDataObject *> > objList = objManager->getDataObjects();
|
||||||
foreach (QList<UAVDataObject*> list, objList) {
|
foreach(QList<UAVDataObject *> list, objList) {
|
||||||
foreach (UAVDataObject* obj, list) {
|
foreach(UAVDataObject * obj, list) {
|
||||||
options_page->cmbUAVObjects->addItem(obj->getName());
|
options_page->cmbUAVObjects->addItem(obj->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Connect signals to slots cmbUAVObjects.currentIndexChanged
|
// Connect signals to slots cmbUAVObjects.currentIndexChanged
|
||||||
connect(options_page->cmbUAVObjects, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_cmbUAVObjects_currentIndexChanged(QString)));
|
connect(options_page->cmbUAVObjects, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_cmbUAVObjects_currentIndexChanged(QString)));
|
||||||
|
|
||||||
options_page->mathFunctionComboBox->addItem("None");
|
options_page->mathFunctionComboBox->addItem("None");
|
||||||
options_page->mathFunctionComboBox->addItem("Boxcar average");
|
options_page->mathFunctionComboBox->addItem("Boxcar average");
|
||||||
options_page->mathFunctionComboBox->addItem("Standard deviation");
|
options_page->mathFunctionComboBox->addItem("Standard deviation");
|
||||||
|
|
||||||
if(options_page->cmbUAVObjects->currentIndex() >= 0)
|
if (options_page->cmbUAVObjects->currentIndex() >= 0) {
|
||||||
on_cmbUAVObjects_currentIndexChanged(options_page->cmbUAVObjects->currentText());
|
on_cmbUAVObjects_currentIndexChanged(options_page->cmbUAVObjects->currentText());
|
||||||
|
}
|
||||||
|
|
||||||
options_page->cmbScale->addItem("10^-9", -9);
|
options_page->cmbScale->addItem("10^-9", -9);
|
||||||
options_page->cmbScale->addItem("10^-6", -6);
|
options_page->cmbScale->addItem("10^-6", -6);
|
||||||
options_page->cmbScale->addItem("10^-5",-5);
|
options_page->cmbScale->addItem("10^-5", -5);
|
||||||
options_page->cmbScale->addItem("10^-4",-4);
|
options_page->cmbScale->addItem("10^-4", -4);
|
||||||
options_page->cmbScale->addItem("10^-3",-3);
|
options_page->cmbScale->addItem("10^-3", -3);
|
||||||
options_page->cmbScale->addItem("10^-2",-2);
|
options_page->cmbScale->addItem("10^-2", -2);
|
||||||
options_page->cmbScale->addItem("10^-1",-1);
|
options_page->cmbScale->addItem("10^-1", -1);
|
||||||
options_page->cmbScale->addItem("1",0);
|
options_page->cmbScale->addItem("1", 0);
|
||||||
options_page->cmbScale->addItem("10^1",1);
|
options_page->cmbScale->addItem("10^1", 1);
|
||||||
options_page->cmbScale->addItem("10^2",2);
|
options_page->cmbScale->addItem("10^2", 2);
|
||||||
options_page->cmbScale->addItem("10^3",3);
|
options_page->cmbScale->addItem("10^3", 3);
|
||||||
options_page->cmbScale->addItem("10^4",4);
|
options_page->cmbScale->addItem("10^4", 4);
|
||||||
options_page->cmbScale->addItem("10^5",5);
|
options_page->cmbScale->addItem("10^5", 5);
|
||||||
options_page->cmbScale->addItem("10^6",6);
|
options_page->cmbScale->addItem("10^6", 6);
|
||||||
options_page->cmbScale->addItem("10^9",9);
|
options_page->cmbScale->addItem("10^9", 9);
|
||||||
options_page->cmbScale->addItem("10^12",12);
|
options_page->cmbScale->addItem("10^12", 12);
|
||||||
options_page->cmbScale->setCurrentIndex(7);
|
options_page->cmbScale->setCurrentIndex(7);
|
||||||
|
|
||||||
//Set widget values from settings
|
// Set widget values from settings
|
||||||
options_page->cmbPlotType->setCurrentIndex(m_config->plotType());
|
options_page->cmbPlotType->setCurrentIndex(m_config->plotType());
|
||||||
options_page->mathFunctionComboBox->setCurrentIndex(m_config->mathFunctionType());
|
options_page->mathFunctionComboBox->setCurrentIndex(m_config->mathFunctionType());
|
||||||
options_page->spnDataSize->setValue(m_config->dataSize());
|
options_page->spnDataSize->setValue(m_config->dataSize());
|
||||||
options_page->spnRefreshInterval->setValue(m_config->refreshInterval());
|
options_page->spnRefreshInterval->setValue(m_config->refreshInterval());
|
||||||
|
|
||||||
//add the configured curves
|
// add the configured curves
|
||||||
foreach (PlotCurveConfiguration* plotData, m_config->plotCurveConfigs()) {
|
foreach(PlotCurveConfiguration * plotData, m_config->plotCurveConfigs()) {
|
||||||
|
|
||||||
QString uavObject = plotData->uavObject;
|
QString uavObject = plotData->uavObject;
|
||||||
QString uavField = plotData->uavField;
|
QString uavField = plotData->uavField;
|
||||||
int scale = plotData->yScalePower;
|
int scale = plotData->yScalePower;
|
||||||
int mean = plotData->yMeanSamples;
|
int mean = plotData->yMeanSamples;
|
||||||
QString mathFunction = plotData->mathFunction;
|
QString mathFunction = plotData->mathFunction;
|
||||||
QVariant varColor = plotData->color;
|
QVariant varColor = plotData->color;
|
||||||
|
bool antialiased = plotData->drawAntialiased;
|
||||||
|
|
||||||
addPlotCurveConfig(uavObject,uavField,scale,mean,mathFunction,varColor);
|
addPlotCurveConfig(uavObject, uavField, scale, mean, mathFunction, varColor, antialiased);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_config->plotCurveConfigs().count() > 0)
|
if (m_config->plotCurveConfigs().count() > 0) {
|
||||||
options_page->lstCurves->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
options_page->lstCurves->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
||||||
|
}
|
||||||
|
|
||||||
connect(options_page->btnAddCurve, SIGNAL(clicked()), this, SLOT(on_btnAddCurve_clicked()));
|
connect(options_page->btnAddCurve, SIGNAL(clicked()), this, SLOT(on_btnAddCurve_clicked()));
|
||||||
connect(options_page->btnRemoveCurve, SIGNAL(clicked()), this, SLOT(on_btnRemoveCurve_clicked()));
|
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->lstCurves, SIGNAL(currentRowChanged(int)), this, SLOT(on_lstCurves_currentRowChanged(int)));
|
||||||
connect(options_page->btnColor, SIGNAL(clicked()), this, SLOT(on_btnColor_clicked()));
|
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->mathFunctionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_mathFunctionComboBox_currentIndexChanged(int)));
|
||||||
connect(options_page->spnRefreshInterval, SIGNAL(valueChanged(int )), this, SLOT(on_spnRefreshInterval_valueChanged(int)));
|
connect(options_page->spnRefreshInterval, SIGNAL(valueChanged(int)), this, SLOT(on_spnRefreshInterval_valueChanged(int)));
|
||||||
|
|
||||||
setYAxisWidgetFromPlotCurve();
|
setYAxisWidgetFromPlotCurve();
|
||||||
|
|
||||||
//logging path setup
|
// logging path setup
|
||||||
options_page->LoggingPath->setExpectedKind(Utils::PathChooser::Directory);
|
options_page->LoggingPath->setExpectedKind(Utils::PathChooser::Directory);
|
||||||
options_page->LoggingPath->setPromptDialogTitle(tr("Choose Logging Directory"));
|
options_page->LoggingPath->setPromptDialogTitle(tr("Choose Logging Directory"));
|
||||||
options_page->LoggingPath->setPath(m_config->getLoggingPath());
|
options_page->LoggingPath->setPath(m_config->getLoggingPath());
|
||||||
@ -134,89 +136,91 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
connect(options_page->LoggingEnable, SIGNAL(clicked()), this, SLOT(on_loggingEnable_clicked()));
|
connect(options_page->LoggingEnable, SIGNAL(clicked()), this, SLOT(on_loggingEnable_clicked()));
|
||||||
on_loggingEnable_clicked();
|
on_loggingEnable_clicked();
|
||||||
|
|
||||||
//Disable mouse wheel events
|
// Disable mouse wheel events
|
||||||
foreach( QSpinBox * sp, findChildren<QSpinBox*>() ) {
|
foreach(QSpinBox * sp, findChildren<QSpinBox *>()) {
|
||||||
sp->installEventFilter( this );
|
sp->installEventFilter(this);
|
||||||
}
|
}
|
||||||
foreach( QDoubleSpinBox * sp, findChildren<QDoubleSpinBox*>() ) {
|
foreach(QDoubleSpinBox * sp, findChildren<QDoubleSpinBox *>()) {
|
||||||
sp->installEventFilter( this );
|
sp->installEventFilter(this);
|
||||||
}
|
}
|
||||||
foreach( QSlider * sp, findChildren<QSlider*>() ) {
|
foreach(QSlider * sp, findChildren<QSlider *>()) {
|
||||||
sp->installEventFilter( this );
|
sp->installEventFilter(this);
|
||||||
}
|
}
|
||||||
foreach( QComboBox * sp, findChildren<QComboBox*>() ) {
|
foreach(QComboBox * sp, findChildren<QComboBox *>()) {
|
||||||
sp->installEventFilter( this );
|
sp->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return optionsPageWidget;
|
return optionsPageWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScopeGadgetOptionsPage::eventFilter( QObject * obj, QEvent * evt ) {
|
bool ScopeGadgetOptionsPage::eventFilter(QObject *obj, QEvent *evt)
|
||||||
//Filter all wheel events, and ignore them
|
{
|
||||||
if ( evt->type() == QEvent::Wheel &&
|
// Filter all wheel events, and ignore them
|
||||||
(qobject_cast<QAbstractSpinBox*>( obj ) ||
|
if (evt->type() == QEvent::Wheel &&
|
||||||
qobject_cast<QComboBox*>( obj ) ||
|
(qobject_cast<QAbstractSpinBox *>(obj) ||
|
||||||
qobject_cast<QAbstractSlider*>( obj ) ))
|
qobject_cast<QComboBox *>(obj) ||
|
||||||
{
|
qobject_cast<QAbstractSlider *>(obj))) {
|
||||||
evt->ignore();
|
evt->ignore();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return ScopeGadgetOptionsPage::eventFilter( obj, evt );
|
return ScopeGadgetOptionsPage::eventFilter(obj, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::on_mathFunctionComboBox_currentIndexChanged(int currentIndex){
|
void ScopeGadgetOptionsPage::on_mathFunctionComboBox_currentIndexChanged(int currentIndex)
|
||||||
if (currentIndex > 0){
|
{
|
||||||
|
if (currentIndex > 0) {
|
||||||
options_page->spnMeanSamples->setEnabled(true);
|
options_page->spnMeanSamples->setEnabled(true);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
options_page->spnMeanSamples->setEnabled(false);
|
options_page->spnMeanSamples->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::on_btnColor_clicked()
|
void ScopeGadgetOptionsPage::on_btnColor_clicked()
|
||||||
{
|
{
|
||||||
QColor color = QColorDialog::getColor( QColor(options_page->btnColor->text()));
|
QColor color = QColorDialog::getColor(QColor(options_page->btnColor->text()));
|
||||||
if (color.isValid()) {
|
|
||||||
setButtonColor(color);
|
if (color.isValid()) {
|
||||||
}
|
setButtonColor(color);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Populate the widgets that containts the configs for the Y-Axis from
|
\brief Populate the widgets that containts the configs for the Y-Axis from
|
||||||
the selected plot curve
|
the selected plot curve
|
||||||
*/
|
*/
|
||||||
void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve()
|
void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve()
|
||||||
{
|
{
|
||||||
bool parseOK = false;
|
bool parseOK = false;
|
||||||
QListWidgetItem* listItem = options_page->lstCurves->currentItem();
|
QListWidgetItem *listItem = options_page->lstCurves->currentItem();
|
||||||
|
|
||||||
if(listItem == 0)
|
if (listItem == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//WHAT IS UserRole DOING?
|
// WHAT IS UserRole DOING?
|
||||||
int currentIndex = options_page->cmbUAVObjects->findText( listItem->data(Qt::UserRole + 0).toString());
|
int currentIndex = options_page->cmbUAVObjects->findText(listItem->data(Qt::UserRole + 0).toString());
|
||||||
options_page->cmbUAVObjects->setCurrentIndex(currentIndex);
|
options_page->cmbUAVObjects->setCurrentIndex(currentIndex);
|
||||||
|
|
||||||
currentIndex = options_page->cmbUAVField->findText( listItem->data(Qt::UserRole + 1).toString());
|
currentIndex = options_page->cmbUAVField->findText(listItem->data(Qt::UserRole + 1).toString());
|
||||||
options_page->cmbUAVField->setCurrentIndex(currentIndex);
|
options_page->cmbUAVField->setCurrentIndex(currentIndex);
|
||||||
|
|
||||||
currentIndex = options_page->cmbScale->findData( listItem->data(Qt::UserRole + 2), Qt::UserRole, Qt::MatchExactly);
|
currentIndex = options_page->cmbScale->findData(listItem->data(Qt::UserRole + 2), Qt::UserRole, Qt::MatchExactly);
|
||||||
options_page->cmbScale->setCurrentIndex(currentIndex);
|
options_page->cmbScale->setCurrentIndex(currentIndex);
|
||||||
|
|
||||||
QVariant varColor = listItem->data(Qt::UserRole + 3);
|
QVariant varColor = listItem->data(Qt::UserRole + 3);
|
||||||
int rgb = varColor.toInt(&parseOK);
|
int rgb = varColor.toInt(&parseOK);
|
||||||
|
|
||||||
setButtonColor(QColor((QRgb)rgb));
|
setButtonColor(QColor((QRgb)rgb));
|
||||||
|
|
||||||
int mean = listItem->data(Qt::UserRole + 4).toInt(&parseOK);
|
int mean = listItem->data(Qt::UserRole + 4).toInt(&parseOK);
|
||||||
if(!parseOK) mean = 1;
|
if (!parseOK) {
|
||||||
|
mean = 1;
|
||||||
|
}
|
||||||
options_page->spnMeanSamples->setValue(mean);
|
options_page->spnMeanSamples->setValue(mean);
|
||||||
|
|
||||||
currentIndex = options_page->mathFunctionComboBox->findText( listItem->data(Qt::UserRole + 5).toString());
|
currentIndex = options_page->mathFunctionComboBox->findText(listItem->data(Qt::UserRole + 5).toString());
|
||||||
options_page->mathFunctionComboBox->setCurrentIndex(currentIndex);
|
options_page->mathFunctionComboBox->setCurrentIndex(currentIndex);
|
||||||
|
options_page->drawAntialiasedCheckBox->setChecked(listItem->data(Qt::UserRole + 6).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
|
void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
|
||||||
@ -227,33 +231,32 @@ void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief When a new UAVObject is selected, populate the UAVObject field combo box with the correct values.
|
\brief When a new UAVObject is selected, populate the UAVObject field combo box with the correct values.
|
||||||
*/
|
*/
|
||||||
void ScopeGadgetOptionsPage::on_cmbUAVObjects_currentIndexChanged(QString val)
|
void ScopeGadgetOptionsPage::on_cmbUAVObjects_currentIndexChanged(QString val)
|
||||||
{
|
{
|
||||||
options_page->cmbUAVField->clear();
|
options_page->cmbUAVField->clear();
|
||||||
|
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(val) );
|
UAVDataObject *obj = dynamic_cast<UAVDataObject *>(objManager->getObject(val));
|
||||||
|
|
||||||
if (obj == NULL)
|
if (obj == NULL) {
|
||||||
return; // Rare case: the config contained a UAVObject name which does not exist anymore.
|
return; // Rare case: the config contained a UAVObject name which does not exist anymore.
|
||||||
|
}
|
||||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
QList<UAVObjectField *> fieldList = obj->getFields();
|
||||||
foreach (UAVObjectField* field, fieldList) {
|
foreach(UAVObjectField * field, fieldList) {
|
||||||
if(field->getType() == UAVObjectField::STRING || field->getType() == UAVObjectField::ENUM )
|
if (field->getType() == UAVObjectField::STRING || field->getType() == UAVObjectField::ENUM) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(field->getElementNames().count() > 1)
|
if (field->getElementNames().count() > 1) {
|
||||||
{
|
foreach(QString elemName, field->getElementNames()) {
|
||||||
foreach(QString elemName , field->getElementNames())
|
|
||||||
{
|
|
||||||
options_page->cmbUAVField->addItem(field->getName() + "-" + elemName);
|
options_page->cmbUAVField->addItem(field->getName() + "-" + elemName);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
options_page->cmbUAVField->addItem(field->getName());
|
options_page->cmbUAVField->addItem(field->getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,130 +270,131 @@ void ScopeGadgetOptionsPage::apply()
|
|||||||
{
|
{
|
||||||
bool parseOK = false;
|
bool parseOK = false;
|
||||||
|
|
||||||
//Apply configuration changes
|
// Apply configuration changes
|
||||||
m_config->setPlotType(options_page->cmbPlotType->currentIndex());
|
m_config->setPlotType(options_page->cmbPlotType->currentIndex());
|
||||||
m_config->setMathFunctionType(options_page->mathFunctionComboBox->currentIndex());
|
m_config->setMathFunctionType(options_page->mathFunctionComboBox->currentIndex());
|
||||||
m_config->setDataSize(options_page->spnDataSize->value());
|
m_config->setDataSize(options_page->spnDataSize->value());
|
||||||
m_config->setRefreashInterval(options_page->spnRefreshInterval->value());
|
m_config->setRefreashInterval(options_page->spnRefreshInterval->value());
|
||||||
|
|
||||||
QList<PlotCurveConfiguration*> plotCurveConfigs;
|
QList<PlotCurveConfiguration *> plotCurveConfigs;
|
||||||
for(int iIndex = 0; iIndex < options_page->lstCurves->count();iIndex++) {
|
for (int iIndex = 0; iIndex < options_page->lstCurves->count(); iIndex++) {
|
||||||
QListWidgetItem* listItem = options_page->lstCurves->item(iIndex);
|
QListWidgetItem *listItem = options_page->lstCurves->item(iIndex);
|
||||||
|
|
||||||
PlotCurveConfiguration* newPlotCurveConfigs = new PlotCurveConfiguration();
|
PlotCurveConfiguration *newPlotCurveConfigs = new PlotCurveConfiguration();
|
||||||
newPlotCurveConfigs->uavObject = listItem->data(Qt::UserRole + 0).toString();
|
newPlotCurveConfigs->uavObject = listItem->data(Qt::UserRole + 0).toString();
|
||||||
newPlotCurveConfigs->uavField = listItem->data(Qt::UserRole + 1).toString();
|
newPlotCurveConfigs->uavField = listItem->data(Qt::UserRole + 1).toString();
|
||||||
newPlotCurveConfigs->yScalePower = listItem->data(Qt::UserRole + 2).toInt(&parseOK);
|
newPlotCurveConfigs->yScalePower = listItem->data(Qt::UserRole + 2).toInt(&parseOK);
|
||||||
if(!parseOK)
|
if (!parseOK) {
|
||||||
newPlotCurveConfigs->yScalePower = 0;
|
newPlotCurveConfigs->yScalePower = 0;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant varColor = listItem->data(Qt::UserRole + 3);
|
QVariant varColor = listItem->data(Qt::UserRole + 3);
|
||||||
int rgb = varColor.toInt(&parseOK);
|
int rgb = varColor.toInt(&parseOK);
|
||||||
if(!parseOK)
|
if (!parseOK) {
|
||||||
newPlotCurveConfigs->color = QColor(Qt::black).rgb();
|
newPlotCurveConfigs->color = QColor(Qt::black).rgb();
|
||||||
else
|
} else {
|
||||||
newPlotCurveConfigs->color = (QRgb)rgb;
|
newPlotCurveConfigs->color = (QRgb)rgb;
|
||||||
|
}
|
||||||
|
|
||||||
newPlotCurveConfigs->yMeanSamples = listItem->data(Qt::UserRole + 4).toInt(&parseOK);
|
newPlotCurveConfigs->yMeanSamples = listItem->data(Qt::UserRole + 4).toInt(&parseOK);
|
||||||
if(!parseOK)
|
if (!parseOK) {
|
||||||
newPlotCurveConfigs->yMeanSamples = 1;
|
newPlotCurveConfigs->yMeanSamples = 1;
|
||||||
|
}
|
||||||
|
|
||||||
newPlotCurveConfigs->mathFunction = listItem->data(Qt::UserRole + 5).toString();
|
newPlotCurveConfigs->mathFunction = listItem->data(Qt::UserRole + 5).toString();
|
||||||
|
newPlotCurveConfigs->drawAntialiased = listItem->data(Qt::UserRole + 6).toBool();
|
||||||
|
|
||||||
plotCurveConfigs.append(newPlotCurveConfigs);
|
plotCurveConfigs.append(newPlotCurveConfigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_config->replacePlotCurveConfig(plotCurveConfigs);
|
m_config->replacePlotCurveConfig(plotCurveConfigs);
|
||||||
|
|
||||||
//save the logging config
|
// save the logging config
|
||||||
m_config->setLoggingPath(options_page->LoggingPath->path());
|
m_config->setLoggingPath(options_page->LoggingPath->path());
|
||||||
m_config->setLoggingNewFileOnConnect(options_page->LoggingConnect->isChecked());
|
m_config->setLoggingNewFileOnConnect(options_page->LoggingConnect->isChecked());
|
||||||
m_config->setLoggingEnabled(options_page->LoggingEnable->isChecked());
|
m_config->setLoggingEnabled(options_page->LoggingEnable->isChecked());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Add a new curve to the plot.
|
\brief Add a new curve to the plot.
|
||||||
*/
|
*/
|
||||||
void ScopeGadgetOptionsPage::on_btnAddCurve_clicked()
|
void ScopeGadgetOptionsPage::on_btnAddCurve_clicked()
|
||||||
{
|
{
|
||||||
bool parseOK = false;
|
bool parseOK = false;
|
||||||
QString uavObject = options_page->cmbUAVObjects->currentText();
|
QString uavObject = options_page->cmbUAVObjects->currentText();
|
||||||
QString uavField = options_page->cmbUAVField->currentText();
|
QString uavField = options_page->cmbUAVField->currentText();
|
||||||
int scale = options_page->cmbScale->itemData(options_page->cmbScale->currentIndex()).toInt(&parseOK);
|
int scale = options_page->cmbScale->itemData(options_page->cmbScale->currentIndex()).toInt(&parseOK);
|
||||||
|
|
||||||
if(!parseOK)
|
if (!parseOK) {
|
||||||
scale = 0;
|
scale = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int mean = options_page->spnMeanSamples->value();
|
int mean = options_page->spnMeanSamples->value();
|
||||||
QString mathFunction = options_page->mathFunctionComboBox->currentText();
|
QString mathFunction = options_page->mathFunctionComboBox->currentText();
|
||||||
|
|
||||||
|
|
||||||
QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb();
|
QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb();
|
||||||
|
|
||||||
//Find an existing plot curve config based on the uavobject and uav field. If it
|
bool antialiased = options_page->drawAntialiasedCheckBox->isChecked();
|
||||||
//exists, update it, else add a new one.
|
// Find an existing plot curve config based on the uavobject and uav field. If it
|
||||||
if(options_page->lstCurves->count() &&
|
// exists, update it, else add a new one.
|
||||||
options_page->lstCurves->currentItem()->text() == uavObject + "." + uavField)
|
if (options_page->lstCurves->count() &&
|
||||||
{
|
options_page->lstCurves->currentItem()->text() == uavObject + "." + uavField) {
|
||||||
QListWidgetItem *listWidgetItem = options_page->lstCurves->currentItem();
|
QListWidgetItem *listWidgetItem = options_page->lstCurves->currentItem();
|
||||||
setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,mean,mathFunction,varColor);
|
setCurvePlotProperties(listWidgetItem, uavObject, uavField, scale, mean, mathFunction, varColor, antialiased);
|
||||||
}else
|
} else {
|
||||||
{
|
addPlotCurveConfig(uavObject, uavField, scale, mean, mathFunction, varColor, antialiased);
|
||||||
addPlotCurveConfig(uavObject,uavField,scale,mean,mathFunction,varColor);
|
|
||||||
|
|
||||||
options_page->lstCurves->setCurrentRow(options_page->lstCurves->count() - 1);
|
options_page->lstCurves->setCurrentRow(options_page->lstCurves->count() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor)
|
void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor, bool antialias)
|
||||||
{
|
{
|
||||||
//Add a new curve config to the list
|
// Add a new curve config to the list
|
||||||
QString listItemDisplayText = uavObject + "." + uavField;
|
QString listItemDisplayText = uavObject + "." + uavField;
|
||||||
|
|
||||||
options_page->lstCurves->addItem(listItemDisplayText);
|
options_page->lstCurves->addItem(listItemDisplayText);
|
||||||
QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1);
|
QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1);
|
||||||
|
|
||||||
setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,mean,mathFunction,varColor);
|
setCurvePlotProperties(listWidgetItem, uavObject, uavField, scale, mean, mathFunction, varColor, antialias);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetItem,QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor)
|
void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetItem, QString uavObject, QString uavField, int scale,
|
||||||
|
int mean, QString mathFunction, QVariant varColor, bool antialias)
|
||||||
{
|
{
|
||||||
bool parseOK = false;
|
bool parseOK = false;
|
||||||
|
|
||||||
//Set the properties of the newly added list item
|
// Set the properties of the newly added list item
|
||||||
QString listItemDisplayText = uavObject + "." + uavField;
|
|
||||||
QRgb rgbColor = (QRgb)varColor.toInt(&parseOK);
|
QRgb rgbColor = (QRgb)varColor.toInt(&parseOK);
|
||||||
QColor color = QColor( rgbColor );
|
QColor color = QColor(rgbColor);
|
||||||
//listWidgetItem->setText(listItemDisplayText);
|
|
||||||
listWidgetItem->setTextColor( color );
|
|
||||||
|
|
||||||
//Store some additional data for the plot curve on the list item
|
listWidgetItem->setTextColor(color);
|
||||||
listWidgetItem->setData(Qt::UserRole + 0,QVariant(uavObject));
|
|
||||||
listWidgetItem->setData(Qt::UserRole + 1,QVariant(uavField));
|
// Store some additional data for the plot curve on the list item
|
||||||
listWidgetItem->setData(Qt::UserRole + 2,QVariant(scale));
|
listWidgetItem->setData(Qt::UserRole + 0, QVariant(uavObject));
|
||||||
listWidgetItem->setData(Qt::UserRole + 3,varColor);
|
listWidgetItem->setData(Qt::UserRole + 1, QVariant(uavField));
|
||||||
listWidgetItem->setData(Qt::UserRole + 4,QVariant(mean));
|
listWidgetItem->setData(Qt::UserRole + 2, QVariant(scale));
|
||||||
listWidgetItem->setData(Qt::UserRole + 5,QVariant(mathFunction));
|
listWidgetItem->setData(Qt::UserRole + 3, varColor);
|
||||||
|
listWidgetItem->setData(Qt::UserRole + 4, QVariant(mean));
|
||||||
|
listWidgetItem->setData(Qt::UserRole + 5, QVariant(mathFunction));
|
||||||
|
listWidgetItem->setData(Qt::UserRole + 6, QVariant(antialias));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Remove a curve config from the plot.
|
Remove a curve config from the plot.
|
||||||
*/
|
*/
|
||||||
void ScopeGadgetOptionsPage::on_btnRemoveCurve_clicked()
|
void ScopeGadgetOptionsPage::on_btnRemoveCurve_clicked()
|
||||||
{
|
{
|
||||||
options_page->lstCurves->takeItem(options_page->lstCurves->currentIndex().row());
|
options_page->lstCurves->takeItem(options_page->lstCurves->currentIndex().row());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::finish()
|
void ScopeGadgetOptionsPage::finish()
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
When a different plot curve config is selected, populate its values into the widgets.
|
When a different plot curve config is selected, populate its values into the widgets.
|
||||||
*/
|
*/
|
||||||
void ScopeGadgetOptionsPage::on_lstCurves_currentRowChanged(int currentRow)
|
void ScopeGadgetOptionsPage::on_lstCurves_currentRowChanged(int currentRow)
|
||||||
{
|
{
|
||||||
Q_UNUSED(currentRow);
|
Q_UNUSED(currentRow);
|
||||||
@ -398,15 +402,15 @@ void ScopeGadgetOptionsPage::on_lstCurves_currentRowChanged(int currentRow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::on_loggingEnable_clicked()
|
void ScopeGadgetOptionsPage::on_loggingEnable_clicked()
|
||||||
{
|
{
|
||||||
bool en = options_page->LoggingEnable->isChecked();
|
bool en = options_page->LoggingEnable->isChecked();
|
||||||
|
|
||||||
options_page->LoggingPath->setEnabled(en);
|
options_page->LoggingPath->setEnabled(en);
|
||||||
options_page->LoggingConnect->setEnabled(en);
|
options_page->LoggingConnect->setEnabled(en);
|
||||||
options_page->LoggingLabel->setEnabled(en);
|
options_page->LoggingLabel->setEnabled(en);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
void ScopeGadgetOptionsPage::on_spnRefreshInterval_valueChanged(int)
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::on_spnRefreshInterval_valueChanged(int )
|
|
||||||
{
|
{
|
||||||
validateRefreshInterval();
|
validateRefreshInterval();
|
||||||
}
|
}
|
||||||
@ -415,19 +419,19 @@ void ScopeGadgetOptionsPage::validateRefreshInterval()
|
|||||||
{
|
{
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
for(int iIndex = 0; iIndex < options_page->lstCurves->count();iIndex++) {
|
|
||||||
QListWidgetItem* listItem = options_page->lstCurves->item(iIndex);
|
|
||||||
|
|
||||||
QString uavObject = listItem->data(Qt::UserRole + 0).toString();
|
for (int iIndex = 0; iIndex < options_page->lstCurves->count(); iIndex++) {
|
||||||
|
QListWidgetItem *listItem = options_page->lstCurves->item(iIndex);
|
||||||
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject((uavObject)));
|
QString uavObject = listItem->data(Qt::UserRole + 0).toString();
|
||||||
if(!obj) {
|
|
||||||
|
UAVDataObject *obj = dynamic_cast<UAVDataObject *>(objManager->getObject((uavObject)));
|
||||||
|
if (!obj) {
|
||||||
qDebug() << "Object " << uavObject << " is missing";
|
qDebug() << "Object " << uavObject << " is missing";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options_page->spnRefreshInterval->value() < obj->getMetadata().flightTelemetryUpdatePeriod)
|
if (options_page->spnRefreshInterval->value() < obj->getMetadata().flightTelemetryUpdatePeriod) {
|
||||||
{
|
|
||||||
options_page->lblWarnings->setText("The refresh interval is faster than some or all telemetry objects.");
|
options_page->lblWarnings->setText("The refresh interval is faster than some or all telemetry objects.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -435,4 +439,3 @@ void ScopeGadgetOptionsPage::validateRefreshInterval()
|
|||||||
|
|
||||||
options_page->lblWarnings->setText("");
|
options_page->lblWarnings->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,22 +38,19 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QtGui/QColorDialog>
|
#include <QtGui/QColorDialog>
|
||||||
|
|
||||||
namespace Core
|
namespace Core {
|
||||||
{
|
|
||||||
class IUAVGadgetConfiguration;
|
class IUAVGadgetConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ScopeGadgetConfiguration;
|
class ScopeGadgetConfiguration;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui {
|
||||||
{
|
|
||||||
class ScopeGadgetOptionsPage;
|
class ScopeGadgetOptionsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
class ScopeGadgetOptionsPage : public IOptionsPage
|
class ScopeGadgetOptionsPage : public IOptionsPage {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent = 0);
|
explicit ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent = 0);
|
||||||
@ -66,23 +63,23 @@ private:
|
|||||||
Ui::ScopeGadgetOptionsPage *options_page;
|
Ui::ScopeGadgetOptionsPage *options_page;
|
||||||
ScopeGadgetConfiguration *m_config;
|
ScopeGadgetConfiguration *m_config;
|
||||||
|
|
||||||
void addPlotCurveConfig(QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor);
|
void addPlotCurveConfig(QString uavObject, QString uavField, int scale, int mean, QString mathFunction, QVariant varColor, bool antialias);
|
||||||
void setCurvePlotProperties(QListWidgetItem *listWidgetItem, 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, bool antialias);
|
||||||
void setYAxisWidgetFromPlotCurve();
|
void setYAxisWidgetFromPlotCurve();
|
||||||
void setButtonColor(const QColor &color);
|
void setButtonColor(const QColor &color);
|
||||||
void validateRefreshInterval();
|
void validateRefreshInterval();
|
||||||
bool eventFilter( QObject * obj, QEvent * evt );
|
bool eventFilter(QObject *obj, QEvent *evt);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_spnRefreshInterval_valueChanged(int );
|
void on_spnRefreshInterval_valueChanged(int);
|
||||||
void on_lstCurves_currentRowChanged(int currentRow);
|
void on_lstCurves_currentRowChanged(int currentRow);
|
||||||
void on_btnRemoveCurve_clicked();
|
void on_btnRemoveCurve_clicked();
|
||||||
void on_btnAddCurve_clicked();
|
void on_btnAddCurve_clicked();
|
||||||
void on_cmbUAVObjects_currentIndexChanged(QString val);
|
void on_cmbUAVObjects_currentIndexChanged(QString val);
|
||||||
void on_btnColor_clicked();
|
void on_btnColor_clicked();
|
||||||
void on_mathFunctionComboBox_currentIndexChanged(int currentIndex);
|
void on_mathFunctionComboBox_currentIndexChanged(int currentIndex);
|
||||||
void on_loggingEnable_clicked();
|
void on_loggingEnable_clicked();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCOPEGADGETOPTIONSPAGE_H
|
#endif // SCOPEGADGETOPTIONSPAGE_H
|
||||||
|
@ -176,38 +176,18 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="mathFunctionLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Color:</string>
|
<string>Math function:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QPushButton" name="btnColor">
|
<widget class="QComboBox" name="mathFunctionComboBox">
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::StrongFocus</enum>
|
<enum>Qt::StrongFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
|
||||||
<string>Choose</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="10" column="0">
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>Y-axis scale factor:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="10" column="1">
|
|
||||||
<widget class="QComboBox" name="cmbScale">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::StrongFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="editable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="8" column="0">
|
||||||
@ -248,18 +228,51 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="mathFunctionLabel">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Math function:</string>
|
<string>Color:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="QComboBox" name="mathFunctionComboBox">
|
<widget class="QPushButton" name="btnColor">
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::StrongFocus</enum>
|
<enum>Qt::StrongFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Choose</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y-axis scale factor:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="1">
|
||||||
|
<widget class="QComboBox" name="cmbScale">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="1">
|
||||||
|
<widget class="QCheckBox" name="drawAntialiasedCheckBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Check this to have the curve drawn antialiased.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Draw Antialiased</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -277,7 +290,7 @@
|
|||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>100</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
@ -288,8 +301,7 @@
|
|||||||
<string>Add a new curve to the scope, or update it if the UAVObject and UAVField is the same.</string>
|
<string>Add a new curve to the scope, or update it if the UAVObject and UAVField is the same.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add
|
<string>Add / Update</string>
|
||||||
Update</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -299,8 +311,7 @@ Update</string>
|
|||||||
<string>Remove the curve from the scope.</string>
|
<string>Remove the curve from the scope.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remove
|
<string>Remove</string>
|
||||||
</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -310,12 +321,12 @@ Update</string>
|
|||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
<property name="sizeType">
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>15</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
@ -331,8 +342,8 @@ Update</string>
|
|||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>20</width>
|
||||||
<height>200</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
@ -347,6 +358,19 @@ Update</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -53,16 +53,16 @@
|
|||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
//using namespace Core;
|
// using namespace Core;
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
||||||
ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
|
ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
|
||||||
{
|
{
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
// canvas()->setMouseTracking(true);
|
// canvas()->setMouseTracking(true);
|
||||||
|
|
||||||
//Setup the timer that replots data
|
// Setup the timer that replots data
|
||||||
replotTimer = new QTimer(this);
|
replotTimer = new QTimer(this);
|
||||||
connect(replotTimer, SIGNAL(timeout()), this, SLOT(replotNewData()));
|
connect(replotTimer, SIGNAL(timeout()), this, SLOT(replotNewData()));
|
||||||
|
|
||||||
@ -71,179 +71,191 @@ ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
|
|||||||
// Also listen to disconnect actions from the user
|
// Also listen to disconnect actions from the user
|
||||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||||
connect(cm, SIGNAL(deviceAboutToDisconnect()), this, SLOT(stopPlotting()));
|
connect(cm, SIGNAL(deviceAboutToDisconnect()), this, SLOT(stopPlotting()));
|
||||||
connect(cm, SIGNAL(deviceConnected(QIODevice*)), this, SLOT(startPlotting()));
|
connect(cm, SIGNAL(deviceConnected(QIODevice *)), this, SLOT(startPlotting()));
|
||||||
|
|
||||||
m_csvLoggingStarted=0;
|
m_csvLoggingStarted = 0;
|
||||||
m_csvLoggingEnabled=0;
|
m_csvLoggingEnabled = 0;
|
||||||
m_csvLoggingHeaderSaved=0;
|
m_csvLoggingHeaderSaved = 0;
|
||||||
m_csvLoggingDataSaved=0;
|
m_csvLoggingDataSaved = 0;
|
||||||
m_csvLoggingDataUpdated=0;
|
m_csvLoggingDataUpdated = 0;
|
||||||
m_csvLoggingNameSet=0;
|
m_csvLoggingNameSet = 0;
|
||||||
m_csvLoggingConnected=0;
|
m_csvLoggingConnected = 0;
|
||||||
m_csvLoggingNewFileOnConnect=0;
|
m_csvLoggingNewFileOnConnect = 0;
|
||||||
m_csvLoggingPath = QString("./csvlogging/");
|
m_csvLoggingPath = QString("./csvlogging/");
|
||||||
m_csvLoggingStartTime = QDateTime::currentDateTime();
|
m_csvLoggingStartTime = QDateTime::currentDateTime();
|
||||||
|
|
||||||
//Listen to autopilot connection events
|
// Listen to autopilot connection events
|
||||||
connect(cm, SIGNAL(deviceAboutToDisconnect()), this, SLOT(csvLoggingDisconnect()));
|
connect(cm, SIGNAL(deviceAboutToDisconnect()), this, SLOT(csvLoggingDisconnect()));
|
||||||
connect(cm, SIGNAL(deviceConnected(QIODevice*)), this, SLOT(csvLoggingConnect()));
|
connect(cm, SIGNAL(deviceConnected(QIODevice *)), this, SLOT(csvLoggingConnect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopeGadgetWidget::~ScopeGadgetWidget()
|
ScopeGadgetWidget::~ScopeGadgetWidget()
|
||||||
{
|
{
|
||||||
if (replotTimer)
|
if (replotTimer) {
|
||||||
{
|
replotTimer->stop();
|
||||||
replotTimer->stop();
|
|
||||||
|
|
||||||
delete replotTimer;
|
delete replotTimer;
|
||||||
replotTimer = NULL;
|
replotTimer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the object to de-monitor
|
// Get the object to de-monitor
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
foreach (QString uavObjName, m_connectedUAVObjects)
|
foreach(QString uavObjName, m_connectedUAVObjects) {
|
||||||
{
|
UAVDataObject *obj = dynamic_cast<UAVDataObject *>(objManager->getObject(uavObjName));
|
||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(objManager->getObject(uavObjName));
|
|
||||||
disconnect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(uavObjectReceived(UAVObject*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
clearCurvePlots();
|
disconnect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(uavObjectReceived(UAVObject *)));
|
||||||
|
}
|
||||||
|
|
||||||
|
clearCurvePlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
||||||
void ScopeGadgetWidget::mousePressEvent(QMouseEvent *e)
|
void ScopeGadgetWidget::mousePressEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
QwtPlot::mousePressEvent(e);
|
QwtPlot::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::mouseReleaseEvent(QMouseEvent *e)
|
void ScopeGadgetWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
QwtPlot::mouseReleaseEvent(e);
|
QwtPlot::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::mouseDoubleClickEvent(QMouseEvent *e)
|
void ScopeGadgetWidget::mouseDoubleClickEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
//On double-click, toggle legend
|
// On double-click, toggle legend
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if (legend())
|
if (legend()) {
|
||||||
deleteLegend();
|
deleteLegend();
|
||||||
else
|
} else {
|
||||||
addLegend();
|
addLegend();
|
||||||
|
}
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
//On double-click, reset plot zoom
|
// On double-click, reset plot zoom
|
||||||
setAxisAutoScale(QwtPlot::yLeft, true);
|
setAxisAutoScale(QwtPlot::yLeft, true);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
QwtPlot::mouseDoubleClickEvent(e);
|
QwtPlot::mouseDoubleClickEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::mouseMoveEvent(QMouseEvent *e)
|
void ScopeGadgetWidget::mouseMoveEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
QwtPlot::mouseMoveEvent(e);
|
QwtPlot::mouseMoveEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::wheelEvent(QWheelEvent *e)
|
void ScopeGadgetWidget::wheelEvent(QWheelEvent *e)
|
||||||
{
|
{
|
||||||
//Change zoom on scroll wheel event
|
// Change zoom on scroll wheel event
|
||||||
QwtInterval yInterval=axisInterval(QwtPlot::yLeft);
|
QwtInterval yInterval = axisInterval(QwtPlot::yLeft);
|
||||||
if (yInterval.minValue() != yInterval.maxValue()) //Make sure that the two values are never the same. Sometimes axisInterval returns (0,0)
|
|
||||||
{
|
|
||||||
//Determine what y value to zoom about. NOTE, this approach has a bug that the in that
|
|
||||||
//the value returned by Qt includes the legend, whereas the value transformed by Qwt
|
|
||||||
//does *not*. Thus, when zooming with a legend, there will always be a small bias error.
|
|
||||||
//In practice, this seems not to be a UI problem.
|
|
||||||
QPoint mouse_pos=e->pos(); //Get the mouse coordinate in the frame
|
|
||||||
double zoomLine=invTransform(QwtPlot::yLeft, mouse_pos.y()); //Transform the y mouse coordinate into a frame value.
|
|
||||||
|
|
||||||
double zoomScale=1.1; //THIS IS AN ARBITRARY CONSTANT, AND PERHAPS SHOULD BE IN A DEFINE INSTEAD OF BURIED HERE
|
if (yInterval.minValue() != yInterval.maxValue()) { // Make sure that the two values are never the same. Sometimes axisInterval returns (0,0)
|
||||||
|
// Determine what y value to zoom about. NOTE, this approach has a bug that the in that
|
||||||
|
// the value returned by Qt includes the legend, whereas the value transformed by Qwt
|
||||||
|
// does *not*. Thus, when zooming with a legend, there will always be a small bias error.
|
||||||
|
// In practice, this seems not to be a UI problem.
|
||||||
|
QPoint mouse_pos = e->pos(); // Get the mouse coordinate in the frame
|
||||||
|
double zoomLine = invTransform(QwtPlot::yLeft, mouse_pos.y()); // Transform the y mouse coordinate into a frame value.
|
||||||
|
|
||||||
mutex.lock(); //DOES THIS mutex.lock NEED TO BE HERE? I DON'T KNOW, I JUST COPIED IT FROM THE ABOVE CODE
|
double zoomScale = 1.1; // THIS IS AN ARBITRARY CONSTANT, AND PERHAPS SHOULD BE IN A DEFINE INSTEAD OF BURIED HERE
|
||||||
|
|
||||||
|
mutex.lock(); // DOES THIS mutex.lock NEED TO BE HERE? I DON'T KNOW, I JUST COPIED IT FROM THE ABOVE CODE
|
||||||
// Set the scale
|
// Set the scale
|
||||||
if (e->delta()<0){
|
if (e->delta() < 0) {
|
||||||
setAxisScale(QwtPlot::yLeft,
|
setAxisScale(QwtPlot::yLeft,
|
||||||
(yInterval.minValue()-zoomLine)*zoomScale+zoomLine,
|
(yInterval.minValue() - zoomLine) * zoomScale + zoomLine,
|
||||||
(yInterval.maxValue()-zoomLine)*zoomScale+zoomLine );
|
(yInterval.maxValue() - zoomLine) * zoomScale + zoomLine);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
setAxisScale(QwtPlot::yLeft,
|
setAxisScale(QwtPlot::yLeft,
|
||||||
(yInterval.minValue()-zoomLine)/zoomScale+zoomLine,
|
(yInterval.minValue() - zoomLine) / zoomScale + zoomLine,
|
||||||
(yInterval.maxValue()-zoomLine)/zoomScale+zoomLine );
|
(yInterval.maxValue() - zoomLine) / zoomScale + zoomLine);
|
||||||
}
|
}
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
QwtPlot::wheelEvent(e);
|
QwtPlot::wheelEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScopeGadgetWidget::showEvent(QShowEvent *e)
|
||||||
|
{
|
||||||
|
replotNewData();
|
||||||
|
QwtPlot::showEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts/stops telemetry
|
* Starts/stops telemetry
|
||||||
*/
|
*/
|
||||||
void ScopeGadgetWidget::startPlotting()
|
void ScopeGadgetWidget::startPlotting()
|
||||||
{
|
{
|
||||||
if (!replotTimer)
|
if (!replotTimer) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!replotTimer->isActive())
|
if (!replotTimer->isActive()) {
|
||||||
replotTimer->start(m_refreshInterval);
|
replotTimer->start(m_refreshInterval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::stopPlotting()
|
void ScopeGadgetWidget::stopPlotting()
|
||||||
{
|
{
|
||||||
if (!replotTimer)
|
if (!replotTimer) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
replotTimer->stop();
|
replotTimer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::deleteLegend()
|
void ScopeGadgetWidget::deleteLegend()
|
||||||
{
|
{
|
||||||
if (!legend())
|
if (!legend()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
disconnect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)), this, 0);
|
disconnect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)), this, 0);
|
||||||
|
|
||||||
insertLegend(NULL, QwtPlot::TopLegend);
|
insertLegend(NULL, QwtPlot::TopLegend);
|
||||||
// insertLegend(NULL, QwtPlot::ExternalLegend);
|
// insertLegend(NULL, QwtPlot::ExternalLegend);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::addLegend()
|
void ScopeGadgetWidget::addLegend()
|
||||||
{
|
{
|
||||||
if (legend())
|
if (legend()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Show a legend at the top
|
// Show a legend at the top
|
||||||
QwtLegend *legend = new QwtLegend();
|
QwtLegend *legend = new QwtLegend();
|
||||||
legend->setItemMode(QwtLegend::CheckableItem);
|
legend->setItemMode(QwtLegend::CheckableItem);
|
||||||
legend->setFrameStyle(QFrame::Box | QFrame::Sunken);
|
legend->setFrameStyle(QFrame::Box | QFrame::Sunken);
|
||||||
legend->setToolTip(tr("Click legend to show/hide scope trace"));
|
legend->setToolTip(tr("Click legend to show/hide scope trace"));
|
||||||
|
|
||||||
QPalette pal = legend->palette();
|
QPalette pal = legend->palette();
|
||||||
pal.setColor(legend->backgroundRole(), QColor(100, 100, 100)); // background colour
|
pal.setColor(legend->backgroundRole(), QColor(100, 100, 100)); // background colour
|
||||||
// pal.setColor(legend->backgroundRole(), Qt::transparent); // background colour
|
// pal.setColor(legend->backgroundRole(), Qt::transparent); // background colour
|
||||||
// pal.setColor(QPalette::Text, QColor(255, 255, 255)); // text colour
|
// pal.setColor(QPalette::Text, QColor(255, 255, 255)); // text colour
|
||||||
pal.setColor(QPalette::Text, QColor(0, 0, 0)); // text colour
|
pal.setColor(QPalette::Text, QColor(0, 0, 0)); // text colour
|
||||||
legend->setPalette(pal);
|
legend->setPalette(pal);
|
||||||
|
|
||||||
insertLegend(legend, QwtPlot::TopLegend);
|
insertLegend(legend, QwtPlot::TopLegend);
|
||||||
// insertLegend(legend, QwtPlot::ExternalLegend);
|
// insertLegend(legend, QwtPlot::ExternalLegend);
|
||||||
|
|
||||||
// // Show a legend at the bottom
|
//// Show a legend at the bottom
|
||||||
// QwtLegend *legend = new QwtLegend();
|
// QwtLegend *legend = new QwtLegend();
|
||||||
// legend->setItemMode(QwtLegend::CheckableItem);
|
// legend->setItemMode(QwtLegend::CheckableItem);
|
||||||
// legend->setFrameStyle(QFrame::Box | QFrame::Sunken);
|
// legend->setFrameStyle(QFrame::Box | QFrame::Sunken);
|
||||||
// insertLegend(legend, QwtPlot::BottomLegend);
|
// insertLegend(legend, QwtPlot::BottomLegend);
|
||||||
|
|
||||||
// Update the checked/unchecked state of the legend items
|
// Update the checked/unchecked state of the legend items
|
||||||
// -> this is necessary when hiding a legend where some plots are
|
// -> this is necessary when hiding a legend where some plots are
|
||||||
// not visible, and the un-hiding it.
|
// not visible, and the un-hiding it.
|
||||||
foreach (QwtPlotItem *item, this->itemList()) {
|
foreach(QwtPlotItem * item, this->itemList()) {
|
||||||
bool on = item->isVisible();
|
bool on = item->isVisible();
|
||||||
QWidget *w = legend->find(item);
|
QWidget *w = legend->find(item);
|
||||||
if ( w && w->inherits("QwtLegendItem") )
|
|
||||||
|
if (w && w->inherits("QwtLegendItem")) {
|
||||||
((QwtLegendItem *)w)->setChecked(!on);
|
((QwtLegendItem *)w)->setChecked(!on);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)), this, SLOT(showCurve(QwtPlotItem *, bool)));
|
connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)), this, SLOT(showCurve(QwtPlotItem *, bool)));
|
||||||
@ -258,18 +270,18 @@ void ScopeGadgetWidget::preparePlot(PlotType plotType)
|
|||||||
setMinimumSize(64, 64);
|
setMinimumSize(64, 64);
|
||||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
// setMargin(1);
|
// setMargin(1);
|
||||||
|
|
||||||
// QPalette pal = palette();
|
// QPalette pal = palette();
|
||||||
// QPalette::ColorRole cr = backgroundRole();
|
// QPalette::ColorRole cr = backgroundRole();
|
||||||
// pal.setColor(cr, QColor(128, 128, 128)); // background colour
|
// pal.setColor(cr, QColor(128, 128, 128)); // background colour
|
||||||
// pal.setColor(QPalette::Text, QColor(255, 255, 255)); // text colour
|
// pal.setColor(QPalette::Text, QColor(255, 255, 255)); // text colour
|
||||||
// setPalette(pal);
|
// setPalette(pal);
|
||||||
|
|
||||||
// setCanvasBackground(Utils::StyleHelper::baseColor());
|
// setCanvasBackground(Utils::StyleHelper::baseColor());
|
||||||
setCanvasBackground(QColor(64, 64, 64));
|
setCanvasBackground(QColor(64, 64, 64));
|
||||||
|
|
||||||
//Add grid lines
|
// Add grid lines
|
||||||
QwtPlotGrid *grid = new QwtPlotGrid;
|
QwtPlotGrid *grid = new QwtPlotGrid;
|
||||||
grid->setMajPen(QPen(Qt::gray, 0, Qt::DashLine));
|
grid->setMajPen(QPen(Qt::gray, 0, Qt::DashLine));
|
||||||
grid->setMinPen(QPen(Qt::lightGray, 0, Qt::DotLine));
|
grid->setMinPen(QPen(Qt::lightGray, 0, Qt::DotLine));
|
||||||
@ -281,12 +293,12 @@ void ScopeGadgetWidget::preparePlot(PlotType plotType)
|
|||||||
|
|
||||||
// Only start the timer if we are already connected
|
// Only start the timer if we are already connected
|
||||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||||
if (cm->getCurrentConnection() && replotTimer)
|
if (cm->getCurrentConnection() && replotTimer) {
|
||||||
{
|
if (!replotTimer->isActive()) {
|
||||||
if (!replotTimer->isActive())
|
|
||||||
replotTimer->start(m_refreshInterval);
|
replotTimer->start(m_refreshInterval);
|
||||||
else
|
} else {
|
||||||
replotTimer->setInterval(m_refreshInterval);
|
replotTimer->setInterval(m_refreshInterval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,22 +306,23 @@ void ScopeGadgetWidget::showCurve(QwtPlotItem *item, bool on)
|
|||||||
{
|
{
|
||||||
item->setVisible(!on);
|
item->setVisible(!on);
|
||||||
QWidget *w = legend()->find(item);
|
QWidget *w = legend()->find(item);
|
||||||
if ( w && w->inherits("QwtLegendItem") )
|
if (w && w->inherits("QwtLegendItem")) {
|
||||||
((QwtLegendItem *)w)->setChecked(on);
|
((QwtLegendItem *)w)->setChecked(on);
|
||||||
|
}
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
replot();
|
replot();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::setupSequentialPlot()
|
void ScopeGadgetWidget::setupSequentialPlot()
|
||||||
{
|
{
|
||||||
preparePlot(SequentialPlot);
|
preparePlot(SequentialPlot);
|
||||||
|
|
||||||
// QwtText title("Index");
|
// QwtText title("Index");
|
||||||
//// title.setFont(QFont("Helvetica", 20));
|
//// title.setFont(QFont("Helvetica", 20));
|
||||||
// title.font().setPointSize(title.font().pointSize() / 2);
|
// title.font().setPointSize(title.font().pointSize() / 2);
|
||||||
// setAxisTitle(QwtPlot::xBottom, title);
|
// setAxisTitle(QwtPlot::xBottom, title);
|
||||||
//// setAxisTitle(QwtPlot::xBottom, "Index");
|
//// setAxisTitle(QwtPlot::xBottom, "Index");
|
||||||
|
|
||||||
setAxisScaleDraw(QwtPlot::xBottom, new QwtScaleDraw());
|
setAxisScaleDraw(QwtPlot::xBottom, new QwtScaleDraw());
|
||||||
@ -317,175 +330,187 @@ void ScopeGadgetWidget::setupSequentialPlot()
|
|||||||
setAxisLabelRotation(QwtPlot::xBottom, 0.0);
|
setAxisLabelRotation(QwtPlot::xBottom, 0.0);
|
||||||
setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
|
setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
|
||||||
|
|
||||||
QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
|
QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
|
||||||
|
|
||||||
// reduce the gap between the scope canvas and the axis scale
|
// reduce the gap between the scope canvas and the axis scale
|
||||||
scaleWidget->setMargin(0);
|
scaleWidget->setMargin(0);
|
||||||
|
|
||||||
// reduce the axis font size
|
// reduce the axis font size
|
||||||
QFont fnt(axisFont(QwtPlot::xBottom));
|
QFont fnt(axisFont(QwtPlot::xBottom));
|
||||||
fnt.setPointSize(7);
|
fnt.setPointSize(7);
|
||||||
setAxisFont(QwtPlot::xBottom, fnt); // x-axis
|
setAxisFont(QwtPlot::xBottom, fnt); // x-axis
|
||||||
setAxisFont(QwtPlot::yLeft, fnt); // y-axis
|
setAxisFont(QwtPlot::yLeft, fnt); // y-axis
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::setupChronoPlot()
|
void ScopeGadgetWidget::setupChronoPlot()
|
||||||
{
|
{
|
||||||
preparePlot(ChronoPlot);
|
preparePlot(ChronoPlot);
|
||||||
|
|
||||||
// QwtText title("Time [h:m:s]");
|
// QwtText title("Time [h:m:s]");
|
||||||
//// title.setFont(QFont("Helvetica", 20));
|
//// title.setFont(QFont("Helvetica", 20));
|
||||||
// title.font().setPointSize(title.font().pointSize() / 2);
|
// title.font().setPointSize(title.font().pointSize() / 2);
|
||||||
// setAxisTitle(QwtPlot::xBottom, title);
|
// setAxisTitle(QwtPlot::xBottom, title);
|
||||||
//// setAxisTitle(QwtPlot::xBottom, "Time [h:m:s]");
|
//// setAxisTitle(QwtPlot::xBottom, "Time [h:m:s]");
|
||||||
|
|
||||||
setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw());
|
setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw());
|
||||||
uint NOW = QDateTime::currentDateTime().toTime_t();
|
uint NOW = QDateTime::currentDateTime().toTime_t();
|
||||||
setAxisScale(QwtPlot::xBottom, NOW - m_xWindowSize / 1000, NOW);
|
setAxisScale(QwtPlot::xBottom, NOW - m_xWindowSize / 1000, NOW);
|
||||||
// setAxisLabelRotation(QwtPlot::xBottom, -15.0);
|
// setAxisLabelRotation(QwtPlot::xBottom, -15.0);
|
||||||
setAxisLabelRotation(QwtPlot::xBottom, 0.0);
|
setAxisLabelRotation(QwtPlot::xBottom, 0.0);
|
||||||
setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
|
setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
|
||||||
// setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignCenter | Qt::AlignBottom);
|
// setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignCenter | Qt::AlignBottom);
|
||||||
|
|
||||||
QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
|
QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
|
||||||
// QwtScaleDraw *scaleDraw = axisScaleDraw();
|
// QwtScaleDraw *scaleDraw = axisScaleDraw();
|
||||||
|
|
||||||
// reduce the gap between the scope canvas and the axis scale
|
// reduce the gap between the scope canvas and the axis scale
|
||||||
scaleWidget->setMargin(0);
|
scaleWidget->setMargin(0);
|
||||||
|
|
||||||
// reduce the axis font size
|
// reduce the axis font size
|
||||||
QFont fnt(axisFont(QwtPlot::xBottom));
|
QFont fnt(axisFont(QwtPlot::xBottom));
|
||||||
fnt.setPointSize(7);
|
fnt.setPointSize(7);
|
||||||
setAxisFont(QwtPlot::xBottom, fnt); // x-axis
|
setAxisFont(QwtPlot::xBottom, fnt); // x-axis
|
||||||
setAxisFont(QwtPlot::yLeft, fnt); // y-axis
|
setAxisFont(QwtPlot::yLeft, fnt); // y-axis
|
||||||
|
|
||||||
// set the axis colours .. can't seem to change the background colour :(
|
// set the axis colours .. can't seem to change the background colour :(
|
||||||
// QPalette pal = scaleWidget->palette();
|
// QPalette pal = scaleWidget->palette();
|
||||||
// QPalette::ColorRole cr = scaleWidget->backgroundRole();
|
// QPalette::ColorRole cr = scaleWidget->backgroundRole();
|
||||||
// pal.setColor(cr, QColor(128, 128, 128)); // background colour
|
// pal.setColor(cr, QColor(128, 128, 128)); // background colour
|
||||||
// cr = scaleWidget->foregroundRole();
|
// cr = scaleWidget->foregroundRole();
|
||||||
// pal.setColor(cr, QColor(255, 255, 255)); // tick colour
|
// pal.setColor(cr, QColor(255, 255, 255)); // tick colour
|
||||||
// pal.setColor(QPalette::Text, QColor(255, 255, 255)); // text colour
|
// pal.setColor(QPalette::Text, QColor(255, 255, 255)); // text colour
|
||||||
// scaleWidget->setPalette(pal);
|
// scaleWidget->setPalette(pal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
In situations, when there is a label at the most right position of the
|
In situations, when there is a label at the most right position of the
|
||||||
scale, additional space is needed to display the overlapping part
|
scale, additional space is needed to display the overlapping part
|
||||||
of the label would be taken by reducing the width of scale and canvas.
|
of the label would be taken by reducing the width of scale and canvas.
|
||||||
To avoid this "jumping canvas" effect, we add a permanent margin.
|
To avoid this "jumping canvas" effect, we add a permanent margin.
|
||||||
We don't need to do the same for the left border, because there
|
We don't need to do the same for the left border, because there
|
||||||
is enough space for the overlapping label below the left scale.
|
is enough space for the overlapping label below the left scale.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// const int fmh = QFontMetrics(scaleWidget->font()).height();
|
// const int fmh = QFontMetrics(scaleWidget->font()).height();
|
||||||
// scaleWidget->setMinBorderDist(0, fmh / 2);
|
// scaleWidget->setMinBorderDist(0, fmh / 2);
|
||||||
|
|
||||||
// const int fmw = QFontMetrics(scaleWidget->font()).width(" 00:00:00 ");
|
// const int fmw = QFontMetrics(scaleWidget->font()).width(" 00:00:00 ");
|
||||||
// const int fmw = QFontMetrics(scaleWidget->font()).width(" ");
|
// const int fmw = QFontMetrics(scaleWidget->font()).width(" ");
|
||||||
// scaleWidget->setMinBorderDist(0, fmw);
|
// scaleWidget->setMinBorderDist(0, fmw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor, int meanSamples, QString mathFunction, QPen pen)
|
void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor, int meanSamples, QString mathFunction, QPen pen, bool antialiased)
|
||||||
{
|
{
|
||||||
PlotData* plotData;
|
PlotData *plotData;
|
||||||
|
|
||||||
if (m_plotType == SequentialPlot)
|
if (m_plotType == SequentialPlot) {
|
||||||
plotData = new SequentialPlotData(uavObject, uavFieldSubField);
|
plotData = new SequentialPlotData(uavObject, uavFieldSubField);
|
||||||
else if (m_plotType == ChronoPlot)
|
} else if (m_plotType == ChronoPlot) {
|
||||||
plotData = new ChronoPlotData(uavObject, uavFieldSubField);
|
plotData = new ChronoPlotData(uavObject, uavFieldSubField);
|
||||||
//else if (m_plotType == UAVObjectPlot)
|
}
|
||||||
// plotData = new UAVObjectPlotData(uavObject, uavField);
|
// else if (m_plotType == UAVObjectPlot)
|
||||||
|
// plotData = new UAVObjectPlotData(uavObject, uavField);
|
||||||
|
|
||||||
plotData->m_xWindowSize = m_xWindowSize;
|
plotData->m_xWindowSize = m_xWindowSize;
|
||||||
plotData->scalePower = scaleOrderFactor;
|
plotData->scalePower = scaleOrderFactor;
|
||||||
plotData->meanSamples = meanSamples;
|
plotData->meanSamples = meanSamples;
|
||||||
plotData->mathFunction = mathFunction;
|
plotData->mathFunction = mathFunction;
|
||||||
|
|
||||||
//If the y-bounds are supplied, set them
|
// If the y-bounds are supplied, set them
|
||||||
if (plotData->yMinimum != plotData->yMaximum)
|
if (plotData->yMinimum != plotData->yMaximum) {
|
||||||
{
|
setAxisScale(QwtPlot::yLeft, plotData->yMinimum, plotData->yMaximum);
|
||||||
setAxisScale(QwtPlot::yLeft, plotData->yMinimum, plotData->yMaximum);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Create the curve
|
// Create the curve
|
||||||
QString curveName = (plotData->uavObject) + "." + (plotData->uavField);
|
QString curveName = (plotData->uavObject) + "." + (plotData->uavField);
|
||||||
if(plotData->haveSubField)
|
if (plotData->haveSubField) {
|
||||||
curveName = curveName.append("." + plotData->uavSubField);
|
curveName = curveName.append("." + plotData->uavSubField);
|
||||||
|
}
|
||||||
|
|
||||||
//Get the uav object
|
// Get the uav object
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject((plotData->uavObject)));
|
UAVDataObject *obj = dynamic_cast<UAVDataObject *>(objManager->getObject((plotData->uavObject)));
|
||||||
if(!obj) {
|
if (!obj) {
|
||||||
qDebug() << "Object " << plotData->uavObject << " is missing";
|
qDebug() << "Object " << plotData->uavObject << " is missing";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UAVObjectField* field = obj->getField(plotData->uavField);
|
UAVObjectField *field = obj->getField(plotData->uavField);
|
||||||
if(!field) {
|
if (!field) {
|
||||||
qDebug() << "In scope gadget, in fields loaded from GCS config file, field" << plotData->uavField << " of object " << plotData->uavObject << " is missing";
|
qDebug() << "In scope gadget, in fields loaded from GCS config file, field" << plotData->uavField << " of object " << plotData->uavObject << " is missing";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString units = field->getUnits();
|
QString units = field->getUnits();
|
||||||
|
|
||||||
if(units == 0)
|
if (units == 0) {
|
||||||
units = QString();
|
units = QString();
|
||||||
|
}
|
||||||
|
|
||||||
QString curveNameScaled;
|
QString curveNameScaled;
|
||||||
if(scaleOrderFactor == 0)
|
if (scaleOrderFactor == 0) {
|
||||||
curveNameScaled = curveName + " (" + units + ")";
|
curveNameScaled = curveName + " (" + units + ")";
|
||||||
else
|
} else {
|
||||||
curveNameScaled = curveName + " (x10^" + QString::number(scaleOrderFactor) + " " + units + ")";
|
curveNameScaled = curveName + " (x10^" + QString::number(scaleOrderFactor) + " " + units + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
QwtPlotCurve *plotCurve = new QwtPlotCurve(curveNameScaled);
|
||||||
|
|
||||||
|
if (antialiased) {
|
||||||
|
plotCurve->setRenderHint(QwtPlotCurve::RenderAntialiased);
|
||||||
|
}
|
||||||
|
|
||||||
QwtPlotCurve* plotCurve = new QwtPlotCurve(curveNameScaled);
|
|
||||||
plotCurve->setPen(pen);
|
plotCurve->setPen(pen);
|
||||||
plotCurve->setSamples(*plotData->xData, *plotData->yData);
|
plotCurve->setSamples(*plotData->xData, *plotData->yData);
|
||||||
plotCurve->attach(this);
|
plotCurve->attach(this);
|
||||||
plotData->curve = plotCurve;
|
plotData->curve = plotCurve;
|
||||||
|
|
||||||
//Keep the curve details for later
|
// Keep the curve details for later
|
||||||
m_curvesData.insert(curveNameScaled, plotData);
|
m_curvesData.insert(curveNameScaled, plotData);
|
||||||
|
|
||||||
//Link to the new signal data only if this UAVObject has not been connected yet
|
// Link to the new signal data only if this UAVObject has not been connected yet
|
||||||
if (!m_connectedUAVObjects.contains(obj->getName())) {
|
if (!m_connectedUAVObjects.contains(obj->getName())) {
|
||||||
m_connectedUAVObjects.append(obj->getName());
|
m_connectedUAVObjects.append(obj->getName());
|
||||||
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(uavObjectReceived(UAVObject*)));
|
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(uavObjectReceived(UAVObject *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
replot();
|
replot();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
//void ScopeGadgetWidget::removeCurvePlot(QString uavObject, QString uavField)
|
// void ScopeGadgetWidget::removeCurvePlot(QString uavObject, QString uavField)
|
||||||
//{
|
// {
|
||||||
// QString curveName = uavObject + "." + uavField;
|
// QString curveName = uavObject + "." + uavField;
|
||||||
//
|
//
|
||||||
// PlotData* plotData = m_curvesData.take(curveName);
|
// PlotData* plotData = m_curvesData.take(curveName);
|
||||||
// m_curvesData.remove(curveName);
|
// m_curvesData.remove(curveName);
|
||||||
// plotData->curve->detach();
|
// plotData->curve->detach();
|
||||||
//
|
//
|
||||||
// delete plotData->curve;
|
// delete plotData->curve;
|
||||||
// delete plotData;
|
// delete plotData;
|
||||||
//
|
//
|
||||||
// mutex.lock();
|
// mutex.lock();
|
||||||
// replot();
|
// replot();
|
||||||
// mutex.unlock();
|
// mutex.unlock();
|
||||||
//}
|
// }
|
||||||
|
|
||||||
void ScopeGadgetWidget::uavObjectReceived(UAVObject* obj)
|
void ScopeGadgetWidget::uavObjectReceived(UAVObject *obj)
|
||||||
{
|
{
|
||||||
foreach(PlotData* plotData, m_curvesData.values()) {
|
foreach(PlotData * plotData, m_curvesData.values()) {
|
||||||
if (plotData->append(obj)) m_csvLoggingDataUpdated=1;
|
if (plotData->append(obj)) {
|
||||||
|
m_csvLoggingDataUpdated = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
csvLoggingAddData();
|
csvLoggingAddData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::replotNewData()
|
void ScopeGadgetWidget::replotNewData()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
if (!isVisible()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach(PlotData* plotData, m_curvesData.values())
|
QMutexLocker locker(&mutex);
|
||||||
{
|
foreach(PlotData * plotData, m_curvesData.values()) {
|
||||||
plotData->removeStaleData();
|
plotData->removeStaleData();
|
||||||
plotData->curve->setSamples(*plotData->xData, *plotData->yData);
|
plotData->curve->setSamples(*plotData->xData, *plotData->yData);
|
||||||
}
|
}
|
||||||
@ -493,66 +518,20 @@ void ScopeGadgetWidget::replotNewData()
|
|||||||
QDateTime NOW = QDateTime::currentDateTime();
|
QDateTime NOW = QDateTime::currentDateTime();
|
||||||
double toTime = NOW.toTime_t();
|
double toTime = NOW.toTime_t();
|
||||||
toTime += NOW.time().msec() / 1000.0;
|
toTime += NOW.time().msec() / 1000.0;
|
||||||
if (m_plotType == ChronoPlot)
|
if (m_plotType == ChronoPlot) {
|
||||||
setAxisScale(QwtPlot::xBottom, toTime - m_xWindowSize, toTime);
|
setAxisScale(QwtPlot::xBottom, toTime - m_xWindowSize, toTime);
|
||||||
|
}
|
||||||
|
|
||||||
// qDebug() << "replotNewData from " << NOW.addSecs(- m_xWindowSize) << " to " << NOW;
|
// qDebug() << "replotNewData from " << NOW.addSecs(- m_xWindowSize) << " to " << NOW;
|
||||||
|
|
||||||
csvLoggingInsertData();
|
csvLoggingInsertData();
|
||||||
|
|
||||||
replot();
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void ScopeGadgetWidget::setupExamplePlot()
|
|
||||||
{
|
|
||||||
preparePlot(SequentialPlot);
|
|
||||||
|
|
||||||
// Show the axes
|
|
||||||
|
|
||||||
setAxisTitle(xBottom, "x");
|
|
||||||
setAxisTitle(yLeft, "y");
|
|
||||||
|
|
||||||
// Calculate the data, 500 points each
|
|
||||||
const int points = 500;
|
|
||||||
double x[ points ];
|
|
||||||
double sn[ points ];
|
|
||||||
double cs[ points ];
|
|
||||||
double sg[ points ];
|
|
||||||
|
|
||||||
for (int i = 0; i < points; i++) {
|
|
||||||
x[i] = (3.0 * 3.14 / double(points)) * double(i);
|
|
||||||
sn[i] = 2.0 * sin(x[i]);
|
|
||||||
cs[i] = 3.0 * cos(x[i]);
|
|
||||||
sg[i] = (sn[i] > 0) ? 1 : ((sn[i] < 0) ? -1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add curves
|
|
||||||
QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
|
|
||||||
curve1->setPen(QPen(Qt::blue));
|
|
||||||
QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2");
|
|
||||||
curve2->setPen(QPen(Qt::red));
|
|
||||||
QwtPlotCurve *curve3 = new QwtPlotCurve("Curve 3");
|
|
||||||
curve3->setPen(QPen(Qt::green));
|
|
||||||
|
|
||||||
// copy the data into the curves
|
|
||||||
curve1->setSamples(x, sn, points);
|
|
||||||
curve2->setSamples(x, cs, points);
|
|
||||||
curve3->setSamples(x, sg, points);
|
|
||||||
curve1->attach(this);
|
|
||||||
curve2->attach(this);
|
|
||||||
curve3->attach(this);
|
|
||||||
|
|
||||||
// finally, refresh the plot
|
|
||||||
mutex.lock();
|
|
||||||
replot();
|
|
||||||
mutex.unlock();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void ScopeGadgetWidget::clearCurvePlots()
|
void ScopeGadgetWidget::clearCurvePlots()
|
||||||
{
|
{
|
||||||
foreach(PlotData* plotData, m_curvesData.values()) {
|
foreach(PlotData * plotData, m_curvesData.values()) {
|
||||||
plotData->curve->detach();
|
plotData->curve->detach();
|
||||||
|
|
||||||
delete plotData->curve;
|
delete plotData->curve;
|
||||||
@ -564,49 +543,42 @@ void ScopeGadgetWidget::clearCurvePlots()
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int csvLoggingEnable;
|
int csvLoggingEnable;
|
||||||
int csvLoggingHeaderSaved;
|
int csvLoggingHeaderSaved;
|
||||||
int csvLoggingDataSaved;
|
int csvLoggingDataSaved;
|
||||||
QString csvLoggingPath;
|
QString csvLoggingPath;
|
||||||
QFile csvLoggingFile;
|
QFile csvLoggingFile;
|
||||||
*/
|
*/
|
||||||
int ScopeGadgetWidget::csvLoggingStart()
|
int ScopeGadgetWidget::csvLoggingStart()
|
||||||
{
|
{
|
||||||
if (!m_csvLoggingStarted)
|
if (!m_csvLoggingStarted) {
|
||||||
if (m_csvLoggingEnabled)
|
if (m_csvLoggingEnabled) {
|
||||||
if ((!m_csvLoggingNewFileOnConnect)||(m_csvLoggingNewFileOnConnect && m_csvLoggingConnected))
|
if ((!m_csvLoggingNewFileOnConnect) || (m_csvLoggingNewFileOnConnect && m_csvLoggingConnected)) {
|
||||||
{
|
QDateTime NOW = QDateTime::currentDateTime();
|
||||||
QDateTime NOW = QDateTime::currentDateTime();
|
m_csvLoggingStartTime = NOW;
|
||||||
m_csvLoggingStartTime = NOW;
|
m_csvLoggingHeaderSaved = 0;
|
||||||
m_csvLoggingHeaderSaved=0;
|
m_csvLoggingDataSaved = 0;
|
||||||
m_csvLoggingDataSaved=0;
|
m_csvLoggingBuffer.clear();
|
||||||
m_csvLoggingBuffer.clear();
|
QDir PathCheck(m_csvLoggingPath);
|
||||||
QDir PathCheck(m_csvLoggingPath);
|
if (!PathCheck.exists()) {
|
||||||
if (!PathCheck.exists())
|
PathCheck.mkpath("./");
|
||||||
{
|
}
|
||||||
PathCheck.mkpath("./");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (m_csvLoggingNameSet)
|
if (m_csvLoggingNameSet) {
|
||||||
{
|
m_csvLoggingFile.setFileName(QString("%1/%2_%3_%4.csv").arg(m_csvLoggingPath).arg(m_csvLoggingName).arg(NOW.toString("yyyy-MM-dd")).arg(NOW.toString("hh-mm-ss")));
|
||||||
m_csvLoggingFile.setFileName(QString("%1/%2_%3_%4.csv").arg(m_csvLoggingPath).arg(m_csvLoggingName).arg(NOW.toString("yyyy-MM-dd")).arg(NOW.toString("hh-mm-ss")));
|
} else {
|
||||||
|
m_csvLoggingFile.setFileName(QString("%1/Log_%2_%3.csv").arg(m_csvLoggingPath).arg(NOW.toString("yyyy-MM-dd")).arg(NOW.toString("hh-mm-ss")));
|
||||||
|
}
|
||||||
|
QDir FileCheck(m_csvLoggingFile.fileName());
|
||||||
|
if (FileCheck.exists()) {
|
||||||
|
m_csvLoggingFile.setFileName("");
|
||||||
|
} else {
|
||||||
|
m_csvLoggingStarted = 1;
|
||||||
|
csvLoggingInsertHeader();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_csvLoggingFile.setFileName(QString("%1/Log_%2_%3.csv").arg(m_csvLoggingPath).arg(NOW.toString("yyyy-MM-dd")).arg(NOW.toString("hh-mm-ss")));
|
|
||||||
}
|
|
||||||
QDir FileCheck(m_csvLoggingFile.fileName());
|
|
||||||
if (FileCheck.exists())
|
|
||||||
{
|
|
||||||
m_csvLoggingFile.setFileName("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_csvLoggingStarted=1;
|
|
||||||
csvLoggingInsertHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -614,33 +586,37 @@ int ScopeGadgetWidget::csvLoggingStart()
|
|||||||
|
|
||||||
int ScopeGadgetWidget::csvLoggingStop()
|
int ScopeGadgetWidget::csvLoggingStop()
|
||||||
{
|
{
|
||||||
m_csvLoggingStarted=0;
|
m_csvLoggingStarted = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScopeGadgetWidget::csvLoggingInsertHeader()
|
int ScopeGadgetWidget::csvLoggingInsertHeader()
|
||||||
{
|
{
|
||||||
if (!m_csvLoggingStarted) return -1;
|
if (!m_csvLoggingStarted) {
|
||||||
if (m_csvLoggingHeaderSaved) return -2;
|
return -1;
|
||||||
if (m_csvLoggingDataSaved) return -3;
|
}
|
||||||
|
if (m_csvLoggingHeaderSaved) {
|
||||||
m_csvLoggingHeaderSaved=1;
|
return -2;
|
||||||
if(m_csvLoggingFile.open(QIODevice::WriteOnly | QIODevice::Append)== FALSE)
|
}
|
||||||
{
|
if (m_csvLoggingDataSaved) {
|
||||||
qDebug() << "Unable to open " << m_csvLoggingFile.fileName() << " for csv logging Header";
|
return -3;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
QTextStream ts( &m_csvLoggingFile );
|
|
||||||
ts << "date" << ", " << "Time"<< ", " << "Sec since start"<< ", " << "Connected" << ", " << "Data changed";
|
|
||||||
|
|
||||||
foreach(PlotData* plotData2, m_curvesData.values())
|
m_csvLoggingHeaderSaved = 1;
|
||||||
{
|
if (m_csvLoggingFile.open(QIODevice::WriteOnly | QIODevice::Append) == FALSE) {
|
||||||
ts << ", ";
|
qDebug() << "Unable to open " << m_csvLoggingFile.fileName() << " for csv logging Header";
|
||||||
ts << plotData2->uavObject;
|
} else {
|
||||||
ts << "." << plotData2->uavField;
|
QTextStream ts(&m_csvLoggingFile);
|
||||||
if (plotData2->haveSubField) ts << "." << plotData2->uavSubField;
|
ts << "date" << ", " << "Time" << ", " << "Sec since start" << ", " << "Connected" << ", " << "Data changed";
|
||||||
|
|
||||||
|
foreach(PlotData * plotData2, m_curvesData.values()) {
|
||||||
|
ts << ", ";
|
||||||
|
ts << plotData2->uavObject;
|
||||||
|
ts << "." << plotData2->uavField;
|
||||||
|
if (plotData2->haveSubField) {
|
||||||
|
ts << "." << plotData2->uavSubField;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ts << endl;
|
ts << endl;
|
||||||
m_csvLoggingFile.close();
|
m_csvLoggingFile.close();
|
||||||
@ -650,47 +626,40 @@ int ScopeGadgetWidget::csvLoggingInsertHeader()
|
|||||||
|
|
||||||
int ScopeGadgetWidget::csvLoggingAddData()
|
int ScopeGadgetWidget::csvLoggingAddData()
|
||||||
{
|
{
|
||||||
if (!m_csvLoggingStarted) return -1;
|
if (!m_csvLoggingStarted) {
|
||||||
m_csvLoggingDataValid=0;
|
return -1;
|
||||||
|
}
|
||||||
|
m_csvLoggingDataValid = 0;
|
||||||
QDateTime NOW = QDateTime::currentDateTime();
|
QDateTime NOW = QDateTime::currentDateTime();
|
||||||
QString tempString;
|
QString tempString;
|
||||||
|
|
||||||
QTextStream ss( &tempString );
|
QTextStream ss(&tempString);
|
||||||
ss << NOW.toString("yyyy-MM-dd") << ", " << NOW.toString("hh:mm:ss.z") << ", " ;
|
ss << NOW.toString("yyyy-MM-dd") << ", " << NOW.toString("hh:mm:ss.z") << ", ";
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040700
|
#if QT_VERSION >= 0x040700
|
||||||
ss <<(NOW.toMSecsSinceEpoch() - m_csvLoggingStartTime.toMSecsSinceEpoch())/1000.00;
|
ss << (NOW.toMSecsSinceEpoch() - m_csvLoggingStartTime.toMSecsSinceEpoch()) / 1000.00;
|
||||||
#else
|
#else
|
||||||
ss <<(NOW.toTime_t() - m_csvLoggingStartTime.toTime_t());
|
ss << (NOW.toTime_t() - m_csvLoggingStartTime.toTime_t());
|
||||||
#endif
|
#endif
|
||||||
ss << ", " << m_csvLoggingConnected << ", " << m_csvLoggingDataUpdated;
|
ss << ", " << m_csvLoggingConnected << ", " << m_csvLoggingDataUpdated;
|
||||||
m_csvLoggingDataUpdated=0;
|
m_csvLoggingDataUpdated = 0;
|
||||||
|
|
||||||
foreach(PlotData* plotData2, m_curvesData.values())
|
foreach(PlotData * plotData2, m_curvesData.values()) {
|
||||||
{
|
ss << ", ";
|
||||||
ss << ", ";
|
if (plotData2->xData->isEmpty()) {
|
||||||
if (plotData2->xData->isEmpty ())
|
ss << ", ";
|
||||||
{
|
if (plotData2->xData->isEmpty()) {} else {
|
||||||
ss << ", ";
|
ss << QString().sprintf("%3.10g", plotData2->yData->last());
|
||||||
if (plotData2->xData->isEmpty ())
|
m_csvLoggingDataValid = 1;
|
||||||
{
|
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
ss << QString().sprintf("%3.10g", plotData2->yData->last());
|
||||||
ss << QString().sprintf("%3.10g",plotData2->yData->last());
|
m_csvLoggingDataValid = 1;
|
||||||
m_csvLoggingDataValid=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ss << QString().sprintf("%3.10g",plotData2->yData->last());
|
|
||||||
m_csvLoggingDataValid=1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ss << endl;
|
ss << endl;
|
||||||
if (m_csvLoggingDataValid)
|
if (m_csvLoggingDataValid) {
|
||||||
{
|
QTextStream ts(&m_csvLoggingBuffer);
|
||||||
QTextStream ts( &m_csvLoggingBuffer );
|
|
||||||
ts << tempString;
|
ts << tempString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,16 +668,15 @@ int ScopeGadgetWidget::csvLoggingAddData()
|
|||||||
|
|
||||||
int ScopeGadgetWidget::csvLoggingInsertData()
|
int ScopeGadgetWidget::csvLoggingInsertData()
|
||||||
{
|
{
|
||||||
if (!m_csvLoggingStarted) return -1;
|
if (!m_csvLoggingStarted) {
|
||||||
m_csvLoggingDataSaved=1;
|
return -1;
|
||||||
|
|
||||||
if(m_csvLoggingFile.open(QIODevice::WriteOnly | QIODevice::Append)== FALSE)
|
|
||||||
{
|
|
||||||
qDebug() << "Unable to open " << m_csvLoggingFile.fileName() << " for csv logging Data";
|
|
||||||
}
|
}
|
||||||
else
|
m_csvLoggingDataSaved = 1;
|
||||||
{
|
|
||||||
QTextStream ts( &m_csvLoggingFile );
|
if (m_csvLoggingFile.open(QIODevice::WriteOnly | QIODevice::Append) == FALSE) {
|
||||||
|
qDebug() << "Unable to open " << m_csvLoggingFile.fileName() << " for csv logging Data";
|
||||||
|
} else {
|
||||||
|
QTextStream ts(&m_csvLoggingFile);
|
||||||
ts << m_csvLoggingBuffer;
|
ts << m_csvLoggingBuffer;
|
||||||
m_csvLoggingFile.close();
|
m_csvLoggingFile.close();
|
||||||
}
|
}
|
||||||
@ -719,20 +687,22 @@ int ScopeGadgetWidget::csvLoggingInsertData()
|
|||||||
|
|
||||||
void ScopeGadgetWidget::csvLoggingSetName(QString newName)
|
void ScopeGadgetWidget::csvLoggingSetName(QString newName)
|
||||||
{
|
{
|
||||||
m_csvLoggingName = newName;
|
m_csvLoggingName = newName;
|
||||||
m_csvLoggingNameSet=1;
|
m_csvLoggingNameSet = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::csvLoggingConnect()
|
void ScopeGadgetWidget::csvLoggingConnect()
|
||||||
{
|
{
|
||||||
m_csvLoggingConnected=1;
|
m_csvLoggingConnected = 1;
|
||||||
if (m_csvLoggingNewFileOnConnect)csvLoggingStart();
|
if (m_csvLoggingNewFileOnConnect) {
|
||||||
return;
|
csvLoggingStart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void ScopeGadgetWidget::csvLoggingDisconnect()
|
void ScopeGadgetWidget::csvLoggingDisconnect()
|
||||||
{
|
{
|
||||||
m_csvLoggingHeaderSaved=0;
|
m_csvLoggingHeaderSaved = 0;
|
||||||
m_csvLoggingConnected=0;
|
m_csvLoggingConnected = 0;
|
||||||
if (m_csvLoggingNewFileOnConnect)csvLoggingStop();
|
if (m_csvLoggingNewFileOnConnect) {
|
||||||
return;
|
csvLoggingStop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ class TimeScaleDraw : public QwtScaleDraw
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TimeScaleDraw() {
|
TimeScaleDraw() {
|
||||||
//baseTime = QDateTime::currentDateTime().toTime_t();
|
|
||||||
}
|
}
|
||||||
virtual QwtText label(double v) const {
|
virtual QwtText label(double v) const {
|
||||||
uint seconds = (uint)(v);
|
uint seconds = (uint)(v);
|
||||||
@ -58,8 +57,6 @@ public:
|
|||||||
upTime.setTime(timePart);
|
upTime.setTime(timePart);
|
||||||
return upTime.toLocalTime().toString("hh:mm:ss");
|
return upTime.toLocalTime().toString("hh:mm:ss");
|
||||||
}
|
}
|
||||||
private:
|
|
||||||
// double baseTime;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScopeGadgetWidget : public QwtPlot
|
class ScopeGadgetWidget : public QwtPlot
|
||||||
@ -81,15 +78,15 @@ public:
|
|||||||
int refreshInterval(){return m_refreshInterval;}
|
int refreshInterval(){return m_refreshInterval;}
|
||||||
|
|
||||||
|
|
||||||
void addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor = 0, int meanSamples = 1, QString mathFunction= "None", QPen pen = QPen(Qt::black));
|
void addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor = 0, int meanSamples = 1,
|
||||||
//void removeCurvePlot(QString uavObject, QString uavField);
|
QString mathFunction= "None", QPen pen = QPen(Qt::black), bool antialiased = true);
|
||||||
void clearCurvePlots();
|
void clearCurvePlots();
|
||||||
int csvLoggingStart();
|
int csvLoggingStart();
|
||||||
int csvLoggingStop();
|
int csvLoggingStop();
|
||||||
void csvLoggingSetName(QString);
|
void csvLoggingSetName(QString);
|
||||||
void setLoggingEnabled(bool value){m_csvLoggingEnabled=value;};
|
void setLoggingEnabled(bool value){m_csvLoggingEnabled=value;}
|
||||||
void setLoggingNewFileOnConnect(bool value){m_csvLoggingNewFileOnConnect=value;};
|
void setLoggingNewFileOnConnect(bool value){m_csvLoggingNewFileOnConnect=value;}
|
||||||
void setLoggingPath(QString value){m_csvLoggingPath=value;};
|
void setLoggingPath(QString value){m_csvLoggingPath=value;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *e);
|
void mousePressEvent(QMouseEvent *e);
|
||||||
@ -97,6 +94,7 @@ protected:
|
|||||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||||
void mouseMoveEvent(QMouseEvent *e);
|
void mouseMoveEvent(QMouseEvent *e);
|
||||||
void wheelEvent(QWheelEvent *e);
|
void wheelEvent(QWheelEvent *e);
|
||||||
|
void showEvent(QShowEvent *e);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void uavObjectReceived(UAVObject*);
|
void uavObjectReceived(UAVObject*);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user