Skip to content
Permalink
Browse files

Move the skybox enabling checkbox to the groupbox widget

Whether skybox is enabled is now saved as part of the 3D Map settings
  • Loading branch information
DelazJ authored and nyalldawson committed Aug 21, 2020
1 parent 7b91f79 commit 09844a7dabd7693fdc2c2b0c4cd52ccbe713be77
@@ -477,6 +477,24 @@ Default value is 96



bool isSkyboxEnabled() const;
%Docstring
Returns whether the skybox is enabled.

.. seealso:: :py:func:`setIsSkyboxEnabled`

.. versionadded:: 3.16
%End

void setIsSkyboxEnabled( bool enabled );
%Docstring
Sets whether the skybox is enabled.

.. seealso:: :py:func:`isSkyboxEnabled`

.. versionadded:: 3.16
%End

signals:
void backgroundColorChanged();
%Docstring
@@ -863,9 +863,9 @@ void Qgs3DMapScene::onSkyboxSettingsChanged()
mSkybox = nullptr;
}

mEngine->setFrustumCullingEnabled( !skyboxSettings.isSkyboxEnabled() );
mEngine->setFrustumCullingEnabled( !mMap.isSkyboxEnabled() );

if ( skyboxSettings.isSkyboxEnabled() )
if ( mMap.isSkyboxEnabled() )
{
QMap<QString, QString> faces;
switch ( skyboxSettings.skyboxType() )
@@ -58,6 +58,7 @@ Qgs3DMapSettings::Qgs3DMapSettings( const Qgs3DMapSettings &other )
, mTransformContext( other.mTransformContext )
, mPathResolver( other.mPathResolver )
, mMapThemes( other.mMapThemes )
, mIsSkyboxEnabled( other.mIsSkyboxEnabled )
, mSkyboxSettings()
{
Q_FOREACH ( QgsAbstract3DRenderer *renderer, other.mRenderers )
@@ -224,9 +225,9 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
}

QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
mIsSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
mSkyboxSettings.readXml( elemSkybox, context );


QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
mShowTerrainTileInfo = elemDebug.attribute( QStringLiteral( "terrain-tile-info" ), QStringLiteral( "0" ) ).toInt();
@@ -325,6 +326,7 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elem.appendChild( elemRenderers );

QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
elemSkybox.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
mSkyboxSettings.writeXml( elemSkybox, context );
elem.appendChild( elemSkybox );

@@ -424,6 +424,20 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
*/
void setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings ) SIP_SKIP;

/**
* Returns whether the skybox is enabled.
* \see setIsSkyboxEnabled()
* \since QGIS 3.16
*/
bool isSkyboxEnabled() const { return mIsSkyboxEnabled; }

/**
* Sets whether the skybox is enabled.
* \see isSkyboxEnabled()
* \since QGIS 3.16
*/
void setIsSkyboxEnabled( bool enabled ) { mIsSkyboxEnabled = enabled; }

signals:
//! Emitted when the background color has changed
void backgroundColorChanged();
@@ -559,7 +573,8 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
QgsMapThemeCollection *mMapThemes = nullptr; //!< Pointer to map themes (e.g. from the current project) to resolve map theme content from the name
double mDpi = 96; //!< Dot per inch value for the screen / painter

QgsSkyboxSettings mSkyboxSettings; //!< Skybox realted configuration
bool mIsSkyboxEnabled = false; //!< Whether the skybox is enabled
QgsSkyboxSettings mSkyboxSettings; //!< Skybox related configuration
};


@@ -23,7 +23,6 @@
void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context )
{
const QgsPathResolver &pathResolver = context.pathResolver();
mIsSkyboxEnabled = element.attribute( QStringLiteral( "skybox-enabled" ) ).toInt();
QString skyboxTypeStr = element.attribute( QStringLiteral( "skybox-type" ) );
if ( skyboxTypeStr == QStringLiteral( "Distinct Faces" ) )
mSkyboxType = QgsSkyboxEntity::DistinctTexturesSkybox;
@@ -41,7 +40,6 @@ void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteC

void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
{
element.setAttribute( QStringLiteral( "skybox-enabled" ), mIsSkyboxEnabled );
switch ( mSkyboxType )
{
case QgsSkyboxEntity::DistinctTexturesSkybox:
@@ -41,11 +41,6 @@ class _3D_EXPORT QgsSkyboxSettings
//! Writes settings to a DOM \a element
void writeXml( QDomElement &element, const QgsReadWriteContext &context ) const;

//! Returns whether the skybox is enabled
bool isSkyboxEnabled() const { return mIsSkyboxEnabled; }
//! Sets whether the skybox is enabled
void setIsSkyboxEnabled( bool enabled ) { mIsSkyboxEnabled = enabled; }

//! Returns the type of the skybox
QgsSkyboxEntity::SkyboxType skyboxType() const { return mSkyboxType; }
//! Sets the type of the skybox
@@ -69,7 +64,6 @@ class _3D_EXPORT QgsSkyboxSettings
void setCubeMapFace( const QString &face, const QString &path ) { mCubeMapFacesPaths[face] = path; }

private:
bool mIsSkyboxEnabled = false;
QgsSkyboxEntity::SkyboxType mSkyboxType;
//
QString mPanoramicTexturePath;
@@ -127,6 +127,8 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas
mSkyboxSettingsWidget = new QgsSkyboxRenderingSettingsWidget( this );
mSkyboxSettingsWidget->setSkyboxSettings( map->skyboxSettings() );
groupSkyboxSettings->layout()->addWidget( mSkyboxSettingsWidget );
groupSkyboxSettings->setChecked( mMap->isSkyboxEnabled() );

}

void Qgs3DMapConfigWidget::apply()
@@ -239,6 +241,7 @@ void Qgs3DMapConfigWidget::apply()

mMap->setPointLights( widgetLights->pointLights() );
mMap->setDirectionalLights( widgetLights->directionalLights() );
mMap->setIsSkyboxEnabled( groupSkyboxSettings->isChecked() );
mMap->setSkyboxSettings( mSkyboxSettingsWidget->toSkyboxSettings() );
}

@@ -40,7 +40,7 @@
<x>0</x>
<y>0</y>
<width>541</width>
<height>753</height>
<height>730</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
@@ -368,6 +368,12 @@
<property name="title">
<string>Skybox rendering</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3"/>
</widget>
</item>
@@ -107,12 +107,7 @@
</layout>
</widget>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="skyboxEnabledCheckBox">
<property name="text">
<string>Enable skybox</string>
</property>
</widget>
</item>

0 comments on commit 09844a7

Please sign in to comment.
You can’t perform that action at this time.