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

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