Add a quick3dinput subproject

Will allow to create the QML specific extension classes

Change-Id: I9075d77e6ae73c63fd60eef3ca400eb110e3b9dd
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
Paul Lemire 2015-11-27 12:09:10 +01:00
parent e3fca06413
commit 9c726452eb
9 changed files with 402 additions and 0 deletions

View File

@ -0,0 +1,5 @@
SOURCES +=
HEADERS +=
INCLUDEPATH += $$PWD

View File

@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qt3dquickinput_global_p.h"
#include "qt3dquickinputnodefactory_p.h"
QT_BEGIN_NAMESPACE
namespace Qt3DInput {
namespace Quick {
void Quick3DInput_initialize()
{
Qt3DCore::QAbstractNodeFactory::registerNodeFactory(QuickInputNodeFactory::instance());
}
void Quick3DInput_registerType(const char *className, const char *quickName, int major, int minor)
{
QuickInputNodeFactory::instance()->registerType(className, quickName, major, minor);
}
} // namespace Quick
} // namespace Qt3DInput
QT_END_NAMESPACE

View File

@ -0,0 +1,56 @@
/****************************************************************************
**
** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QT3DQUICKINPUT_GLOBAL_H
#define QT3DQUICKINPUT_GLOBAL_H
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
#if defined(QT_SHARED) || !defined(QT_STATIC)
# if defined(QT3DQUICKINPUT_LIBRARY)
# define QT3DQUICKINPUTSHARED_EXPORT Q_DECL_EXPORT
# else
# define QT3DQUICKINPUTSHARED_EXPORT Q_DECL_IMPORT
# endif
#else
# define QT3DQUICKINPUTSHARED_EXPORT
#endif
QT_END_NAMESPACE
#endif // QT3DQUICKINPUT_GLOBAL_H

View File

@ -0,0 +1,85 @@
/****************************************************************************
**
** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QT3DQUICKINPUT_GLOBAL_P_H
#define QT3DQUICKINPUT_GLOBAL_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <Qt3DQuickInput/qt3dquickinput_global.h>
#include <QtQml/qqml.h>
#define QT3DQUICKINPUTSHARED_PRIVATE_EXPORT QT3DQUICKINPUTSHARED_EXPORT
QT_BEGIN_NAMESPACE
namespace Qt3DInput {
namespace Quick {
QT3DQUICKINPUTSHARED_PRIVATE_EXPORT void Quick3DInput_initialize();
QT3DQUICKINPUTSHARED_PRIVATE_EXPORT void Quick3DInput_registerType(const char *className, const char *quickName, int major, int minor);
template<class T, class E> void registerExtendedType(const char *className, const char *quickName,
const char *uri, int major, int minor, const char *name)
{
qmlRegisterExtendedType<T, E>(uri, major, minor, name);
Quick3DInput_registerType(className, quickName, major, minor);
}
template<class T> void registerType(const char *className, const char *quickName,
const char *uri, int major, int minor, const char *name)
{
qmlRegisterType<T>(uri, major, minor, name);
Quick3DInput_registerType(className, quickName, major, minor);
}
} // Quick
} // Qt3D
QT_END_NAMESPACE
#endif // QT3DQUICKINPUT_GLOBAL_P_H

View File

@ -0,0 +1,73 @@
/****************************************************************************
**
** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qt3dquickinputnodefactory_p.h"
#include <QtQml/private/qqmlmetatype_p.h>
QT_BEGIN_NAMESPACE
namespace Qt3DInput {
Q_GLOBAL_STATIC(QuickInputNodeFactory, quick_Input_node_factory)
QuickInputNodeFactory *QuickInputNodeFactory::instance()
{
return quick_Input_node_factory();
}
void QuickInputNodeFactory::registerType(const char *className, const char *quickName, int major, int minor)
{
m_types.insert(className, Type(quickName, major, minor));
}
Qt3DCore::QNode *QuickInputNodeFactory::createNode(const char *type)
{
if (!m_types.contains(type))
return Q_NULLPTR;
Type &typeInfo(m_types[type]);
if (!typeInfo.resolved) {
typeInfo.resolved = true;
typeInfo.t = QQmlMetaType::qmlType(QString::fromLatin1(typeInfo.quickName), typeInfo.version.first, typeInfo.version.second);
}
return typeInfo.t ? qobject_cast<Qt3DCore::QNode *>(typeInfo.t->create()) : Q_NULLPTR;
}
} // namespace Qt3DInput
QT_END_NAMESPACE

View File

@ -0,0 +1,86 @@
/****************************************************************************
**
** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QUICKINPUTNODEFACTORY_H
#define QUICKINPUTNODEFACTORY_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <Qt3DCore/qabstractnodefactory.h>
#include <QtCore/qhash.h>
QT_BEGIN_NAMESPACE
class QQmlType;
namespace Qt3DInput {
class QuickInputNodeFactory : public Qt3DCore::QAbstractNodeFactory
{
public:
Qt3DCore::QNode *createNode(const char *type) Q_DECL_OVERRIDE;
void registerType(const char *className, const char *quickName, int major, int minor);
static QuickInputNodeFactory *instance();
private:
struct Type {
Type() : t(Q_NULLPTR), resolved(false) { }
Type(const char *quickName, int major, int minor)
: quickName(quickName), version(major, minor), t(Q_NULLPTR), resolved(false) { }
QByteArray quickName;
QPair<int, int> version;
QQmlType *t;
bool resolved;
};
QHash<QByteArray, Type> m_types;
};
} // namespace Qt3DInput
QT_END_NAMESPACE
#endif // QUICKINPUTNODEFACTORY_H

View File

@ -0,0 +1,34 @@
TARGET = Qt3DQuickInput
QT += core core-private qml qml-private 3dcore 3dinput 3dquick 3dquick-private 3dcore-private 3dinput-private
CONFIG -= precompile_header
DEFINES += QT3DQUICKINPUT_LIBRARY
MODULE = 3dquickinput
load(qt_module)
gcov {
CONFIG += static
QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage
}
SOURCES += \
qt3dquickinput_global.cpp \
qt3dquickinputnodefactory.cpp
HEADERS += \
qt3dquickinput_global_p.h \
qt3dquickinput_global.h \
qt3dquickinputnodefactory_p.h
!contains(QT_CONFIG, egl):DEFINES += QT_NO_EGL
# otherwise mingw headers do not declare common functions like ::strcasecmp
win32-g++*:QMAKE_CXXFLAGS_CXX11 = -std=gnu++0x
include(./items/items.pri)

View File

@ -24,6 +24,9 @@ src_quick3d_render.subdir = $$PWD/quick3d/quick3drender
src_quick3d_render.target = sub-quick3d-render
src_quick3d_render.depends = src_render src_quick3d_core
src_quick3d_input.subdir = $$PWD/quick3d/quick3dinput
src_quick3d_input.target = sub-quick3d-input
src_quick3d_input.depends = src_input src_quick3d_core
# Quick3D imports
src_quick3d_core_imports.file = $$PWD/quick3d/imports/core/importscore.pro
@ -59,6 +62,7 @@ SUBDIRS += \
src_quick3d_core \
src_quick3d_core_imports \
src_quick3d_render \
src_quick3d_input \
src_quick3d_imports_render \
src_quick3d_imports_scene3d \
src_quick3d_imports_input \

View File

@ -4,6 +4,7 @@
"Qt3DQuick" => "$basedir/src/quick3d/quick3d",
"Qt3DQuickRender" => "$basedir/src/quick3d/quick3drender",
"Qt3DInput" => "$basedir/src/input",
"Qt3DQuickInput" => "$basedir/src/quick3d/quick3dinput",
"Qt3DLogic" => "$basedir/src/logic",
);
%moduleheaders = ( # restrict the module headers to those found in relative path