summaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/studio3d/q3dscommandqueue.cpp5
-rw-r--r--src/api/studio3d/q3dscommandqueue_p.h2
-rw-r--r--src/api/studio3d/q3dsviewersettings.cpp50
-rw-r--r--src/api/studio3d/q3dsviewersettings.h7
-rw-r--r--src/api/studio3d/q3dsviewersettings_p.h2
-rw-r--r--src/api/studio3dqml/q3dsrenderer.cpp2
6 files changed, 65 insertions, 3 deletions
diff --git a/src/api/studio3d/q3dscommandqueue.cpp b/src/api/studio3d/q3dscommandqueue.cpp
index c6071aa..e9eed29 100644
--- a/src/api/studio3d/q3dscommandqueue.cpp
+++ b/src/api/studio3d/q3dscommandqueue.cpp
@@ -61,6 +61,7 @@ CommandQueue::CommandQueue()
, m_showRenderStats(false)
, m_matteColor(Qt::black)
, m_delayedLoading(false)
+ , m_matteEnabled(false)
, m_size(0)
{
qRegisterMetaType<CommandType>();
@@ -207,6 +208,7 @@ void CommandQueue::copyCommands(CommandQueue &fromQueue)
m_globalAnimationTimeChanged
= m_globalAnimationTimeChanged || fromQueue.m_globalAnimationTimeChanged;
m_delayedLoadingChanged = m_delayedLoadingChanged || fromQueue.m_delayedLoadingChanged;
+ m_matteEnabledChanged = m_matteEnabledChanged || fromQueue.m_matteEnabledChanged;
if (fromQueue.m_visibleChanged)
m_visible = fromQueue.m_visible;
@@ -226,6 +228,8 @@ void CommandQueue::copyCommands(CommandQueue &fromQueue)
m_globalAnimationTime = fromQueue.m_globalAnimationTime;
if (fromQueue.m_delayedLoadingChanged)
m_delayedLoading = fromQueue.m_delayedLoading;
+ if (fromQueue.m_matteEnabledChanged)
+ m_matteEnabled = fromQueue.m_matteEnabled;
// Pending queue may be synchronized multiple times between queue processing, so let's append
// to the existing queue rather than clearing it.
@@ -304,6 +308,7 @@ void CommandQueue::clear(bool deleteCommandData)
m_variantListChanged = false;
m_globalAnimationTimeChanged = false;
m_delayedLoadingChanged = false;
+ m_matteEnabledChanged = false;
if (deleteCommandData) {
for (int i = 0; i < m_size; ++i) {
diff --git a/src/api/studio3d/q3dscommandqueue_p.h b/src/api/studio3d/q3dscommandqueue_p.h
index 12d1b7e..effb72e 100644
--- a/src/api/studio3d/q3dscommandqueue_p.h
+++ b/src/api/studio3d/q3dscommandqueue_p.h
@@ -142,6 +142,7 @@ public:
bool m_variantListChanged;
bool m_globalAnimationTimeChanged;
bool m_delayedLoadingChanged;
+ bool m_matteEnabledChanged;
bool m_visible;
Q3DSViewerSettings::ScaleMode m_scaleMode;
@@ -152,6 +153,7 @@ public:
QStringList m_variantList;
qint64 m_globalAnimationTime;
bool m_delayedLoading;
+ bool m_matteEnabled;
void clear(bool deleteCommandData);
int size() const { return m_size; }
diff --git a/src/api/studio3d/q3dsviewersettings.cpp b/src/api/studio3d/q3dsviewersettings.cpp
index 01f82df..9403a32 100644
--- a/src/api/studio3d/q3dsviewersettings.cpp
+++ b/src/api/studio3d/q3dsviewersettings.cpp
@@ -229,6 +229,40 @@ void Q3DSViewerSettings::setScaleMode(Q3DSViewerSettings::ScaleMode mode)
}
/*!
+ \qmlproperty bool ViewerSettings::matteEnabled
+
+ Specifies if the empty area around the presentation (applicable when
+ scaleMode is set to ScaleModeCenter or ScaleModeFit) should be filled with
+ a custom color.
+
+ The default value is \c false.
+ */
+/*!
+ \property Q3DSViewerSettings::matteEnabled
+
+ Specifies if the empty area around the presentation (applicable when
+ scaleMode is set to ScaleModeCenter or ScaleModeFit) should be filled with
+ a custom color.
+
+ The default value is \c false.
+
+ \sa matteColor
+ */
+bool Q3DSViewerSettings::matteEnabled() const
+{
+ return d_ptr->m_matteEnabled;
+}
+
+void Q3DSViewerSettings::setMatteEnabled(bool enabled)
+{
+ if (d_ptr->m_matteEnabled != enabled) {
+ d_ptr->setMatteEnabled(enabled);
+ Q_EMIT matteEnabledChanged(enabled);
+ }
+}
+
+
+/*!
\qmlmethod ViewerSettings::save(string group, string organization, string application)
Persistently saves the viewer \l{QSettings}{settings} using \a group, \a organization and
@@ -268,6 +302,7 @@ Q3DSViewerSettingsPrivate::Q3DSViewerSettingsPrivate(Q3DSViewerSettings *q)
, m_commandQueue(nullptr)
, m_matteColor(Qt::black)
, m_showRenderStats(false)
+ , m_matteEnabled(false)
, m_shadeMode(Q3DSViewerSettings::ShadeModeShaded)
, m_scaleMode(Q3DSViewerSettings::ScaleModeCenter)
, m_savedSettings(nullptr)
@@ -282,6 +317,7 @@ void Q3DSViewerSettingsPrivate::setViewerApp(Q3DSViewer::Q3DSViewerApp *app)
{
m_viewerApp = app;
if (m_viewerApp) {
+ setMatteEnabled(m_matteEnabled);
setMatteColor(m_matteColor);
setShowRenderStats(m_showRenderStats);
setShadeMode(m_shadeMode);
@@ -293,6 +329,7 @@ void Q3DSViewerSettingsPrivate::setCommandQueue(CommandQueue *queue)
{
m_commandQueue = queue;
if (m_commandQueue) {
+ setMatteEnabled(m_matteEnabled);
setMatteColor(m_matteColor);
setShowRenderStats(m_showRenderStats);
setShadeMode(m_shadeMode);
@@ -309,6 +346,7 @@ void Q3DSViewerSettingsPrivate::save(const QString &group, const QString &organi
m_savedSettings->setValue(QStringLiteral("showRenderStats"), m_showRenderStats);
m_savedSettings->setValue(QStringLiteral("shadeMode"), m_shadeMode);
m_savedSettings->setValue(QStringLiteral("scaleMode"), m_scaleMode);
+ m_savedSettings->setValue(QStringLiteral("matteEnabled"), m_matteEnabled);
}
void Q3DSViewerSettingsPrivate::load(const QString &group, const QString &organization,
@@ -322,6 +360,7 @@ void Q3DSViewerSettingsPrivate::load(const QString &group, const QString &organi
m_savedSettings->value(QStringLiteral("shadeMode")).toInt()));
q_ptr->setScaleMode(Q3DSViewerSettings::ScaleMode(
m_savedSettings->value(QStringLiteral("scaleMode")).toInt()));
+ q_ptr->setMatteEnabled(m_savedSettings->value(QStringLiteral("matteEnabled")).toBool());
}
void Q3DSViewerSettingsPrivate::setMatteColor(const QColor &color)
@@ -335,6 +374,17 @@ void Q3DSViewerSettingsPrivate::setMatteColor(const QColor &color)
}
}
+void Q3DSViewerSettingsPrivate::setMatteEnabled(bool enabled)
+{
+ m_matteEnabled = enabled;
+ if (m_viewerApp) {
+ m_viewerApp->setMatteColor(enabled);
+ } else if (m_commandQueue) {
+ m_commandQueue->m_matteEnabled = enabled;
+ m_commandQueue->m_matteEnabledChanged = true;
+ }
+}
+
void Q3DSViewerSettingsPrivate::setShowRenderStats(bool show)
{
m_showRenderStats = show;
diff --git a/src/api/studio3d/q3dsviewersettings.h b/src/api/studio3d/q3dsviewersettings.h
index 5d7abf6..7199e1c 100644
--- a/src/api/studio3d/q3dsviewersettings.h
+++ b/src/api/studio3d/q3dsviewersettings.h
@@ -45,9 +45,7 @@ class Q_STUDIO3D_EXPORT Q3DSViewerSettings : public QObject
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(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(ScaleMode scaleMode READ scaleMode WRITE setScaleMode NOTIFY scaleModeChanged)
@@ -67,6 +65,7 @@ public:
explicit Q3DSViewerSettings(QObject *parent = nullptr);
~Q3DSViewerSettings();
+ bool matteEnabled() const;
QColor matteColor() const;
bool isShowRenderStats() const;
ScaleMode scaleMode() const;
@@ -77,11 +76,13 @@ public:
const QString &application = QString());
public Q_SLOTS:
+ void setMatteEnabled(bool enabled);
void setMatteColor(const QColor &color);
void setShowRenderStats(bool show);
void setScaleMode(ScaleMode mode);
Q_SIGNALS:
+ void matteEnabledChanged(bool enabled);
void matteColorChanged(const QColor &color);
void showRenderStatsChanged(bool show);
void shadeModeChanged(ShadeMode mode);
diff --git a/src/api/studio3d/q3dsviewersettings_p.h b/src/api/studio3d/q3dsviewersettings_p.h
index 48fbae3..4628241 100644
--- a/src/api/studio3d/q3dsviewersettings_p.h
+++ b/src/api/studio3d/q3dsviewersettings_p.h
@@ -62,6 +62,7 @@ public:
void save(const QString &group, const QString &organization, const QString &application);
void load(const QString &group, const QString &organization, const QString &application);
+ void setMatteEnabled(bool enabled);
void setMatteColor(const QColor &color);
void setShowRenderStats(bool show);
void setShadeMode(Q3DSViewerSettings::ShadeMode mode);
@@ -78,6 +79,7 @@ private:
CommandQueue *m_commandQueue; // Not owned
QColor m_matteColor;
bool m_showRenderStats;
+ bool m_matteEnabled;
Q3DSViewerSettings::ShadeMode m_shadeMode;
Q3DSViewerSettings::ScaleMode m_scaleMode;
QSettings *m_savedSettings;
diff --git a/src/api/studio3dqml/q3dsrenderer.cpp b/src/api/studio3dqml/q3dsrenderer.cpp
index 7366d6a..33c7b98 100644
--- a/src/api/studio3dqml/q3dsrenderer.cpp
+++ b/src/api/studio3dqml/q3dsrenderer.cpp
@@ -286,6 +286,8 @@ void Q3DSRenderer::processCommands()
m_settings->setShowRenderStats(m_commands.m_showRenderStats);
if (m_commands.m_delayedLoadingChanged)
this->m_runtime->setDelayedLoading(m_commands.m_delayedLoading);
+ if (m_commands.m_matteEnabledChanged)
+ this->m_runtime->setMatteEnabled(m_commands.m_matteEnabled);
if (m_commands.m_globalAnimationTimeChanged)
m_presentation->setGlobalAnimationTime(m_commands.m_globalAnimationTime);