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

A scale draw that maps values to arbitrary text labels 更多...

#include <qwt_text_scale_draw.h>

类 QwtTextScaleDraw 继承关系图:
QwtScaleDraw QwtAbstractScaleDraw

class  PrivateData
 

Public 成员函数

 QwtTextScaleDraw ()
 Constructor
 
 QwtTextScaleDraw (const QMap< double, QString > &map)
 
void setLabelMap (const QMap< double, QString > &map)
 Set the map that maps values to labels
 
QMap< double, QString > labelMap () const
 Get the map that maps values to labels
 
virtual QwtText label (double value) const override
 Map a value to a corresponding label
 
- Public 成员函数 继承自 QwtScaleDraw
 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
 
void setMinimumExtent (double)
 Set a minimum for the extent
 
double minimumExtent () const
 Get the minimum extent
 
void invalidateCache ()
 Invalidate the cache used by tickLabel()
 

额外继承的成员函数

- Public 类型 继承自 QwtScaleDraw
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 更多...
 
- Protected 成员函数 继承自 QwtScaleDraw
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 scale draw that maps values to arbitrary text labels

QwtTextScaleDraw displays user-defined text labels at specific numeric tick positions. It keeps a map from double values to strings and returns the matching string for each major tick value, so a linear axis can show category text (e.g. "Mon", "Tue", "Wed") instead of numbers.

The numeric tick positions are controlled by the scale engine and the QwtScaleDiv like a plain QwtScaleDraw. Only the label text is replaced through the value-to-string map. Values that do not match any key produce an empty label.

Usually the scale draw is combined with an explicit QwtScaleDiv whose major ticks match the map keys.

labels.insert(0.0, "Mon");
labels.insert(1.0, "Tue");
labels.insert(2.0, "Wed");
plot->setAxisScaleDraw(QwtPlot::xBottom, new QwtTextScaleDraw(labels));
Definition qwt_raster_data.h:40
QwtTextScaleDraw()
Constructor
Definition qwt_text_scale_draw.cpp:48
参见
QwtScaleDraw, QwtPlot::setAxisScaleDraw()

构造及析构函数说明

◆ QwtTextScaleDraw()

QwtTextScaleDraw::QwtTextScaleDraw ( )
explicit

Constructor

Constructs a text scale draw with an empty label map, so no labels are displayed until setLabelMap() is called.

Constructor

参数
[in]mapValue to label map

Constructs a text scale draw with a custom value-to-label map. The values of the major ticks are looked up in this map to obtain the displayed text.

参见
setLabelMap(), labelMap()

Destructor

成员函数说明

◆ label()

QwtText QwtTextScaleDraw::label ( double  value) const
overridevirtual

Map a value to a corresponding label

参数
[in]valueValue that will be mapped
返回
The label corresponding to value, or a null text if value matches no key

label() looks up the labelMap() for a corresponding label for value. Matching uses a small tolerance (1e-6) to be robust against floating point drift of the tick values. If no key matches, a null text is returned.

参见
labelMap(), setLabelMap()

重载 QwtAbstractScaleDraw .

◆ labelMap()

QMap< double, QString > QwtTextScaleDraw::labelMap ( ) const

Get the map that maps values to labels

返回
Map mapping values to labels
参见
setLabelMap()

◆ setLabelMap()

void QwtTextScaleDraw::setLabelMap ( const QMap< double, QString > &  map)

Set the map that maps values to labels

参数
[in]mapValue to label map

The values of the major ticks are found by looking into this map. Values that do not match any key produce an empty label.

警告
The map has no effect for values that are not major tick values. Major ticks are controlled by the scale engine and QwtScaleDiv.
参见
labelMap(), QwtScaleDraw::setScale()

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