Logo Search packages:      
Sourcecode: kcm-tablet version File versions  Download package

void PressCurve::paintEvent ( QPaintEvent *  event  )  [protected]

Draws the background grid, controlpoints and the presscurve on the widget Does it with antialias support

Parameters:
event the paint event

Definition at line 162 of file presscurve.cpp.

References m_cP1, m_cP2, m_curveColor, m_pointColor, m_pointSize, and m_presssure.

{
    Q_UNUSED(event);

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.translate( + 0.5, + 0.5);

    // draw the background grid
    int yStep = height() / 10;
    int xStep = width() / 10;
    painter.setPen(QColor(Qt::gray));

    for (int i = 1; i < 10;i++) {
        painter.drawLine(i * xStep, 0, i * xStep, height());
        painter.drawLine(0, i * yStep, width(), i * yStep);
    }

    // draw controllpoint lines
    painter.setPen(QColor(Qt::gray));
    painter.drawLine(m_cP1, QPoint(0, height()));
    painter.drawLine(m_cP2, QPoint(width(), 0));

    // create presscurve
    QPainterPath curvePath;
    curvePath.moveTo(0, height());
    curvePath.cubicTo(m_cP1, m_cP2, QPoint(width(), 0));

    //create polygon for the area below the curve
    QPainterPath areaBelowCurve(curvePath);
    areaBelowCurve.lineTo(width(), height());
    areaBelowCurve.lineTo(0, height());
    QRectF clearRect(m_presssure * width(), 0, width(), height());
    QPainterPath subtract;
    subtract.addRect(clearRect);
    areaBelowCurve.subtracted(subtract);

    //draw below curve area
    painter.setPen(QPen());
    painter.setBrush(Qt::blue);
    painter.drawPath(areaBelowCurve.subtracted(subtract));

    // draw presscurve
    QPen curvePen;
    curvePen.setWidth(2);
    curvePen.setColor(m_curveColor);
    painter.setPen(curvePen);
    painter.setBrush(QBrush());
    painter.drawPath(curvePath);

    // draw controllpoints
    painter.setPen(m_pointColor);
    painter.setBrush(m_pointColor);
    painter.drawEllipse(m_cP1, m_pointSize, m_pointSize);
    painter.drawEllipse(m_cP2, m_pointSize, m_pointSize);
}


Generated by  Doxygen 1.6.0   Back to index