Qwt User's Guide 5.2.2
|
A class for drawing round scales. More...
#include <qwt_round_scale_draw.h>
Public Types | |
enum | ScaleComponent { Backbone = 1, Ticks = 2, Labels = 4 } |
Public Member Functions | |
QPoint | center () const |
virtual void | draw (QPainter *, const QPalette &) const |
void | enableComponent (ScaleComponent, bool enable=true) |
virtual int | extent (const QPen &, const QFont &) const |
bool | hasComponent (ScaleComponent) const |
virtual QwtText | label (double) const |
int | majTickLength () const |
const QwtScaleMap & | map () const |
int | minimumExtent () const |
void | moveCenter (const QPoint &) |
void | moveCenter (int x, int y) |
QwtRoundScaleDraw & | operator= (const QwtRoundScaleDraw &other) |
QwtRoundScaleDraw (const QwtRoundScaleDraw &) | |
QwtRoundScaleDraw () | |
int | radius () const |
const QwtScaleDiv & | scaleDiv () const |
QwtScaleMap & | scaleMap () |
void | setAngleRange (double angle1, double angle2) |
void | setMinimumExtent (int) |
void | setRadius (int radius) |
void | setScaleDiv (const QwtScaleDiv &s) |
void | setSpacing (int margin) |
void | setTickLength (QwtScaleDiv::TickType, int length) |
void | setTransformation (QwtScaleTransformation *) |
int | spacing () const |
int | tickLength (QwtScaleDiv::TickType) const |
virtual | ~QwtRoundScaleDraw () |
Protected Member Functions | |
virtual void | drawBackbone (QPainter *p) const |
virtual void | drawLabel (QPainter *p, double val) const |
virtual void | drawTick (QPainter *p, double val, int len) const |
void | invalidateCache () |
const QwtText & | tickLabel (const QFont &, double value) const |
A class for drawing round scales.
QwtRoundScaleDraw can be used to draw round scales. The circle segment can be adjusted by QwtRoundScaleDraw::setAngleRange(). The geometry of the scale can be specified with QwtRoundScaleDraw::moveCenter() and QwtRoundScaleDraw::setRadius().
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.
enum QwtAbstractScaleDraw::ScaleComponent [inherited] |
QwtRoundScaleDraw::QwtRoundScaleDraw | ( | ) |
Constructor.
The range of the scale is initialized to [0, 100], The center is set to (50, 50) with a radius of 50. The angle range is set to [-135, 135].
QwtRoundScaleDraw::QwtRoundScaleDraw | ( | const QwtRoundScaleDraw & | other | ) |
Copy constructor.
QwtRoundScaleDraw::~QwtRoundScaleDraw | ( | ) | [virtual] |
Destructor.
QPoint QwtRoundScaleDraw::center | ( | ) | const |
Get the center of the scale.
void QwtAbstractScaleDraw::draw | ( | QPainter * | painter, |
const QPalette & | palette | ||
) | const [virtual, inherited] |
Draw the scale.
painter | The painter |
palette | Palette, text color is used for the labels, foreground color for ticks and backbone |
void QwtRoundScaleDraw::drawBackbone | ( | QPainter * | painter | ) | const [protected, virtual] |
Draws the baseline of the scale
painter | Painter |
Implements QwtAbstractScaleDraw.
void QwtRoundScaleDraw::drawLabel | ( | QPainter * | painter, |
double | value | ||
) | const [protected, virtual] |
Draws the label for a major scale tick
painter | Painter |
value | Value |
Implements QwtAbstractScaleDraw.
void QwtRoundScaleDraw::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 |
Implements QwtAbstractScaleDraw.
void QwtAbstractScaleDraw::enableComponent | ( | ScaleComponent | component, |
bool | enable = true |
||
) | [inherited] |
En/Disable a component of the scale
component | Scale component |
enable | On/Off |
int QwtRoundScaleDraw::extent | ( | const QPen & | pen, |
const QFont & | font | ||
) | const [virtual] |
Calculate the extent of the scale
The extent is the distcance between the baseline to the outermost pixel of the scale draw. radius() + extent() is an upper limit for the radius of the bounding circle.
pen | Pen that is used for painting backbone and ticks |
font | Font used for painting the labels |
Implements QwtAbstractScaleDraw.
bool QwtAbstractScaleDraw::hasComponent | ( | ScaleComponent | component | ) | const [inherited] |
Check if a component is enabled
void QwtAbstractScaleDraw::invalidateCache | ( | ) | [protected, inherited] |
Invalidate the cache used by QwtAbstractScaleDraw::tickLabel
The cache is invalidated, when a new QwtScaleDiv is set. If the labels need to be changed. while the same QwtScaleDiv is set, QwtAbstractScaleDraw::invalidateCache needs to be called manually.
QwtText QwtAbstractScaleDraw::label | ( | double | value | ) | const [virtual, inherited] |
Convert a value into its representing label.
The value is converted to a plain text using QLocale::system().toString(value). This method is often overloaded by applications to have individual labels.
value | Value |
Reimplemented in QwtDialScaleDraw.
int QwtAbstractScaleDraw::majTickLength | ( | ) | const [inherited] |
The same as QwtAbstractScaleDraw::tickLength(QwtScaleDiv::MajorTick).
const QwtScaleMap & QwtAbstractScaleDraw::map | ( | ) | const [inherited] |
int QwtAbstractScaleDraw::minimumExtent | ( | ) | const [inherited] |
Get the minimum extent
void QwtRoundScaleDraw::moveCenter | ( | const QPoint & | center | ) |
Move the center of the scale draw, leaving the radius unchanged
center | New center |
void QwtRoundScaleDraw::moveCenter | ( | int | x, |
int | y | ||
) | [inline] |
Move the center of the scale draw, leaving the radius unchanged.
QwtRoundScaleDraw & QwtRoundScaleDraw::operator= | ( | const QwtRoundScaleDraw & | other | ) |
Assignment operator.
int QwtRoundScaleDraw::radius | ( | ) | const |
Get the radius
Radius is the radius of the backbone without ticks and labels.
const QwtScaleDiv & QwtAbstractScaleDraw::scaleDiv | ( | ) | const [inherited] |
QwtScaleMap & QwtAbstractScaleDraw::scaleMap | ( | ) | [inherited] |
void QwtRoundScaleDraw::setAngleRange | ( | double | angle1, |
double | angle2 | ||
) |
Adjust the baseline circle segment for round scales.
The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2). 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.
angle1 | |
angle2 | boundaries of the angle interval in degrees. |
void QwtAbstractScaleDraw::setMinimumExtent | ( | int | minExtent | ) | [inherited] |
Set a minimum for the extent.
The extent is calculated from the coomponents of the scale draw. In situations, where the labels are changing and the layout depends on the extent (f.e scrolling a scale), setting an upper limit as minimum extent will avoid jumps of the layout.
minExtent | Minimum extent |
void QwtRoundScaleDraw::setRadius | ( | int | radius | ) |
Change of radius the scale
Radius is the radius of the backbone without ticks and labels.
radius | New Radius |
void QwtAbstractScaleDraw::setScaleDiv | ( | const QwtScaleDiv & | sd | ) | [inherited] |
Change the scale division
sd | New scale division |
void QwtAbstractScaleDraw::setSpacing | ( | int | spacing | ) | [inherited] |
Set the spacing between tick and labels.
The spacing is the distance between ticks and labels. The default spacing is 4 pixels.
spacing | Spacing |
void QwtAbstractScaleDraw::setTickLength | ( | QwtScaleDiv::TickType | tickType, |
int | length | ||
) | [inherited] |
Set the length of the ticks
tickType | Tick type |
length | New length |
void QwtAbstractScaleDraw::setTransformation | ( | QwtScaleTransformation * | transformation | ) | [inherited] |
Change the transformation of the scale
transformation | New scale transformation |
int QwtAbstractScaleDraw::spacing | ( | ) | const [inherited] |
Get the spacing.
The spacing is the distance between ticks and labels. The default spacing is 4 pixels.
const QwtText & QwtAbstractScaleDraw::tickLabel | ( | const QFont & | font, |
double | value | ||
) | const [protected, inherited] |
Convert a value into its representing label and cache it.
The conversion between value and label is called very often in the layout and painting code. Unfortunately the calculation of the label sizes might be slow (really slow for rich text in Qt4), so it's necessary to cache the labels.
font | Font |
value | Value |
int QwtAbstractScaleDraw::tickLength | ( | QwtScaleDiv::TickType | tickType | ) | const [inherited] |
Return the length of the ticks