Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't write mesh range settings to XML if they are default #60254

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 6 additions & 56 deletions src/core/mesh/qgsmeshrenderersettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ QDomElement QgsMeshRendererScalarSettings::writeXml( QDomDocument &doc, const Qg
}
elem.setAttribute( QStringLiteral( "interpolation-method" ), methodTxt );

elem.setAttribute( QStringLiteral( "range-extent" ), QgsMeshRendererScalarSettings::extentString( mRangeExtent ) );
elem.setAttribute( QStringLiteral( "range-limit" ), QgsMeshRendererScalarSettings::limitsString( mRangeLimit ) );
if ( mRangeExtent != Qgis::MeshRangeExtent::WholeMesh )
elem.setAttribute( QStringLiteral( "range-extent" ), qgsEnumValueToKey( mRangeExtent ) );
if ( mRangeLimit != Qgis::MeshRangeLimit::NotSet )
elem.setAttribute( QStringLiteral( "range-limit" ), qgsEnumValueToKey( mRangeLimit ) );

const QDomElement elemShader = mColorRampShader.writeXml( doc, context );
elem.appendChild( elemShader );
Expand Down Expand Up @@ -163,8 +165,8 @@ void QgsMeshRendererScalarSettings::readXml( const QDomElement &elem, const QgsR
mDataResamplingMethod = DataResamplingMethod::NoResampling;
}

mRangeExtent = QgsMeshRendererScalarSettings::extentFromString( elem.attribute( "range-extent" ) );
mRangeLimit = QgsMeshRendererScalarSettings::limitsFromString( elem.attribute( "range-limit" ) );
mRangeExtent = qgsEnumKeyToValue( elem.attribute( "range-extent" ), Qgis::MeshRangeExtent::WholeMesh );
mRangeLimit = qgsEnumKeyToValue( elem.attribute( "range-limit" ), Qgis::MeshRangeLimit::NotSet );

const QDomElement elemShader = elem.firstChildElement( QStringLiteral( "colorrampshader" ) );
mColorRampShader.readXml( elemShader, context );
Expand Down Expand Up @@ -206,58 +208,6 @@ void QgsMeshRendererScalarSettings::updateShader()
mColorRampShader.classifyColorRamp( mColorRampShader.sourceColorRamp()->count(), 1, QgsRectangle(), nullptr );
}

QString QgsMeshRendererScalarSettings::extentString( Qgis::MeshRangeExtent extent )
{
switch ( extent )
{
case Qgis::MeshRangeExtent::WholeMesh:
return QStringLiteral( "WholeMesh" );
case Qgis::MeshRangeExtent::FixedCanvas:
return QStringLiteral( "CurrentCanvas" );
case Qgis::MeshRangeExtent::UpdatedCanvas:
return QStringLiteral( "UpdatedCanvas" );
}
return QStringLiteral( "WholeMesh" );
}

Qgis::MeshRangeExtent QgsMeshRendererScalarSettings::extentFromString( const QString &extent )
{
if ( extent == QLatin1String( "WholeMesh" ) )
{
return Qgis::MeshRangeExtent::WholeMesh;
}
else if ( extent == QLatin1String( "CurrentCanvas" ) )
{
return Qgis::MeshRangeExtent::FixedCanvas;
}
else if ( extent == QLatin1String( "UpdatedCanvas" ) )
{
return Qgis::MeshRangeExtent::UpdatedCanvas;
}

return Qgis::MeshRangeExtent::WholeMesh;
}

QString QgsMeshRendererScalarSettings::limitsString( Qgis::MeshRangeLimit limits )
{
switch ( limits )
{
case Qgis::MeshRangeLimit::MinimumMaximum:
return QStringLiteral( "MinMax" );
default:
break;
}
return QStringLiteral( "None" );
}

Qgis::MeshRangeLimit QgsMeshRendererScalarSettings::limitsFromString( const QString &limits )
{
if ( limits == QLatin1String( "MinMax" ) )
{
return Qgis::MeshRangeLimit::MinimumMaximum;
}
return Qgis::MeshRangeLimit::NotSet;
}

// ---------------------------------------------------------------------

Expand Down
13 changes: 0 additions & 13 deletions src/core/mesh/qgsmeshrenderersettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,6 @@ class CORE_EXPORT QgsMeshRendererScalarSettings
private:
void updateShader();

//! Returns a string to serialize Limits
static QString limitsString( Qgis::MeshRangeLimit limits );

//! \brief Deserialize Limits
static Qgis::MeshRangeLimit limitsFromString( const QString &limits );

//! Returns a string to serialize Extent
static QString extentString( Qgis::MeshRangeExtent extent );

//! \brief Deserialize Extent
static Qgis::MeshRangeExtent extentFromString( const QString &extent );


QgsColorRampShader mColorRampShader;
DataResamplingMethod mDataResamplingMethod = DataResamplingMethod::NoResampling;
double mClassificationMinimum = 0;
Expand Down
Loading