37 static void _initRendererWidgetFunctions()
39 static bool sInitialized =
false;
63 connect( mResetColorRenderingBtn, &QToolButton::clicked,
this, &QgsRendererRasterPropertiesWidget::mResetColorRenderingBtn_clicked );
65 _initRendererWidgetFunctions();
67 mResamplingUtils.initWidgets( mRasterLayer, mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox, mMaximumOversamplingSpinBox, mCbEarlyResampling );
71 connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
72 connect( mBrightnessSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
73 mBrightnessSpinBox->setClearValue( 0 );
75 connect( mSliderContrast, &QAbstractSlider::valueChanged, mContrastSpinBox, &QSpinBox::setValue );
76 connect( mContrastSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderContrast, &QAbstractSlider::setValue );
77 mContrastSpinBox->setClearValue( 0 );
79 connect( mSliderGamma, &QAbstractSlider::valueChanged,
this, &QgsRendererRasterPropertiesWidget::updateGammaSpinBox );
80 connect( mGammaSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRendererRasterPropertiesWidget::updateGammaSlider );
81 mGammaSpinBox->setClearValue( 1.0 );
84 connect( sliderSaturation, &QAbstractSlider::valueChanged, spinBoxSaturation, &QSpinBox::setValue );
85 connect( spinBoxSaturation,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderSaturation, &QAbstractSlider::setValue );
86 spinBoxSaturation->setClearValue( 0 );
89 connect( sliderColorizeStrength, &QAbstractSlider::valueChanged, spinColorizeStrength, &QSpinBox::setValue );
90 connect( spinColorizeStrength,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderColorizeStrength, &QAbstractSlider::setValue );
91 spinColorizeStrength->setClearValue( 100 );
94 connect( comboGrayscale,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRendererRasterPropertiesWidget::toggleSaturationControls );
97 connect( mColorizeCheck, &QAbstractButton::toggled,
this, &QgsRendererRasterPropertiesWidget::toggleColorizeControls );
100 connect( mBrightnessSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &
QgsPanelWidget::widgetChanged );
102 connect( mGammaSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsPanelWidget::widgetChanged );
104 connect( spinColorizeStrength,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &
QgsPanelWidget::widgetChanged );
107 connect( mBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &
QgsPanelWidget::widgetChanged );
108 connect( mZoomedInResamplingComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &
QgsPanelWidget::widgetChanged );
109 connect( mZoomedOutResamplingComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &
QgsPanelWidget::widgetChanged );
110 connect( mMaximumOversamplingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsPanelWidget::widgetChanged );
127 QString rendererName = cboRenderers->currentData().toString();
128 setRendererWidget( rendererName );
136 brightnessFilter->setBrightness( mSliderBrightness->value() );
137 brightnessFilter->setContrast( mSliderContrast->value() );
138 brightnessFilter->setGamma( mGammaSpinBox->value() );
143 rendererWidget->doComputations();
150 newRenderer->copyCommonProperties( oldRenderer,
false );
158 hueSaturationFilter->setSaturation( sliderSaturation->value() );
160 hueSaturationFilter->setColorizeOn( mColorizeCheck->checkState() );
161 hueSaturationFilter->setColorizeColor( btnColorizeColor->color() );
162 hueSaturationFilter->setColorizeStrength( sliderColorizeStrength->value() );
165 mResamplingUtils.refreshLayerFromWidgets();
167 mRasterLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
172 mRasterLayer = layer;
174 cboRenderers->blockSignals(
true );
175 cboRenderers->clear();
178 for (
const QString &name : constRenderersList )
189 cboRenderers->setCurrentIndex( -1 );
190 cboRenderers->blockSignals(
false );
194 setRendererWidget( renderer->type() );
199 mSliderBrightness->setValue( brightnessFilter->brightness() );
200 mSliderContrast->setValue( brightnessFilter->contrast() );
201 mGammaSpinBox->setValue( brightnessFilter->gamma() );
204 btnColorizeColor->setColorDialogTitle( tr(
"Select Color" ) );
205 btnColorizeColor->setContext( QStringLiteral(
"symbology" ) );
211 sliderSaturation->setValue( hueSaturationFilter->saturation() );
212 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->grayscaleMode() );
215 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->grayscaleMode() ) );
218 mColorizeCheck->setChecked( hueSaturationFilter->colorizeOn() );
219 btnColorizeColor->setColor( hueSaturationFilter->colorizeColor() );
220 toggleColorizeControls( hueSaturationFilter->colorizeOn() );
221 sliderColorizeStrength->setValue( hueSaturationFilter->colorizeStrength() );
225 mBlendModeComboBox->setBlendMode( mRasterLayer->
blendMode() );
228 mResamplingUtils.refreshWidgetsFromLayer();
231 void QgsRendererRasterPropertiesWidget::mResetColorRenderingBtn_clicked()
233 mBlendModeComboBox->setBlendMode( QPainter::CompositionMode_SourceOver );
234 mSliderBrightness->setValue( 0 );
235 mSliderContrast->setValue( 0 );
236 mGammaSpinBox->setValue( 1.0 );
237 sliderSaturation->setValue( 0 );
239 mColorizeCheck->setChecked(
false );
240 sliderColorizeStrength->setValue( 100 );
243 void QgsRendererRasterPropertiesWidget::toggleSaturationControls(
int grayscaleMode )
246 if ( grayscaleMode == 0 )
248 sliderSaturation->setEnabled(
true );
249 spinBoxSaturation->setEnabled(
true );
253 sliderSaturation->setEnabled(
false );
254 spinBoxSaturation->setEnabled(
false );
259 void QgsRendererRasterPropertiesWidget::toggleColorizeControls(
bool colorizeEnabled )
262 btnColorizeColor->setEnabled( colorizeEnabled );
263 sliderColorizeStrength->setEnabled( colorizeEnabled );
264 spinColorizeStrength->setEnabled( colorizeEnabled );
268 void QgsRendererRasterPropertiesWidget::setRendererWidget(
const QString &rendererName )
279 alphaBand = oldRenderer->alphaBand();
280 opacity = oldRenderer->opacity();
281 nodataColor = oldRenderer->nodataColor();
289 QgsDebugMsgLevel( QStringLiteral(
"renderer has widgetCreateFunction" ), 3 );
294 if ( rendererName == QLatin1String(
"singlebandgray" ) )
297 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
299 else if ( rendererName == QLatin1String(
"multibandcolor" ) )
302 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
311 stackedWidget->addWidget( mRendererWidget );
312 stackedWidget->setCurrentWidget( mRendererWidget );
319 QList<int> oldBands = oldRenderer->
usesBands();
320 QList<int> newBands = newRenderer->
usesBands();
322 if ( oldBands != newBands )
324 populateTransparencyTable( newRenderer );
334 if ( mRendererWidget != oldWidget )
337 int widgetIndex = cboRenderers->findData( rendererName );
338 if ( widgetIndex != -1 )
340 whileBlocking( cboRenderers )->setCurrentIndex( widgetIndex );
345 void QgsRendererRasterPropertiesWidget::refreshAfterStyleChanged()
347 if ( mRendererWidget )
383 void QgsRendererRasterPropertiesWidget::updateGammaSpinBox(
int value )
385 mGammaSpinBox->setValue( value / 100.0 );
388 void QgsRendererRasterPropertiesWidget::updateGammaSlider(
double value )
390 mSliderGamma->setValue( value * 100 );