23 #include <qstyleoption.h> 27 double dist = qAbs( a2 - a1 );
38 return ( angle >= min ) && ( angle <=
max );
42 return ( angle >= min ) || ( angle <=
max );
129 setFocusPolicy( Qt::TabFocus );
131 QPalette p = palette();
132 for (
int i = 0; i < QPalette::NColorGroups; i++ )
134 const QPalette::ColorGroup colorGroup =
135 static_cast<QPalette::ColorGroup
>( i );
140 p.setColor( colorGroup, QPalette::WindowText,
141 p.color( colorGroup, QPalette::Base ) );
236 const QRect cr = contentsRect();
238 const int dim = qMin( cr.width(), cr.height() );
240 QRect inner( 0, 0, dim, dim );
241 inner.moveCenter( cr.center() );
260 rect.adjust( scaleDist, scaleDist, -scaleDist, -scaleDist );
312 QPainter painter(
this );
313 painter.setClipRegion( event->region() );
317 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
322 painter.setRenderHint( QPainter::Antialiasing,
true );
329 const QRect r = contentsRect();
336 p.setRenderHint( QPainter::Antialiasing,
true );
337 p.translate( -r.topLeft() );
393 if ( testAttribute( Qt::WA_NoSystemBackground ) ||
394 palette().brush( QPalette::Base ) !=
395 palette().brush( QPalette::Window ) )
400 painter->setPen( Qt::NoPen );
401 painter->setBrush( palette().brush( QPalette::Base ) );
402 painter->drawEllipse( br );
407 if ( palette().brush( QPalette::WindowText ) !=
408 palette().brush( QPalette::Base ) )
411 painter->setPen( Qt::NoPen );
412 painter->setBrush( palette().brush( QPalette::WindowText ) );
413 painter->drawEllipse( insideScaleRect );
417 const QPointF
center = insideScaleRect.center();
418 const double radius = 0.5 * insideScaleRect.width();
439 double radius,
double direction, QPalette::ColorGroup colorGroup )
const 443 direction = 360.0 - direction;
453 QPalette::ColorGroup colorGroup;
455 colorGroup = hasFocus() ? QPalette::Active : QPalette::Inactive;
457 colorGroup = QPalette::Disabled;
462 painter->setRenderHint( QPainter::Antialiasing,
true );
463 drawNeedle( painter, sr.center(), 0.5 * sr.width(),
476 const QPointF &
center,
double radius )
const 485 QPalette pal = palette();
487 const QColor textColor = pal.color( QPalette::Text );
488 pal.setColor( QPalette::WindowText, textColor );
490 painter->setFont( font() );
491 painter->setPen( QPen( textColor, sd->
penWidthF() ) );
493 painter->setBrush( Qt::red );
494 sd->
draw( painter, pal );
507 const QPointF &
center,
double radius )
const 590 if ( minArc != 360.0 && minArc != -360.0 )
591 minArc = std::fmod( minArc, 360.0 );
592 if ( maxArc != 360.0 && maxArc != -360.0 )
593 maxArc = std::fmod( maxArc, 360.0 );
598 if ( maxScaleArc - minScaleArc > 360.0 )
599 maxScaleArc = minScaleArc + 360.0;
710 return QSize( d, d );
723 const QRegion region(
innerRect(), QRegion::Ellipse );
724 if ( region.contains( pos ) && ( pos !=
innerRect().center() ) )
726 double angle = QLineF( rect().
center(), pos ).angle();
728 angle = 360.0 - angle;
753 double angle = QLineF( rect().
center(), pos ).angle();
757 angle = 360.0 - angle;
770 double boundedAngle = angle;
773 if ( qAbs( arc ) > 180.0 )
775 boundedAngle = ( arc > 0 )
781 angle = boundedAngle;
786 const double boundedAngle =
792 angle = boundedAngle;
806 switch( event->type() )
808 case QEvent::EnabledChange:
809 case QEvent::FontChange:
810 case QEvent::StyleChange:
811 case QEvent::PaletteChange:
812 case QEvent::LanguageChange:
813 case QEvent::LocaleChange:
831 #if QT_VERSION < 0x050e00 832 const QPoint wheelPos =
event->pos();
834 const QPoint wheelPos =
event->position().toPoint();
837 const QRegion region(
innerRect(), QRegion::Ellipse );
838 if ( region.contains( wheelPos ) )
847 sd->setAngleRange( angle, angle + span );
877 #include "moc_qwt_dial.cpp" A abstract base class for drawing scales.
virtual void drawNeedle(QPainter *, const QPointF &, double radius, double direction, QPalette::ColorGroup) const
virtual void scaleChange() QWT_OVERRIDE
void setAngleRange(double angle, double span)
virtual void draw(QPainter *, const QPointF ¢er, double length, double direction, QPalette::ColorGroup=QPalette::Active) const
The needle is fixed, the scales are rotating.
void setNeedle(QwtDialNeedle *)
virtual void drawFrame(QPainter *)
static void drawFocusRect(QPainter *, const QWidget *)
Draw a focus rectangle on a widget using its style.
void setAbstractScaleDraw(QwtAbstractScaleDraw *)
Set a scale draw.
Mode
Mode controlling whether the needle or the scale is rotating.
int transform(double) const
virtual void sliderChange()
Calling update()
QSize qwtExpandedToGlobalStrut(const QSize &size)
QRect boundingRect() const
QWT_CONSTEXPR float qwtMaxF(float a, float b)
static bool qwtIsOnArc(double angle, double min, double max)
void setValue(double value)
static void drawRoundFrame(QPainter *, const QRectF &, const QPalette &, int lineWidth, int frameStyle)
virtual void drawFocusIndicator(QPainter *) const
virtual void scaleChange() QWT_OVERRIDE
void setMode(Mode)
Change the mode of the dial.
const QwtScaleMap & scaleMap() const
virtual void wheelEvent(QWheelEvent *) QWT_OVERRIDE
virtual double scrolledTo(const QPoint &) const QWT_OVERRIDE
Determine the value for a new position of the slider handle.
virtual void setOrigin(double)
Change the origin.
virtual QRect scaleInnerRect() const
virtual void changeEvent(QEvent *) QWT_OVERRIDE
virtual bool isScrollPosition(const QPoint &) const QWT_OVERRIDE
Determine what to do when the user presses a mouse button.
virtual void drawContents(QPainter *) const
Draw the contents inside the frame.
QWT_CONSTEXPR float qwtMinF(float a, float b)
virtual ~QwtDial()
Destructor.
virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE
double maxScaleArc() const
void moveCenter(double x, double y)
Move the center of the scale draw, leaving the radius unchanged.
void setScaleMaxMajor(int ticks)
Set the maximum number of major tick intervals.
An abstract base class for slider widgets with a scale.
Base class for needles that can be used in a QwtDial.
void setMaxScaleArc(double)
virtual void wheelEvent(QWheelEvent *) QWT_OVERRIDE
virtual void sliderChange() QWT_OVERRIDE
Calling update()
virtual void drawScale(QPainter *, const QPointF ¢er, double radius) const
Shadow frameShadow() const
const QwtDialNeedle * needle() const
backward::SignalHandling sh
QwtRoundScaleDraw * scaleDraw()
virtual QSize sizeHint() const QWT_OVERRIDE
virtual void drawScaleContents(QPainter *painter, const QPointF ¢er, double radius) const
static double qwtBoundedAngle(double min, double angle, double max)
const QwtAbstractScaleDraw * abstractScaleDraw() const
void setScaleMaxMinor(int ticks)
Set the maximum number of minor tick intervals.
double invTransform(double p) const
QwtDial(QWidget *parent=NULL)
Constructor.
A class for drawing round scales.
virtual double extent(const QFont &font) const =0
virtual void draw(QPainter *, const QPalette &) const
Draw the scale.
double minScaleArc() const
virtual void changeEvent(QEvent *) QWT_OVERRIDE
void setFrameShadow(Shadow)
void setScaleDraw(QwtRoundScaleDraw *)
void setScaleArc(double minArc, double maxArc)
void setMinScaleArc(double)
static double qwtAngleDist(double a1, double a2)
void setRadius(double radius)
double transform(double s) const
double qwtNormalizeDegrees(double degrees)
Normalize an angle to be int the range [0.0, 360.0[.
virtual QSize minimumSizeHint() const QWT_OVERRIDE
static QPixmap backingStore(QWidget *, const QSize &)