QwtScaleDraw can be used to draw linear or logarithmic scales. A scale has an origin, an orientation and a length, which all can be specified with QwtScaleDraw::setGeometry(). The labels can be rotated and aligned to the ticks using QwtScaleDraw::setLabelRotation(), QwtScaleDraw::setLabelAlignment().
After a scale division has been specified as a QwtScaleDiv object using QwtScaleDraw::setScale(const QwtScaleDiv &s), or determined internally using QwtScaleDraw::setScale(double vmin, double vmax, int maxMajIntv, int maxMinIntv, double step = 0.0, int logarithmic = 0), the scale can be drawn with the QwtScaleDraw::draw() member.
Definition at line 38 of file qwt_scldraw.h.
Public Types | |
enum | Orientation { Bottom, Top, Left, Right, Round } |
enum | Option { None = 0, Backbone = 1 } |
Public Member Functions | |
QwtScaleDraw () | |
virtual | ~QwtScaleDraw () |
void | setScale (const QwtScaleDiv &s) |
void | setScale (double vmin, double vmax, int maxMajIntv, int maxMinIntv, double step=0.0, int logarithmic=0) |
void | setOptions (int opt) |
int | options () const |
void | setGeometry (int xorigin, int yorigin, int length, Orientation o) |
int | x () const |
int | y () const |
int | length () const |
Orientation | orientation () const |
void | setAngleRange (double angle1, double angle2) |
void | setLabelFormat (char f, int prec, int fieldwidth=0) |
void | setLabelAlignment (int align) |
void | setLabelRotation (double rotation) |
void | setTickLength (unsigned int minLen, unsigned int medLen, unsigned int majLen) |
void | setMargin (uint hMargin, uint vMargin) |
const QwtScaleDiv & | scaleDiv () const |
int | maxWidth (const QPen &pen, const QFontMetrics &fm) const |
int | maxHeight (const QPen &pen, const QFontMetrics &fm) const |
void | minBorderDist (const QFontMetrics &fm, int &start, int &end) const |
int | minLabelDist (const QFontMetrics &fm) const |
int | minHeight (const QPen &pen, const QFontMetrics &fm) const |
int | minWidth (const QPen &pen, const QFontMetrics &fm) const |
void | labelFormat (char &f, int &prec, int &fieldwidth) const |
int | labelAlignment () const |
double | labelRotation () const |
void | tickLength (unsigned int &minLen, unsigned int &medLen, unsigned int &majLen) const |
unsigned int | majTickLength () const |
virtual void | draw (QPainter *p) const |
virtual QString | label (double) const |
Protected Member Functions | |
virtual void | labelPlacement (const QFontMetrics &, double val, QPoint &pos, int &alignment, double &rotation) const |
virtual int | maxLabelHeight (const QFontMetrics &) const |
virtual int | maxLabelWidth (const QFontMetrics &) const |
QRect | labelBoundingRect (const QFontMetrics &, double val) const |
void | drawTick (QPainter *p, double val, int len) const |
void | drawBackbone (QPainter *p) const |
void | drawLabel (QPainter *p, double val) const |
QWMatrix | labelWorldMatrix (const QFontMetrics &, const QPoint &, int alignment, double rotation, const QString &) const |
|
Orientation/Position of the scale draw
Definition at line 45 of file qwt_scldraw.h. Referenced by orientation(). |
|
Constructor. The range of the scale is initialized to [0, 100], the angle range is set to [-135, 135], the geometry is initialized such that the origin is at (0,0), the length is 100, and the orientation is QwtScaleDraw::Bottom. Definition at line 29 of file qwt_scldraw.cpp. References setGeometry(), and setScale(). |
|
Destructor.
Definition at line 52 of file qwt_scldraw.cpp. |
|
Draw the scale.
Definition at line 104 of file qwt_scldraw.cpp. References drawBackbone(), drawLabel(), drawTick(), QwtScaleDiv::logScale(), QwtScaleDiv::majCnt(), QwtScaleDiv::majMark(), QwtScaleDiv::majStep(), QwtScaleDiv::minCnt(), QwtScaleDiv::minMark(), and options(). Referenced by QwtThermo::draw(), QwtSlider::draw(), QwtScale::draw(), QwtKnob::draw(), QwtDial::drawScale(), and QwtPlot::printScale(). |
|
Draws the baseline of the scale.
Definition at line 374 of file qwt_scldraw.cpp. References QwtPainter::drawLine(), QwtDiMap::i1(), and QwtDiMap::i2(). Referenced by draw(). |
|
Draws the number label for a major scale tick.
Definition at line 204 of file qwt_scldraw.cpp. References QwtPainter::drawText(), label(), labelPlacement(), and labelWorldMatrix(). Referenced by draw(). |
|
Draws a single scale tick.
Definition at line 160 of file qwt_scldraw.cpp. References QwtPainter::drawLine(), and QwtDiMap::transform(). Referenced by draw(). |
|
Convert a value into its representing label using the labelFormat.
Reimplemented in QwtDialScaleDraw. Definition at line 1045 of file qwt_scldraw.cpp. Referenced by drawLabel(), QwtDialScaleDraw::label(), labelBoundingRect(), and labelPlacement(). |
|
Definition at line 588 of file qwt_scldraw.cpp. |
|
Find the bounding rect for the label. The coordinates of the rect are relative to margin + ticklength from the backbone in direction of the tick. Definition at line 793 of file qwt_scldraw.cpp. References label(), labelPlacement(), and labelWorldMatrix(). Referenced by maxLabelHeight(), maxLabelWidth(), minBorderDist(), and minLabelDist(). |
|
Return the number format for the major scale labels. Format character, precision and fieldwidth have the same meaning as for sprintf().
Definition at line 679 of file qwt_scldraw.cpp. Referenced by QwtScale::labelFormat(). |
|
Find position, alignment and rotation of the label.
Definition at line 232 of file qwt_scldraw.cpp. References label(), QwtScaleDiv::logScale(), QwtScaleDiv::majStep(), QwtDiMap::transform(), x(), and y(). Referenced by drawLabel(), and labelBoundingRect(). |
|
Definition at line 555 of file qwt_scldraw.cpp. |
|
Return the world matrix for painting the label.
Definition at line 335 of file qwt_scldraw.cpp. Referenced by drawLabel(), and labelBoundingRect(). |
|
Return length.
Definition at line 1076 of file qwt_scldraw.cpp. Referenced by QwtPlot::printScale(). |
|
Return the length of the major ticks
Definition at line 727 of file qwt_scldraw.cpp. Referenced by QwtPlotLayout::minimumSizeHint(). |
|
Definition at line 513 of file qwt_scldraw.cpp. References maxLabelHeight(). Referenced by QwtScale::layoutScale(), maxLabelHeight(), and QwtDial::scaleContentsRect(). |
|
Definition at line 764 of file qwt_scldraw.cpp. References labelBoundingRect(), QwtScaleDiv::logScale(), QwtScaleDiv::majCnt(), QwtScaleDiv::majMark(), QwtScaleDiv::majStep(), and maxHeight(). Referenced by maxHeight(), and minHeight(). |
|
Definition at line 736 of file qwt_scldraw.cpp. References labelBoundingRect(), QwtScaleDiv::logScale(), QwtScaleDiv::majCnt(), QwtScaleDiv::majMark(), QwtScaleDiv::majStep(), and maxWidth(). Referenced by maxWidth(), minHeight(), and minWidth(). |
|
Definition at line 487 of file qwt_scldraw.cpp. References maxLabelWidth(). Referenced by QwtScale::layoutScale(), maxLabelWidth(), and QwtDial::scaleContentsRect(). |
|
Determine the minimum border distance. This member function returns the minimum space needed to draw the mark labels at the scale's endpoints.
Definition at line 839 of file qwt_scldraw.cpp. References labelBoundingRect(), QwtScaleDiv::majCnt(), and QwtScaleDiv::majMark(). Referenced by QwtSlider::layoutSlider(), QwtThermo::layoutThermo(), QwtScale::minBorderDist(), minHeight(), QwtSlider::minimumSizeHint(), and minWidth(). |
|
Definition at line 960 of file qwt_scldraw.cpp. References QwtScaleDiv::majCnt(), maxLabelHeight(), maxLabelWidth(), minBorderDist(), QwtScaleDiv::minCnt(), and minLabelDist(). Referenced by QwtScale::dimForLength(), QwtThermo::minimumSizeHint(), QwtSlider::minimumSizeHint(), QwtScale::minimumSizeHint(), QwtKnob::minimumSizeHint(), QwtDial::minimumSizeHint(), and QwtDial::sizeHint(). |
|
Determine the minimum distance between two labels, that is necessairy that the texts don't overlap.
Definition at line 880 of file qwt_scldraw.cpp. References labelBoundingRect(), QwtScaleDiv::majCnt(), and QwtScaleDiv::majMark(). Referenced by minHeight(), and minWidth(). |
|
Definition at line 1000 of file qwt_scldraw.cpp. References QwtScaleDiv::majCnt(), maxLabelWidth(), minBorderDist(), QwtScaleDiv::minCnt(), and minLabelDist(). Referenced by QwtScale::dimForLength(), QwtThermo::minimumSizeHint(), QwtSlider::minimumSizeHint(), and QwtScale::minimumSizeHint(). |
|
Definition at line 65 of file qwt_scldraw.cpp. Referenced by draw(), and QwtDial::setScaleOptions(). |
|
Return scale orientation.
Definition at line 1082 of file qwt_scldraw.cpp. References Orientation. Referenced by QwtScale::dimForLength(), QwtScale::draw(), QwtScale::layoutScale(), QwtScale::minimumSizeHint(), QwtScale::position(), QwtThermo::sizePolicy(), and QwtScale::sizePolicy(). |
|
Definition at line 74 of file qwt_scldraw.h. Referenced by QwtThermo::setRange(), QwtScaleIf::setScale(), QwtScale::setScaleDiv(), QwtScaleIf::setScaleMaxMajor(), QwtScaleIf::setScaleMaxMinor(), and QwtPlot::sizeHint(). |
|
Adjust the baseline circle segment for round scales. The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2). The settings have no effect if the scale orientation is not set to QwtScaleDraw::Round. The default setting is [ -135, 135 ]. An angle of 0 degrees corresponds to the 12 o'clock position, and positive angles count in a clockwise direction.
Definition at line 611 of file qwt_scldraw.cpp. References qwtLim(), and QwtDiMap::setIntRange(). Referenced by QwtDial::drawScale(), and QwtKnob::setTotalAngle(). |
|
Specify the geometry of the scale. The parameters xorigin, yorigin and length have different meanings, dependent on the orientation:
Definition at line 448 of file qwt_scldraw.cpp. References QwtDiMap::setIntRange(). Referenced by QwtDial::drawScale(), QwtScale::layoutScale(), QwtSlider::layoutSlider(), QwtThermo::layoutThermo(), QwtPlot::printScale(), QwtDial::QwtDial(), QwtKnob::QwtKnob(), QwtScaleDraw(), QwtSlider::QwtSlider(), and QwtScale::setPosition(). |
|
Labels are aligned to the point ticklength + margin away from the backbone. The alignment is relative to the orientation of the label text. In case of an alignment of 0 the label will be aligned depending on the orientation of the scale:
QwtScaleDraw::Top: Qt::AlignHCenter | Qt::AlignTop Changing the alignment is often necessary for rotated labels.
Definition at line 579 of file qwt_scldraw.cpp. Referenced by QwtScale::setLabelAlignment(). |
|
Set the number format for the major scale labels. Format character, precision and fieldwidth have the same meaning as for sprintf().
Definition at line 646 of file qwt_scldraw.cpp. Referenced by QwtScale::setLabelFormat(). |
|
Rotate all labels.
Definition at line 546 of file qwt_scldraw.cpp. Referenced by QwtScale::setLabelRotation(). |
|
Set the margins of the ticks
Definition at line 692 of file qwt_scldraw.cpp. |
|
Change the scale draw options.
Definition at line 57 of file qwt_scldraw.cpp. Referenced by QwtDial::setScaleOptions(). |
|
Adjust the range of the scale. If step == 0.0, the step width is calculated automatically dependent on the maximal number of scale ticks.
Definition at line 82 of file qwt_scldraw.cpp. References QwtScaleDiv::hBound(), QwtScaleDiv::lBound(), QwtScaleDiv::logScale(), QwtScaleDiv::rebuild(), and QwtDiMap::setDblRange(). |
|
Change the scale division.
Definition at line 94 of file qwt_scldraw.cpp. References QwtScaleDiv::hBound(), QwtScaleDiv::lBound(), QwtScaleDiv::logScale(), and QwtDiMap::setDblRange(). Referenced by QwtScaleDraw(), QwtScaleIf::QwtScaleIf(), QwtSlider::rangeChange(), QwtSlider::scaleChange(), QwtThermo::setRange(), QwtScaleIf::setScale(), QwtScale::setScaleDiv(), QwtScaleIf::setScaleMaxMajor(), QwtScaleIf::setScaleMaxMinor(), and QwtDial::updateScale(). |
|
Set the length of the ticks Definition at line 701 of file qwt_scldraw.cpp. Referenced by QwtDial::setScaleOptions(), and QwtDial::setScaleTicks(). |
|
Return the length of the ticks
Definition at line 715 of file qwt_scldraw.cpp. |
|
Return x origin.
Definition at line 1064 of file qwt_scldraw.cpp. Referenced by labelPlacement(), labelWorldMatrix(), and QwtPlot::printScale(). |
|
Return y origin.
Definition at line 1070 of file qwt_scldraw.cpp. Referenced by labelPlacement(), labelWorldMatrix(), and QwtPlot::printScale(). |