Newer
Older
/*!
\return True, when the step alignment is enabled
\sa setStepAlignment(), singleStep()
*/
bool QwtWheel::stepAlignment() const
/*!
\brief Set the page step count
pageStepCount is a multiplicator for the single step size
that typically corresponds to the user pressing PageUp or PageDown.
A value of 0 disables page stepping.
The default value is 1.
\param count Multiplicator for the single step size
\sa pageStepCount(), setSingleStep()
*/
void QwtWheel::setPageStepCount( int count )
/*!
\return Page step count
\sa setPageStepCount(), singleStep()
*/
int QwtWheel::pageStepCount() const
{
return d_data->pageStepCount;
}
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
/*!
\brief Set the minimum and maximum values
The maximum is adjusted if necessary to ensure that the range remains valid.
The value might be modified to be inside of the range.
\param min Minimum value
\param max Maximum value
\sa minimum(), maximum()
*/
void QwtWheel::setRange( double min, double max )
{
max = qMax( min, max );
if ( d_data->minimum == min && d_data->maximum == max )
return;
d_data->minimum = min;
d_data->maximum = max;
if ( d_data->value < min || d_data->value > max )
{
d_data->value = qBound( min, d_data->value, max );
update();
Q_EMIT valueChanged( d_data->value );
}
\param value Minimum value
\sa setRange(), setMaximum(), minimum()
\note The maximum is adjusted if necessary to ensure that the range remains valid.
*/
void QwtWheel::setMinimum( double value )
/*!
\return The minimum of the range
\sa setRange(), setMinimum(), maximum()
*/
double QwtWheel::minimum() const
{
return d_data->minimum;
}
Set the maximum value of the range
\param value Maximum value
\sa setRange(), setMinimum(), maximum()
/*!
\return The maximum of the range
\sa setRange(), setMaximum(), minimum()
*/
double QwtWheel::maximum() const
{
return d_data->maximum;
\brief Set a new value without adjusting to the step raster
\param value New value
\sa value(), valueChanged()
\warning The value is clipped when it lies outside the range.
stopFlying();
d_data->isScrolling = false;
value = qBound( d_data->minimum, value, d_data->maximum );
if ( d_data->value != value )
{
d_data->value = value;
update();
Q_EMIT valueChanged( d_data->value );
}
\return Current value of the wheel
\sa setValue(), valueChanged()
*/
double QwtWheel::value() const
{
return d_data->value;
}
/*!
\brief En/Disable inverted appearance
An inverted wheel increases its values in the opposite direction.
The direction of an inverted horizontal wheel will be from right to left
an inverted vertical wheel will increase from bottom to top.
\param on En/Disable inverted appearance
\sa isInverted()
*/
void QwtWheel::setInverted( bool on )
if ( d_data->inverted != on )
{
d_data->inverted = on;
update();
}
\return True, when the wheel is inverted
\sa setInverted()
*/
bool QwtWheel::isInverted() const
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
\brief En/Disable wrapping
If wrapping is true stepping up from maximum() value will take
you to the minimum() value and vice versa.
\param on En/Disable wrapping
\sa wrapping()
*/
void QwtWheel::setWrapping( bool on )
{
d_data->wrapping = on;
}
/*!
\return True, when wrapping is set
\sa setWrapping()
*/
bool QwtWheel::wrapping() const
{
return d_data->wrapping;
}
/*!
\brief Set the slider's mass for flywheel effect.
If the slider's mass is greater then 0, it will continue
to move after the mouse button has been released. Its speed
decreases with time at a rate depending on the slider's mass.
A large mass means that it will continue to move for a
long time.
Derived widgets may overload this function to make it public.
\param mass New mass in kg
\bug If the mass is smaller than 1g, it is set to zero.
The maximal mass is limited to 100kg.
\sa mass()
if ( mass < 0.001 )
{
d_data->mass = 0.0;
}
else
{
d_data->mass = qMin( 100.0, mass );
}
if ( d_data->mass <= 0.0 )
stopFlying();
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
return d_data->mass;
}
//! Stop the flying movement of the wheel
void QwtWheel::stopFlying()
{
if ( d_data->timerId != 0 )
{
killTimer( d_data->timerId );
d_data->timerId = 0;
d_data->speed = 0.0;
}
}
double QwtWheel::boundedValue( double value ) const
{
const double range = d_data->maximum - d_data->minimum;
if ( d_data->wrapping && range >= 0.0 )
{
if ( value < d_data->minimum )
{
value += ::ceil( ( d_data->minimum - value ) / range ) * range;
}
else if ( value > d_data->maximum )
{
value -= ::ceil( ( value - d_data->maximum ) / range ) * range;
}
}
else
{
value = qBound( d_data->minimum, value, d_data->maximum );
}
return value;
}
double QwtWheel::alignedValue( double value ) const
{
const double stepSize = d_data->singleStep;
if ( stepSize > 0.0 )
{
value = d_data->minimum +
qRound( ( value - d_data->minimum ) / stepSize ) * stepSize;
if ( stepSize > 1e-12 )
{
if ( qFuzzyCompare( value + 1.0, 1.0 ) )
{
// correct rounding error if value = 0
value = 0.0;
}
else if ( qFuzzyCompare( value, d_data->maximum ) )
{
// correct rounding error at the border
value = d_data->maximum;
}
}
}
return value;