QWT 7.0.1
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtAbstractScaleDraw Class Referenceabstract

A abstract base class for drawing scales. More...

#include <qwt_abstract_scale_draw.h>

Inheritance diagram for QwtAbstractScaleDraw:
QwtRoundScaleDraw QwtScaleDraw QWT_FINAL QwtCompassScaleDraw QwtDateScaleDraw

Classes

class  PrivateData
 

Public Types

enum  ScaleComponent { Backbone = 0x01 , Ticks = 0x02 , Labels = 0x04 }
 Components of a scale. More...
 

Public Member Functions

 QwtAbstractScaleDraw ()
 Constructor.
 
virtual ~QwtAbstractScaleDraw ()
 Destructor.
 
void setScaleDiv (const QwtScaleDiv &)
 Change the scale division.
 
const QwtScaleDivscaleDiv () const
 
void setTransformation (QwtTransform *)
 Change the transformation of the scale.
 
const QwtScaleMapscaleMap () const
 
QwtScaleMapscaleMap ()
 
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.
 
virtual double extent (const QFont &font) const =0
 Calculate the extent.
 
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

virtual void drawTick (QPainter *painter, double value, double len) const =0
 Draw a tick.
 
virtual void drawBackbone (QPainter *painter) const =0
 Draws the baseline of the scale.
 
virtual void drawLabel (QPainter *painter, double value) const =0
 Draws the label for a major scale tick.
 
const QwtTexttickLabel (const QFont &, double value) const
 Convert a value into its representing label and cache it.
 

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 setScaleDiv(), the scale can be drawn with the draw() member.

Member Enumeration Documentation

◆ 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::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

Member Function Documentation

◆ draw()

void QwtAbstractScaleDraw::draw ( QPainter *  painter,
const QPalette &  palette 
) const
virtual

Draw the scale.

Parameters
painterThe painter
palettePalette, text color is used for the labels, foreground color for ticks and backbone

◆ drawBackbone()

virtual void QwtAbstractScaleDraw::drawBackbone ( QPainter *  painter) const
protectedpure virtual

Draws the baseline of the scale.

Parameters
painterPainter
See also
drawTick(), drawLabel()

Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

◆ drawLabel()

virtual void QwtAbstractScaleDraw::drawLabel ( QPainter *  painter,
double  value 
) const
protectedpure virtual

Draws the label for a major scale tick.

Parameters
painterPainter
valueValue
See also
drawTick(), drawBackbone()

Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

◆ drawTick()

virtual void QwtAbstractScaleDraw::drawTick ( QPainter *  painter,
double  value,
double  len 
) const
protectedpure virtual

Draw a tick.

Parameters
painterPainter
valueValue of the tick
lenLength of the tick
See also
drawBackbone(), drawLabel()

Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

◆ enableComponent()

void QwtAbstractScaleDraw::enableComponent ( ScaleComponent  component,
bool  enable = true 
)

En/Disable a component of the scale.

Parameters
componentScale component
enableOn/Off
See also
hasComponent()

◆ extent()

virtual double QwtAbstractScaleDraw::extent ( const QFont &  font) const
pure virtual

Calculate the extent.

The extent is the distance from the baseline to the outermost pixel of the scale draw in opposite to its orientation. It is at least minimumExtent() pixels.

Parameters
fontFont used for drawing the tick labels
Returns
Number of pixels
See also
setMinimumExtent(), minimumExtent()

Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

◆ hasComponent()

bool QwtAbstractScaleDraw::hasComponent ( ScaleComponent  component) const

Check if a component is enabled.

Parameters
componentComponent type
Returns
true, when component is enabled
See also
enableComponent()

◆ invalidateCache()

void QwtAbstractScaleDraw::invalidateCache ( )

Invalidate the cache used by 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.

◆ isSelected()

bool QwtAbstractScaleDraw::isSelected ( ) const

是否选中

Returns

◆ 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
valueValue
Returns
Label string.

Reimplemented in QwtCompassScaleDraw, and QwtDateScaleDraw.

◆ maxTickLength()

double QwtAbstractScaleDraw::maxTickLength ( ) const
Returns
Length of the longest tick

Useful for layout calculations

See also
tickLength(), setTickLength()

◆ minimumExtent()

double QwtAbstractScaleDraw::minimumExtent ( ) const

Get the minimum extent.

Returns
Minimum extent
See also
extent(), setMinimumExtent()

◆ penWidthF()

qreal QwtAbstractScaleDraw::penWidthF ( ) const
Returns
Scale pen width
See also
setPenWidth()

◆ scaleDiv()

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

◆ scaleMap() [1/2]

QwtScaleMap & QwtAbstractScaleDraw::scaleMap ( )
Returns
Map how to translate between scale and pixel values

◆ scaleMap() [2/2]

const QwtScaleMap & QwtAbstractScaleDraw::scaleMap ( ) const
Returns
Map how to translate between scale and pixel values

◆ selectedPenWidthOffset()

qreal QwtAbstractScaleDraw::selectedPenWidthOffset ( ) const

获取当前坐标轴在选中状态下的画笔宽度附加值

Returns
当前的宽度附加值。
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 (f.e scrolling a scale), setting an upper limit as minimum extent will avoid jumps of the layout.

Parameters
minExtentMinimum extent
See also
extent(), minimumExtent()

◆ setPenWidthF()

void QwtAbstractScaleDraw::setPenWidthF ( qreal  width)

Specify the width of the scale pen.

Parameters
widthPen width
See also
penWidth()

◆ setScaleDiv()

void QwtAbstractScaleDraw::setScaleDiv ( const QwtScaleDiv scaleDiv)

Change the scale division.

Parameters
scaleDivNew scale division

◆ setSelected()

void QwtAbstractScaleDraw::setSelected ( bool  on)

设置是否选中

Parameters
on

◆ setSelectedPenWidthOffset()

void QwtAbstractScaleDraw::setSelectedPenWidthOffset ( qreal  offset = 1)

设置坐标轴在选中状态下的画笔宽度附加值

当一个坐标轴(例如 X 轴或 Y 轴)被用户选中时,其绘制的画笔宽度会 在原始宽度的基础上增加这个附加值,从而实现视觉上的突出显示效果。

Parameters
offset选中时增加的宽度值(单位:像素)。 该值应为非负数。如果为 0,则选中状态下的线宽与普通状态相同。
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
spacingSpacing
See also
spacing()

◆ setTickLength()

void QwtAbstractScaleDraw::setTickLength ( QwtScaleDiv::TickType  tickType,
double  length 
)

Set the length of the ticks.

Parameters
tickTypeTick type
lengthNew length
Warning
the length is limited to [0..1000]

◆ setTransformation()

void QwtAbstractScaleDraw::setTransformation ( QwtTransform transformation)

Change the transformation of the scale.

Parameters
transformationNew scale transformation

◆ 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
fontFont
valueValue
Returns
Tick label

◆ tickLength()

double QwtAbstractScaleDraw::tickLength ( QwtScaleDiv::TickType  tickType) const
Returns
Length of the ticks
See also
setTickLength(), maxTickLength()

The documentation for this class was generated from the following files: