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