39 static void _initRendererWidgetFunctions()
41 static bool sInitialized =
false;
65 connect( mResetColorRenderingBtn, &QToolButton::clicked,
this, &QgsRendererRasterPropertiesWidget::mResetColorRenderingBtn_clicked );
67 _initRendererWidgetFunctions();
69 mResamplingUtils.initWidgets( mRasterLayer, mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox, mMaximumOversamplingSpinBox, mCbEarlyResampling );
73 connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
74 connect( mBrightnessSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
75 mBrightnessSpinBox->setClearValue( 0 );
77 connect( mSliderContrast, &QAbstractSlider::valueChanged, mContrastSpinBox, &QSpinBox::setValue );
78 connect( mContrastSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderContrast, &QAbstractSlider::setValue );
79 mContrastSpinBox->setClearValue( 0 );
81 connect( mSliderGamma, &QAbstractSlider::valueChanged,
this, &QgsRendererRasterPropertiesWidget::updateGammaSpinBox );
82 connect( mGammaSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRendererRasterPropertiesWidget::updateGammaSlider );
83 mGammaSpinBox->setClearValue( 1.0 );
86 connect( sliderSaturation, &QAbstractSlider::valueChanged, spinBoxSaturation, &QSpinBox::setValue );
87 connect( spinBoxSaturation,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderSaturation, &QAbstractSlider::setValue );
88 spinBoxSaturation->setClearValue( 0 );
91 connect( sliderColorizeStrength, &QAbstractSlider::valueChanged, spinColorizeStrength, &QSpinBox::setValue );
92 connect( spinColorizeStrength,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderColorizeStrength, &QAbstractSlider::setValue );
93 spinColorizeStrength->setClearValue( 100 );
96 connect( comboGrayscale,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRendererRasterPropertiesWidget::toggleSaturationControls );
99 connect( mColorizeCheck, &QAbstractButton::toggled,
this, &QgsRendererRasterPropertiesWidget::toggleColorizeControls );
102 connect( mBrightnessSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &
QgsPanelWidget::widgetChanged );
104 connect( mGammaSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsPanelWidget::widgetChanged );
106 connect( spinColorizeStrength,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &
QgsPanelWidget::widgetChanged );
110 connect( mBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &
QgsPanelWidget::widgetChanged );
111 connect( mZoomedInResamplingComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &
QgsPanelWidget::widgetChanged );
112 connect( mZoomedOutResamplingComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &
QgsPanelWidget::widgetChanged );
113 connect( mMaximumOversamplingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &
QgsPanelWidget::widgetChanged );
130 const QString rendererName = cboRenderers->currentData().toString();
131 setRendererWidget( rendererName );
139 brightnessFilter->setBrightness( mSliderBrightness->value() );
140 brightnessFilter->setContrast( mSliderContrast->value() );
141 brightnessFilter->setGamma( mGammaSpinBox->value() );
146 rendererWidget->doComputations();
153 newRenderer->copyCommonProperties( oldRenderer,
false );
161 hueSaturationFilter->setSaturation( sliderSaturation->value() );
163 hueSaturationFilter->setColorizeOn( mColorizeCheck->checkState() );
164 hueSaturationFilter->setColorizeColor( btnColorizeColor->color() );
165 hueSaturationFilter->setColorizeStrength( sliderColorizeStrength->value() );
166 hueSaturationFilter->setInvertColors( mInvertColorsCheck->isChecked() );
169 mResamplingUtils.refreshLayerFromWidgets();
171 mRasterLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
176 mRasterLayer = layer;
178 cboRenderers->blockSignals(
true );
179 cboRenderers->clear();
182 for (
const QString &name : constRenderersList )
193 cboRenderers->setCurrentIndex( -1 );
194 cboRenderers->blockSignals(
false );
198 setRendererWidget( renderer->type() );
203 mSliderBrightness->setValue( brightnessFilter->brightness() );
204 mSliderContrast->setValue( brightnessFilter->contrast() );
205 mGammaSpinBox->setValue( brightnessFilter->gamma() );
208 btnColorizeColor->setColorDialogTitle( tr(
"Select Color" ) );
209 btnColorizeColor->setContext( QStringLiteral(
"symbology" ) );
215 sliderSaturation->setValue( hueSaturationFilter->saturation() );
216 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->grayscaleMode() );
219 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->grayscaleMode() ) );
222 mColorizeCheck->setChecked( hueSaturationFilter->colorizeOn() );
223 btnColorizeColor->setColor( hueSaturationFilter->colorizeColor() );
224 toggleColorizeControls( hueSaturationFilter->colorizeOn() );
225 sliderColorizeStrength->setValue( hueSaturationFilter->colorizeStrength() );
227 mInvertColorsCheck->setChecked( hueSaturationFilter->invertColors() );
232 mBlendModeComboBox->setBlendMode( mRasterLayer->
blendMode() );
235 mResamplingUtils.refreshWidgetsFromLayer();
238 void QgsRendererRasterPropertiesWidget::mResetColorRenderingBtn_clicked()
240 mBlendModeComboBox->setBlendMode( QPainter::CompositionMode_SourceOver );
241 mSliderBrightness->setValue( 0 );
242 mSliderContrast->setValue( 0 );
243 mGammaSpinBox->setValue( 1.0 );
244 sliderSaturation->setValue( 0 );
246 mColorizeCheck->setChecked(
false );
247 sliderColorizeStrength->setValue( 100 );
248 mInvertColorsCheck->setChecked(
false );
251 void QgsRendererRasterPropertiesWidget::toggleSaturationControls(
int grayscaleMode )
254 if ( grayscaleMode == 0 )
256 sliderSaturation->setEnabled(
true );
257 spinBoxSaturation->setEnabled(
true );
261 sliderSaturation->setEnabled(
false );
262 spinBoxSaturation->setEnabled(
false );
267 void QgsRendererRasterPropertiesWidget::toggleColorizeControls(
bool colorizeEnabled )
270 btnColorizeColor->setEnabled( colorizeEnabled );
271 sliderColorizeStrength->setEnabled( colorizeEnabled );
272 spinColorizeStrength->setEnabled( colorizeEnabled );
276 void QgsRendererRasterPropertiesWidget::setRendererWidget(
const QString &rendererName )
287 alphaBand = oldRenderer->alphaBand();
288 opacity = oldRenderer->opacity();
289 nodataColor = oldRenderer->nodataColor();
297 QgsDebugMsgLevel( QStringLiteral(
"renderer has widgetCreateFunction" ), 3 );
304 std::unique_ptr< QgsRasterRenderer > oldRenderer( oldWidget->
renderer() );
305 if ( !oldRenderer || oldRenderer->type() != rendererName )
307 if ( rendererName == QLatin1String(
"singlebandgray" ) )
310 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
312 else if ( rendererName == QLatin1String(
"multibandcolor" ) )
315 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
325 stackedWidget->addWidget( mRendererWidget );
326 stackedWidget->setCurrentWidget( mRendererWidget );
333 QList<int> oldBands = oldRenderer->
usesBands();
334 QList<int> newBands = newRenderer->
usesBands();
336 if ( oldBands != newBands )
338 populateTransparencyTable( newRenderer );
348 if ( mRendererWidget != oldWidget )
351 const int widgetIndex = cboRenderers->findData( rendererName );
352 if ( widgetIndex != -1 )
354 whileBlocking( cboRenderers )->setCurrentIndex( widgetIndex );
359 void QgsRendererRasterPropertiesWidget::refreshAfterStyleChanged()
361 if ( mRendererWidget )
397 void QgsRendererRasterPropertiesWidget::updateGammaSpinBox(
int value )
399 mGammaSpinBox->setValue( value / 100.0 );
402 void QgsRendererRasterPropertiesWidget::updateGammaSlider(
double value )
404 mSliderGamma->setValue( value * 100 );