@@ -1,83 +1,82 | |||||
1 | /****************************************************************************** |
|
1 | /****************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd. | |
4 | ** Contact: http://www.qt.io/licensing/ |
|
4 | ** Contact: http://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module. |
|
6 | ** This file is part of the Qt Charts module. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:COMM$ |
|
8 | ** $QT_BEGIN_LICENSE:COMM$ | |
9 | ** |
|
9 | ** | |
10 | ** Commercial License Usage |
|
10 | ** Commercial License Usage | |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
11 | ** Licensees holding valid commercial Qt licenses may use this file in | |
12 | ** accordance with the commercial license agreement provided with the |
|
12 | ** accordance with the commercial license agreement provided with the | |
13 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | ** Software or, alternatively, in accordance with the terms contained in | |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
|
14 | ** a written agreement between you and The Qt Company. For licensing terms | |
15 | ** and conditions see http://www.qt.io/terms-conditions. For further |
|
15 | ** and conditions see http://www.qt.io/terms-conditions. For further | |
16 | ** information use the contact form at http://www.qt.io/contact-us. |
|
16 | ** information use the contact form at http://www.qt.io/contact-us. | |
17 | ** |
|
17 | ** | |
18 | ** $QT_END_LICENSE$ |
|
18 | ** $QT_END_LICENSE$ | |
19 | ** |
|
19 | ** | |
20 | ******************************************************************************/ |
|
20 | ******************************************************************************/ | |
21 |
|
21 | |||
22 | // W A R N I N G |
|
22 | // W A R N I N G | |
23 | // ------------- |
|
23 | // ------------- | |
24 | // |
|
24 | // | |
25 | // This file is not part of the Qt Chart API. It exists purely as an |
|
25 | // This file is not part of the Qt Chart API. It exists purely as an | |
26 | // implementation detail. This header file may change from version to |
|
26 | // implementation detail. This header file may change from version to | |
27 | // version without notice, or even be removed. |
|
27 | // version without notice, or even be removed. | |
28 | // |
|
28 | // | |
29 | // We mean it. |
|
29 | // We mean it. | |
30 |
|
30 | |||
31 | #ifndef GLWIDGET_H |
|
31 | #ifndef GLWIDGET_H | |
32 | #define GLWIDGET_H |
|
32 | #define GLWIDGET_H | |
33 |
|
33 | |||
34 | #ifndef QT_NO_OPENGL |
|
34 | #ifndef QT_NO_OPENGL | |
35 |
|
35 | |||
36 | #include <QtWidgets/QOpenGLWidget> |
|
36 | #include <QtWidgets/QOpenGLWidget> | |
37 | #include <QtGui/QOpenGLFunctions> |
|
37 | #include <QtGui/QOpenGLFunctions> | |
38 | #include <QtGui/QOpenGLVertexArrayObject> |
|
38 | #include <QtGui/QOpenGLVertexArrayObject> | |
|
39 | #include <QtGui/QOpenGLBuffer> | |||
39 | #include <QtCore/QHash> |
|
40 | #include <QtCore/QHash> | |
40 | #include <QtCharts/QAbstractSeries> |
|
41 | #include <QtCharts/QAbstractSeries> | |
41 | #include <QtCharts/QXYSeries> |
|
42 | #include <QtCharts/QXYSeries> | |
42 |
|
43 | |||
43 | QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram) |
|
44 | QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram) | |
44 |
|
45 | |||
45 | class QOpenGLBuffer; |
|
|||
46 |
|
||||
47 | QT_CHARTS_BEGIN_NAMESPACE |
|
46 | QT_CHARTS_BEGIN_NAMESPACE | |
48 |
|
47 | |||
49 | class GLXYSeriesDataManager; |
|
48 | class GLXYSeriesDataManager; | |
50 |
|
49 | |||
51 | class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions |
|
50 | class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions | |
52 | { |
|
51 | { | |
53 | Q_OBJECT |
|
52 | Q_OBJECT | |
54 |
|
53 | |||
55 | public: |
|
54 | public: | |
56 | GLWidget(GLXYSeriesDataManager *xyDataManager, QWidget *parent = 0); |
|
55 | GLWidget(GLXYSeriesDataManager *xyDataManager, QWidget *parent = 0); | |
57 | ~GLWidget(); |
|
56 | ~GLWidget(); | |
58 |
|
57 | |||
59 | public Q_SLOTS: |
|
58 | public Q_SLOTS: | |
60 | void cleanup(); |
|
59 | void cleanup(); | |
61 | void cleanXYSeriesResources(const QXYSeries *series); |
|
60 | void cleanXYSeriesResources(const QXYSeries *series); | |
62 |
|
61 | |||
63 | protected: |
|
62 | protected: | |
64 | void initializeGL() Q_DECL_OVERRIDE; |
|
63 | void initializeGL() Q_DECL_OVERRIDE; | |
65 | void paintGL() Q_DECL_OVERRIDE; |
|
64 | void paintGL() Q_DECL_OVERRIDE; | |
66 | void resizeGL(int width, int height) Q_DECL_OVERRIDE; |
|
65 | void resizeGL(int width, int height) Q_DECL_OVERRIDE; | |
67 |
|
66 | |||
68 | private: |
|
67 | private: | |
69 | QOpenGLShaderProgram *m_program; |
|
68 | QOpenGLShaderProgram *m_program; | |
70 | int m_shaderAttribLoc; |
|
69 | int m_shaderAttribLoc; | |
71 | int m_colorUniformLoc; |
|
70 | int m_colorUniformLoc; | |
72 | int m_minUniformLoc; |
|
71 | int m_minUniformLoc; | |
73 | int m_deltaUniformLoc; |
|
72 | int m_deltaUniformLoc; | |
74 | int m_pointSizeUniformLoc; |
|
73 | int m_pointSizeUniformLoc; | |
75 | QOpenGLVertexArrayObject m_vao; |
|
74 | QOpenGLVertexArrayObject m_vao; | |
76 |
|
75 | |||
77 | QHash<const QAbstractSeries *, QOpenGLBuffer *> m_seriesBufferMap; |
|
76 | QHash<const QAbstractSeries *, QOpenGLBuffer *> m_seriesBufferMap; | |
78 | GLXYSeriesDataManager *m_xyDataManager; |
|
77 | GLXYSeriesDataManager *m_xyDataManager; | |
79 | }; |
|
78 | }; | |
80 |
|
79 | |||
81 | QT_CHARTS_END_NAMESPACE |
|
80 | QT_CHARTS_END_NAMESPACE | |
82 | #endif |
|
81 | #endif | |
83 | #endif |
|
82 | #endif |
@@ -1,77 +1,76 | |||||
1 | /****************************************************************************** |
|
1 | /****************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd. |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd. | |
4 | ** Contact: http://www.qt.io/licensing/ |
|
4 | ** Contact: http://www.qt.io/licensing/ | |
5 | ** |
|
5 | ** | |
6 | ** This file is part of the Qt Charts module. |
|
6 | ** This file is part of the Qt Charts module. | |
7 | ** |
|
7 | ** | |
8 | ** $QT_BEGIN_LICENSE:COMM$ |
|
8 | ** $QT_BEGIN_LICENSE:COMM$ | |
9 | ** |
|
9 | ** | |
10 | ** Commercial License Usage |
|
10 | ** Commercial License Usage | |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
11 | ** Licensees holding valid commercial Qt licenses may use this file in | |
12 | ** accordance with the commercial license agreement provided with the |
|
12 | ** accordance with the commercial license agreement provided with the | |
13 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | ** Software or, alternatively, in accordance with the terms contained in | |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
|
14 | ** a written agreement between you and The Qt Company. For licensing terms | |
15 | ** and conditions see http://www.qt.io/terms-conditions. For further |
|
15 | ** and conditions see http://www.qt.io/terms-conditions. For further | |
16 | ** information use the contact form at http://www.qt.io/contact-us. |
|
16 | ** information use the contact form at http://www.qt.io/contact-us. | |
17 | ** |
|
17 | ** | |
18 | ** $QT_END_LICENSE$ |
|
18 | ** $QT_END_LICENSE$ | |
19 | ** |
|
19 | ** | |
20 | ******************************************************************************/ |
|
20 | ******************************************************************************/ | |
21 |
|
21 | |||
22 | #ifndef DECLARATIVERENDERNODE_P_H |
|
22 | #ifndef DECLARATIVERENDERNODE_P_H | |
23 | #define DECLARATIVERENDERNODE_P_H |
|
23 | #define DECLARATIVERENDERNODE_P_H | |
24 |
|
24 | |||
25 | #include <QtCharts/QChartGlobal> |
|
25 | #include <QtCharts/QChartGlobal> | |
26 | #include <private/glxyseriesdata_p.h> |
|
26 | #include <private/glxyseriesdata_p.h> | |
27 | #include <QtQuick/QSGSimpleTextureNode> |
|
27 | #include <QtQuick/QSGSimpleTextureNode> | |
28 | #include <QtQuick/QQuickWindow> |
|
28 | #include <QtQuick/QQuickWindow> | |
29 | #include <QtGui/QOpenGLVertexArrayObject> |
|
29 | #include <QtGui/QOpenGLVertexArrayObject> | |
30 | #include <QtGui/QOpenGLFunctions> |
|
30 | #include <QtGui/QOpenGLFunctions> | |
31 |
|
31 | #include <QtGui/QOpenGLFramebufferObject> | ||
32 | class QOpenGLFramebufferObject; |
|
32 | #include <QtGui/QOpenGLBuffer> | |
33 | class QOpenGLBuffer; |
|
|||
34 |
|
33 | |||
35 | QT_CHARTS_BEGIN_NAMESPACE |
|
34 | QT_CHARTS_BEGIN_NAMESPACE | |
36 |
|
35 | |||
37 | class DeclarativeRenderNode : public QObject, public QSGSimpleTextureNode, QOpenGLFunctions |
|
36 | class DeclarativeRenderNode : public QObject, public QSGSimpleTextureNode, QOpenGLFunctions | |
38 | { |
|
37 | { | |
39 | Q_OBJECT |
|
38 | Q_OBJECT | |
40 | public: |
|
39 | public: | |
41 | DeclarativeRenderNode(QQuickWindow *window); |
|
40 | DeclarativeRenderNode(QQuickWindow *window); | |
42 | ~DeclarativeRenderNode(); |
|
41 | ~DeclarativeRenderNode(); | |
43 |
|
42 | |||
44 | void initGL(); |
|
43 | void initGL(); | |
45 | QSize textureSize() const { return m_textureSize; } |
|
44 | QSize textureSize() const { return m_textureSize; } | |
46 | void setTextureSize(const QSize &size); |
|
45 | void setTextureSize(const QSize &size); | |
47 | void setSeriesData(bool mapDirty, const GLXYDataMap &dataMap); |
|
46 | void setSeriesData(bool mapDirty, const GLXYDataMap &dataMap); | |
48 |
|
47 | |||
49 | public Q_SLOTS: |
|
48 | public Q_SLOTS: | |
50 | void render(); |
|
49 | void render(); | |
51 |
|
50 | |||
52 | private: |
|
51 | private: | |
53 | void renderGL(); |
|
52 | void renderGL(); | |
54 | void recreateFBO(); |
|
53 | void recreateFBO(); | |
55 | void cleanXYSeriesResources(const QXYSeries *series); |
|
54 | void cleanXYSeriesResources(const QXYSeries *series); | |
56 |
|
55 | |||
57 | QSGTexture *m_texture; |
|
56 | QSGTexture *m_texture; | |
58 | QQuickWindow *m_window; |
|
57 | QQuickWindow *m_window; | |
59 | QQuickWindow::CreateTextureOptions m_textureOptions; |
|
58 | QQuickWindow::CreateTextureOptions m_textureOptions; | |
60 | QSize m_textureSize; |
|
59 | QSize m_textureSize; | |
61 | bool m_recreateFbo; |
|
60 | bool m_recreateFbo; | |
62 | GLXYDataMap m_xyDataMap; |
|
61 | GLXYDataMap m_xyDataMap; | |
63 | QOpenGLFramebufferObject *m_fbo; |
|
62 | QOpenGLFramebufferObject *m_fbo; | |
64 | QOpenGLShaderProgram *m_program; |
|
63 | QOpenGLShaderProgram *m_program; | |
65 | int m_shaderAttribLoc; |
|
64 | int m_shaderAttribLoc; | |
66 | int m_colorUniformLoc; |
|
65 | int m_colorUniformLoc; | |
67 | int m_minUniformLoc; |
|
66 | int m_minUniformLoc; | |
68 | int m_deltaUniformLoc; |
|
67 | int m_deltaUniformLoc; | |
69 | int m_pointSizeUniformLoc; |
|
68 | int m_pointSizeUniformLoc; | |
70 | QOpenGLVertexArrayObject m_vao; |
|
69 | QOpenGLVertexArrayObject m_vao; | |
71 | QHash<const QAbstractSeries *, QOpenGLBuffer *> m_seriesBufferMap; |
|
70 | QHash<const QAbstractSeries *, QOpenGLBuffer *> m_seriesBufferMap; | |
72 | bool m_renderNeeded; |
|
71 | bool m_renderNeeded; | |
73 | }; |
|
72 | }; | |
74 |
|
73 | |||
75 | QT_CHARTS_END_NAMESPACE |
|
74 | QT_CHARTS_END_NAMESPACE | |
76 |
|
75 | |||
77 | #endif // DECLARATIVERENDERNODE_P_H |
|
76 | #endif // DECLARATIVERENDERNODE_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now