Draw graph & widgets @ 24 FPS

This commit is contained in:
Alex Spataru 2021-02-09 18:11:37 -05:00
parent 826b601897
commit 733a659ba1
5 changed files with 11 additions and 13 deletions

View File

@ -23,7 +23,6 @@
#ifndef UI_DATA_PROVIDER_H
#define UI_DATA_PROVIDER_H
#include <QTimer>
#include <QObject>
#include <JSON/Frame.h>

View File

@ -75,8 +75,9 @@ GraphProvider::GraphProvider()
connect(CSV::Player::getInstance(), SIGNAL(timestampChanged()),
this, SLOT(csvPlayerFixes()));
// Draw data every 50 ms
QTimer::singleShot(50, this, SLOT(drawData()));
// Draw data at 24 FPS
connect(&m_timer, &QTimer::timeout, this, &GraphProvider::dataUpdated);
m_timer.start(1000 / 24);
// clang-format on
LOG_TRACE() << "Class initialized";
@ -188,12 +189,6 @@ void GraphProvider::setDisplayedPoints(const int points)
}
}
void GraphProvider::drawData()
{
emit dataUpdated();
QTimer::singleShot(500, this, SLOT(drawData()));
}
/**
* Deletes all stored information
*/

View File

@ -23,6 +23,7 @@
#ifndef GRAPH_PROVIDER_H
#define GRAPH_PROVIDER_H
#include <QTimer>
#include <QVector>
#include <QObject>
#include <QVector>
@ -75,12 +76,12 @@ private:
GraphProvider();
private slots:
void drawData();
void resetData();
void updateValues();
void csvPlayerFixes();
private:
QTimer m_timer;
int m_prevFramePos;
int m_displayedPoints;
QVector<double> m_maximumValues;

View File

@ -51,6 +51,10 @@ WidgetProvider::WidgetProvider()
connect(ge, SIGNAL(frameChanged()), this, SLOT(updateModels()));
connect(io, SIGNAL(connectedChanged()), this, SLOT(resetData()));
// Draw data at 24 FPS
connect(&m_timer, &QTimer::timeout, this, &WidgetProvider::dataChanged);
m_timer.start(1000 / 24);
// Look like a pro
LOG_TRACE() << "Class initialized";
}
@ -419,9 +423,6 @@ void WidgetProvider::updateModels()
m_gyroGroups = getWidgetGroup("gyro");
m_barDatasets = getWidgetDatasets("bar");
m_accelerometerGroups = getWidgetGroup("accelerometer");
// Update UI
emit dataChanged();
}
/**

View File

@ -24,6 +24,7 @@
#define WIDGETPROVIDER_H
#include <QList>
#include <QTimer>
#include <QObject>
#include <JSON/Frame.h>
@ -87,6 +88,7 @@ private:
QList<JSON::Dataset *> getWidgetDatasets(const QString &handle);
private:
QTimer m_timer;
QList<JSON::Group *> m_mapGroups;
QList<JSON::Group *> m_gyroGroups;
QList<JSON::Dataset *> m_barDatasets;