Skip to content
Permalink
Browse files

fix loading a project from XML

  • Loading branch information
PeterPetrik committed Jan 3, 2020
1 parent c8558ef commit 8a16451f26ecbf351817af6dac33c49581cd021c
@@ -285,6 +285,7 @@ void QgsMeshRenderer3dAveragingWidget::syncToLayer( )
}
}
whileBlocking( mAveragingMethodComboBox )->setCurrentIndex( pageIndex );
whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( pageIndex );
}
}

@@ -233,11 +233,15 @@ QDomElement QgsMeshMultiLevelsAveragingMethod::writeXml( QDomDocument &doc ) con

void QgsMeshMultiLevelsAveragingMethod::readXml( const QDomElement &elem )
{
mStartVerticalLevel = elem.attribute( QStringLiteral( "start-layer-index" ) ).toInt();
mEndVerticalLevel = elem.attribute( QStringLiteral( "end-layer-index" ) ).toInt();
if ( mStartVerticalLevel > mEndVerticalLevel )
QDomElement settings = elem.firstChildElement( QStringLiteral( "multi-vertical-layers-settings" ) );
if ( !settings.isNull() )
{
std::swap( mStartVerticalLevel, mEndVerticalLevel );
mStartVerticalLevel = settings.attribute( QStringLiteral( "start-layer-index" ) ).toInt();
mEndVerticalLevel = settings.attribute( QStringLiteral( "end-layer-index" ) ).toInt();
if ( mStartVerticalLevel > mEndVerticalLevel )
{
std::swap( mStartVerticalLevel, mEndVerticalLevel );
}
}
}

@@ -348,11 +352,15 @@ QDomElement QgsMeshSigmaAveragingMethod::writeXml( QDomDocument &doc ) const

void QgsMeshSigmaAveragingMethod::readXml( const QDomElement &elem )
{
mStartFraction = elem.attribute( QStringLiteral( "start-fraction" ) ).toInt();
mEndFraction = elem.attribute( QStringLiteral( "end-fraction" ) ).toInt();
if ( mStartFraction > mEndFraction )
QDomElement settings = elem.firstChildElement( QStringLiteral( "sigma-settings" ) );
if ( !settings.isNull() )
{
std::swap( mStartFraction, mEndFraction );
mStartFraction = settings.attribute( QStringLiteral( "start-fraction" ) ).toDouble();
mEndFraction = settings.attribute( QStringLiteral( "end-fraction" ) ).toDouble();
if ( mStartFraction > mEndFraction )
{
std::swap( mStartFraction, mEndFraction );
}
}
}

@@ -447,11 +455,15 @@ QDomElement QgsMeshRelativeHeightAveragingMethod::writeXml( QDomDocument &doc )

void QgsMeshRelativeHeightAveragingMethod::readXml( const QDomElement &elem )
{
mStartHeight = elem.attribute( QStringLiteral( "start-height" ) ).toInt();
mEndHeight = elem.attribute( QStringLiteral( "end-height" ) ).toInt();
if ( mStartHeight > mEndHeight )
QDomElement settings = elem.firstChildElement( QStringLiteral( "relative-height-settings" ) );
if ( !settings.isNull() )
{
std::swap( mStartHeight, mEndHeight );
mStartHeight = settings.attribute( QStringLiteral( "start-height" ) ).toDouble();
mEndHeight = settings.attribute( QStringLiteral( "end-height" ) ).toDouble();
if ( mStartHeight > mEndHeight )
{
std::swap( mStartHeight, mEndHeight );
}
}
}

@@ -539,11 +551,15 @@ QDomElement QgsMeshElevationAveragingMethod::writeXml( QDomDocument &doc ) const

void QgsMeshElevationAveragingMethod::readXml( const QDomElement &elem )
{
mStartElevation = elem.attribute( QStringLiteral( "start-elevation" ) ).toInt();
mEndElevation = elem.attribute( QStringLiteral( "end-elevation" ) ).toInt();
if ( mEndElevation > mStartElevation )
QDomElement settings = elem.firstChildElement( QStringLiteral( "elevation-settings" ) );
if ( !settings.isNull() )
{
std::swap( mEndElevation, mStartElevation );
mStartElevation = settings.attribute( QStringLiteral( "start-elevation" ) ).toDouble();
mEndElevation = settings.attribute( QStringLiteral( "end-elevation" ) ).toDouble();
if ( mEndElevation > mStartElevation )
{
std::swap( mEndElevation, mStartElevation );
}
}
}

@@ -400,6 +400,7 @@ QDomElement QgsMeshRendererSettings::writeXml( QDomDocument &doc ) const
QDomElement elemAveraging = doc.createElement( QStringLiteral( "averaging-3d" ) );
elemAveraging.setAttribute( QStringLiteral( "method" ), QStringLiteral( "%1" ).arg( mAveragingMethod->method() ) ) ;
QDomElement elemAveragingParams = mAveragingMethod->writeXml( doc );
elemAveraging.appendChild( elemAveragingParams );
elem.appendChild( elemAveraging );
}

@@ -457,7 +458,7 @@ void QgsMeshRendererSettings::readXml( const QDomElement &elem )
QDomElement elemAveraging = elem.firstChildElement( QStringLiteral( "averaging-3d" ) );
if ( !elemAveraging.isNull() )
{
mAveragingMethod.reset( QgsMesh3dAveragingMethod::createFromXml( elem ) );
mAveragingMethod.reset( QgsMesh3dAveragingMethod::createFromXml( elemAveraging ) );
}
}

@@ -476,6 +476,9 @@
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.250000000000000</double>
</property>

0 comments on commit 8a16451

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