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

A class for drawing scales 更多...

#include <qwt_scale_draw.h>

类 QwtScaleDraw 继承关系图:
QwtAbstractScaleDraw QwtDateScaleDraw

class  PrivateData
 

Public 类型

enum  Alignment { BottomScale , TopScale , LeftScale , RightScale }
 Alignment of the scale draw 更多...
 
- Public 类型 继承自 QwtAbstractScaleDraw
enum  ScaleComponent { Backbone = 0x01 , Ticks = 0x02 , Labels = 0x04 }
 Components of a scale 更多...
 

Public 成员函数

 QwtScaleDraw ()
 Constructor
 
void getBorderDistHint (const QFont &, int &start, int &end) const
 Get the border distance hint
 
int minLabelDist (const QFont &) const
 Get the minimum label distance
 
int minLength (const QFont &) const
 Get the minimum length
 
virtual double extent (const QFont &) const override
 Calculate the width/height that is needed for a vertical/horizontal scale
 
void move (double x, double y)
 Move the position of the scale
 
void move (const QPointF &)
 Move the position of the scale
 
void setLength (double length)
 Set the length of the backbone
 
Alignment alignment () const
 Return alignment of the scale
 
void setAlignment (Alignment)
 Set the alignment
 
Qt::Orientation orientation () const
 Return the orientation
 
QPointF pos () const
 Get origin of the scale
 
double length () const
 Get the length of the backbone
 
void setLabelAlignment (Qt::Alignment)
 Set the label alignment
 
Qt::Alignment labelAlignment () const
 Get the label flags
 
void setLabelRotation (double rotation)
 Set the label rotation
 
double labelRotation () const
 Get the label rotation
 
int maxLabelHeight (const QFont &) const
 Get the maximum label height
 
int maxLabelWidth (const QFont &) const
 Get the maximum label width
 
QPointF labelPosition (double value) const
 Get the label position for a value
 
QRectF labelRect (const QFont &, double value) const
 Get the label rectangle for a value
 
QSizeF labelSize (const QFont &, double value) const
 Get the label size for a value
 
QRect boundingLabelRect (const QFont &, double value) const
 Get the bounding label rectangle
 
- Public 成员函数 继承自 QwtAbstractScaleDraw
 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
 
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 成员函数

QTransform labelTransformation (const QPointF &, const QSizeF &) const
 Calculate the transformation that is needed to paint a label
 
virtual void drawTick (QPainter *, double value, double len) const override
 Draw a tick
 
virtual void drawBackbone (QPainter *) const override
 Draws the baseline of the scale
 
virtual void drawLabel (QPainter *, double value) const override
 Draws the label for a major scale tick
 
- Protected 成员函数 继承自 QwtAbstractScaleDraw
const QwtTexttickLabel (const QFont &, double value) const
 Convert a value into its representing label and cache it
 

详细描述

A class for drawing scales

QwtScaleDraw can be used to draw linear or logarithmic scales. A scale has a position, an alignment and a length, which can be specified. The labels can be rotated and aligned to the ticks using setLabelRotation() and setLabelAlignment().

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.

成员枚举类型说明

◆ Alignment

Alignment of the scale draw

参见
setAlignment(), alignment()
枚举值
BottomScale 

The scale is below

TopScale 

The scale is above

LeftScale 

The scale is left

RightScale 

The scale is right

构造及析构函数说明

◆ QwtScaleDraw()

QwtScaleDraw::QwtScaleDraw ( )

Constructor

The range of the scale is initialized to [0, 100], the position is at (0, 0) with a length of 100. The orientation is QwtAbstractScaleDraw::Bottom.

成员函数说明

◆ alignment()

QwtScaleDraw::Alignment QwtScaleDraw::alignment ( ) const

Return alignment of the scale

返回
the alignment
Alignment of the scale
参见
setAlignment()

◆ boundingLabelRect()

QRect QwtScaleDraw::boundingLabelRect ( const QFont &  font,
double  value 
) const

