Go to the documentation of this file.
23 #include <qstyleoption.h>
27 double dist = qAbs( a2 - a1 );
34 static inline bool qwtIsOnArc(
double angle,
double min,
double max )
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 );
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 class for drawing round scales.
virtual void draw(QPainter *, const QPalette &) const
Draw the scale.
const QwtDialNeedle * needle() const
Base class for needles that can be used in a QwtDial.
double invTransform(double p) const
virtual double scrolledTo(const QPoint &) const QWT_OVERRIDE
Determine the value for a new position of the slider handle.
const QwtScaleMap & scaleMap() const
static double qwtBoundedAngle(double min, double angle, double max)
QSize qwtExpandedToGlobalStrut(const QSize &size)
QRect boundingRect() const
virtual QSize minimumSizeHint() const QWT_OVERRIDE
void setFrameShadow(Shadow)
virtual void drawNeedle(QPainter *, const QPointF &, double radius, double direction, QPalette::ColorGroup) const
virtual void wheelEvent(QWheelEvent *) QWT_OVERRIDE
void setMaxScaleArc(double)
virtual void sliderChange()
Calling update()
@ RotateNeedle
The needle is rotating.
void setValue(double value)
virtual void scaleChange() QWT_OVERRIDE
static double qwtAngleDist(double a1, double a2)
void moveCenter(double x, double y)
Move the center of the scale draw, leaving the radius unchanged.
double qwtNormalizeDegrees(double degrees)
Normalize an angle to be int the range [0.0, 360.0[.
virtual void drawFocusIndicator(QPainter *) const
void setNeedle(QwtDialNeedle *)
virtual double extent(const QFont &font) const =0
QWT_CONSTEXPR float qwtMinF(float a, float b)
void setAbstractScaleDraw(QwtAbstractScaleDraw *)
Set a scale draw.
QwtDial(QWidget *parent=NULL)
Constructor.
virtual void draw(QPainter *, const QPointF ¢er, double length, double direction, QPalette::ColorGroup=QPalette::Active) const
void setScaleMaxMajor(int ticks)
Set the maximum number of major tick intervals.
void setScaleDraw(QwtRoundScaleDraw *)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
virtual void setOrigin(double)
Change the origin.
@ RotateScale
The needle is fixed, the scales are rotating.
int transform(double) const
QWT_CONSTEXPR float qwtMaxF(float a, float b)
static QPixmap backingStore(QWidget *, const QSize &)
virtual void scaleChange() QWT_OVERRIDE
virtual void drawScaleContents(QPainter *painter, const QPointF ¢er, double radius) const
void setMinScaleArc(double)
void setScaleArc(double minArc, double maxArc)
void setScaleMaxMinor(int ticks)
Set the maximum number of minor tick intervals.
A abstract base class for drawing scales.
double value
Returns the current value.
double transform(double s) const
static void drawRoundFrame(QPainter *, const QRectF &, const QPalette &, int lineWidth, int frameStyle)
virtual void drawFrame(QPainter *)
static bool qwtIsOnArc(double angle, double min, double max)
static void drawFocusRect(QPainter *, const QWidget *)
Draw a focus rectangle on a widget using its style.
const QwtAbstractScaleDraw * abstractScaleDraw() const
virtual QRect scaleInnerRect() const
virtual void drawScale(QPainter *, const QPointF ¢er, double radius) const
QwtRoundScaleDraw * scaleDraw()
void setRadius(double radius)
virtual void sliderChange() QWT_OVERRIDE
Calling update()
virtual void wheelEvent(QWheelEvent *) QWT_OVERRIDE
Mode
Mode controlling whether the needle or the scale is rotating.
virtual void changeEvent(QEvent *) QWT_OVERRIDE
virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE
virtual void drawContents(QPainter *) const
Draw the contents inside the frame.
virtual ~QwtDial()
Destructor.
An abstract base class for slider widgets with a scale.
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.
void setMode(Mode)
Change the mode of the dial.
virtual QSize sizeHint() const QWT_OVERRIDE
backward::SignalHandling sh
void setAngleRange(double angle, double span)
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45