|
42 | 42 | #include <QPolygonF> |
43 | 43 | #include <QColorDialog> |
44 | 44 | #include <QList> |
45 | | - |
| 45 | +#include <QSettings> |
46 | 46 |
|
47 | 47 | #include <iostream> |
48 | 48 |
|
@@ -298,6 +298,7 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) ) |
298 | 298 | pbnDefaultValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionCopySelected.png"))); |
299 | 299 | pbnImportTransparentPixelValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileOpen.png"))); |
300 | 300 | pbnExportTransparentPixelValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileSave.png"))); |
| 301 | + pbtnMakeContrastEnhancementAlgorithmDefault->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileSave.png"))); |
301 | 302 |
|
302 | 303 | // Only do pyramids if dealing directly with GDAL. |
303 | 304 | if (mRasterLayerIsGdal) |
@@ -613,11 +614,6 @@ void QgsRasterLayerProperties::sync() |
613 | 614 | cboxInvertColorMap->setChecked(false); |
614 | 615 | } |
615 | 616 |
|
616 | | - //set the transparency slider |
617 | | - sliderTransparency->setValue(255 - mRasterLayer->getTransparency()); |
618 | | - //update the transparency percentage label |
619 | | - sliderTransparency_valueChanged(255 - mRasterLayer->getTransparency()); |
620 | | - |
621 | 617 | //set the combos to the correct values |
622 | 618 | cboRed->setCurrentText(mRasterLayer->getRedBandName()); |
623 | 619 | cboGreen->setCurrentText(mRasterLayer->getGreenBandName()); |
@@ -712,13 +708,45 @@ void QgsRasterLayerProperties::sync() |
712 | 708 | { |
713 | 709 | cboxContrastEnhancementAlgorithm->setCurrentText(tr("No Scaling")); |
714 | 710 | } |
| 711 | + |
| 712 | + //Display the current default contrast enhancement algorithm |
| 713 | + QSettings myQSettings; |
| 714 | + QString myDefaultAlgorithm = myQSettings.value("/Raster/defaultContrastEnhancementAlgorithm", "NO_STRETCH").toString(); |
| 715 | + if(myDefaultAlgorithm == "NO_STRETCH") |
| 716 | + { |
| 717 | + labelDefaultContrastEnhancementAlgorithm->setText(tr("No Scaling")); |
| 718 | + } |
| 719 | + if(myDefaultAlgorithm == "STRETCH_TO_MINMAX") |
| 720 | + { |
| 721 | + labelDefaultContrastEnhancementAlgorithm->setText(tr("Stretch To MinMax")); |
| 722 | + } |
| 723 | + else if(myDefaultAlgorithm == "STRETCH_AND_CLIP_TO_MINMAX") |
| 724 | + { |
| 725 | + labelDefaultContrastEnhancementAlgorithm->setText(tr("Stretch And Clip To MinMax")); |
| 726 | + } |
| 727 | + else if(myDefaultAlgorithm == "CLIP_TO_MINMAX") |
| 728 | + { |
| 729 | + labelDefaultContrastEnhancementAlgorithm->setText(tr("Clip To MinMax")); |
| 730 | + } |
| 731 | + else |
| 732 | + { |
| 733 | + labelDefaultContrastEnhancementAlgorithm->setText(tr("No Scaling")); |
| 734 | + } |
| 735 | + |
| 736 | + |
715 | 737 |
|
716 | 738 | #ifdef QGISDEBUG |
717 | 739 | QgsDebugMsg("QgsRasterLayerProperties::sync populate transparency tab"); |
718 | 740 | #endif |
719 | 741 | /* |
720 | 742 | * Transparent Pixel Tab |
721 | 743 | */ |
| 744 | + |
| 745 | + //set the transparency slider |
| 746 | + sliderTransparency->setValue(255 - mRasterLayer->getTransparency()); |
| 747 | + //update the transparency percentage label |
| 748 | + sliderTransparency_valueChanged(255 - mRasterLayer->getTransparency()); |
| 749 | + |
722 | 750 | int myIndex = cboxTransparencyLayer->findText(mRasterLayer->getTransparentLayerName()); |
723 | 751 | if(-1 != myIndex) |
724 | 752 | { |
@@ -2697,22 +2725,87 @@ void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked() |
2697 | 2725 | if(rbtnThreeBand->isChecked()) |
2698 | 2726 | { |
2699 | 2727 | rbtnThreeBandMinMax->setChecked(true); |
2700 | | - myRasterBandStats = mRasterLayer->getRasterBandStats(mRasterLayer->getRasterBandNumber(cboRed->currentText())); |
2701 | | - leRedMin->setText(QString::number(myRasterBandStats.minVal)); |
2702 | | - leRedMax->setText(QString::number(myRasterBandStats.maxVal)); |
2703 | | - myRasterBandStats = mRasterLayer->getRasterBandStats(mRasterLayer->getRasterBandNumber(cboGreen->currentText())); |
2704 | | - leGreenMin->setText(QString::number(myRasterBandStats.minVal)); |
2705 | | - leGreenMax->setText(QString::number(myRasterBandStats.maxVal)); |
2706 | | - myRasterBandStats = mRasterLayer->getRasterBandStats(mRasterLayer->getRasterBandNumber(cboBlue->currentText())); |
2707 | | - leBlueMin->setText(QString::number(myRasterBandStats.minVal)); |
2708 | | - leBlueMax->setText(QString::number(myRasterBandStats.maxVal)); |
| 2728 | + |
| 2729 | + if(rbtnActualMinMax->isChecked()) |
| 2730 | + { |
| 2731 | + myRasterBandStats = mRasterLayer->getRasterBandStats(mRasterLayer->getRasterBandNumber(cboRed->currentText())); |
| 2732 | + leRedMin->setText(QString::number(myRasterBandStats.minVal)); |
| 2733 | + leRedMax->setText(QString::number(myRasterBandStats.maxVal)); |
| 2734 | + myRasterBandStats = mRasterLayer->getRasterBandStats(mRasterLayer->getRasterBandNumber(cboGreen->currentText())); |
| 2735 | + leGreenMin->setText(QString::number(myRasterBandStats.minVal)); |
| 2736 | + leGreenMax->setText(QString::number(myRasterBandStats.maxVal)); |
| 2737 | + myRasterBandStats = mRasterLayer->getRasterBandStats(mRasterLayer->getRasterBandNumber(cboBlue->currentText())); |
| 2738 | + leBlueMin->setText(QString::number(myRasterBandStats.minVal)); |
| 2739 | + leBlueMax->setText(QString::number(myRasterBandStats.maxVal)); |
| 2740 | + } |
| 2741 | + else |
| 2742 | + { |
| 2743 | + rbtnEstimateMinMax->setChecked(true); |
| 2744 | + double myMinimumMaximum[2]; |
| 2745 | + mRasterLayer->computeMinimumMaximumEstimates(mRasterLayer->getRasterBandNumber(cboRed->currentText()), myMinimumMaximum); |
| 2746 | + leRedMin->setText(QString::number(myMinimumMaximum[0])); |
| 2747 | + leRedMax->setText(QString::number(myMinimumMaximum[1])); |
| 2748 | + mRasterLayer->computeMinimumMaximumEstimates(mRasterLayer->getRasterBandNumber(cboGreen->currentText()), myMinimumMaximum); |
| 2749 | + leGreenMin->setText(QString::number(myMinimumMaximum[0])); |
| 2750 | + leGreenMax->setText(QString::number(myMinimumMaximum[1])); |
| 2751 | + mRasterLayer->computeMinimumMaximumEstimates(mRasterLayer->getRasterBandNumber(cboBlue->currentText()), myMinimumMaximum); |
| 2752 | + leBlueMin->setText(QString::number(myMinimumMaximum[0])); |
| 2753 | + leBlueMax->setText(QString::number(myMinimumMaximum[1])); |
| 2754 | + } |
| 2755 | + |
2709 | 2756 | } |
2710 | 2757 | else |
2711 | 2758 | { |
2712 | 2759 | rbtnSingleBandMinMax->setChecked(true); |
2713 | | - myRasterBandStats = mRasterLayer->getRasterBandStats(mRasterLayer->getRasterBandNumber(cboGray->currentText())); |
2714 | | - leGrayMin->setText(QString::number(myRasterBandStats.minVal)); |
2715 | | - leGrayMax->setText(QString::number(myRasterBandStats.maxVal)); |
| 2760 | + if(rbtnActualMinMax->isChecked()) |
| 2761 | + { |
| 2762 | + myRasterBandStats = mRasterLayer->getRasterBandStats(mRasterLayer->getRasterBandNumber(cboGray->currentText())); |
| 2763 | + leGrayMin->setText(QString::number(myRasterBandStats.minVal)); |
| 2764 | + leGrayMax->setText(QString::number(myRasterBandStats.maxVal)); |
| 2765 | + } |
| 2766 | + else |
| 2767 | + { |
| 2768 | + rbtnEstimateMinMax->setChecked(true); |
| 2769 | + double myMinimumMaximum[2]; |
| 2770 | + mRasterLayer->computeMinimumMaximumEstimates(mRasterLayer->getRasterBandNumber(cboGray->currentText()), myMinimumMaximum); |
| 2771 | + leGrayMin->setText(QString::number(myMinimumMaximum[0])); |
| 2772 | + leGrayMax->setText(QString::number(myMinimumMaximum[1])); |
| 2773 | + } |
| 2774 | + } |
| 2775 | + } |
| 2776 | +} |
| 2777 | + |
| 2778 | +void QgsRasterLayerProperties::on_pbtnMakeContrastEnhancementAlgorithmDefault_clicked() |
| 2779 | +{ |
| 2780 | + //Like some of the other functionality in the raster properties GUI this deviated a little from the |
| 2781 | + //best practice of GUI design as this pressing cancel will not undo setting the default |
| 2782 | + //contrast enhancement algorithm |
| 2783 | + if(cboxContrastEnhancementAlgorithm->currentText() != tr("User Defined")) |
| 2784 | + { |
| 2785 | + QSettings myQSettings; |
| 2786 | + if(cboxContrastEnhancementAlgorithm->currentText() == tr("No Stretch")) |
| 2787 | + { |
| 2788 | + myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "NO_STRETCH"); |
| 2789 | + labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText()); |
| 2790 | + } |
| 2791 | + else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Stretch To MinMax")) |
| 2792 | + { |
| 2793 | + myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "STRETCH_TO_MINMAX"); |
| 2794 | + labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText()); |
| 2795 | + } |
| 2796 | + else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Stretch And Clip To MinMax")) |
| 2797 | + { |
| 2798 | + myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "STRETCH_AND_CLIP_TO_MINMAX"); |
| 2799 | + labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText()); |
| 2800 | + } |
| 2801 | + else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Clip To MinMax")) |
| 2802 | + { |
| 2803 | + myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "CLIP_TO_MINMAX"); |
| 2804 | + labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText()); |
| 2805 | + } |
| 2806 | + else |
| 2807 | + { |
| 2808 | + //do nothing |
2716 | 2809 | } |
2717 | 2810 | } |
2718 | 2811 | } |
|
0 commit comments