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.
Definition at line 67 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 { FixedColors, ScaledColors, RotateNeedle, RotateScale } |
Public Member Functions | |
QwtDial (QWidget *parent=NULL) | |
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 | updateMask () |
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 QwtText | 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) |
Friends | |
class | QwtDialScaleDraw |
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 92 of file qwt_dial.h.
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 112 of file qwt_dial.h.
QwtDial::QwtDial | ( | QWidget * | parent = NULL |
) | [explicit] |
Constructor.
parent | Parent widget |
Definition at line 129 of file qwt_dial.cpp.
QwtDial::~QwtDial | ( | ) | [virtual] |
void QwtDial::setFrameShadow | ( | Shadow | shadow | ) |
Sets the frame shadow value from the frame style.
shadow | Frame shadow |
Definition at line 230 of file qwt_dial.cpp.
References lineWidth().
QwtDial::Shadow QwtDial::frameShadow | ( | ) | const |
Definition at line 244 of file qwt_dial.cpp.
bool QwtDial::hasVisibleBackground | ( | ) | const |
true when the area outside of the frame is visible
Definition at line 220 of file qwt_dial.cpp.
Referenced by resizeEvent().
void QwtDial::showBackground | ( | bool | show | ) |
Show/Hide the area outside of the frame
show | Show if true, hide if false |
Definition at line 206 of file qwt_dial.cpp.
References updateMask().
void QwtDial::setLineWidth | ( | int | lineWidth | ) |
Sets the line width
lineWidth | Line width |
Definition at line 255 of file qwt_dial.cpp.
int QwtDial::lineWidth | ( | ) | const |
Definition at line 271 of file qwt_dial.cpp.
Referenced by contentsRect(), drawFrame(), minimumSizeHint(), setFrameShadow(), and sizeHint().
void QwtDial::setMode | ( | Mode | mode | ) |
Change the mode of the meter.
mode | New mode |
The default mode is QwtDial::RotateNeedle.
Definition at line 345 of file qwt_dial.cpp.
QwtDial::Mode QwtDial::mode | ( | ) | const |
The default mode is QwtDial::RotateNeedle.
Definition at line 368 of file qwt_dial.cpp.
Referenced by drawContents(), QwtCompass::drawScaleContents(), getValue(), and QwtCompass::keyPressEvent().
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.
wrapping | en/disables wrapping |
Definition at line 383 of file qwt_dial.cpp.
References QwtDoubleRange::setPeriodic().
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.
Definition at line 396 of file qwt_dial.cpp.
References QwtDoubleRange::periodic().
Referenced by getValue().
void QwtDial::setScale | ( | int | maxMajIntv, | |
int | maxMinIntv, | |||
double | step = 0.0 | |||
) | [virtual] |
Change the intervals of the scale
Definition at line 846 of file qwt_dial.cpp.
References updateScale().
void QwtDial::setScaleArc | ( | double | minArc, | |
double | maxArc | |||
) |
Change the arc of the scale
minArc | Lower limit | |
maxArc | Upper limit |
Definition at line 961 of file qwt_dial.cpp.
void QwtDial::setScaleOptions | ( | int | options | ) |
A wrapper method for accessing the scale draw.
Definition at line 869 of file qwt_dial.cpp.
References QwtAbstractScaleDraw::enableComponent(), and setScaleDraw().
void QwtDial::setScaleTicks | ( | int | minLen, | |
int | medLen, | |||
int | majLen, | |||
int | penWidth = 1 | |||
) |
See: QwtAbstractScaleDraw::setTickLength, QwtDialScaleDraw::setPenWidth.
Definition at line 889 of file qwt_dial.cpp.
References QwtDialScaleDraw::setPenWidth(), and QwtAbstractScaleDraw::setTickLength().
double QwtDial::minScaleArc | ( | ) | const |
double QwtDial::maxScaleArc | ( | ) | const |
void QwtDial::setOrigin | ( | double | origin | ) | [virtual] |
Change the origin.
The origin is the angle where scale and needle is relative to.
origin | New origin |
Definition at line 938 of file qwt_dial.cpp.
double QwtDial::origin | ( | ) | const |
The origin is the angle where scale and needle is relative to.
Definition at line 950 of file qwt_dial.cpp.
Referenced by drawContents(), QwtAnalogClock::drawNeedle(), QwtCompass::drawScaleContents(), and QwtCompass::keyPressEvent().
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.
needle | Needle |
Definition at line 756 of file qwt_dial.cpp.
References needle().
const QwtDialNeedle * QwtDial::needle | ( | ) | const |
Definition at line 772 of file qwt_dial.cpp.
Referenced by QwtAnalogClock::drawHand(), QwtAnalogClock::setHand(), and setNeedle().
QwtDialNeedle * QwtDial::needle | ( | ) |
QRect QwtDial::boundingRect | ( | ) | const |
Definition at line 297 of file qwt_dial.cpp.
Referenced by contentsRect(), drawContents(), drawFrame(), and updateMask().
QRect QwtDial::contentsRect | ( | ) | const |
Definition at line 280 of file qwt_dial.cpp.
References boundingRect(), and lineWidth().
Referenced by drawFocusIndicator(), getScrollMode(), and scaleContentsRect().
QRect QwtDial::scaleContentsRect | ( | ) | const [virtual] |
Definition at line 310 of file qwt_dial.cpp.
References contentsRect().
Referenced by drawContents().
QSize QwtDial::sizeHint | ( | ) | const [virtual] |
QSize QwtDial::minimumSizeHint | ( | ) | const [virtual] |
Return a minimum size hint.
Definition at line 1002 of file qwt_dial.cpp.
References lineWidth().
void QwtDial::setScaleDraw | ( | QwtDialScaleDraw * | scaleDraw | ) | [virtual] |
Set an individual scale draw
scaleDraw | Scale draw |
Definition at line 829 of file qwt_dial.cpp.
References scaleDraw(), and updateScale().
Referenced by setScaleOptions().
QwtDialScaleDraw * QwtDial::scaleDraw | ( | ) |
const QwtDialScaleDraw * QwtDial::scaleDraw | ( | ) | const |
void QwtDial::paintEvent | ( | QPaintEvent * | e | ) | [protected, virtual] |
Paint the dial
e | Paint event |
Definition at line 417 of file qwt_dial.cpp.
References drawContents(), drawFocusIndicator(), and drawFrame().
void QwtDial::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
Resize the dial widget
e | Resize event |
Definition at line 405 of file qwt_dial.cpp.
References hasVisibleBackground(), and updateMask().
void QwtDial::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
Handles key events
Reimplemented from QwtAbstractSlider.
Reimplemented in QwtCompass.
Definition at line 1172 of file qwt_dial.cpp.
References QwtDoubleRange::incValue(), QwtAbstractSlider::isReadOnly(), QwtAbstractSlider::isValid(), QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), QwtDoubleRange::pageSize(), QwtDoubleRange::prevValue(), QwtAbstractSlider::setValue(), QwtAbstractSlider::sliderMoved(), and QwtDoubleRange::value().
Referenced by QwtCompass::keyPressEvent().
void QwtDial::updateMask | ( | ) | [protected, virtual] |
Update the mask of the dial.
In case of "hasVisibleBackground() == false", the backgound is transparent by a mask.
Definition at line 1231 of file qwt_dial.cpp.
References boundingRect().
Referenced by resizeEvent(), and showBackground().
void QwtDial::drawFrame | ( | QPainter * | painter | ) | [protected, virtual] |
Draw the frame around the dial
painter | Painter |
Definition at line 495 of file qwt_dial.cpp.
References boundingRect(), QwtPainter::drawRoundFrame(), and lineWidth().
Referenced by paintEvent().
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.
painter | Painter |
Definition at line 557 of file qwt_dial.cpp.
References boundingRect(), drawNeedle(), drawScale(), drawScaleContents(), QwtAbstractSlider::isValid(), QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), mode(), origin(), scaleContentsRect(), and QwtDoubleRange::value().
Referenced by paintEvent().
void QwtDial::drawFocusIndicator | ( | QPainter * | painter | ) | const [protected, virtual] |
Draw a dotted round circle, if !isReadOnly()
painter | Painter |
Definition at line 448 of file qwt_dial.cpp.
References contentsRect(), and QwtAbstractSlider::isReadOnly().
Referenced by paintEvent().
void QwtDial::drawScale | ( | QPainter * | painter, | |
const QPoint & | center, | |||
int | radius, | |||
double | origin, | |||
double | minArc, | |||
double | maxArc | |||
) | const [protected, virtual] |
Draw the scale
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 |
Definition at line 689 of file qwt_dial.cpp.
Referenced by drawContents().
void QwtDial::drawScaleContents | ( | QPainter * | painter, | |
const QPoint & | center, | |||
int | radius | |||
) | const [protected, virtual] |
Draw the contents inside the scale
Paints nothing.
painter | Painter | |
center | Center of the contents circle | |
radius | Radius of the contents circle |
Reimplemented in QwtCompass.
Definition at line 740 of file qwt_dial.cpp.
Referenced by drawContents().
void QwtDial::drawNeedle | ( | QPainter * | painter, | |
const QPoint & | center, | |||
int | radius, | |||
double | direction, | |||
QPalette::ColorGroup | cg | |||
) | const [protected, virtual] |
Draw the needle
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 667 of file qwt_dial.cpp.
Referenced by drawContents().
QwtText QwtDial::scaleLabel | ( | double | value | ) | const [protected, virtual] |
Find the label for a value
value | Value |
Reimplemented in QwtAnalogClock, and QwtCompass.
Definition at line 908 of file qwt_dial.cpp.
Referenced by QwtDialScaleDraw::label().
void QwtDial::updateScale | ( | ) | [protected] |
Update the scale with the current attributes
Definition at line 796 of file qwt_dial.cpp.
References QwtLinearScaleEngine::divideScale(), QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), and QwtLinearScaleEngine::transformation().
Referenced by rangeChange(), setScale(), and setScaleDraw().
void QwtDial::rangeChange | ( | ) | [protected, virtual] |
QwtDoubleRange update hook.
Reimplemented from QwtDoubleRange.
Definition at line 787 of file qwt_dial.cpp.
References updateScale().
void QwtDial::valueChange | ( | ) | [protected, virtual] |
QwtDoubleRange update hook.
Reimplemented from QwtAbstractSlider.
Definition at line 977 of file qwt_dial.cpp.
References QwtAbstractSlider::valueChange().
double QwtDial::getValue | ( | const QPoint & | pos | ) | [protected, virtual] |
Find the value for a given position
pos | Position |
Implements QwtAbstractSlider.
Definition at line 1037 of file qwt_dial.cpp.
References QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), mode(), QwtAbstractSlider::mouseOffset(), QwtAbstractSlider::scrollMode(), QwtAbstractSlider::setMouseOffset(), QwtDoubleRange::value(), and wrapping().
void QwtDial::getScrollMode | ( | const QPoint & | p, | |
int & | scrollMode, | |||
int & | direction | |||
) | [protected, virtual] |
Implements QwtAbstractSlider.
Definition at line 1140 of file qwt_dial.cpp.
References contentsRect().