Scroll to navigation

QwtAbstractScaleDraw(3) Qwt User's Guide QwtAbstractScaleDraw(3)

NAME

QwtAbstractScaleDraw -
A abstract base class for drawing scales.
 

SYNOPSIS

#include <qwt_abstract_scale_draw.h>
Inherited by QwtRoundScaleDraw, and QwtScaleDraw.

Public Types


enum ScaleComponent { Backbone = 0x01, Ticks = 0x02, Labels = 0x04 }
 
typedef QFlags< ScaleComponent > ScaleComponents
 

Public Member Functions


QwtAbstractScaleDraw ()
 
virtual ~QwtAbstractScaleDraw ()
 
void setScaleDiv (const QwtScaleDiv &s)
 
const QwtScaleDiv & scaleDiv () const
 
void setTransformation (QwtScaleTransformation *)
 
const QwtScaleMap & scaleMap () const
 
QwtScaleMap & scaleMap ()
 
void enableComponent (ScaleComponent, bool enable=true)
 
bool hasComponent (ScaleComponent) const
 
void setTickLength (QwtScaleDiv::TickType, double length)
 
double tickLength (QwtScaleDiv::TickType) const
 
double maxTickLength () const
 
void setSpacing (double margin)
 
double spacing () const
 
void setPenWidth (int width)
 
int penWidth () const
 
virtual void draw (QPainter *, const QPalette &) const
 
virtual QwtText label (double) const
 
virtual double extent (const QFont &) const =0
 
void setMinimumExtent (double)
 
double minimumExtent () const
 

Protected Member Functions


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
 
void invalidateCache ()
 
const QwtText & tickLabel (const QFont &, double value) const
 

Detailed Description

A 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 QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s), the scale can be drawn with the QwtAbstractScaleDraw::draw() member.

Member Typedef Documentation

typedef QFlags<ScaleComponent> QwtAbstractScaleDraw::ScaleComponents

Scale components.

Member Enumeration Documentation

enum QwtAbstractScaleDraw::ScaleComponent Components of a scale

See also:
enableComponent(), hasComponent
 
Enumerator:
Backbone
Backbone = the line where the ticks are located.
Ticks
Ticks.
Labels
Labels.

Constructor & Destructor Documentation

QwtAbstractScaleDraw::QwtAbstractScaleDraw ()

Constructor. 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

QwtAbstractScaleDraw::~QwtAbstractScaleDraw () [virtual]

Destructor.

Member Function Documentation

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
 

virtual void QwtAbstractScaleDraw::drawBackbone (QPainter *painter) const [protected, pure virtual] Draws the baseline of the scale

Parameters:
painter Painter
See also:
drawTick(), drawLabel()
 
Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

virtual void QwtAbstractScaleDraw::drawLabel (QPainter *painter, doublevalue) const [protected, pure virtual] Draws the label for a major scale tick

Parameters:
painter Painter
 
value Value
See also:
drawTick(), drawBackbone()
 
Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

virtual void QwtAbstractScaleDraw::drawTick (QPainter *painter, doublevalue, doublelen) const [protected, pure virtual] Draw a tick

Parameters:
painter Painter
 
value Value of the tick
 
len Lenght of the tick
See also:
drawBackbone(), drawLabel()
 
Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

void QwtAbstractScaleDraw::enableComponent (ScaleComponentcomponent, boolenable = true) En/Disable a component of the scale

Parameters:
component Scale component
 
enable On/Off
See also:
hasComponent()
 

virtual double QwtAbstractScaleDraw::extent (const QFont &) const [pure virtual] Calculate the extent

The extent is the distcance from the baseline to the outermost pixel of the scale draw in opposite to its orientation. It is at least minimumExtent() pixels.
See also:
setMinimumExtent(), minimumExtent()
 
Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

bool QwtAbstractScaleDraw::hasComponent (ScaleComponentcomponent) const Check if a component is enabled

See also:
enableComponent()
 

void QwtAbstractScaleDraw::invalidateCache () [protected] 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, invalidateCache() needs to be called manually.

QwtText QwtAbstractScaleDraw::label (doublevalue) const [virtual]

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.
Parameters:
value Value
Returns:
Label string.
 
Reimplemented in QwtDialScaleDraw.

double QwtAbstractScaleDraw::maxTickLength () const Returns:

Length of the longest tick
Useful for layout calculations
See also:
tickLength(), setTickLength()
 

double QwtAbstractScaleDraw::minimumExtent () const Get the minimum extent

See also:
extent(), setMinimumExtent()
 

int QwtAbstractScaleDraw::penWidth () const Returns:

Scale pen width
See also:
setPenWidth()
 
Reimplemented in QwtDialScaleDraw.

const QwtScaleDiv & QwtAbstractScaleDraw::scaleDiv () const Returns:

scale division
 

const QwtScaleMap & QwtAbstractScaleDraw::scaleMap () const Returns:

Map how to translate between scale and pixel values
 

QwtScaleMap & QwtAbstractScaleDraw::scaleMap () Returns:

Map how to translate between scale and pixel values
 

void QwtAbstractScaleDraw::setMinimumExtent (doubleminExtent)

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.
Parameters:
minExtent Minimum extent
See also:
extent(), minimumExtent()
 

void QwtAbstractScaleDraw::setPenWidth (intwidth)

Specify the width of the scale pen. Parameters:
width Pen width
See also:
penWidth()
 

void QwtAbstractScaleDraw::setScaleDiv (const QwtScaleDiv &sd) Change the scale division

Parameters:
sd New scale division
 

void QwtAbstractScaleDraw::setSpacing (doublespacing)

Set the spacing between tick and labels. The spacing is the distance between ticks and labels. The default spacing is 4 pixels.
Parameters:
spacing Spacing
See also:
spacing()
 

void QwtAbstractScaleDraw::setTickLength (QwtScaleDiv::TickTypetickType, doublelength) Set the length of the ticks

Parameters:
tickType Tick type
 
length New length
Warning:
the length is limited to [0..1000]
 

void QwtAbstractScaleDraw::setTransformation (QwtScaleTransformation *transformation) Change the transformation of the scale

Parameters:
transformation New scale transformation
 

double QwtAbstractScaleDraw::spacing () const

Get the spacing. The spacing is the distance between ticks and labels. The default spacing is 4 pixels.
See also:
setSpacing()
 

const QwtText & QwtAbstractScaleDraw::tickLabel (const QFont &font, doublevalue) 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:
font Font
 
value Value
Returns:
Tick label
 

double QwtAbstractScaleDraw::tickLength (QwtScaleDiv::TickTypetickType) const Return the length of the ticks

See also:
setTickLength(), maxTickLength()
 
 

Author

Generated automatically by Doxygen for Qwt User's Guide from the source code.
Fri Apr 15 2011 Version 6.0.0