QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_abstract_scale_draw.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *
9 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_ABSTRACT_SCALE_DRAW_H
28#define QWT_ABSTRACT_SCALE_DRAW_H
29
30#include "qwt_global.h"
31#include "qwt_scale_div.h"
32
33class QwtText;
34class QPalette;
35class QPainter;
36class QFont;
37class QwtTransform;
38class QwtScaleMap;
39
46class QWT_EXPORT QwtAbstractScaleDraw
47{
48public:
54 {
56 Backbone = 0x01,
57
59 Ticks = 0x02,
60
62 Labels = 0x04
63 };
64
65 Q_DECLARE_FLAGS(ScaleComponents, ScaleComponent)
66
68 virtual ~QwtAbstractScaleDraw();
69
70 void setScaleDiv(const QwtScaleDiv&);
71 const QwtScaleDiv& scaleDiv() const;
72
73 void setTransformation(QwtTransform*);
74 const QwtScaleMap& scaleMap() const;
75 QwtScaleMap& scaleMap();
76
77 void enableComponent(ScaleComponent, bool enable = true);
78 bool hasComponent(ScaleComponent) const;
79
80 void setTickLength(QwtScaleDiv::TickType, double length);
81 double tickLength(QwtScaleDiv::TickType) const;
82 double maxTickLength() const;
83
84 void setSpacing(double);
85 double spacing() const;
86
87 void setPenWidthF(qreal width);
88 qreal penWidthF() const;
89
90 // Set whether the scale draw is selected
91 void setSelected(bool on);
92 // Check if the scale draw is selected
93 bool isSelected() const;
94
95 // Set the pen width adjustment after selection
96 void setSelectedPenWidthOffset(qreal offset = 1);
97 qreal selectedPenWidthOffset() const;
98
99 virtual void draw(QPainter*, const QPalette&) const;
100
101 virtual QwtText label(double) const;
102
103 // Calculate the extent (distance from baseline to outermost pixel)
104 virtual double extent(const QFont& font) const = 0;
105
106 void setMinimumExtent(double);
107 double minimumExtent() const;
108
109 void invalidateCache();
110
111protected:
112 // Draw a tick
113 virtual void drawTick(QPainter* painter, double value, double len) const = 0;
114
115 // Draws the baseline of the scale
116 virtual void drawBackbone(QPainter* painter) const = 0;
117
118 // Draws the label for a major scale tick
119 virtual void drawLabel(QPainter* painter, double value) const = 0;
120
121 const QwtText& tickLabel(const QFont&, double value) const;
122
123private:
125 QwtAbstractScaleDraw& operator=(const QwtAbstractScaleDraw&) = delete;
126
127 QWT_DECLARE_PRIVATE(QwtAbstractScaleDraw)
128};
129
130Q_DECLARE_OPERATORS_FOR_FLAGS(QwtAbstractScaleDraw::ScaleComponents)
131
132#endif
An abstract base class for drawing scales
Definition qwt_abstract_scale_draw.h:47
ScaleComponent
Components of a scale
Definition qwt_abstract_scale_draw.h:54
A class representing a scale division
Definition qwt_scale_div.h:47
TickType
Scale tick types
Definition qwt_scale_div.h:51
A scale map
Definition qwt_scale_map.h:44
A class representing a text
Definition qwt_text.h:70
A transformation between coordinate systems
Definition qwt_transform.h:47