@@ -284,13 +284,13 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
284
284
QPixmap myPyramidPixmap (myThemePath + " /mIconPyramid.png" );
285
285
QPixmap myNoPyramidPixmap (myThemePath + " /mIconNoPyramid.png" );
286
286
287
- pbnAddValuesManually->setIcon (QIcon (QPixmap ( myThemePath + " /mActionNewAttribute.png" ) ));
288
- pbnAddValuesFromDisplay->setIcon (QIcon (QPixmap ( myThemePath + " /mActionContextHelp.png" ) ));
289
- pbnRemoveSelectedRow->setIcon (QIcon (QPixmap ( myThemePath + " /mActionDeleteAttribute.png" ) ));
290
- pbnDefaultValues->setIcon (QIcon (QPixmap ( myThemePath + " /mActionCopySelected.png" ) ));
291
- pbnImportTransparentPixelValues->setIcon (QIcon (QPixmap ( myThemePath + " /mActionFileOpen.png" ) ));
292
- pbnExportTransparentPixelValues->setIcon (QIcon (QPixmap ( myThemePath + " /mActionFileSave.png" ) ));
293
- pbtnMakeContrastEnhancementAlgorithmDefault->setIcon (QIcon (QPixmap ( myThemePath + " /mActionFileSave.png" ) ));
287
+ pbnAddValuesManually->setIcon (QIcon (myThemePath + " /mActionNewAttribute.png" ));
288
+ pbnAddValuesFromDisplay->setIcon (QIcon (myThemePath + " /mActionContextHelp.png" ));
289
+ pbnRemoveSelectedRow->setIcon (QIcon (myThemePath + " /mActionDeleteAttribute.png" ));
290
+ pbnDefaultValues->setIcon (QIcon (myThemePath + " /mActionCopySelected.png" ));
291
+ pbnImportTransparentPixelValues->setIcon (QIcon (myThemePath + " /mActionFileOpen.png" ));
292
+ pbnExportTransparentPixelValues->setIcon (QIcon (myThemePath + " /mActionFileSave.png" ));
293
+ pbtnMakeContrastEnhancementAlgorithmDefault->setIcon (QIcon (myThemePath + " /mActionFileSave.png" ));
294
294
295
295
// Only do pyramids if dealing directly with GDAL.
296
296
if (mRasterLayerIsGdal )
@@ -729,20 +729,25 @@ void QgsRasterLayerProperties::sync()
729
729
730
730
// Display the current default contrast enhancement algorithm
731
731
QSettings myQSettings;
732
- QString myDefaultAlgorithm = myQSettings.value (" /Raster/defaultContrastEnhancementAlgorithm" , " NO_STRETCH" ).toString ();
733
- if (myDefaultAlgorithm == " NO_STRETCH" )
732
+ mDefaultRedBand = myQSettings.value (" /Raster/defaultRedBand" , 1 ).toInt ();
733
+ mDefaultGreenBand = myQSettings.value (" /Raster/defaultGreenBand" , 2 ).toInt ();
734
+ mDefaultBlueBand = myQSettings.value (" /Raster/defaultBlueBand" , 3 ).toInt ();
735
+ labelDefaultBandCombination->setText (QString (tr (" Default" ) + " R:%1 G:%2 B:%3" ) .arg (mDefaultRedBand ) .arg (mDefaultGreenBand ) .arg (mDefaultBlueBand ));
736
+
737
+ mDefaultContrastEnhancementAlgorithm = myQSettings.value (" /Raster/defaultContrastEnhancementAlgorithm" , " NO_STRETCH" ).toString ();
738
+ if (mDefaultContrastEnhancementAlgorithm == " NO_STRETCH" )
734
739
{
735
740
labelDefaultContrastEnhancementAlgorithm->setText (tr (" No Stretch" ));
736
741
}
737
- if (myDefaultAlgorithm == " STRETCH_TO_MINMAX" )
742
+ if (mDefaultContrastEnhancementAlgorithm == " STRETCH_TO_MINMAX" )
738
743
{
739
744
labelDefaultContrastEnhancementAlgorithm->setText (tr (" Stretch To MinMax" ));
740
745
}
741
- else if (myDefaultAlgorithm == " STRETCH_AND_CLIP_TO_MINMAX" )
746
+ else if (mDefaultContrastEnhancementAlgorithm == " STRETCH_AND_CLIP_TO_MINMAX" )
742
747
{
743
748
labelDefaultContrastEnhancementAlgorithm->setText (tr (" Stretch And Clip To MinMax" ));
744
749
}
745
- else if (myDefaultAlgorithm == " CLIP_TO_MINMAX" )
750
+ else if (mDefaultContrastEnhancementAlgorithm == " CLIP_TO_MINMAX" )
746
751
{
747
752
labelDefaultContrastEnhancementAlgorithm->setText (tr (" Clip To MinMax" ));
748
753
}
@@ -1196,6 +1201,13 @@ void QgsRasterLayerProperties::apply()
1196
1201
}
1197
1202
}
1198
1203
1204
+ QSettings myQSettings;
1205
+ myQSettings.setValue (" /Raster/defaultRedBand" , mDefaultRedBand );
1206
+ myQSettings.setValue (" /Raster/defaultGreenBand" , mDefaultGreenBand );
1207
+ myQSettings.setValue (" /Raster/defaultBlueBand" , mDefaultBlueBand );
1208
+
1209
+ myQSettings.setValue (" /Raster/defaultContrastEnhancementAlgorithm" , mDefaultContrastEnhancementAlgorithm );
1210
+
1199
1211
#ifdef QGISDEBUG
1200
1212
QgsDebugMsg (" QgsRasterLayerProperties::apply processing transparency tab" );
1201
1213
#endif
@@ -1857,29 +1869,6 @@ void QgsRasterLayerProperties::on_pbnHistRefresh_clicked()
1857
1869
std::cout << " QgsRasterLayerProperties::on_pbnHistRefresh_clicked" << std::endl;
1858
1870
#endif
1859
1871
int myBandCountInt = mRasterLayer ->getBandCount ();
1860
- //
1861
- // Find out how many bands are selected and short circuit out clearing the image
1862
- // if needed
1863
- int mySelectionCount=0 ;
1864
- for (int myIteratorInt = 1 ;
1865
- myIteratorInt <= myBandCountInt;
1866
- ++myIteratorInt)
1867
- {
1868
- QgsRasterBandStats myRasterBandStats = mRasterLayer ->getRasterBandStats (myIteratorInt);
1869
- QListWidgetItem *myItem = lstHistogramLabels->item ( myIteratorInt-1 );
1870
- if ( myItem->isSelected () )
1871
- {
1872
- mySelectionCount++;
1873
- }
1874
- }
1875
- if (mySelectionCount==0 )
1876
- {
1877
- int myImageWidth = pixHistogram->width ();
1878
- int myImageHeight = pixHistogram->height ();
1879
- QPixmap myPixmap (myImageWidth,myImageHeight);
1880
- myPixmap.fill (Qt::white);
1881
- pixHistogram->setPixmap (myPixmap);
1882
- }
1883
1872
1884
1873
// Explanation:
1885
1874
// We use the gdal histogram creation routine is called for each selected
@@ -2766,32 +2755,36 @@ void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
2766
2755
}
2767
2756
}
2768
2757
2758
+ void QgsRasterLayerProperties::on_pbtnMakeBandCombinationDefault_clicked ()
2759
+ {
2760
+ mDefaultRedBand = cboRed->currentIndex () + 1 ;
2761
+ mDefaultGreenBand = cboGreen->currentIndex () + 1 ;
2762
+ mDefaultBlueBand = cboBlue->currentIndex () + 1 ;
2763
+ labelDefaultBandCombination->setText (QString (tr (" Default" ) + " R:%1 G:%2 B:%3" ) .arg (mDefaultRedBand ) .arg (mDefaultGreenBand ) .arg (mDefaultBlueBand ));
2764
+ }
2765
+
2769
2766
void QgsRasterLayerProperties::on_pbtnMakeContrastEnhancementAlgorithmDefault_clicked ()
2770
2767
{
2771
- // Like some of the other functionality in the raster properties GUI this deviated a little from the
2772
- // best practice of GUI design as this pressing cancel will not undo setting the default
2773
- // contrast enhancement algorithm
2774
2768
if (cboxContrastEnhancementAlgorithm->currentText () != tr (" User Defined" ))
2775
2769
{
2776
- QSettings myQSettings;
2777
2770
if (cboxContrastEnhancementAlgorithm->currentText () == tr (" No Stretch" ))
2778
2771
{
2779
- myQSettings. setValue ( " /Raster/defaultContrastEnhancementAlgorithm " , " NO_STRETCH" ) ;
2772
+ mDefaultContrastEnhancementAlgorithm = " NO_STRETCH" ;
2780
2773
labelDefaultContrastEnhancementAlgorithm->setText (cboxContrastEnhancementAlgorithm->currentText ());
2781
2774
}
2782
2775
else if (cboxContrastEnhancementAlgorithm->currentText () == tr (" Stretch To MinMax" ))
2783
2776
{
2784
- myQSettings. setValue ( " /Raster/defaultContrastEnhancementAlgorithm " , " STRETCH_TO_MINMAX" ) ;
2777
+ mDefaultContrastEnhancementAlgorithm = " STRETCH_TO_MINMAX" ;
2785
2778
labelDefaultContrastEnhancementAlgorithm->setText (cboxContrastEnhancementAlgorithm->currentText ());
2786
2779
}
2787
2780
else if (cboxContrastEnhancementAlgorithm->currentText () == tr (" Stretch And Clip To MinMax" ))
2788
2781
{
2789
- myQSettings. setValue ( " /Raster/defaultContrastEnhancementAlgorithm " , " STRETCH_AND_CLIP_TO_MINMAX" ) ;
2782
+ mDefaultContrastEnhancementAlgorithm = " STRETCH_AND_CLIP_TO_MINMAX" ;
2790
2783
labelDefaultContrastEnhancementAlgorithm->setText (cboxContrastEnhancementAlgorithm->currentText ());
2791
2784
}
2792
2785
else if (cboxContrastEnhancementAlgorithm->currentText () == tr (" Clip To MinMax" ))
2793
2786
{
2794
- myQSettings. setValue ( " /Raster/defaultContrastEnhancementAlgorithm " , " CLIP_TO_MINMAX" ) ;
2787
+ mDefaultContrastEnhancementAlgorithm = " CLIP_TO_MINMAX" ;
2795
2788
labelDefaultContrastEnhancementAlgorithm->setText (cboxContrastEnhancementAlgorithm->currentText ());
2796
2789
}
2797
2790
else
0 commit comments