QwtDial class provides a rounded range control. More...
#include <qwt_dial.h>
Classes | |
class | PrivateData |
Public Types | |
enum | Mode { RotateNeedle, RotateScale } |
Mode controlling whether the needle or the scale is rotating. More... | |
enum | Shadow { Plain = QFrame::Plain, Raised = QFrame::Raised, Sunken = QFrame::Sunken } |
Frame shadow. More... | |
Public Member Functions | |
QRect | boundingRect () const |
Shadow | frameShadow () const |
QRect | innerRect () const |
int | lineWidth () const |
double | maxScaleArc () const |
virtual QSize | minimumSizeHint () const |
double | minScaleArc () const |
Mode | mode () const |
const QwtDialNeedle * | needle () const |
QwtDialNeedle * | needle () |
double | origin () const |
QwtDial (QWidget *parent=NULL) | |
Constructor. | |
QwtRoundScaleDraw * | scaleDraw () |
const QwtRoundScaleDraw * | scaleDraw () const |
virtual QRect | scaleInnerRect () const |
void | setFrameShadow (Shadow) |
void | setLineWidth (int) |
void | setMaxScaleArc (double min) |
void | setMinScaleArc (double min) |
void | setMode (Mode) |
Change the mode of the dial. | |
void | setNeedle (QwtDialNeedle *) |
virtual void | setOrigin (double) |
Change the origin. | |
void | setScaleArc (double min, double max) |
void | setScaleDraw (QwtRoundScaleDraw *) |
virtual QSize | sizeHint () const |
virtual | ~QwtDial () |
Destructor. | |
Protected Member Functions | |
virtual void | changeEvent (QEvent *) |
virtual void | drawContents (QPainter *) const |
Draw the contents inside the frame. | |
virtual void | drawFocusIndicator (QPainter *) const |
virtual void | drawFrame (QPainter *p) |
virtual void | drawNeedle (QPainter *, const QPointF &, double radius, double direction, QPalette::ColorGroup) const |
virtual void | drawScale (QPainter *, const QPointF ¢er, double radius) const |
virtual void | drawScaleContents (QPainter *painter, const QPointF ¢er, double radius) const |
void | invalidateCache () |
virtual bool | isScrollPosition (const QPoint &) const |
Determine what to do when the user presses a mouse button. | |
virtual void | paintEvent (QPaintEvent *) |
virtual void | scaleChange () |
virtual double | scrolledTo (const QPoint &) const |
Determine the value for a new position of the slider handle. | |
virtual void | sliderChange () |
Calling update() | |
virtual void | wheelEvent (QWheelEvent *) |
Properties | |
Shadow | frameShadow |
int | lineWidth |
double | maxScaleArc |
double | minScaleArc |
Mode | mode |
double | origin |
Private Member Functions | |
void | drawNeedle (QPainter *) const |
void | setAngleRange (double angle, double span) |
Private Attributes | |
PrivateData * | d_data |
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 QwtAbstractSlider::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.
Often dials have to be updated very often according to values from external devices. For these high refresh rates QwtDial caches as much as possible. For derived classes it might be necessary to clear these caches manually according to attribute changes using invalidateCache().
Definition at line 49 of file qwt_dial.h.
enum QwtDial::Mode |
Mode controlling whether the needle or the scale is rotating.
RotateNeedle |
The needle is rotating. |
RotateScale |
The needle is fixed, the scales are rotating. |
Definition at line 85 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 72 of file qwt_dial.h.
QwtDial::QwtDial | ( | QWidget * | parent = NULL | ) | [explicit] |
Constructor.
parent | Parent widget |
Create a dial widget with no needle. The scale is initialized to [ 0.0, 360.0 ] and 360 steps ( QwtAbstractSlider::setTotalSteps() ). The origin of the scale is at 90°,
The value is set to 0.0.
The default mode is QwtDial::RotateNeedle.
Definition at line 126 of file qwt_dial.cpp.
QwtDial::~QwtDial | ( | ) | [virtual] |
Destructor.
Definition at line 161 of file qwt_dial.cpp.
QRect QwtDial::boundingRect | ( | ) | const |
Definition at line 236 of file qwt_dial.cpp.
void QwtDial::changeEvent | ( | QEvent * | event | ) | [protected, virtual] |
Change Event handler
event | Change event |
Invalidates internal paint caches if necessary
Reimplemented from QwtAbstractScale.
Definition at line 806 of file qwt_dial.cpp.
void QwtDial::drawContents | ( | QPainter * | painter | ) | const [protected, virtual] |
Draw the contents inside the frame.
QPalette::Window is the background color outside of the frame. QPalette::Base is the background color inside the frame. QPalette::WindowText is the background color inside the scale.
painter | Painter |
Definition at line 393 of file qwt_dial.cpp.
void QwtDial::drawFocusIndicator | ( | QPainter * | painter | ) | const [protected, virtual] |
void QwtDial::drawFrame | ( | QPainter * | painter | ) | [protected, virtual] |
Draw the frame around the dial
painter | Painter |
Definition at line 375 of file qwt_dial.cpp.
void QwtDial::drawNeedle | ( | QPainter * | painter, |
const QPointF & | center, | ||
double | radius, | ||
double | direction, | ||
QPalette::ColorGroup | colorGroup | ||
) | 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 |
colorGroup | ColorGroup |
Reimplemented in QwtAnalogClock.
Definition at line 440 of file qwt_dial.cpp.
void QwtDial::drawNeedle | ( | QPainter * | painter | ) | const [private] |
Definition at line 450 of file qwt_dial.cpp.
void QwtDial::drawScale | ( | QPainter * | painter, |
const QPointF & | center, | ||
double | radius | ||
) | const [protected, virtual] |
Draw the scale
painter | Painter |
center | Center of the dial |
radius | Radius of the scale |
Definition at line 477 of file qwt_dial.cpp.
void QwtDial::drawScaleContents | ( | QPainter * | painter, |
const QPointF & | center, | ||
double | 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 508 of file qwt_dial.cpp.
Shadow QwtDial::frameShadow | ( | ) | const |
QRect QwtDial::innerRect | ( | ) | const |
Definition at line 226 of file qwt_dial.cpp.
void QwtDial::invalidateCache | ( | ) | [protected] |
Invalidate the internal caches used to speed up repainting
Definition at line 303 of file qwt_dial.cpp.
bool QwtDial::isScrollPosition | ( | const QPoint & | pos | ) | const [protected, virtual] |
Determine what to do when the user presses a mouse button.
pos | Mouse position |
True,when | the inner circle contains pos |
Implements QwtAbstractSlider.
Definition at line 723 of file qwt_dial.cpp.
int QwtDial::lineWidth | ( | ) | const |
double QwtDial::maxScaleArc | ( | ) | const |
QSize QwtDial::minimumSizeHint | ( | ) | const [virtual] |
double QwtDial::minScaleArc | ( | ) | const |
Mode QwtDial::mode | ( | ) | const |
const QwtDialNeedle * QwtDial::needle | ( | ) | const |
QwtDialNeedle * QwtDial::needle | ( | ) |
double QwtDial::origin | ( | ) | const |
void QwtDial::paintEvent | ( | QPaintEvent * | event | ) | [protected, virtual] |
void QwtDial::scaleChange | ( | ) | [protected, virtual] |
Invalidate the internal caches and call QwtAbstractSlider::scaleChange()
Reimplemented from QwtAbstractSlider.
Definition at line 852 of file qwt_dial.cpp.
Definition at line 555 of file qwt_dial.cpp.
const QwtRoundScaleDraw * QwtDial::scaleDraw | ( | ) | const |
Definition at line 561 of file qwt_dial.cpp.
QRect QwtDial::scaleInnerRect | ( | ) | const [virtual] |
Definition at line 252 of file qwt_dial.cpp.
double QwtDial::scrolledTo | ( | const QPoint & | pos | ) | const [protected, virtual] |
Determine the value for a new position of the slider handle.
pos | Mouse position |
Implements QwtAbstractSlider.
Definition at line 753 of file qwt_dial.cpp.
void QwtDial::setAngleRange | ( | double | angle, |
double | span | ||
) | [private] |
Definition at line 838 of file qwt_dial.cpp.
void QwtDial::setFrameShadow | ( | Shadow | shadow | ) |
Sets the frame shadow value from the frame style.
shadow | Frame shadow |
Definition at line 172 of file qwt_dial.cpp.
void QwtDial::setLineWidth | ( | int | lineWidth | ) |
Sets the line width of the frame
lineWidth | Line width |
Definition at line 199 of file qwt_dial.cpp.
void QwtDial::setMaxScaleArc | ( | double | max | ) |
Set the upper limit for the scale arc
max | Upper limit of the scale arc |
Definition at line 640 of file qwt_dial.cpp.
void QwtDial::setMinScaleArc | ( | double | min | ) |
Set the lower limit for the scale arc
min | Lower limit of the scale arc |
Definition at line 620 of file qwt_dial.cpp.
void QwtDial::setMode | ( | Mode | mode | ) |
Change the mode of the dial.
mode | New mode |
In case of QwtDial::RotateNeedle 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.
Definition at line 280 of file qwt_dial.cpp.
void QwtDial::setNeedle | ( | QwtDialNeedle * | needle | ) |
Set a needle for the dial
needle | Needle |
Reimplemented in QwtAnalogClock.
Definition at line 524 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.
origin | New origin |
Definition at line 662 of file qwt_dial.cpp.
void QwtDial::setScaleArc | ( | double | minArc, |
double | maxArc | ||
) |
Change the arc of the scale
minArc | Lower limit |
maxArc | Upper limit |
Definition at line 590 of file qwt_dial.cpp.
void QwtDial::setScaleDraw | ( | QwtRoundScaleDraw * | scaleDraw | ) |
Set an individual scale draw
The motivation for setting a scale draw is often to overload QwtRoundScaleDraw::label() to return individual tick labels.
scaleDraw | Scale draw |
Definition at line 576 of file qwt_dial.cpp.
QSize QwtDial::sizeHint | ( | ) | const [virtual] |
void QwtDial::sliderChange | ( | ) | [protected, virtual] |
void QwtDial::wheelEvent | ( | QWheelEvent * | event | ) | [protected, virtual] |
Wheel Event handler
event | Wheel event |
Reimplemented from QwtAbstractSlider.
Definition at line 831 of file qwt_dial.cpp.
PrivateData* QwtDial::d_data [private] |
Reimplemented from QwtAbstractSlider.
Reimplemented in QwtCompass.
Definition at line 164 of file qwt_dial.h.
QwtDial::Shadow QwtDial::frameShadow [read, write] |
Definition at line 56 of file qwt_dial.h.
int QwtDial::lineWidth [read, write] |
Definition at line 55 of file qwt_dial.h.
double QwtDial::maxScaleArc [read, write] |
Definition at line 60 of file qwt_dial.h.
double QwtDial::minScaleArc [read, write] |
Definition at line 59 of file qwt_dial.h.
QwtDial::Mode QwtDial::mode [read, write] |
Definition at line 57 of file qwt_dial.h.
double QwtDial::origin [read, write] |
The origin is the angle where scale and needle is relative to.
Definition at line 58 of file qwt_dial.h.