NAME
QwtDial -
SYNOPSIS
Inherits QwtSliderBase.
Inherited by QwtAnalogClock, and QwtCompass.
Detailed Description
QwtDial class provides a rounded range control.
QwtDial is intended as base class for dial widgets like speedometers,
compass widgets, clocks ...
A dial contains a scale and a needle indicating the current value of
the dial. Depending on Mode one of them is fixed and the other is
rotating. If not isReadOnly() the dial can be rotated by dragging the
mouse or using keyboard inputs (see keyPressEvent()). A dial might be
wrapping, what means a rotation below/above one limit continues on the
other limit (f.e compass). The scale might cover any arc of the dial,
its values are related to the origin() of the dial.
Qwt is missing a set of good looking needles (QwtDialNeedle).
Contributions are very welcome.
See also:
QwtCompass, QwtAnalogClock, QwtDialNeedle
Note:
The examples/dials example shows different types of dials.
Definition at line 72 of file qwt_dial.h.
Public Types
enum Shadow { Plain = QFrame::Plain, Raised = QFrame::Raised, Sunken
= QFrame::Sunken }
enum ScaleOptions { ScaleBackbone = 1, ScaleTicks = 2, ScaleLabel =
4 }
enum Mode { RotateNeedle, RotateScale }
Public Member Functions
QwtDial (QWidget *parent=0, const char *name=0)
virtual ~QwtDial ()
void setFrameShadow (Shadow)
Shadow frameShadow () const
bool hasVisibleBackground () const
void showBackground (bool)
void setLineWidth (int)
int lineWidth () const
void setMode (Mode)
Mode mode () const
virtual void setWrapping (bool)
bool wrapping () const
virtual void setScale (int maxMajIntv, int maxMinIntv, double step=0.0)
void setScaleArc (double min, double max)
void setScaleOptions (int)
void setScaleTicks (int minLen, int medLen, int majLen, int penWidth=1)
double minScaleArc () const
double maxScaleArc () const
virtual void setOrigin (double)
double origin () const
virtual void setNeedle (QwtDialNeedle *)
const QwtDialNeedle * needle () const
QwtDialNeedle * needle ()
QRect boundingRect () const
QRect contentsRect () const
virtual QRect scaleContentsRect () const
virtual QSize sizeHint () const
virtual QSize minimumSizeHint () const
virtual void setScaleDraw (QwtDialScaleDraw *)
QwtDialScaleDraw * scaleDraw ()
const QwtDialScaleDraw * scaleDraw () const
Protected Member Functions
virtual void paintEvent (QPaintEvent *)
virtual void resizeEvent (QResizeEvent *)
virtual void keyPressEvent (QKeyEvent *)
virtual void drawFrame (QPainter *p)
virtual void drawContents (QPainter *) const
virtual void drawFocusIndicator (QPainter *) const
virtual void drawScale (QPainter *, const QPoint ¢er, int radius,
double origin, double arcMin, double arcMax) const
virtual void drawScaleContents (QPainter *painter, const QPoint
¢er, int radius) const
virtual void drawNeedle (QPainter *, const QPoint &, int radius, double
direction, QPalette::ColorGroup) const
virtual QString scaleLabel (double) const
void updateScale ()
virtual void rangeChange ()
virtual void valueChange ()
virtual double getValue (const QPoint &)
virtual void getScrollMode (const QPoint &, int &scrollMode, int
&direction)
Member Enumeration Documentation
enum QwtDial::Mode
In case of RotateNeedle the needle is rotating, in case of RotateScale,
the needle points to origin() and the scale is rotating. Definition at
line 117 of file qwt_dial.h.
Referenced by mode().
enum QwtDial::ScaleOptions
see QwtDial::setScaleOptions
Definition at line 105 of file qwt_dial.h.
enum QwtDial::Shadow
Frame shadow.
Unfortunately it is not possible to use QFrame::Shadow as a property of
a widget that is not derived from QFrame. The following enum is made
for the designer only. It is safe to use QFrame::Shadow instead.
Definition at line 97 of file qwt_dial.h.
Referenced by frameShadow().
Constructor & Destructor Documentation
QwtDial::QwtDial (QWidget * parent = 0, const char * name = 0)
Constructor.
Parameters:
parent Parent widget
name Widget name
Create a dial widget with no scale and no needle. The default origin is
90.0 with no valid value. It accepts mouse and keyboard inputs and has
no step size. The default mode is QwtDial::RotateNeedle. Definition at
line 107 of file qwt_dial.cpp.
References QwtScaleDraw::setGeometry(), QwtDblRange::setRange(), and
setScaleArc().
QwtDial::~QwtDial () [virtual]
Destructor.
Definition at line 147 of file qwt_dial.cpp.
Member Function Documentation
QRect QwtDial::boundingRect () const
Returns:
bounding rect of the dial including the frame
See also:
QwtDial::setLineWidth, QwtDial::scaleContentsRect,
QwtDial::contentsRect
Definition at line 260 of file qwt_dial.cpp.
Referenced by contentsRect(), drawContents(), drawFrame(),
resizeEvent(), and showBackground().
QRect QwtDial::contentsRect () const
Returns:
bounding rect of the circle inside the frame
See also:
QwtDial::setLineWidth, QwtDial::scaleContentsRect,
QwtDial::boundingRect
Definition at line 243 of file qwt_dial.cpp.
References boundingRect(), and lineWidth().
Referenced by drawFocusIndicator(), getScrollMode(), and
scaleContentsRect().
void QwtDial::drawContents (QPainter * painter) const [protected, virtual]
Draw the contents inside the frame.
QColorGroup::Background is the background color outside of the frame.
QColorGroup::Base is the background color inside the frame.
QColorGroup::Foreground is the background color inside the scale.
Parameters:
painter Painter
See also:
QwtDial::boundingRect, QwtDial::contentsRect,
QwtDial::scaleContentsRect, QWidget::setPalette
Definition at line 475 of file qwt_dial.cpp.
References boundingRect(), drawNeedle(), drawScale(),
drawScaleContents(), QwtSliderBase::isValid(), QwtDblRange::maxValue(),
QwtDblRange::minValue(), mode(), origin(), scaleContentsRect(), and
QwtDblRange::value().
Referenced by paintEvent().
void QwtDial::drawFocusIndicator (QPainter * painter) const [protected,
virtual]
Draw a dotted round circle, if !isReadOnly()
Parameters:
painter Painter
Definition at line 394 of file qwt_dial.cpp.
References contentsRect(), and QwtSliderBase::isReadOnly().
Referenced by paintEvent().
void QwtDial::drawFrame (QPainter * painter) [protected, virtual]
Draw the frame around the dial
Parameters:
painter Painter
See also:
QwtDial::lineWidth, QwtDial::frameShadow
Definition at line 431 of file qwt_dial.cpp.
References boundingRect(), QwtPainter::drawRoundFrame(), and
lineWidth().
Referenced by paintEvent().
void QwtDial::drawNeedle (QPainter * painter, const QPoint & center, int
radius, double direction, QPalette::ColorGroup cg) const [protected,
virtual]
Draw the needle
Qwt is missing a set of good looking needles. Contributions are very
welcome.
Parameters:
painter Painter
center Center of the dial
radius Length for the needle
direction Direction of the needle in degrees, counter clockwise
cg ColorGroup
Reimplemented in QwtAnalogClock.
Definition at line 584 of file qwt_dial.cpp.
References QwtDialNeedle::draw().
Referenced by drawContents().
void QwtDial::drawScale (QPainter * painter, const QPoint & center, int
radius, double origin, double minArc, double maxArc) const [protected,
virtual]
Draw the scale
Parameters:
painter Painter
center Center of the dial
radius Radius of the scale
origin Origin of the scale
minArc Minimum of the arc
maxArc Minimum of the arc
See also:
QwtScaleDraw::setAngleRange
Definition at line 606 of file qwt_dial.cpp.
References QwtScaleDraw::draw(), QwtDialScaleDraw::penWidth(),
QwtScaleDraw::setAngleRange(), and QwtScaleDraw::setGeometry().
Referenced by drawContents().
void QwtDial::drawScaleContents (QPainter * painter, const QPoint & center,
int radius) const [protected, virtual]
Draw the contents inside the scale
Paints nothing.
Parameters:
painter Painter
center Center of the contents circle
radius Radius of the contents circle
Reimplemented in QwtCompass.
Definition at line 643 of file qwt_dial.cpp.
Referenced by drawContents().
QwtDial::Shadow QwtDial::frameShadow () const
Returns:
Frame shadow /sa QwtDial::setFrameShadow, QwtDial::lineWidth,
QFrame::frameShadow
Definition at line 206 of file qwt_dial.cpp.
References Shadow.
void QwtDial::getScrollMode (const QPoint & p, int & scrollMode, int &
direction) [protected, virtual]
See also:
QwtSliderBase::getScrollMode
Implements QwtSliderBase.
Definition at line 1012 of file qwt_dial.cpp.
References contentsRect().
double QwtDial::getValue (const QPoint & pos) [protected, virtual]
Find the value for a given position
Parameters:
pos .RE
Returns:
Value
Implements QwtSliderBase.
Definition at line 909 of file qwt_dial.cpp.
References QwtDblRange::maxValue(), QwtDblRange::minValue(),
mode(), QwtDblRange::value(), and wrapping().
bool QwtDial::hasVisibleBackground () const
TRUE when the area outside of the frame is visible
See also:
QwtDial::showBackground, QWidget::setMask
Definition at line 181 of file qwt_dial.cpp.
Referenced by resizeEvent().
void QwtDial::keyPressEvent (QKeyEvent * e) [protected, virtual]
Handles key events
· Key_Down, KeyLeft
Decrement by 1
· Key_Prior
Decrement by pageSize()
· Key_Home
Set the value to minValue()
· Key_Up, KeyRight
Increment by 1
· Key_Next
Increment by pageSize()
· Key_End
Set the value to maxValue()
See also:
isReadOnly()
Reimplemented from QwtSliderBase.
Reimplemented in QwtCompass.
Definition at line 1044 of file qwt_dial.cpp.
References QwtDblRange::incValue(), QwtSliderBase::isReadOnly(),
QwtSliderBase::isValid(), QwtDblRange::maxValue(),
QwtDblRange::minValue(), QwtDblRange::pageSize(),
QwtDblRange::prevValue(), QwtSliderBase::setValue(),
QwtSliderBase::sliderMoved(), and QwtDblRange::value().
Referenced by QwtCompass::keyPressEvent().
int QwtDial::lineWidth () const
Returns:
Line width of the frame
See also:
QwtDial::setLineWidth, QwtDial::frameShadow, QFrame::lineWidth
Definition at line 234 of file qwt_dial.cpp.
Referenced by contentsRect(), drawFrame(), minimumSizeHint(),
setFrameShadow(), and sizeHint().
double QwtDial::maxScaleArc () const
Return the upper limit of the scale arc.
Definition at line 150 of file qwt_dial.h.
QSize QwtDial::minimumSizeHint () const [virtual]
Return a minimum size hint.
Warning:
The return value of QwtDial::minimumSizeHint() depends on the font
and the scale.
Definition at line 874 of file qwt_dial.cpp.
References lineWidth(), and QwtScaleDraw::minHeight().
double QwtDial::minScaleArc () const
Return the lower limit of the scale arc.
Definition at line 148 of file qwt_dial.h.
QwtDial::Mode QwtDial::mode () const
Returns:
mode of the dial.
The value of the dial is indicated by the difference between the origin
and the direction of the needle. In case of QwtDial::RotateNeedle the
scale arc is fixed to the origin() and the needle is rotating, in case
of QwtDial::RotateScale, the needle points to origin() and the scale is
rotating.
The default mode is QwtDial::RotateNeedle.
See also:
QwtDial::setMode, QwtDial::origin, QwtDial::setScaleArc,
QwtDial::value
Definition at line 329 of file qwt_dial.cpp.
References Mode.
Referenced by drawContents(), QwtCompass::drawScaleContents(),
getValue(), and QwtCompass::keyPressEvent().
QwtDialNeedle * QwtDial::needle ()
Returns:
needle
See also:
QwtDial::setNeedle
Definition at line 684 of file qwt_dial.cpp.
const QwtDialNeedle * QwtDial::needle () const
Returns:
needle
See also:
QwtDial::setNeedle
Definition at line 675 of file qwt_dial.cpp.
double QwtDial::origin () const
The origin is the angle where scale and needle is relative to.
Returns:
Origin of the dial
See also:
QwtDial::setOrigin()
Definition at line 822 of file qwt_dial.cpp.
Referenced by drawContents(), QwtAnalogClock::drawNeedle(),
QwtCompass::drawScaleContents(), and QwtCompass::keyPressEvent().
void QwtDial::paintEvent (QPaintEvent *) [protected, virtual]
Repaint the dial.
Definition at line 372 of file qwt_dial.cpp.
References drawContents(), drawFocusIndicator(), drawFrame(), and
QwtPaintBuffer::painter().
void QwtDial::rangeChange () [protected, virtual]
QwtDblRange update hook.
Reimplemented from QwtDblRange.
Definition at line 690 of file qwt_dial.cpp.
References updateScale().
void QwtDial::resizeEvent (QResizeEvent *) [protected, virtual]
Resize the dial widget.
Definition at line 363 of file qwt_dial.cpp.
References boundingRect(), and hasVisibleBackground().
QRect QwtDial::scaleContentsRect () const [virtual]
Returns:
rect inside the scale
See also:
setLineWidth, QwtDial::boundingRect, QwtDial::contentsRect
Definition at line 273 of file qwt_dial.cpp.
References contentsRect(), QwtScaleDraw::maxHeight(), and
QwtScaleDraw::maxWidth().
Referenced by drawContents().
const QwtDialScaleDraw* QwtDial::scaleDraw () const
Return the scale draw.
Definition at line 171 of file qwt_dial.h.
QwtDialScaleDraw* QwtDial::scaleDraw ()
Return the scale draw.
Definition at line 169 of file qwt_dial.h.
QString QwtDial::scaleLabel (double value) const [protected, virtual]
Returns:
the label for a value
Reimplemented in QwtAnalogClock, and QwtCompass.
Definition at line 789 of file qwt_dial.cpp.
Referenced by QwtDialScaleDraw::label().
void QwtDial::setFrameShadow (Shadow shadow)
Sets the frame shadow value from the frame style.
Parameters:
shadow Frame shadow
See also:
QwtDial::setLineWidth, QFrame::setFrameShadow
Definition at line 191 of file qwt_dial.cpp.
References lineWidth().
void QwtDial::setLineWidth (int lineWidth)
Sets the line width
Parameters:
lineWidth Line width
See also:
QwtDial::setFrameShadow
Definition at line 217 of file qwt_dial.cpp.
void QwtDial::setMode (Mode mode)
Change the mode of the meter.
Parameters:
mode New mode
The value of the meter is indicated by the difference between north of
the scale and the direction of the needle. In case of
QwtDial::RotateNeedle north is pointing to the origin() and the needle
is rotating, in case of QwtDial::RotateScale, the needle points to
origin() and the scale is rotating.
The default mode is QwtDial::RotateNeedle.
See also:
QwtDial::mode, QwtDial::setValue, QwtDial::setOrigin
Definition at line 306 of file qwt_dial.cpp.
void QwtDial::setNeedle (QwtDialNeedle * needle) [virtual]
Set a needle for the dial
Qwt is missing a set of good looking needles. Contributions are very
welcome.
Parameters:
needle Needle
Warning:
The needle will be deleted, when a different needle is set or in
~QwtDial
Definition at line 659 of file qwt_dial.cpp.
void QwtDial::setOrigin (double origin) [virtual]
Change the origin.
The origin is the angle where scale and needle is relative to.
Parameters:
origin New origin
See also:
QwtDial::origin()
Definition at line 810 of file qwt_dial.cpp.
Referenced by QwtAnalogClock::QwtAnalogClock(), and
QwtCompass::QwtCompass().
void QwtDial::setScale (int maxMajIntv, int maxMinIntv, double step = 0.0)
[virtual]
Change the intervals of the scale
See also:
QwtScaleDraw::setScale
Definition at line 730 of file qwt_dial.cpp.
References updateScale().
Referenced by QwtAnalogClock::QwtAnalogClock().
void QwtDial::setScaleArc (double minArc, double maxArc)
Change the arc of the scale
Parameters:
minArc Lower limit
maxArc Upper limit
Definition at line 833 of file qwt_dial.cpp.
Referenced by QwtDial().
void QwtDial::setScaleDraw (QwtDialScaleDraw * scaleDraw) [virtual]
Set an individual scale draw
Warning:
The previous scale draw is deleted
Definition at line 713 of file qwt_dial.cpp.
References updateScale().
Referenced by setScaleOptions().
void QwtDial::setScaleOptions (int options)
A wrapper method for accessing the scale draw.
· options == 0
No visible scale: setScaleDraw(NULL)
· options & ScaleBackbone
En/disable the backbone of the scale.
· options & ScaleTicks
Don´t change anything. Otherwise set all tick lengths to 0.
· options & ScaleLabel
En/disable scale labels
See also:
QwtScaleDraw:.setOptions, QwtScaleDraw::setTickLength,
QwtDialScaleDraw::showLabels
Definition at line 754 of file qwt_dial.cpp.
References QwtScaleDraw::options(), QwtScaleDraw::setOptions(),
setScaleDraw(), QwtScaleDraw::setTickLength(), and
QwtDialScaleDraw::showLabels().
Referenced by QwtAnalogClock::QwtAnalogClock(), and
QwtCompass::QwtCompass().
void QwtDial::setScaleTicks (int minLen, int medLen, int majLen, int
penWidth = 1)
See: QwtScaleDraw::setTickLength, QwtDialScaleDraw::setPenWidth.
Definition at line 776 of file qwt_dial.cpp.
References QwtDialScaleDraw::setPenWidth(), and
QwtScaleDraw::setTickLength().
Referenced by QwtAnalogClock::QwtAnalogClock().
void QwtDial::setWrapping (bool wrapping) [virtual]
Sets whether it is possible to step the value from the highest value to
the lowest value and vice versa to on.
Parameters:
wrapping en/disables wrapping
See also:
QwtDial::wrapping, QwtDblRange::periodic
Note:
The meaning of wrapping is like the wrapping property of QSpinBox,
but not like it is used in QDial.
Definition at line 344 of file qwt_dial.cpp.
References QwtDblRange::setPeriodic().
Referenced by QwtAnalogClock::QwtAnalogClock(), and
QwtCompass::QwtCompass().
void QwtDial::showBackground (bool show)
Show/Hide the area outside of the frame
Parameters:
show Show if TRUE, hide if FALSE
See also:
QwtDial::hasVisibleBackground, QWidget::setMask
Warning:
When QwtDial is a toplevel widget the window border might disappear
too.
Definition at line 161 of file qwt_dial.cpp.
References boundingRect().
QSize QwtDial::sizeHint () const [virtual]
Returns:
QwtDial::sizeHint()
Definition at line 858 of file qwt_dial.cpp.
References lineWidth(), and QwtScaleDraw::minHeight().
void QwtDial::updateScale () [protected]
Update the scale with the current attributes
See also:
QwtDial::setScale
Definition at line 699 of file qwt_dial.cpp.
References QwtDblRange::maxValue(), QwtDblRange::minValue(), and
QwtScaleDraw::setScale().
Referenced by rangeChange(), setScale(), and setScaleDraw().
void QwtDial::valueChange () [protected, virtual]
QwtDblRange update hook.
Reimplemented from QwtSliderBase.
Definition at line 849 of file qwt_dial.cpp.
References QwtSliderBase::valueChange().
bool QwtDial::wrapping () const
wrapping() holds whether it is possible to step the value from the
highest value to the lowest value and vice versa.
See also:
QwtDial::setWrapping, QwtDblRange::setPeriodic
Note:
The meaning of wrapping is like the wrapping property of QSpinBox,
but not like it is used in QDial.
Definition at line 357 of file qwt_dial.cpp.
References QwtDblRange::periodic().
Referenced by getValue().
Author
Generated automatically by Doxygen for Qwt User’s Guide from the source
code.