diff options
author | Kaj Grönholm <kaj.gronholm@qt.io> | 2018-11-20 15:07:03 +0200 |
---|---|---|
committer | Kaj Grönholm <kaj.gronholm@qt.io> | 2018-11-29 06:09:10 +0000 |
commit | 10c49ffb01f5b49440dc53c402ae11fb386e9611 (patch) | |
tree | 24e1d147c1aa8f52779efe6c1a39c37d078987f7 /src/runtime/api/q3dsviewersettings.cpp | |
parent | d1098f9b10a643d1d945c8f3dbc4baabaa75b838 (diff) |
Add QML API for stereoscopic settings
Allows modifying stereoscopic mode and eye separation amount
from QML API.
Task-number: QT3DS-2695
Change-Id: I75994e80827afbee25b481ab2fd431bf29958e86
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/runtime/api/q3dsviewersettings.cpp')
-rw-r--r-- | src/runtime/api/q3dsviewersettings.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/src/runtime/api/q3dsviewersettings.cpp b/src/runtime/api/q3dsviewersettings.cpp index d2d488c..5d30414 100644 --- a/src/runtime/api/q3dsviewersettings.cpp +++ b/src/runtime/api/q3dsviewersettings.cpp @@ -86,6 +86,20 @@ Q3DSViewerSettings::~Q3DSViewerSettings() */ /*! + \enum Q3DSViewerSettings::StereoMode + + \since Qt 3D Studio 2.3 + + This enumeration specifies the possible stereo modes. + + \value StereoModeMono Renders the view normally in mono. This is the default. + \value StereoModeTopBottom Renders view in 3D top-bottom mode. + \value StereoModeLeftRight Renders view in 3D left-right mode. + \value StereoModeAnaglyphRedCyan Renders view in 3D anaglyph red-cyan mode. + \value StereoModeAnaglyphGreenMagenta Renders view in 3D anaglyph green-magenta mode. +*/ + +/*! \property Q3DSViewerSettings::matteEnabled Specifies if the empty area around the presentation (applicable when @@ -165,6 +179,40 @@ Q3DSViewerSettings::ScaleMode Q3DSViewerSettings::scaleMode() const return d->scaleMode; } +/*! + \property Q3DSViewerSettings::stereoMode + + \since Qt 3D Studio 2.3 + + Specifies the stereo mode. The default value \c is StereoModeMono where the + view is rendered normally, as suitable for 2D displays. + + Other available modes target different 3D stereo rendering types. + */ +Q3DSViewerSettings::StereoMode Q3DSViewerSettings::stereoMode() const +{ + Q_D(const Q3DSViewerSettings); + return d->stereoMode; +} + +/*! + \property Q3DSViewerSettings::stereoEyeSeparation + + \since Qt 3D Studio 2.3 + + Specifies the eye (camera) separation of stereo rendering. + Value is the amount left and right eye cameras move in x-coordinate + away from center. Bigger separation increases the 3D effect. + This value should be set to match viewed presentation dimensions. + + This has only effect when stereo mode is set to something else than + default \c{StereoModeMono}. + */ +float Q3DSViewerSettings::stereoEyeSeparation() const +{ + Q_D(const Q3DSViewerSettings); + return d->stereoEyeSeparation; +} void Q3DSViewerSettings::setMatteEnabled(bool isEnabled) { @@ -212,6 +260,24 @@ void Q3DSViewerSettings::setScaleMode(Q3DSViewerSettings::ScaleMode mode) } } +void Q3DSViewerSettings::setStereoMode(Q3DSViewerSettings::StereoMode mode) +{ + Q_D(Q3DSViewerSettings); + if (d->stereoMode != mode) { + d->stereoMode = mode; + emit stereoModeChanged(); + } +} + +void Q3DSViewerSettings::setStereoEyeSeparation(float value) +{ + Q_D(Q3DSViewerSettings); + if (!qFuzzyCompare(d->stereoEyeSeparation, value)) { + d->stereoEyeSeparation = value; + emit stereoEyeSeparationChanged(); + } +} + /*! Persistently saves the viewer \l{QSettings}{settings} using \a group, \a organization and \a application. @@ -264,6 +330,14 @@ Q3DSViewportSettings *Q3DSViewerSettingsPrivate::createViewportSettingsProxy() QObject::connect(q, &Q3DSViewerSettings::matteColorChanged, q, [vp, q] { vp->setMatteColor(q->matteColor()); }); + vp->setStereoMode(Q3DSViewportSettings::StereoMode(q->stereoMode())); + QObject::connect(q, &Q3DSViewerSettings::stereoModeChanged, q, [vp, q] { + vp->setStereoMode(Q3DSViewportSettings::StereoMode(q->stereoMode())); + }); + vp->setStereoEyeSeparation(q->stereoEyeSeparation()); + QObject::connect(q, &Q3DSViewerSettings::stereoEyeSeparationChanged, q, [vp, q] { + vp->setStereoEyeSeparation(q->stereoEyeSeparation()); + }); return vp; } @@ -331,4 +405,39 @@ Q3DSViewportSettings *Q3DSViewerSettingsPrivate::createViewportSettingsProxy() The default value is \c{ScaleModeFill}. */ +/*! + \qmlproperty enumeration ViewerSettings::stereoMode + + \since Qt 3D Studio 2.3 + + Specifies the stereo mode. The default value \c is StereoModeMono where the + view is rendered normally, suitable for 2D displays. + + Other available modes target different 3D stereo rendering types. + + \value StereoModeMono Renders the view normally in mono. This is the default. + \value StereoModeTopBottom Renders view in 3D top-bottom mode. + \value StereoModeLeftRight Renders view in 3D left-right mode. + \value StereoModeAnaglyphRedCyan Renders view in 3D anaglyph red-cyan mode. + \value StereoModeAnaglyphGreenMagenta Renders view in 3D anaglyph green-magenta mode. + + The default value is \c{StereoModeMono}. +*/ + +/*! + \qmlproperty float ViewerSettings::stereoEyeSeparation + + \since Qt 3D Studio 2.3 + + Specifies the eye (camera) separation of stereo rendering. + Value is the amount left and right eye cameras move in x-coordinate + away from center. Bigger separation increases the 3D effect. + This value should be set to match the presentation's dimensions. + + This has only effect when stereo mode is set to something else than + the default \c{StereoModeMono}. + + The default value is \c{0.4}. +*/ + QT_END_NAMESPACE |