summaryrefslogtreecommitdiffstats
path: root/src/graphs3d/utils/utils_p.h
blob: 8866293a06073906ddf96ad3d9a6619579856c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

//
//  W A R N I N G
//  -------------
//
// This file is not part of the QtGraphs API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.

#ifndef UTILS_P_H
#define UTILS_P_H

#include <QtCore/qlocale.h>
#include <QtGui/qimage.h>
#include <QtGui/qquaternion.h>
#include "common/theme/qquickgraphscolor_p.h"
#include "qabstract3dseries.h"
#include <private/qgraphsglobal_p.h>

QT_FORWARD_DECLARE_CLASS(QLinearGradient)

QT_BEGIN_NAMESPACE

class QQuickGradient;

class Utils
{
public:
    enum class ParamType { Unknown, Int, UInt, Real };

    static ParamType preParseFormat(
        const QString &format, QString &preStr, QString &postStr, int &precision, char &formatSpec);
    static QString formatLabelSprintf(const QByteArray &format, ParamType paramType, qreal value);
    static QString formatLabelLocalized(ParamType paramType,
                                        qreal value,
                                        const QLocale &locale,
                                        const QString &preStr,
                                        const QString &postStr,
                                        int precision,
                                        char formatSpec,
                                        const QByteArray &format);
    static QString defaultLabelFormat();

    static float wrapValue(float value, float min, float max);
    static QQuaternion calculateRotation(QVector3D xyzRotations);
    static void verifyGradientCompleteness(QLinearGradient &gradient);
    static void setSeriesGradient(QAbstract3DSeries *series, QJSValue gradient, GradientType type);
    static void setSeriesGradient(QAbstract3DSeries *series,
                                  QQuickGradient *gradient,
                                  GradientType type);
    static void connectSeriesGradient(QAbstract3DSeries *series,
                                      QJSValue newGradient,
                                      GradientType type,
                                      QJSValue &memberGradient);

private:
    static ParamType mapFormatCharToParamType(char formatSpec);
};

QT_END_NAMESPACE

#endif