Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Raster Rendering: set min/max in widget earlier when loading from ren…
…derer

When populating QgsSingleBandPseudoColorRenderer from an existing one the
min/max values where set last. However if that renderers shader was a
QgsColorRampShader without an actual color ramp, a default one was used.
Now, if the color ramp shader contained a color map, we try to interpolate
the colors with these min/max values, which are not set yet.

So we set these values before loading any raster shader.
  • Loading branch information
iona5 committed Jul 31, 2020
1 parent 7368e7f commit 5b81714
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
Expand Up @@ -153,6 +153,12 @@ void QgsSingleBandPseudoColorRendererWidget::setFromRenderer( const QgsRasterRen
mMinMaxWidget->setBands( QList< int >() << pr->band() );
mColorRampShaderWidget->setRasterBand( pr->band() );

// need to set min/max properties here because if we use the raster shader below,
// we may set a new color ramp which needs to have min/max values defined.
setLineEditValue( mMinLineEdit, pr->classificationMin() );
setLineEditValue( mMaxLineEdit, pr->classificationMax() );
mMinMaxWidget->setFromMinMaxOrigin( pr->minMaxOrigin() );

const QgsRasterShader *rasterShader = pr->shader();
if ( rasterShader )
{
Expand All @@ -162,10 +168,6 @@ void QgsSingleBandPseudoColorRendererWidget::setFromRenderer( const QgsRasterRen
mColorRampShaderWidget->setFromShader( *colorRampShader );
}
}
setLineEditValue( mMinLineEdit, pr->classificationMin() );
setLineEditValue( mMaxLineEdit, pr->classificationMax() );

mMinMaxWidget->setFromMinMaxOrigin( pr->minMaxOrigin() );
}
else
{
Expand Down

0 comments on commit 5b81714

Please sign in to comment.