QtIndustrialWidgets 2.3.0
Modern, High-Performance Industrial Instruments & SCADA Widgets for Qt
Loading...
Searching...
No Matches
RadialGauge.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 Paolo Sereno <paolomsereno@gmail.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#pragma once
8
10#include <QtWidgets/QWidget>
11#include <memory>
12#include <QtGui/QColor>
13#include <QtGui/QPixmap>
14
52namespace QtIndustrialWidgets {
53
54class RadialGaugePrivate;
55
57{
58 Q_OBJECT
59
60 Q_PROPERTY(double minimum READ minimum WRITE setMinimum NOTIFY rangeChanged)
61 Q_PROPERTY(double maximum READ maximum WRITE setMaximum NOTIFY rangeChanged)
62 Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged)
63 Q_PROPERTY(int precision READ precision WRITE setPrecision NOTIFY appearanceChanged)
64 Q_PROPERTY(QString unit READ unit WRITE setUnit NOTIFY appearanceChanged)
65 Q_PROPERTY(double startAngle READ startAngle WRITE setStartAngle NOTIFY appearanceChanged)
66 Q_PROPERTY(double spanAngle READ spanAngle WRITE setSpanAngle NOTIFY appearanceChanged)
67 Q_PROPERTY(int majorTicks READ majorTicks WRITE setMajorTicks NOTIFY appearanceChanged)
68 Q_PROPERTY(int minorTicks READ minorTicks WRITE setMinorTicks NOTIFY appearanceChanged)
69 Q_PROPERTY(double warningThreshold READ warningThreshold WRITE setWarningThreshold NOTIFY thresholdChanged)
70 Q_PROPERTY(double errorThreshold READ errorThreshold WRITE setErrorThreshold NOTIFY thresholdChanged)
71 Q_PROPERTY(bool thresholdBandsVisible READ thresholdBandsVisible WRITE setThresholdBandsVisible NOTIFY appearanceChanged)
72 Q_PROPERTY(bool digitalDisplayVisible READ digitalDisplayVisible WRITE setDigitalDisplayVisible NOTIFY appearanceChanged)
73 Q_PROPERTY(QColor needleColor READ needleColor WRITE setNeedleColor NOTIFY appearanceChanged)
74 Q_PROPERTY(QColor normalColor READ normalColor WRITE setNormalColor NOTIFY appearanceChanged)
75 Q_PROPERTY(QColor warningColor READ warningColor WRITE setWarningColor NOTIFY appearanceChanged)
76 Q_PROPERTY(QColor errorColor READ errorColor WRITE setErrorColor NOTIFY appearanceChanged)
77 Q_PROPERTY(QColor dialColor READ dialColor WRITE setDialColor NOTIFY appearanceChanged)
78 Q_PROPERTY(QColor scaleColor READ scaleColor WRITE setScaleColor NOTIFY appearanceChanged)
79 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY appearanceChanged)
80 Q_PROPERTY(QColor bezelColor READ bezelColor WRITE setBezelColor NOTIFY appearanceChanged)
81
82public:
87 explicit RadialGauge(QWidget *parent = nullptr);
88 ~RadialGauge() override;
89
91 [[nodiscard]] double minimum() const;
93 [[nodiscard]] double maximum() const;
95 [[nodiscard]] double value() const;
97 [[nodiscard]] int precision() const;
99 [[nodiscard]] QString unit() const;
101 [[nodiscard]] double startAngle() const;
103 [[nodiscard]] double spanAngle() const;
105 [[nodiscard]] int majorTicks() const;
107 [[nodiscard]] int minorTicks() const;
109 [[nodiscard]] double warningThreshold() const;
111 [[nodiscard]] double errorThreshold() const;
113 [[nodiscard]] bool thresholdBandsVisible() const;
115 [[nodiscard]] bool digitalDisplayVisible() const;
116
118 [[nodiscard]] QColor needleColor() const;
120 [[nodiscard]] QColor normalColor() const;
122 [[nodiscard]] QColor warningColor() const;
124 [[nodiscard]] QColor errorColor() const;
126 [[nodiscard]] QColor dialColor() const;
128 [[nodiscard]] QColor scaleColor() const;
130 [[nodiscard]] QColor textColor() const;
132 [[nodiscard]] QColor bezelColor() const;
133
134 [[nodiscard]] QSize sizeHint() const override;
135 [[nodiscard]] QSize minimumSizeHint() const override;
136
137public Q_SLOTS:
139 void setValue(double value);
141 void setMinimum(double min);
143 void setMaximum(double max);
145 void setRange(double min, double max);
147 void setPrecision(int precision);
149 void setUnit(const QString &unit);
151 void setStartAngle(double angle);
153 void setSpanAngle(double span);
155 void setMajorTicks(int count);
157 void setMinorTicks(int count);
159 void setWarningThreshold(double threshold);
161 void setErrorThreshold(double threshold);
163 void setThresholdBandsVisible(bool visible);
165 void setDigitalDisplayVisible(bool visible);
166
168 void setNeedleColor(const QColor &color);
170 void setNormalColor(const QColor &color);
172 void setWarningColor(const QColor &color);
174 void setErrorColor(const QColor &color);
176 void setDialColor(const QColor &color);
178 void setScaleColor(const QColor &color);
180 void setTextColor(const QColor &color);
182 void setBezelColor(const QColor &color);
183
184Q_SIGNALS:
186 void valueChanged(double value);
188 void rangeChanged(double min, double max);
190 void thresholdChanged(double warning, double error);
192 void warningExceeded(bool exceeded);
194 void errorExceeded(bool exceeded);
196 void appearanceChanged();
197
198protected:
199 void paintEvent(QPaintEvent *event) override;
200 void resizeEvent(QResizeEvent *event) override;
201 void changeEvent(QEvent *event) override;
202
203private:
204 void invalidateCache();
205 void renderStaticScale(const QSize &size);
206 double valueToAngle(double val) const;
207
208 std::unique_ptr<RadialGaugePrivate> d_ptr;
209 Q_DECLARE_PRIVATE(RadialGauge)
210};
211
212} // namespace QtIndustrialWidgets
Definition RadialGauge.h:57
Definition AnalysisChart.h:21
Library export macros and version definitions for QtIndustrialWidgets.
#define QTINDUSTRIALWIDGETS_EXPORT
Export/import macro for shared library symbol visibility across dynamic linking boundaries.
Definition qtindustrialwidgets_global.h:25