Changeset View
Changeset View
Standalone View
Standalone View
src/qt/trafficgraphwidget.cpp
Show All 32 Lines | void TrafficGraphWidget::setClientModel(ClientModel *model) { | ||||
} | } | ||||
} | } | ||||
int TrafficGraphWidget::getGraphRangeMins() const { | int TrafficGraphWidget::getGraphRangeMins() const { | ||||
return nMins; | return nMins; | ||||
} | } | ||||
void TrafficGraphWidget::paintPath(QPainterPath &path, QQueue<float> &samples) { | void TrafficGraphWidget::paintPath(QPainterPath &path, QQueue<float> &samples) { | ||||
int h = height() - YMARGIN * 2, w = width() - XMARGIN * 2; | int sampleCount = samples.size(); | ||||
int sampleCount = samples.size(), x = XMARGIN + w, y; | |||||
if (sampleCount > 0) { | if (sampleCount > 0) { | ||||
int h = height() - YMARGIN * 2, w = width() - XMARGIN * 2; | |||||
int x = XMARGIN + w; | |||||
path.moveTo(x, YMARGIN + h); | path.moveTo(x, YMARGIN + h); | ||||
for (int i = 0; i < sampleCount; ++i) { | for (int i = 0; i < sampleCount; ++i) { | ||||
x = XMARGIN + w - w * i / DESIRED_SAMPLES; | x = XMARGIN + w - w * i / DESIRED_SAMPLES; | ||||
y = YMARGIN + h - (int)(h * samples.at(i) / fMax); | int y = YMARGIN + h - (int)(h * samples.at(i) / fMax); | ||||
path.lineTo(x, y); | path.lineTo(x, y); | ||||
} | } | ||||
path.lineTo(x, YMARGIN + h); | path.lineTo(x, YMARGIN + h); | ||||
} | } | ||||
} | } | ||||
void TrafficGraphWidget::paintEvent(QPaintEvent *) { | void TrafficGraphWidget::paintEvent(QPaintEvent *) { | ||||
QPainter painter(this); | QPainter painter(this); | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |