void 
OpenSteer::OpenSteerDemo::gridUtility (const float3& gridTarget)
{
    // round off target to the nearest multiple of 2 (because the
    // checkboard grid with a pitch of 1 tiles with a period of 2)
    // then lower the grid a bit to put it under 2d annotation lines
    const float3 gridCenter = make_float3((round (gridTarget.x * 0.5f) * 2),
										  (round (gridTarget.y * 0.5f) * 2) - .05f,
										  (round (gridTarget.z * 0.5f) * 2));

    // colors for checkboard
    const float3 gray1 = grayColor (0.27f);
    const float3 gray2 = grayColor (0.30f);

    // draw 50x50 checkerboard grid with 50 squares along each side
    drawXZCheckerboardGrid (50, 50, gridCenter, gray1, gray2);

    // alternate style
    // drawXZLineGrid (50, 50, gridCenter, black);
}
Beispiel #2
0
void Ball::drawBall(QPainter* painter)
{
    // draw bg
    const QPoint center = rect().center();
    int radius = width() > height() ? height() / 2 : width() / 2;
    QRadialGradient bgColor(center, radius, QPoint(center.x(), center.y() - 5));

    if (_isInteractive && !_pressed) {
        QColor grayColor(176, 176, 176);
        bgColor.setColorAt(0.0, lighterColor(grayColor));
        bgColor.setColorAt(1.0, grayColor);
    } else {
        if (_type == Red) {
            switch (numberZone(_number)) {
            case 1:
                bgColor.setColorAt(0.0, lighterColor(Zone1Color));
                bgColor.setColorAt(1.0, Zone1Color);
                break;

            case 2:
                bgColor.setColorAt(0.0, lighterColor(Zone2Color));
                bgColor.setColorAt(1.0, Zone2Color);
                break;

            case 3:
                bgColor.setColorAt(0.0, lighterColor(Zone3Color));
                bgColor.setColorAt(1.0, Zone3Color);
                break;
            }

        } else {
            QColor blueColor(0, 162, 245);
            bgColor.setColorAt(0.0, lighterColor(blueColor));
            bgColor.setColorAt(1.0, blueColor);
        }
    }

    painter->setBrush(bgColor);
    painter->setPen(Qt::NoPen);
    painter->drawEllipse(center, radius - 1, radius - 1);

    // draw text
    painter->setRenderHints(QPainter::TextAntialiasing);
    if ((_isInteractive && !_pressed) ||(_type == Red && (numberZone(_number) == 3 || numberZone(_number) == 2)))
        painter->setPen(AlternateNumberColor);
    else
        painter->setPen(NumberColor);
    QFont f = painter->font();
    f.setBold(true);
    f.setPointSize(12);
    painter->setFont(f);
    painter->drawText(rect(), Qt::AlignVCenter | Qt::AlignHCenter, QString("%1").arg(_number));
}
Beispiel #3
0
void Widget::drawWidget(QPainter &qp) {

    QString num[] = { "75", "150", "225", "300", "375", "450",
                      "525", "600", "675" };

    int asize = sizeof(num)/sizeof(num[1]);

    QColor redColor(255, 175, 175);
    QColor yellowColor(255, 255, 184);

    int width = size().width();

    Burning *burn = (Burning *) m_parent;
    int cur_width = burn->getCurrentWidth();

    int step = (int) qRound((double)width / DIVISIONS);
    int till = (int) ((width / MAX_CAPACITY) * cur_width);
    int full = (int) ((width / MAX_CAPACITY) * FULL_CAPACITY);

    if (cur_width >= FULL_CAPACITY) {

        qp.setPen(yellowColor);
        qp.setBrush(yellowColor);
        qp.drawRect(0, 0, full, 30);
        qp.setPen(redColor);
        qp.setBrush(redColor);
        qp.drawRect(full, 0, till-full, PANEL_HEIGHT);

    } else if (till > 0) {

        qp.setPen(yellowColor);
        qp.setBrush(yellowColor);
        qp.drawRect(0, 0, till, PANEL_HEIGHT);
    }

    QColor grayColor(90, 80, 60);
    qp.setPen(grayColor);

    for (int i=1; i <=asize; i++) {

        qp.drawLine(i*step, 0, i*step, LINE_WIDTH);
        QFont newFont = font();
        newFont.setPointSize(7);
        setFont(newFont);

        QFontMetrics metrics(font());

        int w = metrics.width(num[i-1]);
        qp.drawText(i*step-w/2, DISTANCE, num[i-1]);
    }
}