QWT 7.0.1
Loading...
Searching...
No Matches
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
48class QWT_EXPORT QwtAbstractScaleDraw
49{
50public:
56 {
58 Backbone = 0x01,
59
61 Ticks = 0x02,
62
64 Labels = 0x04
65 };
66
67 Q_DECLARE_FLAGS(ScaleComponents, ScaleComponent)
68
70 virtual ~QwtAbstractScaleDraw();
71
72 void setScaleDiv(const QwtScaleDiv&);
73 const QwtScaleDiv& scaleDiv() const;
74
75 void setTransformation(QwtTransform*);
76 const QwtScaleMap& scaleMap() const;
77 QwtScaleMap& scaleMap();
78
79 void enableComponent(ScaleComponent, bool enable = true);
80 bool hasComponent(ScaleComponent) const;
81
82 void setTickLength(QwtScaleDiv::TickType, double length);
83 double tickLength(QwtScaleDiv::TickType) const;
84 double maxTickLength() const;
85
86 void setSpacing(double);
87 double spacing() const;
88
89 void setPenWidthF(qreal width);
90 qreal penWidthF() const;
91
92 // 设置是否选中,选中状态的绘制会有一定差异
93 void setSelected(bool on);
94 bool isSelected() const;
95
96 // 设置选中后画笔的宽度修正
97 void setSelectedPenWidthOffset(qreal offset = 1);
98 qreal selectedPenWidthOffset() const;
99
100 virtual void draw(QPainter*, const QPalette&) const;
101
102 virtual QwtText label(double) const;
103
116 virtual double extent(const QFont& font) const = 0;
117
118 void setMinimumExtent(double);
119 double minimumExtent() const;
120
121 void invalidateCache();
122
123protected:
133 virtual void drawTick(QPainter* painter, double value, double len) const = 0;
134
141 virtual void drawBackbone(QPainter* painter) const = 0;
142
151 virtual void drawLabel(QPainter* painter, double value) const = 0;
152
153 const QwtText& tickLabel(const QFont&, double value) const;
154
155private:
156 Q_DISABLE_COPY(QwtAbstractScaleDraw)
157
158 class PrivateData;
159 PrivateData* m_data;
160};
161
162Q_DECLARE_OPERATORS_FOR_FLAGS(QwtAbstractScaleDraw::ScaleComponents)
163
164#endif
A abstract base class for drawing scales.
Definition qwt_abstract_scale_draw.h:49
virtual void drawBackbone(QPainter *painter) const =0
Draws the baseline of the scale.
ScaleComponent
Components of a scale.
Definition qwt_abstract_scale_draw.h:56
virtual void drawTick(QPainter *painter, double value, double len) const =0
Draw a tick.
virtual double extent(const QFont &font) const =0
Calculate the extent.
virtual void drawLabel(QPainter *painter, double value) const =0
Draws the label for a major scale tick.
A class representing a scale division/表示刻度划分的类
Definition qwt_scale_div.h:53
TickType
Scale tick types.
Definition qwt_scale_div.h:57
A scale map.
Definition qwt_scale_map.h:44
A class representing a text.
Definition qwt_text.h:69
A transformation between coordinate systems.
Definition qwt_transform.h:53