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 DRAWER_P_H |
15 | #define DRAWER_P_H |
16 | |
17 | #include <private/datavisualizationglobal_p.h> |
18 | #include <private/labelitem_p.h> |
19 | #include <private/abstractrenderitem_p.h> |
20 | |
21 | #include <QtDataVisualization/q3dbars.h> |
22 | #include <QtDataVisualization/q3dtheme.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class ShaderHelper; |
27 | class ObjectHelper; |
28 | class AbstractObjectHelper; |
29 | class SurfaceObject; |
30 | class TextureHelper; |
31 | class Q3DCamera; |
32 | class Abstract3DRenderer; |
33 | class ScatterPointBufferHelper; |
34 | |
35 | class Drawer : public QObject, public QOpenGLFunctions |
36 | { |
37 | Q_OBJECT |
38 | |
39 | public: |
40 | enum LabelPosition { |
41 | LabelBelow = 0, |
42 | LabelLow, |
43 | LabelMid, |
44 | LabelHigh, |
45 | LabelOver, |
46 | LabelBottom, // Absolute positions from here onward, used for axes (QDataItem is ignored) |
47 | LabelTop, |
48 | LabelLeft, |
49 | LabelRight |
50 | }; |
51 | |
52 | public: |
53 | explicit Drawer(Q3DTheme *theme); |
54 | ~Drawer(); |
55 | |
56 | void initializeOpenGL(); |
57 | |
58 | void setTheme(Q3DTheme *theme); |
59 | Q3DTheme *theme() const; |
60 | QFont font() const; |
61 | inline GLfloat scaledFontSize() const { return m_scaledFontSize; } |
62 | |
63 | void drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLuint textureId = 0, |
64 | GLuint depthTextureId = 0, GLuint textureId3D = 0); |
65 | void drawSelectionObject(ShaderHelper *shader, AbstractObjectHelper *object); |
66 | void drawSurfaceGrid(ShaderHelper *shader, SurfaceObject *object); |
67 | void drawPoint(ShaderHelper *shader); |
68 | void drawPoints(ShaderHelper *shader, ScatterPointBufferHelper *object, GLuint textureId); |
69 | void drawLine(ShaderHelper *shader); |
70 | void drawLabel(const AbstractRenderItem &item, const LabelItem &labelItem, |
71 | const QMatrix4x4 &viewmatrix, const QMatrix4x4 &projectionmatrix, |
72 | const QVector3D &positionComp, const QQuaternion &rotation, GLfloat itemHeight, |
73 | QAbstract3DGraph::SelectionFlags mode, ShaderHelper *shader, ObjectHelper *object, |
74 | const Q3DCamera *camera, bool useDepth = false, bool rotateAlong = false, |
75 | LabelPosition position = LabelOver, |
76 | Qt::Alignment alignment = Qt::AlignCenter, bool isSlicing = false, |
77 | bool isSelecting = false); |
78 | |
79 | void generateSelectionLabelTexture(Abstract3DRenderer *item); |
80 | void generateLabelItem(LabelItem &item, const QString &text, int widestLabel = 0); |
81 | |
82 | Q_SIGNALS: |
83 | void drawerChanged(); |
84 | |
85 | private: |
86 | Q3DTheme *m_theme; |
87 | TextureHelper *m_textureHelper; |
88 | GLuint m_pointbuffer; |
89 | GLuint m_linebuffer; |
90 | GLfloat m_scaledFontSize; |
91 | }; |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | #endif |
96 | |