| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | // |
| 5 | // W A R N I N G |
| 6 | // ------------- |
| 7 | // |
| 8 | // This file is not part of the QtGraphs API. It exists purely as an |
| 9 | // implementation detail. This header file may change from version to |
| 10 | // version without notice, or even be removed. |
| 11 | // |
| 12 | // We mean it. |
| 13 | |
| 14 | #ifndef UTILS_P_H |
| 15 | #define UTILS_P_H |
| 16 | |
| 17 | #include <QtCore/qlocale.h> |
| 18 | #include <QtGui/qimage.h> |
| 19 | #include <QtGui/qquaternion.h> |
| 20 | #include "common/theme/qquickgraphscolor_p.h" |
| 21 | #include "qabstract3dseries.h" |
| 22 | #include <private/qgraphsglobal_p.h> |
| 23 | |
| 24 | QT_FORWARD_DECLARE_CLASS(QLinearGradient) |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QQuickGradient; |
| 29 | |
| 30 | class Utils |
| 31 | { |
| 32 | public: |
| 33 | enum class ParamType { Unknown, Int, UInt, Real }; |
| 34 | |
| 35 | static ParamType preParseFormat( |
| 36 | const QString &format, QString &preStr, QString &postStr, int &precision, char &formatSpec); |
| 37 | static QString formatLabelSprintf(const QByteArray &format, ParamType paramType, qreal value); |
| 38 | static QString formatLabelLocalized(ParamType paramType, |
| 39 | qreal value, |
| 40 | const QLocale &locale, |
| 41 | const QString &preStr, |
| 42 | const QString &postStr, |
| 43 | int precision, |
| 44 | char formatSpec, |
| 45 | const QByteArray &format); |
| 46 | static QString defaultLabelFormat(); |
| 47 | |
| 48 | static float wrapValue(float value, float min, float max); |
| 49 | static QQuaternion calculateRotation(QVector3D xyzRotations); |
| 50 | static void verifyGradientCompleteness(QLinearGradient &gradient); |
| 51 | static void setSeriesGradient(QAbstract3DSeries *series, QJSValue gradient, GradientType type); |
| 52 | static void setSeriesGradient(QAbstract3DSeries *series, |
| 53 | QQuickGradient *gradient, |
| 54 | GradientType type); |
| 55 | static void connectSeriesGradient(QAbstract3DSeries *series, |
| 56 | QJSValue newGradient, |
| 57 | GradientType type, |
| 58 | QJSValue &memberGradient); |
| 59 | |
| 60 | private: |
| 61 | static ParamType mapFormatCharToParamType(char formatSpec); |
| 62 | }; |
| 63 | |
| 64 | QT_END_NAMESPACE |
| 65 | |
| 66 | #endif |
| 67 | |