1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Data Visualization module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30//
31// W A R N I N G
32// -------------
33//
34// This file is not part of the QtDataVisualization API. It exists purely as an
35// implementation detail. This header file may change from version to
36// version without notice, or even be removed.
37//
38// We mean it.
39
40#ifndef DRAWER_P_H
41#define DRAWER_P_H
42
43#include "datavisualizationglobal_p.h"
44#include "q3dbars.h"
45#include "q3dtheme.h"
46#include "labelitem_p.h"
47#include "abstractrenderitem_p.h"
48
49QT_BEGIN_NAMESPACE_DATAVISUALIZATION
50
51class ShaderHelper;
52class ObjectHelper;
53class AbstractObjectHelper;
54class SurfaceObject;
55class TextureHelper;
56class Q3DCamera;
57class Abstract3DRenderer;
58class ScatterPointBufferHelper;
59
60class Drawer : public QObject, public QOpenGLFunctions
61{
62 Q_OBJECT
63
64public:
65 enum LabelPosition {
66 LabelBelow = 0,
67 LabelLow,
68 LabelMid,
69 LabelHigh,
70 LabelOver,
71 LabelBottom, // Absolute positions from here onward, used for axes (QDataItem is ignored)
72 LabelTop,
73 LabelLeft,
74 LabelRight
75 };
76
77public:
78 explicit Drawer(Q3DTheme *theme);
79 ~Drawer();
80
81 void initializeOpenGL();
82
83 void setTheme(Q3DTheme *theme);
84 Q3DTheme *theme() const;
85 QFont font() const;
86 inline GLfloat scaledFontSize() const { return m_scaledFontSize; }
87
88 void drawObject(ShaderHelper *shader, AbstractObjectHelper *object, GLuint textureId = 0,
89 GLuint depthTextureId = 0, GLuint textureId3D = 0);
90 void drawSelectionObject(ShaderHelper *shader, AbstractObjectHelper *object);
91 void drawSurfaceGrid(ShaderHelper *shader, SurfaceObject *object);
92 void drawPoint(ShaderHelper *shader);
93 void drawPoints(ShaderHelper *shader, ScatterPointBufferHelper *object, GLuint textureId);
94 void drawLine(ShaderHelper *shader);
95 void drawLabel(const AbstractRenderItem &item, const LabelItem &labelItem,
96 const QMatrix4x4 &viewmatrix, const QMatrix4x4 &projectionmatrix,
97 const QVector3D &positionComp, const QQuaternion &rotation, GLfloat itemHeight,
98 QAbstract3DGraph::SelectionFlags mode, ShaderHelper *shader, ObjectHelper *object,
99 const Q3DCamera *camera, bool useDepth = false, bool rotateAlong = false,
100 LabelPosition position = LabelOver,
101 Qt::Alignment alignment = Qt::AlignCenter, bool isSlicing = false,
102 bool isSelecting = false);
103
104 void generateSelectionLabelTexture(Abstract3DRenderer *item);
105 void generateLabelItem(LabelItem &item, const QString &text, int widestLabel = 0);
106
107Q_SIGNALS:
108 void drawerChanged();
109
110private:
111 Q3DTheme *m_theme;
112 TextureHelper *m_textureHelper;
113 GLuint m_pointbuffer;
114 GLuint m_linebuffer;
115 GLfloat m_scaledFontSize;
116};
117
118QT_END_NAMESPACE_DATAVISUALIZATION
119
120#endif
121

source code of qtdatavis3d/src/datavisualization/engine/drawer_p.h