void Box2DDebugDraw::setWorld(Box2DWorld *world) { if (mWorld == world) return; if (mWorld) mWorld->disconnect(this); mWorld = world; if (mWorld) connect(mWorld, SIGNAL(stepped()), SLOT(onWorldStepped())); }
void StandardLife::step() { const Board *curr = _cache->getBoard(); for(int x=0; x < _next->getWidth(); x++) { for(int y=0; y < _next->getHeight(); y++) { int neigh = curr->getNeighbourCount(x, y); int cell = curr->getCell(x, y); _next->setCell(x, y, _rule->checkCell(cell, neigh)); } } if(_cache->append(_next)) { emit stepped(_cache); } }
void Box2DWorld::timerEvent(QTimerEvent *event) { if (event->timerId() == mTimerId) { mWorld->Step(mTimeStep, mVelocityIterations, mPositionIterations); foreach (Box2DBody *body, mBodies) body->synchronize(); // Emit contact signals foreach (const ContactEvent &event, mContactListener->events()) { switch (event.type) { case ContactEvent::BeginContact: event.fixtureA->emitBeginContact(event.fixtureB); event.fixtureB->emitBeginContact(event.fixtureA); break; case ContactEvent::EndContact: event.fixtureA->emitEndContact(event.fixtureB); event.fixtureB->emitEndContact(event.fixtureA); break; } } mContactListener->clearEvents(); // Emit signals for the current state of the contacts b2Contact *contact = mWorld->GetContactList(); while (contact) { Box2DFixture *fixtureA = toBox2DFixture(contact->GetFixtureA()); Box2DFixture *fixtureB = toBox2DFixture(contact->GetFixtureB()); fixtureA->emitContactChanged(fixtureB); fixtureB->emitContactChanged(fixtureA); contact = contact->GetNext(); } emit stepped(); }
/****************************************************************************** * Set spin widget stepping to the normal or shift increment. */ bool SpinBox::setShiftStepping(bool shift, int currentButton) { if (currentButton == NO_BUTTON) shift = false; if (shift && !mShiftMouse) { /* The value is to be stepped to a multiple of the shift increment. * Adjust the value so that after the spin widget steps it, it will be correct. * Then, if the mouse button is held down, the spin widget will continue to * step by the shift amount. */ int val = value(); int step = (currentButton == UP) ? mLineShiftStep : (currentButton == DOWN) ? -mLineShiftStep : 0; int adjust = shiftStepAdjustment(val, step); mShiftMouse = true; if (adjust) { /* The value is to be stepped by other than the shift increment, * presumably because it is being set to a multiple of the shift * increment. Achieve this by making the adjustment here, and then * allowing the normal step processing to complete the job by * adding/subtracting the normal shift increment. */ if (!wrapping()) { // Prevent the step from going past the spinbox's range, or // to the minimum value if that has a special text unless it is // already at the minimum value + 1. int newval = val + adjust + step; int svt = specialValueText().isEmpty() ? 0 : 1; int minval = mMinValue + svt; if (newval <= minval || newval >= mMaxValue) { // Stepping to the minimum or maximum value if (svt && newval <= mMinValue && val == mMinValue) newval = mMinValue; else newval = (newval <= minval) ? minval : mMaxValue; QSpinBox::setValue(newval); emit stepped(step); return true; } // If the interim value will lie outside the spinbox's range, // temporarily adjust the range to allow the value to be set. int tempval = val + adjust; if (tempval < mMinValue) { QSpinBox::setMinimum(tempval); mShiftMinBound = true; } else if (tempval > mMaxValue) { QSpinBox::setMaximum(tempval); mShiftMaxBound = true; } } // Don't process changes since this new value will be stepped immediately mSuppressSignals = true; bool blocked = signalsBlocked(); blockSignals(true); addValue(adjust, true); blockSignals(blocked); mSuppressSignals = false; } QSpinBox::setSingleStep(mLineShiftStep); } else if (!shift && mShiftMouse) { // Reinstate to normal (non-shift) stepping QSpinBox::setSingleStep(mLineStep); QSpinBox::setMinimum(mMinValue); QSpinBox::setMaximum(mMaxValue); mShiftMinBound = mShiftMaxBound = false; mShiftMouse = false; } return false; }
void SpinBox::stepBy(int steps) { int increment = steps * QSpinBox::singleStep(); addValue(increment); emit stepped(increment); }
void DebugConsole::step() { ui->stepButton->setEnabled(false); emit stepped(); }
void SpinBox::stepDown() { int step = -QSpinBox::lineStep(); addValue(step); emit stepped(step); }