Qwt User's Guide
svn
|
#include <qwt_analog_clock.h>
Inherits QwtDial.
Public Types | |
enum | Direction { Clockwise, CounterClockwise } |
enum | Hand { SecondHand, MinuteHand, HourHand, NHands } |
enum | Mode { RotateNeedle, RotateScale } |
enum | ScrollMode { ScrNone, ScrMouse, ScrTimer, ScrDirect, ScrPage } |
enum | Shadow { Plain = QFrame::Plain, Raised = QFrame::Raised, Sunken = QFrame::Sunken } |
Public Slots | |
virtual void | fitValue (double val) |
virtual void | incValue (int steps) |
void | setCurrentTime () |
virtual void | setReadOnly (bool) |
void | setTime (const QTime &=QTime::currentTime()) |
virtual void | setValue (double val) |
Signals | |
void | sliderMoved (double value) |
void | sliderPressed () |
void | sliderReleased () |
void | valueChanged (double value) |
Public Member Functions | |
QRectF | boundingRect () const |
Direction | direction () const |
Shadow | frameShadow () const |
const QwtDialNeedle * | hand (Hand) const |
QwtDialNeedle * | hand (Hand) |
virtual void | incPages (int) |
QRectF | innerRect () const |
bool | isReadOnly () const |
bool | isValid () const |
int | lineWidth () const |
virtual double | mass () const |
double | maxScaleArc () const |
double | maxValue () const |
virtual QSize | minimumSizeHint () const |
double | minScaleArc () const |
double | minValue () const |
Mode | mode () const |
const QwtDialNeedle * | needle () const |
QwtDialNeedle * | needle () |
Qt::Orientation | orientation () const |
double | origin () const |
int | pageSize () const |
bool | periodic () const |
QwtAnalogClock (QWidget *parent=NULL) | |
QwtDialScaleDraw * | scaleDraw () |
const QwtDialScaleDraw * | scaleDraw () const |
virtual QRectF | scaleInnerRect () const |
void | setDirection (Direction) |
void | setFrameShadow (Shadow) |
virtual void | setHand (Hand, QwtDialNeedle *) |
void | setLineWidth (int) |
virtual void | setMass (double val) |
void | setMode (Mode) |
virtual void | setOrientation (Qt::Orientation o) |
virtual void | setOrigin (double) |
void | setPeriodic (bool tf) |
void | setRange (double vmin, double vmax, double vstep=0.0, int pagesize=1) |
virtual void | setScale (int maxMajIntv, int maxMinIntv, double step=0.0) |
void | setScaleArc (double min, double max) |
void | setScaleComponents (QwtAbstractScaleDraw::ScaleComponents) |
virtual void | setScaleDraw (QwtDialScaleDraw *) |
void | setScaleTicks (int minLen, int medLen, int majLen, int penWidth=1) |
void | setStep (double) |
void | setTracking (bool enable) |
void | setUpdateTime (int t) |
void | setValid (bool valid) |
virtual void | setWrapping (bool) |
virtual QSize | sizeHint () const |
double | step () const |
void | stopMoving () |
double | value () const |
bool | wrapping () const |
virtual | ~QwtAnalogClock () |
Protected Member Functions | |
virtual void | drawContents (QPainter *) const |
virtual void | drawFocusIndicator (QPainter *) const |
virtual void | drawFrame (QPainter *p) |
virtual void | drawHand (QPainter *, Hand, const QPointF &, double radius, double direction, QPalette::ColorGroup) const |
virtual void | drawNeedle (QPainter *, const QPointF &, double radius, double direction, QPalette::ColorGroup) const |
virtual void | drawScale (QPainter *, const QPointF ¢er, double radius, double origin, double arcMin, double arcMax) const |
virtual void | drawScaleContents (QPainter *painter, const QPointF ¢er, double radius) const |
double | exactPrevValue () const |
double | exactValue () const |
virtual void | getScrollMode (const QPoint &, QwtAbstractSlider::ScrollMode &, int &direction) const |
virtual double | getValue (const QPoint &) |
virtual void | keyPressEvent (QKeyEvent *) |
virtual void | mouseMoveEvent (QMouseEvent *e) |
double | mouseOffset () const |
virtual void | mousePressEvent (QMouseEvent *e) |
virtual void | mouseReleaseEvent (QMouseEvent *e) |
virtual void | paintEvent (QPaintEvent *) |
double | prevValue () const |
virtual void | rangeChange () |
virtual QwtText | scaleLabel (double) const |
int | scrollMode () const |
void | setMouseOffset (double) |
virtual void | setPosition (const QPoint &) |
virtual void | stepChange () |
virtual void | timerEvent (QTimerEvent *e) |
void | updateScale () |
virtual void | valueChange () |
virtual void | wheelEvent (QWheelEvent *e) |
An analog clock.
#include <qwt_analog_clock.h> QwtAnalogClock *clock = new QwtAnalogClock(...); clock->scaleDraw()->setPenWidth(3); clock->setLineWidth(6); clock->setFrameShadow(QwtDial::Sunken); clock->setTime(); // update the clock every second QTimer *timer = new QTimer(clock); timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime())); timer->start(1000);
Qwt is missing a set of good looking hands. Contributions are very welcome.
enum QwtDial::Direction [inherited] |
enum QwtAnalogClock::Hand |
enum QwtDial::Mode [inherited] |
enum QwtAbstractSlider::ScrollMode [inherited] |
Scroll mode
enum QwtDial::Shadow [inherited] |
QwtAnalogClock::QwtAnalogClock | ( | QWidget * | parent = NULL | ) | [explicit] |
Constructor
parent | Parent widget |
QwtAnalogClock::~QwtAnalogClock | ( | ) | [virtual] |
Destructor.
QRectF QwtDial::boundingRect | ( | ) | const [inherited] |
QwtDial::Direction QwtDial::direction | ( | ) | const [inherited] |
The default direction of a dial is QwtDial::Clockwise
void QwtDial::drawContents | ( | QPainter * | painter | ) | const [protected, virtual, inherited] |
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 |
void QwtDial::drawFocusIndicator | ( | QPainter * | painter | ) | const [protected, virtual, inherited] |
Draw a dotted round circle, if !isReadOnly()
painter | Painter |
void QwtDial::drawFrame | ( | QPainter * | painter | ) | [protected, virtual, inherited] |
void QwtAnalogClock::drawHand | ( | QPainter * | painter, |
Hand | hd, | ||
const QPointF & | center, | ||
double | radius, | ||
double | direction, | ||
QPalette::ColorGroup | cg | ||
) | const [protected, virtual] |
Draw a clock hand
painter | Painter |
hd | Specify the type of hand |
center | Center of the clock |
radius | Maximum length for the hands |
direction | Direction of the hand in degrees, counter clockwise |
cg | ColorGroup |
void QwtAnalogClock::drawNeedle | ( | QPainter * | painter, |
const QPointF & | center, | ||
double | radius, | ||
double | dir, | ||
QPalette::ColorGroup | colorGroup | ||
) | const [protected, virtual] |
Draw the needle.
A clock has no single needle but three hands instead. drawNeedle translates value() into directions for the hands and calls drawHand().
painter | Painter |
center | Center of the clock |
radius | Maximum length for the hands |
dir | Dummy, not used. |
colorGroup | ColorGroup |
Reimplemented from QwtDial.
void QwtDial::drawScale | ( | QPainter * | painter, |
const QPointF & | center, | ||
double | radius, | ||
double | origin, | ||
double | minArc, | ||
double | maxArc | ||
) | const [protected, virtual, inherited] |
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 |
void QwtDial::drawScaleContents | ( | QPainter * | painter, |
const QPointF & | center, | ||
double | radius | ||
) | const [protected, virtual, inherited] |
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.
double QwtDoubleRange::exactPrevValue | ( | ) | const [protected, inherited] |
Returns the exact previous value.
double QwtDoubleRange::exactValue | ( | ) | const [protected, inherited] |
Returns the exact value.
The exact value is the value which QwtDoubleRange::value would return if the value were not adjusted to the step raster. It differs from the current value only if fitValue() or incValue() have been used before. This function is intended for internal use in derived classes.
void QwtAbstractSlider::fitValue | ( | double | value | ) | [virtual, slot, inherited] |
Set the slider's value to the nearest integer multiple of the step size.
value | Value |
Reimplemented from QwtDoubleRange.
QwtDial::Shadow QwtDial::frameShadow | ( | ) | const [inherited] |
void QwtDial::getScrollMode | ( | const QPoint & | pos, |
QwtAbstractSlider::ScrollMode & | scrollMode, | ||
int & | direction | ||
) | const [protected, virtual, inherited] |
See QwtAbstractSlider::getScrollMode()
pos | point where the mouse was pressed |
scrollMode | The scrolling mode |
direction | direction: 1, 0, or -1. |
Implements QwtAbstractSlider.
double QwtDial::getValue | ( | const QPoint & | pos | ) | [protected, virtual, inherited] |
Find the value for a given position
pos | Position |
Implements QwtAbstractSlider.
const QwtDialNeedle * QwtAnalogClock::hand | ( | Hand | hd | ) | const |
QwtDialNeedle * QwtAnalogClock::hand | ( | Hand | hd | ) |
void QwtDoubleRange::incPages | ( | int | nPages | ) | [virtual, inherited] |
Increment the value by a specified number of pages.
nPages | Number of pages to increment. A negative number decrements the value. |
void QwtAbstractSlider::incValue | ( | int | steps | ) | [virtual, slot, inherited] |
Increment the value by a specified number of steps.
steps | number of steps |
Reimplemented from QwtDoubleRange.
QRectF QwtDial::innerRect | ( | ) | const [inherited] |
bool QwtAbstractSlider::isReadOnly | ( | ) | const [inherited] |
In read only mode the slider can't be controlled by mouse or keyboard.
bool QwtAbstractSlider::isValid | ( | ) | const [inline, inherited] |
Reimplemented from QwtDoubleRange.
void QwtDial::keyPressEvent | ( | QKeyEvent * | event | ) | [protected, virtual, inherited] |
Handles key events
event | Key event |
Reimplemented from QwtAbstractSlider.
Reimplemented in QwtCompass.
int QwtDial::lineWidth | ( | ) | const [inherited] |
double QwtAbstractSlider::mass | ( | ) | const [virtual, inherited] |
double QwtDial::maxScaleArc | ( | ) | const [inherited] |
double QwtDoubleRange::maxValue | ( | ) | const [inherited] |
Returns the value of the second border of the range.
maxValue returns the value which has been specified as the second parameter in QwtDoubleRange::setRange.
Reimplemented in QwtCounter.
QSize QwtDial::minimumSizeHint | ( | ) | const [virtual, inherited] |
Return a minimum size hint.
double QwtDial::minScaleArc | ( | ) | const [inherited] |
double QwtDoubleRange::minValue | ( | ) | const [inherited] |
Returns the value at the first border of the range.
minValue returns the value which has been specified as the first parameter in setRange().
Reimplemented in QwtCounter.
QwtDial::Mode QwtDial::mode | ( | ) | const [inherited] |
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.
void QwtAbstractSlider::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual, inherited] |
Mouse Move Event handler
e | Mouse event |
double QwtAbstractSlider::mouseOffset | ( | ) | const [protected, inherited] |
void QwtAbstractSlider::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual, inherited] |
Mouse press event handler
e | Mouse event |
void QwtAbstractSlider::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual, inherited] |
Mouse Release Event handler
e | Mouse event |
const QwtDialNeedle * QwtDial::needle | ( | ) | const [inherited] |
QwtDialNeedle * QwtDial::needle | ( | ) | [inherited] |
Qt::Orientation QwtAbstractSlider::orientation | ( | ) | const [inherited] |
double QwtDial::origin | ( | ) | const [inherited] |
The origin is the angle where scale and needle is relative to.
int QwtDoubleRange::pageSize | ( | ) | const [inherited] |
Returns the page size in steps.
void QwtDial::paintEvent | ( | QPaintEvent * | event | ) | [protected, virtual, inherited] |
Paint the dial
event | Paint event |
bool QwtDoubleRange::periodic | ( | ) | const [inherited] |
Returns true if the range is periodic.
double QwtDoubleRange::prevValue | ( | ) | const [protected, inherited] |
Returns the previous value.
void QwtDial::rangeChange | ( | ) | [protected, virtual, inherited] |
QwtDoubleRange update hook.
Reimplemented from QwtDoubleRange.
QwtDialScaleDraw * QwtDial::scaleDraw | ( | ) | [inherited] |
Return the scale draw.
const QwtDialScaleDraw * QwtDial::scaleDraw | ( | ) | const [inherited] |
Return the scale draw.
QRectF QwtDial::scaleInnerRect | ( | ) | const [virtual, inherited] |
QwtText QwtAnalogClock::scaleLabel | ( | double | value | ) | const [protected, virtual] |
Find the scale label for a given value
value | Value |
Reimplemented from QwtDial.
int QwtAbstractSlider::scrollMode | ( | ) | const [protected, inherited] |
sa ScrollMode
void QwtAnalogClock::setCurrentTime | ( | ) | [slot] |
Set the current time.
This is the same as QwtAnalogClock::setTime(), but Qt < 3.0 can't handle default parameters for slots.
void QwtDial::setDirection | ( | Direction | direction | ) | [inherited] |
Set the direction of the dial (clockwise/counterclockwise)
direction | Direction |
void QwtDial::setFrameShadow | ( | Shadow | shadow | ) | [inherited] |
Sets the frame shadow value from the frame style.
shadow | Frame shadow |
void QwtAnalogClock::setHand | ( | Hand | hand, |
QwtDialNeedle * | needle | ||
) | [virtual] |
void QwtDial::setLineWidth | ( | int | lineWidth | ) | [inherited] |
void QwtAbstractSlider::setMass | ( | double | val | ) | [virtual, inherited] |
Set the slider's mass for flywheel effect.
If the slider's mass is greater then 0, it will continue to move after the mouse button has been released. Its speed decreases with time at a rate depending on the slider's mass. A large mass means that it will continue to move for a long time.
Derived widgets may overload this function to make it public.
val | New mass in kg |
Reimplemented in QwtWheel.
void QwtDial::setMode | ( | Mode | mode | ) | [inherited] |
Change the mode of the meter.
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.
void QwtAbstractSlider::setMouseOffset | ( | double | offset | ) | [protected, inherited] |
void QwtAbstractSlider::setOrientation | ( | Qt::Orientation | o | ) | [virtual, inherited] |
void QwtDial::setOrigin | ( | double | origin | ) | [virtual, inherited] |
Change the origin.
The origin is the angle where scale and needle is relative to.
origin | New origin |
void QwtDoubleRange::setPeriodic | ( | bool | tf | ) | [inherited] |
Make the range periodic.
When the range is periodic, the value will be set to a point inside the interval such that
point = value + n * width
if the user tries to set a new value which is outside the range. If the range is nonperiodic (the default), values outside the range will be clipped.
tf | true for a periodic range |
void QwtAbstractSlider::setPosition | ( | const QPoint & | p | ) | [protected, virtual, inherited] |
Move the slider to a specified point, adjust the value and emit signals if necessary.
void QwtDoubleRange::setRange | ( | double | vmin, |
double | vmax, | ||
double | vstep = 0.0 , |
||
int | pageSize = 1 |
||
) | [inherited] |
Specify range and step size.
vmin | lower boundary of the interval |
vmax | higher boundary of the interval |
vstep | step width |
pageSize | page size in steps |
void QwtAbstractSlider::setReadOnly | ( | bool | readOnly | ) | [virtual, slot, inherited] |
En/Disable read only mode
In read only mode the slider can't be controlled by mouse or keyboard.
readOnly | Enables in case of true |
void QwtDial::setScale | ( | int | maxMajIntv, |
int | maxMinIntv, | ||
double | step = 0.0 |
||
) | [virtual, inherited] |
Change the intervals of the scale
maxMajIntv | Maximum for the number of major steps |
maxMinIntv | Maximum number of minor steps |
step | Step size |
void QwtDial::setScaleArc | ( | double | minArc, |
double | maxArc | ||
) | [inherited] |
Change the arc of the scale
minArc | Lower limit |
maxArc | Upper limit |
void QwtDial::setScaleComponents | ( | QwtAbstractScaleDraw::ScaleComponents | components | ) | [inherited] |
A wrapper method for accessing the scale draw.
components | Scale components |
void QwtDial::setScaleDraw | ( | QwtDialScaleDraw * | scaleDraw | ) | [virtual, inherited] |
Set an individual scale draw
scaleDraw | Scale draw |
void QwtDial::setScaleTicks | ( | int | minLen, |
int | medLen, | ||
int | majLen, | ||
int | penWidth = 1 |
||
) | [inherited] |
Assign length and width of the ticks
minLen | Length of the minor ticks |
medLen | Length of the medium ticks |
majLen | Length of the major ticks |
penWidth | Width of the pen for all ticks |
void QwtDoubleRange::setStep | ( | double | vstep | ) | [inherited] |
Change the step raster.
vstep | new step width |
Reimplemented in QwtCounter.
void QwtAnalogClock::setTime | ( | const QTime & | time = QTime::currentTime() | ) | [slot] |
Set a time
time | Time to display |
void QwtAbstractSlider::setTracking | ( | bool | enable | ) | [inherited] |
Enables or disables tracking.
If tracking is enabled, the slider emits a valueChanged() signal whenever its value changes (the default behaviour). If tracking is disabled, the value changed() signal will only be emitted if:
Tracking is enabled by default.
enable | true (enable) or false (disable) tracking. |
void QwtAbstractSlider::setUpdateTime | ( | int | t | ) | [inherited] |
Specify the update interval for automatic scrolling.
t | update interval in milliseconds |
void QwtAbstractSlider::setValid | ( | bool | valid | ) | [inline, inherited] |
void QwtAbstractSlider::setValue | ( | double | val | ) | [virtual, slot, inherited] |
Move the slider to a specified value.
This function can be used to move the slider to a value which is not an integer multiple of the step size.
val | new value |
Reimplemented from QwtDoubleRange.
void QwtDial::setWrapping | ( | bool | wrapping | ) | [virtual, inherited] |
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 |
QSize QwtDial::sizeHint | ( | ) | const [virtual, inherited] |
void QwtAbstractSlider::sliderMoved | ( | double | value | ) | [signal, inherited] |
This signal is emitted when the user moves the slider with the mouse.
value | new value |
void QwtAbstractSlider::sliderPressed | ( | ) | [signal, inherited] |
This signal is emitted when the user presses the movable part of the slider (start ScrMouse Mode).
void QwtAbstractSlider::sliderReleased | ( | ) | [signal, inherited] |
This signal is emitted when the user releases the movable part of the slider.
double QwtDoubleRange::step | ( | ) | const [inherited] |
void QwtDoubleRange::stepChange | ( | ) | [protected, virtual, inherited] |
Notify a change of the step size.
This virtual function is called whenever the step size changes. The default implementation does nothing.
void QwtAbstractSlider::stopMoving | ( | ) | [inherited] |
Stop updating if automatic scrolling is active.
void QwtAbstractSlider::timerEvent | ( | QTimerEvent * | e | ) | [protected, virtual, inherited] |
Qt timer event
e | Timer event |
void QwtDial::updateScale | ( | ) | [protected, inherited] |
Update the scale with the current attributes
double QwtDoubleRange::value | ( | ) | const [inherited] |
Returns the current value.
Reimplemented in QwtCounter.
void QwtDial::valueChange | ( | ) | [protected, virtual, inherited] |
QwtDoubleRange update hook.
Reimplemented from QwtAbstractSlider.
void QwtAbstractSlider::valueChanged | ( | double | value | ) | [signal, inherited] |
Notify a change of value.
In the default setting (tracking enabled), this signal will be emitted every time the value changes ( see setTracking() ).
value | new value |
void QwtAbstractSlider::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual, inherited] |
Wheel Event handler
e | Whell event |
bool QwtDial::wrapping | ( | ) | const [inherited] |
wrapping() holds whether it is possible to step the value from the highest value to the lowest value and vice versa.