14 #include <qdrawutil.h> 17 #include <qstyleoption.h> 18 #include <qapplication.h> 19 #include <qdatetime.h> 21 #if QT_VERSION < 0x040601 22 #define qFabs(x) ::fabs(x) 23 #define qFastSin(x) ::sin(x) 24 #define qExp(x) ::exp(x) 102 setFocusPolicy( Qt::StrongFocus );
103 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
104 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
198 double mouseValue =
valueAt( event->pos() );
207 ms = qMax( ms, 5.0 );
251 bool startFlying =
false;
292 QWidget::timerEvent( event );
331 if ( !
wheelRect().contains( event->pos() ) )
342 double increment = 0.0;
344 if ( ( event->modifiers() & Qt::ControlModifier) ||
345 ( event->modifiers() & Qt::ShiftModifier ) )
349 if ( event->delta() < 0 )
350 increment = -increment;
354 const int numSteps =
event->delta() / 120;
359 increment = -increment;
412 double increment = 0.0;
414 switch ( event->key() )
461 case Qt::Key_PageDown:
482 if ( event->isAccepted() )
485 if ( increment != 0.0 )
515 count = qBound( 6, count, 50 );
547 const int d = qMin( width(), height() ) / 3;
548 borderWidth = qMin( borderWidth, d );
591 return contentsRect().adjusted( bw, bw, -bw, -bw );
638 if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
640 QSizePolicy sp = sizePolicy();
644 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
699 dx = rect.top() - pos.y();
704 dx = pos.x() - rect.left();
732 QPainter painter(
this );
733 painter.setClipRegion( event->region() );
737 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
739 qDrawShadePanel( &painter,
756 QPainter *painter,
const QRectF &rect )
760 QPalette pal = palette();
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 ) );
770 painter->fillRect( rect, gradient );
774 const QPen lightPen( palette().color( QPalette::Light ),
776 const QPen darkPen( pal.color( QPalette::Dark ),
783 painter->setPen( lightPen );
784 painter->drawLine( QPointF( rect.left(), rect.top() + bw2 ),
785 QPointF( rect.right(), rect.top() + bw2 ) );
787 painter->setPen( darkPen );
788 painter->drawLine( QPointF( rect.left(), rect.bottom() - bw2 ),
789 QPointF( rect.right(), rect.bottom() - bw2 ) );
793 painter->setPen( lightPen );
794 painter->drawLine( QPointF( rect.left() + bw2, rect.top() ),
795 QPointF( rect.left() + bw2, rect.bottom() ) );
797 painter->setPen( darkPen );
798 painter->drawLine( QPointF( rect.right() - bw2, rect.top() ),
799 QPointF( rect.right() - bw2, rect.bottom() ) );
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 );
827 const double loValue =
value() - halfIntv;
828 const double hiValue =
value() + halfIntv;
829 const double tickWidth = 360.0 / double(
d_data->
tickCount ) / cnvFactor;
834 const double radius = rect.width() * 0.5;
846 const double maxpos = rect.right() - 2;
847 const double minpos = rect.left() + 2;
850 for (
double tickValue = ::ceil( loValue / tickWidth ) * tickWidth;
851 tickValue < hiValue; tickValue += tickWidth )
854 const double s =
qFastSin( angle * cnvFactor );
856 const double off = radius * ( sinArc + s ) / sinArc;
860 tickPos = rect.left() + off;
862 tickPos = rect.right() - off;
864 if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) )
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 ) );
877 const double radius = rect.height() * 0.5;
888 const double maxpos = rect.bottom() - 2;
889 const double minpos = rect.top() + 2;
891 for (
double tickValue = ::ceil( loValue / tickWidth ) * tickWidth;
892 tickValue < hiValue; tickValue += tickWidth )
895 const double s =
qFastSin( angle * cnvFactor );
897 const double off = radius * ( sinArc + s ) / sinArc;
902 tickPos = rect.bottom() - off;
904 tickPos = rect.top() + off;
906 if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) )
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 ) );
949 return hint.expandedTo( QApplication::globalStrut() );
1055 max = qMax( min, max );
1256 if ( value < d_data->
minimum )
1258 value += ::ceil( (
d_data->
minimum - value ) / range ) * range;
1262 value -= ::ceil( ( value -
d_data->
maximum ) / range ) * range;
1277 if ( stepSize > 0.0 )
1280 qRound( ( value -
d_data->
minimum ) / stepSize ) * stepSize;
1282 if ( stepSize > 1e-12 )
1284 if ( qFuzzyCompare( value + 1.0, 1.0 ) )
void setOrientation(Qt::Orientation)
Set the wheel's orientation.
void setInverted(bool tf)
En/Disable inverted appearance.
static void drawFocusRect(QPainter *, const QWidget *)
Draw a focus rectangle on a widget using its style.
double totalAngle() const
virtual void paintEvent(QPaintEvent *)
Qt Paint Event.
void setUpdateInterval(int)
Specify the update interval when the wheel is flying.
void setMaximum(double max)
void setTracking(bool enable)
En/Disable tracking.
void setWheelBorderWidth(int)
Set the wheel border width of the wheel.
void setStepAlignment(bool on)
En/Disable step alignment.
double singleStep() const
void setTotalAngle(double)
Set the total angle which the wheel can be turned.
int pageStepCount() const
virtual double valueAt(const QPoint &) const
double alignedValue(double) const
void setRange(double vmin, double vmax)
Set the minimum and maximum values.
virtual void keyPressEvent(QKeyEvent *)
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
void setMinimum(double min)
virtual QSize sizeHint() const
virtual void wheelEvent(QWheelEvent *)
Handle wheel events.
double qwtRadians(double degrees)
Translate degrees into radians.
void setWheelWidth(int)
Set the width of the wheel.
bool stepAlignment() const
virtual void mouseReleaseEvent(QMouseEvent *)
Mouse Release Event handler.
void setBorderWidth(int)
Set the border width.
void setWrapping(bool tf)
En/Disable wrapping.
Qt::Orientation orientation() const
int updateInterval() const
Qt::Orientation orientation
void setTickCount(int)
Adjust the number of grooves in the wheel's surface.
virtual void drawWheelBackground(QPainter *, const QRectF &)
TFSIMD_FORCE_INLINE const tfScalar & w() const
virtual void drawTicks(QPainter *, const QRectF &)
int wheelBorderWidth() const
void setValue(double)
Set a new value without adjusting to the step raster.
virtual ~QwtWheel()
Destructor.
void valueChanged(double value)
Notify a change of value.
virtual void mousePressEvent(QMouseEvent *)
Mouse press event handler.
void setPageStepCount(int)
Set the page step count.
QwtWheel(QWidget *parent=NULL)
Constructor.
void setSingleStep(double)
Set the step size of the counter.
void setMass(double)
Set the slider's mass for flywheel effect.
void wheelMoved(double value)
void setViewAngle(double)
Specify the visible portion of the wheel.
virtual void timerEvent(QTimerEvent *)
Qt timer event.
void stopFlying()
Stop the flying movement of the wheel.
virtual QSize minimumSizeHint() const
virtual void mouseMoveEvent(QMouseEvent *)
Mouse Move Event handler.