qwt_wheel.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #include "qwt_wheel.h"
11 #include "qwt_math.h"
12 #include "qwt_painter.h"
13 #include <qevent.h>
14 #include <qdrawutil.h>
15 #include <qpainter.h>
16 #include <qstyle.h>
17 #include <qstyleoption.h>
18 #include <qapplication.h>
19 #include <qdatetime.h>
20 
21 #if QT_VERSION < 0x040601
22 #define qFabs(x) ::fabs(x)
23 #define qFastSin(x) ::sin(x)
24 #define qExp(x) ::exp(x)
25 #endif
26 
28 {
29 public:
31  orientation( Qt::Horizontal ),
32  viewAngle( 175.0 ),
33  totalAngle( 360.0 ),
34  tickCount( 10 ),
35  wheelBorderWidth( 2 ),
36  borderWidth( 2 ),
37  wheelWidth( 20 ),
38  isScrolling( false ),
39  mouseOffset( 0.0 ),
40  tracking( true ),
41  pendingValueChanged( false ),
42  updateInterval( 50 ),
43  mass( 0.0 ),
44  timerId( 0 ),
45  speed( 0.0 ),
46  mouseValue( 0.0 ),
47  flyingValue( 0.0 ),
48  minimum( 0.0 ),
49  maximum( 100.0 ),
50  singleStep( 1.0 ),
51  pageStepCount( 1 ),
52  stepAlignment( true ),
53  value( 0.0 ),
54  inverted( false ),
55  wrapping( false )
56  {
57  };
58 
59  Qt::Orientation orientation;
60  double viewAngle;
61  double totalAngle;
62  int tickCount;
66 
68  double mouseOffset;
69 
70  bool tracking;
71  bool pendingValueChanged; // when not tracking
72 
74  double mass;
75 
76  // for the flying wheel effect
77  int timerId;
78  QTime time;
79  double speed;
80  double mouseValue;
81  double flyingValue;
82 
83  double minimum;
84  double maximum;
85 
86  double singleStep;
89 
90  double value;
91 
92  bool inverted;
93  bool wrapping;
94 };
95 
97 QwtWheel::QwtWheel( QWidget *parent ):
98  QWidget( parent )
99 {
100  d_data = new PrivateData;
101 
102  setFocusPolicy( Qt::StrongFocus );
103  setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
104  setAttribute( Qt::WA_WState_OwnSizePolicy, false );
105 }
106 
109 {
110  delete d_data;
111 }
112 
125 void QwtWheel::setTracking( bool enable )
126 {
127  d_data->tracking = enable;
128 }
129 
135 {
136  return d_data->tracking;
137 }
138 
147 void QwtWheel::setUpdateInterval( int interval )
148 {
149  d_data->updateInterval = qMax( interval, 50 );
150 }
151 
156 int QwtWheel::updateInterval() const
157 {
158  return d_data->updateInterval;
159 }
160 
168 void QwtWheel::mousePressEvent( QMouseEvent *event )
169 {
170  stopFlying();
171 
172  d_data->isScrolling = wheelRect().contains( event->pos() );
173 
174  if ( d_data->isScrolling )
175  {
176  d_data->time.start();
177  d_data->speed = 0.0;
178  d_data->mouseValue = valueAt( event->pos() );
180  d_data->pendingValueChanged = false;
181 
182  Q_EMIT wheelPressed();
183  }
184 }
185 
193 void QwtWheel::mouseMoveEvent( QMouseEvent *event )
194 {
195  if ( !d_data->isScrolling )
196  return;
197 
198  double mouseValue = valueAt( event->pos() );
199 
200  if ( d_data->mass > 0.0 )
201  {
202  double ms = d_data->time.restart();
203 
204  // the interval when mouse move events are posted are somehow
205  // random. To avoid unrealistic speed values we limit ms
206 
207  ms = qMax( ms, 5.0 );
208 
209  d_data->speed = ( mouseValue - d_data->mouseValue ) / ms;
210  }
211 
212  d_data->mouseValue = mouseValue;
213 
214  double value = boundedValue( mouseValue - d_data->mouseOffset );
215  if ( d_data->stepAlignment )
216  value = alignedValue( value );
217 
218  if ( value != d_data->value )
219  {
220  d_data->value = value;
221 
222  update();
223 
224  Q_EMIT wheelMoved( d_data->value );
225 
226  if ( d_data->tracking )
227  Q_EMIT valueChanged( d_data->value );
228  else
229  d_data->pendingValueChanged = true;
230  }
231 }
232 
242 void QwtWheel::mouseReleaseEvent( QMouseEvent *event )
243 {
244  Q_UNUSED( event );
245 
246  if ( !d_data->isScrolling )
247  return;
248 
249  d_data->isScrolling = false;
250 
251  bool startFlying = false;
252 
253  if ( d_data->mass > 0.0 )
254  {
255  const int ms = d_data->time.elapsed();
256  if ( ( qFabs( d_data->speed ) > 0.0 ) && ( ms < 50 ) )
257  startFlying = true;
258  }
259 
260  if ( startFlying )
261  {
262  d_data->flyingValue =
264 
265  d_data->timerId = startTimer( d_data->updateInterval );
266  }
267  else
268  {
270  Q_EMIT valueChanged( d_data->value );
271  }
272 
273  d_data->pendingValueChanged = false;
274  d_data->mouseOffset = 0.0;
275 
276  Q_EMIT wheelReleased();
277 }
278 
288 void QwtWheel::timerEvent( QTimerEvent *event )
289 {
290  if ( event->timerId() != d_data->timerId )
291  {
292  QWidget::timerEvent( event );
293  return;
294  }
295 
296  d_data->speed *= qExp( -d_data->updateInterval * 0.001 / d_data->mass );
297 
300 
301  double value = d_data->flyingValue;
302  if ( d_data->stepAlignment )
303  value = alignedValue( value );
304 
305  if ( qFabs( d_data->speed ) < 0.001 * d_data->singleStep )
306  {
307  // stop if d_data->speed < one step per second
308  stopFlying();
309  }
310 
311  if ( value != d_data->value )
312  {
313  d_data->value = value;
314  update();
315 
316  if ( d_data->tracking || d_data->timerId == 0 )
317  Q_EMIT valueChanged( d_data->value );
318  }
319 }
320 
321 
329 void QwtWheel::wheelEvent( QWheelEvent *event )
330 {
331  if ( !wheelRect().contains( event->pos() ) )
332  {
333  event->ignore();
334  return;
335  }
336 
337  if ( d_data->isScrolling )
338  return;
339 
340  stopFlying();
341 
342  double increment = 0.0;
343 
344  if ( ( event->modifiers() & Qt::ControlModifier) ||
345  ( event->modifiers() & Qt::ShiftModifier ) )
346  {
347  // one page regardless of delta
348  increment = d_data->singleStep * d_data->pageStepCount;
349  if ( event->delta() < 0 )
350  increment = -increment;
351  }
352  else
353  {
354  const int numSteps = event->delta() / 120;
355  increment = d_data->singleStep * numSteps;
356  }
357 
358  if ( d_data->orientation == Qt::Vertical && d_data->inverted )
359  increment = -increment;
360 
361  double value = boundedValue( d_data->value + increment );
362 
363  if ( d_data->stepAlignment )
364  value = alignedValue( value );
365 
366  if ( value != d_data->value )
367  {
368  d_data->value = value;
369  update();
370 
371  Q_EMIT valueChanged( d_data->value );
372  Q_EMIT wheelMoved( d_data->value );
373  }
374 }
375 
403 void QwtWheel::keyPressEvent( QKeyEvent *event )
404 {
405  if ( d_data->isScrolling )
406  {
407  // don't interfere mouse scrolling
408  return;
409  }
410 
411  double value = d_data->value;
412  double increment = 0.0;
413 
414  switch ( event->key() )
415  {
416  case Qt::Key_Down:
417  {
418  if ( d_data->orientation == Qt::Vertical && d_data->inverted )
419  increment = d_data->singleStep;
420  else
421  increment = -d_data->singleStep;
422 
423  break;
424  }
425  case Qt::Key_Up:
426  {
427  if ( d_data->orientation == Qt::Vertical && d_data->inverted )
428  increment = -d_data->singleStep;
429  else
430  increment = d_data->singleStep;
431 
432  break;
433  }
434  case Qt::Key_Left:
435  {
436  if ( d_data->orientation == Qt::Horizontal )
437  {
438  if ( d_data->inverted )
439  increment = d_data->singleStep;
440  else
441  increment = -d_data->singleStep;
442  }
443  break;
444  }
445  case Qt::Key_Right:
446  {
447  if ( d_data->orientation == Qt::Horizontal )
448  {
449  if ( d_data->inverted )
450  increment = -d_data->singleStep;
451  else
452  increment = d_data->singleStep;
453  }
454  break;
455  }
456  case Qt::Key_PageUp:
457  {
458  increment = d_data->pageStepCount * d_data->singleStep;
459  break;
460  }
461  case Qt::Key_PageDown:
462  {
463  increment = -d_data->pageStepCount * d_data->singleStep;
464  break;
465  }
466  case Qt::Key_Home:
467  {
468  value = d_data->minimum;
469  break;
470  }
471  case Qt::Key_End:
472  {
473  value = d_data->maximum;
474  break;
475  }
476  default:;
477  {
478  event->ignore();
479  }
480  }
481 
482  if ( event->isAccepted() )
483  stopFlying();
484 
485  if ( increment != 0.0 )
486  {
487  value = boundedValue( d_data->value + increment );
488 
489  if ( d_data->stepAlignment )
490  value = alignedValue( value );
491  }
492 
493  if ( value != d_data->value )
494  {
495  d_data->value = value;
496  update();
497 
498  Q_EMIT valueChanged( d_data->value );
499  Q_EMIT wheelMoved( d_data->value );
500  }
501 }
502 
513 void QwtWheel::setTickCount( int count )
514 {
515  count = qBound( 6, count, 50 );
516 
517  if ( count != d_data->tickCount )
518  {
519  d_data->tickCount = qBound( 6, count, 50 );
520  update();
521  }
522 }
523 
528 int QwtWheel::tickCount() const
529 {
530  return d_data->tickCount;
531 }
532 
546 {
547  const int d = qMin( width(), height() ) / 3;
548  borderWidth = qMin( borderWidth, d );
549  d_data->wheelBorderWidth = qMax( borderWidth, 1 );
550  update();
551 }
552 
557 int QwtWheel::wheelBorderWidth() const
558 {
559  return d_data->wheelBorderWidth;
560 }
561 
570 void QwtWheel::setBorderWidth( int width )
571 {
572  d_data->borderWidth = qMax( width, 0 );
573  update();
574 }
575 
580 int QwtWheel::borderWidth() const
581 {
582  return d_data->borderWidth;
583 }
584 
588 QRect QwtWheel::wheelRect() const
589 {
590  const int bw = d_data->borderWidth;
591  return contentsRect().adjusted( bw, bw, -bw, -bw );
592 }
593 
607 void QwtWheel::setTotalAngle( double angle )
608 {
609  if ( angle < 0.0 )
610  angle = 0.0;
611 
612  d_data->totalAngle = angle;
613  update();
614 }
615 
620 double QwtWheel::totalAngle() const
621 {
622  return d_data->totalAngle;
623 }
624 
633 void QwtWheel::setOrientation( Qt::Orientation orientation )
634 {
635  if ( d_data->orientation == orientation )
636  return;
637 
638  if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
639  {
640  QSizePolicy sp = sizePolicy();
641  sp.transpose();
642  setSizePolicy( sp );
643 
644  setAttribute( Qt::WA_WState_OwnSizePolicy, false );
645  }
646 
648  update();
649 }
650 
655 Qt::Orientation QwtWheel::orientation() const
656 {
657  return d_data->orientation;
658 }
659 
670 void QwtWheel::setViewAngle( double angle )
671 {
672  d_data->viewAngle = qBound( 10.0, angle, 175.0 );
673  update();
674 }
675 
680 double QwtWheel::viewAngle() const
681 {
682  return d_data->viewAngle;
683 }
684 
691 double QwtWheel::valueAt( const QPoint &pos ) const
692 {
693  const QRectF rect = wheelRect();
694 
695  double w, dx;
696  if ( d_data->orientation == Qt::Vertical )
697  {
698  w = rect.height();
699  dx = rect.top() - pos.y();
700  }
701  else
702  {
703  w = rect.width();
704  dx = pos.x() - rect.left();
705  }
706 
707  if ( w == 0.0 )
708  return 0.0;
709 
710  if ( d_data->inverted )
711  {
712  dx = w - dx;
713  }
714 
715  // w pixels is an arc of viewAngle degrees,
716  // so we convert change in pixels to change in angle
717  const double ang = dx * d_data->viewAngle / w;
718 
719  // value range maps to totalAngle degrees,
720  // so convert the change in angle to a change in value
721  const double val = ang * ( maximum() - minimum() ) / d_data->totalAngle;
722 
723  return val;
724 }
725 
730 void QwtWheel::paintEvent( QPaintEvent *event )
731 {
732  QPainter painter( this );
733  painter.setClipRegion( event->region() );
734 
735  QStyleOption opt;
736  opt.init(this);
737  style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
738 
739  qDrawShadePanel( &painter,
740  contentsRect(), palette(), true, d_data->borderWidth );
741 
742  drawWheelBackground( &painter, wheelRect() );
743  drawTicks( &painter, wheelRect() );
744 
745  if ( hasFocus() )
746  QwtPainter::drawFocusRect( &painter, this );
747 }
748 
756  QPainter *painter, const QRectF &rect )
757 {
758  painter->save();
759 
760  QPalette pal = palette();
761 
762  // draw shaded background
763  QLinearGradient gradient( rect.topLeft(),
764  ( d_data->orientation == Qt::Horizontal ) ? rect.topRight() : rect.bottomLeft() );
765  gradient.setColorAt( 0.0, pal.color( QPalette::Button ) );
766  gradient.setColorAt( 0.2, pal.color( QPalette::Midlight ) );
767  gradient.setColorAt( 0.7, pal.color( QPalette::Mid ) );
768  gradient.setColorAt( 1.0, pal.color( QPalette::Dark ) );
769 
770  painter->fillRect( rect, gradient );
771 
772  // draw internal border
773 
774  const QPen lightPen( palette().color( QPalette::Light ),
775  d_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap );
776  const QPen darkPen( pal.color( QPalette::Dark ),
777  d_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap );
778 
779  const double bw2 = 0.5 * d_data->wheelBorderWidth;
780 
781  if ( d_data->orientation == Qt::Horizontal )
782  {
783  painter->setPen( lightPen );
784  painter->drawLine( QPointF( rect.left(), rect.top() + bw2 ),
785  QPointF( rect.right(), rect.top() + bw2 ) );
786 
787  painter->setPen( darkPen );
788  painter->drawLine( QPointF( rect.left(), rect.bottom() - bw2 ),
789  QPointF( rect.right(), rect.bottom() - bw2 ) );
790  }
791  else // Qt::Vertical
792  {
793  painter->setPen( lightPen );
794  painter->drawLine( QPointF( rect.left() + bw2, rect.top() ),
795  QPointF( rect.left() + bw2, rect.bottom() ) );
796 
797  painter->setPen( darkPen );
798  painter->drawLine( QPointF( rect.right() - bw2, rect.top() ),
799  QPointF( rect.right() - bw2, rect.bottom() ) );
800  }
801 
802  painter->restore();
803 }
804 
811 void QwtWheel::drawTicks( QPainter *painter, const QRectF &rect )
812 {
813  const double range = d_data->maximum - d_data->minimum;
814 
815  if ( range == 0.0 || d_data->totalAngle == 0.0 )
816  {
817  return;
818  }
819 
820  const QPen lightPen( palette().color( QPalette::Light ),
821  0, Qt::SolidLine, Qt::FlatCap );
822  const QPen darkPen( palette().color( QPalette::Dark ),
823  0, Qt::SolidLine, Qt::FlatCap );
824 
825  const double cnvFactor = qAbs( d_data->totalAngle / range );
826  const double halfIntv = 0.5 * d_data->viewAngle / cnvFactor;
827  const double loValue = value() - halfIntv;
828  const double hiValue = value() + halfIntv;
829  const double tickWidth = 360.0 / double( d_data->tickCount ) / cnvFactor;
830  const double sinArc = qFastSin( d_data->viewAngle * M_PI / 360.0 );
831 
832  if ( d_data->orientation == Qt::Horizontal )
833  {
834  const double radius = rect.width() * 0.5;
835 
836  double l1 = rect.top() + d_data->wheelBorderWidth;
837  double l2 = rect.bottom() - d_data->wheelBorderWidth - 1;
838 
839  // draw one point over the border if border > 1
840  if ( d_data->wheelBorderWidth > 1 )
841  {
842  l1--;
843  l2++;
844  }
845 
846  const double maxpos = rect.right() - 2;
847  const double minpos = rect.left() + 2;
848 
849  // draw tick marks
850  for ( double tickValue = ::ceil( loValue / tickWidth ) * tickWidth;
851  tickValue < hiValue; tickValue += tickWidth )
852  {
853  const double angle = qwtRadians( tickValue - value() );
854  const double s = qFastSin( angle * cnvFactor );
855 
856  const double off = radius * ( sinArc + s ) / sinArc;
857 
858  double tickPos;
859  if ( d_data->inverted )
860  tickPos = rect.left() + off;
861  else
862  tickPos = rect.right() - off;
863 
864  if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) )
865  {
866  painter->setPen( darkPen );
867  painter->drawLine( QPointF( tickPos - 1 , l1 ),
868  QPointF( tickPos - 1, l2 ) );
869  painter->setPen( lightPen );
870  painter->drawLine( QPointF( tickPos, l1 ),
871  QPointF( tickPos, l2 ) );
872  }
873  }
874  }
875  else // Qt::Vertical
876  {
877  const double radius = rect.height() * 0.5;
878 
879  double l1 = rect.left() + d_data->wheelBorderWidth;
880  double l2 = rect.right() - d_data->wheelBorderWidth - 1;
881 
882  if ( d_data->wheelBorderWidth > 1 )
883  {
884  l1--;
885  l2++;
886  }
887 
888  const double maxpos = rect.bottom() - 2;
889  const double minpos = rect.top() + 2;
890 
891  for ( double tickValue = ::ceil( loValue / tickWidth ) * tickWidth;
892  tickValue < hiValue; tickValue += tickWidth )
893  {
894  const double angle = qwtRadians( tickValue - value() );
895  const double s = qFastSin( angle * cnvFactor );
896 
897  const double off = radius * ( sinArc + s ) / sinArc;
898 
899  double tickPos;
900 
901  if ( d_data->inverted )
902  tickPos = rect.bottom() - off;
903  else
904  tickPos = rect.top() + off;
905 
906  if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) )
907  {
908  painter->setPen( darkPen );
909  painter->drawLine( QPointF( l1, tickPos - 1 ),
910  QPointF( l2, tickPos - 1 ) );
911  painter->setPen( lightPen );
912  painter->drawLine( QPointF( l1, tickPos ),
913  QPointF( l2, tickPos ) );
914  }
915  }
916  }
917 }
918 
928 void QwtWheel::setWheelWidth( int width )
929 {
930  d_data->wheelWidth = width;
931  update();
932 }
933 
938 int QwtWheel::wheelWidth() const
939 {
940  return d_data->wheelWidth;
941 }
942 
946 QSize QwtWheel::sizeHint() const
947 {
948  const QSize hint = minimumSizeHint();
949  return hint.expandedTo( QApplication::globalStrut() );
950 }
951 
957 {
958  QSize sz( 3 * d_data->wheelWidth + 2 * d_data->borderWidth,
960  if ( d_data->orientation != Qt::Horizontal )
961  sz.transpose();
962 
963  return sz;
964 }
965 
974 void QwtWheel::setSingleStep( double stepSize )
975 {
976  d_data->singleStep = qMax( stepSize, 0.0 );
977 }
978 
983 double QwtWheel::singleStep() const
984 {
985  return d_data->singleStep;
986 }
987 
999 {
1000  if ( on != d_data->stepAlignment )
1001  {
1002  d_data->stepAlignment = on;
1003  }
1004 }
1005 
1010 bool QwtWheel::stepAlignment() const
1011 {
1012  return d_data->stepAlignment;
1013 }
1014 
1029 {
1030  d_data->pageStepCount = qMax( 0, count );
1031 }
1032 
1037 int QwtWheel::pageStepCount() const
1038 {
1039  return d_data->pageStepCount;
1040 }
1041 
1053 void QwtWheel::setRange( double min, double max )
1054 {
1055  max = qMax( min, max );
1056 
1057  if ( d_data->minimum == min && d_data->maximum == max )
1058  return;
1059 
1060  d_data->minimum = min;
1061  d_data->maximum = max;
1062 
1063  if ( d_data->value < min || d_data->value > max )
1064  {
1065  d_data->value = qBound( min, d_data->value, max );
1066 
1067  update();
1068  Q_EMIT valueChanged( d_data->value );
1069  }
1070 }
1080 {
1081  setRange( value, maximum() );
1082 }
1083 
1088 double QwtWheel::minimum() const
1089 {
1090  return d_data->minimum;
1091 }
1092 
1100 {
1101  setRange( minimum(), value );
1102 }
1103 
1108 double QwtWheel::maximum() const
1109 {
1110  return d_data->maximum;
1111 }
1112 
1122 {
1123  stopFlying();
1124  d_data->isScrolling = false;
1125 
1126  value = qBound( d_data->minimum, value, d_data->maximum );
1127 
1128  if ( d_data->value != value )
1129  {
1130  d_data->value = value;
1131 
1132  update();
1133  Q_EMIT valueChanged( d_data->value );
1134  }
1135 }
1136 
1141 double QwtWheel::value() const
1142 {
1143  return d_data->value;
1144 }
1145 
1157 void QwtWheel::setInverted( bool on )
1158 {
1159  if ( d_data->inverted != on )
1160  {
1161  d_data->inverted = on;
1162  update();
1163  }
1164 }
1165 
1171 {
1172  return d_data->inverted;
1173 }
1174 
1184 void QwtWheel::setWrapping( bool on )
1185 {
1186  d_data->wrapping = on;
1187 }
1188 
1193 bool QwtWheel::wrapping() const
1194 {
1195  return d_data->wrapping;
1196 }
1197 
1215 void QwtWheel::setMass( double mass )
1216 {
1217  if ( mass < 0.001 )
1218  {
1219  d_data->mass = 0.0;
1220  }
1221  else
1222  {
1223  d_data->mass = qMin( 100.0, mass );
1224  }
1225 
1226  if ( d_data->mass <= 0.0 )
1227  stopFlying();
1228 }
1229 
1234 double QwtWheel::mass() const
1235 {
1236  return d_data->mass;
1237 }
1238 
1241 {
1242  if ( d_data->timerId != 0 )
1243  {
1244  killTimer( d_data->timerId );
1245  d_data->timerId = 0;
1246  d_data->speed = 0.0;
1247  }
1248 }
1249 
1250 double QwtWheel::boundedValue( double value ) const
1251 {
1252  const double range = d_data->maximum - d_data->minimum;
1253 
1254  if ( d_data->wrapping && range >= 0.0 )
1255  {
1256  if ( value < d_data->minimum )
1257  {
1258  value += ::ceil( ( d_data->minimum - value ) / range ) * range;
1259  }
1260  else if ( value > d_data->maximum )
1261  {
1262  value -= ::ceil( ( value - d_data->maximum ) / range ) * range;
1263  }
1264  }
1265  else
1266  {
1267  value = qBound( d_data->minimum, value, d_data->maximum );
1268  }
1269 
1270  return value;
1271 }
1272 
1273 double QwtWheel::alignedValue( double value ) const
1274 {
1275  const double stepSize = d_data->singleStep;
1276 
1277  if ( stepSize > 0.0 )
1278  {
1279  value = d_data->minimum +
1280  qRound( ( value - d_data->minimum ) / stepSize ) * stepSize;
1281 
1282  if ( stepSize > 1e-12 )
1283  {
1284  if ( qFuzzyCompare( value + 1.0, 1.0 ) )
1285  {
1286  // correct rounding error if value = 0
1287  value = 0.0;
1288  }
1289  else if ( qFuzzyCompare( value, d_data->maximum ) )
1290  {
1291  // correct rounding error at the border
1292  value = d_data->maximum;
1293  }
1294  }
1295  }
1296 
1297  return value;
1298 }
1299 
void setOrientation(Qt::Orientation)
Set the wheel&#39;s orientation.
Definition: qwt_wheel.cpp:633
d
void wheelReleased()
double value() const
void setInverted(bool tf)
En/Disable inverted appearance.
Definition: qwt_wheel.cpp:1157
static void drawFocusRect(QPainter *, const QWidget *)
Draw a focus rectangle on a widget using its style.
#define qExp(x)
Definition: qwt_wheel.cpp:24
double totalAngle() const
virtual void paintEvent(QPaintEvent *)
Qt Paint Event.
Definition: qwt_wheel.cpp:730
int borderWidth() const
void setUpdateInterval(int)
Specify the update interval when the wheel is flying.
Definition: qwt_wheel.cpp:147
int tickCount() const
void setMaximum(double max)
Definition: qwt_wheel.cpp:1099
XmlRpcServer s
void setTracking(bool enable)
En/Disable tracking.
Definition: qwt_wheel.cpp:125
void setWheelBorderWidth(int)
Set the wheel border width of the wheel.
Definition: qwt_wheel.cpp:545
void setStepAlignment(bool on)
En/Disable step alignment.
Definition: qwt_wheel.cpp:998
bool isTracking() const
Definition: qwt_wheel.cpp:134
double singleStep() const
bool isInverted() const
Definition: qwt_wheel.cpp:1170
void setTotalAngle(double)
Set the total angle which the wheel can be turned.
Definition: qwt_wheel.cpp:607
int pageStepCount() const
virtual double valueAt(const QPoint &) const
Definition: qwt_wheel.cpp:691
double alignedValue(double) const
Definition: qwt_wheel.cpp:1273
void setRange(double vmin, double vmax)
Set the minimum and maximum values.
Definition: qwt_wheel.cpp:1053
virtual void keyPressEvent(QKeyEvent *)
Definition: qwt_wheel.cpp:403
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
double boundedValue(double) const
Definition: qwt_wheel.cpp:1250
double viewAngle() const
void setMinimum(double min)
Definition: qwt_wheel.cpp:1079
void wheelPressed()
virtual QSize sizeHint() const
Definition: qwt_wheel.cpp:946
virtual void wheelEvent(QWheelEvent *)
Handle wheel events.
Definition: qwt_wheel.cpp:329
double qwtRadians(double degrees)
Translate degrees into radians.
Definition: qwt_math.h:144
#define qFabs(x)
Definition: qwt_wheel.cpp:22
bool wrapping() const
void setWheelWidth(int)
Set the width of the wheel.
Definition: qwt_wheel.cpp:928
bool stepAlignment() const
virtual void mouseReleaseEvent(QMouseEvent *)
Mouse Release Event handler.
Definition: qwt_wheel.cpp:242
void setBorderWidth(int)
Set the border width.
Definition: qwt_wheel.cpp:570
void setWrapping(bool tf)
En/Disable wrapping.
Definition: qwt_wheel.cpp:1184
Qt::Orientation orientation() const
int wheelWidth() const
int updateInterval() const
Qt::Orientation orientation
Definition: qwt_wheel.cpp:57
void setTickCount(int)
Adjust the number of grooves in the wheel&#39;s surface.
Definition: qwt_wheel.cpp:513
virtual void drawWheelBackground(QPainter *, const QRectF &)
Definition: qwt_wheel.cpp:755
#define qFastSin(x)
Definition: qwt_wheel.cpp:23
TFSIMD_FORCE_INLINE const tfScalar & w() const
virtual void drawTicks(QPainter *, const QRectF &)
Definition: qwt_wheel.cpp:811
int wheelBorderWidth() const
double maximum() const
void setValue(double)
Set a new value without adjusting to the step raster.
Definition: qwt_wheel.cpp:1121
virtual ~QwtWheel()
Destructor.
Definition: qwt_wheel.cpp:108
void valueChanged(double value)
Notify a change of value.
virtual void mousePressEvent(QMouseEvent *)
Mouse press event handler.
Definition: qwt_wheel.cpp:168
QRect wheelRect() const
Definition: qwt_wheel.cpp:588
void setPageStepCount(int)
Set the page step count.
Definition: qwt_wheel.cpp:1028
QwtWheel(QWidget *parent=NULL)
Constructor.
Definition: qwt_wheel.cpp:97
PrivateData * d_data
Definition: qwt_wheel.h:175
void setSingleStep(double)
Set the step size of the counter.
Definition: qwt_wheel.cpp:974
void setMass(double)
Set the slider&#39;s mass for flywheel effect.
Definition: qwt_wheel.cpp:1215
double mass() const
void wheelMoved(double value)
void setViewAngle(double)
Specify the visible portion of the wheel.
Definition: qwt_wheel.cpp:670
double minimum() const
virtual void timerEvent(QTimerEvent *)
Qt timer event.
Definition: qwt_wheel.cpp:288
void stopFlying()
Stop the flying movement of the wheel.
Definition: qwt_wheel.cpp:1240
virtual QSize minimumSizeHint() const
Definition: qwt_wheel.cpp:956
virtual void mouseMoveEvent(QMouseEvent *)
Mouse Move Event handler.
Definition: qwt_wheel.cpp:193


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:18