Delete previous skybox implementation and save skybox settings as a DOM element

This commit is contained in:
NEDJIMAbelgacem 2020-08-02 00:31:41 +01:00
parent 5c418c4837
commit b39547e508
3 changed files with 4 additions and 54 deletions

View File

@ -299,26 +299,6 @@ Sets list of extra 3D renderers to use in the scene. Takes ownership of the obje
QList<QgsAbstract3DRenderer *> renderers() const;
%Docstring
Returns list of extra 3D renderers
%End
void setSkybox( bool enabled, const QString &fileBase = QString(), const QString &fileExtension = QString() );
%Docstring
Sets skybox configuration. When enabled, map scene will try to load six texture files
using the following syntax of filenames: "[base]_[side][extension]" where [side] is one
of the following: posx/posy/posz/negx/negy/negz and [base] and [extension] are the arguments
passed this method.
%End
bool hasSkyboxEnabled() const;
%Docstring
Returns whether skybox is enabled
%End
QString skyboxFileBase() const;
%Docstring
Returns base part of filenames of skybox (see :py:func:`~Qgs3DMapSettings.setSkybox`)
%End
QString skyboxFileExtension() const;
%Docstring
Returns extension part of filenames of skybox (see :py:func:`~Qgs3DMapSettings.setSkybox`)
%End
void setShowTerrainBoundingBoxes( bool enabled );

View File

@ -54,9 +54,6 @@ Qgs3DMapSettings::Qgs3DMapSettings( const Qgs3DMapSettings &other )
, mFieldOfView( other.mFieldOfView )
, mLayers( other.mLayers )
, mRenderers() // initialized in body
, mSkyboxEnabled( other.mSkyboxEnabled )
, mSkyboxFileBase( other.mSkyboxFileBase )
, mSkyboxFileExtension( other.mSkyboxFileExtension )
, mTransformContext( other.mTransformContext )
, mPathResolver( other.mPathResolver )
, mMapThemes( other.mMapThemes )
@ -208,9 +205,7 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
}
QDomElement elemSkybox = elem.firstChildElement( QStringLiteral( "skybox" ) );
mSkyboxEnabled = elemSkybox.attribute( QStringLiteral( "enabled" ), QStringLiteral( "0" ) ).toInt();
mSkyboxFileBase = elemSkybox.attribute( QStringLiteral( "file-base" ) );
mSkyboxFileExtension = elemSkybox.attribute( QStringLiteral( "file-ext" ) );
mSkyboxSettings.readXml( elemSkybox, context );
QDomElement elemDebug = elem.firstChildElement( QStringLiteral( "debug" ) );
mShowTerrainBoundingBoxes = elemDebug.attribute( QStringLiteral( "bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
@ -300,10 +295,8 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elem.appendChild( elemRenderers );
QDomElement elemSkybox = doc.createElement( QStringLiteral( "skybox" ) );
elemSkybox.setAttribute( QStringLiteral( "enabled" ), mSkyboxEnabled ? 1 : 0 );
// TODO: use context for relative paths, maybe explicitly list all files(?)
elemSkybox.setAttribute( QStringLiteral( "file-base" ), mSkyboxFileBase );
elemSkybox.setAttribute( QStringLiteral( "file-ext" ), mSkyboxFileExtension );
mSkyboxSettings.writeXml( elemSkybox, context );
elem.appendChild( elemSkybox );
QDomElement elemDebug = doc.createElement( QStringLiteral( "debug" ) );
@ -588,13 +581,6 @@ void Qgs3DMapSettings::setFieldOfView( const float fieldOfView )
emit fieldOfViewChanged();
}
void Qgs3DMapSettings::setSkybox( bool enabled, const QString &fileBase, const QString &fileExtension )
{
mSkyboxEnabled = enabled;
mSkyboxFileBase = fileBase;
mSkyboxFileExtension = fileExtension;
}
void Qgs3DMapSettings::setSkyboxSettings( const QgsSkyboxSettings &skyboxSettings )
{
mSkyboxSettings = skyboxSettings;

View File

@ -281,20 +281,6 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
//! Returns list of extra 3D renderers
QList<QgsAbstract3DRenderer *> renderers() const { return mRenderers; }
/**
* Sets skybox configuration. When enabled, map scene will try to load six texture files
* using the following syntax of filenames: "[base]_[side][extension]" where [side] is one
* of the following: posx/posy/posz/negx/negy/negz and [base] and [extension] are the arguments
* passed this method.
*/
void setSkybox( bool enabled, const QString &fileBase = QString(), const QString &fileExtension = QString() );
//! Returns whether skybox is enabled
bool hasSkyboxEnabled() const { return mSkyboxEnabled; }
//! Returns base part of filenames of skybox (see setSkybox())
QString skyboxFileBase() const { return mSkyboxFileBase; }
//! Returns extension part of filenames of skybox (see setSkybox())
QString skyboxFileExtension() const { return mSkyboxFileExtension; }
//! Sets whether to display bounding boxes of terrain tiles (for debugging)
void setShowTerrainBoundingBoxes( bool enabled );
//! Returns whether to display bounding boxes of terrain tiles (for debugging)
@ -502,15 +488,13 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
float mFieldOfView = 45.0f; //<! Camera lens field of view value
QList<QgsMapLayerRef> mLayers; //!< Layers to be rendered
QList<QgsAbstract3DRenderer *> mRenderers; //!< Extra stuff to render as 3D object
bool mSkyboxEnabled = false; //!< Whether to render skybox
QString mSkyboxFileBase; //!< Base part of the files with skybox textures
QString mSkyboxFileExtension; //!< Extension part of the files with skybox textures
//! Coordinate transform context
QgsCoordinateTransformContext mTransformContext;
QgsPathResolver mPathResolver;
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;
QgsSkyboxSettings mSkyboxSettings; //!< Skybox realted configuration
};