21 #include <qalgorithms.h> 24 #include <qstyleoption.h> 25 #include <qapplication.h> 29 double dist = qAbs( a2 - a1 );
36 static inline bool qwtIsOnArc(
double angle,
double min,
double max )
40 return ( angle >= min ) && ( angle <= max );
44 return ( angle >= min ) || ( angle <= max );
131 setFocusPolicy( Qt::TabFocus );
133 QPalette p = palette();
134 for (
int i = 0;
i < QPalette::NColorGroups;
i++ )
136 const QPalette::ColorGroup colorGroup =
137 static_cast<QPalette::ColorGroup
>(
i );
142 p.setColor( colorGroup, QPalette::WindowText,
143 p.color( colorGroup, QPalette::Base ) );
238 const QRect cr = contentsRect();
240 const double dim = qMin( cr.width(), cr.height() );
242 QRect inner( 0, 0, dim, dim );
243 inner.moveCenter( cr.center() );
259 int scaleDist = qCeil( sd->
extent( font() ) );
262 rect.adjust( scaleDist, scaleDist, -scaleDist, -scaleDist );
314 QPainter painter(
this );
315 painter.setClipRegion( event->region() );
319 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
324 painter.setRenderHint( QPainter::Antialiasing,
true );
331 const QRect r = contentsRect();
338 p.setRenderHint( QPainter::Antialiasing,
true );
339 p.translate( -r.topLeft() );
395 if ( testAttribute( Qt::WA_NoSystemBackground ) ||
396 palette().brush( QPalette::Base ) !=
397 palette().brush( QPalette::Window ) )
402 painter->setPen( Qt::NoPen );
403 painter->setBrush( palette().brush( QPalette::Base ) );
404 painter->drawEllipse( br );
409 if ( palette().brush( QPalette::WindowText ) !=
410 palette().brush( QPalette::Base ) )
413 painter->setPen( Qt::NoPen );
414 painter->setBrush( palette().brush( QPalette::WindowText ) );
415 painter->drawEllipse( insideScaleRect );
419 const QPointF center = insideScaleRect.center();
420 const double radius = 0.5 * insideScaleRect.width();
441 double radius,
double direction, QPalette::ColorGroup colorGroup )
const 445 direction = 360.0 - direction;
455 QPalette::ColorGroup colorGroup;
457 colorGroup = hasFocus() ? QPalette::Active : QPalette::Inactive;
459 colorGroup = QPalette::Disabled;
464 painter->setRenderHint( QPainter::Antialiasing,
true );
465 drawNeedle( painter, sr.center(), 0.5 * sr.width(),
478 const QPointF ¢er,
double radius )
const 487 QPalette pal = palette();
489 const QColor textColor = pal.color( QPalette::Text );
490 pal.setColor( QPalette::WindowText, textColor );
492 painter->setFont( font() );
493 painter->setPen( QPen( textColor, sd->
penWidth() ) );
495 painter->setBrush( Qt::red );
496 sd->
draw( painter, pal );
509 const QPointF ¢er,
double radius )
const 592 if ( minArc != 360.0 && minArc != -360.0 )
593 minArc = ::fmod( minArc, 360.0 );
594 if ( maxArc != 360.0 && maxArc != -360.0 )
595 maxArc = ::fmod( maxArc, 360.0 );
600 if ( maxScaleArc - minScaleArc > 360.0 )
601 maxScaleArc = minScaleArc + 360.0;
689 sh = qCeil(
scaleDraw()->extent( font() ) );
695 hint = hint.expandedTo( QApplication::globalStrut() );
708 sh = qCeil(
scaleDraw()->extent( font() ) );
712 return QSize( d, d );
725 const QRegion region(
innerRect(), QRegion::Ellipse );
726 if ( region.contains( pos ) && ( pos !=
innerRect().center() ) )
728 double angle = QLineF( rect().center(), pos ).angle();
730 angle = 360.0 - angle;
755 double angle = QLineF( rect().center(), pos ).angle();
759 angle = 360.0 - angle;
772 double boundedAngle = angle;
775 if ( qAbs( arc ) > 180.0 )
777 boundedAngle = ( arc > 0 )
783 angle = boundedAngle;
788 const double boundedAngle =
794 angle = boundedAngle;
808 switch( event->type() )
810 case QEvent::EnabledChange:
811 case QEvent::FontChange:
812 case QEvent::StyleChange:
813 case QEvent::PaletteChange:
814 case QEvent::LanguageChange:
815 case QEvent::LocaleChange:
833 const QRegion region(
innerRect(), QRegion::Ellipse );
834 if ( region.contains( event->pos() ) )
A abstract base class for drawing scales.
virtual void drawNeedle(QPainter *, const QPointF &, double radius, double direction, QPalette::ColorGroup) const
void setAngleRange(double angle, double span)
void setScaleArc(double min, double max)
The needle is fixed, the scales are rotating.
void setNeedle(QwtDialNeedle *)
static void drawFocusRect(QPainter *, const QWidget *)
Draw a focus rectangle on a widget using its style.
void setAbstractScaleDraw(QwtAbstractScaleDraw *)
Set a scale draw.
virtual void drawFrame(QPainter *p)
Mode
Mode controlling whether the needle or the scale is rotating.
int transform(double) const
virtual void wheelEvent(QWheelEvent *)
virtual void sliderChange()
Calling update()
QRect boundingRect() const
void setValue(double val)
void setMinScaleArc(double min)
static bool qwtIsOnArc(double angle, double min, double max)
static void drawRoundFrame(QPainter *, const QRectF &, const QPalette &, int lineWidth, int frameStyle)
virtual void drawFocusIndicator(QPainter *) const
void setMode(Mode)
Change the mode of the dial.
const QwtScaleMap & scaleMap() const
virtual void wheelEvent(QWheelEvent *)
virtual void setOrigin(double)
Change the origin.
virtual QRect scaleInnerRect() const
virtual void scaleChange()
virtual void drawContents(QPainter *) const
Draw the contents inside the frame.
virtual ~QwtDial()
Destructor.
double maxScaleArc() const
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
virtual void sliderChange()
Calling update()
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.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
An abstract base class for slider widgets with a scale.
Base class for needles that can be used in a QwtDial.
virtual QSize minimumSizeHint() const
virtual void drawScale(QPainter *, const QPointF ¢er, double radius) const
Shadow frameShadow() const
const QwtDialNeedle * needle() const
virtual bool isScrollPosition(const QPoint &) const
Determine what to do when the user presses a mouse button.
virtual QSize sizeHint() const
backward::SignalHandling sh
QwtRoundScaleDraw * scaleDraw()
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
void setAngleRange(double angle1, double angle2)
Adjust the baseline circle segment for round scales.
virtual void changeEvent(QEvent *)
QwtDial(QWidget *parent=NULL)
Constructor.
virtual void paintEvent(QPaintEvent *)
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 scaleChange()
void setFrameShadow(Shadow)
void setScaleDraw(QwtRoundScaleDraw *)
virtual double scrolledTo(const QPoint &) const
Determine the value for a new position of the slider handle.
virtual void draw(QPainter *painter, const QPointF ¢er, double length, double direction, QPalette::ColorGroup=QPalette::Active) const
static double qwtAngleDist(double a1, double a2)
virtual void changeEvent(QEvent *)
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[.
void setMaxScaleArc(double min)
static QPixmap backingStore(QWidget *, const QSize &)