An abstract base class for drawing scales.
More...
#include <qwt_abstract_scale_draw.h>
|
| virtual void | drawTick (QPainter *painter, double value, double len) const =0 |
| |
| virtual void | drawBackbone (QPainter *painter) const =0 |
| |
| virtual void | drawLabel (QPainter *painter, double value) const =0 |
| |
| const QwtText & | tickLabel (const QFont &, double value) const |
| | Convert a value into its representing label and cache it.
|
| |
An abstract base class for drawing scales.
QwtAbstractScaleDraw can be used to draw linear or logarithmic scales. After a scale division has been specified as a QwtScaleDiv object using setScaleDiv(), the scale can be drawn with the draw() member.
◆ ScaleComponent
Components of a scale.
- See also
- enableComponent(), hasComponent
| Enumerator |
|---|
| Backbone | Backbone = the line where the ticks are located.
|
| Ticks | Ticks.
|
| Labels | Labels.
|
◆ QwtAbstractScaleDraw()
| QwtAbstractScaleDraw::QwtAbstractScaleDraw |
( |
| ) |
|
Constructor for QwtAbstractScaleDraw.
The range of the scale is initialized to [0, 100], the spacing (distance between ticks and labels) is set to 4, the tick lengths are set to 4, 6 and 8 pixels.
Destructor for QwtAbstractScaleDraw
◆ draw()
| void QwtAbstractScaleDraw::draw |
( |
QPainter * |
painter, |
|
|
const QPalette & |
palette |
|
) |
| const |
|
virtual |
Draw the scale.
- Parameters
-
| painter | The painter |
| palette | Palette, text color is used for the labels, foreground color for ticks and backbone |
◆ drawBackbone()
| virtual void QwtAbstractScaleDraw::drawBackbone |
( |
QPainter * |
painter | ) |
const |
|
protectedpure virtual |
◆ drawLabel()
| virtual void QwtAbstractScaleDraw::drawLabel |
( |
QPainter * |
painter, |
|
|
double |
value |
|
) |
| const |
|
protectedpure virtual |
◆ drawTick()
| virtual void QwtAbstractScaleDraw::drawTick |
( |
QPainter * |
painter, |
|
|
double |
value, |
|
|
double |
len |
|
) |
| const |
|
protectedpure virtual |
◆ enableComponent()
| void QwtAbstractScaleDraw::enableComponent |
( |
ScaleComponent |
component, |
|
|
bool |
enable = true |
|
) |
| |
Enable or disable a scale component.
- Parameters
-
| component | Scale component (Backbone, Ticks, or Labels) |
| enable | True to enable, false to disable |
- See also
- hasComponent()
◆ extent()
| virtual double QwtAbstractScaleDraw::extent |
( |
const QFont & |
font | ) |
const |
|
pure virtual |
◆ hasComponent()
| bool QwtAbstractScaleDraw::hasComponent |
( |
ScaleComponent |
component | ) |
const |
Check if a component is enabled.
- Parameters
-
- Returns
- True if component is enabled
- See also
- enableComponent()
◆ invalidateCache()
| void QwtAbstractScaleDraw::invalidateCache |
( |
| ) |
|
◆ isSelected()
| bool QwtAbstractScaleDraw::isSelected |
( |
| ) |
const |
Check if the scale draw is selected.
- Returns
- True if selected, false otherwise
◆ label()
| QwtText QwtAbstractScaleDraw::label |
( |
double |
value | ) |
const |
|
virtual |
Convert a value into its representing label.
The value is converted to a plain text using QLocale().toString(value). This method is often overloaded by applications to have individual labels.
- Parameters
-
- Returns
- Label string
Reimplemented in QwtCompassScaleDraw, and QwtDateScaleDraw.
◆ maxTickLength()
| double QwtAbstractScaleDraw::maxTickLength |
( |
| ) |
const |
Get the length of the longest tick.
- Returns
- Length of the longest tick
Useful for layout calculations
- See also
- tickLength(), setTickLength()
◆ minimumExtent()
| double QwtAbstractScaleDraw::minimumExtent |
( |
| ) |
const |
◆ penWidthF()
| qreal QwtAbstractScaleDraw::penWidthF |
( |
| ) |
const |
Get the scale pen width.
- Returns
- Scale pen width
- See also
- setPenWidth()
◆ scaleDiv()
| const QwtScaleDiv & QwtAbstractScaleDraw::scaleDiv |
( |
| ) |
const |
Return the scale division.
- Returns
- Current scale division object
◆ scaleMap() [1/2]
Return the scale map (non-const version)
- Returns
- Map for translating between scale and pixel values
◆ scaleMap() [2/2]
| const QwtScaleMap & QwtAbstractScaleDraw::scaleMap |
( |
| ) |
const |
Return the scale map (const version)
- Returns
- Map for translating between scale and pixel values
◆ selectedPenWidthOffset()
| qreal QwtAbstractScaleDraw::selectedPenWidthOffset |
( |
| ) |
const |
Get the current pen width offset for the axis when it is in selected state.
- Returns
- The current width offset value
- See also
- setSelectedPenWidthOffset()
◆ setMinimumExtent()
| void QwtAbstractScaleDraw::setMinimumExtent |
( |
double |
minExtent | ) |
|
Set a minimum for the extent.
The extent is calculated from the components of the scale draw. In situations where the labels are changing and the layout depends on the extent (e.g., scrolling a scale), setting an upper limit as minimum extent will avoid jumps of the layout.
- Parameters
-
- See also
- extent(), minimumExtent()
◆ setPenWidthF()
| void QwtAbstractScaleDraw::setPenWidthF |
( |
qreal |
width | ) |
|
Specify the width of the scale pen.
- Parameters
-
- See also
- penWidth()
◆ setScaleDiv()
| void QwtAbstractScaleDraw::setScaleDiv |
( |
const QwtScaleDiv & |
scaleDiv | ) |
|
Set the scale division.
- Parameters
-
| scaleDiv | New scale division object |
This also updates the scale map and clears the label cache.
◆ setSelected()
| void QwtAbstractScaleDraw::setSelected |
( |
bool |
on | ) |
|
Set whether the scale draw is selected.
- Parameters
-
| on | True to select, false to deselect |
◆ setSelectedPenWidthOffset()
| void QwtAbstractScaleDraw::setSelectedPenWidthOffset |
( |
qreal |
offset = 1 | ) |
|
Set the pen width offset for the axis when it is in selected state.
When an axis (e.g., X-axis or Y-axis) is selected by the user, the pen width used for drawing will be increased by this offset value, achieving a visual highlighting effect.
- Parameters
-
| offset | The additional width value to be added when selected (unit: pixels). This value should be non-negative. If it is 0, the line width in selected state will be the same as in normal state. |
- See also
- selectedPenWidthOffset()
◆ setSpacing()
| void QwtAbstractScaleDraw::setSpacing |
( |
double |
spacing | ) |
|
Set the spacing between tick and labels.
The spacing is the distance between ticks and labels. The default spacing is 4 pixels.
- Parameters
-
- See also
- spacing()
◆ setTickLength()
Set the length of the ticks.
- Parameters
-
| tickType | Tick type |
| length | New length |
- Warning
- The length is limited to [0..1000]
◆ setTransformation()
| void QwtAbstractScaleDraw::setTransformation |
( |
QwtTransform * |
transformation | ) |
|
Set the scale transformation.
- Parameters
-
| transformation | New scale transformation object |
◆ spacing()
| double QwtAbstractScaleDraw::spacing |
( |
| ) |
const |
Get the spacing.
The spacing is the distance between ticks and labels. The default spacing is 4 pixels.
- Returns
- Spacing
- See also
- setSpacing()
◆ tickLabel()
| const QwtText & QwtAbstractScaleDraw::tickLabel |
( |
const QFont & |
font, |
|
|
double |
value |
|
) |
| const |
|
protected |
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.
- Parameters
-
- Returns
- Tick label
◆ tickLength()
The documentation for this class was generated from the following files: