summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-01-15 17:32:44 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-01-26 06:56:23 +0000
commit1961ff954c4df4a437bb0e9375fd8bdcb643a88a (patch)
tree34976069f2d3a106723ac9fbd4a9ba1fffcb5566 /examples
parent260ca381faddc1010ab079900e178cdbf2b5482c (diff)
Add QML type and C++ class for data input
QML type is DataInput. C++ class is Q3DSDataInput. Task-number: QT3DS-387 Change-Id: I7f871ae3e1149adee7859fdb8f844e8f90837264 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'examples')
-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
10 files changed, 337 insertions, 1 deletions
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.