|
QWT 7.0.1
|
A class for drawing scales. More...
#include <qwt_scale_draw.h>
Classes | |
| class | PrivateData |
Public Types | |
| enum | Alignment { BottomScale , TopScale , LeftScale , RightScale } |
| Alignment of the scale draw. More... | |
Public Types inherited from QwtAbstractScaleDraw | |
| enum | ScaleComponent { Backbone = 0x01 , Ticks = 0x02 , Labels = 0x04 } |
| Components of a scale. More... | |
Public Member Functions | |
| QwtScaleDraw () | |
| Constructor. | |
| virtual | ~QwtScaleDraw () |
| Destructor. | |
| void | getBorderDistHint (const QFont &, int &start, int &end) const |
| Determine the minimum border distance. | |
| int | minLabelDist (const QFont &) const |
| Determine the minimum distance between two labels, that is necessary that the texts don't overlap. | |
| int | minLength (const QFont &) const |
| Calculate the minimum length that is needed to draw the scale. | |
| virtual double | extent (const QFont &) const QWT_OVERRIDE |
| Calculate the width/height that is needed for a vertical/horizontal scale. | |
| void | move (double x, double y) |
| Move the position of the scale. | |
| void | move (const QPointF &) |
| Move the position of the scale. | |
| void | setLength (double length) |
| Set the length of the backbone. | |
| Alignment | alignment () const |
| Return alignment of the scale. | |
| void | setAlignment (Alignment) |
| Set the alignment of the scale. | |
| Qt::Orientation | orientation () const |
| Return the orientation. | |
| QPointF | pos () const |
| double | length () const |
| void | setLabelAlignment (Qt::Alignment) |
| Change the label flags. | |
| Qt::Alignment | labelAlignment () const |
| void | setLabelRotation (double rotation) |
| Rotate all labels. | |
| double | labelRotation () const |
| int | maxLabelHeight (const QFont &) const |
| int | maxLabelWidth (const QFont &) const |
| QPointF | labelPosition (double value) const |
| Find the position, where to paint a label. | |
| QRectF | labelRect (const QFont &, double value) const |
| Find the bounding rectangle for the label. | |
| QSizeF | labelSize (const QFont &, double value) const |
| Calculate the size that is needed to draw a label. | |
| QRect | boundingLabelRect (const QFont &, double value) const |
| Find the bounding rectangle for the label. | |
Public Member Functions inherited from QwtAbstractScaleDraw | |
| QwtAbstractScaleDraw () | |
| Constructor. | |
| virtual | ~QwtAbstractScaleDraw () |
| Destructor. | |
| void | setScaleDiv (const QwtScaleDiv &) |
| Change the scale division. | |
| const QwtScaleDiv & | scaleDiv () const |
| void | setTransformation (QwtTransform *) |
| Change the transformation of the scale. | |
| const QwtScaleMap & | scaleMap () const |
| QwtScaleMap & | scaleMap () |
| void | enableComponent (ScaleComponent, bool enable=true) |
| En/Disable a component of the scale. | |
| bool | hasComponent (ScaleComponent) const |
| Check if a component is enabled. | |
| void | setTickLength (QwtScaleDiv::TickType, double length) |
| Set the length of the ticks. | |
| double | tickLength (QwtScaleDiv::TickType) const |
| double | maxTickLength () const |
| void | setSpacing (double) |
| Set the spacing between tick and labels. | |
| double | spacing () const |
| Get the spacing. | |
| void | setPenWidthF (qreal width) |
| Specify the width of the scale pen. | |
| qreal | penWidthF () const |
| void | setSelected (bool on) |
| 设置是否选中 | |
| bool | isSelected () const |
| 是否选中 | |
| void | setSelectedPenWidthOffset (qreal offset=1) |
| 设置坐标轴在选中状态下的画笔宽度附加值 | |
| qreal | selectedPenWidthOffset () const |
| 获取当前坐标轴在选中状态下的画笔宽度附加值 | |
| virtual void | draw (QPainter *, const QPalette &) const |
| Draw the scale. | |
| virtual QwtText | label (double) const |
| Convert a value into its representing label. | |
| void | setMinimumExtent (double) |
| Set a minimum for the extent. | |
| double | minimumExtent () const |
| Get the minimum extent. | |
| void | invalidateCache () |
| Invalidate the cache used by tickLabel() | |
Protected Member Functions | |
| QTransform | labelTransformation (const QPointF &, const QSizeF &) const |
| Calculate the transformation that is needed to paint a label depending on its alignment and rotation. | |
| virtual void | drawTick (QPainter *, double value, double len) const QWT_OVERRIDE |
| Draw a tick. | |
| virtual void | drawBackbone (QPainter *) const QWT_OVERRIDE |
| Draws the baseline of the scale. | |
| virtual void | drawLabel (QPainter *, double value) const QWT_OVERRIDE |
| Draws the label for a major scale tick. | |
Protected Member Functions inherited from QwtAbstractScaleDraw | |
| const QwtText & | tickLabel (const QFont &, double value) const |
| Convert a value into its representing label and cache it. | |
A class for drawing scales.
QwtScaleDraw can be used to draw linear or logarithmic scales. A scale has a position, an alignment and a length, which can be specified . The labels can be rotated and aligned to the ticks using setLabelRotation() and setLabelAlignment().
After a scale division has been specified as a QwtScaleDiv object using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s), the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
Alignment of the scale draw.
| Enumerator | |
|---|---|
| BottomScale | The scale is below. |
| TopScale | The scale is above. |
| LeftScale | The scale is left. |
| RightScale | The scale is right. |
| QwtScaleDraw::QwtScaleDraw | ( | ) |
Constructor.
The range of the scale is initialized to [0, 100], The position is at (0, 0) with a length of 100. The orientation is QwtAbstractScaleDraw::Bottom.
| QwtScaleDraw::Alignment QwtScaleDraw::alignment | ( | ) | const |
| QRect QwtScaleDraw::boundingLabelRect | ( | const QFont & | font, |
| double | value | ||
| ) | const |
Find the bounding rectangle for the label.
The coordinates of the rectangle are absolute ( calculated from pos() ). in direction of the tick.
| font | Font used for painting |
| value | Value |
|
protectedvirtual |
Draws the baseline of the scale.
| painter | Painter |
Implements QwtAbstractScaleDraw.
|
protectedvirtual |
Draws the label for a major scale tick.
| painter | Painter |
| value | Value |
Implements QwtAbstractScaleDraw.
|
protectedvirtual |
Draw a tick.
| painter | Painter |
| value | Value of the tick |
| len | Length of the tick |
Implements QwtAbstractScaleDraw.
|
virtual |
Calculate the width/height that is needed for a vertical/horizontal scale.
The extent is calculated from the pen width of the backbone, the major tick length, the spacing and the maximum width/height of the labels.
| font | Font used for painting the labels |
Implements QwtAbstractScaleDraw.
| void QwtScaleDraw::getBorderDistHint | ( | const QFont & | font, |
| int & | start, | ||
| int & | end | ||
| ) | const |
Determine the minimum border distance.
This member function returns the minimum space needed to draw the mark labels at the scale's endpoints.
| font | Font |
| start | Start border distance |
| end | End border distance |
| Qt::Alignment QwtScaleDraw::labelAlignment | ( | ) | const |
| QPointF QwtScaleDraw::labelPosition | ( | double | value | ) | const |
Find the position, where to paint a label.
The position has a distance that depends on the length of the ticks in direction of the alignment().
| value | Value |
| QRectF QwtScaleDraw::labelRect | ( | const QFont & | font, |
| double | value | ||
| ) | const |
Find the bounding rectangle for the label.
The coordinates of the rectangle are relative to spacing + tick length from the backbone in direction of the tick.
| font | Font used for painting |
| value | Value |
| double QwtScaleDraw::labelRotation | ( | ) | const |
| QSizeF QwtScaleDraw::labelSize | ( | const QFont & | font, |
| double | value | ||
| ) | const |
Calculate the size that is needed to draw a label.
| font | Label font |
| value | Value |
|
protected |
Calculate the transformation that is needed to paint a label depending on its alignment and rotation.
| pos | Position where to paint the label |
| size | Size of the label |
| double QwtScaleDraw::length | ( | ) | const |
| int QwtScaleDraw::maxLabelHeight | ( | const QFont & | font | ) | const |
| font | Font |
| int QwtScaleDraw::maxLabelWidth | ( | const QFont & | font | ) | const |
| font | Font |
| int QwtScaleDraw::minLabelDist | ( | const QFont & | font | ) | const |
Determine the minimum distance between two labels, that is necessary that the texts don't overlap.
| font | Font |
| int QwtScaleDraw::minLength | ( | const QFont & | font | ) | const |
Calculate the minimum length that is needed to draw the scale.
| font | Font used for painting the labels |
| void QwtScaleDraw::move | ( | const QPointF & | pos | ) |
Move the position of the scale.
The meaning of the parameter pos depends on the alignment:
| pos | Origin of the scale |
|
inline |
Move the position of the scale.
| x | X coordinate |
| y | Y coordinate |
| Qt::Orientation QwtScaleDraw::orientation | ( | ) | const |
Return the orientation.
TopScale, BottomScale are horizontal (Qt::Horizontal) scales, LeftScale, RightScale are vertical (Qt::Vertical) scales.
| void QwtScaleDraw::setAlignment | ( | Alignment | align | ) |
Set the alignment of the scale.
| align | Alignment of the scale |
The default alignment is QwtScaleDraw::BottomScale
| void QwtScaleDraw::setLabelAlignment | ( | Qt::Alignment | alignment | ) |
Change the label flags.
Labels are aligned to the point tick length + spacing away from the backbone.
The alignment is relative to the orientation of the label text. In case of an flags of 0 the label will be aligned depending on the orientation of the scale:
QwtScaleDraw::TopScale: Qt::AlignHCenter | Qt::AlignTop
QwtScaleDraw::BottomScale: Qt::AlignHCenter | Qt::AlignBottom
QwtScaleDraw::LeftScale: Qt::AlignLeft | Qt::AlignVCenter
QwtScaleDraw::RightScale: Qt::AlignRight | Qt::AlignVCenter
Changing the alignment is often necessary for rotated labels.
| alignment | Or'd Qt::AlignmentFlags see <qnamespace.h> |
| void QwtScaleDraw::setLabelRotation | ( | double | rotation | ) |
Rotate all labels.
When changing the rotation, it might be necessary to adjust the label flags too. Finding a useful combination is often the result of try and error.
| rotation | Angle in degrees. When changing the label rotation, the label flags often needs to be adjusted too. |
| void QwtScaleDraw::setLength | ( | double | length | ) |
Set the length of the backbone.
The length doesn't include the space needed for overlapping labels.
| length | Length of the backbone |