1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

OP-1611 Addressed some review comments and changed logic around plots wanting initial data.

This commit is contained in:
m_thread 2014-11-15 11:04:19 +01:00
parent 6c476d2a58
commit 8a11c588a6
4 changed files with 15 additions and 8 deletions

View File

@ -201,6 +201,10 @@ QwtPlotMarker *PlotData::createMarker(QString value)
bool SequentialPlotData::append(UAVObject *obj) bool SequentialPlotData::append(UAVObject *obj)
{ {
if (obj == NULL) {
obj = m_object;
}
if (m_object == obj && m_field) { if (m_object == obj && m_field) {
if (!m_isEnumPlot) { if (!m_isEnumPlot) {
double currentValue = m_field->getValue(m_element).toDouble() * pow(10, m_scalePower); double currentValue = m_field->getValue(m_element).toDouble() * pow(10, m_scalePower);
@ -241,6 +245,10 @@ bool SequentialPlotData::append(UAVObject *obj)
bool ChronoPlotData::append(UAVObject *obj) bool ChronoPlotData::append(UAVObject *obj)
{ {
if (obj == NULL) {
obj = m_object;
}
if (m_object == obj && m_field) { if (m_object == obj && m_field) {
// Get the field of interest // Get the field of interest
// THINK ABOUT REIMPLEMENTING THIS TO SHOW UAVO TIME, NOT SYSTEM TIME // THINK ABOUT REIMPLEMENTING THIS TO SHOW UAVO TIME, NOT SYSTEM TIME

View File

@ -47,7 +47,7 @@ void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration *config)
ScopeGadgetConfiguration *sgConfig = qobject_cast<ScopeGadgetConfiguration *>(config); ScopeGadgetConfiguration *sgConfig = qobject_cast<ScopeGadgetConfiguration *>(config);
ScopeGadgetWidget *widget = qobject_cast<ScopeGadgetWidget *>(m_widget); ScopeGadgetWidget *widget = qobject_cast<ScopeGadgetWidget *>(m_widget);
widget->setName(config->name()); widget->setObjectName(config->name());
widget->setPlotDataSize(sgConfig->dataSize()); widget->setPlotDataSize(sgConfig->dataSize());
widget->setRefreshInterval(sgConfig->refreshInterval()); widget->setRefreshInterval(sgConfig->refreshInterval());

View File

@ -195,6 +195,11 @@ void ScopeGadgetWidget::showEvent(QShowEvent *e)
void ScopeGadgetWidget::startPlotting() void ScopeGadgetWidget::startPlotting()
{ {
if (replotTimer && !replotTimer->isActive()) { if (replotTimer && !replotTimer->isActive()) {
foreach (PlotData *plot, m_curvesData.values()) {
if (plot->wantsInitialData()) {
plot->append(NULL);
}
}
replotTimer->start(m_refreshInterval); replotTimer->start(m_refreshInterval);
} }
} }
@ -378,10 +383,6 @@ void ScopeGadgetWidget::addCurvePlot(QString objectName, QString fieldPlusSubFie
connect(this, SIGNAL(visibilityChanged(QwtPlotItem *)), plotData, SLOT(visibilityChanged(QwtPlotItem *))); connect(this, SIGNAL(visibilityChanged(QwtPlotItem *)), plotData, SLOT(visibilityChanged(QwtPlotItem *)));
plotData->attach(this); plotData->attach(this);
if (plotData->wantsInitialData()) {
plotData->append(object);
}
// Keep the curve details for later // Keep the curve details for later
m_curvesData.insert(plotData->plotName(), plotData); m_curvesData.insert(plotData->plotName(), plotData);
@ -671,5 +672,5 @@ void ScopeGadgetWidget::copyToClipboardAsImage()
void ScopeGadgetWidget::showOptionDialog() void ScopeGadgetWidget::showOptionDialog()
{ {
Core::ICore::instance()->showOptionsDialog("ScopeGadget", m_name); Core::ICore::instance()->showOptionsDialog("ScopeGadget", objectName());
} }

View File

@ -69,7 +69,6 @@ public:
ScopeGadgetWidget(QWidget *parent = 0); ScopeGadgetWidget(QWidget *parent = 0);
~ScopeGadgetWidget(); ~ScopeGadgetWidget();
void setName (QString name) { m_name = name; }
void setupSequentialPlot(); void setupSequentialPlot();
void setupChronoPlot(); void setupChronoPlot();
void setupUAVObjectPlot(); void setupUAVObjectPlot();
@ -148,7 +147,6 @@ private:
void preparePlot(PlotType plotType); void preparePlot(PlotType plotType);
void setupExamplePlot(); void setupExamplePlot();
QString m_name;
PlotType m_plotType; PlotType m_plotType;
double m_plotDataSize; double m_plotDataSize;