I have a std::map< QString, QPolygonF>
that contains three QStrings
(sensorId) and for each sensor some data as QVector< QPointF>
, which are produced continuously and written in a cv::Mat
.
In the code block below, I take data from cv::Mat
for each sensor and save it in std::map< QString, double> m_Value;
and the values are pushed in std::map< QString, QPolygonF> m_Points
. I collect data for each sensors only 5 times. Afterwards I send my points to other class in order visualize them with QwtPlot
.
std::map<QString, QPolygonF> m_Points
std::map<QString, double> m_Value;
std::map<QString, int> m_Index;
for(int i= 0; i< 5 ++i)
{
m_Value[sensorId]= dataMat.at<double>(i);
m_Points[sensorId].push_back(QPointF((double)m_Index[sensorId],
m_Value[sensorId]));
m_Index[sensorId]++;
}
qDebug()<<" POINTS: " << toolId << m_Points[toolId];
emit updateDataSignal(m_Points);
With the std::map< QString, int> m_Index;
I continue/increase the number of sent points.
The output of the for-loop for only one loop looks like:
POINTS:
sensor1 QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue)
sensor2 QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue)
sensor3 QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue)
For second loop:
sensor1 QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue) QPolygonF(5, newPointValue) QPolygonF(6, newPointValue) QPolygonF(7, newPointValue) QPolygonF(8, newPointValue) QPolygonF(9, newPointValue)
sensor2 ...
sensor3 ...
After some time I have thousand of points and my Qwtplot
slows down by drawing/updating in real-time. Therefore I want to send only e.g. last 5 points from my map.
The output e.g. for sensor 1 should looks like:
first loop:
sensor1 QPolygonF(0, pointValue) QPolygonF(1, pointValue) QPolygonF(2, pointValue) QPolygonF(3, pointValue) QPolygonF(4, pointValue)
second loop:
sensor1 QPolygonF(5, newPointValue) QPolygonF(6, newPointValue) QPolygonF(7, newPointValue) QPolygonF(8, newPointValue) QPolygonF(9, newPointValue)
third loop:
sensor1 QPolygonF(10, newPointValue) QPolygonF(11, newPointValue) QPolygonF(12, newPointValue) QPolygonF(13, newPointValue) QPolygonF(14, newPointValue)
...
Thank you