diff options
Diffstat (limited to 'src/datavisualization/utils')
24 files changed, 215 insertions, 801 deletions
diff --git a/src/datavisualization/utils/abstractobjecthelper.cpp b/src/datavisualization/utils/abstractobjecthelper.cpp index db0318ce..a99bdfac 100644 --- a/src/datavisualization/utils/abstractobjecthelper.cpp +++ b/src/datavisualization/utils/abstractobjecthelper.cpp @@ -1,35 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "abstractobjecthelper_p.h" -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE AbstractObjectHelper::AbstractObjectHelper() : m_vertexbuffer(0), @@ -85,4 +59,4 @@ GLuint AbstractObjectHelper::indexCount() return m_indexCount; } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/abstractobjecthelper_p.h b/src/datavisualization/utils/abstractobjecthelper_p.h index cb03b156..918db4e4 100644 --- a/src/datavisualization/utils/abstractobjecthelper_p.h +++ b/src/datavisualization/utils/abstractobjecthelper_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -42,7 +16,7 @@ #include "datavisualizationglobal_p.h" -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class AbstractObjectHelper: protected QOpenGLFunctions { @@ -67,6 +41,6 @@ public: GLboolean m_meshDataLoaded; }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/camerahelper.cpp b/src/datavisualization/utils/camerahelper.cpp index 38091b49..1a8c8823 100644 --- a/src/datavisualization/utils/camerahelper.cpp +++ b/src/datavisualization/utils/camerahelper.cpp @@ -1,38 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "camerahelper_p.h" #include <QtCore/qmath.h> #include <QtGui/QMatrix4x4> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE CameraHelper::CameraHelper(QObject *parent) : QObject(parent), @@ -265,4 +239,4 @@ void CameraHelper::setCameraPreset(Q3DCamera::CameraPreset preset) } } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/camerahelper_p.h b/src/datavisualization/utils/camerahelper_p.h index fd28e3e6..88c556b3 100644 --- a/src/datavisualization/utils/camerahelper_p.h +++ b/src/datavisualization/utils/camerahelper_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -48,7 +22,7 @@ class QMatrix4x4; class QPoint; QT_END_NAMESPACE -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class CameraHelper : public QObject { @@ -95,6 +69,6 @@ public: void setCameraPreset(Q3DCamera::CameraPreset preset); }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/meshloader.cpp b/src/datavisualization/utils/meshloader.cpp index 2069b444..dc21b0f6 100644 --- a/src/datavisualization/utils/meshloader.cpp +++ b/src/datavisualization/utils/meshloader.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "meshloader_p.h" @@ -34,7 +8,7 @@ #include <QtCore/QList> #include <QtGui/QVector2D> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE QString slashTag = QStringLiteral("/"); @@ -81,6 +55,10 @@ bool MeshLoader::loadOBJ(const QString &path, QList<QVector3D> &out_vertices, QStringList set1 = lineContents.at(1).split(slashTag); QStringList set2 = lineContents.at(2).split(slashTag); QStringList set3 = lineContents.at(3).split(slashTag); + if (set1.size() < 3 || set2.size() < 3 || set3.size() < 3) { + qWarning("The file being loaded is missing UVs and/or normals"); + return false; + } vertexIndex[0] = set1.at(0).toUInt(); vertexIndex[1] = set2.at(0).toUInt(); vertexIndex[2] = set3.at(0).toUInt(); @@ -123,4 +101,4 @@ bool MeshLoader::loadOBJ(const QString &path, QList<QVector3D> &out_vertices, return true; } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/meshloader_p.h b/src/datavisualization/utils/meshloader_p.h index e8f60ffc..cbd4036b 100644 --- a/src/datavisualization/utils/meshloader_p.h +++ b/src/datavisualization/utils/meshloader_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -43,7 +17,7 @@ #include "datavisualizationglobal_p.h" #include <QtGui/QVector2D> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class MeshLoader { @@ -52,6 +26,6 @@ class MeshLoader QList<QVector2D> &out_uvs, QList<QVector3D> &out_normals); }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/objecthelper.cpp b/src/datavisualization/utils/objecthelper.cpp index 410a22d7..6053b255 100644 --- a/src/datavisualization/utils/objecthelper.cpp +++ b/src/datavisualization/utils/objecthelper.cpp @@ -1,37 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "meshloader_p.h" #include "vertexindexer_p.h" #include "objecthelper_p.h" -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE ObjectHelper::ObjectHelper(const QString &objectFile) : m_objectFile(objectFile) @@ -113,10 +87,19 @@ ObjectHelper *ObjectHelper::getObjectHelper(const Abstract3DRenderer *cacheId, objRef = new ObjectHelperRef; objRef->refCount = 0; objRef->obj = new ObjectHelper(objectFile); - objectTable->insert(objectFile, objRef); + if (objRef->obj->m_meshDataLoaded) { + objectTable->insert(objectFile, objRef); + } else { + delete objRef->obj; + delete objRef; + objRef = nullptr; + } + } + if (objRef) { + objRef->refCount++; + return objRef->obj; } - objRef->refCount++; - return objRef->obj; + return nullptr; } void ObjectHelper::load() @@ -140,41 +123,44 @@ void ObjectHelper::load() QList<QVector2D> uvs; QList<QVector3D> normals; bool loadOk = MeshLoader::loadOBJ(m_objectFile, vertices, uvs, normals); - if (!loadOk) - qFatal("loading failed"); - - // Index vertices - VertexIndexer::indexVBO(vertices, uvs, normals, m_indices, m_indexedVertices, m_indexedUVs, - m_indexedNormals); - - m_indexCount = m_indices.size(); - - glGenBuffers(1, &m_vertexbuffer); - glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer); - glBufferData(GL_ARRAY_BUFFER, m_indexedVertices.size() * sizeof(QVector3D), - &m_indexedVertices.at(0), - GL_STATIC_DRAW); - glGenBuffers(1, &m_normalbuffer); - glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer); - glBufferData(GL_ARRAY_BUFFER, m_indexedNormals.size() * sizeof(QVector3D), - &m_indexedNormals.at(0), - GL_STATIC_DRAW); - - glGenBuffers(1, &m_uvbuffer); - glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer); - glBufferData(GL_ARRAY_BUFFER, m_indexedUVs.size() * sizeof(QVector2D), - &m_indexedUVs.at(0), GL_STATIC_DRAW); - - glGenBuffers(1, &m_elementbuffer); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(GLuint), - &m_indices.at(0), GL_STATIC_DRAW); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - m_meshDataLoaded = true; + if (!loadOk) { + qCritical() << "Loading" << m_objectFile << "failed"; + m_meshDataLoaded = false; + } else { + // Index vertices + VertexIndexer::indexVBO(vertices, uvs, normals, m_indices, m_indexedVertices, m_indexedUVs, + m_indexedNormals); + + m_indexCount = m_indices.size(); + + glGenBuffers(1, &m_vertexbuffer); + glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer); + glBufferData(GL_ARRAY_BUFFER, m_indexedVertices.size() * sizeof(QVector3D), + &m_indexedVertices.at(0), + GL_STATIC_DRAW); + + glGenBuffers(1, &m_normalbuffer); + glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer); + glBufferData(GL_ARRAY_BUFFER, m_indexedNormals.size() * sizeof(QVector3D), + &m_indexedNormals.at(0), + GL_STATIC_DRAW); + + glGenBuffers(1, &m_uvbuffer); + glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer); + glBufferData(GL_ARRAY_BUFFER, m_indexedUVs.size() * sizeof(QVector2D), + &m_indexedUVs.at(0), GL_STATIC_DRAW); + + glGenBuffers(1, &m_elementbuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(GLuint), + &m_indices.at(0), GL_STATIC_DRAW); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + m_meshDataLoaded = true; + } } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/objecthelper_p.h b/src/datavisualization/utils/objecthelper_p.h index d1c2ea78..1ac0feb0 100644 --- a/src/datavisualization/utils/objecthelper_p.h +++ b/src/datavisualization/utils/objecthelper_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -43,7 +17,7 @@ #include "datavisualizationglobal_p.h" #include "abstractobjecthelper_p.h" -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class Abstract3DRenderer; @@ -76,6 +50,6 @@ private: QList<QVector3D> m_indexedNormals; }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/qutils.h b/src/datavisualization/utils/qutils.h index b7001652..6b58a977 100644 --- a/src/datavisualization/utils/qutils.h +++ b/src/datavisualization/utils/qutils.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QUTILS_H #define QUTILS_H @@ -36,11 +10,9 @@ #include <QtGui/QOffscreenSurface> #include <QtCore/QCoreApplication> -namespace QtDataVisualization { +QT_BEGIN_NAMESPACE -#ifndef Q_QDOC -static inline QSurfaceFormat qDefaultSurfaceFormat(bool antialias = true) Q_DECL_UNUSED; -#endif +[[maybe_unused]] static inline QSurfaceFormat qDefaultSurfaceFormat(bool antialias) { bool isES = false; @@ -65,7 +37,7 @@ static inline QSurfaceFormat qDefaultSurfaceFormat(bool antialias) ctx->makeCurrent(dummySurface); } -#if defined(QT_OPENGL_ES_2) +#if QT_CONFIG(opengles2) isES = true; #elif (QT_VERSION < QT_VERSION_CHECK(5, 3, 0)) isES = false; @@ -111,6 +83,6 @@ static inline QSurfaceFormat qDefaultSurfaceFormat(bool antialias) return surfaceFormat; } -} +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/scatterobjectbufferhelper.cpp b/src/datavisualization/utils/scatterobjectbufferhelper.cpp index 8e06617b..0a04d038 100644 --- a/src/datavisualization/utils/scatterobjectbufferhelper.cpp +++ b/src/datavisualization/utils/scatterobjectbufferhelper.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "scatterobjectbufferhelper_p.h" #include "objecthelper_p.h" @@ -33,9 +7,9 @@ #include <QtGui/QMatrix4x4> #include <QtCore/qmath.h> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE -const GLfloat itemScaler = 3.0f; +const GLfloat ScatterObjectBufferHelper::itemScaler = 3.0f; ScatterObjectBufferHelper::ScatterObjectBufferHelper() : m_scaleY(0.0f) @@ -48,7 +22,6 @@ ScatterObjectBufferHelper::~ScatterObjectBufferHelper() void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal dotScale) { - m_meshDataLoaded = false; m_indexCount = 0; ObjectHelper *dotObj = cache->object(); @@ -71,6 +44,7 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal m_uvbuffer = 0; m_normalbuffer = 0; m_elementbuffer = 0; + m_meshDataLoaded = false; } // Index vertices @@ -78,10 +52,10 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal const QList<QVector3D> indexed_vertices = dotObj->indexedvertices(); const QList<QVector2D> indexed_uvs = dotObj->indexedUVs(); const QList<QVector3D> indexed_normals = dotObj->indexedNormals(); - const int indicesCount = indices.count(); - const int verticeCount = indexed_vertices.count(); - const int uvsCount = indexed_uvs.count(); - const int normalsCount = indexed_normals.count(); + const int indicesCount = indices.size(); + const int verticeCount = indexed_vertices.size(); + const int uvsCount = indexed_uvs.size(); + const int normalsCount = indexed_normals.size(); float itemSize = cache->itemSize() / itemScaler; if (itemSize == 0.0f) @@ -98,7 +72,7 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal QList<QVector3D> scaled_vertices; scaled_vertices.resize(verticeCount); for (int i = 0; i < verticeCount; i++) - scaled_vertices[i] = indexed_vertices[i] * modelMatrix; + scaled_vertices[i] = (QVector4D(indexed_vertices[i]) * modelMatrix).toVector3D(); QList<GLuint> buffered_indices; QList<QVector3D> buffered_vertices; @@ -141,9 +115,11 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal modelMatrix = matrix.transposed(); // Because of row-column major difference for (int j = 0; j < verticeCount; j++) { - buffered_vertices[j + offset] = indexed_vertices[j] * modelMatrix + buffered_vertices[j + offset] + = (QVector4D(indexed_vertices[j]) * modelMatrix).toVector3D() + item.translation(); - buffered_normals[j + offset] = indexed_normals[j] * itModelMatrix; + buffered_normals[j + offset] + = (QVector4D(indexed_normals[j]) * itModelMatrix).toVector3D(); } } @@ -196,7 +172,7 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal void ScatterObjectBufferHelper::updateUVs(ScatterSeriesRenderCache *cache) { ObjectHelper *dotObj = cache->object(); - const int uvsCount = dotObj->indexedUVs().count(); + const int uvsCount = dotObj->indexedUVs().size(); const ScatterRenderItemArray &renderArray = cache->renderArray(); const bool updateAll = (cache->updateIndices().size() == 0); const int updateSize = updateAll ? renderArray.size() : cache->updateIndices().size(); @@ -237,7 +213,7 @@ uint ScatterObjectBufferHelper::createRangeGradientUVs(ScatterSeriesRenderCache QList<QVector2D> &buffered_uvs) { ObjectHelper *dotObj = cache->object(); - const int uvsCount = dotObj->indexedUVs().count(); + const int uvsCount = dotObj->indexedUVs().size(); const ScatterRenderItemArray &renderArray = cache->renderArray(); const bool updateAll = (cache->updateIndices().size() == 0); const int updateSize = updateAll ? renderArray.size() : cache->updateIndices().size(); @@ -280,7 +256,7 @@ uint ScatterObjectBufferHelper::createObjectGradientUVs(ScatterSeriesRenderCache const QList<QVector3D> &indexed_vertices) { ObjectHelper *dotObj = cache->object(); - const int uvsCount = dotObj->indexedUVs().count(); + const int uvsCount = dotObj->indexedUVs().size(); const ScatterRenderItemArray &renderArray = cache->renderArray(); const uint renderArraySize = renderArray.size(); @@ -317,7 +293,7 @@ void ScatterObjectBufferHelper::update(ScatterSeriesRenderCache *cache, qreal do // Index vertices const QList<QVector3D> indexed_vertices = dotObj->indexedvertices(); - int verticeCount = indexed_vertices.count(); + int verticeCount = indexed_vertices.size(); float itemSize = cache->itemSize() / itemScaler; if (itemSize == 0.0f) @@ -334,7 +310,7 @@ void ScatterObjectBufferHelper::update(ScatterSeriesRenderCache *cache, qreal do QList<QVector3D> scaled_vertices; scaled_vertices.resize(verticeCount); for (int i = 0; i < verticeCount; i++) - scaled_vertices[i] = indexed_vertices[i] * modelMatrix; + scaled_vertices[i] = (QVector4D(indexed_vertices[i]) * modelMatrix).toVector3D(); QList<QVector3D> buffered_vertices; buffered_vertices.resize(verticeCount * updateSize); @@ -356,9 +332,11 @@ void ScatterObjectBufferHelper::update(ScatterSeriesRenderCache *cache, qreal do modelMatrix = matrix.transposed(); modelMatrix.scale(modelScaler); - for (int j = 0; j < verticeCount; j++) - buffered_vertices[j + offset] = indexed_vertices[j] * modelMatrix + for (int j = 0; j < verticeCount; j++) { + buffered_vertices[j + offset] + = (QVector4D(indexed_vertices[j]) * modelMatrix).toVector3D() + item.translation(); + } } itemCount++; } @@ -386,4 +364,4 @@ void ScatterObjectBufferHelper::update(ScatterSeriesRenderCache *cache, qreal do m_meshDataLoaded = true; } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/scatterobjectbufferhelper_p.h b/src/datavisualization/utils/scatterobjectbufferhelper_p.h index fac5e922..5328e029 100644 --- a/src/datavisualization/utils/scatterobjectbufferhelper_p.h +++ b/src/datavisualization/utils/scatterobjectbufferhelper_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -44,7 +18,7 @@ #include "abstractobjecthelper_p.h" #include "scatterseriesrendercache_p.h" -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class ScatterObjectBufferHelper : public AbstractObjectHelper { @@ -63,8 +37,9 @@ private: const QList<QVector3D> &indexed_vertices); float m_scaleY; + static const GLfloat itemScaler; }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/scatterpointbufferhelper.cpp b/src/datavisualization/utils/scatterpointbufferhelper.cpp index d3621423..ccb5dd13 100644 --- a/src/datavisualization/utils/scatterpointbufferhelper.cpp +++ b/src/datavisualization/utils/scatterpointbufferhelper.cpp @@ -1,36 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "scatterpointbufferhelper_p.h" #include <QtGui/QVector2D> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE const QVector3D hiddenPos(-1000.0f, -1000.0f, -1000.0f); @@ -97,6 +71,7 @@ void ScatterPointBufferHelper::load(ScatterSeriesRenderCache *cache) m_bufferedPoints.clear(); m_pointbuffer = 0; m_uvbuffer = 0; + m_meshDataLoaded = false; } bool itemsVisible = false; @@ -215,4 +190,4 @@ void ScatterPointBufferHelper::createRangeGradientUVs(ScatterSeriesRenderCache * } } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/scatterpointbufferhelper_p.h b/src/datavisualization/utils/scatterpointbufferhelper_p.h index d1e8f5b0..ff19a36e 100644 --- a/src/datavisualization/utils/scatterpointbufferhelper_p.h +++ b/src/datavisualization/utils/scatterpointbufferhelper_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -44,7 +18,7 @@ #include "abstractobjecthelper_p.h" #include "scatterseriesrendercache_p.h" -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class ScatterPointBufferHelper : public AbstractObjectHelper { @@ -73,6 +47,6 @@ private: float m_scaleY; }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/shaderhelper.cpp b/src/datavisualization/utils/shaderhelper.cpp index ba029be2..7de9592d 100644 --- a/src/datavisualization/utils/shaderhelper.cpp +++ b/src/datavisualization/utils/shaderhelper.cpp @@ -1,37 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "shaderhelper_p.h" #include <QtOpenGL/QOpenGLShader> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE void discardDebugMsgs(QtMsgType type, const QMessageLogContext &context, const QString &msg) { @@ -113,7 +87,12 @@ void ShaderHelper::initialize() qFatal("Compiling Vertex shader failed"); if (!m_program->addShaderFromSourceFile(QOpenGLShader::Fragment, m_fragmentShaderFile)) qFatal("Compiling Fragment shader failed"); - m_program->link(); + + if (!m_program->link()) { + qWarning() << "Unable to link shader program:" << + m_vertexShaderFile << m_fragmentShaderFile; + return; + } m_positionAttr = m_program->attributeLocation("vertexPosition_mdl"); m_normalAttr = m_program->attributeLocation("vertexNormal_mdl"); @@ -416,4 +395,4 @@ GLint ShaderHelper::normalAtt() return m_normalAttr; } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/shaderhelper_p.h b/src/datavisualization/utils/shaderhelper_p.h index c4e4a717..93f861b2 100644 --- a/src/datavisualization/utils/shaderhelper_p.h +++ b/src/datavisualization/utils/shaderhelper_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -44,7 +18,7 @@ QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram) -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class ShaderHelper { @@ -146,6 +120,6 @@ class ShaderHelper GLboolean m_initialized; }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/surfaceobject.cpp b/src/datavisualization/utils/surfaceobject.cpp index 96a75422..30635e6c 100644 --- a/src/datavisualization/utils/surfaceobject.cpp +++ b/src/datavisualization/utils/surfaceobject.cpp @@ -1,38 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "surfaceobject_p.h" #include "surface3drenderer_p.h" #include <QtGui/QVector2D> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE SurfaceObject::SurfaceObject(Surface3DRenderer *renderer) : m_axisCacheX(renderer->m_axisCacheX), @@ -870,7 +844,8 @@ void SurfaceObject::getNormalizedVertex(const QSurfaceDataItem &data, QVector3D } float normalizedY = m_axisCacheY.positionAt(data.y()); m_minY = qMin(normalizedY, m_minY); - m_maxY = qMax(normalizedY, m_maxY); + if (!qIsNaN(normalizedY) && !qIsInf(normalizedY)) + m_maxY = qMax(normalizedY, m_maxY); vertex.setX(normalizedX); vertex.setY(normalizedY); vertex.setZ(normalizedZ); @@ -992,4 +967,4 @@ QVector3D SurfaceObject::normal(const QVector3D &a, const QVector3D &b, const QV return normal; } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/surfaceobject_p.h b/src/datavisualization/utils/surfaceobject_p.h index 532f7692..7a2b7241 100644 --- a/src/datavisualization/utils/surfaceobject_p.h +++ b/src/datavisualization/utils/surfaceobject_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -40,13 +14,13 @@ #ifndef SURFACEOBJECT_P_H #define SURFACEOBJECT_P_H -#include "datavisualizationglobal_p.h" #include "abstractobjecthelper_p.h" #include "qsurfacedataproxy.h" #include <QtCore/QRect> +#include <QtGui/QColor> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class Surface3DRenderer; class AxisRenderCache; @@ -88,13 +62,15 @@ public: void createCoarseGridlineIndices(int x, int y, int endX, int endY); void uploadBuffers(); GLuint gridElementBuf(); - GLuint uvBuf(); + GLuint uvBuf() override; GLuint gridIndexCount(); QVector3D vertexAt(int column, int row); void clear(); float minYValue() const { return m_minY; } float maxYValue() const { return m_maxY; } inline void activateSurfaceTexture(bool value) { m_returnTextureBuffer = value; } + inline void setLineColor(const QColor &color) { m_wireframeColor = color; } + inline const QColor &wireframeColor() const { return m_wireframeColor; } private: void createCoarseIndices(GLint *indices, int &p, int row, int upperRow, int j); @@ -129,8 +105,9 @@ private: bool m_returnTextureBuffer = false; SurfaceObject::DataDimensions m_dataDimension; SurfaceObject::DataDimensions m_oldDataDimension = DataDimensions(-1); + QColor m_wireframeColor; }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/texturehelper.cpp b/src/datavisualization/utils/texturehelper.cpp index 0e66459c..c892014a 100644 --- a/src/datavisualization/utils/texturehelper.cpp +++ b/src/datavisualization/utils/texturehelper.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "texturehelper_p.h" #include "utils_p.h" @@ -34,7 +8,7 @@ #include <QtGui/QPainter> #include <QtCore/QTime> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE // Defined in shaderhelper.cpp extern void discardDebugMsgs(QtMsgType type, const QMessageLogContext &context, const QString &msg); @@ -42,13 +16,12 @@ extern void discardDebugMsgs(QtMsgType type, const QMessageLogContext &context, TextureHelper::TextureHelper() { initializeOpenGLFunctions(); -#if !defined(QT_OPENGL_ES_2) +#if !QT_CONFIG(opengles2) if (!Utils::isOpenGLES()) { // Discard warnings about deprecated functions QtMessageHandler handler = qInstallMessageHandler(discardDebugMsgs); - m_openGlFunctions_2_1 = - QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_1>(); + m_openGlFunctions_2_1 = new QOpenGLFunctions_2_1; if (m_openGlFunctions_2_1) m_openGlFunctions_2_1->initializeOpenGLFunctions(); @@ -63,6 +36,9 @@ TextureHelper::TextureHelper() TextureHelper::~TextureHelper() { +#if !QT_CONFIG(opengles2) + delete m_openGlFunctions_2_1; +#endif } GLuint TextureHelper::create2DTexture(const QImage &image, bool useTrilinearFiltering, @@ -115,7 +91,7 @@ GLuint TextureHelper::create3DTexture(const QList<uchar> *data, int width, int h return 0; GLuint textureId = 0; -#if defined(QT_OPENGL_ES_2) +#if QT_CONFIG(opengles2) Q_UNUSED(dataFormat); Q_UNUSED(data); #else @@ -290,7 +266,7 @@ GLuint TextureHelper::createGradientTexture(const QLinearGradient &gradient) GLuint TextureHelper::createDepthTexture(const QSize &size, GLuint textureSize) { GLuint depthtextureid = 0; -#if defined(QT_OPENGL_ES_2) +#if QT_CONFIG(opengles2) Q_UNUSED(size); Q_UNUSED(textureSize); #else @@ -316,7 +292,7 @@ GLuint TextureHelper::createDepthTextureFrameBuffer(const QSize &size, GLuint &f GLuint textureSize) { GLuint depthtextureid = createDepthTexture(size, textureSize); -#if defined(QT_OPENGL_ES_2) +#if QT_CONFIG(opengles2) Q_UNUSED(frameBuffer); #else if (!Utils::isOpenGLES()) { @@ -328,7 +304,7 @@ GLuint TextureHelper::createDepthTextureFrameBuffer(const QSize &size, GLuint &f // Attach texture to depth attachment glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthtextureid, 0); - m_openGlFunctions_2_1->glDrawBuffer(GL_NONE); + m_openGlFunctions_2_1->glDrawBuffers(0, GL_NONE); m_openGlFunctions_2_1->glReadBuffer(GL_NONE); // Verify that the frame buffer is complete @@ -402,7 +378,7 @@ void TextureHelper::convertToGLFormatHelper(QImage &dstImage, const QImage &srcI const uint *p = (const uint*) srcImage.scanLine(srcImage.height() - 1); uint *q = (uint*) dstImage.scanLine(0); -#if !defined(QT_OPENGL_ES_2) +#if !QT_CONFIG(opengles2) if (texture_format == GL_BGRA) { #else if (texture_format == GL_BGRA8_EXT) { @@ -457,7 +433,7 @@ void TextureHelper::convertToGLFormatHelper(QImage &dstImage, const QImage &srcI QRgb TextureHelper::qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture_format) { -#if !defined(QT_OPENGL_ES_2) +#if !QT_CONFIG(opengles2) if (texture_format == GL_BGRA) { #else if (texture_format == GL_BGRA8_EXT) { @@ -481,4 +457,4 @@ QRgb TextureHelper::qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture } } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/texturehelper_p.h b/src/datavisualization/utils/texturehelper_p.h index fac32a42..f9baa272 100644 --- a/src/datavisualization/utils/texturehelper_p.h +++ b/src/datavisualization/utils/texturehelper_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -43,12 +17,12 @@ #include "datavisualizationglobal_p.h" #include <QtGui/QRgb> #include <QtGui/QLinearGradient> -#if !defined(QT_OPENGL_ES_2) +#if !QT_CONFIG(opengles2) // 3D Textures are not supported by ES set -# include <QtGui/QOpenGLFunctions_2_1> +# include <QtOpenGL/QOpenGLFunctions_2_1> #endif -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class TextureHelper : protected QOpenGLFunctions { @@ -77,8 +51,8 @@ class TextureHelper : protected QOpenGLFunctions void convertToGLFormatHelper(QImage &dstImage, const QImage &srcImage, GLenum texture_format); QRgb qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture_format); -#if !defined(QT_OPENGL_ES_2) - QOpenGLFunctions_2_1 *m_openGlFunctions_2_1; // Not owned +#if !QT_CONFIG(opengles2) + QOpenGLFunctions_2_1 *m_openGlFunctions_2_1 = nullptr; #endif friend class Bars3DRenderer; friend class Surface3DRenderer; @@ -86,6 +60,6 @@ class TextureHelper : protected QOpenGLFunctions friend class Abstract3DRenderer; }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index e80058db..3470c44d 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "utils_p.h" @@ -33,8 +7,10 @@ #include <QtGui/QOpenGLContext> #include <QtGui/QOffscreenSurface> #include <QtCore/QCoreApplication> +#include <QtCore/QRegularExpression> +#include <QLocale> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE #define NUM_IN_POWER(y, x) for (;y<x;y<<=1) #define MIN_POWER 2 @@ -217,24 +193,28 @@ QImage Utils::getGradientImage(QLinearGradient &gradient) Utils::ParamType Utils::preParseFormat(const QString &format, QString &preStr, QString &postStr, int &precision, char &formatSpec) { - static QRegExp formatMatcher(QStringLiteral("^([^%]*)%([\\-\\+#\\s\\d\\.lhjztL]*)([dicuoxfegXFEG])(.*)$")); - static QRegExp precisionMatcher(QStringLiteral("\\.(\\d+)")); + static QRegularExpression formatMatcher(QStringLiteral("^([^%]*)%([\\-\\+#\\s\\d\\.lhjztL]*)([dicuoxfegXFEG])(.*)$")); + static QRegularExpression precisionMatcher(QStringLiteral("\\.(\\d+)")); Utils::ParamType retVal; - if (formatMatcher.indexIn(format, 0) != -1) { - preStr = formatMatcher.cap(1); + QRegularExpressionMatch formatMatch = formatMatcher.match(format, 0); + + if (formatMatch.hasMatch()) { + preStr = formatMatch.captured(1); // Six and 'g' are defaults in Qt API precision = 6; - if (!formatMatcher.cap(2).isEmpty()) { - if (precisionMatcher.indexIn(formatMatcher.cap(2), 0) != -1) - precision = precisionMatcher.cap(1).toInt(); + if (!formatMatch.captured(2).isEmpty()) { + QRegularExpressionMatch precisionMatch = precisionMatcher.match(formatMatch.captured(2), + 0); + if (precisionMatch.hasMatch()) + precision = precisionMatch.captured(1).toInt(); } - if (formatMatcher.cap(3).isEmpty()) + if (formatMatch.captured(3).isEmpty()) formatSpec = 'g'; else - formatSpec = formatMatcher.cap(3).at(0).toLatin1(); - postStr = formatMatcher.cap(4); + formatSpec = formatMatch.captured(3).at(0).toLatin1(); + postStr = formatMatch.captured(4); retVal = mapFormatCharToParamType(formatSpec); } else { retVal = ParamTypeUnknown; @@ -350,7 +330,7 @@ void Utils::resolveStatics() ctx->makeCurrent(dummySurface); } -#if defined(QT_OPENGL_ES_2) +#if QT_CONFIG(opengles2) isES = true; #elif (QT_VERSION < QT_VERSION_CHECK(5, 3, 0)) isES = false; @@ -383,4 +363,4 @@ void Utils::resolveStatics() staticsResolved = true; } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/utils.pri b/src/datavisualization/utils/utils.pri deleted file mode 100644 index 904407b8..00000000 --- a/src/datavisualization/utils/utils.pri +++ /dev/null @@ -1,26 +0,0 @@ -HEADERS += $$PWD/meshloader_p.h \ - $$PWD/vertexindexer_p.h \ - $$PWD/camerahelper_p.h \ - $$PWD/shaderhelper_p.h \ - $$PWD/objecthelper_p.h \ - $$PWD/texturehelper_p.h \ - $$PWD/utils_p.h \ - $$PWD/abstractobjecthelper_p.h \ - $$PWD/surfaceobject_p.h \ - $$PWD/qutils.h \ - $$PWD/scatterobjectbufferhelper_p.h \ - $$PWD/scatterpointbufferhelper_p.h - -SOURCES += $$PWD/meshloader.cpp \ - $$PWD/vertexindexer.cpp \ - $$PWD/camerahelper.cpp \ - $$PWD/shaderhelper.cpp \ - $$PWD/objecthelper.cpp \ - $$PWD/texturehelper.cpp \ - $$PWD/utils.cpp \ - $$PWD/abstractobjecthelper.cpp \ - $$PWD/surfaceobject.cpp \ - $$PWD/scatterobjectbufferhelper.cpp \ - $$PWD/scatterpointbufferhelper.cpp - -INCLUDEPATH += $$PWD diff --git a/src/datavisualization/utils/utils_p.h b/src/datavisualization/utils/utils_p.h index 08f036c8..06c98407 100644 --- a/src/datavisualization/utils/utils_p.h +++ b/src/datavisualization/utils/utils_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -44,7 +18,7 @@ QT_FORWARD_DECLARE_CLASS(QLinearGradient) -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class Utils { @@ -87,6 +61,6 @@ private: static ParamType mapFormatCharToParamType(char formatSpec); }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif diff --git a/src/datavisualization/utils/vertexindexer.cpp b/src/datavisualization/utils/vertexindexer.cpp index 5b770366..65316c63 100644 --- a/src/datavisualization/utils/vertexindexer.cpp +++ b/src/datavisualization/utils/vertexindexer.cpp @@ -1,37 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "vertexindexer_p.h" #include <QtCore/qmath.h> +#include <QtCore/qmap.h> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE int unique_vertices = 0; @@ -78,4 +53,4 @@ void VertexIndexer::indexVBO(const QList<QVector3D> &in_vertices, const QList<QV } } -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE diff --git a/src/datavisualization/utils/vertexindexer_p.h b/src/datavisualization/utils/vertexindexer_p.h index 42a48465..e7f0f775 100644 --- a/src/datavisualization/utils/vertexindexer_p.h +++ b/src/datavisualization/utils/vertexindexer_p.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // // W A R N I N G @@ -45,7 +19,7 @@ #include <QtCore/QList> #include <QtGui/QVector2D> -QT_BEGIN_NAMESPACE_DATAVISUALIZATION +QT_BEGIN_NAMESPACE class VertexIndexer { @@ -70,6 +44,6 @@ private: GLuint &result); }; -QT_END_NAMESPACE_DATAVISUALIZATION +QT_END_NAMESPACE #endif |