Skip to content

Commit

Permalink
[FEATURE] Implement raster pseudocolor updated extent auto classifica…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
nirvn committed Dec 27, 2016
1 parent 181f84b commit 5ece689
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
22 changes: 22 additions & 0 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,30 @@ void QgsRasterLayer::refreshRendererIfNeeded( QgsRasterRenderer* rasterRenderer,
SAMPLE_SIZE, min, max );
sbpcr->setClassificationMin( min );
sbpcr->setClassificationMax( max );

if ( sbpcr->shader() )
{
QgsColorRampShader* colorRampShader = dynamic_cast<QgsColorRampShader*>( sbpcr->shader()->rasterShaderFunction() );
if ( colorRampShader )
{
colorRampShader->classifyColorRamp( sbpcr->band(), theExtent, rasterRenderer->input() );
}
}

QgsSingleBandPseudoColorRenderer* r = dynamic_cast<QgsSingleBandPseudoColorRenderer*>( renderer() );
dynamic_cast<QgsSingleBandPseudoColorRenderer*>( renderer() )->setClassificationMin( min );
dynamic_cast<QgsSingleBandPseudoColorRenderer*>( renderer() )->setClassificationMax( max );

if ( r->shader() )
{
QgsColorRampShader* colorRampShader = dynamic_cast<QgsColorRampShader*>( r->shader()->rasterShaderFunction() );
if ( colorRampShader )
{
colorRampShader->classifyColorRamp( sbpcr->band(), theExtent, rasterRenderer->input() );
}
}

emit repaintRequested();
emit styleChanged();
emit rendererChanged();
return;
Expand Down
8 changes: 3 additions & 5 deletions src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ QgsSingleBandPseudoColorRendererWidget::QgsSingleBandPseudoColorRendererWidget(
mMinMaxContainerWidget->setLayout( layout );
layout->addWidget( mMinMaxWidget );

connect( mMinMaxWidget, &QgsRasterMinMaxWidget::widgetChanged,
this, &QgsSingleBandPseudoColorRendererWidget::widgetChanged );

connect( mMinMaxWidget, &QgsRasterMinMaxWidget::load,
this, &QgsSingleBandPseudoColorRendererWidget::loadMinMax );
connect( mMinMaxWidget, &QgsRasterMinMaxWidget::widgetChanged, this, &QgsSingleBandPseudoColorRendererWidget::widgetChanged );
connect( mMinMaxWidget, &QgsRasterMinMaxWidget::load, this, &QgsSingleBandPseudoColorRendererWidget::loadMinMax );

//fill available bands into combo box
int nBands = provider->bandCount();
Expand Down Expand Up @@ -775,6 +772,7 @@ void QgsSingleBandPseudoColorRendererWidget::loadMinMax( int theBandNo, double t
mMaxLineEdit->setText( QString::number( theMax ) );
}
mDisableMinMaxWidgetRefresh = false;
classify();
}

void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit * theLineEdit, double theValue )
Expand Down

0 comments on commit 5ece689

Please sign in to comment.