1// Copyright (C) 2016 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 QtDataVisualization 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 "datavisualizationglobal_p.h"
18
19QT_FORWARD_DECLARE_CLASS(QLinearGradient)
20
21QT_BEGIN_NAMESPACE
22
23class Utils
24{
25public:
26 enum ParamType {
27 ParamTypeUnknown = 0,
28 ParamTypeInt,
29 ParamTypeUInt,
30 ParamTypeReal
31 };
32
33 static GLuint getNearestPowerOfTwo(GLuint value);
34 static QVector4D vectorFromColor(const QColor &color);
35 static QColor colorFromVector(const QVector3D &colorVector);
36 static QColor colorFromVector(const QVector4D &colorVector);
37 static QImage printTextToImage(const QFont &font,
38 const QString &text,
39 const QColor &bgrColor,
40 const QColor &txtColor,
41 bool labelBackground,
42 bool borders = false,
43 int maxLabelWidth = 0);
44 static QVector4D getSelection(QPoint mousepos, int height);
45 static QImage getGradientImage(QLinearGradient &gradient);
46
47 static ParamType preParseFormat(const QString &format, QString &preStr, QString &postStr,
48 int &precision, char &formatSpec);
49 static QString formatLabelSprintf(const QByteArray &format, ParamType paramType, qreal value);
50 static QString formatLabelLocalized(ParamType paramType, qreal value,
51 const QLocale &locale, const QString &preStr, const QString &postStr,
52 int precision, char formatSpec, const QByteArray &format);
53 static QString defaultLabelFormat();
54
55 static float wrapValue(float value, float min, float max);
56 static QQuaternion calculateRotation(const QVector3D &xyzRotations);
57 static bool isOpenGLES();
58 static void resolveStatics();
59
60private:
61 static ParamType mapFormatCharToParamType(char formatSpec);
62};
63
64QT_END_NAMESPACE
65
66#endif
67

source code of qtdatavis3d/src/datavisualization/utils/utils_p.h