Browse Source

SpeedPlotView: Save int's instead of double's

adaptive-webui-19844
Anton Lashkov 9 years ago
parent
commit
baadf34134
  1. 40
      src/gui/properties/speedplotview.cpp
  2. 10
      src/gui/properties/speedplotview.h

40
src/gui/properties/speedplotview.cpp

@ -68,16 +68,16 @@ SpeedPlotView::SpeedPlotView(QWidget *parent) @@ -68,16 +68,16 @@ SpeedPlotView::SpeedPlotView(QWidget *parent)
m_properties[TRACKER_UP] = GraphProperties(tr("Tracker Upload"), bluePen);
m_properties[TRACKER_DOWN] = GraphProperties(tr("Tracker Download"), greenPen);
m_yData[UP] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[DOWN] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[PAYLOAD_UP] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[PAYLOAD_DOWN] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[OVERHEAD_UP] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[OVERHEAD_DOWN] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[DHT_UP] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[DHT_DOWN] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[TRACKER_UP] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[TRACKER_DOWN] = boost::circular_buffer<double>(HOUR6_SEC);
m_yData[UP] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[DOWN] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[PAYLOAD_UP] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[PAYLOAD_DOWN] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[OVERHEAD_UP] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[OVERHEAD_DOWN] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[DHT_UP] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[DHT_DOWN] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[TRACKER_UP] = boost::circular_buffer<int>(HOUR6_SEC);
m_yData[TRACKER_DOWN] = boost::circular_buffer<int>(HOUR6_SEC);
}
void SpeedPlotView::setGraphEnable(GraphID id, bool enable)
@ -85,12 +85,12 @@ void SpeedPlotView::setGraphEnable(GraphID id, bool enable) @@ -85,12 +85,12 @@ void SpeedPlotView::setGraphEnable(GraphID id, bool enable)
m_properties[id].m_enable = enable;
}
void SpeedPlotView::pushXPoint(double x)
void SpeedPlotView::pushXPoint(uint x)
{
m_xData.push_back(x);
}
void SpeedPlotView::pushYPoint(GraphID id, double y)
void SpeedPlotView::pushYPoint(GraphID id, int y)
{
m_yData[id].push_back(y);
}
@ -120,15 +120,15 @@ void SpeedPlotView::replot() @@ -120,15 +120,15 @@ void SpeedPlotView::replot()
this->viewport()->update();
}
double SpeedPlotView::maxYValue()
int SpeedPlotView::maxYValue()
{
double maxYValue = 0;
for (QMap<GraphID, boost::circular_buffer<double> >::const_iterator it = m_yData.begin(); it != m_yData.end(); ++it) {
int maxYValue = 0;
for (QMap<GraphID, boost::circular_buffer<int> >::const_iterator it = m_yData.begin(); it != m_yData.end(); ++it) {
if (!m_properties[it.key()].m_enable)
continue;
const boost::circular_buffer<double> &queue = it.value();
const boost::circular_buffer<int> &queue = it.value();
for (int i = queue.size() - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) {
if (queue[i] > maxYValue)
@ -149,7 +149,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *) @@ -149,7 +149,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
rect.adjust(4, 4, 0, -4); // Add padding
double max_y = maxYValue();
int max_y = maxYValue();
rect.adjust(0, font_metrics.height(), 0, 0); // Add top padding for top speed text
@ -200,15 +200,15 @@ void SpeedPlotView::paintEvent(QPaintEvent *) @@ -200,15 +200,15 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
// draw graphs
rect.adjust(3, 0, 0, 0); // Need, else graphs cross left gridline
double y_multiplier = (max_y == 0.0) ? 0.0 : rect.height() / max_y;
double y_multiplier = (max_y == 0) ? 0.0 : double(rect.height()) / max_y;
double x_tick_size = double(rect.width()) / m_viewablePointsCount;
for (QMap<GraphID, boost::circular_buffer<double> >::const_iterator it = m_yData.begin(); it != m_yData.end(); ++it) {
for (QMap<GraphID, boost::circular_buffer<int> >::const_iterator it = m_yData.begin(); it != m_yData.end(); ++it) {
if (!m_properties[it.key()].m_enable)
continue;
const boost::circular_buffer<double> &queue = it.value();
const boost::circular_buffer<int> &queue = it.value();
QVector<QPoint> points;
for (int i = queue.size() - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) {

10
src/gui/properties/speedplotview.h

@ -68,8 +68,8 @@ public: @@ -68,8 +68,8 @@ public:
void setGraphEnable(GraphID id, bool enable);
void pushXPoint(double x);
void pushYPoint(GraphID id, double y);
void pushXPoint(uint x);
void pushYPoint(GraphID id, int y);
void setViewableLastPoints(TimePeriod period);
@ -97,14 +97,14 @@ private: @@ -97,14 +97,14 @@ private:
bool m_enable;
};
boost::circular_buffer<double> m_xData;
QMap<GraphID, boost::circular_buffer<double> > m_yData;
boost::circular_buffer<uint> m_xData;
QMap<GraphID, boost::circular_buffer<int> > m_yData;
QMap<GraphID, GraphProperties> m_properties;
PeriodInSeconds m_viewablePointsCount;
PeriodInSeconds m_maxCapacity;
double maxYValue();
int maxYValue();
};
#endif // SPEEDPLOTVIEW_H

Loading…
Cancel
Save