/*! \brief Determine the value for a new position of the mouse \param pos Mouse position \return Value for the mouse position \sa isScrollPosition() */ double QwtKnob::scrolledTo( const QPoint &pos ) const { double angle = QLineF( rect().center(), pos ).angle(); angle = qwtNormalizeDegrees( angle - d_data->mouseOffset ); if ( scaleMap().pDist() > 360.0 ) { angle = qwtToDegrees( angle ); const double v = scaleMap().transform( value() ); int numTurns = qFloor( ( v - scaleMap().p1() ) / 360.0 ); double valueAngle = qwtNormalizeDegrees( v ); if ( qAbs( valueAngle - angle ) > 180.0 ) { numTurns += ( angle > valueAngle ) ? -1 : 1; } angle += scaleMap().p1() + numTurns * 360.0; if ( !wrapping() ) { const double boundedAngle = qBound( scaleMap().p1(), angle, scaleMap().p2() ); d_data->mouseOffset += ( boundedAngle - angle ); angle = boundedAngle; } } else { angle = qwtToScaleAngle( angle ); double boundedAngle = qBound( scaleMap().p1(), angle, scaleMap().p2() ); if ( !wrapping() ) { const double currentAngle = scaleMap().transform( value() ); if ( ( currentAngle > 90.0 ) && ( boundedAngle < -90.0 ) ) boundedAngle = scaleMap().p2(); else if ( ( currentAngle < -90.0 ) && ( boundedAngle > 90.0 ) ) boundedAngle = scaleMap().p1(); d_data->mouseOffset += ( boundedAngle - angle ); } angle = boundedAngle; } return scaleMap().invTransform( angle ); }
int QwtAbstractSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QwtAbstractScale::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 5) qt_static_metacall(this, _c, _id, _a); _id -= 5; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< double*>(_v) = value(); break; case 1: *reinterpret_cast< uint*>(_v) = totalSteps(); break; case 2: *reinterpret_cast< uint*>(_v) = singleSteps(); break; case 3: *reinterpret_cast< uint*>(_v) = pageSteps(); break; case 4: *reinterpret_cast< bool*>(_v) = stepAlignment(); break; case 5: *reinterpret_cast< bool*>(_v) = isReadOnly(); break; case 6: *reinterpret_cast< bool*>(_v) = isTracking(); break; case 7: *reinterpret_cast< bool*>(_v) = wrapping(); break; case 8: *reinterpret_cast< bool*>(_v) = invertedControls(); break; } _id -= 9; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setValue(*reinterpret_cast< double*>(_v)); break; case 1: setTotalSteps(*reinterpret_cast< uint*>(_v)); break; case 2: setSingleSteps(*reinterpret_cast< uint*>(_v)); break; case 3: setPageSteps(*reinterpret_cast< uint*>(_v)); break; case 4: setStepAlignment(*reinterpret_cast< bool*>(_v)); break; case 5: setReadOnly(*reinterpret_cast< bool*>(_v)); break; case 6: setTracking(*reinterpret_cast< bool*>(_v)); break; case 7: setWrapping(*reinterpret_cast< bool*>(_v)); break; case 8: setInvertedControls(*reinterpret_cast< bool*>(_v)); break; } _id -= 9; } else if (_c == QMetaObject::ResetProperty) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 9; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 9; } #endif // QT_NO_PROPERTIES return _id; }
QString TimeSpinBox::mapValueToText(int v) { if (m12Hour) { if (v < 60) v += 720; // convert 0:nn to 12:nn else if (v >= 780) v -= 720; // convert 13 - 23 hours to 1 - 11 } QString s; s.sprintf((wrapping() ? "%02d:%02d" : "%d:%02d"), v/60, v%60); return s; }
int QwtDial::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QwtAbstractSlider::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = hasVisibleBackground(); break; case 1: *reinterpret_cast< int*>(_v) = lineWidth(); break; case 2: *reinterpret_cast< Shadow*>(_v) = frameShadow(); break; case 3: *reinterpret_cast< Mode*>(_v) = mode(); break; case 4: *reinterpret_cast< double*>(_v) = origin(); break; case 5: *reinterpret_cast< bool*>(_v) = wrapping(); break; } _id -= 6; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: showBackground(*reinterpret_cast< bool*>(_v)); break; case 1: setLineWidth(*reinterpret_cast< int*>(_v)); break; case 2: setFrameShadow(*reinterpret_cast< Shadow*>(_v)); break; case 3: setMode(*reinterpret_cast< Mode*>(_v)); break; case 4: setOrigin(*reinterpret_cast< double*>(_v)); break; case 5: setWrapping(*reinterpret_cast< bool*>(_v)); break; } _id -= 6; } else if (_c == QMetaObject::ResetProperty) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 6; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 6; } #endif // QT_NO_PROPERTIES return _id; }
int QDial::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractSlider::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 5) qt_static_metacall(this, _c, _id, _a); _id -= 5; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = wrapping(); break; case 1: *reinterpret_cast< int*>(_v) = notchSize(); break; case 2: *reinterpret_cast< qreal*>(_v) = notchTarget(); break; case 3: *reinterpret_cast< bool*>(_v) = notchesVisible(); break; } _id -= 4; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setWrapping(*reinterpret_cast< bool*>(_v)); break; case 2: setNotchTarget(*reinterpret_cast< qreal*>(_v)); break; case 3: setNotchesVisible(*reinterpret_cast< bool*>(_v)); break; } _id -= 4; } else if (_c == QMetaObject::ResetProperty) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 4; } #endif // QT_NO_PROPERTIES return _id; }
/****************************************************************************** * Adds a positive or negative increment to the current value, wrapping as appropriate. * If 'current' is true, any temporary 'shift' values for the range are used instead * of the real maximum and minimum values. */ void SpinBox::addValue(int change, bool current) { int newval = value() + change; int maxval = current ? QSpinBox::maximum() : mMaxValue; int minval = current ? QSpinBox::minimum() : mMinValue; if (wrapping()) { int range = maxval - minval + 1; if (newval > maxval) newval = minval + (newval - maxval - 1) % range; else if (newval < minval) newval = maxval - (minval - 1 - newval) % range; } else { if (newval > maxval) newval = maxval; else if (newval < minval) newval = minval; } setValue(newval); }
/*! Find the value for a given position \param pos Position \return Value */ double QwtDial::getValue( const QPoint &pos ) { if ( d_data->maxScaleArc == d_data->minScaleArc || maxValue() == minValue() ) return minValue(); double dir = line2Radians( innerRect().center(), pos ) - d_data->origin; if ( dir < 0.0 ) dir += 360.0; if ( mode() == RotateScale ) dir = 360.0 - dir; // The position might be in the area that is outside the scale arc. // We need the range of the scale if it was a complete circle. const double completeCircle = 360.0 / ( d_data->maxScaleArc - d_data->minScaleArc ) * ( maxValue() - minValue() ); double posValue = minValue() + completeCircle * dir / 360.0; if ( scrollMode() == ScrMouse ) { if ( d_data->previousDir >= 0.0 ) // valid direction { // We have to find out whether the mouse is moving // clock or counter clockwise bool clockWise = false; const double angle = dir - d_data->previousDir; if ( ( angle >= 0.0 && angle <= 180.0 ) || angle < -180.0 ) clockWise = true; if ( clockWise ) { if ( dir < d_data->previousDir && mouseOffset() > 0.0 ) { // We passed 360 -> 0 setMouseOffset( mouseOffset() - completeCircle ); } if ( wrapping() ) { if ( posValue - mouseOffset() > maxValue() ) { // We passed maxValue and the value will be set // to minValue. We have to adjust the mouseOffset. setMouseOffset( posValue - minValue() ); } } else { if ( posValue - mouseOffset() > maxValue() || value() == maxValue() ) { // We fix the value at maxValue by adjusting // the mouse offset. setMouseOffset( posValue - maxValue() ); } } } else { if ( dir > d_data->previousDir && mouseOffset() < 0.0 ) { // We passed 0 -> 360 setMouseOffset( mouseOffset() + completeCircle ); } if ( wrapping() ) { if ( posValue - mouseOffset() < minValue() ) { // We passed minValue and the value will be set // to maxValue. We have to adjust the mouseOffset. setMouseOffset( posValue - maxValue() ); } } else { if ( posValue - mouseOffset() < minValue() || value() == minValue() ) { // We fix the value at minValue by adjusting // the mouse offset. setMouseOffset( posValue - minValue() ); } } } } d_data->previousDir = dir; } return posValue; }
/****************************************************************************** * 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; }
Texture<GLubyte> Texture<GLubyte>::copy() const { Texture<GLubyte> texture(buffer().data(), filter(), internalFormat(), width(), height(), buffered(), wrapping()); if(borderColor() != vec4(0)) texture.setBorderColor(borderColor()); return texture; }
int KSimBaseIntSpinBox::setValueInternal(const KSimBaseInt & newValue) { // KSIMDEBUG(QString::fromLatin1(">>> KSimBaseIntSpinBox::setValueInternal() this=%1 newValue=%2").arg((unsigned int)this,0, 16).arg(newValue.text())); bool toggle = true; int res = KSimSpinBox::value(); int val = newValue.value(); // if (newValue != value()) { // KSIMDEBUG_VAR("KSimBaseIntSpinBox::setValueInternal()", val); // Value changed if (wrapping()) { if (val > maxValue()) { val = minValue(); } else if (val < minValue()) { val = maxValue(); } if (val >= maxValue()) { res = Private::s_upperLimit; toggle = false; } else if (val <= minValue()) { res = Private::s_lowerLimit; toggle = false; } } else // (wrapping()) { if (val >= maxValue()) { // KSIMDEBUG("newValue >= maxValue()"); val = maxValue(); res = Private::s_upperLimit; toggle = false; } else if (val <= minValue()) { // KSIMDEBUG("newValue <= minValue()"); val = minValue(); res = Private::s_lowerLimit; toggle = false; } } if(toggle) { // KSIMDEBUG("toggle"); res = (res == Private::s_toggle0) ? Private::s_toggle1 : Private::s_toggle0; } KSimBaseInt i(val, newValue.base()); // KSIMDEBUG_VAR("KSimBaseIntSpinBox::setValueInternal", i.text()); m_p->setValue(i); } // KSIMDEBUG("<<< KSimBaseIntSpinBox::setValueInternal()"); return res; }