summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/06-qml-reference/DataInput.qdoc57
-rw-r--r--doc/src/06-qml-reference/Presentation.qdoc7
-rw-r--r--doc/src/06-qml-reference/Studio3D.qdoc4
-rw-r--r--doc/src/12-cpp-reference/Q3DSDataInput.qdoc81
-rw-r--r--doc/src/12-cpp-reference/Q3DSPresentation.qdoc30
-rw-r--r--doc/src/examples-index.qdoc1
-rw-r--r--examples/studio3d/qmldatainput/doc/images/qml-datainput.jpgbin0 -> 17480 bytes
-rw-r--r--examples/studio3d/qmldatainput/doc/src/qmldatainput.qdoc53
-rw-r--r--examples/studio3d/qmldatainput/main.cpp103
-rw-r--r--examples/studio3d/qmldatainput/presentation/datainput.uia16
-rw-r--r--examples/studio3d/qmldatainput/presentation/datainput.uip35
-rw-r--r--examples/studio3d/qmldatainput/presentation/fonts/TitilliumWeb-Regular.ttfbin0 -> 63752 bytes
-rw-r--r--examples/studio3d/qmldatainput/qml/qmldatainput/main.qml101
-rw-r--r--examples/studio3d/qmldatainput/qmldatainput.pro21
-rw-r--r--examples/studio3d/qmldatainput/qmldatainput.qrc6
-rw-r--r--examples/studio3d/studio3d.pro3
-rw-r--r--src/Runtime/Source/Engine/Include/Qt3DSTegraApplication.h5
-rw-r--r--src/Runtime/Source/Engine/Source/Qt3DSTegraApplication.cpp19
-rw-r--r--src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp8
-rw-r--r--src/Runtime/Source/Viewer/Qt3DSViewerApp.h2
-rw-r--r--src/Viewer/qmlviewer/Qt3DSRenderer.cpp3
-rw-r--r--src/Viewer/qmlviewer/Qt3DSViewPlugin.cpp4
-rw-r--r--src/Viewer/qmlviewer/q3dspresentationitem.cpp18
-rw-r--r--src/Viewer/qmlviewer/q3dspresentationitem.h3
-rw-r--r--src/Viewer/studio3d/q3dscommandqueue.cpp1
-rw-r--r--src/Viewer/studio3d/q3dscommandqueue_p.h1
-rw-r--r--src/Viewer/studio3d/q3dsdatainput.cpp137
-rw-r--r--src/Viewer/studio3d/q3dsdatainput.h82
-rw-r--r--src/Viewer/studio3d/q3dsdatainput_p.h74
-rw-r--r--src/Viewer/studio3d/q3dspresentation.cpp90
-rw-r--r--src/Viewer/studio3d/q3dspresentation.h6
-rw-r--r--src/Viewer/studio3d/q3dspresentation_p.h6
-rw-r--r--src/Viewer/studio3d/studio3d.pri7
-rw-r--r--tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp21
-rw-r--r--tests/auto/studio3d/shared/presentation/datainput.uip31
-rw-r--r--tests/auto/studio3d/shared/shared_presentations.h1
-rw-r--r--tests/auto/studio3d/shared/shared_presentations.qrc1
37 files changed, 1024 insertions, 14 deletions
diff --git a/doc/src/06-qml-reference/DataInput.qdoc b/doc/src/06-qml-reference/DataInput.qdoc
new file mode 100644
index 00000000..124c1588
--- /dev/null
+++ b/doc/src/06-qml-reference/DataInput.qdoc
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmltype DataInput
+ \inqmlmodule QtStudio3D
+ \brief Control type for data inputs in a Qt 3D Studio presentation.
+ \since QtStudio3D 1.1
+
+ This type is a convenience type for controlling a data input in a presentation.
+
+ \sa Studio3D, Presentation
+*/
+
+/*!
+ \qmlproperty string DataInput::name
+
+ Specifies the name of the controlled data input element in the presentation.
+ This property must be set as part of DataInput declaration.
+*/
+
+/*!
+ \qmlproperty variant DataInput::value
+
+ Specifies the value of the controlled data input element in the presentation.
+ The changes to the value property are queued and handled asynchronously before the
+ next frame is displayed.
+
+ The value of this property only accounts for changes done via the same DataInput instance.
+ If the value of the same data input in the presentation is changed elsewhere,
+ for example via presentation scripting, those changes are not reflected in
+ the value of this property.
+*/
diff --git a/doc/src/06-qml-reference/Presentation.qdoc b/doc/src/06-qml-reference/Presentation.qdoc
index 606c90b0..77a2262e 100644
--- a/doc/src/06-qml-reference/Presentation.qdoc
+++ b/doc/src/06-qml-reference/Presentation.qdoc
@@ -167,6 +167,13 @@
*/
/*!
+ \qmlmethod void Presentation::setDataInputValue(string name, variant value)
+ \since QtStudio3D 1.1
+
+ Sets the \a value of a data input element \a name in the presentation.
+*/
+
+/*!
\qmlsignal Presentation::slideEntered(string elementPath, int index, string name)
This signal is emitted when a slide is entered in the presentation.
diff --git a/doc/src/06-qml-reference/Studio3D.qdoc b/doc/src/06-qml-reference/Studio3D.qdoc
index 48757f27..07fbbd67 100644
--- a/doc/src/06-qml-reference/Studio3D.qdoc
+++ b/doc/src/06-qml-reference/Studio3D.qdoc
@@ -105,8 +105,8 @@
*/
/*!
- \qmlsignal bool Studio3D::presentationReady
- \since 1.1
+ \qmlsignal Studio3D::presentationReady()
+ \since QtStudio3D 1.1
This signal is emitted when the viewer has been initialized and the presentation is ready to
be shown. The difference to \c running property is that the viewer has to be visible for
diff --git a/doc/src/12-cpp-reference/Q3DSDataInput.qdoc b/doc/src/12-cpp-reference/Q3DSDataInput.qdoc
new file mode 100644
index 00000000..a16bdc0a
--- /dev/null
+++ b/doc/src/12-cpp-reference/Q3DSDataInput.qdoc
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class Q3DSDataInput
+ \inheaderfile q3dsdatainput.h
+ \inmodule QtStudio3D
+ \since QtStudio3D 1.1
+ \brief Control class for data inputs in a Qt 3D Studio presentation.
+
+ This class is a convenience class for controlling a data input in a presentation.
+
+ \sa Q3DSPresentation
+*/
+
+/*!
+ \fn Q3DSDataInput::Q3DSDataInput(const QString &name, QObject *parent = nullptr)
+
+ Constructs a Q3DSDataInput instance and initializes the \a name.
+ An optional \a parent object can be specified.
+*/
+
+/*!
+ \fn Q3DSDataInput::Q3DSDataInput(Q3DSPresentation *presentation, const QString &name,
+ QObject *parent = nullptr)
+
+ Constructs a Q3DSDataInput instance and initializes the \a name.
+ The constructed instance is automatically \l{Q3DSPresentation::registerDataInput}{registered}
+ for the \a presentation.
+ An optional \a parent object can be specified.
+*/
+
+/*!
+ \fn Q3DSDataInput::Q3DSDataInput(Q3DSDataInputPrivate *d, Q3DSPresentation *presentation,
+ const QString &name, QObject *parent = nullptr)
+ \internal
+*/
+
+/*!
+ \property Q3DSDataInput::name
+
+ Specifies the name of the controlled data input element in the presentation.
+ This property must be set before the data input is registered to a presentation.
+
+ \sa Q3DSPresentation::registerDataInput()
+*/
+
+/*!
+ \property Q3DSDataInput::value
+
+ Specifies the value of the controlled data input element in the presentation.
+
+ The value of this property only accounts for changes done via the same Q3DSDataInput instance.
+ If the value of the same data input in the presentation is changed elsewhere,
+ for example via presentation scripting, those changes are not reflected in
+ the value of this property.
+*/
diff --git a/doc/src/12-cpp-reference/Q3DSPresentation.qdoc b/doc/src/12-cpp-reference/Q3DSPresentation.qdoc
index 02fa7a55..12b45acd 100644
--- a/doc/src/12-cpp-reference/Q3DSPresentation.qdoc
+++ b/doc/src/12-cpp-reference/Q3DSPresentation.qdoc
@@ -79,6 +79,29 @@
*/
/*!
+ \fn void Q3DSPresentation::registerDataInput(Q3DSDataInput *dataInput)
+
+ \since QtStudio3D 1.1
+ Registers a \a dataInput for the presentation. The registered \a dataInput can be used to manage
+ the corresponding data input in the presentation.
+*/
+
+/*!
+ \fn void Q3DSPresentation::unregisterDataInput(Q3DSDataInput *dataInput)
+ \since QtStudio3D 1.1
+
+ Unregisters a \a dataInput from the presentation.
+*/
+
+/*!
+ \fn Q3DSElement *Q3DSPresentation::registeredDataInput(const QString &name) const
+ \since QtStudio3D 1.1
+
+ Returns a pointer to a registered data input with \a name. If no data input with given name
+ is registered, a null pointer is returned.
+*/
+
+/*!
\fn void Q3DSPresentation::goToSlide(const QString &elementPath, unsigned int index)
Requests a time context (a Scene or a Component element) to change to a specific slide by
@@ -193,6 +216,13 @@
*/
/*!
+ \fn void Q3DSPresentation::setDataInputValue(const QString &name, const QVariant &value)
+ \since QtStudio3D 1.1
+
+ Sets the \a value of a data input element \a name in the presentation.
+*/
+
+/*!
\fn void Q3DSPresentation::slideEntered(const QString &elementPath, unsigned int index, const QString &name)
This signal is emitted when a slide is entered in the presentation.
diff --git a/doc/src/examples-index.qdoc b/doc/src/examples-index.qdoc
index 7b456a81..4955b7e7 100644
--- a/doc/src/examples-index.qdoc
+++ b/doc/src/examples-index.qdoc
@@ -39,6 +39,7 @@ folder in the installation folder.
\list
\li \l {Qt 3D Studio: Dynamic Keyframes Example}
\li \l {Qt 3D Studio: QML Streamer Example}
+ \li \l {Qt 3D Studio: QML DataInput Example}
\endlist
\section1 More Examples
diff --git a/examples/studio3d/qmldatainput/doc/images/qml-datainput.jpg b/examples/studio3d/qmldatainput/doc/images/qml-datainput.jpg
new file mode 100644
index 00000000..5ad24953
--- /dev/null
+++ b/examples/studio3d/qmldatainput/doc/images/qml-datainput.jpg
Binary files differ
diff --git a/examples/studio3d/qmldatainput/doc/src/qmldatainput.qdoc b/examples/studio3d/qmldatainput/doc/src/qmldatainput.qdoc
new file mode 100644
index 00000000..10100528
--- /dev/null
+++ b/examples/studio3d/qmldatainput/doc/src/qmldatainput.qdoc
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example qmldatainput
+ \title Qt 3D Studio: QML DataInput Example
+ \ingroup qtstudio3d-examples-qml
+ \brief Demonstrates using DataInput elements in QML
+ \since QtStudio3D 1.1
+
+ \image qml-datainput.jpg
+
+ \e {This example demonstrates using DataInput elements with QML in Studio}
+
+ \include examples-run.qdocinc
+
+ \section1 Description
+
+ The presentation consists of a static text element serving as a label, a rotating text element
+ for showing the input data, and a DataInput element linked to the textstring property of the
+ rotating text element.
+
+ The \l {qmldatainput/qml/qmldatainput/main.qml}{qml main} loads the presentation and animates
+ a number property. The value of the animated property is bound to the
+ \l{DataInput::value}{value} property of the DataInput element, making the value show up in the
+ linked text element in the presentation:
+
+ \snippet qmldatainput/qml/qmldatainput/main.qml 1
+*/
diff --git a/examples/studio3d/qmldatainput/main.cpp b/examples/studio3d/qmldatainput/main.cpp
new file mode 100644
index 00000000..cf7a2787
--- /dev/null
+++ b/examples/studio3d/qmldatainput/main.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtCore/QDir>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+#include <QtCore/QLoggingCategory>
+
+#ifdef USE_EMBEDDED_FONTS
+#include <QtGui/QFontDatabase>
+#include <QtCore/QDebug>
+#endif
+
+int main(int argc, char *argv[])
+{
+#ifdef USE_EMBEDDED_FONTS
+ qputenv("QT_QPA_FONTDIR",".");
+#endif
+ // To enable QOpenGLWidget to work on macOS, we must set the default
+ // QSurfaceFormat before QApplication is created. Otherwise context-sharing
+ // fails and QOpenGLWidget breaks.
+#if defined(Q_OS_MACOS)
+ QSurfaceFormat openGLFormat;
+ openGLFormat.setRenderableType(QSurfaceFormat::OpenGL);
+ openGLFormat.setProfile(QSurfaceFormat::CoreProfile);
+ openGLFormat.setMajorVersion(4);
+ openGLFormat.setMinorVersion(1);
+ openGLFormat.setStencilBufferSize(8);
+ QSurfaceFormat::setDefaultFormat(openGLFormat);
+#endif
+
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+#ifdef USE_EMBEDDED_FONTS
+ int fontId = QFontDatabase::addApplicationFont(":/res/Font/TitilliumWeb-Regular.ttf");
+ QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(fontId);
+ if (!loadedFontFamilies.empty()) {
+ QString fontName = loadedFontFamilies.at(0);
+ QGuiApplication::setFont(QFont(fontName));
+ } else {
+ qWarning("Error: failed to load font");
+ }
+#endif
+
+ QQuickView viewer;
+
+ viewer.setSource(QUrl("qrc:/main.qml"));
+
+ viewer.setTitle(QStringLiteral("Qt 3D Studio DataInput Element Example"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/studio3d/qmldatainput/presentation/datainput.uia b/examples/studio3d/qmldatainput/presentation/datainput.uia
new file mode 100644
index 00000000..b92dc7e2
--- /dev/null
+++ b/examples/studio3d/qmldatainput/presentation/datainput.uia
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application xmlns="http://qt.io/qt3dstudio/uia">
+ <assets initial="datainput">
+ <presentation id="datainput" src="datainput.uip"/>
+ </assets>
+
+ <statemachine ref="#logic">
+ <visual-states>
+ <state ref="Initial">
+ <enter>
+ <goto-slide element="main:Scene" rel="next"/>
+ </enter>
+ </state>
+ </visual-states>
+ </statemachine>
+</application>
diff --git a/examples/studio3d/qmldatainput/presentation/datainput.uip b/examples/studio3d/qmldatainput/presentation/datainput.uip
new file mode 100644
index 00000000..71ed63f2
--- /dev/null
+++ b/examples/studio3d/qmldatainput/presentation/datainput.uip
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<UIP version="3" >
+ <Project >
+ <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" >
+ <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
+ </ProjectSettings>
+ <Graph >
+ <Scene id="Scene" >
+ <Layer id="Layer" >
+ <Camera id="Camera" />
+ <Light id="Light" />
+ <Text id="Text" />
+ <Text id="Text2" />
+ </Layer>
+ <DataInput id="MyDataInput" name="MyDataInput" controlledelemprop="Scene.Layer.Text textstring " />
+ </Scene>
+ </Graph>
+ <Logic >
+ <State name="Master Slide" component="#Scene" >
+ <Add ref="#Layer" />
+ <Add ref="#Camera" />
+ <Add ref="#Light" />
+ <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
+ <Add ref="#Text" name="Text" font="TitilliumWeb-Regular" position="-0.000391006 46.1884 0" scale="1.0 1.0 1.0" size="48" textstring="Datainput value goes here" >
+ <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 0 0 10 0 0 0</AnimationTrack>
+ <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 0 0 10 0 0 0</AnimationTrack>
+ <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 0 0 10 -360 0 0</AnimationTrack>
+ </Add>
+ <Add ref="#Text2" name="Text2" font="TitilliumWeb-Regular" position="2.88678 207.846 0" scale="1 1 1" size="48" textstring="Text via DataInput:" />
+ <Add ref="#MyDataInput" name="MyDataInput" />
+ </State>
+ </State>
+ </Logic>
+ </Project>
+</UIP>
diff --git a/examples/studio3d/qmldatainput/presentation/fonts/TitilliumWeb-Regular.ttf b/examples/studio3d/qmldatainput/presentation/fonts/TitilliumWeb-Regular.ttf
new file mode 100644
index 00000000..6da82193
--- /dev/null
+++ b/examples/studio3d/qmldatainput/presentation/fonts/TitilliumWeb-Regular.ttf
Binary files differ
diff --git a/examples/studio3d/qmldatainput/qml/qmldatainput/main.qml b/examples/studio3d/qmldatainput/qml/qmldatainput/main.qml
new file mode 100644
index 00000000..cec6c335
--- /dev/null
+++ b/examples/studio3d/qmldatainput/qml/qmldatainput/main.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtStudio3D 1.1
+
+Item {
+ id: mainview
+ width: 1280
+ height: 768
+ visible: true
+
+ // Qt 3D Studio element
+ //
+ // The presentation displayed in this example consists of two text elements and a DataInput
+ // element.
+ // The content of one of the text elements is controlled via the DataInput element.
+ Studio3D {
+ id: studio3D
+ anchors.fill: parent
+
+ property int inputNumber: 0
+
+ // A changing property to demonstrate DataInput
+ NumberAnimation {
+ target: studio3D
+ property: "inputNumber"
+ duration: 30000
+ from: 0
+ to: 1000
+ loops: Animation.Infinite
+ running: true
+ }
+
+ // ViewerSettings item is used to specify presentation independent viewer settings.
+ ViewerSettings {
+ scaleMode: ViewerSettings.ScaleModeFill
+ showRenderStats: false
+ }
+
+ // Presentation item is used to control the presentation.
+ //![1]
+ Presentation {
+ source: "qrc:/presentation/datainput.uip"
+ DataInput {
+ // Name must match the DataInput element name in the presentation
+ name: "MyDataInput"
+ value: studio3D.inputNumber
+ }
+ }
+ //![1]
+ }
+
+}
diff --git a/examples/studio3d/qmldatainput/qmldatainput.pro b/examples/studio3d/qmldatainput/qmldatainput.pro
new file mode 100644
index 00000000..314ca916
--- /dev/null
+++ b/examples/studio3d/qmldatainput/qmldatainput.pro
@@ -0,0 +1,21 @@
+include(../examples.pri)
+
+TEMPLATE = app
+
+QT += qml quick
+
+integrity: DEFINES += USE_EMBEDDED_FONTS
+
+target.path = $$[QT_INSTALL_EXAMPLES]/studio3d/$$TARGET
+INSTALLS += target
+
+SOURCES += main.cpp
+
+RESOURCES += qmldatainput.qrc
+
+OTHER_FILES += qml/qmldatainput/* \
+ doc/src/* \
+ doc/images/*
+
+# Icon in case example is included in installer
+exists(example.ico): RC_ICONS = example.ico
diff --git a/examples/studio3d/qmldatainput/qmldatainput.qrc b/examples/studio3d/qmldatainput/qmldatainput.qrc
new file mode 100644
index 00000000..3d45f9b4
--- /dev/null
+++ b/examples/studio3d/qmldatainput/qmldatainput.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="main.qml">qml/qmldatainput/main.qml</file>
+ <file>presentation/datainput.uip</file>
+ </qresource>
+</RCC>
diff --git a/examples/studio3d/studio3d.pro b/examples/studio3d/studio3d.pro
index 6c10a4ea..df16888e 100644
--- a/examples/studio3d/studio3d.pro
+++ b/examples/studio3d/studio3d.pro
@@ -6,7 +6,8 @@ TEMPLATE = subdirs
qmlstreamer \
widgetviewer \
surfaceviewer \
- surfaceviewer_offscreen
+ surfaceviewer_offscreen \
+ qmldatainput
# Sample project only has the presentation.
# We do not want to pollute the sample folder with .pro file, so do the install here.
diff --git a/src/Runtime/Source/Engine/Include/Qt3DSTegraApplication.h b/src/Runtime/Source/Engine/Include/Qt3DSTegraApplication.h
index 8c47c3c6..ab50c6f1 100644
--- a/src/Runtime/Source/Engine/Include/Qt3DSTegraApplication.h
+++ b/src/Runtime/Source/Engine/Include/Qt3DSTegraApplication.h
@@ -189,6 +189,7 @@ public:
virtual void SetPresentationAttribute(const char *presId, const char *, const char *value) = 0;
virtual void GoToTime(const char *elementPath, const float time) = 0;
virtual void SetGlobalAnimationTime(qint64 inMilliSecs) = 0;
+ virtual void SetDataInputValue(const QString &name, const QVariant &value) = 0;
virtual void SetAttribute(const char *elementPath, const char *attributeName,
const char *value) = 0;
virtual bool GetAttribute(const char *elementPath, const char *attributeName, void *value) = 0;
@@ -282,6 +283,10 @@ public:
{
m_NDDView->SetGlobalAnimationTime(inMilliSecs);
}
+ void SetDataInputValue(const QString &name, const QVariant &value)
+ {
+ m_NDDView->SetDataInputValue(name, value);
+ }
void SetAttribute(const char *elementPath, const char *attributeName, const char *value)
{
m_NDDView->SetAttribute(elementPath, attributeName, value);
diff --git a/src/Runtime/Source/Engine/Source/Qt3DSTegraApplication.cpp b/src/Runtime/Source/Engine/Source/Qt3DSTegraApplication.cpp
index 4aaaae60..4286368a 100644
--- a/src/Runtime/Source/Engine/Source/Qt3DSTegraApplication.cpp
+++ b/src/Runtime/Source/Engine/Source/Qt3DSTegraApplication.cpp
@@ -202,6 +202,7 @@ public:
void SetPresentationAttribute(const char *presId, const char *, const char *value) override;
void GoToTime(const char *elementPath, const float time) override;
void SetGlobalAnimationTime(qint64 inMilliSecs) override;
+ void SetDataInputValue(const QString &name, const QVariant &value);
void SetAttribute(const char *elementPath, const char *attributeName, const char *value) override;
bool GetAttribute(const char *elementPath, const char *attributeName, void *value) override;
void FireEvent(const char *element, const char *evtName) override;
@@ -538,6 +539,24 @@ void CNDDView::SetGlobalAnimationTime(qint64 inMilliSecs)
m_Application->SetTimeMilliSecs(inMilliSecs);
}
+void CNDDView::SetDataInputValue(const QString &name, const QVariant &value)
+{
+ if (m_Application) {
+ if (name.isEmpty() || !value.isValid())
+ return;
+ QByteArray valueStr = value.toString().toUtf8();
+ float valueFloat = value.toFloat();
+ QByteArray elementPath = QByteArrayLiteral("Scene.") + name.toUtf8();
+
+ Q3DStudio::CQmlEngine &theBridgeEngine
+ = static_cast<Q3DStudio::CQmlEngine &>(m_RuntimeFactoryCore->GetScriptEngineQml());
+
+ theBridgeEngine.SetAttribute(elementPath.constData(), "valuestr", valueStr.constData());
+ theBridgeEngine.SetAttribute(elementPath.constData(), "value",
+ reinterpret_cast<char *>(&valueFloat));
+ }
+}
+
void CNDDView::SetAttribute(const char *elementPath, const char *attributeName, const char *value)
{
if (m_Application) {
diff --git a/src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp b/src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp
index c16092f4..00b6febc 100644
--- a/src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp
+++ b/src/Runtime/Source/Viewer/Qt3DSViewerApp.cpp
@@ -746,6 +746,14 @@ void Q3DSViewerApp::SetGlobalAnimationTime(qint64 inMilliSecs)
m_Impl.m_tegraApp->SetGlobalAnimationTime(inMilliSecs);
}
+void Q3DSViewerApp::SetDataInputValue(const QString &name, const QVariant &value)
+{
+ if (!m_Impl.m_tegraApp)
+ return;
+
+ m_Impl.m_tegraApp->SetDataInputValue(name, value);
+}
+
Q3DSViewerApp &Q3DSViewerApp::Create(void *glContext, Q3DStudio::IAudioPlayer *inAudioPlayer)
{
return *Q3DStudio_virtual_new(Q3DSViewerApp) Q3DSViewerApp(glContext, inAudioPlayer);
diff --git a/src/Runtime/Source/Viewer/Qt3DSViewerApp.h b/src/Runtime/Source/Viewer/Qt3DSViewerApp.h
index b28989dc..a1487da3 100644
--- a/src/Runtime/Source/Viewer/Qt3DSViewerApp.h
+++ b/src/Runtime/Source/Viewer/Qt3DSViewerApp.h
@@ -347,6 +347,8 @@ public:
void SetGlobalAnimationTime(qint64 inMilliSecs);
+ void SetDataInputValue(const QString &name, const QVariant &value);
+
QString error();
private:
diff --git a/src/Viewer/qmlviewer/Qt3DSRenderer.cpp b/src/Viewer/qmlviewer/Qt3DSRenderer.cpp
index 82604722..53617cf8 100644
--- a/src/Viewer/qmlviewer/Qt3DSRenderer.cpp
+++ b/src/Viewer/qmlviewer/Qt3DSRenderer.cpp
@@ -312,6 +312,9 @@ void Q3DSRenderer::processCommands()
case CommandType_KeyRelease:
m_runtime->HandleKeyInput(Q3DStudio::EKeyCode(cmd.m_intValues[0]), false);
break;
+ case CommandType_SetDataInputValue:
+ m_runtime->SetDataInputValue(cmd.m_stringValue, cmd.m_variantValue);
+ break;
case CommandType_RequestSlideInfo: {
int current = 0;
int previous = 0;
diff --git a/src/Viewer/qmlviewer/Qt3DSViewPlugin.cpp b/src/Viewer/qmlviewer/Qt3DSViewPlugin.cpp
index 15c1da06..389e1cc4 100644
--- a/src/Viewer/qmlviewer/Qt3DSViewPlugin.cpp
+++ b/src/Viewer/qmlviewer/Qt3DSViewPlugin.cpp
@@ -39,6 +39,7 @@
#include "q3dsqmlstream.h"
#include "q3dsqmlsubpresentationsettings.h"
#include "q3dssceneelement.h"
+#include "q3dsdatainput.h"
QT_BEGIN_NAMESPACE
@@ -70,8 +71,11 @@ void Q3DSViewPlugin::registerTypes(const char *uri)
qmlRegisterType<Q3DSElement>(uri, 1, 0, "Element");
qmlRegisterType<Q3DSQmlStream>(uri, 1, 0, "QmlStream");
qmlRegisterType<Q3DSSubPresentationSettings>(uri, 1, 0, "SubPresentationSettings");
+
// Version 1.1
qmlRegisterType<Q3DSView, 1>(uri, 1, 1, "Studio3D");
+ qmlRegisterType<Q3DSDataInput>(uri, 1, 1, "DataInput");
+ qmlRegisterType<Q3DSPresentationItem, 1>(uri, 1, 1, "Presentation");
}
QT_END_NAMESPACE
diff --git a/src/Viewer/qmlviewer/q3dspresentationitem.cpp b/src/Viewer/qmlviewer/q3dspresentationitem.cpp
index 573ea263..6c4c8e36 100644
--- a/src/Viewer/qmlviewer/q3dspresentationitem.cpp
+++ b/src/Viewer/qmlviewer/q3dspresentationitem.cpp
@@ -29,6 +29,8 @@
#include "q3dspresentationitem.h"
+#include <QtStudio3D/q3dssceneelement.h>
+#include <QtStudio3D/q3dsdatainput.h>
#include <QtStudio3D/private/q3dspresentation_p.h>
#include <QtStudio3D/private/viewerqmlstreamproxy_p.h>
#include <QtCore/qdebug.h>
@@ -55,25 +57,25 @@ QQmlListProperty<QObject> Q3DSPresentationItem::qmlChildren()
return QQmlListProperty<QObject>(this, nullptr, &appendQmlChildren, nullptr, nullptr, nullptr);
}
-void Q3DSPresentationItem::appendQmlChildren(QQmlListProperty<QObject> *list, QObject *element)
+void Q3DSPresentationItem::appendQmlChildren(QQmlListProperty<QObject> *list, QObject *obj)
{
auto item = qobject_cast<Q3DSPresentationItem *>(list->object);
if (item) {
- auto scene = qobject_cast<Q3DSSceneElement *>(element);
+ auto scene = qobject_cast<Q3DSSceneElement *>(obj);
if (scene) {
if (item->registeredElement(scene->elementPath()))
qWarning() << __FUNCTION__ << "A duplicate SceneElement defined for Presentation.";
else
item->registerElement(scene);
} else {
- auto studioElement = qobject_cast<Q3DSElement *>(element);
+ auto studioElement = qobject_cast<Q3DSElement *>(obj);
if (studioElement) {
if (item->registeredElement(studioElement->elementPath()))
qWarning() << __FUNCTION__ << "A duplicate Element defined for Presentation.";
else
item->registerElement(studioElement);
} else {
- auto subPresSettings = qobject_cast<Q3DSSubPresentationSettings *>(element);
+ auto subPresSettings = qobject_cast<Q3DSSubPresentationSettings *>(obj);
if (subPresSettings) {
if (item->m_subPresentationSettings) {
qWarning() << __FUNCTION__
@@ -82,6 +84,14 @@ void Q3DSPresentationItem::appendQmlChildren(QQmlListProperty<QObject> *list, QO
item->m_subPresentationSettings = subPresSettings;
item->d_ptr->streamProxy()->setSettings(subPresSettings);
}
+ } else {
+ auto dataInput = qobject_cast<Q3DSDataInput *>(obj);
+ if (item->registeredDataInput(dataInput->name())) {
+ qWarning() << __FUNCTION__
+ << "Duplicate DataInput defined for Presentation.";
+ } else {
+ item->registerDataInput(dataInput);
+ }
}
}
}
diff --git a/src/Viewer/qmlviewer/q3dspresentationitem.h b/src/Viewer/qmlviewer/q3dspresentationitem.h
index 59414275..63270594 100644
--- a/src/Viewer/qmlviewer/q3dspresentationitem.h
+++ b/src/Viewer/qmlviewer/q3dspresentationitem.h
@@ -33,7 +33,6 @@
#include "q3dsqmlsubpresentationsettings.h"
#include <QtStudio3D/q3dspresentation.h>
-#include <QtStudio3D/q3dssceneelement.h>
#include <QtQml/qqmllist.h>
QT_BEGIN_NAMESPACE
@@ -54,7 +53,7 @@ public:
QQmlListProperty<QObject> qmlChildren();
public Q_SLOTS:
- static void appendQmlChildren(QQmlListProperty<QObject> *list, QObject *element);
+ static void appendQmlChildren(QQmlListProperty<QObject> *list, QObject *obj);
private:
Q3DSSubPresentationSettings *m_subPresentationSettings;
diff --git a/src/Viewer/studio3d/q3dscommandqueue.cpp b/src/Viewer/studio3d/q3dscommandqueue.cpp
index 9882fea6..aec8cc26 100644
--- a/src/Viewer/studio3d/q3dscommandqueue.cpp
+++ b/src/Viewer/studio3d/q3dscommandqueue.cpp
@@ -167,6 +167,7 @@ void CommandQueue::copyCommands(const CommandQueue &fromQueue)
for (int i = 0; i < fromQueue.m_size; i++) {
const ElementCommand &source = fromQueue.commandAt(i);
switch (source.m_commandType) {
+ case CommandType_SetDataInputValue:
case CommandType_SetAttribute:
queueCommand(source.m_elementPath, source.m_commandType, source.m_stringValue,
source.m_variantValue);
diff --git a/src/Viewer/studio3d/q3dscommandqueue_p.h b/src/Viewer/studio3d/q3dscommandqueue_p.h
index 5c4c2e70..42e3bc5c 100644
--- a/src/Viewer/studio3d/q3dscommandqueue_p.h
+++ b/src/Viewer/studio3d/q3dscommandqueue_p.h
@@ -67,6 +67,7 @@ enum CommandType {
CommandType_KeyPress,
CommandType_KeyRelease,
CommandType_SetGlobalAnimationTime,
+ CommandType_SetDataInputValue,
CommandType_RequestSlideInfo
};
diff --git a/src/Viewer/studio3d/q3dsdatainput.cpp b/src/Viewer/studio3d/q3dsdatainput.cpp
new file mode 100644
index 00000000..a22e1694
--- /dev/null
+++ b/src/Viewer/studio3d/q3dsdatainput.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "q3dsdatainput_p.h"
+#include "q3dspresentation_p.h"
+#include "q3dscommandqueue_p.h"
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+Q3DSDataInput::Q3DSDataInput(QObject *parent)
+ : QObject(parent)
+ , d_ptr(new Q3DSDataInputPrivate(this))
+{
+}
+
+Q3DSDataInput::Q3DSDataInput(const QString &name, QObject *parent)
+ : QObject(parent)
+ , d_ptr(new Q3DSDataInputPrivate(this))
+{
+ d_ptr->m_name = name;
+}
+
+Q3DSDataInput::Q3DSDataInput(Q3DSPresentation *presentation, const QString &name, QObject *parent)
+ : QObject(parent)
+ , d_ptr(new Q3DSDataInputPrivate(this))
+{
+ d_ptr->m_name = name;
+ if (presentation)
+ presentation->registerDataInput(this);
+}
+
+Q3DSDataInput::Q3DSDataInput(Q3DSDataInputPrivate *d, Q3DSPresentation *presentation,
+ const QString &name, QObject *parent)
+ : QObject(parent)
+ , d_ptr(d)
+{
+ d_ptr->m_name = name;
+ if (presentation)
+ presentation->registerDataInput(this);
+}
+
+Q3DSDataInput::~Q3DSDataInput()
+{
+ delete d_ptr;
+}
+
+QString Q3DSDataInput::name() const
+{
+ return d_ptr->m_name;
+}
+
+void Q3DSDataInput::setName(const QString &name)
+{
+ if (d_ptr->m_name != name) {
+ d_ptr->m_name = name;
+ if (d_ptr->m_presentation)
+ d_ptr->m_presentation->registerDataInput(this);
+ Q_EMIT nameChanged();
+ }
+}
+
+QVariant Q3DSDataInput::value() const
+{
+ return d_ptr->m_value;
+}
+
+void Q3DSDataInput::setValue(const QVariant &value)
+{
+ if (value != d_ptr->m_value) {
+ d_ptr->m_value = value;
+ if (d_ptr->m_presentation)
+ d_ptr->m_presentation->q_ptr->setDataInputValue(d_ptr->m_name, d_ptr->m_value);
+ Q_EMIT valueChanged();
+ }
+}
+
+Q3DSDataInputPrivate::Q3DSDataInputPrivate(Q3DSDataInput *parent)
+ : q_ptr(parent)
+{
+}
+
+Q3DSDataInputPrivate::~Q3DSDataInputPrivate()
+{
+ if (m_presentation)
+ m_presentation->unregisterDataInput(q_ptr);
+}
+
+void Q3DSDataInputPrivate::setViewerApp(Q3DSViewer::Q3DSViewerApp *app)
+{
+ m_viewerApp = app;
+
+ if (m_viewerApp && m_value.isValid())
+ q_ptr->setValue(m_value);
+}
+
+void Q3DSDataInputPrivate::setCommandQueue(CommandQueue *queue)
+{
+ m_commandQueue = queue;
+
+ if (m_commandQueue && m_value.isValid())
+ q_ptr->setValue(m_value);
+}
+
+void Q3DSDataInputPrivate::setPresentation(Q3DSPresentationPrivate *presentation)
+{
+ m_presentation = presentation;
+}
+
+QT_END_NAMESPACE
diff --git a/src/Viewer/studio3d/q3dsdatainput.h b/src/Viewer/studio3d/q3dsdatainput.h
new file mode 100644
index 00000000..c4a8a483
--- /dev/null
+++ b/src/Viewer/studio3d/q3dsdatainput.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef Q3DSDATAINPUT_P_H
+#define Q3DSDATAINPUT_P_H
+
+#include <QtStudio3D/qstudio3dglobal.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q3DSDataInputPrivate;
+class Q3DSPresentation;
+
+class Q_STUDIO3D_EXPORT Q3DSDataInput : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(Q3DSDataInput)
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
+
+public:
+ explicit Q3DSDataInput(QObject *parent = nullptr);
+ explicit Q3DSDataInput(const QString &name, QObject *parent = nullptr);
+ explicit Q3DSDataInput(Q3DSPresentation *presentation, const QString &name,
+ QObject *parent = nullptr);
+
+ virtual ~Q3DSDataInput();
+
+ QString name() const;
+ QVariant value() const;
+
+public Q_SLOTS:
+ void setName(const QString &name);
+ void setValue(const QVariant &value);
+
+Q_SIGNALS:
+ void nameChanged();
+ void valueChanged();
+
+protected:
+ explicit Q3DSDataInput(Q3DSDataInputPrivate *d, Q3DSPresentation *presentation,
+ const QString &name, QObject *parent = nullptr);
+ Q3DSDataInputPrivate *d_ptr;
+
+private:
+ Q_DISABLE_COPY(Q3DSDataInput)
+
+ friend class Q3DSPresentationPrivate;
+};
+
+QT_END_NAMESPACE
+
+#endif // Q3DSDATAINPUT_P_H
diff --git a/src/Viewer/studio3d/q3dsdatainput_p.h b/src/Viewer/studio3d/q3dsdatainput_p.h
new file mode 100644
index 00000000..f6c87db0
--- /dev/null
+++ b/src/Viewer/studio3d/q3dsdatainput_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef Q3DSDATAINPUT_P_P_H
+#define Q3DSDATAINPUT_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the QtStudio3D API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "q3dsdatainput.h"
+#include "q3dscommandqueue_p.h"
+#include "Qt3DSViewerApp.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q3DSPresentationPrivate;
+
+class Q_STUDIO3D_EXPORT Q3DSDataInputPrivate
+{
+ Q_DECLARE_PUBLIC(Q3DSDataInput)
+public:
+ explicit Q3DSDataInputPrivate(Q3DSDataInput *parent);
+ virtual ~Q3DSDataInputPrivate();
+
+ void setViewerApp(Q3DSViewer::Q3DSViewerApp *app);
+ void setCommandQueue(CommandQueue *queue);
+ void setPresentation(Q3DSPresentationPrivate *presentation);
+
+protected:
+ Q3DSDataInput *q_ptr;
+ Q3DSViewer::Q3DSViewerApp *m_viewerApp = nullptr; // Not owned
+ CommandQueue *m_commandQueue = nullptr; // Not owned
+ Q3DSPresentationPrivate *m_presentation = nullptr; // Not owned
+ QString m_name;
+ QVariant m_value;
+};
+
+QT_END_NAMESPACE
+
+#endif // Q3DSDATAINPUT_P_P_H
diff --git a/src/Viewer/studio3d/q3dspresentation.cpp b/src/Viewer/studio3d/q3dspresentation.cpp
index 881031f0..f4a75a03 100644
--- a/src/Viewer/studio3d/q3dspresentation.cpp
+++ b/src/Viewer/studio3d/q3dspresentation.cpp
@@ -31,6 +31,7 @@
#include "q3dssceneelement_p.h"
#include "q3dscommandqueue_p.h"
#include "viewerqmlstreamproxy_p.h"
+#include "q3dsdatainput_p.h"
#include <QtCore/qdebug.h>
#include <QtCore/qsettings.h>
@@ -71,6 +72,21 @@ Q3DSElement *Q3DSPresentation::registeredElement(const QString &elementPath) con
return d_ptr->m_elements.value(elementPath, nullptr);
}
+void Q3DSPresentation::registerDataInput(Q3DSDataInput *dataInput)
+{
+ d_ptr->registerDataInput(dataInput);
+}
+
+void Q3DSPresentation::unregisterDataInput(Q3DSDataInput *dataInput)
+{
+ d_ptr->unregisterDataInput(dataInput);
+}
+
+Q3DSDataInput *Q3DSPresentation::registeredDataInput(const QString &name) const
+{
+ return d_ptr->m_dataInputs.value(name, nullptr);
+}
+
void Q3DSPresentation::setSource(const QUrl &source)
{
if (d_ptr->m_source != source) {
@@ -184,6 +200,16 @@ void Q3DSPresentation::setGlobalAnimationTime(qint64 milliseconds)
}
}
+void Q3DSPresentation::setDataInputValue(const QString &name, const QVariant &value)
+{
+ if (d_ptr->m_viewerApp) {
+ d_ptr->m_viewerApp->SetDataInputValue(name, value);
+ } else if (d_ptr->m_commandQueue) {
+ d_ptr->m_commandQueue->queueCommand(QString(), CommandType_SetDataInputValue,
+ name, value);
+ }
+}
+
void Q3DSPresentation::mousePressEvent(QMouseEvent *e)
{
if (d_ptr->m_viewerApp) {
@@ -275,6 +301,7 @@ Q3DSPresentationPrivate::Q3DSPresentationPrivate(Q3DSPresentation *q)
Q3DSPresentationPrivate::~Q3DSPresentationPrivate()
{
unregisterAllElements();
+ unregisterAllDataInputs();
delete m_streamProxy;
}
@@ -289,9 +316,12 @@ void Q3DSPresentationPrivate::setSource(const QUrl &source)
void Q3DSPresentationPrivate::setViewerApp(Q3DSViewer::Q3DSViewerApp *app, bool connectApp)
{
-
- for (Q3DSElement *element : m_elements.values())
+ const auto elements = m_elements.values();
+ const auto dataInputs = m_dataInputs.values();
+ for (Q3DSElement *element : elements)
element->d_ptr->setViewerApp(app);
+ for (Q3DSDataInput *di : dataInputs)
+ di->d_ptr->setViewerApp(app);
if (connectApp) {
if (app) {
@@ -313,8 +343,12 @@ void Q3DSPresentationPrivate::setViewerApp(Q3DSViewer::Q3DSViewerApp *app, bool
void Q3DSPresentationPrivate::setCommandQueue(CommandQueue *queue)
{
- for (Q3DSElement *element : m_elements.values())
+ const auto elements = m_elements.values();
+ const auto dataInputs = m_dataInputs.values();
+ for (Q3DSElement *element : elements)
element->d_ptr->setCommandQueue(queue);
+ for (Q3DSDataInput *di : dataInputs)
+ di->d_ptr->setCommandQueue(queue);
m_commandQueue = queue;
@@ -374,6 +408,56 @@ void Q3DSPresentationPrivate::unregisterAllElements()
m_elements.clear();
}
+void Q3DSPresentationPrivate::registerDataInput(Q3DSDataInput *dataInput)
+{
+ Q_ASSERT(!dataInput->name().isEmpty());
+
+ // Allow only single registration for each DataInput
+ QMutableHashIterator<QString, Q3DSDataInput *> i(m_dataInputs);
+ while (i.hasNext()) {
+ i.next();
+ if (i.value() == dataInput) {
+ // If the same DataInput object is already registered with different name,
+ // remove it from the map to avoid duplication.
+ if (i.key() != dataInput->name())
+ i.remove();
+ } else if (i.key() == dataInput->name()) {
+ // If the same name is registered by another DataInput object, the old
+ // DataInput object is unregistered.
+ i.value()->d_ptr->setViewerApp(nullptr);
+ i.value()->d_ptr->setPresentation(nullptr);
+ i.remove();
+ }
+ }
+
+ dataInput->d_ptr->setPresentation(this);
+ dataInput->d_ptr->setViewerApp(m_viewerApp);
+ dataInput->d_ptr->setCommandQueue(m_commandQueue);
+
+ m_dataInputs.insert(dataInput->name(), dataInput);
+}
+
+void Q3DSPresentationPrivate::unregisterDataInput(Q3DSDataInput *dataInput)
+{
+ Q3DSDataInput *oldDi = m_dataInputs.value(dataInput->name());
+ if (oldDi == dataInput) {
+ dataInput->d_ptr->setCommandQueue(nullptr);
+ dataInput->d_ptr->setViewerApp(nullptr);
+ dataInput->d_ptr->setPresentation(nullptr);
+ m_dataInputs.remove(dataInput->name());
+ }
+}
+
+void Q3DSPresentationPrivate::unregisterAllDataInputs()
+{
+ for (Q3DSDataInput *di : m_dataInputs.values()) {
+ di->d_ptr->setViewerApp(nullptr);
+ di->d_ptr->setCommandQueue(nullptr);
+ di->d_ptr->setPresentation(nullptr);
+ }
+ m_dataInputs.clear();
+}
+
Q3DStudio::EKeyCode Q3DSPresentationPrivate::getScanCode(QKeyEvent *e)
{
enum {
diff --git a/src/Viewer/studio3d/q3dspresentation.h b/src/Viewer/studio3d/q3dspresentation.h
index a00388ea..c604787a 100644
--- a/src/Viewer/studio3d/q3dspresentation.h
+++ b/src/Viewer/studio3d/q3dspresentation.h
@@ -41,6 +41,7 @@ class Q3DSElement;
class QMouseEvent;
class QWheelEvent;
class QKeyEvent;
+class Q3DSDataInput;
class Q_STUDIO3D_EXPORT Q3DSPresentation : public QObject
{
@@ -58,6 +59,10 @@ public:
void unregisterElement(Q3DSElement *scene);
Q3DSElement *registeredElement(const QString &elementPath) const;
+ void registerDataInput(Q3DSDataInput *dataInput);
+ void unregisterDataInput(Q3DSDataInput *dataInput);
+ Q3DSDataInput *registeredDataInput(const QString &name) const;
+
// Input event handlers
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
@@ -77,6 +82,7 @@ public Q_SLOTS:
void setPresentationActive(const QString &id, bool active);
void fireEvent(const QString &elementPath, const QString &eventName);
void setGlobalAnimationTime(qint64 milliseconds);
+ Q_REVISION(1) void setDataInputValue(const QString &name, const QVariant &value);
Q_SIGNALS:
void sourceChanged(const QUrl &source);
diff --git a/src/Viewer/studio3d/q3dspresentation_p.h b/src/Viewer/studio3d/q3dspresentation_p.h
index 60036aff..27e553ca 100644
--- a/src/Viewer/studio3d/q3dspresentation_p.h
+++ b/src/Viewer/studio3d/q3dspresentation_p.h
@@ -59,6 +59,7 @@ class Q_STUDIO3D_EXPORT Q3DSPresentationPrivate : public QObject
public:
typedef QHash<QString, Q3DSElement *> ElementMap;
+ typedef QHash<QString, Q3DSDataInput *> DataInputMap;
explicit Q3DSPresentationPrivate(Q3DSPresentation *parent);
~Q3DSPresentationPrivate();
@@ -71,6 +72,10 @@ public:
void unregisterElement(Q3DSElement *element);
void unregisterAllElements();
+ void registerDataInput(Q3DSDataInput *dataInput);
+ void unregisterDataInput(Q3DSDataInput *dataInput);
+ void unregisterAllDataInputs();
+
ViewerQmlStreamProxy *streamProxy();
Q3DStudio::EKeyCode getScanCode(QKeyEvent *e);
@@ -84,6 +89,7 @@ private:
Q3DSViewer::Q3DSViewerApp *m_viewerApp; // Not owned
CommandQueue *m_commandQueue; // Not owned
ElementMap m_elements;
+ DataInputMap m_dataInputs;
QUrl m_source;
ViewerQmlStreamProxy *m_streamProxy;
};
diff --git a/src/Viewer/studio3d/studio3d.pri b/src/Viewer/studio3d/studio3d.pri
index 9a02b8b2..ce13e469 100644
--- a/src/Viewer/studio3d/studio3d.pri
+++ b/src/Viewer/studio3d/studio3d.pri
@@ -16,7 +16,9 @@ HEADERS += \
studioutils_p.h \
q3dscommandqueue_p.h \
q3dsimagesequencegenerator_p.h \
- q3dsimagesequencegeneratorthread_p.h
+ q3dsimagesequencegeneratorthread_p.h \
+ q3dsdatainput.h \
+ q3dsdatainput_p.h
SOURCES += q3dswidget.cpp \
q3dssurfaceviewer.cpp \
@@ -28,7 +30,8 @@ SOURCES += q3dswidget.cpp \
studioutils.cpp \
q3dscommandqueue.cpp \
q3dsimagesequencegenerator.cpp \
- q3dsimagesequencegeneratorthread.cpp
+ q3dsimagesequencegeneratorthread.cpp \
+ q3dsdatainput.cpp
macos {
INCLUDEPATH += $$PWD/../../Runtime/SDKsAndTools/nvap_sdk/libs/inc
diff --git a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
index ef3cb942..40cbe210 100644
--- a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
+++ b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
@@ -82,6 +82,8 @@ private slots:
void testElement();
void testMouseInput_data();
void testMouseInput();
+ void testDataInput_data();
+ void testDataInput();
private:
QWindow *createWindow(const QSize &size);
@@ -1472,6 +1474,25 @@ void tst_Q3DSSurfaceViewer::testMouseInput()
// Note: No way yet to hook mouse move into anything in the presentation
}
+void tst_Q3DSSurfaceViewer::testDataInput_data()
+{
+ testBasics_data();
+}
+
+void tst_Q3DSSurfaceViewer::testDataInput()
+{
+// QFETCH(bool, isWindow);
+
+// if (isWindow)
+// createWindowAndViewer(m_viewer, DATAINPUT);
+// else
+// createOffscreenAndViewer(m_viewer, DATAINPUT);
+
+ // TODO: This is a placeholder for data input test. To be finished when proper support
+ // for changing animation time via data inputs is supported and the display bugs fixed.
+ // See: https://bugreports.qt.io/browse/QT3DS-854
+}
+
QTEST_MAIN(tst_Q3DSSurfaceViewer)
diff --git a/tests/auto/studio3d/shared/presentation/datainput.uip b/tests/auto/studio3d/shared/presentation/datainput.uip
new file mode 100644
index 00000000..e2464527
--- /dev/null
+++ b/tests/auto/studio3d/shared/presentation/datainput.uip
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<UIP version="3" >
+ <Project >
+ <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" >
+ <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
+ </ProjectSettings>
+ <Graph >
+ <Scene id="Scene" >
+ <Layer id="Layer" >
+ <Camera id="Camera" />
+ <Light id="Light" />
+ <Text id="Text" />
+ <Text id="Text2" />
+ </Layer>
+ <DataInput id="MyDataInput" name="MyDataInput" controlledelemprop="Scene.Layer.Text textstring " />
+ </Scene>
+ </Graph>
+ <Logic >
+ <State name="Master Slide" component="#Scene" >
+ <Add ref="#Layer" />
+ <Add ref="#Camera" />
+ <Add ref="#Light" />
+ <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
+ <Add ref="#Text" name="Text" font="TitilliumWeb-Regular" position="-0.000391006 46.1884 0" scale="1.0 1.0 1.0" size="48" textstring="Datainput value goes here" />
+ <Add ref="#Text2" name="Text2" font="TitilliumWeb-Regular" position="2.88678 207.846 0" scale="1 1 1" size="48" textstring="Text via DataInput:" />
+ <Add ref="#MyDataInput" name="MyDataInput" />
+ </State>
+ </State>
+ </Logic>
+ </Project>
+</UIP>
diff --git a/tests/auto/studio3d/shared/shared_presentations.h b/tests/auto/studio3d/shared/shared_presentations.h
index c778b453..b1d23e0e 100644
--- a/tests/auto/studio3d/shared/shared_presentations.h
+++ b/tests/auto/studio3d/shared/shared_presentations.h
@@ -36,3 +36,4 @@ const QUrl ANIMATION = QUrl(QStringLiteral("qrc:/animation.uip"));
const QUrl SETTINGS = QUrl(QStringLiteral("qrc:/settings.uip"));
const QUrl MULTISLIDE = QUrl(QStringLiteral("qrc:/multislide.uip"));
const QUrl MOUSE = QUrl(QStringLiteral("qrc:/mouse.uip"));
+const QUrl DATAINPUT = QUrl(QStringLiteral("qrc:/datinput.uip"));
diff --git a/tests/auto/studio3d/shared/shared_presentations.qrc b/tests/auto/studio3d/shared/shared_presentations.qrc
index a68dae72..00877c26 100644
--- a/tests/auto/studio3d/shared/shared_presentations.qrc
+++ b/tests/auto/studio3d/shared/shared_presentations.qrc
@@ -8,5 +8,6 @@
<file alias="settings.uip">presentation/settings.uip</file>
<file alias="multislide.uip">presentation/multislide.uip</file>
<file alias="mouse.uip">presentation/mouse.uip</file>
+ <file alias="datainput.uip">presentation/datainput.uip</file>
</qresource>
</RCC>