QwtDial class provides a rounded range control. More...
#include <qwt_dial.h>
Classes | |
class | PrivateData |
Public Types | |
enum | Shadow { Plain = QFrame::Plain, Raised = QFrame::Raised, Sunken = QFrame::Sunken } |
Frame shadow. More... | |
enum | ScaleOptions { ScaleBackbone = 1, ScaleTicks = 2, ScaleLabel = 4 } |
More... | |
enum | Mode { RotateNeedle, RotateScale } |
enum | Direction { Clockwise, CounterClockwise } |
Public Member Functions | |
QwtDial (QWidget *parent=NULL) | |
Constructor. | |
QwtDial (QWidget *parent, const char *name) | |
Constructor. | |
virtual | ~QwtDial () |
Destructor. | |
void | setFrameShadow (Shadow) |
Shadow | frameShadow () const |
bool | hasVisibleBackground () const |
void | showBackground (bool) |
void | setLineWidth (int) |
int | lineWidth () const |
void | setMode (Mode) |
Change the mode of the meter. | |
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) |
Change the origin. | |
double | origin () const |
void | setDirection (Direction) |
Direction | direction () 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 |
Return a minimum size hint. | |
virtual void | setScaleDraw (QwtDialScaleDraw *) |
QwtDialScaleDraw * | scaleDraw () |
Return the scale draw. | |
const QwtDialScaleDraw * | scaleDraw () const |
Return the scale draw. | |
Protected Member Functions | |
virtual void | paintEvent (QPaintEvent *) |
virtual void | resizeEvent (QResizeEvent *) |
virtual void | keyPressEvent (QKeyEvent *) |
virtual void | updateMask () |
Update the mask of the dial. | |
virtual void | drawFrame (QPainter *p) |
virtual void | drawContents (QPainter *) const |
Draw the contents inside the frame. | |
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 () |
QwtDoubleRange update hook. | |
virtual void | valueChange () |
QwtDoubleRange update hook. | |
virtual double | getValue (const QPoint &) |
virtual void | getScrollMode (const QPoint &, int &scrollMode, int &direction) |
Properties | |
bool | visibleBackground |
int | lineWidth |
Shadow | frameShadow |
Mode | mode |
double | origin |
bool | wrapping |
Direction | direction |
Friends | |
class | QwtDialScaleDraw |
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.
Definition at line 67 of file qwt_dial.h.
enum QwtDial::Direction |
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 114 of file qwt_dial.h.
{ RotateNeedle, RotateScale };
Definition at line 102 of file qwt_dial.h.
{ ScaleBackbone = 1, ScaleTicks = 2, ScaleLabel = 4 };
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 94 of file qwt_dial.h.
{ Plain = QFrame::Plain, Raised = QFrame::Raised, Sunken = QFrame::Sunken };
QwtDial::QwtDial | ( | QWidget * | parent = NULL ) |
[explicit] |
Constructor.
parent | Parent widget |
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 131 of file qwt_dial.cpp.
: QwtAbstractSlider(Qt::Horizontal, parent) { initDial(); }
QwtDial::QwtDial | ( | QWidget * | parent, |
const char * | name | ||
) | [explicit] |
Constructor.
parent | Parent widget |
name | Object 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 148 of file qwt_dial.cpp.
: QwtAbstractSlider(Qt::Horizontal, parent) { setName(name); initDial(); }
QwtDial::~QwtDial | ( | ) | [virtual] |
QRect QwtDial::boundingRect | ( | ) | const |
Definition at line 299 of file qwt_dial.cpp.
References qwtMin.
Referenced by contentsRect(), drawContents(), drawFrame(), and updateMask().
QRect QwtDial::contentsRect | ( | ) | const |
Definition at line 282 of file qwt_dial.cpp.
References boundingRect(), and lineWidth().
Referenced by drawFocusIndicator(), getScrollMode(), and scaleContentsRect().
{ const int lw = lineWidth(); QRect r = boundingRect(); if ( lw > 0 ) { r.setRect(r.x() + lw, r.y() + lw, r.width() - 2 * lw, r.height() - 2 * lw); } return r; }
Direction QwtDial::direction | ( | ) | const |
Referenced by drawContents(), drawNeedle(), QwtAnalogClock::drawNeedle(), and setDirection().
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 584 of file qwt_dial.cpp.
References boundingRect(), CounterClockwise, QwtDial::PrivateData::direction, direction(), drawNeedle(), drawScale(), drawScaleContents(), QwtAbstractSlider::isValid(), QwtDial::PrivateData::maxScaleArc, QwtDoubleRange::maxValue(), QwtDial::PrivateData::minScaleArc, QwtDoubleRange::minValue(), mode(), origin(), QwtDial::PrivateData::origin, RotateScale, scaleContentsRect(), and QwtDoubleRange::value().
Referenced by paintEvent().
{ #if QT_VERSION < 0x040000 if ( backgroundMode() == Qt::NoBackground || colorGroup().brush(QColorGroup::Base) != colorGroup().brush(QColorGroup::Background) ) #else if ( testAttribute(Qt::WA_NoSystemBackground) || palette().brush(QPalette::Base) != palette().brush(QPalette::Background) ) #endif { const QRect br = boundingRect(); painter->save(); painter->setPen(Qt::NoPen); #if QT_VERSION < 0x040000 painter->setBrush(colorGroup().brush(QColorGroup::Base)); #else painter->setBrush(palette().brush(QPalette::Base)); #endif painter->drawEllipse(br); painter->restore(); } const QRect insideScaleRect = scaleContentsRect(); #if QT_VERSION < 0x040000 if ( colorGroup().brush(QColorGroup::Foreground) != colorGroup().brush(QColorGroup::Base) ) #else if ( palette().brush(QPalette::Foreground) != palette().brush(QPalette::Base) ) #endif { painter->save(); painter->setPen(Qt::NoPen); #if QT_VERSION < 0x040000 painter->setBrush(colorGroup().brush(QColorGroup::Foreground)); #else painter->setBrush(palette().brush(QPalette::Foreground)); #endif painter->drawEllipse(insideScaleRect.x() - 1, insideScaleRect.y() - 1, insideScaleRect.width(), insideScaleRect.height() ); painter->restore(); } const QPoint center = insideScaleRect.center(); const int radius = insideScaleRect.width() / 2; painter->save(); drawScaleContents(painter, center, radius); painter->restore(); double direction = d_data->origin; if (isValid()) { direction = d_data->minScaleArc; if ( maxValue() > minValue() && d_data->maxScaleArc > d_data->minScaleArc ) { const double ratio = (value() - minValue()) / (maxValue() - minValue()); direction += ratio * (d_data->maxScaleArc - d_data->minScaleArc); } if ( d_data->direction == QwtDial::CounterClockwise ) direction = d_data->maxScaleArc - (direction - d_data->minScaleArc); direction += d_data->origin; if ( direction >= 360.0 ) direction -= 360.0; else if ( direction < 0.0 ) direction += 360.0; } double origin = d_data->origin; if ( mode() == RotateScale ) { origin -= direction - d_data->origin; direction = d_data->origin; } painter->save(); drawScale(painter, center, radius, origin, d_data->minScaleArc, d_data->maxScaleArc); painter->restore(); if ( isValid() ) { QPalette::ColorGroup cg; if ( isEnabled() ) cg = hasFocus() ? QPalette::Active : QPalette::Inactive; else cg = QPalette::Disabled; painter->save(); drawNeedle(painter, center, radius, direction, cg); painter->restore(); } }
void QwtDial::drawFocusIndicator | ( | QPainter * | painter ) | const [protected, virtual] |
Draw a dotted round circle, if !isReadOnly()
painter | Painter |
Definition at line 477 of file qwt_dial.cpp.
References contentsRect(), and QwtAbstractSlider::isReadOnly().
Referenced by paintEvent().
{ if ( !isReadOnly() ) { QRect focusRect = contentsRect(); const int margin = 2; focusRect.setRect( focusRect.x() + margin, focusRect.y() + margin, focusRect.width() - 2 * margin, focusRect.height() - 2 * margin); #if QT_VERSION < 0x040000 QColor color = colorGroup().color(QColorGroup::Base); #else QColor color = palette().color(QPalette::Base); #endif if (color.isValid()) { const QColor gray(Qt::gray); int h, s, v; #if QT_VERSION < 0x040000 color.hsv(&h, &s, &v); #else color.getHsv(&h, &s, &v); #endif color = (v > 128) ? gray.dark(120) : gray.light(120); } else color = Qt::darkGray; painter->save(); painter->setBrush(Qt::NoBrush); painter->setPen(QPen(color, 0, Qt::DotLine)); painter->drawEllipse(focusRect); painter->restore(); } }
void QwtDial::drawFrame | ( | QPainter * | painter ) | [protected, virtual] |
Draw the frame around the dial
painter | Painter |
Definition at line 524 of file qwt_dial.cpp.
References boundingRect(), QwtPainter::drawRoundFrame(), QwtDial::PrivateData::frameShadow, lineWidth(), Raised, and Sunken.
Referenced by paintEvent().
{ const int lw = lineWidth(); const int off = (lw + 1) % 2; QRect r = boundingRect(); r.setRect(r.x() + lw / 2 - off, r.y() + lw / 2 - off, r.width() - lw + off + 1, r.height() - lw + off + 1); #if QT_VERSION >= 0x040000 r.setX(r.x() + 1); r.setY(r.y() + 1); r.setWidth(r.width() - 2); r.setHeight(r.height() - 2); #endif if ( lw > 0 ) { switch(d_data->frameShadow) { case QwtDial::Raised: #if QT_VERSION < 0x040000 QwtPainter::drawRoundFrame(painter, r, lw, colorGroup(), false); #else QwtPainter::drawRoundFrame(painter, r, lw, palette(), false); #endif break; case QwtDial::Sunken: #if QT_VERSION < 0x040000 QwtPainter::drawRoundFrame(painter, r, lw, colorGroup(), true); #else QwtPainter::drawRoundFrame(painter, r, lw, palette(), true); #endif break; default: // Plain { painter->save(); painter->setPen(QPen(Qt::black, lw)); painter->setBrush(Qt::NoBrush); painter->drawEllipse(r); painter->restore(); } } } }
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 701 of file qwt_dial.cpp.
References direction(), QwtDialNeedle::draw(), and QwtDial::PrivateData::needle.
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
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 723 of file qwt_dial.cpp.
References CounterClockwise, QwtDial::PrivateData::direction, QwtAbstractScaleDraw::draw(), QwtRoundScaleDraw::moveCenter(), origin(), QwtDialScaleDraw::penWidth(), QwtDial::PrivateData::scaleDraw, QwtRoundScaleDraw::setAngleRange(), and QwtRoundScaleDraw::setRadius().
Referenced by drawContents().
{ if ( d_data->scaleDraw == NULL ) return; origin -= 270.0; // hardcoded origin of QwtScaleDraw double angle = maxArc - minArc; if ( angle > 360.0 ) angle = ::fmod(angle, 360.0); minArc += origin; if ( minArc < -360.0 ) minArc = ::fmod(minArc, 360.0); maxArc = minArc + angle; if ( maxArc > 360.0 ) { // QwtAbstractScaleDraw::setAngleRange accepts only values // in the range [-360.0..360.0] minArc -= 360.0; maxArc -= 360.0; } if ( d_data->direction == QwtDial::CounterClockwise ) qSwap(minArc, maxArc); painter->setFont(font()); d_data->scaleDraw->setAngleRange(minArc, maxArc); d_data->scaleDraw->setRadius(radius); d_data->scaleDraw->moveCenter(center); #if QT_VERSION < 0x040000 QColorGroup cg = colorGroup(); const QColor textColor = cg.color(QColorGroup::Text); cg.setColor(QColorGroup::Foreground, textColor); painter->setPen(QPen(textColor, d_data->scaleDraw->penWidth())); d_data->scaleDraw->draw(painter, cg); #else QPalette pal = palette(); const QColor textColor = pal.color(QPalette::Text); pal.setColor(QPalette::Foreground, textColor); //ticks, backbone painter->setPen(QPen(textColor, d_data->scaleDraw->penWidth())); d_data->scaleDraw->draw(painter, pal); #endif }
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 777 of file qwt_dial.cpp.
Referenced by drawContents().
{
// empty default implementation
}
Shadow QwtDial::frameShadow | ( | ) | const |
void QwtDial::getScrollMode | ( | const QPoint & | pos, |
int & | scrollMode, | ||
int & | direction | ||
) | [protected, virtual] |
See QwtAbstractSlider::getScrollMode()
pos | point where the mouse was pressed |
scrollMode | The scrolling mode |
direction | direction: 1, 0, or -1. |
Implements QwtAbstractSlider.
Definition at line 1192 of file qwt_dial.cpp.
References contentsRect(), QwtDial::PrivateData::previousDir, QwtAbstractSlider::ScrMouse, and QwtAbstractSlider::ScrNone.
{ direction = 0; scrollMode = ScrNone; const QRegion region(contentsRect(), QRegion::Ellipse); if ( region.contains(pos) && pos != rect().center() ) { scrollMode = ScrMouse; d_data->previousDir = -1.0; } }
double QwtDial::getValue | ( | const QPoint & | pos ) | [protected, virtual] |
Find the value for a given position
pos | Position |
Implements QwtAbstractSlider.
Definition at line 1083 of file qwt_dial.cpp.
References line2Radians(), QwtDial::PrivateData::maxScaleArc, QwtDoubleRange::maxValue(), QwtDial::PrivateData::minScaleArc, QwtDoubleRange::minValue(), mode(), QwtAbstractSlider::mouseOffset(), QwtDial::PrivateData::origin, QwtDial::PrivateData::previousDir, RotateScale, QwtAbstractSlider::ScrMouse, QwtAbstractSlider::scrollMode(), QwtAbstractSlider::setMouseOffset(), QwtDoubleRange::value(), and wrapping().
{ if ( d_data->maxScaleArc == d_data->minScaleArc || maxValue() == minValue() ) return minValue(); double dir = line2Radians(rect().center(), pos) - d_data->origin; if ( dir < 0.0 ) dir += 360.0; if ( mode() == RotateScale ) dir = 360.0 - dir; // The position might be in the area that is outside the scale arc. // We need the range of the scale if it was a complete circle. const double completeCircle = 360.0 / (d_data->maxScaleArc - d_data->minScaleArc) * (maxValue() - minValue()); double posValue = minValue() + completeCircle * dir / 360.0; if ( scrollMode() == ScrMouse ) { if ( d_data->previousDir >= 0.0 ) // valid direction { // We have to find out whether the mouse is moving // clock or counter clockwise bool clockWise = false; const double angle = dir - d_data->previousDir; if ( (angle >= 0.0 && angle <= 180.0) || angle < -180.0 ) clockWise = true; if ( clockWise ) { if ( dir < d_data->previousDir && mouseOffset() > 0.0 ) { // We passed 360 -> 0 setMouseOffset(mouseOffset() - completeCircle); } if ( wrapping() ) { if ( posValue - mouseOffset() > maxValue() ) { // We passed maxValue and the value will be set // to minValue. We have to adjust the mouseOffset. setMouseOffset(posValue - minValue()); } } else { if ( posValue - mouseOffset() > maxValue() || value() == maxValue() ) { // We fix the value at maxValue by adjusting // the mouse offset. setMouseOffset(posValue - maxValue()); } } } else { if ( dir > d_data->previousDir && mouseOffset() < 0.0 ) { // We passed 0 -> 360 setMouseOffset(mouseOffset() + completeCircle); } if ( wrapping() ) { if ( posValue - mouseOffset() < minValue() ) { // We passed minValue and the value will be set // to maxValue. We have to adjust the mouseOffset. setMouseOffset(posValue - maxValue()); } } else { if ( posValue - mouseOffset() < minValue() || value() == minValue() ) { // We fix the value at minValue by adjusting // the mouse offset. setMouseOffset(posValue - minValue()); } } } } d_data->previousDir = dir; } return posValue; }
bool QwtDial::hasVisibleBackground | ( | ) | const |
true when the area outside of the frame is visible
Definition at line 222 of file qwt_dial.cpp.
References QwtDial::PrivateData::visibleBackground.
Referenced by resizeEvent().
{ return d_data->visibleBackground; }
void QwtDial::keyPressEvent | ( | QKeyEvent * | event ) | [protected, virtual] |
Handles key events
event | Key event |
Reimplemented from QwtAbstractSlider.
Reimplemented in QwtCompass.
Definition at line 1225 of file qwt_dial.cpp.
References QwtAbstractSlider::incValue(), QwtAbstractSlider::isReadOnly(), QwtAbstractSlider::isValid(), mitk::Key_Down, mitk::Key_End, mitk::Key_Home, mitk::Key_Left, mitk::Key_Next, mitk::Key_PageDown, mitk::Key_PageUp, mitk::Key_Prior, mitk::Key_Right, mitk::Key_Up, QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), QwtDoubleRange::pageSize(), QwtDoubleRange::prevValue(), QwtAbstractSlider::setValue(), QwtAbstractSlider::sliderMoved(), and QwtDoubleRange::value().
{ if ( isReadOnly() ) { event->ignore(); return; } if ( !isValid() ) return; double previous = prevValue(); switch ( event->key() ) { case Qt::Key_Down: case Qt::Key_Left: QwtDoubleRange::incValue(-1); break; #if QT_VERSION < 0x040000 case Qt::Key_Prior: #else case Qt::Key_PageUp: #endif QwtDoubleRange::incValue(-pageSize()); break; case Qt::Key_Home: setValue(minValue()); break; case Qt::Key_Up: case Qt::Key_Right: QwtDoubleRange::incValue(1); break; #if QT_VERSION < 0x040000 case Qt::Key_Next: #else case Qt::Key_PageDown: #endif QwtDoubleRange::incValue(pageSize()); break; case Qt::Key_End: setValue(maxValue()); break; default:; event->ignore(); } if (value() != previous) emit sliderMoved(value()); }
int QwtDial::lineWidth | ( | ) | const |
Referenced by contentsRect(), drawFrame(), minimumSizeHint(), setFrameShadow(), setLineWidth(), and sizeHint().
double QwtDial::maxScaleArc | ( | ) | const |
Definition at line 971 of file qwt_dial.cpp.
References QwtDial::PrivateData::maxScaleArc.
{ return d_data->maxScaleArc; }
QSize QwtDial::minimumSizeHint | ( | ) | const [virtual] |
Return a minimum size hint.
Definition at line 1048 of file qwt_dial.cpp.
References QwtRoundScaleDraw::extent(), lineWidth(), and QwtDial::PrivateData::scaleDraw.
double QwtDial::minScaleArc | ( | ) | const |
Definition at line 965 of file qwt_dial.cpp.
References QwtDial::PrivateData::minScaleArc.
{ return d_data->minScaleArc; }
Mode QwtDial::mode | ( | ) | const |
Referenced by drawContents(), QwtCompass::drawScaleContents(), getValue(), QwtCompass::keyPressEvent(), and setMode().
QwtDialNeedle * QwtDial::needle | ( | ) |
Definition at line 818 of file qwt_dial.cpp.
References QwtDial::PrivateData::needle.
{ return d_data->needle; }
const QwtDialNeedle * QwtDial::needle | ( | ) | const |
Definition at line 809 of file qwt_dial.cpp.
References QwtDial::PrivateData::needle.
Referenced by QwtAnalogClock::drawHand(), QwtAnalogClock::setHand(), and setNeedle().
{ return d_data->needle; }
double QwtDial::origin | ( | ) | const |
void QwtDial::paintEvent | ( | QPaintEvent * | e ) | [protected, virtual] |
Paint the dial
e | Paint event |
Definition at line 446 of file qwt_dial.cpp.
References drawContents(), drawFocusIndicator(), drawFrame(), and QwtPaintBuffer::painter().
{ const QRect &ur = e->rect(); if ( ur.isValid() ) { #if QT_VERSION < 0x040000 QwtPaintBuffer paintBuffer(this, ur); QPainter &painter = *paintBuffer.painter(); #else QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); #endif painter.save(); drawContents(&painter); painter.restore(); painter.save(); drawFrame(&painter); painter.restore(); if ( hasFocus() ) drawFocusIndicator(&painter); } }
void QwtDial::rangeChange | ( | ) | [protected, virtual] |
QwtDoubleRange update hook.
Reimplemented from QwtDoubleRange.
Definition at line 824 of file qwt_dial.cpp.
References updateScale().
{ updateScale(); }
void QwtDial::resizeEvent | ( | QResizeEvent * | e ) | [protected, virtual] |
Resize the dial widget
e | Resize event |
Definition at line 434 of file qwt_dial.cpp.
References hasVisibleBackground(), and updateMask().
{ QWidget::resizeEvent(e); if ( !hasVisibleBackground() ) updateMask(); }
QRect QwtDial::scaleContentsRect | ( | ) | const [virtual] |
Definition at line 312 of file qwt_dial.cpp.
References contentsRect(), QwtRoundScaleDraw::extent(), and QwtDial::PrivateData::scaleDraw.
Referenced by drawContents().
{ #if QT_VERSION < 0x040000 const QPen scalePen(colorGroup().text(), 0, Qt::NoPen); #else const QPen scalePen(palette().text(), 0, Qt::NoPen); #endif int scaleDist = 0; if ( d_data->scaleDraw ) { scaleDist = d_data->scaleDraw->extent(scalePen, font()); scaleDist++; // margin } const QRect rect = contentsRect(); return QRect(rect.x() + scaleDist, rect.y() + scaleDist, rect.width() - 2 * scaleDist, rect.height() - 2 * scaleDist); }
QwtDialScaleDraw * QwtDial::scaleDraw | ( | ) |
Return the scale draw.
Definition at line 849 of file qwt_dial.cpp.
References QwtDial::PrivateData::scaleDraw.
Referenced by setScaleDraw().
{ return d_data->scaleDraw; }
const QwtDialScaleDraw * QwtDial::scaleDraw | ( | ) | const |
Return the scale draw.
Definition at line 855 of file qwt_dial.cpp.
References QwtDial::PrivateData::scaleDraw.
{ return d_data->scaleDraw; }
QwtText QwtDial::scaleLabel | ( | double | value ) | const [protected, virtual] |
Find the label for a value
value | Value |
Reimplemented in QwtAnalogClock, and QwtCompass.
Definition at line 954 of file qwt_dial.cpp.
Referenced by QwtDialScaleDraw::label().
void QwtDial::setDirection | ( | Direction | direction ) |
Set the direction of the dial (clockwise/counterclockwise)
Direction direction
Definition at line 409 of file qwt_dial.cpp.
References direction(), and QwtDial::PrivateData::direction.
void QwtDial::setFrameShadow | ( | Shadow | shadow ) |
Sets the frame shadow value from the frame style.
shadow | Frame shadow |
Definition at line 232 of file qwt_dial.cpp.
References QwtDial::PrivateData::frameShadow, and lineWidth().
{ if ( shadow != d_data->frameShadow ) { d_data->frameShadow = shadow; if ( lineWidth() > 0 ) update(); } }
void QwtDial::setLineWidth | ( | int | lineWidth ) |
Sets the line width
lineWidth | Line width |
Definition at line 257 of file qwt_dial.cpp.
References lineWidth(), and QwtDial::PrivateData::lineWidth.
void QwtDial::setMode | ( | Mode | mode ) |
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.
Definition at line 347 of file qwt_dial.cpp.
References mode(), and QwtDial::PrivateData::mode.
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 793 of file qwt_dial.cpp.
References needle(), and QwtDial::PrivateData::needle.
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 984 of file qwt_dial.cpp.
References origin(), and QwtDial::PrivateData::origin.
void QwtDial::setScale | ( | int | maxMajIntv, |
int | maxMinIntv, | ||
double | step = 0.0 |
||
) | [virtual] |
Change the intervals of the scale
Definition at line 883 of file qwt_dial.cpp.
References QwtDial::PrivateData::maxMajIntv, QwtDial::PrivateData::maxMinIntv, QwtDial::PrivateData::scaleStep, QwtDoubleRange::step(), and updateScale().
{ d_data->maxMajIntv = maxMajIntv; d_data->maxMinIntv = maxMinIntv; d_data->scaleStep = step; updateScale(); }
void QwtDial::setScaleArc | ( | double | minArc, |
double | maxArc | ||
) |
Change the arc of the scale
minArc | Lower limit |
maxArc | Upper limit |
Definition at line 1007 of file qwt_dial.cpp.
References QwtDial::PrivateData::maxScaleArc, QwtDial::PrivateData::minScaleArc, qwtMax, and qwtMin.
{ if ( minArc != 360.0 && minArc != -360.0 ) minArc = fmod(minArc, 360.0); if ( maxArc != 360.0 && maxArc != -360.0 ) maxArc = fmod(maxArc, 360.0); d_data->minScaleArc = qwtMin(minArc, maxArc); d_data->maxScaleArc = qwtMax(minArc, maxArc); if ( d_data->maxScaleArc - d_data->minScaleArc > 360.0 ) d_data->maxScaleArc = d_data->minScaleArc + 360.0; update(); }
void QwtDial::setScaleDraw | ( | QwtDialScaleDraw * | scaleDraw ) | [virtual] |
Set an individual scale draw
scaleDraw | Scale draw |
Definition at line 866 of file qwt_dial.cpp.
References scaleDraw(), QwtDial::PrivateData::scaleDraw, and updateScale().
Referenced by setScaleOptions().
void QwtDial::setScaleOptions | ( | int | options ) |
A wrapper method for accessing the scale draw.
Definition at line 906 of file qwt_dial.cpp.
References QwtAbstractScaleDraw::Backbone, QwtAbstractScaleDraw::enableComponent(), QwtAbstractScaleDraw::Labels, ScaleBackbone, QwtDial::PrivateData::scaleDraw, ScaleLabel, ScaleTicks, setScaleDraw(), and QwtAbstractScaleDraw::Ticks.
{ if ( options == 0 ) setScaleDraw(NULL); QwtDialScaleDraw *sd = d_data->scaleDraw; if ( sd == NULL ) return; sd->enableComponent(QwtAbstractScaleDraw::Backbone, options & ScaleBackbone); sd->enableComponent(QwtAbstractScaleDraw::Ticks, options & ScaleTicks); sd->enableComponent(QwtAbstractScaleDraw::Labels, options & ScaleLabel); }
void QwtDial::setScaleTicks | ( | int | minLen, |
int | medLen, | ||
int | majLen, | ||
int | penWidth = 1 |
||
) |
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 |
Definition at line 935 of file qwt_dial.cpp.
References QwtScaleDiv::MajorTick, QwtScaleDiv::MediumTick, QwtScaleDiv::MinorTick, QwtDial::PrivateData::scaleDraw, QwtDialScaleDraw::setPenWidth(), and QwtAbstractScaleDraw::setTickLength().
{ QwtDialScaleDraw *sd = d_data->scaleDraw; if ( sd ) { sd->setTickLength(QwtScaleDiv::MinorTick, minLen); sd->setTickLength(QwtScaleDiv::MediumTick, medLen); sd->setTickLength(QwtScaleDiv::MajorTick, majLen); sd->setPenWidth(penWidth); } }
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 385 of file qwt_dial.cpp.
References QwtDoubleRange::setPeriodic().
{ setPeriodic(wrapping); }
void QwtDial::showBackground | ( | bool | show ) |
Show/Hide the area outside of the frame
show | Show if true, hide if false |
Definition at line 208 of file qwt_dial.cpp.
References updateMask(), and QwtDial::PrivateData::visibleBackground.
{ if ( d_data->visibleBackground != show ) { d_data->visibleBackground = show; updateMask(); } }
QSize QwtDial::sizeHint | ( | ) | const [virtual] |
Definition at line 1032 of file qwt_dial.cpp.
References QwtRoundScaleDraw::extent(), lineWidth(), and QwtDial::PrivateData::scaleDraw.
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 1284 of file qwt_dial.cpp.
References boundingRect(), and QwtDial::PrivateData::visibleBackground.
Referenced by resizeEvent(), and showBackground().
{ if ( d_data->visibleBackground ) clearMask(); else setMask(QRegion(boundingRect(), QRegion::Ellipse)); }
void QwtDial::updateScale | ( | ) | [protected] |
Update the scale with the current attributes
Definition at line 833 of file qwt_dial.cpp.
References QwtLinearScaleEngine::divideScale(), QwtDial::PrivateData::maxMajIntv, QwtDial::PrivateData::maxMinIntv, QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), QwtDial::PrivateData::scaleDraw, QwtDial::PrivateData::scaleStep, QwtAbstractScaleDraw::setScaleDiv(), QwtAbstractScaleDraw::setTransformation(), and QwtLinearScaleEngine::transformation().
Referenced by rangeChange(), setScale(), and setScaleDraw().
{ if ( d_data->scaleDraw ) { QwtLinearScaleEngine scaleEngine; const QwtScaleDiv scaleDiv = scaleEngine.divideScale( minValue(), maxValue(), d_data->maxMajIntv, d_data->maxMinIntv, d_data->scaleStep); d_data->scaleDraw->setTransformation(scaleEngine.transformation()); d_data->scaleDraw->setScaleDiv(scaleDiv); } }
void QwtDial::valueChange | ( | ) | [protected, virtual] |
QwtDoubleRange update hook.
Reimplemented from QwtAbstractSlider.
Definition at line 1023 of file qwt_dial.cpp.
{ update(); QwtAbstractSlider::valueChange(); }
bool QwtDial::wrapping | ( | ) | const |
Referenced by getValue().
friend class QwtDialScaleDraw [friend] |
Definition at line 83 of file qwt_dial.h.
QwtDial::Direction QwtDial::direction [read, write] |
The default direction of a dial is QwtDial::Clockwise
Definition at line 81 of file qwt_dial.h.
QwtDial::Shadow QwtDial::frameShadow [read, write] |
Definition at line 77 of file qwt_dial.h.
int QwtDial::lineWidth [read, write] |
Definition at line 76 of file qwt_dial.h.
QwtDial::Mode QwtDial::mode [read, write] |
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.
Definition at line 78 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 79 of file qwt_dial.h.
bool QwtDial::visibleBackground [read, write] |
Definition at line 75 of file qwt_dial.h.
bool QwtDial::wrapping [read, write] |
wrapping() holds whether it is possible to step the value from the highest value to the lowest value and vice versa.
Definition at line 80 of file qwt_dial.h.