File: cpuaveragecurve.cpp

package info (click to toggle)
libqwt 4.2.0-4.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 9,832 kB
  • ctags: 5,512
  • sloc: cpp: 22,973; ansic: 244; makefile: 66
file content (37 lines) | stat: -rw-r--r-- 936 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <qpainter.h>
#include <qwt_painter.h>
#include "cpuplot.h"
#include "cpuaveragecurve.h"

CpuAverageCurve::CpuAverageCurve(CpuPlot *plot):
    QwtPlotCurve(plot)
{
}

void CpuAverageCurve::drawCurve(QPainter *painter, int,
    const QwtDiMap &xMap, const QwtDiMap &yMap, int from, int to)
{
    QPointArray polyline( 2 * (to - from + 1));

    int idx = 0;
    for (register int i = from; i <= to; i++, idx++)
    {
        int xi = xMap.transform(x(i));
        int yi = yMap.transform(y(i));

        polyline.setPoint(idx, xi, yi);
    }

    const CpuPlot *plot = (const CpuPlot *)parentPlot();
    const QwtPlotCurve *totalCurve = plot->cpuCurve(CpuPlot::Total);

    for (register int j = to; j >= from; j--, idx++)
    {
        int xj = xMap.transform(totalCurve->x(j));
        int yj = yMap.transform(totalCurve->y(j));

        polyline.setPoint(idx, xj, yj);
    }

    QwtPainter::drawPolygon(painter, polyline);
}