summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPasi Keränen <pasi.keranen@qt.io>2019-05-28 10:16:55 +0300
committerPasi Keränen <pasi.keranen@qt.io>2019-05-29 10:36:22 +0300
commitee4f48c4980f1c346924bc3e1c6b07993d408c13 (patch)
tree2cda5c52db06b4b9bb833a0cc37ef576f8a9b10c
parent100014e25b72f01d86c940cecff78018c7a82253 (diff)
Add initial documentation for 2.4 OpenGL Runtime
Mostly copy paste of documentation from 2.3. Adds DataOutput documentation and recommendations to avoid APIs that require use of elementPath. Task-number: QT3DS-3529 Change-Id: I75878fc2cd0e101827ea02996d6df8a981afe4fc Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Jari Karppinen <jari.karppinen@qt.io> Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Pasi Keränen <pasi.keranen@qt.io>
-rw-r--r--src/Authoring/Studio/Render/StudioSubPresentationRenderer.cpp8
-rw-r--r--src/QtExtras/qmlstreamer/q3dsqmlstream.cpp42
-rw-r--r--src/QtExtras/qmlstreamer/q3dsqmlsubpresentationsettings.cpp27
-rw-r--r--src/Runtime/api/studio3d/q3dsdatainput.cpp231
-rw-r--r--src/Runtime/api/studio3d/q3dsdataoutput.cpp107
-rw-r--r--src/Runtime/api/studio3d/q3dselement.cpp130
-rw-r--r--src/Runtime/api/studio3d/q3dsimagesequencegeneratorthread.cpp2
-rw-r--r--src/Runtime/api/studio3d/q3dspresentation.cpp593
-rw-r--r--src/Runtime/api/studio3d/q3dspresentation.h2
-rw-r--r--src/Runtime/api/studio3d/q3dssceneelement.cpp197
-rw-r--r--src/Runtime/api/studio3d/q3dssurfaceviewer.cpp278
-rw-r--r--src/Runtime/api/studio3d/q3dssurfaceviewer.h41
-rw-r--r--src/Runtime/api/studio3d/q3dsviewersettings.cpp205
-rw-r--r--src/Runtime/api/studio3d/q3dsviewersettings.h10
-rw-r--r--src/Runtime/api/studio3dqml/q3dspresentationitem.cpp45
-rw-r--r--src/Runtime/api/studio3dqml/q3dsstudio3d.cpp203
16 files changed, 1987 insertions, 134 deletions
diff --git a/src/Authoring/Studio/Render/StudioSubPresentationRenderer.cpp b/src/Authoring/Studio/Render/StudioSubPresentationRenderer.cpp
index 4e09dbf9..76e5f3c3 100644
--- a/src/Authoring/Studio/Render/StudioSubPresentationRenderer.cpp
+++ b/src/Authoring/Studio/Render/StudioSubPresentationRenderer.cpp
@@ -115,11 +115,7 @@ public:
m_surfaceViewer->setUpdateInterval(-1);
m_surfaceViewer->presentation()->setSource(QUrl::fromLocalFile(info.absoluteFilePath()));
m_surfaceViewer->settings()->setMatteColor(Qt::transparent);
-#ifdef Q3DS_PREVIEW_SUBPRESENTATION_RT2
m_surfaceViewer->create(m_surface.data(), m_context.data(), m_fbo->handle());
-#else
- m_surfaceViewer->initialize(m_surface.data(), m_context.data(), m_fbo->handle());
-#endif
m_running = true;
m_semaphore.release();
@@ -157,11 +153,7 @@ public:
m_context->doneCurrent();
m_context.reset();
#endif
-#ifdef Q3DS_PREVIEW_SUBPRESENTATION_RT2
m_surfaceViewer->destroy();
-#else
- m_surfaceViewer->shutdown();
-#endif
m_surfaceViewer.reset();
m_surface->moveToThread(m_mainThread);
m_semaphore.release();
diff --git a/src/QtExtras/qmlstreamer/q3dsqmlstream.cpp b/src/QtExtras/qmlstreamer/q3dsqmlstream.cpp
index ec231d83..e1b9e857 100644
--- a/src/QtExtras/qmlstreamer/q3dsqmlstream.cpp
+++ b/src/QtExtras/qmlstreamer/q3dsqmlstream.cpp
@@ -29,23 +29,61 @@
#include "q3dsqmlstream.h"
+/*!
+ \qmltype QmlStream
+ \instantiates Q3DSQmlStream
+ \inqmlmodule Qt3DStudio
+ \ingroup OpenGLRuntime
+ \brief Allows streaming of QML as subpresentation.
+
+ \sa Studio3D, Presentation, SubPresentation
+*/
+/*!
+ \class Q3DSQmlStream
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.0
+ \brief Allows streaming of QML as subpresentation.
+ \param parent
+ */
+
+/*!
+ * \brief Q3DSQmlStream::Q3DSQmlStream Constructor
+ * \param parent Optional parent object.
+ */
Q3DSQmlStream::Q3DSQmlStream(QObject *parent)
: QObject(parent)
, m_item(nullptr)
{
-
}
+/*!
+ * \brief Q3DSQmlStream::~Q3DSQmlStream Destructor.
+ */
Q3DSQmlStream::~Q3DSQmlStream()
{
-
}
+/*!
+ * \qmlproperty string QmlStream::presentationId
+ * Contains the presentation id of this subpresentation.
+ */
+/*!
+ * \property Q3DSQmlStream::presentationId
+ * Contains the presentation id of this subpresentation.
+ */
QString Q3DSQmlStream::presentationId() const
{
return m_presentationId;
}
+/*!
+ * \qmlproperty Item QmlStream::item
+ * Contains the Item to be streamed as subpresentation.
+ */
+/*!
+ * \property Q3DSQmlStream::item
+ * Contains the QQuickItem to be streamed as subpresentation.
+ */
QQuickItem *Q3DSQmlStream::item() const
{
return m_item;
diff --git a/src/QtExtras/qmlstreamer/q3dsqmlsubpresentationsettings.cpp b/src/QtExtras/qmlstreamer/q3dsqmlsubpresentationsettings.cpp
index 8487909b..bde5ad31 100644
--- a/src/QtExtras/qmlstreamer/q3dsqmlsubpresentationsettings.cpp
+++ b/src/QtExtras/qmlstreamer/q3dsqmlsubpresentationsettings.cpp
@@ -30,10 +30,27 @@
#include "q3dsqmlsubpresentationsettings.h"
#include "q3dsqmlstream.h"
+/*!
+ \qmltype SubPresentationSettings
+ \instantiates Q3DSSubPresentationSettings
+ \inqmlmodule Qt3DStudio
+ \ingroup OpenGLRuntime
+ \brief
+
+ \sa Studio3D, Presentation, QmlStream
+*/
+/*!
+ \class Q3DSSubPresentationSettings
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.0
+ \brief Settings for subpresentations.
+ \param parent
+
+ \sa Q3DSPresentation, Q3DSQmlStream
+ */
Q3DSSubPresentationSettings::Q3DSSubPresentationSettings(QObject *parent)
: QObject(parent)
{
-
}
Q3DSSubPresentationSettings::~Q3DSSubPresentationSettings()
@@ -41,6 +58,14 @@ Q3DSSubPresentationSettings::~Q3DSSubPresentationSettings()
qDeleteAll(m_list);
}
+/*!
+ * \qmlproperty variant SubPresentationSettings::qmlStream
+ * Contains the QML streams to be used as subpresentations.
+ */
+/*!
+ * \property Q3DSSubPresentationSettings::qmlStreams
+ * Contains the QML streams to be used as subpresentations.
+ */
QQmlListProperty<Q3DSQmlStream> Q3DSSubPresentationSettings::qmlStreams()
{
return QQmlListProperty<Q3DSQmlStream>(this, m_list);
diff --git a/src/Runtime/api/studio3d/q3dsdatainput.cpp b/src/Runtime/api/studio3d/q3dsdatainput.cpp
index d2d82008..2e6281e6 100644
--- a/src/Runtime/api/studio3d/q3dsdatainput.cpp
+++ b/src/Runtime/api/studio3d/q3dsdatainput.cpp
@@ -35,12 +35,64 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmltype DataInput
+ \instantiates Q3DSDataInput
+ \inqmlmodule Qt3DStudio
+ \ingroup OpenGLRuntime
+ \brief Controls a data input entry in a Qt 3D Studio presentation.
+ This class is a convenience class for controlling a data input in a presentation.
+ DataInput provides a clean contract between the presentation design and the code.
+ It hides the presentation details from the code while providing a contractual access
+ point to code for controlling aspects of the presentation (e.g. timeline of a
+ subpresentation). It also allows the design to use a single DataInput to drive
+ multiple aspects of the design (e.g. DataInput for speed can change the color of
+ the speedometer, angle of the needle).
+
+ \note There is a performance cost for each registered DataInput, so try to avoid
+ creating unnecessary DataInputs.
+
+ \sa Presentation, DataOutput, Presentation::slideExited, Presentation::slideEntered
+ \sa Presentation::customSignalEmitted
+*/
+
+/*!
+ \class Q3DSDataInput
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.0
+ \brief Controls a data input entry in a Qt 3D Studio presentation.
+ This class is a convenience class for controlling a data input in a presentation.
+ DataInput provides a clean contract between the presentation design and the code.
+ It hides the presentation details from the code while providing a contractual access
+ point to code for controlling aspects of the presentation (e.g. timeline of a
+ subpresentation). It also allows the design to use a single DataInput to drive
+ multiple aspects of the design (e.g. DataInput for speed can change the color of
+ the speedometer, angle of the needle).
+
+ \note There is a performance cost for each registered DataInput, so try to avoid
+ creating unnecessary DataInputs.
+
+ For other integration points between code and presentation see:
+ \sa Q3DSPresentation::customSignalEmitted
+ \sa Q3DSPresentation::slideEntered
+ \sa Q3DSPresentation::slideExited
+ \sa Q3DSDataOutput
+
+ \sa Q3DSPresentation
+*/
+
+/*!
+ \internal
+ */
Q3DSDataInput::Q3DSDataInput(QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSDataInputPrivate(this))
{
}
+/*!
+ \internal
+ */
Q3DSDataInput::Q3DSDataInput(const QString &name, QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSDataInputPrivate(this))
@@ -48,6 +100,11 @@ Q3DSDataInput::Q3DSDataInput(const QString &name, QObject *parent)
d_ptr->m_name = name;
}
+/*!
+ Constructs a Q3DSDataInput instance and initializes the \a name. The
+ constructed instance is automatically associated with the specified \a
+ presentation. An optional \a parent object can be specified.
+ */
Q3DSDataInput::Q3DSDataInput(Q3DSPresentation *presentation, const QString &name, QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSDataInputPrivate(this))
@@ -58,6 +115,9 @@ Q3DSDataInput::Q3DSDataInput(Q3DSPresentation *presentation, const QString &name
presentation->registerDataInput(this);
}
+/*!
+ \internal
+ */
Q3DSDataInput::Q3DSDataInput(Q3DSDataInputPrivate *d, Q3DSPresentation *presentation,
const QString &name, QObject *parent)
: QObject(parent)
@@ -69,11 +129,34 @@ Q3DSDataInput::Q3DSDataInput(Q3DSDataInputPrivate *d, Q3DSPresentation *presenta
presentation->registerDataInput(this);
}
+/*!
+ Destructor.
+ */
Q3DSDataInput::~Q3DSDataInput()
{
delete d_ptr;
}
+/*!
+ \qmlproperty string DataInput::name
+
+ Specifies the name of the controlled data input element in the
+ presentation. The name must match a name of a data input defined
+ in the presentation. This property must be set before setting the
+ value property.
+ */
+
+/*!
+ \property Q3DSDataInput::name
+
+ Specifies the name of the controlled data input element in the
+ presentation. The name must match a name of a data input defined
+ in the presentation.
+
+ This property must be set before setting the value property.
+ The initial value is provided via the constructor, but the name
+ can also be changed later on.
+ */
QString Q3DSDataInput::name() const
{
return d_ptr->m_name;
@@ -89,11 +172,53 @@ void Q3DSDataInput::setName(const QString &name)
}
}
+/*!
+ \qmlproperty variant DataInput::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 animations or
+ Q3DSPresentation::setAttribute(), those changes are not reflected in the
+ value of this property. Due to this uncertainty, this property treats all
+ value sets as changes even if the newly set value is the same value as the
+ previous value.
+
+ To get actual values from the presentation, use DataOutput.
+ \sa DataOutput
+*/
+/*!
+ \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 animations or
+ Q3DSPresentation::setAttribute(), those changes are not reflected in the
+ value of this property. Due to this uncertainty, this property treats all
+ value sets as changes even if the newly set value is the same value as the
+ previous value.
+
+ To get actual values from the presentation, use DataOutput.
+ \sa DataOutput
+*/
QVariant Q3DSDataInput::value() const
{
return d_ptr->m_value;
}
+/*!
+ \property Q3DSDataInput::min
+
+ Contains the minimum range value for datainput. Returned value is zero
+ for datainput types other than \e {Ranged Number}.
+
+ \note This value is read-only.
+ */
float Q3DSDataInput::min() const
{
if (!d_ptr->m_presentation)
@@ -102,6 +227,14 @@ float Q3DSDataInput::min() const
return d_ptr->m_presentation->d_ptr->dataInputMin(d_ptr->m_name);
}
+/*!
+ \property Q3DSDataInput::max
+
+ Contains the maximum range value for datainput. Returned value is zero
+ for datainput types other than \e {Ranged Number}.
+
+ \note This value is read-only.
+ */
float Q3DSDataInput::max() const
{
if (!d_ptr->m_presentation)
@@ -110,6 +243,11 @@ float Q3DSDataInput::max() const
return d_ptr->m_presentation->d_ptr->dataInputMax(d_ptr->m_name);
}
+/*!
+ Returns true if presentation (or its subpresentation) associated with
+ this datainput has a datainput definition with a matching name. Returns
+ false if the datainput has no associated presentation, or if a match is not found.
+ */
bool Q3DSDataInput::isValid() const
{
if (d_ptr->m_presentation)
@@ -118,6 +256,11 @@ bool Q3DSDataInput::isValid() const
return false;
}
+/*!
+ \brief Q3DSDataInput::setValue Set value of the data input.
+ \param value New value to be set.
+ \note For performance reasons do not call setValue unnecessarily.
+ */
void Q3DSDataInput::setValue(const QVariant &value)
{
// Since properties controlled by data inputs can change without the current value being
@@ -169,4 +312,92 @@ void Q3DSDataInputPrivate::setCommandQueue(CommandQueue *queue)
setValue(m_value);
}
+
+/*!
+ \qmltype DataInput
+ \instantiates Q3DSDataInput
+ \inqmlmodule QtStudio3D
+ \ingroup OpenGLRuntime
+
+ \brief Controls a data input entry in a Qt 3D Studio presentation.
+
+ This type is a convenience for controlling a data in a presentation. Its functionality is
+ equivalent to \c{Presentation::setDataInputValue()}, however it has a big advantage
+ of being able to use QML property bindings, thus avoiding the need to having to resort
+ to a JavaScript function call for every value change.
+
+ As an example:
+
+ \qml
+ Studio3D {
+ ...
+ Presentation {
+ id: presentation
+ ...
+ property string text: ""
+ DataInput {
+ name: "inputForSomeTextNode"
+ value: presentation.text
+ }
+ }
+ }
+
+ Button {
+ onClicked: presentation.text = "Hello World"
+ }
+ \endqml
+
+ The example assumes that a data input connection was made in Qt 3D Studio
+ presentation using Qt 3D Studio editor between the \c textstring property of
+ target property and a data input name \c inputForSomeTextNode. As the value
+ is now set via a property, the full set of QML property bindings techniques
+ are available.
+
+ \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,
+ although it is changeable afterwards, if desired.
+*/
+
+/*!
+ \qmlproperty variant DataInput::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
+ DataInput instance. If the value of the underlying attribute in the
+ presentation is changed elsewhere, for example via animations or
+ Presentation::setAttribute(), those changes are not reflected in the value
+ of this property. Due to this uncertainty, this property treats all value
+ sets as changes even if the newly set value is the same value as the
+ previous value.
+*/
+
+/*!
+ \qmlproperty real DataInput::min
+
+ Contains the minimum value of the controlled data input element range.
+
+ This property is applicable only to data input type \e {Ranged Number}. For other
+ types, value returned is zero.
+
+ \note This value is read-only.
+*/
+
+/*!
+ \qmlproperty real DataInput::max
+
+ Contains the maximum value of the controlled data input element range.
+
+ This property is applicable only to data input type \e {Ranged Number}. For other
+ types, value returned is zero.
+
+ \note This value is read-only.
+*/
+
QT_END_NAMESPACE
diff --git a/src/Runtime/api/studio3d/q3dsdataoutput.cpp b/src/Runtime/api/studio3d/q3dsdataoutput.cpp
index e0db2dd5..3cb13a0e 100644
--- a/src/Runtime/api/studio3d/q3dsdataoutput.cpp
+++ b/src/Runtime/api/studio3d/q3dsdataoutput.cpp
@@ -31,6 +31,55 @@
#include "q3dspresentation_p.h"
#include "q3dscommandqueue_p.h"
+/*!
+ \qmltype DataOutput
+ \instantiates Q3DSDataOutput
+ \inqmlmodule Qt3DStudio
+ \ingroup OpenGLRuntime
+ \brief Provides notifications from data output entries in Qt 3D Studio presentation.
+ This class is a convenience class for listening for changes in the Qt 3D Studio
+ presentation attributes. DataOutput provides a clean contract between the presentation
+ design and the code. It hides the presentation details from the code while providing a
+ contractual access point to code to be notified when aspects of the presentation change
+ (e.g. movement of an element in the presentation due to timeline animation).
+
+ DataOutput can be attached to same attributes in the design as DataInput is, including
+ presentation timeline. Only exception is slide changes. Slide changes are already notified
+ through \c{Presentation::slideEntered} and \c{Presentation::slideExited} signals.
+
+ \note There is a performance cost for each registered DataOutput, so try to avoid
+ creating unnecessary DataOutputs.
+
+ \sa Presentation, DataInput, Presentation::slideExited, Presentation::slideEntered
+ \sa Presentation::customSignalEmitted
+*/
+
+/*!
+ \class Q3DSDataOutput
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.4
+ \brief Provides notifications from data output entries in Qt 3D Studio presentation.
+ This class is a convenience class for listening for changes in the Qt 3D Studio
+ presentation attributes. DataOutput provides a clean contract between the presentation
+ design and the code. It hides the presentation details from the code while providing a
+ contractual access point to code to be notified when aspects of the presentation change
+ (e.g. movement of an element in the presentation due to timeline animation).
+
+ DataOutput can be attached to same attributes in the design as DataInput is, including
+ presentation timeline. Only excaption is slide changes Slide changes are already notified
+ through \c{Q3DSPresentation::slideEntered} and \c{Q3DSPresentation::slideExited} signals.
+
+ \note There is a performance cost for each registered DataOutput, so try to avoid
+ creating unnecessary DataOutputs.
+
+ For other integration points between code and presentation see:
+ \sa Q3DSPresentation::customSignalEmitted
+ \sa Q3DSPresentation::slideEntered
+ \sa Q3DSPresentation::slideExited
+ \sa Q3DSDataInput
+
+ \sa Q3DSPresentation
+*/
Q3DSDataOutput::Q3DSDataOutput(QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSDataOutputPrivate(this))
@@ -50,6 +99,26 @@ Q3DSDataOutput::~Q3DSDataOutput()
delete d_ptr;
}
+/*!
+ \qmlproperty string DataOutput::name
+
+ Specifies the name of the observed data output element in the
+ presentation. The name must match a name of a data output defined
+ in the presentation. This property must be set before setting the value
+ property.
+ */
+
+/*!
+ \property Q3DSDataOutput::name
+
+ Specifies the name of the observed data output element in the
+ presentation. The name must match a name of a data output defined
+ in the presentation.
+
+ This property must be set before setting the value property.
+ The initial value is provided via the constructor, but the name
+ can also be changed later on.
+ */
QString Q3DSDataOutput::name() const
{
return d_ptr->m_name;
@@ -65,11 +134,49 @@ void Q3DSDataOutput::setName(const QString &name)
}
}
+/*!
+ \qmlproperty DataOutput::value
+
+ Contains the read-only value of the controlled data output element in the
+ presentation.
+
+ The value of this property accounts for actual value in the last processed
+ frame of the presentation. This includes animation timeline driven changes,
+ changes done via DataInput and changes done via Behavior scripts.
+*/
+
+/*!
+ \property Q3DSDataOutput::value
+
+ Contains the read-only value of the controlled data output element in the
+ presentation.
+
+ The value of this property accounts for actual value in the last processed
+ frame of the presentation. This includes animation timeline driven changes,
+ changes done via DataInput and changes done via Behavior scripts.
+*/
QVariant Q3DSDataOutput::value() const
{
return d_ptr->m_value;
}
+/*!
+ * \qmlsignal DataOutput::valueChanged
+ Emitted when the value of the observed DataOutput has changed in the
+ presentation.
+ \param newValue The new value of the observed DataOutput.
+ */
+
+/*!
+ \fn Q3DSDataOutput::valueChanged
+ Emitted when the value of the observed DataOutput has changed in the
+ presentation.
+ \param newValue The new value of the observed DataOutput.
+ */
+
+/*!
+ * \internal
+ */
void Q3DSDataOutput::setValue(const QVariant &value)
{
if (d_ptr->m_value == value)
diff --git a/src/Runtime/api/studio3d/q3dselement.cpp b/src/Runtime/api/studio3d/q3dselement.cpp
index ac3221dd..16ae1102 100644
--- a/src/Runtime/api/studio3d/q3dselement.cpp
+++ b/src/Runtime/api/studio3d/q3dselement.cpp
@@ -37,12 +37,58 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmltype Element
+ \instantiates Q3DSElement
+ \inqmlmodule Qt3DStudio
+ \ingroup OpenGLRuntime
+ \brief Control type for elements in a Qt 3D Studio presentation.
+
+ This class is provided for backwards compatibility. We recommend using
+ DataInput and DataOutput APIs for contractual and clean API between
+ the design and the code.
+
+ \sa DataInput, DataOutput
+
+ This type is a convenience for controlling the properties of a scene object
+ (such as, model, material, camera, layer) in a Qt 3D Studio presentation.
+
+ \note The functionality of Element is equivalent to
+ Presentation::setAttribute() and Presentation::fireEvent().
+
+ \sa Studio3D, SceneElement, Presentation, DataInput, DataOutput
+*/
+
+/*!
+ \class Q3DSElement
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.0
+
+ \brief Controls a scene object (node) in a Qt 3D Studio presentation.
+
+ This class is provided for backwards compatibility. We recommend using
+ DataInput and DataOutput APIs for contractual and clean API between
+ the design and the code.
+
+ This class is a convenience class for controlling the properties of a scene
+ object (such as, model, material, camera, layer) in a Qt 3D Studio
+ presentation.
+
+ \sa Q3DSWidget, Q3DSSurfaceViewer, Q3DSSceneElement
+ */
+
+/*!
+ \internal
+ */
Q3DSElement::Q3DSElement(QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSElementPrivate(this))
{
}
+/*!
+ \internal
+ */
Q3DSElement::Q3DSElement(const QString &elementPath, QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSElementPrivate(this))
@@ -50,6 +96,12 @@ Q3DSElement::Q3DSElement(const QString &elementPath, QObject *parent)
d_ptr->m_elementPath = elementPath;
}
+/*!
+ Constructs a Q3DSElement instance controlling the scene object specified by
+ \a elementPath. An optional \a parent object can be specified. The
+ constructed instance is automatically associated with the specified \a
+ presentation. An optional \a parent object can be specified.
+ */
Q3DSElement::Q3DSElement(Q3DSPresentation *presentation, const QString &elementPath,
QObject *parent)
: QObject(parent)
@@ -60,6 +112,9 @@ Q3DSElement::Q3DSElement(Q3DSPresentation *presentation, const QString &elementP
presentation->registerElement(this);
}
+/*!
+ \internal
+ */
Q3DSElement::Q3DSElement(Q3DSElementPrivate *d, Q3DSPresentation *presentation,
const QString &elementPath, QObject *parent)
: QObject(parent)
@@ -70,12 +125,54 @@ Q3DSElement::Q3DSElement(Q3DSElementPrivate *d, Q3DSPresentation *presentation,
presentation->registerElement(this);
}
+/*!
+ Destructor.
+ */
Q3DSElement::~Q3DSElement()
{
// Private class isn't QObject, so we need to delete it explicitly
delete d_ptr;
}
+/*!
+ \qmlproperty string Element::elementPath
+
+ Holds the element path of the presentation element.
+
+ An element path refers to an object in the scene by name, for example,
+ \c{Scene.Layer.Camera}. Here the right camera object gets chosen even if
+ the scene contains other layers with the default camera names (for instance
+ \c{Scene.Layer2.Camera}).
+
+ To reference an object stored in a property of another object, the dot
+ syntax can be used. The most typical example of this is changing the source
+ of a texture map by changing the \c sourcepath property on the object
+ selected by \c{SomeMaterial.diffusemap}.
+
+ To access an object in a sub-presentation, prepend the name of the
+ sub-presentation followed by a colon, for example,
+ \c{SubPresentationOne:Scene.Layer.Camera}.
+ */
+
+/*!
+ \property Q3DSElement::elementPath
+
+ Holds the element path of the presentation element.
+
+ An element path refers to an object in the scene by name, for example,
+ \c{Scene.Layer.Camera}. Here the right camera object gets chosen even if
+ the scene contains other layers with the default camera names (for instance
+ \c{Scene.Layer2.Camera}).
+
+ To reference an object stored in a property of another object, the dot
+ syntax can be used. The most typical example of this is changing the source
+ of a texture map by changing the \c sourcepath property on the object
+ selected by \c{SomeMaterial.diffusemap}.
+
+ To access an object in a sub-presentation, prepend the name of the
+ sub-presentation followed by a colon, for example,
+ \c{SubPresentationOne:Scene.Layer.Camera}.
+ */
QString Q3DSElement::elementPath() const
{
return d_ptr->m_elementPath;
@@ -89,6 +186,20 @@ void Q3DSElement::setElementPath(const QString &elementPath)
}
}
+/*!
+ \qmlmethod void Element::setAttribute(string attributeName, variant value)
+
+ Sets the \a value of an attribute (property) of the scene object specified
+ by this Element instance. The \a attributeName is the \l{Attribute
+ Names}{scripting name} of the attribute.
+*/
+
+/*!
+ Sets the \a value of an attribute (property) of the scene object
+ specified by elementPath.
+
+ The \a attributeName is the \l{Attribute Names}{scripting name} of the attribute.
+ */
void Q3DSElement::setAttribute(const QString &attributeName, const QVariant &value)
{
if (d_ptr->m_presentation)
@@ -97,6 +208,25 @@ void Q3DSElement::setAttribute(const QString &attributeName, const QVariant &val
qWarning() << __FUNCTION__ << "Element is not registered to any presentation!";
}
+/*!
+ \qmlmethod void Element::fireEvent(string eventName)
+
+ Dispatches an event with \a eventName on the scene object
+ specified by elementPath.
+
+ Appropriate actions created in Qt 3D Studio or callbacks registered using
+ the registerForEvent() method in attached \c{behavior scripts} will be
+ executed in response to the event.
+*/
+
+/*!
+ Dispatches an event with \a eventName on the scene object
+ specified by elementPath.
+
+ Appropriate actions created in Qt 3D Studio or callbacks registered using
+ the registerForEvent() method in attached (behavior) scripts will be
+ executed in response to the event.
+ */
void Q3DSElement::fireEvent(const QString &eventName)
{
if (d_ptr->m_presentation)
diff --git a/src/Runtime/api/studio3d/q3dsimagesequencegeneratorthread.cpp b/src/Runtime/api/studio3d/q3dsimagesequencegeneratorthread.cpp
index 40bb95b9..0968e3f1 100644
--- a/src/Runtime/api/studio3d/q3dsimagesequencegeneratorthread.cpp
+++ b/src/Runtime/api/studio3d/q3dsimagesequencegeneratorthread.cpp
@@ -131,7 +131,7 @@ void Q3DSImageSequenceGeneratorThread::run() {
viewer.setAutoSize(false);
viewer.setSize(size);
- if (!viewer.initialize(m_surface, m_context, fbo.handle())) {
+ if (!viewer.create(m_surface, m_context, fbo.handle())) {
QString error = QObject::tr("Viewer initialization failed.");
qWarning() << "Generating image sequence failed -" << error;
Q_EMIT generationFinished(false, error);
diff --git a/src/Runtime/api/studio3d/q3dspresentation.cpp b/src/Runtime/api/studio3d/q3dspresentation.cpp
index 5b55608d..204b2035 100644
--- a/src/Runtime/api/studio3d/q3dspresentation.cpp
+++ b/src/Runtime/api/studio3d/q3dspresentation.cpp
@@ -42,71 +42,266 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class Q3DSPresentation
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.0
+
+ \brief Represents a Qt 3D Studio presentation.
+
+ This class provides properties and methods for controlling a
+ presentation.
+
+ Qt 3D Studio supports multiple presentations in one project. There
+ is always a main presentation and zero or more
+ subpresentations. The subpresentations are composed into the
+ main presentations either as contents of Qt 3D Studio layers or as
+ texture maps.
+
+ In the filesystem each presentation corresponds to one \c{.uip}
+ presentation file. When present, the \c{.uia} project file ties
+ these together by specifying a name for each of the
+ (sub-)presentations and specifies which one is the main one.
+
+ The \c{.uia} project also defines \l{DataInput}s and
+ \l{DataOutput}s that are exported by the presentations.
+ \l{DataInput}s provide a way to provide input to the presentation
+ to e.g. control a timeline of a subpresentation from code.
+ \c{DataOutput}s provide a way to get notified when an attribute
+ is changed in the presentation by animation timeline,
+ by behavior scripts or by a \l{DataInput}.
+
+ From the API point of view Q3DSPresentation corresponds to the
+ main presentation. The source property can refer either to a
+ \c{.uia} or \c{.uip} file. When specifying a file with \c{.uip}
+ extension and a \c{.uia} is present with the same name, the
+ \c{.uia} is loaded automatically and thus sub-presentation
+ information is available regardless.
+
+ \note This class should not be instantiated directly when working with the
+ C++ APIs. Q3DSSurfaceViewer and Q3DSWidget create a Q3DSPresentation
+ instance implicitly. This can be queried via
+ Q3DSSurfaceViewer::presentation() or Q3DSWidget::presentation().
+ */
+
+/*!
+ Constructs a new Q3DSPresentation with the given \a parent.
+ */
Q3DSPresentation::Q3DSPresentation(QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSPresentationPrivate(this))
{
}
+/*!
+ Destructor.
+ */
Q3DSPresentation::~Q3DSPresentation()
{
}
+/*!
+ \qmlproperty string Presentation::source
+
+ Holds the name of the main presentation file (\c{*.uia} or
+ \c{*.uip}). This may be either a local file or qrc URL.
+
+ The names of all further assets (image files for texture maps, qml
+ behavior scripts, mesh files) will be resolved relative to the
+ location of the presentation, unless they use absolute paths. This
+ allows bundling all assets next to the presentation in the Qt
+ resource system.
+
+ Currently set \c{variantList} property will modify which variant groups
+ and tags are loaded from the presentations. See
+ Q3DSPresentation::variantList property.
+*/
+
+/*!
+ \property Q3DSPresentation::source
+
+ Holds the name of the main presentation file (\c{*.uia} or
+ \c{*.uip}). This may be either a local file or qrc URL.
+
+ The names of all further assets (image files for texture maps, qml
+ behavior scripts, mesh files) will be resolved relative to the
+ location of the presentation, unless they use absolute paths. This
+ allows bundling all assets next to the presentation in the Qt
+ resource system.
+
+ Currently set variantList will modify which variant groups
+ and tags are loaded from the presentations. See
+ Q3DSPresentation::variantList property.
+*/
QUrl Q3DSPresentation::source() const
{
return d_ptr->m_source;
}
+void Q3DSPresentation::setSource(const QUrl &source)
+{
+ if (d_ptr->m_source != source) {
+ d_ptr->setSource(source);
+ Q_EMIT sourceChanged(source);
+ }
+}
+
+/*!
+ \qmlproperty variant Presentation::variantList
+
+ Holds a list of (variant group):(variant) tags that are loaded when the
+ \c{source} property is set. If this list is left empty (default), no variant
+ filtering is applied and all items are loaded regardless of variant tags in
+ the presentation. Variant mechanism allows one presentation project to
+ contain multiple variants of the presentation and the decision which variant
+ set is loaded is determined during runtime based on the \c{variantList}.
+
+ Variants are divided to variant groups, e.g. one variant group could be
+ \c{region} and the variants within that group could be e.g. \c{US, EU, CH}.
+ Another variant group could be e.g. \c{power} and variants within that could
+ be e.g. \c{gas, electric, diesel}. To filter in this example an electric
+ variant for the EU region, the variantList needs to contain two strings
+ "region:EU" and "power:electric". Also of course the presentation project
+ needs to contain these variant groups and tags applied appropriately to the
+ presentation content.
+
+ When variant filters are used, the decision what gets loaded and what is not
+ loaded is based on checking every item in the presentation:
+ \list
+ \li If the item has no variant tags, it will be loaded.
+ \li If the item has no tags defined for the checked variant group(s),
+ it will be loaded.
+ \li If the item has tag(s) for the variant group, any of those tags must
+ match any of the variants defined in the filter for that group.
+ \endlist
+
+ If the item doesn't fulfill the above rules it will not be loaded.
+*/
+
+/*!
+ \property Q3DSPresentation::variantList
+
+ Holds a list of (variant group):(variant) tags that are loaded when the
+ \c{source} property is set. If this list is left empty (default), no variant
+ filtering is applied and all items are loaded regardless of variant tags in
+ the presentation. Variant mechanism allows one presentation project to
+ contain multiple variants of the presentation and the decision which variant
+ set is loaded is determined during runtime based on the \c{variantList}.
+
+ Variants are divided to variant groups, e.g. one variant group could be
+ \c{region} and the variants within that group could be e.g. \c{US, EU, CH}.
+ Another variant group could be e.g. \c{power} and variants within that could
+ be e.g. \c{gas, electric, diesel}. To filter in this example an electric
+ variant for the EU region, the variantList needs to contain two strings
+ "region:EU" and "power:electric". Also of course the presentation project
+ needs to contain these variant groups and tags applied appropriately to the
+ presentation content.
+
+ When variant filters are used, the decision what gets loaded and what is not
+ loaded is based on checking every item in the presentation:
+ \list
+ \li If the item has no variant tags, it will be loaded.
+ \li If the item has no tags defined for the checked variant group(s),
+ it will be loaded.
+ \li If the item has tag(s) for the variant group, any of those tags must
+ match any of the variants defined in the filter for that group.
+ \endlist
+
+ If the item doesn't fulfill the above rules it will not be loaded.
+*/
QStringList Q3DSPresentation::variantList() const
{
return d_ptr->m_variantList;
}
+void Q3DSPresentation::setVariantList(const QStringList &variantList)
+{
+ if (d_ptr->m_variantList != variantList) {
+ d_ptr->setVariantList(variantList);
+ Q_EMIT variantListChanged(variantList);
+ }
+}
+
+/*!
+ \internal
+ */
void Q3DSPresentation::registerElement(Q3DSElement *element)
{
d_ptr->registerElement(element);
}
+/*!
+ \internal
+ */
void Q3DSPresentation::unregisterElement(Q3DSElement *element)
{
d_ptr->unregisterElement(element);
}
+/*!
+ \internal
+ */
Q3DSElement *Q3DSPresentation::registeredElement(const QString &elementPath) const
{
return d_ptr->m_elements.value(elementPath, nullptr);
}
+/*!
+ \internal
+ */
void Q3DSPresentation::registerDataInput(Q3DSDataInput *dataInput)
{
d_ptr->registerDataInput(dataInput);
}
+/*!
+ \internal
+ */
void Q3DSPresentation::unregisterDataInput(Q3DSDataInput *dataInput)
{
d_ptr->unregisterDataInput(dataInput);
}
+/*!
+ \internal
+ */
Q3DSDataInput *Q3DSPresentation::registeredDataInput(const QString &name) const
{
return d_ptr->m_dataInputs.value(name, nullptr);
}
+/*!
+ \internal
+ */
void Q3DSPresentation::registerDataOutput(Q3DSDataOutput *dataOutput)
{
d_ptr->registerDataOutput(dataOutput);
}
+/*!
+ \internal
+ */
void Q3DSPresentation::unregisterDataOutput(Q3DSDataOutput *dataOutput)
{
d_ptr->unregisterDataOutput(dataOutput);
}
+/*!
+ \internal
+ */
Q3DSDataOutput *Q3DSPresentation::registeredDataOutput(const QString &name) const
{
return d_ptr->m_dataOutputs.value(name, nullptr);
}
+/*!
+ Returns a list of datainputs defined for this presentation. Use setDataInputValue()
+ interface to set a datainput value using datainput name, or call Q3DSDataInput::setValue
+ directly for a specific datainput.
+
+ \sa setDataInputValue
+ \sa Q3DSDataInput
+ */
QVector<Q3DSDataInput *> Q3DSPresentation::dataInputs() const
{
QVector<Q3DSDataInput *> ret;
@@ -117,17 +312,41 @@ QVector<Q3DSDataInput *> Q3DSPresentation::dataInputs() const
return ret;
}
-QVariantList Q3DSPresentation::getDataOutputs() const
+/*!
+ \qmlmethod variant Presentation::getDataInputs
+ Returns a list of datainputs defined for this presentation. Use setDataInputValue()
+ interface to set a datainput value using datainput name, or call Q3DSDataInput::setValue
+ directly for a specific datainput.
+
+ \sa DataInput
+ */
+
+/*!
+ Returns a list of datainputs defined for this presentation. Use setDataInputValue()
+ interface to set a datainput value using datainput name, or call Q3DSDataInput::setValue
+ directly for a specific datainput.
+
+ \sa setDataInputValue
+ \sa Q3DSDataInput
+ */
+QVariantList Q3DSPresentation::getDataInputs() const
{
QVariantList ret;
- const auto dataoutputs = dataOutputs();
+ const auto datainputs = dataInputs();
- for (const auto &it : dataoutputs)
+ for (const auto &it : datainputs)
ret.append(QVariant::fromValue(it));
return ret;
}
+/*!
+ Returns a list of dataoutputs defined for this presentation. Use Qt's connect() method
+ to connect slots to the valueChanged() signal in the required \l{DataOutput}s to get notified
+ when the value tracked by the DataOutput is changed.
+
+ \sa Q3DSDataOutput
+ */
QVector<Q3DSDataOutput *> Q3DSPresentation::dataOutputs() const
{
QVector<Q3DSDataOutput *> ret;
@@ -138,33 +357,59 @@ QVector<Q3DSDataOutput *> Q3DSPresentation::dataOutputs() const
return ret;
}
-QVariantList Q3DSPresentation::getDataInputs() const
+/*!
+ \qmlmethod variant Presentation::getDataOutputs
+
+ Returns a list of dataoutputs defined for this presentation. Connect slots to the
+ \c{valueChanged()} signal in the required \l{DataOutput}s to get notified
+ when the value tracked by the DataOutput is changed.
+
+ \sa SDataOutput
+ */
+/*!
+ * \brief Q3DSPresentation::getDataOutputs Returns \l{DataOutput}s.
+ Returns a list of dataoutputs defined for this presentation. Use Qt's connect() method
+ to connect slots to the valueChanged() signal in the required \l{DataOutput}s to get notified
+ when the value tracked by the DataOutput is changed.
+
+ \sa Q3DSDataOutput
+ */
+QVariantList Q3DSPresentation::getDataOutputs() const
{
QVariantList ret;
- const auto datainputs = dataInputs();
+ const auto dataoutputs = dataOutputs();
- for (const auto &it : datainputs)
+ for (const auto &it : dataoutputs)
ret.append(QVariant::fromValue(it));
return ret;
}
-void Q3DSPresentation::setSource(const QUrl &source)
-{
- if (d_ptr->m_source != source) {
- d_ptr->setSource(source);
- Q_EMIT sourceChanged(source);
- }
-}
+/*!
+ \qmlproperty bool Presentation::delayedLoading
-void Q3DSPresentation::setVariantList(const QStringList &variantList)
-{
- if (d_ptr->m_variantList != variantList) {
- d_ptr->setVariantList(variantList);
- Q_EMIT variantListChanged(variantList);
- }
-}
+ This property controls whether the presentation resources are loaded while loading
+ the presentation(false) or afterwards when they are actually used in the presentation(true).
+ The resources are loaded per slide basis so that all resources required by a slide will be
+ loaded at once.
+
+ The resources can be images, subpresentations, materials, effects and meshes.
+
+ Default is \c{false}.
+ */
+
+/*!
+ \property Q3DSPresentation::delayedLoading
+
+ This property controls whether the presentation resources are loaded while loading
+ the presentation(false) or afterwards when they are actually used in the presentation(true).
+ The resources are loaded per slide basis so that all resources required by a slide will be
+ loaded at once.
+ The resources can be images, subpresentations, materials, effects and meshes.
+
+ Default is \c{false}.
+ */
bool Q3DSPresentation::delayedLoading() const
{
return d_ptr->m_delayedLoading;
@@ -178,6 +423,18 @@ void Q3DSPresentation::setDelayedLoading(bool enable)
}
}
+/*!
+ \qmlmethod Presentation::preloadSlide
+ Preloads slide resources to memory. All resources required by the given slide will be
+ loaded in the background. This function has effect only when delayed loading is enabled.
+ \param elementPath
+ */
+/*!
+ \brief Q3DSPresentation::preloadSlide
+ Preloads slide resources to memory. All resources required by the given slide will be
+ loaded in the background. This function has effect only when delayed loading is enabled.
+ \param elementPath
+ */
void Q3DSPresentation::preloadSlide(const QString &elementPath)
{
if (d_ptr->m_viewerApp)
@@ -186,6 +443,19 @@ void Q3DSPresentation::preloadSlide(const QString &elementPath)
d_ptr->m_commandQueue->queueCommand(elementPath, CommandType_PreloadSlide);
}
+/*!
+ \qmlmethod Presentation::unloadSlide
+ Unloads slide resources from memory. If the slide is current, then the resources are unloaded
+ when the slide is changed. This function has effect only when delayed loading is enabled.
+ \param elementPath
+ */
+
+/*!
+ \brief Q3DSPresentation::unloadSlide
+ Unloads slide resources from memory. If the slide is current, then the resources are unloaded
+ when the slide is changed. This function has effect only when delayed loading is enabled.
+ \param elementPath
+ */
void Q3DSPresentation::unloadSlide(const QString &elementPath)
{
if (d_ptr->m_viewerApp)
@@ -194,6 +464,21 @@ void Q3DSPresentation::unloadSlide(const QString &elementPath)
d_ptr->m_commandQueue->queueCommand(elementPath, CommandType_UnloadSlide);
}
+/*!
+ This API is for backwards compatibility. We recommend using \l{DataInput}s to control
+ slide changes. \l{DataInput} provides stronger contract between the design and
+ code as it avoids use of elementPath (a reference to design's internal structure).
+
+ Requests a time context (a Scene or a Component object) to change
+ to a specific slide by \a index. If the context is already on that
+ slide, playback will start over.
+
+ If \a elementPath points to a time context, that element is
+ controlled. For all other element types the time context owning
+ that element is controlled instead. You can target the command to
+ a specific sub-presentation by adding "SubPresentationId:" in
+ front of the element path, for example \c{"SubPresentationOne:Scene"}.
+ */
void Q3DSPresentation::goToSlide(const QString &elementPath, unsigned int index)
{
if (d_ptr->m_viewerApp) {
@@ -204,6 +489,21 @@ void Q3DSPresentation::goToSlide(const QString &elementPath, unsigned int index)
}
}
+/*!
+ This API is for backwards compatibility. We recommend using \l{DataInput}s to control
+ slide changes. \l{DataInput} provides stronger contract between the design and
+ code as it avoids use of elementPath (a reference to design's internal structure).
+
+ Requests a time context (a Scene or a Component object) to change
+ to a specific slide by \a name. If the context is already on that
+ slide, playback will start over.
+
+ If \a elementPath points to a time context, that element is
+ controlled. For all other element types the time context owning
+ that element is controlled instead. You can target the command to
+ a specific sub-presentation by adding "SubPresentationId:" in
+ front of the element path, for example \c{"SubPresentationOne:Scene"}.
+ */
void Q3DSPresentation::goToSlide(const QString &elementPath, const QString &name)
{
if (d_ptr->m_viewerApp) {
@@ -215,6 +515,22 @@ void Q3DSPresentation::goToSlide(const QString &elementPath, const QString &name
}
}
+/*!
+ This API is for backwards compatibility. We recommend using \l{DataInput}s to control
+ slide changes. \l{DataInput} provides stronger contract between the design and
+ code as it avoids use of elementPath (a reference to design's internal structure).
+
+ Requests a time context (a Scene or a Component object) to change to the
+ next or previous slide, depending on the value of \a next. If the context
+ is already at the last or first slide, \a wrap defines if wrapping over to
+ the first or last slide, respectively, occurs.
+
+ If \a elementPath points to a time context, that element is controlled. For
+ all other element types the time context owning that element is controlled
+ instead. You can target the command to a specific sub-presentation by
+ adding "SubPresentationId:" in front of the element path, for example
+ \c{"SubPresentationOne:Scene"}.
+ */
void Q3DSPresentation::goToSlide(const QString &elementPath, bool next, bool wrap)
{
if (d_ptr->m_viewerApp) {
@@ -226,6 +542,36 @@ void Q3DSPresentation::goToSlide(const QString &elementPath, bool next, bool wra
}
}
+/*!
+ This API is for backwards compatibility. We recommend using \l{DataInput}s to control
+ slide changes. \l{DataInput} provides stronger contract between the design and
+ code as it avoids use of elementPath (a reference to design's internal structure).
+
+ Moves the timeline for a time context (a Scene or a Component element) to a
+ specific position. The position is given in seconds in \a timeSeconds.
+
+ If \a elementPath points to a time context, that element is
+ controlled. For all other element types the time context owning
+ that element is controlled instead. You can target the command to
+ a specific sub-presentation by adding "SubPresentationId:" in
+ front of the element path, for example
+ \c{"SubPresentationOne:Scene"}.
+
+ The behavior when specifying a time before 0 or after the end time
+ for the current slide depends on the play mode of the slide:
+
+ \list
+ \li \c{Stop at End} - values outside the valid time range instead clamp to the boundaries.
+ For example, going to time -5 is the same as going to time 0.
+ \li \c{Looping} - values outside the valid time range mod into the valid range. For example,
+ going to time -4 on a 10 second slide is the same as going to time 6.
+ \li \c{Ping Pong} - values outside the valid time range bounce off the ends. For example,
+ going to time -4 is the same as going to time 4 (assuming the time context is at least 4 seconds
+ long), while going to time 12 on a 10 second slide is the same as going to time 8.
+ \li \c{Ping} - values less than 0 are treated as time 0, while values greater than the endtime
+ bounce off the end (eventually hitting 0.)
+ \endlist
+ */
void Q3DSPresentation::goToTime(const QString &elementPath, float time)
{
if (d_ptr->m_viewerApp) {
@@ -236,6 +582,30 @@ void Q3DSPresentation::goToTime(const QString &elementPath, float time)
}
}
+/*!
+ This API is for backwards compatibility. We recommend using \l{DataInput}s to control
+ attributes in the presentation. \l{DataInput} provides stronger contract between the
+ design and code as it avoids use of elementPath (a reference to design's
+ internal structure).
+
+ Sets the \a value of an attribute (property) on the object specified by
+ \a elementPath. The \a attributeName is the \l{Attribute Names}{scripting
+ name} of the attribute.
+
+ An element path refers to an object in the scene by name, for example,
+ \c{Scene.Layer.Camera}. Here the right camera object gets chosen even if
+ the scene contains other layers with the default camera names (for instance
+ \c{Scene.Layer2.Camera}).
+
+ To reference an object stored in a property of another object, the dot
+ syntax can be used. The most typical example of this is changing the source
+ of a texture map by changing the \c sourcepath property on the object
+ selected by \c{SomeMaterial.diffusemap}.
+
+ To access an object in a sub-presentation, prepend the name of the
+ sub-presentation followed by a colon, for example,
+ \c{SubPresentationOne:Scene.Layer.Camera}.
+ */
void Q3DSPresentation::setAttribute(const QString &elementPath, const QString &attributeName,
const QVariant &value)
{
@@ -268,6 +638,12 @@ void Q3DSPresentation::setAttribute(const QString &elementPath, const QString &a
}
}
+// #TODO: QT3DS-3558
+/*!
+ \brief Q3DSPresentation::setPresentationActive
+ \param id
+ \param active
+ */
void Q3DSPresentation::setPresentationActive(const QString &id, bool active)
{
if (d_ptr->m_viewerApp) {
@@ -278,6 +654,15 @@ void Q3DSPresentation::setPresentationActive(const QString &id, bool active)
}
}
+/*!
+ Dispatches a Qt 3D Studio presentation event with \a eventName on
+ scene object specified by \a elementPath. These events provide a
+ way to communicate with the \c .qml based \c{behavior scripts}
+ attached to scene objects since they can register to be notified
+ via Behavior::registerForEvent().
+
+ See setAttribute() for a description of \a elementPath.
+ */
void Q3DSPresentation::fireEvent(const QString &elementPath, const QString &eventName)
{
if (d_ptr->m_viewerApp) {
@@ -289,6 +674,11 @@ void Q3DSPresentation::fireEvent(const QString &elementPath, const QString &even
}
}
+// #TODO: QT3DS-3559
+/*!
+ \brief Q3DSPresentation::setGlobalAnimationTime
+ \param milliseconds
+ */
void Q3DSPresentation::setGlobalAnimationTime(qint64 milliseconds)
{
if (d_ptr->m_viewerApp) {
@@ -299,6 +689,23 @@ void Q3DSPresentation::setGlobalAnimationTime(qint64 milliseconds)
}
}
+/*!
+ Sets the \a value of a data input element \a name in the presentation.
+
+ Data input provides a higher level, designer-driven alternative to
+ Q3DSElement and setAttribute(). Instead of exposing a large set of
+ properties with their internal engine names, data input allows designers to
+ decide which properties should be writable by the application, and can
+ assign custom names to these data input entries, thus forming a
+ well-defined contract between the designer and the developer.
+
+ In addition, data input also allows controlling the time line and the
+ current slide for time context objects (Scene or Component). Therefore it
+ is also an alternative to the goToSlide() and goToTime() family of APIs and
+ to Q3DSSceneElement.
+
+ \sa DataInput
+ */
void Q3DSPresentation::setDataInputValue(const QString &name, const QVariant &value,
Q3DSDataInput::ValueRole valueRole)
{
@@ -311,13 +718,14 @@ void Q3DSPresentation::setDataInputValue(const QString &name, const QVariant &va
}
}
-/**
- Adds a new child element for the element specified by parentElementPath to the slide specified
- with slideName. Only model element creation is currently supported.
+/*!
+ * \brief Q3DSPresentation::createElement Adds a new child element for the specified element.
+ Adds a new child element for the element specified by parentElementPath to the slide
+ specified with slideName. Only model element creation is currently supported.
A referenced material element is also created for the new model element. The source material
name can be specified with custom "material" property in the properties hash.
The source material must exist in the material container of the presentation.
-*/
+ */
void Q3DSPresentation::createElement(const QString &parentElementPath, const QString &slideName,
const QHash<QString, QVariant> &properties)
{
@@ -326,6 +734,13 @@ void Q3DSPresentation::createElement(const QString &parentElementPath, const QSt
createElements(parentElementPath, slideName, theProperties);
}
+// #TODO: QT3DS-3560
+/*!
+ \brief Q3DSPresentation::createElements
+ \param parentElementPath
+ \param slideName
+ \param properties
+ */
void Q3DSPresentation::createElements(const QString &parentElementPath, const QString &slideName,
const QVector<QHash<QString, QVariant>> &properties)
{
@@ -340,9 +755,11 @@ void Q3DSPresentation::createElements(const QString &parentElementPath, const QS
}
}
-/**
+/*!
+ \brief Q3DSPresentation::deleteElement
Removes an element added by createElement and all its child elements.
-*/
+ \param elementPath
+ */
void Q3DSPresentation::deleteElement(const QString &elementPath)
{
QStringList elementPaths;
@@ -350,6 +767,11 @@ void Q3DSPresentation::deleteElement(const QString &elementPath)
deleteElements(elementPaths);
}
+/*!
+ \brief Q3DSPresentation::deleteElements
+ Removes the given list of elements added by createElement and all their child elements.
+ \param elementPaths QStringList containing the elementPaths of dynamically created objects.
+ */
void Q3DSPresentation::deleteElements(const QStringList &elementPaths)
{
if (d_ptr->m_viewerApp) {
@@ -361,13 +783,16 @@ void Q3DSPresentation::deleteElements(const QStringList &elementPaths)
}
}
-/**
+/*!
+ \brief Q3DSPresentation::createMaterial
Creates a material specified by the materialDefinition parameter into the material
container of the presentation that owns the element specified by the elementPath parameter.
After creation, the material can be used for new elements created via createElement.
The materialDefinition parameter can contain either the file path to a material definition
file or a material definition in the Qt 3D Studion material data format.
-*/
+ \param elementPath
+ \param materialDefinition
+ */
void Q3DSPresentation::createMaterial(const QString &elementPath,
const QString &materialDefinition)
{
@@ -376,6 +801,12 @@ void Q3DSPresentation::createMaterial(const QString &elementPath,
createMaterials(elementPath, materialDefinitions);
}
+/*!
+ \brief Q3DSPresentation::createMaterials
+ Same as createMaterial, but creates multiple materials.
+ \param elementPath
+ \param materialDefinitions
+ */
void Q3DSPresentation::createMaterials(const QString &elementPath,
const QStringList &materialDefinitions)
{
@@ -467,6 +898,9 @@ void Q3DSPresentation::mousePressEvent(QMouseEvent *e)
}
}
+/*!
+ * \internal
+ */
void Q3DSPresentation::mouseReleaseEvent(QMouseEvent *e)
{
if (d_ptr->m_viewerApp) {
@@ -477,6 +911,9 @@ void Q3DSPresentation::mouseReleaseEvent(QMouseEvent *e)
}
}
+/*!
+ * \internal
+ */
void Q3DSPresentation::mouseMoveEvent(QMouseEvent *e)
{
if (d_ptr->m_viewerApp) {
@@ -487,6 +924,9 @@ void Q3DSPresentation::mouseMoveEvent(QMouseEvent *e)
}
}
+/*!
+ * \internal
+ */
void Q3DSPresentation::wheelEvent(QWheelEvent *e)
{
QPoint pixelData = e->pixelDelta();
@@ -516,6 +956,9 @@ void Q3DSPresentation::wheelEvent(QWheelEvent *e)
}
}
+/*!
+ * \internal
+ */
void Q3DSPresentation::keyPressEvent(QKeyEvent *e)
{
if (d_ptr->m_viewerApp) {
@@ -526,6 +969,9 @@ void Q3DSPresentation::keyPressEvent(QKeyEvent *e)
}
}
+/*!
+ * \internal
+ */
void Q3DSPresentation::keyReleaseEvent(QKeyEvent *e)
{
if (d_ptr->m_viewerApp) {
@@ -536,6 +982,97 @@ void Q3DSPresentation::keyReleaseEvent(QKeyEvent *e)
}
}
+// #TODO: QT3DS-3562 Most Presentation signals missing documentation
+/*!
+ * \qmlsignal Presentation::slideEntered
+ * Emitted when
+ * \param elementPath
+ * \param index
+ * \param name
+ */
+
+/*!
+ * \fn Q3DSPresentation::slideEntered
+ * Emitted when
+ * \param elementPath
+ * \param index
+ * \param name
+ */
+
+/*!
+ * \qmlsignal Presentation::slideExited
+ * Emitted when
+ * \param elementPath
+ * \param index
+ * \param name
+ */
+
+/*!
+ * \fn Q3DSPresentation::slideExited
+ * Emitted when
+ * \param elementPath
+ * \param index
+ * \param name
+ */
+
+/*!
+ * \fn Q3DSPresentation::dataInputsReady
+ * Emitted when \l{DataInput}s in the Studio project have been parsed and data inputs are available
+ * through dataInputs() and getDataInputs() methods.
+ */
+
+/*!
+ * \fn Q3DSPresentation::dataOutputsReady
+ * Emitted when \l{DataOutput}s in the Studio project have been parsed and data outputs are available
+ * through dataOutputs() and getDataOutputs() methods.
+ */
+
+/*!
+ * \qmlsignal Presentation::customSignalEmitted
+ * Emitted when
+ * \param elementPath
+ * \param name
+ */
+
+/*!
+ * \fn Q3DSPresentation::customSignalEmitted
+ * Emitted when
+ * \param elementPath
+ * \param name
+ */
+
+/*!
+ * \qmlsignal Presentation::elementsCreated
+ * Emitted when
+ * \param elementPaths
+ * \param error
+ */
+
+/*!
+ * \fn Q3DSPresentation::elementsCreated
+ * Emitted when
+ * \param elementPaths
+ * \param error
+ */
+
+/*!
+ * \qmlsignal Presentation::materialsCreated
+ * Emitted when
+ * \param materialNames
+ * \param error
+ */
+
+/*!
+ * \fn Q3DSPresentation::materialsCreated
+ * Emitted when
+ * \param materialNames
+ * \param error
+ */
+
+
+/*!
+ * \internal
+ */
Q3DSPresentationPrivate::Q3DSPresentationPrivate(Q3DSPresentation *q)
: QObject(q)
, q_ptr(q)
diff --git a/src/Runtime/api/studio3d/q3dspresentation.h b/src/Runtime/api/studio3d/q3dspresentation.h
index bcdd9c53..436e6844 100644
--- a/src/Runtime/api/studio3d/q3dspresentation.h
+++ b/src/Runtime/api/studio3d/q3dspresentation.h
@@ -128,8 +128,6 @@ Q_SIGNALS:
void sourceChanged(const QUrl &source);
void slideEntered(const QString &elementPath, unsigned int index, const QString &name);
void slideExited(const QString &elementPath, unsigned int index, const QString &name);
- // Indicates that data input and output definitions in the Studio project have been parsed
- // and datainputs/dataoutputs are available through dataInputs() / getDataInputs().
void dataInputsReady();
void dataOutputsReady();
void customSignalEmitted(const QString &elementPath, const QString &name);
diff --git a/src/Runtime/api/studio3d/q3dssceneelement.cpp b/src/Runtime/api/studio3d/q3dssceneelement.cpp
index 2eef5d00..3f860d65 100644
--- a/src/Runtime/api/studio3d/q3dssceneelement.cpp
+++ b/src/Runtime/api/studio3d/q3dssceneelement.cpp
@@ -37,16 +37,63 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmltype SceneElement
+ \instantiates Q3DSSceneElement
+ \inqmlmodule Qt3DStudio
+ \ingroup OpenGLRuntime
+ \brief Controls the special Scene or Component scene objects in a Qt 3D
+ Studio presentation.
+
+ This class is a convenience class for controlling the properties of Scene
+ and Component objects in the scene. These are special since they have a
+ time context, meaning they control a timeline and a set of associated
+ slides.
+
+ \sa Studio3D, Element, Presentation
+*/
+
+/*!
+ \class Q3DSSceneElement
+ \inherits Q3DSElement
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.0
+
+ \brief Controls the special Scene or Component scene objects in a Qt 3D
+ Studio presentation.
+
+ This class is a convenience class for controlling the properties of Scene
+ and Component objects in the scene. These are special since they have a
+ time context, meaning they control a timline and a set of associated
+ slides.
+
+ \note The functionality of Q3DSSceneElement is equivalent to
+ Q3DSPresentation::goToTime() and Q3DSPresentation::goToSlide().
+
+ \sa Q3DSPresentation, Q3DSWidget, Q3DSSurfaceViewer, Q3DSElement
+ */
+
+/*!
+ \internal
+ */
Q3DSSceneElement::Q3DSSceneElement(QObject *parent)
: Q3DSElement(new Q3DSSceneElementPrivate(this), nullptr, QString(), parent)
{
}
+/*!
+ \internal
+ */
Q3DSSceneElement::Q3DSSceneElement(const QString &elementPath, QObject *parent)
: Q3DSElement(new Q3DSSceneElementPrivate(this), nullptr, elementPath, parent)
{
}
+/*!
+ Constructs a Q3DSSceneElement instance and associated it with the object
+ specified by \a elementPath and the given \a presentation. An optional \a
+ parent object can be specified.
+ */
Q3DSSceneElement::Q3DSSceneElement(Q3DSPresentation *presentation, const QString &elementPath,
QObject *parent)
: Q3DSElement(new Q3DSSceneElementPrivate(this), presentation, elementPath, parent)
@@ -54,32 +101,42 @@ Q3DSSceneElement::Q3DSSceneElement(Q3DSPresentation *presentation, const QString
}
+/*!
+ Destructor.
+ */
Q3DSSceneElement::~Q3DSSceneElement()
{
}
-int Q3DSSceneElement::currentSlideIndex() const
-{
- Q_D(const Q3DSSceneElement);
- return d->m_currentSlideIndex;
-}
+/*!
+ \qmlproperty int SceneElement::currentSlideIndex
-int Q3DSSceneElement::previousSlideIndex() const
-{
- Q_D(const Q3DSSceneElement);
- return d->m_previousSlideIndex;
-}
+ Holds the index of the currently active slide of the tracked time context.
-QString Q3DSSceneElement::currentSlideName() const
-{
- Q_D(const Q3DSSceneElement);
- return d->m_currentSlideName;
-}
+ \note If this property is set to something else than the default slide for
+ the scene at the initial declaration of SceneElement, a changed signal for
+ the default slide may still be emitted before the slide changes to the
+ desired one. This happens in order to ensure we end up with the index of
+ the slide that is actually shown even if the slide specified in the initial
+ declaration is invalid.
+*/
-QString Q3DSSceneElement::previousSlideName() const
+/*!
+ \property Q3DSSceneElement::currentSlideIndex
+
+ Holds the index of the currently active slide of the tracked time context.
+
+ \note If this property is set to something else than the default slide for
+ the scene at the initial declaration of SceneElement, a changed signal for
+ the default slide may still be emitted before the slide changes to the
+ desired one. This happens in order to ensure we end up with the index of
+ the slide that is actually shown even if the slide specified in the initial
+ declaration is invalid.
+*/
+int Q3DSSceneElement::currentSlideIndex() const
{
Q_D(const Q3DSSceneElement);
- return d->m_previousSlideName;
+ return d->m_currentSlideIndex;
}
void Q3DSSceneElement::setCurrentSlideIndex(int currentSlideIndex)
@@ -98,6 +155,57 @@ void Q3DSSceneElement::setCurrentSlideIndex(int currentSlideIndex)
}
}
+/*!
+ \property int SceneElement::previousSlideIndex
+
+ Holds the index of the previously active slide of the tracked time context.
+
+ Note: This property is read-only.
+*/
+/*!
+ \property Q3DSSceneElement::previousSlideIndex
+
+ Holds the index of the previously active slide of the tracked time context.
+
+ This property is read-only.
+*/
+int Q3DSSceneElement::previousSlideIndex() const
+{
+ Q_D(const Q3DSSceneElement);
+ return d->m_previousSlideIndex;
+}
+
+/*!
+ \qmlproperty string SceneElement::currentSlideName
+
+ Holds the name of the currently active slide of the tracked time context.
+
+ \note If this property is set to something else than the default slide for
+ the scene at the initial declaration of SceneElement, a changed signal for
+ the default slide may still be emitted before the slide changes to the
+ desired one. This happens in order to ensure we end up with the index of
+ the slide that is actually shown even if the slide specified in the initial
+ declaration is invalid.
+*/
+
+/*!
+ \property Q3DSSceneElement::currentSlideName
+
+ Holds the name of the currently active slide of the tracked time context.
+
+ \note If this property is set to something else than the default slide for
+ the scene at the initial declaration of SceneElement, a changed signal for
+ the default slide may still be emitted before the slide changes to the
+ desired one. This happens in order to ensure we end up with the index of
+ the slide that is actually shown even if the slide specified in the initial
+ declaration is invalid.
+*/
+QString Q3DSSceneElement::currentSlideName() const
+{
+ Q_D(const Q3DSSceneElement);
+ return d->m_currentSlideName;
+}
+
void Q3DSSceneElement::setCurrentSlideName(const QString &currentSlideName)
{
Q_D(Q3DSSceneElement);
@@ -115,18 +223,52 @@ void Q3DSSceneElement::setCurrentSlideName(const QString &currentSlideName)
}
}
+/*!
+ \qmlmproperty string SceneElement::previousSlideName
+
+ Holds the name of the previously active slide of the tracked time context.
+
+ Note: This property is read-only.
+*/
+/*!
+ \property Q3DSSceneElement::previousSlideName
+
+ Holds the name of the previously active slide of the tracked time context.
+
+ This property is read-only.
+*/
+QString Q3DSSceneElement::previousSlideName() const
+{
+ Q_D(const Q3DSSceneElement);
+ return d->m_previousSlideName;
+}
+
+/*!
+ Requests a time context (a Scene or a Component object) to change to the
+ next or previous slide, depending on the value of \a next. If the context
+ is already at the last or first slide, \a wrap defines if wrapping over to
+ the first or last slide, respectively, occurs.
+ */
void Q3DSSceneElement::goToSlide(bool next, bool wrap)
{
Q_D(Q3DSSceneElement);
d->goToSlide(next, wrap);
}
+/*!
+ Moves the timeline for a time context (a Scene or a Component element) to a
+ specific position. The position is given in seconds in \a timeSeconds.
+ */
void Q3DSSceneElement::goToTime(float time)
{
Q_D(Q3DSSceneElement);
d->goToTime(time);
}
+
+/*!
+ \internal
+ */
Q3DSSceneElementPrivate::Q3DSSceneElementPrivate(Q3DSSceneElement *parent)
: Q3DSElementPrivate(parent)
, m_currentSlideIndex(0)
@@ -136,10 +278,16 @@ Q3DSSceneElementPrivate::Q3DSSceneElementPrivate(Q3DSSceneElement *parent)
{
}
+/*!
+ \internal
+ */
Q3DSSceneElementPrivate::~Q3DSSceneElementPrivate()
{
}
+/*!
+ \internal
+ */
void Q3DSSceneElementPrivate::handleSlideEntered(int index, const QString &name)
{
Q_Q(Q3DSSceneElement);
@@ -175,6 +323,9 @@ void Q3DSSceneElementPrivate::handleSlideEntered(int index, const QString &name)
}
}
+/*!
+ \internal
+ */
void Q3DSSceneElementPrivate::goToSlide(bool next, bool wrap)
{
if (m_presentation)
@@ -183,6 +334,9 @@ void Q3DSSceneElementPrivate::goToSlide(bool next, bool wrap)
qWarning() << __FUNCTION__ << "Element is not registered to any presentation!";
}
+/*!
+ \internal
+ */
void Q3DSSceneElementPrivate::goToTime(float time)
{
if (m_presentation)
@@ -191,6 +345,9 @@ void Q3DSSceneElementPrivate::goToTime(float time)
qWarning() << __FUNCTION__ << "Element is not registered to any presentation!";
}
+/*!
+ \internal
+ */
void Q3DSSceneElementPrivate::setViewerApp(Q3DSViewer::Q3DSViewerApp *app)
{
Q_Q(Q3DSSceneElement);
@@ -221,6 +378,9 @@ void Q3DSSceneElementPrivate::setViewerApp(Q3DSViewer::Q3DSViewerApp *app)
}
}
+/*!
+ \internal
+ */
void Q3DSSceneElementPrivate::setCommandQueue(CommandQueue *queue)
{
Q_Q(Q3DSSceneElement);
@@ -248,6 +408,9 @@ void Q3DSSceneElementPrivate::setCommandQueue(CommandQueue *queue)
}
}
+/*!
+ \internal
+ */
void Q3DSSceneElementPrivate::requestResponseHandler(CommandType commandType, void *requestData)
{
switch (commandType) {
diff --git a/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp b/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp
index cea764e7..bd0fd6aa 100644
--- a/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp
+++ b/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp
@@ -47,42 +47,154 @@ using namespace Q3DSViewer;
QT_BEGIN_NAMESPACE
+/*!
+ \class Q3DSSurfaceViewer
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.0
+
+ \brief Renders a Qt 3D Studio presentation on a QWindow or an offscreen
+ render target using OpenGL.
+
+ Q3DSSurfaceViewer is used to render Qt 3D Studio presentations onto a
+ QSurface. In practice this means two types of uses: rendering to an
+ on-screen QWindow, or rendering to an offscreen render target (typically an
+ OpenGL texture via a framebuffer object and a QOffscreenSurface).
+
+ \section2 Example Usage
+
+ \code
+ int main(int argc, char *argv[])
+ {
+ QGuiApplication app(argc, argv);
+
+ QOpenGLContext context;
+ context.create();
+
+ QWindow window;
+ window.setSurfaceType(QSurface::OpenGLSurface);
+ window.setFormat(context.format());
+ window.create();
+
+ Q3DSSurfaceViewer viewer;
+ viewer.presentation()->setSource(QUrl(QStringLiteral("qrc:/my_presentation.uip")));
+ viewer.setUpdateInterval(0); // enable automatic updates
+
+ // Register a scene object for slide management (optional)
+ Q3DSSceneElement scene(viewer.presentation(), QStringLiteral("Scene"));
+
+ // Register an element object for attribute setting (optional)
+ Q3DSElement element(viewer.presentation(), QStringLiteral("Scene.Layer.myCarModel"));
+
+ viewer.create(&window, &context);
+
+ w.resize(1024, 768);
+ w.show();
+
+ return app.exec();
+ }
+ \endcode
+
+ \sa Q3DSWidget
+ */
+
+/*!
+ * \brief Q3DSSurfaceViewer::Q3DSSurfaceViewer Constructor.
+ * \param parent Optional parent of the object.
+ */
Q3DSSurfaceViewer::Q3DSSurfaceViewer(QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSSurfaceViewerPrivate(this))
{
}
+/*!
+ * \brief Q3DSSurfaceViewer::~Q3DSSurfaceViewer Destructor
+ */
Q3DSSurfaceViewer::~Q3DSSurfaceViewer()
{
delete d_ptr;
}
-bool Q3DSSurfaceViewer::initialize(QSurface *surface, QOpenGLContext *context, GLuint fboId)
+/*!
+ Initializes Q3DSSurfaceViewer to render the presentation to the given
+ \a surface using the \a context.
+
+ The source property of the attached presentation must be set before the
+ viewer can be initialized.
+
+ Returns whether the initialization succeeded.
+
+ \sa running, Q3DSPresentation::source, presentation()
+*/
+bool Q3DSSurfaceViewer::create(QSurface *surface, QOpenGLContext *context)
+{
+ // #TODO: QT3DS-3531 Fix this to behave as in RT2
+ return create(surface, context, 0);
+}
+
+
+/*!
+ Initializes Q3DSSurfaceViewer to render the presentation to the given
+ \a surface using the \a context and optional framebuffer id (\a fboId). If
+ \a fboId is omitted, it defaults to zero.
+
+ The source property of the attached presentation must be set before the
+ viewer can be initialized.
+
+ Returns whether the initialization succeeded.
+
+ \sa running, Q3DSPresentation::source, presentation()
+*/
+bool Q3DSSurfaceViewer::create(QSurface *surface, QOpenGLContext *context, GLuint fboId)
{
return d_ptr->initialize(surface, context, fboId);
}
-void Q3DSSurfaceViewer::shutdown()
+/*!
+ Releases the presentation and all related resources.
+ The Q3DSSurfaceViewer instance can be reused by calling create() again.
+ */
+void Q3DSSurfaceViewer::destroy()
{
d_ptr->shutdown();
}
+/*!
+ \brief Q3DSSurfaceViewer::reset
+ */
void Q3DSSurfaceViewer::reset()
{
d_ptr->reset();
}
+/*!
+ Updates the surface viewer with a new frame.
+*/
void Q3DSSurfaceViewer::update()
{
d_ptr->update();
}
+/*!
+ Grabs the data rendered to the framebuffer into an image using the given \a
+ rect. The \a rect parameter is optional. If it is omitted, the whole
+ framebuffer is captured.
+
+ \note This is a potentially expensive operation.
+*/
QImage Q3DSSurfaceViewer::grab(const QRect &rect)
{
return d_ptr->grab(rect);
}
+/*!
+ \property Q3DSSurfaceViewer::size
+
+ Holds the desired size of the presentation. Relevant only when
+ autoSize is set to \c false.
+
+ \sa autoSize
+*/
QSize Q3DSSurfaceViewer::size() const
{
return d_ptr->m_size;
@@ -93,6 +205,22 @@ void Q3DSSurfaceViewer::setSize(const QSize &size)
d_ptr->setSize(size);
}
+/*!
+ \property Q3DSSurfaceViewer::autoSize
+
+ Specifies whether the viewer should change the size of the presentation
+ automatically to match the surface size when surface size changes. The
+ \l{Q3DSSurfaceViewer::size}{size} property is updated automatically
+ whenever the viewer is \l{Q3DSSurfaceViewer::update()}{updated} if this
+ property value is \c{true}.
+
+ When rendering offscreen, via a QOffscreenSurface, this property must be
+ set to \c{false} by the application since it is then up to the application
+ to provide a QOpenGLFramebufferObject with the desired size. The size of
+ the Q3DSSurfaceViewer must be set to the same value.
+
+ The default value is \c{true}.
+*/
bool Q3DSSurfaceViewer::autoSize() const
{
return d_ptr->m_autoSize;
@@ -106,6 +234,17 @@ void Q3DSSurfaceViewer::setAutoSize(bool autoSize)
}
}
+/*!
+ \property Q3DSSurfaceViewer::updateInterval
+
+ Holds the viewer update interval in milliseconds. If the value is negative,
+ the viewer doesn't update the presentation automatically.
+
+ The default value is -1, meaning there are no automatic updates and
+ update() must be called manually.
+
+ \sa update()
+*/
int Q3DSSurfaceViewer::updateInterval() const
{
return d_ptr->m_updateInterval;
@@ -116,41 +255,78 @@ void Q3DSSurfaceViewer::setUpdateInterval(int interval)
d_ptr->setUpdateInterval(interval);
}
+/*!
+ \property Q3DSSurfaceViewer::running
+
+ The value of this property is \c true when the presentation has been loaded
+ and is ready to be shown.
+
+ This property is read-only.
+*/
bool Q3DSSurfaceViewer::isRunning() const
{
return d_ptr->m_viewerApp != nullptr;
}
+// #TODO QT3DS-3534
+
+/*!
+ \property Q3DSSurfaceViewer::presentationId
+ */
QString Q3DSSurfaceViewer::presentationId() const
{
return d_ptr->m_id;
}
+/*!
+ Returns the framebuffer id given in initialization.
+
+ \sa create()
+*/
int Q3DSSurfaceViewer::fboId() const
{
return d_ptr->m_fboId;
}
+/*!
+ Returns the surface given in initialization.
+
+ \sa create()
+*/
QSurface *Q3DSSurfaceViewer::surface() const
{
return d_ptr->m_surface;
}
+/*!
+ Returns the context given in initialization.
+
+ \sa create()
+*/
QOpenGLContext *Q3DSSurfaceViewer::context() const
{
return d_ptr->m_context;
}
+/*!
+ Returns the settings object used by the Q3DSSurfaceViewer.
+*/
Q3DSViewerSettings *Q3DSSurfaceViewer::settings() const
{
return d_ptr->m_settings;
}
+/*!
+ Returns the presentation object used by the Q3DSSurfaceViewer.
+*/
Q3DSPresentation *Q3DSSurfaceViewer::presentation() const
{
return d_ptr->m_presentation;
}
+/*!
+ * \internal
+ */
void Q3DSSurfaceViewer::setPresentationId(const QString &id)
{
if (d_ptr->m_id != id) {
@@ -161,6 +337,51 @@ void Q3DSSurfaceViewer::setPresentationId(const QString &id)
}
}
+// TODO: QT3DS-3563
+
+/*!
+ * \brief Q3DSSurfaceViewer::qmlEngine
+ * \return
+ */
+QQmlEngine *Q3DSSurfaceViewer::qmlEngine() const
+{
+ Q_D(const Q3DSSurfaceViewer);
+ return d->qmlEngine;
+}
+
+/*!
+ * \brief Q3DSSurfaceViewer::setQmlEngine
+ * \param qmlEngine
+ */
+void Q3DSSurfaceViewer::setQmlEngine(QQmlEngine *qmlEngine)
+{
+ Q_D(Q3DSSurfaceViewer);
+ d->qmlEngine = qmlEngine;
+}
+
+
+/*!
+ \fn Q3DSSurfaceViewer::frameUpdate()
+
+ Emitted each time a frame has been rendered.
+*/
+
+/*!
+ \fn Q3DSSurfaceViewer::presentationLoaded()
+
+ Emitted when the presentation has been loaded and is ready
+ to be shown.
+*/
+
+/*!
+ \fn Q3DSSurfaceViewer::presentationReady()
+ Emitted when first frame is about to be shown. DataInputs and setAttribute
+ are ready to be used after this signal.
+ */
+
+/*!
+ * \internal
+ */
Q3DSSurfaceViewerPrivate::Q3DSSurfaceViewerPrivate(Q3DSSurfaceViewer *q)
: QObject(q)
, q_ptr(q)
@@ -180,6 +401,9 @@ Q3DSSurfaceViewerPrivate::Q3DSSurfaceViewerPrivate(Q3DSSurfaceViewer *q)
this, &Q3DSSurfaceViewerPrivate::reset);
}
+/*!
+ * \internal
+ */
Q3DSSurfaceViewerPrivate::~Q3DSSurfaceViewerPrivate()
{
releaseRuntime();
@@ -187,6 +411,9 @@ Q3DSSurfaceViewerPrivate::~Q3DSSurfaceViewerPrivate()
delete m_timer;
}
+/*!
+ * \internal
+ */
void Q3DSSurfaceViewerPrivate::reset()
{
if (m_viewerApp) {
@@ -195,6 +422,9 @@ void Q3DSSurfaceViewerPrivate::reset()
}
}
+/*!
+ * \internal
+ */
void Q3DSSurfaceViewerPrivate::setSize(const QSize &size)
{
if (m_size != size) {
@@ -210,6 +440,9 @@ void Q3DSSurfaceViewerPrivate::setSize(const QSize &size)
}
}
+/*!
+ * \internal
+ */
void Q3DSSurfaceViewerPrivate::setUpdateInterval(int interval)
{
if (m_updateInterval != interval) {
@@ -219,6 +452,9 @@ void Q3DSSurfaceViewerPrivate::setUpdateInterval(int interval)
}
}
+/*!
+ * \internal
+ */
bool Q3DSSurfaceViewerPrivate::initialize(QSurface *surface, QOpenGLContext *context, GLuint fboId)
{
Q_ASSERT(context);
@@ -257,7 +493,9 @@ bool Q3DSSurfaceViewerPrivate::initialize(QSurface *surface, QOpenGLContext *con
return success;
}
-
+/*!
+ * \internal
+ */
void Q3DSSurfaceViewerPrivate::shutdown()
{
bool oldInitialized = (m_viewerApp != nullptr);
@@ -280,7 +518,9 @@ void Q3DSSurfaceViewerPrivate::shutdown()
Q_EMIT q_ptr->runningChanged(false);
}
-
+/*!
+ * \internal
+ */
void Q3DSSurfaceViewerPrivate::update()
{
if (m_viewerApp && m_viewerApp->IsInitialised()) {
@@ -302,6 +542,9 @@ void Q3DSSurfaceViewerPrivate::update()
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format,
bool include_alpha);
+/*!
+ * \internal
+ */
QImage Q3DSSurfaceViewerPrivate::grab(const QRect &rect)
{
QRect captureRect;
@@ -341,18 +584,9 @@ QImage Q3DSSurfaceViewerPrivate::grab(const QRect &rect)
return image;
}
-QQmlEngine *Q3DSSurfaceViewer::qmlEngine() const
-{
- Q_D(const Q3DSSurfaceViewer);
- return d->qmlEngine;
-}
-
-void Q3DSSurfaceViewer::setQmlEngine(QQmlEngine *qmlEngine)
-{
- Q_D(Q3DSSurfaceViewer);
- d->qmlEngine = qmlEngine;
-}
-
+/*!
+ * \internal
+ */
bool Q3DSSurfaceViewerPrivate::eventFilter(QObject *obj, QEvent *e)
{
if (m_surface && e->type() == QEvent::PlatformSurface) {
@@ -365,6 +599,9 @@ bool Q3DSSurfaceViewerPrivate::eventFilter(QObject *obj, QEvent *e)
return QObject::eventFilter(obj, e);
}
+/*!
+ * \internal
+ */
bool Q3DSSurfaceViewerPrivate::initializeRuntime()
{
Q_ASSERT(!m_viewerApp);
@@ -407,6 +644,9 @@ bool Q3DSSurfaceViewerPrivate::initializeRuntime()
return true;
}
+/*!
+ * \internal
+ */
void Q3DSSurfaceViewerPrivate::releaseRuntime()
{
m_settings->d_ptr->setViewerApp(nullptr);
@@ -423,6 +663,9 @@ void Q3DSSurfaceViewerPrivate::releaseRuntime()
resetUpdateTimer();
}
+/*!
+ * \internal
+ */
void Q3DSSurfaceViewerPrivate::resetUpdateTimer()
{
if (m_viewerApp && m_updateInterval >= 0) {
@@ -436,6 +679,9 @@ void Q3DSSurfaceViewerPrivate::resetUpdateTimer()
}
}
+/*!
+ * \internal
+ */
QObject *Q3DSSurfaceViewerPrivate::surfaceObject()
{
if (m_surface) {
diff --git a/src/Runtime/api/studio3d/q3dssurfaceviewer.h b/src/Runtime/api/studio3d/q3dssurfaceviewer.h
index c0ae05a0..75e35713 100644
--- a/src/Runtime/api/studio3d/q3dssurfaceviewer.h
+++ b/src/Runtime/api/studio3d/q3dssurfaceviewer.h
@@ -50,55 +50,64 @@ class Q_STUDIO3D_EXPORT Q3DSSurfaceViewer : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(Q3DSSurfaceViewer)
+
+ // #TODO: QT3DS-3532 SurfaceViewer API missing error string
+ //Q_PROPERTY(QString error READ error NOTIFY errorChanged)
+ Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged)
Q_PROPERTY(bool autoSize READ autoSize WRITE setAutoSize NOTIFY autoSizeChanged)
Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval NOTIFY updateIntervalChanged)
- Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
Q_PROPERTY(QString presentationId READ presentationId WRITE setPresentationId NOTIFY presentationIdChanged)
public:
explicit Q3DSSurfaceViewer(QObject *parent = nullptr);
~Q3DSSurfaceViewer();
- bool initialize(QSurface *surface, QOpenGLContext *context, GLuint fboId = 0);
+ bool create(QSurface *surface, QOpenGLContext *context);
+ bool create(QSurface *surface, QOpenGLContext *context, GLuint fboId);
+ void destroy();
- QImage grab(const QRect &rect = QRect());
+ Q3DSPresentation *presentation() const;
+ Q3DSViewerSettings *settings() const;
- QQmlEngine *qmlEngine() const;
- void setQmlEngine(QQmlEngine *qmlEngine);
+ bool isRunning() const;
- // Property accessors
QSize size() const;
+ void setSize(const QSize &size);
+
bool autoSize() const;
+ void setAutoSize(bool autoSize);
+
int updateInterval() const;
- bool isRunning() const;
- QString presentationId() const;
+ void setUpdateInterval(int interval);
int fboId() const;
QSurface *surface() const;
QOpenGLContext *context() const;
- Q3DSViewerSettings *settings() const;
- Q3DSPresentation *presentation() const;
+ QImage grab(const QRect &rect = QRect());
+
+ QQmlEngine *qmlEngine() const;
+ void setQmlEngine(QQmlEngine *qmlEngine);
+ QString presentationId() const;
+
+
public Q_SLOTS:
- void setSize(const QSize &size);
- void setAutoSize(bool autoSize);
- void setUpdateInterval(int interval);
void update();
- void shutdown();
void reset();
void setPresentationId(const QString &id);
Q_SIGNALS:
void presentationLoaded();
void presentationReady();
+ void frameUpdate();
+
+ void presentationIdChanged(const QString &id);
void sizeChanged(const QSize &size);
void autoSizeChanged(bool autoSize);
void updateIntervalChanged(bool autoUpdate);
void runningChanged(bool initialized);
- void frameUpdate();
- void presentationIdChanged(const QString &id);
private:
Q_DISABLE_COPY(Q3DSSurfaceViewer)
diff --git a/src/Runtime/api/studio3d/q3dsviewersettings.cpp b/src/Runtime/api/studio3d/q3dsviewersettings.cpp
index b6660c84..187729a0 100644
--- a/src/Runtime/api/studio3d/q3dsviewersettings.cpp
+++ b/src/Runtime/api/studio3d/q3dsviewersettings.cpp
@@ -37,46 +37,79 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmltype ViewerSettings
+ \instantiates Q3DSViewerSettings
+ \inqmlmodule Qt3DStudio
+ \ingroup OpenGLRuntime
+ \brief Qt 3D Studio presentation viewer settings.
+
+ This type provides properties to define presentation independent viewer settings.
+
+ \note ViewerSettings are only applicable when \l Studio3D is used in the
+ default mode, showing the final, composed image from the Qt 3D Studio
+ renderer.
+
+ \sa Studio3D
+*/
+
+/*!
+ \class Q3DSViewerSettings
+ \inmodule OpenGLRuntime
+ \since Qt 3D Studio 2.0
+
+ \brief Qt 3D Studio presentation viewer settings.
+
+ Q3DSViewerSettings provides properties to define presentation independent
+ viewer settings.
+
+ \note This class should not be instantiated directly when working with the
+ C++ APIs. Q3DSSurfaceViewer and Q3DSWidget create a Q3DSViewerSettings
+ instance implicitly. This can be queried via Q3DSSurfaceViewer::settings()
+ or Q3DSWidget::settings().
+ */
+
+/*!
+ * \internal
+ */
Q3DSViewerSettings::Q3DSViewerSettings(QObject *parent)
: QObject(parent)
, d_ptr(new Q3DSViewerSettingsPrivate(this))
{
}
+/*!
+ * \internal
+ */
Q3DSViewerSettings::~Q3DSViewerSettings()
{
}
-QColor Q3DSViewerSettings::matteColor() const
-{
- return d_ptr->m_matteColor;
-}
+/*!
+ \enum Q3DSViewerSettings::ScaleMode
-bool Q3DSViewerSettings::isShowRenderStats() const
-{
- return d_ptr->m_showRenderStats;
-}
+ This enumeration specifies the possible scaling modes.
-Q3DSViewerSettings::ShadeMode Q3DSViewerSettings::shadeMode() const
-{
- return d_ptr->m_shadeMode;
-}
+ \value ScaleModeFit Scales the presentation to fit the output area.
+ \value ScaleModeFill Scales the presentation to completely fill the output area.
+ This is the default.
+ \value ScaleModeCenter Centers the presentation in the output area without scaling it.
+*/
-Q3DSViewerSettings::ScaleMode Q3DSViewerSettings::scaleMode() const
-{
- return d_ptr->m_scaleMode;
-}
+/*!
+ \qmlproperty QColor ViewerSettings::matteColor
-void Q3DSViewerSettings::save(const QString &group, const QString &organization,
- const QString &application)
-{
- d_ptr->save(group, organization, application);
-}
+ Specifies the matte color.
+ */
-void Q3DSViewerSettings::load(const QString &group, const QString &organization,
- const QString &application)
+/*!
+ \property Q3DSViewerSettings::matteColor
+
+ Specifies the matte color.
+ */
+QColor Q3DSViewerSettings::matteColor() const
{
- d_ptr->load(group, organization, application);
+ return d_ptr->m_matteColor;
}
void Q3DSViewerSettings::setMatteColor(const QColor &color)
@@ -87,6 +120,34 @@ void Q3DSViewerSettings::setMatteColor(const QColor &color)
}
}
+/*!
+ \qmlproperty bool ViewerSettings::showRenderStats
+
+ If this property is set to \c true, the simple profile
+ view is displayed in-scene, on top of the 3D content.
+
+ \note this feature can be disabled at build time, in which case this
+ property has no effect.
+
+ The default value is \c{false}.
+*/
+
+/*!
+ \property Q3DSViewerSettings::showRenderStats
+
+ When this property is \c{true}, the simple profile
+ view is displayed in-scene, on top of the 3D content.
+
+ \note This feature can be disabled at build time, in which case this
+ property has no effect.
+
+ Default value is \c{false}.
+*/
+bool Q3DSViewerSettings::isShowRenderStats() const
+{
+ return d_ptr->m_showRenderStats;
+}
+
void Q3DSViewerSettings::setShowRenderStats(bool show)
{
if (d_ptr->m_showRenderStats != show) {
@@ -95,13 +156,65 @@ void Q3DSViewerSettings::setShowRenderStats(bool show)
}
}
+/*!
+ \qmlproperty ViewerSettings::shadeMode
+ */
+
+/*!
+ \property Q3DSViewerSettings::shadeMode
+ */
+Q3DSViewerSettings::ShadeMode Q3DSViewerSettings::shadeMode() const
+{
+ return d_ptr->m_shadeMode;
+}
+
void Q3DSViewerSettings::setShadeMode(Q3DSViewerSettings::ShadeMode mode)
{
if (d_ptr->m_shadeMode != mode) {
d_ptr->setShadeMode(mode);
Q_EMIT shadeModeChanged(mode);
}
+}
+
+/*!
+ \qmlproperty enumeration ViewerSettings::scaleMode
+
+ Specifies the scaling mode. The default value \c is ScaleModeFill where the
+ size of the presentation on-screen follows and fills the size of the output
+ area (the window, the screen, or the area occupied by the Studio3D
+ element).
+
+ During the design phase it can be valuable to see the presentation with
+ some other scaling approach. For example, the Qt 3D Studio Viewer
+ application uses ScaleModeCenter by default.
+
+ \value ScaleModeFit Scales the presentation to fit the output area.
+ \value ScaleModeFill Scales the presentation to completely fill the output area.
+ \value ScaleModeCenter Centers the presentation in the output area without scaling it.
+ The default value is \c{ScaleModeFill}.
+*/
+/*!
+ \property Q3DSViewerSettings::scaleMode
+
+ Specifies the scaling mode. The default value \c is ScaleModeFill where the
+ size of the presentation on-screen follows and fills the size of the output
+ area (the window, the screen, or the area occupied by the \l Studio3D
+ element).
+
+ During the design phase it can be valuable to see the presentation with
+ some other scaling approach. For example, the Qt 3D Studio Viewer
+ application uses ScaleModeCenter by default.
+
+ \value ScaleModeFit Scales the presentation to fit the output area.
+ \value ScaleModeFill Scales the presentation to completely fill the output area.
+ \value ScaleModeCenter Centers the presentation in the output area without scaling it.
+
+ The default value is \c{ScaleModeFill}.
+ */
+Q3DSViewerSettings::ScaleMode Q3DSViewerSettings::scaleMode() const
+{
+ return d_ptr->m_scaleMode;
}
void Q3DSViewerSettings::setScaleMode(Q3DSViewerSettings::ScaleMode mode)
@@ -112,6 +225,50 @@ void Q3DSViewerSettings::setScaleMode(Q3DSViewerSettings::ScaleMode mode)
}
}
+/*!
+ \qmmlmethod ViewerSettings::save
+ Persistently saves the viewer \l{QSettings}{settings} using \a group, \a organization and
+ \a application.
+ \param group
+ \param organization
+ \param application
+ */
+/*!
+ * \brief Q3DSViewerSettings::save Persistently saves the viewer \l{QSettings}{settings}
+ Persistently saves the viewer \l{QSettings}{settings} using \a group, \a organization and
+ \a application.
+ \param group
+ \param organization
+ \param application
+ */
+void Q3DSViewerSettings::save(const QString &group, const QString &organization,
+ const QString &application)
+{
+ d_ptr->save(group, organization, application);
+}
+
+/*!
+ \qmlmethod ViewerSettings::load
+ Loads previously saved viewer \l{QSettings}{settings} using \a group, \a organization and
+ \a application.
+ \param group
+ \param organization
+ \param application
+ */
+/*!
+ * \brief Q3DSViewerSettings::load Loads previously saved viewer \l{QSettings}{settings}
+ Loads previously saved viewer \l{QSettings}{settings} using \a group, \a organization and
+ \a application.
+ \param group
+ \param organization
+ \param application
+ */
+void Q3DSViewerSettings::load(const QString &group, const QString &organization,
+ const QString &application)
+{
+ d_ptr->load(group, organization, application);
+}
+
Q3DSViewerSettingsPrivate::Q3DSViewerSettingsPrivate(Q3DSViewerSettings *q)
: QObject(q)
, q_ptr(q)
diff --git a/src/Runtime/api/studio3d/q3dsviewersettings.h b/src/Runtime/api/studio3d/q3dsviewersettings.h
index 80d5edb2..5d7abf68 100644
--- a/src/Runtime/api/studio3d/q3dsviewersettings.h
+++ b/src/Runtime/api/studio3d/q3dsviewersettings.h
@@ -44,9 +44,12 @@ class Q_STUDIO3D_EXPORT Q3DSViewerSettings : public QObject
Q_DECLARE_PRIVATE(Q3DSViewerSettings)
Q_ENUMS(ShadeMode)
Q_ENUMS(ScaleMode)
+
+// #TODO: QT3DS-3542 Q3DSViewerSettings API is missing property matteEnabled compared to 2.3
+// Q_PROPERTY(bool matteEnabled READ matteEnabled WRITE setMatteEnabled NOTIFY matteEnabledChanged)
+
Q_PROPERTY(QColor matteColor READ matteColor WRITE setMatteColor NOTIFY matteColorChanged)
Q_PROPERTY(bool showRenderStats READ isShowRenderStats WRITE setShowRenderStats NOTIFY showRenderStatsChanged)
- Q_PROPERTY(ShadeMode shadeMode READ shadeMode WRITE setShadeMode NOTIFY shadeModeChanged)
Q_PROPERTY(ScaleMode scaleMode READ scaleMode WRITE setScaleMode NOTIFY scaleModeChanged)
public:
@@ -66,7 +69,6 @@ public:
QColor matteColor() const;
bool isShowRenderStats() const;
- ShadeMode shadeMode() const;
ScaleMode scaleMode() const;
Q_INVOKABLE void save(const QString &group, const QString &organization = QString(),
@@ -77,7 +79,6 @@ public:
public Q_SLOTS:
void setMatteColor(const QColor &color);
void setShowRenderStats(bool show);
- void setShadeMode(ShadeMode mode);
void setScaleMode(ScaleMode mode);
Q_SIGNALS:
@@ -90,6 +91,9 @@ private:
Q_DISABLE_COPY(Q3DSViewerSettings)
Q3DSViewerSettingsPrivate *d_ptr;
+ ShadeMode shadeMode() const;
+ void setShadeMode(ShadeMode mode);
+
friend class Q3DSSurfaceViewerPrivate;
friend class Q3DSRenderer;
friend class Q3DSStudio3D;
diff --git a/src/Runtime/api/studio3dqml/q3dspresentationitem.cpp b/src/Runtime/api/studio3dqml/q3dspresentationitem.cpp
index cb571d87..407739e5 100644
--- a/src/Runtime/api/studio3dqml/q3dspresentationitem.cpp
+++ b/src/Runtime/api/studio3dqml/q3dspresentationitem.cpp
@@ -37,6 +37,45 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmltype Presentation
+ \instantiates Q3DSPresentationItem
+ \inqmlmodule QtStudio3D
+ \ingroup OpenGLRuntime
+ \inherits Q3DSPresentation
+ \keyword Studio3D
+
+ \brief Represents a Qt 3D Studio presentation.
+
+ This item provides properties and methods for controlling a
+ presentation.
+
+ Qt 3D Studio supports multiple presentations in one project. There
+ is always a main presentation and zero or more
+ sub-presentations. The sub-presentations are composed into the
+ main presentations either as contents of Qt 3D Studio layers or as
+ texture maps.
+
+ In the filesystem each presentation corresponds to one \c{.uip}
+ presentation file. When present, the \c{.uia} project file ties
+ these together by specifying a name for each of the
+ (sub-)presentations and specifies which one is the main one.
+
+ The \c{.uia} project also defines \l{DataInput}s and
+ \l{DataOutput}s that are exported by the presentations.
+ \l{DataInput}s provide a way to provide input to the presentation
+ to e.g. control a timeline of a subpresentation from code.
+ \l{DataOutput}s provide a way to get notified when an attribute
+ is changed in the presentation by animation timeline,
+ by behavior scripts or by a \l{DataInput}.
+
+ From the API point of view Presentation corresponds to the
+ main presentation. The source property can refer either to a
+ \c{.uia} or \c{.uip} file. When specifying a file with \c{.uip}
+ extension and a \c{.uia} is present with the same name, the
+ \c{.uia} is loaded automatically and thus sub-presentation
+ information is available regardless.
+ */
Q3DSPresentationItem::Q3DSPresentationItem(QObject *parent)
: Q3DSPresentation(parent)
, m_subPresentationSettings(nullptr)
@@ -47,6 +86,12 @@ Q3DSPresentationItem::~Q3DSPresentationItem()
{
}
+// #TODO: QT3DS-3565 subPresentationSettings is missing documentation
+/*!
+ \qmlproperty SubPresentationSettings Presentation::subPresentationSettings
+
+ Note: This property is read-only.
+ */
Q3DSSubPresentationSettings *Q3DSPresentationItem::subPresentationSettings() const
{
return m_subPresentationSettings;
diff --git a/src/Runtime/api/studio3dqml/q3dsstudio3d.cpp b/src/Runtime/api/studio3dqml/q3dsstudio3d.cpp
index 41f59f44..59f92b01 100644
--- a/src/Runtime/api/studio3dqml/q3dsstudio3d.cpp
+++ b/src/Runtime/api/studio3dqml/q3dsstudio3d.cpp
@@ -43,6 +43,101 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmltype Studio3D
+ \instantiates Q3DSStudio3D
+ \inqmlmodule QtStudio3D
+ \ingroup OpenGLRuntime
+ \inherits Item
+ \keyword Studio3D
+
+ \brief Qt 3D Studio presentation viewer.
+
+ This type enables developers to embed Qt 3D Studio presentations in Qt
+ Quick.
+
+ \section2 Example Usage
+
+ \qml
+ Studio3D {
+ id: studio3D
+ anchors.fill: parent
+
+ Presentation {
+ source: "qrc:///presentation.uia"
+ SceneElement {
+ id: scene
+ elementPath: "Scene"
+ currentSlideIndex: 2
+ }
+ Element {
+ id: textLabel
+ elementPath: "Scene.Layer.myLabel"
+ }
+ }
+ ViewerSettings {
+ showRenderStats: true
+ }
+ onRunningChanged: {
+ console.log("Presentation ready!");
+ }
+ }
+ \endqml
+
+ \section2 Controlling the presentation
+
+ Like the example above suggests, Studio3D and the other types under the
+ QtStudio3D import offer more than simply rendering the animated Qt 3D
+ Studio presentation. They also offer scene manipulation, including
+
+ \list
+
+ \li querying and changing scene object properties (for example, the
+ transform of a model, colors and other settings of a material, etc.) via
+ Presentation::getAttribute(), Presentation::setAttribute(), \l Element, and
+ \l DataInput,
+
+ \li changing slides (and thus starting the relevant animations and applying
+ the scene object property changes associated with the new slide) via
+ Presentation::goToSlide(), \l SceneElement, and \l DataInput,
+
+ \li and controlling the timeline (the current playback position for the
+ key-frame based animations) both on the main scene and on individual
+ Component nodes via Presentation::goToTime(), \l SceneElement, and \l DataInput.
+
+ \endlist
+
+ \sa Presentation
+*/
+
+/*!
+ \qmlsignal Studio3D::frameUpdate()
+
+ This signal is emitted each time a frame has been rendered.
+*/
+
+/*!
+ \qmlsignal Studio3D::presentationLoaded()
+
+ This signal is emitted when the presentation has been loaded and is ready
+ to be shown.
+*/
+
+/*!
+ \qmlsignal Studio3D::presentationReady()
+
+ This signal is emitted when the presentation has fully initialized its 3D
+ scene for the first frame.
+
+ The difference to presentationLoaded() is that this signal is emitted only
+ when the asynchronous operations needed to build to 3D scene and the first
+ frame have completed.
+
+ When implementing splash screens via Loader items and the Item::visible
+ property, this is the signal that should be used to trigger hiding the
+ splash screen.
+*/
+
Q3DSStudio3D::Q3DSStudio3D()
: m_viewerSettings(nullptr)
, m_presentation(nullptr)
@@ -64,16 +159,40 @@ Q3DSStudio3D::~Q3DSStudio3D()
{
}
+/*!
+ \qmlproperty Presentation Studio3D::presentation
+
+ Accessor for the presentation. Applications are expected to create a single
+ Presentation child object for Studio3D. If this is omitted, a presentation
+ is created automatically.
+
+ This property is read-only.
+*/
Q3DSPresentationItem *Q3DSStudio3D::presentation() const
{
return m_presentation;
}
+// #TODO: QT3DS-3566 viewerSettings is missing documentation
+/*!
+ \qmlproperty ViewerSettings Studio3D::viewerSettings
+
+ This property is read-only.
+*/
Q3DSViewerSettings *Q3DSStudio3D::viewerSettings() const
{
return m_viewerSettings;
}
+/*!
+ \qmlproperty string Studio3D::error
+
+ Contains the text for the error message that was generated during the
+ loading of the presentation. When no error occurred or there is no
+ presentation loaded, the value is an empty string.
+
+ This property is read-only.
+*/
QString Q3DSStudio3D::error() const
{
return m_error;
@@ -87,9 +206,12 @@ void Q3DSStudio3D::setError(const QString &error)
}
}
+/*!
+ \internal
+ It might be beneficial to have these as properties so they could be accessed from QML?
+ */
void Q3DSStudio3D::setIgnoreEvents(bool mouse, bool wheel, bool keyboard)
{
- // TODO: It might be beneficial to have these as properties so they could be acceessed from QML
m_ignoreMouseEvents = mouse;
m_ignoreWheelEvents = wheel;
m_ignoreKeyboardEvents = keyboard;
@@ -101,6 +223,9 @@ void Q3DSStudio3D::setIgnoreEvents(bool mouse, bool wheel, bool keyboard)
setAcceptHoverEvents(!mouse);
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::componentComplete()
{
const auto childObjs = children();
@@ -134,6 +259,9 @@ void Q3DSStudio3D::componentComplete()
QQuickFramebufferObject::componentComplete();
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::handleWindowChanged(QQuickWindow *window)
{
if (!window)
@@ -148,13 +276,19 @@ void Q3DSStudio3D::handleWindowChanged(QQuickWindow *window)
connect(window, &QQuickWindow::afterSynchronizing, this, &Q3DSStudio3D::update);
}
-// Queue up a command to inform the renderer of a newly-changed visible/hidden status.
+/*!
+ \internal
+ Queue up a command to inform the renderer of a newly-changed visible/hidden status.
+ */
void Q3DSStudio3D::handleVisibleChanged()
{
m_pendingCommands.m_visibleChanged = true;
m_pendingCommands.m_visible = isVisible();
}
+/*!
+ \brief internal
+ */
void Q3DSStudio3D::reset()
{
// Fake a source change to trigger a reloading of the presentation
@@ -164,6 +298,9 @@ void Q3DSStudio3D::reset()
m_pendingCommands.m_variantList = m_presentation->variantList();
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::requestResponseHandler(const QString &elementPath, CommandType commandType,
void *requestData)
{
@@ -203,7 +340,10 @@ void Q3DSStudio3D::requestResponseHandler(const QString &elementPath, CommandTyp
}
}
-// Create the Q3DSRenderer. Invoked automatically by the QML scene graph.
+/*!
+ \internal
+ Create the Q3DSRenderer. Invoked automatically by the QML scene graph.
+ */
QQuickFramebufferObject::Renderer *Q3DSStudio3D::createRenderer() const
{
// It is "illegal" to create a connection between the renderer
@@ -234,23 +374,33 @@ QQuickFramebufferObject::Renderer *Q3DSStudio3D::createRenderer() const
return renderer;
}
+/*!
+ \qmlproperty bool Studio3D::running
+
+ The value of this property is \c true when the presentation has been loaded
+ and is ready to be shown.
+
+ This property is read-only.
+*/
bool Q3DSStudio3D::isRunning() const
{
return m_isRunning;
}
-/** Emit QML `runningChanged` and `frameUpdate` and signals.
- * This method is called every frame, and emits the `frameUpdate` signal every frame,
- * regardless of plugin visibility. This allows a hidden Qt3DSView to still process
- * information every frame, even though the Renderer is not rendering.
- *
- * To prevent expensive onFrameUpdate handlers from being processed when hidden,
- * add an early return to the top like:
- *
- * onFrameUpdate: {
- * if (!visible) return;
- * ...
- * }
+/*!
+ \internal
+ Emit QML `runningChanged` and `frameUpdate` and signals.
+ This method is called every frame, and emits the `frameUpdate` signal every frame,
+ regardless of plugin visibility. This allows a hidden Qt3DSView to still process
+ information every frame, even though the Renderer is not rendering.
+
+ To prevent expensive onFrameUpdate handlers from being processed when hidden,
+ add an early return to the top like:
+
+ onFrameUpdate: {
+ if (!visible) return;
+ ...
+ }
*/
void Q3DSStudio3D::tick()
{
@@ -267,7 +417,10 @@ void Q3DSStudio3D::tick()
}
}
-// Copies the list of commands previously queued up. Called by Q3DSRenderer::synchronize().
+/*!
+ \internal
+ Copies the list of commands previously queued up. Called by Q3DSRenderer::synchronize().
+ */
void Q3DSStudio3D::getCommands(bool emitInitialize, CommandQueue &renderQueue)
{
if (emitInitialize)
@@ -277,6 +430,9 @@ void Q3DSStudio3D::getCommands(bool emitInitialize, CommandQueue &renderQueue)
m_pendingCommands.clear(false);
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::mousePressEvent(QMouseEvent *event)
{
if (!m_ignoreMouseEvents) {
@@ -290,6 +446,9 @@ void Q3DSStudio3D::mousePressEvent(QMouseEvent *event)
}
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::mouseReleaseEvent(QMouseEvent *event)
{
if (!m_ignoreMouseEvents) {
@@ -303,6 +462,9 @@ void Q3DSStudio3D::mouseReleaseEvent(QMouseEvent *event)
}
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::mouseMoveEvent(QMouseEvent *event)
{
if (!m_ignoreMouseEvents) {
@@ -316,12 +478,18 @@ void Q3DSStudio3D::mouseMoveEvent(QMouseEvent *event)
}
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::wheelEvent(QWheelEvent *event)
{
if (!m_ignoreWheelEvents)
m_presentation->wheelEvent(event);
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::keyPressEvent(QKeyEvent *event)
{
if (m_ignoreKeyboardEvents)
@@ -329,6 +497,9 @@ void Q3DSStudio3D::keyPressEvent(QKeyEvent *event)
m_presentation->keyPressEvent(event);
}
+/*!
+ \internal
+ */
void Q3DSStudio3D::keyReleaseEvent(QKeyEvent *event)
{
if (m_ignoreKeyboardEvents)