|
45 | 45 | #include "qgsrastertransparency.h" |
46 | 46 | #include "qgssinglebandgrayrendererwidget.h" |
47 | 47 | #include "qgssinglebandpseudocolorrendererwidget.h" |
| 48 | +#include "qgshuesaturationfilter.h" |
48 | 49 |
|
49 | 50 | #include <QTableWidgetItem> |
50 | 51 | #include <QHeaderView> |
@@ -89,6 +90,20 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv |
89 | 90 | connect( mSliderContrast, SIGNAL( valueChanged( int ) ), mContrastSpinBox, SLOT( setValue( int ) ) ); |
90 | 91 | connect( mContrastSpinBox, SIGNAL( valueChanged( int ) ), mSliderContrast, SLOT( setValue( int ) ) ); |
91 | 92 |
|
| 93 | + // Connect saturation slider and spin box |
| 94 | + connect( sliderSaturation, SIGNAL( valueChanged( int ) ), spinBoxSaturation, SLOT( setValue( int ) ) ); |
| 95 | + connect( spinBoxSaturation, SIGNAL( valueChanged( int ) ), sliderSaturation, SLOT( setValue( int ) ) ); |
| 96 | + |
| 97 | + // Connect colorize strength slider and spin box |
| 98 | + connect( sliderColorizeStrength, SIGNAL( valueChanged( int ) ), spinColorizeStrength, SLOT( setValue( int ) ) ); |
| 99 | + connect( spinColorizeStrength, SIGNAL( valueChanged( int ) ), sliderColorizeStrength, SLOT( setValue( int ) ) ); |
| 100 | + |
| 101 | + // enable or disable saturation slider and spin box depending on grayscale combo choice |
| 102 | + connect( comboGrayscale, SIGNAL( currentIndexChanged( int ) ), this, SLOT( toggleSaturationControls( int ) ) ); |
| 103 | + |
| 104 | + // enable or disable colorize colorbutton with colorize checkbox |
| 105 | + connect( mColorizeCheck, SIGNAL( toggled( bool ) ), this, SLOT( toggleColorizeControls( bool ) ) ); |
| 106 | + |
92 | 107 | // enable or disable Build Pyramids button depending on selection in pyramid list |
93 | 108 | connect( lbxPyramidResolutions, SIGNAL( itemSelectionChanged() ), this, SLOT( toggleBuildPyramidsButton() ) ); |
94 | 109 |
|
@@ -250,6 +265,25 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv |
250 | 265 | mMaximumOversamplingSpinBox->setValue( resampleFilter->maxOversampling() ); |
251 | 266 | } |
252 | 267 |
|
| 268 | + // Hue and saturation color control |
| 269 | + mHueSaturationGroupBox->setSaveCheckedState( true ); |
| 270 | + const QgsHueSaturationFilter* hueSaturationFilter = mRasterLayer->hueSaturationFilter(); |
| 271 | + //set hue and saturation controls to current values |
| 272 | + if ( hueSaturationFilter ) |
| 273 | + { |
| 274 | + sliderSaturation->setValue( hueSaturationFilter->saturation() ); |
| 275 | + comboGrayscale->setCurrentIndex(( int ) hueSaturationFilter->grayscaleMode() ); |
| 276 | + |
| 277 | + // Set initial state of saturation controls based on grayscale mode choice |
| 278 | + toggleSaturationControls(( int )hueSaturationFilter->grayscaleMode() ); |
| 279 | + |
| 280 | + // Set initial state of colorize controls |
| 281 | + mColorizeCheck->setChecked( hueSaturationFilter->colorizeOn() ); |
| 282 | + btnColorizeColor->setColor( hueSaturationFilter->colorizeColor() ); |
| 283 | + toggleColorizeControls( hueSaturationFilter->colorizeOn() ); |
| 284 | + sliderColorizeStrength->setValue( hueSaturationFilter->colorizeStrength() ); |
| 285 | + } |
| 286 | + |
253 | 287 | //blend mode |
254 | 288 | mBlendModeComboBox->setBlendMode( mRasterLayer->blendMode() ); |
255 | 289 |
|
@@ -824,6 +858,17 @@ void QgsRasterLayerProperties::apply() |
824 | 858 | resampleFilter->setMaxOversampling( mMaximumOversamplingSpinBox->value() ); |
825 | 859 | } |
826 | 860 |
|
| 861 | + // Hue and saturation controls |
| 862 | + QgsHueSaturationFilter* hueSaturationFilter = mRasterLayer->hueSaturationFilter(); |
| 863 | + if ( hueSaturationFilter ) |
| 864 | + { |
| 865 | + hueSaturationFilter->setSaturation( sliderSaturation->value() ); |
| 866 | + hueSaturationFilter->setGrayscaleMode(( QgsHueSaturationFilter::GrayscaleMode ) comboGrayscale->currentIndex() ); |
| 867 | + hueSaturationFilter->setColorizeOn( mColorizeCheck->checkState() ); |
| 868 | + hueSaturationFilter->setColorizeColor( btnColorizeColor->color() ); |
| 869 | + hueSaturationFilter->setColorizeStrength( sliderColorizeStrength->value() ); |
| 870 | + } |
| 871 | + |
827 | 872 | //set the blend mode for the layer |
828 | 873 | mRasterLayer->setBlendMode(( QgsMapRenderer::BlendMode ) mBlendModeComboBox->blendMode() ); |
829 | 874 |
|
@@ -1457,6 +1502,29 @@ void QgsRasterLayerProperties::sliderTransparency_valueChanged( int theValue ) |
1457 | 1502 | lblTransparencyPercent->setText( QString::number( myInt ) + "%" ); |
1458 | 1503 | }//sliderTransparency_valueChanged |
1459 | 1504 |
|
| 1505 | +void QgsRasterLayerProperties::toggleSaturationControls( int grayscaleMode ) |
| 1506 | +{ |
| 1507 | + // Enable or disable saturation controls based on choice of grayscale mode |
| 1508 | + if ( grayscaleMode == 0 ) |
| 1509 | + { |
| 1510 | + sliderSaturation->setEnabled( true ); |
| 1511 | + spinBoxSaturation->setEnabled( true ); |
| 1512 | + } |
| 1513 | + else |
| 1514 | + { |
| 1515 | + sliderSaturation->setEnabled( false ); |
| 1516 | + spinBoxSaturation->setEnabled( false ); |
| 1517 | + } |
| 1518 | +} |
| 1519 | + |
| 1520 | +void QgsRasterLayerProperties::toggleColorizeControls( bool colorizeEnabled ) |
| 1521 | +{ |
| 1522 | + // Enable or disable colorize controls based on checkbox |
| 1523 | + btnColorizeColor->setEnabled( colorizeEnabled ); |
| 1524 | + sliderColorizeStrength->setEnabled( colorizeEnabled ); |
| 1525 | + spinColorizeStrength->setEnabled( colorizeEnabled ); |
| 1526 | +} |
| 1527 | + |
1460 | 1528 |
|
1461 | 1529 | QLinearGradient QgsRasterLayerProperties::redGradient() |
1462 | 1530 | { |
|
0 commit comments