QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_dial_needle.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_DIAL_NEEDLE_H
28#define QWT_DIAL_NEEDLE_H
29
30#include "qwt_global.h"
31#include <qpalette.h>
32
33class QPainter;
34
42class QWT_EXPORT QwtDialNeedle
43{
44public:
48 virtual ~QwtDialNeedle();
49
51 virtual void setPalette(const QPalette&);
53 const QPalette& palette() const;
54
56 void setFlatStyle(bool);
58 bool flatStyle() const;
59
61 virtual void
62 draw(QPainter*, const QPointF& center, double length, double direction, QPalette::ColorGroup = QPalette::Active) const;
63
64protected:
80 virtual void drawNeedle(QPainter* painter, double length, QPalette::ColorGroup colorGroup) const = 0;
81
82 virtual void drawKnob(QPainter*, double width, const QBrush&, bool sunken) const;
83
84protected:
85 QPalette m_palette;
86 bool m_flatStyle;
87
88private:
89 QwtDialNeedle(const QwtDialNeedle&) = delete;
90 QwtDialNeedle& operator=(const QwtDialNeedle&) = delete;
91};
92
101class QWT_EXPORT QwtDialSimpleNeedle : public QwtDialNeedle
102{
103public:
107 enum Style
108 {
109 // Arrow style
110 Arrow,
111
112 // A straight line from the center
113 Ray
114 };
115
117 QwtDialSimpleNeedle(Style, bool hasKnob = true, const QColor& mid = Qt::gray, const QColor& base = Qt::darkGray);
118
120 void setWidth(double width);
122 double width() const;
123
124protected:
125 virtual void drawNeedle(QPainter*, double length, QPalette::ColorGroup) const override;
126
127private:
128 Style m_style;
129 bool m_hasKnob;
130 double m_width;
131};
132
144class QWT_EXPORT QwtCompassMagnetNeedle : public QwtDialNeedle
145{
146public:
150 enum Style
151 {
152 // A needle with a triangular shape
153 TriangleStyle,
154
155 // A thin needle
156 ThinStyle
157 };
158
160 QwtCompassMagnetNeedle(Style = TriangleStyle, const QColor& light = Qt::white, const QColor& dark = Qt::red);
161
162protected:
163 virtual void drawNeedle(QPainter*, double length, QPalette::ColorGroup) const override;
164
165private:
166 Style m_style;
167};
168
178class QWT_EXPORT QwtCompassWindArrow : public QwtDialNeedle
179{
180public:
184 enum Style
185 {
186 // A needle pointing to the center
187 Style1,
188
189 // A needle pointing to the center
190 Style2
191 };
192
194 QwtCompassWindArrow(Style, const QColor& light = Qt::white, const QColor& dark = Qt::gray);
195
196protected:
197 virtual void drawNeedle(QPainter*, double length, QPalette::ColorGroup) const override;
198
199private:
200 Style m_style;
201};
202
203#endif
A magnet needle for compass widgets
Definition qwt_dial_needle.h:145
Style
Style of the needle
Definition qwt_dial_needle.h:151
An indicator for the wind direction
Definition qwt_dial_needle.h:179
Style
Style of the arrow
Definition qwt_dial_needle.h:185
Base class for needles that can be used in a QwtDial
Definition qwt_dial_needle.h:43
virtual void drawNeedle(QPainter *painter, double length, QPalette::ColorGroup colorGroup) const =0
Draw the needle
A needle for dial widgets
Definition qwt_dial_needle.h:102
Style
Style of the needle
Definition qwt_dial_needle.h:108