Skip to content
Permalink
Browse files
Default to random color ramps for unique value rasters
  • Loading branch information
nyalldawson committed Apr 3, 2017
1 parent fcbda57 commit 19403f6986d6b2993192b6a8a551d8cb3e85eb3d
Showing with 8 additions and 16 deletions.
  1. +8 −16 src/gui/raster/qgspalettedrendererwidget.cpp
@@ -68,9 +68,10 @@ QgsPalettedRendererWidget::QgsPalettedRendererWidget( QgsRasterLayer *layer, con
connect( mTreeView, &QTreeView::customContextMenuRequested, [ = ]( const QPoint & ) { contextMenu->exec( QCursor::pos() ); }
);

QgsSettings settings;
QString defaultPalette = settings.value( QStringLiteral( "Raster/defaultPalette" ), QString() ).toString();
btnColorRamp->setColorRampFromName( defaultPalette );
btnColorRamp->setShowRandomColorRamp( true );

std::unique_ptr< QgsColorRamp > ramp( new QgsRandomColorRamp() );
btnColorRamp->setDefaultColorRamp( ramp.get() );
connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsPalettedRendererWidget::applyColorRamp );

if ( mRasterLayer )
@@ -150,17 +151,15 @@ void QgsPalettedRendererWidget::setFromRenderer( const QgsRasterRenderer *r )
}
else
{
QgsSettings settings;
QString defaultPalette = settings.value( "/Raster/defaultPalette", "Spectral" ).toString();
whileBlocking( btnColorRamp )->setColorRampFromName( defaultPalette );
std::unique_ptr< QgsColorRamp > ramp( new QgsRandomColorRamp() );
whileBlocking( btnColorRamp )->setColorRamp( ramp.get() );
}
}
else
{
loadFromLayer();
QgsSettings settings;
QString defaultPalette = settings.value( "/Raster/defaultPalette", "Spectral" ).toString();
whileBlocking( btnColorRamp )->setColorRampFromName( defaultPalette );
std::unique_ptr< QgsColorRamp > ramp( new QgsRandomColorRamp() );
whileBlocking( btnColorRamp )->setColorRamp( ramp.get() );
}
}

@@ -312,13 +311,6 @@ void QgsPalettedRendererWidget::applyColorRamp()
return;
}

if ( !btnColorRamp->colorRampName().isEmpty() )
{
// Remember last used color ramp
QgsSettings settings;
settings.setValue( QStringLiteral( "Raster/defaultPalette" ), btnColorRamp->colorRampName() );
}

disconnect( mModel, &QgsPalettedRendererModel::classesChanged, this, &QgsPalettedRendererWidget::widgetChanged );

QgsPalettedRasterRenderer::ClassData data = mModel->classData();

0 comments on commit 19403f6

Please sign in to comment.