summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/abstract3drenderer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/engine/abstract3drenderer.cpp')
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp83
1 files changed, 44 insertions, 39 deletions
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index ef77dc92..a39a6079 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -1,31 +1,7 @@
-/****************************************************************************
-**
-** 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
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include "abstract3drenderer_p.h"
#include "texturehelper_p.h"
@@ -42,7 +18,7 @@
#include <QtGui/QOffscreenSurface>
#include <QtCore/QThread>
-QT_BEGIN_NAMESPACE_DATAVISUALIZATION
+QT_BEGIN_NAMESPACE
// Defined in shaderhelper.cpp
extern void discardDebugMsgs(QtMsgType type, const QMessageLogContext &context, const QString &msg);
@@ -118,7 +94,7 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
m_oldCameraTarget(QVector3D(2000.0f, 2000.0f, 2000.0f)), // Just random invalid target
m_reflectionEnabled(false),
m_reflectivity(0.5),
-#if !defined(QT_OPENGL_ES_2)
+#if !QT_CONFIG(opengles2)
m_funcs_2_1(0),
#endif
m_context(0),
@@ -127,12 +103,12 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
{
initializeOpenGLFunctions();
m_isOpenGLES = Utils::isOpenGLES();
-#if !defined(QT_OPENGL_ES_2)
+#if !QT_CONFIG(opengles2)
if (!m_isOpenGLES) {
// Discard warnings about deprecated functions
QtMessageHandler handler = qInstallMessageHandler(discardDebugMsgs);
- m_funcs_2_1 = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_1>();
+ m_funcs_2_1 = new QOpenGLFunctions_2_1;
if (m_funcs_2_1)
m_funcs_2_1->initializeOpenGLFunctions();
@@ -192,6 +168,10 @@ Abstract3DRenderer::~Abstract3DRenderer()
m_axisCacheX.clearLabels();
m_axisCacheY.clearLabels();
m_axisCacheZ.clearLabels();
+
+#if !QT_CONFIG(opengles2)
+ delete m_funcs_2_1;
+#endif
}
void Abstract3DRenderer::contextCleanup()
@@ -210,7 +190,7 @@ void Abstract3DRenderer::initializeOpenGL()
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
-#if !defined(QT_OPENGL_ES_2)
+#if !QT_CONFIG(opengles2)
if (!m_isOpenGLES) {
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
@@ -745,8 +725,10 @@ void Abstract3DRenderer::updateCustomData(const QList<QCustom3DItem *> &customIt
CustomRenderItem *renderItem = m_customRenderCache.value(item);
if (!renderItem)
renderItem = addCustomItem(item);
- renderItem->setValid(true);
- renderItem->setIndex(i); // always update index, as it must match the custom item index
+ if (renderItem) {
+ renderItem->setValid(true);
+ renderItem->setIndex(i); // always update index, as it must match the custom item index
+ }
}
// Check render item cache and remove items that are not in customItems list anymore
@@ -937,12 +919,27 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
xRotation = -90.0f - labelRotation.z();
extraRotation = -extraRotation;
}
+ if (m_yFlipped) {
+ alignment = Qt::AlignBottom;
+ extraRotation = -extraRotation;
+ if (m_xFlipped)
+ xRotation = 90.0f + labelRotation.z();
+ else
+ xRotation = 90.0f - labelRotation.z();
+ }
} else {
if (m_xFlipped) {
offsetRotation = -offsetRotation;
xRotation = -90.0f - labelRotation.z();
extraRotation = -extraRotation;
}
+ if (m_yFlipped) {
+ xRotation = 90.0f + labelRotation.z();
+ alignment = Qt::AlignBottom;
+ extraRotation = -extraRotation;
+ if (m_xFlipped)
+ xRotation = 90.0f - labelRotation.z();
+ }
}
}
@@ -1034,6 +1031,11 @@ void Abstract3DRenderer::drawAxisTitleZ(const QVector3D &labelRotation,
yRotation = -yRotation;
}
}
+ if (m_yFlipped) {
+ xRotation = -xRotation;
+ alignment = Qt::AlignBottom;
+ extraRotation = -extraRotation;
+ }
}
float offsetRotation = zRotation;
@@ -1129,7 +1131,10 @@ CustomRenderItem *Abstract3DRenderer::addCustomItem(QCustom3DItem *item)
CustomRenderItem *newItem = new CustomRenderItem();
newItem->setRenderer(this);
newItem->setItemPointer(item); // Store pointer for render item updates
- newItem->setMesh(item->meshFile());
+ if (!newItem->setMesh(item->meshFile())) {
+ delete newItem;
+ return nullptr;
+ }
newItem->setOrigPosition(item->position());
newItem->setOrigScaling(item->scaling());
newItem->setScalingAbsolute(item->isScalingAbsolute());
@@ -1442,7 +1447,7 @@ void Abstract3DRenderer::drawCustomItems(RenderingState state,
bool volumeDetected = false;
int loopCount = 0;
while (loopCount < 2) {
- for (QCustom3DItem *customItem : qAsConst(m_customItemDrawOrder)) {
+ for (QCustom3DItem *customItem : std::as_const(m_customItemDrawOrder)) {
CustomRenderItem *item = m_customRenderCache.value(customItem);
// Check that the render item is visible, and skip drawing if not
// Also check if reflected item is on the "wrong" side, and skip drawing if it is
@@ -1633,7 +1638,7 @@ void Abstract3DRenderer::drawCustomItems(RenderingState state,
m_drawer->drawObject(shader, item->mesh(), item->texture());
}
}
- } else if (RenderingSelection == state) {
+ } else if (RenderingSelection == state && !volumeDetected) {
// Selection render
shader->setUniformValue(shader->MVP(), MVPMatrix);
QVector4D itemColor = indexToSelectionColor(item->index());
@@ -1991,4 +1996,4 @@ void Abstract3DRenderer::updateCameraViewport()
}
}
-QT_END_NAMESPACE_DATAVISUALIZATION
+QT_END_NAMESPACE