Beispiel #1
0
void FrameGraphRenderable::drawTimeLine(const Ogre::FrameEvent& evt, Ogre::Real ogreTime, Ogre::Real bulletTime, Ogre::Real worldTime)
{
    bool redraw = false;

    Ogre::Real unknownTime = evt.timeSinceLastFrame - (ogreTime + bulletTime + worldTime);
    mlastTimes[mLastLine].set(unknownTime, ogreTime, bulletTime, worldTime);

    if (evt.timeSinceLastFrame > mCurrentScaling) {
        mCurrentScaling *= std::ceil(evt.timeSinceLastFrame / mCurrentScaling);
        redraw = true;
        mSmallerScaling = 0;
    } else {
        if (evt.timeSinceLastFrame <= mCurrentScaling) {
            mSmallerScaling++;
            if (mSmallerScaling >= mNumFrames && mCurrentScaling >= 0.01f) {
                mCurrentScaling /= 2;
                redraw = true;
                mSmallerScaling = 0;
            }
        }
    }

    if (redraw) {
        redrawGraph();
    } else {
        drawGraphLine(mlastTimes[mLastLine], mLastLine);
    }

    mLastLine++;
    if (mLastLine >= mNumFrames) {
        mLastLine = 0;
    }
}
Beispiel #2
0
void DemoQPItem::paint(QPainter *painter)
{
    m_painter = painter;

    qreal w = boundingRect().width();
    qreal h = boundingRect().height();
    qreal t = m_animationTime;

    // These painting commands are identical with both renderers
    for (int i=0 ; i < m_testCount ; i++) {
        // Paint ruler
        if (m_enabledTests & 1) {
            drawRuler(0, h*0.02, w, h*0.05, t);
        }
        // Paint circles
        if (m_enabledTests & 2) {
            drawGraphCircles(w*0.15, h*0.1, w*0.7, w*0.7, 10, t*2);
            drawGraphCircles(w*0.05, h*0.55, w*0.25, w*0.25, 8, t*3);
            drawGraphCircles(w*0.70, h*0.55, w*0.25, w*0.25, 3, t);
        }
        // Paint lines
        if (m_enabledTests & 4) {
            drawGraphLine(0, h, w, -h, 4, t);
            drawGraphLine(0, h, w, -h*0.8, 6,  t+10);
            drawGraphLine(0, h, w, -h*0.6, 12, t/2);
        }
        // Paint bars
        if (m_enabledTests & 8) {
            drawGraphBars(0, h, w, -h*0.8, 6, t*3);
            drawGraphBars(0, h, w, -h*0.4, 10, t+2);
            drawGraphBars(0, h, w, -h*0.3, 20, t*2+2);
            drawGraphBars(0, h, w, -h*0.2, 40, t*3+2);
        }
        // Paint icons
        int icons = 50;
        if (m_enabledTests & 16) {
            drawIcons(0, h*0.2, w, h*0.2, icons, t);
        }

        // Increase animation time when m_testCount > 1
        t += 0.3;
    }
}