Get the bounding label rectangle

Find the bounding rectangle for the label

The coordinates of the rectangle are absolute ( calculated from pos() ) in direction of the tick.

参数
fontFont used for painting
valueValue
返回
Bounding rectangle
参见
labelRect()

◆ drawBackbone()

void QwtScaleDraw::drawBackbone ( QPainter *  painter) const
overrideprotectedvirtual

Draws the baseline of the scale

参数
painterPainter
参见
drawTick(), drawLabel()

实现了 QwtAbstractScaleDraw.

◆ drawLabel()

void QwtScaleDraw::drawLabel ( QPainter *  painter,
double  value 
) const
overrideprotectedvirtual

Draws the label for a major scale tick

参数
painterPainter
valueValue
参见
drawTick(), drawBackbone(), boundingLabelRect()

实现了 QwtAbstractScaleDraw.

◆ drawTick()

void QwtScaleDraw::drawTick ( QPainter *  painter,
double  value,
double  len 
) const
overrideprotectedvirtual

Draw a tick

参数
painterPainter
valueValue of the tick
lenLength of the tick
参见
drawBackbone(), drawLabel()

实现了 QwtAbstractScaleDraw.

◆ extent()

double QwtScaleDraw::extent ( const QFont &  font) const
overridevirtual

Calculate the width/height that is needed for a vertical/horizontal scale

The extent is calculated from the pen width of the backbone, the major tick length, the spacing and the maximum width/height of the labels.

参数
fontFont used for painting the labels
返回
Extent
参见
minLength()

实现了 QwtAbstractScaleDraw.

◆ getBorderDistHint()

void QwtScaleDraw::getBorderDistHint ( const QFont &  font,
int &  start,
int &  end 
) const

Get the border distance hint

Determine the minimum border distance

This member function returns the minimum space needed to draw the mark labels at the scale's endpoints.

参数
fontFont
startStart border distance
endEnd border distance

◆ labelAlignment()

Qt::Alignment QwtScaleDraw::labelAlignment ( ) const

Get the label flags

返回
the label alignment
the label flags
参见
setLabelAlignment(), labelRotation()

◆ labelPosition()

QPointF QwtScaleDraw::labelPosition ( double  value) const

Get the label position for a value

Find the position, where to paint a label

The position has a distance that depends on the length of the ticks in direction of the alignment().

参数
valueValue
返回
Position, where to paint a label

◆ labelRect()

QRectF QwtScaleDraw::labelRect ( const QFont &  font,
double  value 
) const

Get the label rectangle for a value

Find the bounding rectangle for the label

The coordinates of the rectangle are relative to spacing + tick length from the backbone in direction of the tick.

参数
fontFont used for painting
valueValue
返回
Bounding rectangle that is needed to draw a label

◆ labelRotation()

double QwtScaleDraw::labelRotation ( ) const

Get the label rotation

返回
the label rotation
the label rotation
参见
setLabelRotation(), labelAlignment()

◆ labelSize()

QSizeF QwtScaleDraw::labelSize ( const QFont &  font,
double  value 
) const

Get the label size for a value

Calculate the size that is needed to draw a label

参数
fontLabel font
valueValue
返回
Size that is needed to draw a label

◆ labelTransformation()

QTransform QwtScaleDraw::labelTransformation ( const QPointF &  pos,
const QSizeF &  size 
) const
protected

Calculate the transformation that is needed to paint a label

Calculate the transformation that is needed to paint a label depending on its alignment and rotation.

参数
posPosition where to paint the label
sizeSize of the label
返回
Transformation matrix
参见
setLabelAlignment(), setLabelRotation()

◆ length()

double QwtScaleDraw::length ( ) const

Get the length of the backbone

返回
the length
the length of the backbone
参见
setLength(), pos()

◆ maxLabelHeight()

int QwtScaleDraw::maxLabelHeight ( const QFont &  font) const

Get the maximum label height

