QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
| Public 类型 | Public 成员函数 | Protected 成员函数 | 所有成员列表
QwtAbstractScaleDraw类 参考abstract

An abstract base class for drawing scales 更多...

#include <qwt_abstract_scale_draw.h>

类 QwtAbstractScaleDraw 继承关系图:
QwtRoundScaleDraw QwtScaleDraw QwtCompassScaleDraw QwtDateScaleDraw

class  PrivateData
 

Public 类型

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

Public 成员函数

 QwtAbstractScaleDraw ()
 Constructor for QwtAbstractScaleDraw
 
void setScaleDiv (const QwtScaleDiv &)
 Set the scale division
 
const QwtScaleDivscaleDiv () const
 Return the scale division
 
void setTransformation (QwtTransform *)
 Set the scale transformation
 
const QwtScaleMapscaleMap () const
 Return the scale map (const version)
 
QwtScaleMapscaleMap ()
 Return the scale map (non-const version)
 
void enableComponent (ScaleComponent, bool enable=true)
 Enable or disable a scale component
 
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
 Get the length of the ticks
 
double maxTickLength () const
 Get the length of the longest tick
 
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
 Get the scale pen width
 
void setSelected (bool on)
 Set whether the scale draw is selected
 
bool isSelected () const
 Check if the scale draw is selected
 
void setSelectedPenWidthOffset (qreal offset=1)
 Set the pen width offset for the axis when it is in selected state
 
qreal selectedPenWidthOffset () const
 Get the current pen width offset for the axis when it is in selected state
 
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
 
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 成员函数

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 QwtTexttickLabel (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

参见
enableComponent(), hasComponent
枚举值
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

参数
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

QwtRoundScaleDraw , 以及 QwtScaleDraw 内被实现.

◆ drawLabel()

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

QwtRoundScaleDraw , 以及 QwtScaleDraw 内被实现.

◆ drawTick()

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

QwtRoundScaleDraw , 以及 QwtScaleDraw 内被实现.

◆ enableComponent()

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

Enable or disable a scale component

参数
componentScale component (Backbone, Ticks, or Labels)
enableTrue to enable, false to disable
参见
hasComponent()

◆ extent()

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

QwtRoundScaleDraw , 以及 QwtScaleDraw 内被实现.

◆ hasComponent()

bool QwtAbstractScaleDraw::hasComponent ( ScaleComponent  component) const

Check if a component is enabled

参数
componentComponent type
返回
True if component is enabled
参见
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

Check if the scale draw is selected

返回
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.

参数
valueValue
返回
Label string

QwtCompassScaleDraw , 以及 QwtDateScaleDraw 重载.

◆ maxTickLength()

double QwtAbstractScaleDraw::maxTickLength ( ) const

Get the length of the longest tick

返回
Length of the longest tick

Useful for layout calculations

参见
tickLength(), setTickLength()

◆ minimumExtent()

double QwtAbstractScaleDraw::minimumExtent ( ) const

Get the minimum extent

返回
Minimum extent
参见
extent(), setMinimumExtent()

◆ penWidthF()

qreal QwtAbstractScaleDraw::penWidthF ( ) const

Get the scale pen width

返回
Scale pen width
参见
setPenWidth()

◆ scaleDiv()

const QwtScaleDiv & QwtAbstractScaleDraw::scaleDiv ( ) const

Return the scale division

返回
Current scale division object

◆ scaleMap() [1/2]

QwtScaleMap & QwtAbstractScaleDraw::scaleMap ( )

Return the scale map (non-const version)

返回
Map for translating between scale and pixel values

◆ scaleMap() [2/2]

const QwtScaleMap & QwtAbstractScaleDraw::scaleMap ( ) const

Return the scale map (const version)

返回
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

返回
The current width offset value
参见
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.

参数
minExtentMinimum extent
参见
extent(), minimumExtent()

◆ setPenWidthF()

void QwtAbstractScaleDraw::setPenWidthF ( qreal  width)

Specify the width of the scale pen

参数
widthPen width
参见
penWidth()

◆ setScaleDiv()

void QwtAbstractScaleDraw::setScaleDiv ( const QwtScaleDiv scaleDiv)

Set the scale division

参数
scaleDivNew 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

参数
onTrue 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.

参数
offsetThe 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.
参见
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.

参数
spacingSpacing
参见
spacing()

◆ setTickLength()

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

Set the length of the ticks

参数
tickTypeTick type
lengthNew length
警告
The length is limited to [0..1000]

◆ setTransformation()

void QwtAbstractScaleDraw::setTransformation ( QwtTransform transformation)

Set the scale transformation

参数
transformationNew 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.

返回
Spacing
参见
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.

参数
fontFont
valueValue
返回
Tick label

◆ tickLength()

double QwtAbstractScaleDraw::tickLength ( QwtScaleDiv::TickType  tickType) const

Get the length of the ticks

返回
Length of the ticks
参见
setTickLength(), maxTickLength()

该类的文档由以下文件生成: