Eneboo - Documentación para desarrolladores
|
A class for drawing scales. Más...
#include <qwt_scale_draw.h>
Clases | |
class | PrivateData |
Tipos públicos | |
enum | Alignment { BottomScale, TopScale, LeftScale, RightScale } |
Métodos públicos | |
QwtScaleDraw () | |
Constructor. | |
QwtScaleDraw (const QwtScaleDraw &) | |
Copy constructor. | |
virtual | ~QwtScaleDraw () |
Destructor. | |
QwtScaleDraw & | operator= (const QwtScaleDraw &other) |
Assignment operator. | |
void | getBorderDistHint (const QFont &, int &start, int &end) const |
Determine the minimum border distance. | |
int | minLabelDist (const QFont &) const |
int | minLength (const QPen &, const QFont &) const |
virtual int | extent (const QPen &, const QFont &) const |
void | move (int x, int y) |
void | move (const QPoint &) |
Move the position of the scale. | |
void | setLength (int length) |
Alignment | alignment () const |
void | setAlignment (Alignment) |
Qt::Orientation | orientation () const |
QPoint | pos () const |
int | length () const |
void | setLabelAlignment (int) |
Change the label flags. | |
int | labelAlignment () const |
void | setLabelRotation (double rotation) |
double | labelRotation () const |
int | maxLabelHeight (const QFont &) const |
int | maxLabelWidth (const QFont &) const |
QPoint | labelPosition (double val) const |
QRect | labelRect (const QFont &, double val) const |
QSize | labelSize (const QFont &, double val) const |
QRect | boundingLabelRect (const QFont &, double val) const |
Métodos protegidos | |
QWMatrix | labelMatrix (const QPoint &, const QSize &) const |
virtual void | drawTick (QPainter *p, double val, int len) const |
virtual void | drawBackbone (QPainter *p) const |
virtual void | drawLabel (QPainter *p, double val) const |
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
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::QwtScaleDraw | ( | const QwtScaleDraw & | other | ) |
Copy constructor.
QwtScaleDraw::~QwtScaleDraw | ( | ) | [virtual] |
Destructor.
QwtScaleDraw::Alignment QwtScaleDraw::alignment | ( | ) | const |
Return alignment of the scale
Find the bounding rect for the label. The coordinates of the rect are absolute coordinates ( calculated from pos() ). in direction of the tick.
font | Font used for painting |
value | Value |
void QwtScaleDraw::drawBackbone | ( | QPainter * | painter | ) | const [protected, virtual] |
Draws the baseline of the scale
painter | Painter |
Implementa QwtAbstractScaleDraw.
void QwtScaleDraw::drawLabel | ( | QPainter * | painter, |
double | value | ||
) | const [protected, virtual] |
Draws the label for a major scale tick
painter | Painter |
value | Value |
Implementa QwtAbstractScaleDraw.
void QwtScaleDraw::drawTick | ( | QPainter * | painter, |
double | value, | ||
int | len | ||
) | const [protected, virtual] |
Draw a tick
painter | Painter |
value | Value of the tick |
len | Lenght of the tick |
Implementa QwtAbstractScaleDraw.
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.
pen | Pen that is used for painting backbone and ticks |
font | Font used for painting the labels |
Implementa QwtAbstractScaleDraw.
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 |
int QwtScaleDraw::labelAlignment | ( | ) | const |
Calculate the matrix 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 |
QPoint QwtScaleDraw::labelPosition | ( | double | value | ) | const |
Find the position, where to paint a label
The position has a distance of majTickLength() + spacing() + 1 from the backbone. The direction depends on the alignment()
value | Value |
Find the bounding rect for the label. The coordinates of the rect are relative to spacing + ticklength from the backbone in direction of the tick.
font | Font used for painting |
value | Value |
double QwtScaleDraw::labelRotation | ( | ) | const |
Calculate the size that is needed to draw a label
font | Label font |
value | Value |
int QwtScaleDraw::length | ( | void | ) | const |
font | Font |
font | Font |
Determine the minimum distance between two labels, that is necessary that the texts don't overlap.
font | Font |
Calculate the minimum length that is needed to draw the scale
pen | Pen that is used for painting backbone and ticks |
font | Font used for painting the labels |
void QwtScaleDraw::move | ( | const QPoint & | pos | ) |
Move the position of the scale.
The meaning of the parameter pos depends on the alignment:
pos | Origin of the scale |
QwtScaleDraw & QwtScaleDraw::operator= | ( | const QwtScaleDraw & | other | ) |
Assignment operator.
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
The default alignment is QwtScaleDraw::BottomScale
void QwtScaleDraw::setLabelAlignment | ( | int | alignment | ) |
Change the label flags.
Labels are aligned to the point ticklength + 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 | ( | int | length | ) |
Set the length of the backbone.
The length doesn't include the space needed for overlapping labels.