Get the maximum height of a label

参数
fontFont
返回
the maximum height of a label

◆ maxLabelWidth()

int QwtScaleDraw::maxLabelWidth ( const QFont &  font) const

Get the maximum label width

Get the maximum width of a label

参数
fontFont
返回
the maximum width of a label

◆ minLabelDist()

int QwtScaleDraw::minLabelDist ( const QFont &  font) const

Get the minimum label distance

Determine the minimum distance between two labels

Determine the minimum distance between two labels, that is necessary that the texts don't overlap.

参数
fontFont
返回
The maximum width of a label
参见
getBorderDistHint()

◆ minLength()

int QwtScaleDraw::minLength ( const QFont &  font) const

Get the minimum length

Calculate the minimum length that is needed to draw the scale

参数
fontFont used for painting the labels
返回
Minimum length that is needed to draw the scale
参见
extent()

◆ move() [1/2]

void QwtScaleDraw::move ( const QPointF &  pos)

Move the position of the scale

The meaning of the parameter pos depends on the alignment:

  • QwtScaleDraw::LeftScale: The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the left of the backbone.
  • QwtScaleDraw::RightScale: The origin is the topmost point of the backbone. The backbone is a vertical line. Scale marks and labels are drawn at the right of the backbone.
  • QwtScaleDraw::TopScale: The origin is the leftmost point of the backbone. The backbone is a horizontal line. Scale marks and labels are drawn above the backbone.
  • QwtScaleDraw::BottomScale: The origin is the leftmost point of the backbone. The backbone is a horizontal line. Scale marks and labels are drawn below the backbone.
参数
posOrigin of the scale
参见
pos(), setLength()

◆ move() [2/2]

void QwtScaleDraw::move ( double  x,
double  y 
)
inline

Move the position of the scale

参数
xX coordinate
yY coordinate
参见
move(const QPointF&)

◆ orientation()

Qt::Orientation QwtScaleDraw::orientation ( ) const

Return the orientation

返回
the orientation

TopScale, BottomScale are horizontal (Qt::Horizontal) scales, LeftScale, RightScale are vertical (Qt::Vertical) scales.

返回
Orientation of the scale
参见
alignment()

◆ pos()

QPointF QwtScaleDraw::pos ( ) const

Get origin of the scale

返回
the position
Origin of the scale
参见
move(), length()

◆ setAlignment()

void QwtScaleDraw::setAlignment ( Alignment  align)

Set the alignment

Set the alignment of the scale

参数
alignAlignment of the scale

The default alignment is QwtScaleDraw::BottomScale

参见
alignment()

◆ setLabelAlignment()

void QwtScaleDraw::setLabelAlignment ( Qt::Alignment  alignment)

Set the label alignment

Change the label flags

Labels are aligned to the point tick length + spacing away from the backbone.

The alignment is relative to the orientation of the label text. In case of an flags of 0 the label will be aligned depending on the orientation of the scale:

Changing the alignment is often necessary for rotated labels.

参数
alignmentOr'd Qt::AlignmentFlags see <qnamespace.h>
参见
setLabelRotation(), labelRotation(), labelAlignment()
警告
The various alignments might be confusing. The alignment of the label is not the alignment of the scale and is not the alignment of the flags ( QwtText::flags() ) returned from QwtAbstractScaleDraw::label().

◆ setLabelRotation()

void QwtScaleDraw::setLabelRotation ( double  rotation)

Set the label rotation

Rotate all labels

When changing the rotation, it might be necessary to adjust the label flags too. Finding a useful combination is often the result of try and error.

参数
rotationAngle in degrees. When changing the label rotation, the label flags often needs to be adjusted too.
参见
setLabelAlignment(), labelRotation(), labelAlignment()

◆ setLength()

void QwtScaleDraw::setLength ( double  length)

Set the length of the backbone

The length doesn't include the space needed for overlapping labels.

参数
lengthLength of the backbone
参见
move(), minLabelDist()

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