diff options
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d')
15 files changed, 293 insertions, 16 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp index 9c81fdc970..0fbc28c6b5 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp @@ -51,6 +51,19 @@ CameraGeometry::~CameraGeometry() { } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString CameraGeometry::name() const +{ + return objectName(); +} + +void CameraGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + QQuick3DCamera *CameraGeometry::camera() const { return m_camera; @@ -173,13 +186,16 @@ void CameraGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexDat QMatrix4x4 m; QSSGRenderCamera *camera = m_camera->cameraNode(); if (camera) { + QRectF rect = m_viewPortRect; + if (rect.isNull()) + rect = QRectF(0, 0, 1000, 1000); // Let's have some visualization for null viewports if (qobject_cast<QQuick3DOrthographicCamera *>(m_camera)) { // For some reason ortho cameras show double what projection suggests, // so give them doubled viewport to match visualization to actual camera view - camera->calculateGlobalVariables(QRectF(0, 0, m_viewPortRect.width() * 2.0, - m_viewPortRect.height() * 2.0)); + camera->calculateGlobalVariables(QRectF(0, 0, rect.width() * 2.0, + rect.height() * 2.0)); } else { - camera->calculateGlobalVariables(m_viewPortRect); + camera->calculateGlobalVariables(rect); } m = camera->projection.inverted(); } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h index 73722cd7a1..55d31ca389 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h @@ -39,6 +39,17 @@ class CameraGeometry : public QQuick3DGeometry Q_PROPERTY(QQuick3DCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged) Q_PROPERTY(QRectF viewPortRect READ viewPortRect WRITE setViewPortRect NOTIFY viewPortRectChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: CameraGeometry(); ~CameraGeometry() override; @@ -46,12 +57,12 @@ public: QQuick3DCamera *camera() const; QRectF viewPortRect() const; -public Q_SLOTS: +public slots: void setCamera(QQuick3DCamera *camera); void setViewPortRect(const QRectF &rect); void handleCameraPropertyChange(); -Q_SIGNALS: +signals: void cameraChanged(); void viewPortRectChanged(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri index 755aef73e2..bcfbc5e12e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri @@ -15,3 +15,8 @@ SOURCES += $$PWD/generalhelper.cpp \ $$PWD/selectionboxgeometry.cpp \ $$PWD/linegeometry.cpp \ $$PWD/icongizmoimageprovider.cpp + +versionAtLeast(QT_VERSION, 6.0.0) { + HEADERS += $$PWD/qt5compat/qquick3darealight_p.h + SOURCES += $$PWD/qt5compat/qquick3darealight.cpp +} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp index afa02625d4..6222c84ce7 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp @@ -36,6 +36,7 @@ #include <QtQuick3D/private/qquick3dmodel_p.h> #include <QtQuick3D/private/qquick3dviewport_p.h> #include <QtQuick3D/private/qquick3ddefaultmaterial_p.h> +#include <QtQuick3D/private/qquick3dscenemanager_p.h> #include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h> #include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h> #include <QtQuick3DRuntimeRender/private/qssgrendermodel_p.h> @@ -166,7 +167,12 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau if (auto renderModel = static_cast<QSSGRenderModel *>(targetPriv->spatialNode)) { QWindow *window = static_cast<QWindow *>(viewPort->window()); if (window) { - auto context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); + QSSGRef<QSSGRenderContextInterface> context; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); +#else + context = targetPriv->sceneManager->rci; +#endif if (!context.isNull()) { QSSGBounds3 bounds; auto geometry = qobject_cast<SelectionBoxGeometry *>(modelNode->geometry()); @@ -297,6 +303,16 @@ QString GeneralHelper::rootSizeKey() const return _rootSizeKey; } +double GeneralHelper::brightnessScaler() const +{ + // Light brightness was rescaled in Qt6 from 100 -> 1. +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + return 100.; +#else + return 1.; +#endif +} + bool GeneralHelper::isMacOS() const { #ifdef Q_OS_MACOS diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h index 92893cc546..f162eb0d30 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h @@ -31,6 +31,7 @@ #include <QtCore/qtimer.h> #include <QtCore/qhash.h> #include <QtCore/qpointer.h> +#include <QtCore/qvariant.h> #include <QtGui/qvector3d.h> #include <QtGui/qmatrix4x4.h> @@ -82,6 +83,8 @@ public: QString lastSceneIdKey() const; QString rootSizeKey() const; + Q_INVOKABLE double brightnessScaler() const; + bool isMacOS() const; signals: diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp index 4b548239ca..66a2a6b2a5 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp @@ -41,6 +41,19 @@ GridGeometry::~GridGeometry() { } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString GridGeometry::name() const +{ + return objectName(); +} + +void GridGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + int GridGeometry::lines() const { return m_lines; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h index 50b41288e2..6074fb4245 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h @@ -41,6 +41,17 @@ class GridGeometry : public QQuick3DGeometry Q_PROPERTY(bool isCenterLine READ isCenterLine WRITE setIsCenterLine NOTIFY isCenterLineChanged) Q_PROPERTY(bool isSubdivision MEMBER m_isSubdivision) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: GridGeometry(); ~GridGeometry() override; @@ -49,12 +60,12 @@ public: float step() const; bool isCenterLine() const; -public Q_SLOTS: +public slots: void setLines(int count); void setStep(float step); void setIsCenterLine(bool enabled); -Q_SIGNALS: +signals: void linesChanged(); void stepChanged(); void isCenterLineChanged(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp index cebf3232f1..2facb77139 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp @@ -45,6 +45,19 @@ LightGeometry::~LightGeometry() { } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString LightGeometry::name() const +{ + return objectName(); +} + +void LightGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + LightGeometry::LightType LightGeometry::lightType() const { return m_lightType; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h index cac375d675..e9ba718218 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h @@ -37,6 +37,17 @@ class LightGeometry : public QQuick3DGeometry Q_OBJECT Q_PROPERTY(LightType lightType READ lightType WRITE setLightType NOTIFY lightTypeChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: enum class LightType { Invalid, @@ -52,10 +63,10 @@ public: LightType lightType() const; -public Q_SLOTS: +public slots: void setLightType(LightType lightType); -Q_SIGNALS: +signals: void lightTypeChanged(); protected: diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp index cd2e890f86..5b6110d2af 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp @@ -41,6 +41,19 @@ LineGeometry::~LineGeometry() { } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString LineGeometry::name() const +{ + return objectName(); +} + +void LineGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + QVector3D LineGeometry::startPos() const { return m_startPos; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h index 2e87ff8748..df83f89b25 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h @@ -39,6 +39,17 @@ class LineGeometry : public QQuick3DGeometry Q_PROPERTY(QVector3D startPos READ startPos WRITE setStartPos NOTIFY startPosChanged) Q_PROPERTY(QVector3D endPos READ endPos WRITE setEndPos NOTIFY endPosChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: LineGeometry(); ~LineGeometry() override; @@ -46,11 +57,11 @@ public: QVector3D startPos() const; QVector3D endPos() const; -public Q_SLOTS: +public slots: void setStartPos(const QVector3D &pos); void setEndPos(const QVector3D &pos); -Q_SIGNALS: +signals: void startPosChanged(); void endPosChanged(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp new file mode 100644 index 0000000000..6fcbdcb89e --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** 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 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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. +** +****************************************************************************/ + +#ifdef QUICK3D_MODULE + +#include "qquick3darealight_p.h" +#include <QtQuick3D/private/qquick3dobject_p.h> + +#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h> + +namespace QmlDesigner::Internal { + +float QQuick3DAreaLight::width() const +{ + return m_width; +} + +float QQuick3DAreaLight::height() const +{ + return m_height; +} + +void QQuick3DAreaLight::setWidth(float width) +{ + m_width = width; + emit widthChanged(); +} + +void QQuick3DAreaLight::setHeight(float height) +{ + m_height = height; + emit heightChanged(); +} + +} + +#endif diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h new file mode 100644 index 0000000000..8db5487960 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** 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 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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. +** +****************************************************************************/ + +#pragma once + +#ifdef QUICK3D_MODULE + +// This is a dummy class for Qt 5 compatibility purposes only + +#include <QtQuick3D/private/qquick3dabstractlight_p.h> + +namespace QmlDesigner::Internal { + +class QQuick3DAreaLight : public QQuick3DAbstractLight +{ + Q_OBJECT + Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged) + +public: + QQuick3DAreaLight() : QQuick3DAbstractLight() {} + ~QQuick3DAreaLight() override {} + + float width() const; + float height() const; + +public slots: + void setWidth(float width); + void setHeight(float height); + +signals: + void widthChanged(); + void heightChanged(); + +private: + float m_width = 100.0f; + float m_height = 100.0f; +}; + +} + +QML_DECLARE_TYPE(QmlDesigner::Internal::QQuick3DAreaLight) + +#endif diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp index 621508c499..1e1fe8937c 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp @@ -32,6 +32,7 @@ #include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h> #include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h> #include <QtQuick3D/private/qquick3dmodel_p.h> +#include <QtQuick3D/private/qquick3dscenemanager_p.h> #include <QtQuick3D/qquick3dobject.h> #include <QtQuick/qquickwindow.h> #include <QtCore/qvector.h> @@ -59,6 +60,19 @@ SelectionBoxGeometry::~SelectionBoxGeometry() m_connections.clear(); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +QString SelectionBoxGeometry::name() const +{ + return objectName(); +} + +void SelectionBoxGeometry::setName(const QString &name) +{ + setObjectName(name); + emit nameChanged(); +} +#endif + QQuick3DNode *SelectionBoxGeometry::targetNode() const { return m_targetNode; @@ -291,8 +305,12 @@ void SelectionBoxGeometry::getBounds( if (auto renderModel = static_cast<QSSGRenderModel *>(renderNode)) { QWindow *window = static_cast<QWindow *>(m_view3D->window()); if (window) { - auto context = QSSGRenderContextInterface::getRenderContextInterface( - quintptr(window)); + QSSGRef<QSSGRenderContextInterface> context; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); +#else + context = QQuick3DObjectPrivate::get(this)->sceneManager->rci; +#endif if (!context.isNull()) { auto bufferManager = context->bufferManager(); QSSGBounds3 bounds = renderModel->getModelBounds(bufferManager); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h index 6cf9a153c2..947ef7d54a 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h @@ -43,6 +43,17 @@ class SelectionBoxGeometry : public QQuick3DGeometry Q_PROPERTY(QQuick3DViewport *view3D READ view3D WRITE setView3D NOTIFY view3DChanged) Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + // Name property was removed in Qt 6, so define it here for compatibility. + // Name maps to object name. + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +public: + QString name() const; + void setName(const QString &name); +signals: + void nameChanged(); +#endif + public: SelectionBoxGeometry(); ~SelectionBoxGeometry() override; @@ -54,12 +65,12 @@ public: QSSGBounds3 bounds() const; -public Q_SLOTS: +public slots: void setTargetNode(QQuick3DNode *targetNode); void setRootNode(QQuick3DNode *rootNode); void setView3D(QQuick3DViewport *view); -Q_SIGNALS: +signals: void targetNodeChanged(); void rootNodeChanged(); void view3DChanged(); |