@@ -56,7 +56,9 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
5656 TRSTRING_NOT_SET( tr(" Not Set" ))
5757{
5858 ignoreSpinBoxEvent = false ; // Short circuit signal loop between min max field and stdDev spin box
59-
59+ mGrayActualMinimumMaximum = false ;
60+ mRGBActualMinimumMaximum = false ;
61+
6062 if (mRasterLayer ->getDataProvider () == 0 )
6163 {
6264 // This is a GDAL-based layer
@@ -277,16 +279,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
277279 }
278280
279281 cboxTransparencyBand->addItem (TRSTRING_NOT_SET);
280- cboxTransparencyLayer->addItem (TRSTRING_NOT_SET);
281- QMap<QString, QgsMapLayer *> myLayers = QgsMapLayerRegistry::instance ()->mapLayers ();
282- QMap<QString, QgsMapLayer *>::iterator it;
283- for (it = myLayers.begin (); it != myLayers.end (); it++)
284- {
285- if (QgsMapLayer::RASTER == it.value ()->type ())
286- {
287- cboxTransparencyLayer->addItem (it.value ()->name ());
288- }
289- }
290282
291283 QString myThemePath = QgsApplication::themePath ();
292284 QPixmap myPyramidPixmap (myThemePath + " /mIconPyramid.png" );
@@ -438,6 +430,29 @@ void QgsRasterLayerProperties::populateTransparencyTable()
438430 tableTransparency->resizeRowsToContents ();
439431}
440432
433+ /* * Set the message indicating if any min max values are estimates */
434+ void QgsRasterLayerProperties::setMinimumMaximumEstimateWarning ()
435+ {
436+ bool myActualComputedValues = false ;
437+ if (rbtnThreeBand->isChecked ())
438+ {
439+ myActualComputedValues = mRGBActualMinimumMaximum ;
440+ }
441+ else
442+ {
443+ myActualComputedValues = mGrayActualMinimumMaximum ;
444+ }
445+
446+ if (myActualComputedValues)
447+ {
448+ lblMinMaxEstimateWarning->setText (" Note: Minimum Maximum values are actual values computed from the band(s)" );
449+ }
450+ else
451+ {
452+ lblMinMaxEstimateWarning->setText (" Note: Minimum Maximum values are estimates or user defined" );
453+ }
454+ }
455+
441456/* *
442457 @note moved from ctor
443458
@@ -584,24 +599,24 @@ void QgsRasterLayerProperties::sync()
584599 {
585600 if (mRasterLayer ->getColorShadingAlgorithm ()==QgsRasterLayer::PSEUDO_COLOR)
586601 {
587- cboxColorMap->setCurrentText ( tr (" Pseudocolor" ));
602+ cboxColorMap->setCurrentIndex (cboxColorMap-> findText ( tr (" Pseudocolor" ) ));
588603 }
589604 else if (mRasterLayer ->getColorShadingAlgorithm ()==QgsRasterLayer::FREAK_OUT)
590605 {
591- cboxColorMap->setCurrentText ( tr (" Freak Out" ));
606+ cboxColorMap->setCurrentIndex (cboxColorMap-> findText ( tr (" Freak Out" ) ));
592607 }
593608 else if (mRasterLayer ->getColorShadingAlgorithm ()==QgsRasterLayer::COLOR_RAMP)
594609 {
595- cboxColorMap->setCurrentText ( tr (" Custom Colormap" ));
610+ cboxColorMap->setCurrentIndex (cboxColorMap-> findText ( tr (" Custom Colormap" ) ));
596611 }
597612 else if (mRasterLayer ->getColorShadingAlgorithm ()==QgsRasterLayer::USER_DEFINED)
598613 {
599- cboxColorMap->setCurrentText ( tr (" User Defined" ));
614+ cboxColorMap->setCurrentIndex (cboxColorMap-> findText ( tr (" User Defined" ) ));
600615 }
601616 }
602617 else
603618 {
604- cboxColorMap->setCurrentText ( tr (" Grayscale" ));
619+ cboxColorMap->setCurrentIndex (cboxColorMap-> findText ( tr (" Grayscale" ) ));
605620 }
606621
607622 // set whether the layer histogram should be inverted
@@ -615,14 +630,15 @@ void QgsRasterLayerProperties::sync()
615630 }
616631
617632 // set the combos to the correct values
618- cboRed->setCurrentText ( mRasterLayer ->getRedBandName ());
619- cboGreen->setCurrentText ( mRasterLayer ->getGreenBandName ());
620- cboBlue->setCurrentText ( mRasterLayer ->getBlueBandName ());
621- cboGray->setCurrentText ( mRasterLayer ->getGrayBandName ());
633+ cboRed->setCurrentIndex (cboRed-> findText ( mRasterLayer ->getRedBandName () ));
634+ cboGreen->setCurrentIndex (cboGreen-> findText ( mRasterLayer ->getGreenBandName () ));
635+ cboBlue->setCurrentIndex (cboBlue-> findText ( mRasterLayer ->getBlueBandName () ));
636+ cboGray->setCurrentIndex (cboGray-> findText ( mRasterLayer ->getGrayBandName () ));
622637
623638 // set the stdDevs and min max values
624639 if (mRasterLayerIsGdal && rbtnThreeBand->isChecked ())
625640 {
641+ mRGBActualMinimumMaximum = mRasterLayer ->getActualRGBMinMaxFlag ();
626642 if (mRasterLayer ->getUserDefinedRGBMinMax ())
627643 {
628644 sboxThreeBandStdDev->setValue (0.0 );
@@ -656,10 +672,12 @@ void QgsRasterLayerProperties::sync()
656672 leBlueMin->setText (QString::number (mRasterLayer ->getMinimumValue (mRasterLayer ->getBlueBandName ())));
657673 leBlueMax->setText (QString::number (mRasterLayer ->getMaximumValue (mRasterLayer ->getBlueBandName ())));
658674 }
675+ setMinimumMaximumEstimateWarning ();
659676 }
660677 }
661678 else if (mRasterLayerIsGdal )
662679 {
680+ mGrayActualMinimumMaximum = mRasterLayer ->getActualGrayMinMaxFlag ();
663681 if (mRasterLayer ->getUserDefinedGrayMinMax ())
664682 {
665683 sboxSingleBandStdDev->setValue (0.0 );
@@ -684,37 +702,37 @@ void QgsRasterLayerProperties::sync()
684702 leGrayMax->setText (QString::number (mRasterLayer ->getMaximumValue (mRasterLayer ->getGrayBandName ())));
685703 }
686704 }
687-
705+ setMinimumMaximumEstimateWarning ();
688706 }
689707
690708 // set color scaling algorithm
691709 if (QgsContrastEnhancement::STRETCH_TO_MINMAX == mRasterLayer ->getContrastEnhancementAlgorithm ())
692710 {
693- cboxContrastEnhancementAlgorithm->setCurrentText ( tr (" Stretch To MinMax" ));
711+ cboxContrastEnhancementAlgorithm->setCurrentIndex (cboxContrastEnhancementAlgorithm-> findText ( tr (" Stretch To MinMax" ) ));
694712 }
695713 else if (QgsContrastEnhancement::STRETCH_AND_CLIP_TO_MINMAX == mRasterLayer ->getContrastEnhancementAlgorithm ())
696714 {
697- cboxContrastEnhancementAlgorithm->setCurrentText ( tr (" Stretch And Clip To MinMax" ));
715+ cboxContrastEnhancementAlgorithm->setCurrentIndex (cboxContrastEnhancementAlgorithm-> findText ( tr (" Stretch And Clip To MinMax" ) ));
698716 }
699717 else if (QgsContrastEnhancement::CLIP_TO_MINMAX == mRasterLayer ->getContrastEnhancementAlgorithm ())
700718 {
701- cboxContrastEnhancementAlgorithm->setCurrentText ( tr (" Clip To MinMax" ));
719+ cboxContrastEnhancementAlgorithm->setCurrentIndex (cboxContrastEnhancementAlgorithm-> findText ( tr (" Clip To MinMax" ) ));
702720 }
703721 else if (QgsContrastEnhancement::USER_DEFINED == mRasterLayer ->getContrastEnhancementAlgorithm ())
704722 {
705- cboxContrastEnhancementAlgorithm->setCurrentText ( tr (" User Defined" ));
723+ cboxContrastEnhancementAlgorithm->setCurrentIndex (cboxContrastEnhancementAlgorithm-> findText ( tr (" User Defined" ) ));
706724 }
707725 else
708726 {
709- cboxContrastEnhancementAlgorithm->setCurrentText ( tr (" No Scaling " ));
727+ cboxContrastEnhancementAlgorithm->setCurrentIndex (cboxContrastEnhancementAlgorithm-> findText ( tr (" No Stretch " ) ));
710728 }
711729
712730 // Display the current default contrast enhancement algorithm
713731 QSettings myQSettings;
714732 QString myDefaultAlgorithm = myQSettings.value (" /Raster/defaultContrastEnhancementAlgorithm" , " NO_STRETCH" ).toString ();
715733 if (myDefaultAlgorithm == " NO_STRETCH" )
716734 {
717- labelDefaultContrastEnhancementAlgorithm->setText (tr (" No Scaling " ));
735+ labelDefaultContrastEnhancementAlgorithm->setText (tr (" No Stretch " ));
718736 }
719737 if (myDefaultAlgorithm == " STRETCH_TO_MINMAX" )
720738 {
@@ -730,7 +748,7 @@ void QgsRasterLayerProperties::sync()
730748 }
731749 else
732750 {
733- labelDefaultContrastEnhancementAlgorithm->setText (tr (" No Scaling " ));
751+ labelDefaultContrastEnhancementAlgorithm->setText (tr (" No Stretch " ));
734752 }
735753
736754
@@ -746,18 +764,8 @@ void QgsRasterLayerProperties::sync()
746764 sliderTransparency->setValue (255 - mRasterLayer ->getTransparency ());
747765 // update the transparency percentage label
748766 sliderTransparency_valueChanged (255 - mRasterLayer ->getTransparency ());
749-
750- int myIndex = cboxTransparencyLayer->findText (mRasterLayer ->getTransparentLayerName ());
751- if (-1 != myIndex)
752- {
753- cboxTransparencyLayer->setCurrentIndex (myIndex);
754- }
755- else
756- {
757- cboxTransparencyLayer->setCurrentIndex (cboxTransparencyLayer->findText (TRSTRING_NOT_SET));
758- }
759767
760- myIndex = cboxTransparencyBand->findText (mRasterLayer ->getTransparentBandName ());
768+ int myIndex = cboxTransparencyBand->findText (mRasterLayer ->getTransparentBandName ());
761769 if (-1 != myIndex)
762770 {
763771 cboxTransparencyBand->setCurrentIndex (myIndex);
@@ -1085,7 +1093,6 @@ void QgsRasterLayerProperties::apply()
10851093 mRasterLayer ->setBlueBandName (cboBlue->currentText ());
10861094 mRasterLayer ->setGrayBandName (cboGray->currentText ());
10871095 mRasterLayer ->setTransparentBandName (cboxTransparencyBand->currentText ());
1088- mRasterLayer ->setTransparentLayerName (cboxTransparencyLayer->currentText ());
10891096
10901097 // set the appropriate color shading type
10911098 // If USER_DEFINED do nothing, user defined can only be set programatically
@@ -1133,6 +1140,7 @@ void QgsRasterLayerProperties::apply()
11331140 // Set min max based on user defined values if all are set and stdDev is 0.0
11341141 if (rbtnThreeBandMinMax->isEnabled () && rbtnThreeBandMinMax->isChecked () && validUserDefinedMinMax ())
11351142 {
1143+ mRasterLayer ->setActualRGBMinMaxFlag (mRGBActualMinimumMaximum );
11361144 if (mRasterLayer ->getRedBandName () != TRSTRING_NOT_SET)
11371145 {
11381146 mRasterLayer ->setMinimumValue (cboRed->currentText (), leRedMin->text ().toDouble (), false );
@@ -1167,6 +1175,7 @@ void QgsRasterLayerProperties::apply()
11671175 // Set min max based on user defined values if all are set and stdDev is 0.0
11681176 if (rbtnSingleBandMinMax->isEnabled () && rbtnSingleBandMinMax->isChecked () && validUserDefinedMinMax ())
11691177 {
1178+ mRasterLayer ->setActualGrayMinMaxFlag (mGrayActualMinimumMaximum );
11701179 if (mRasterLayer ->getGrayBandName () != TRSTRING_NOT_SET)
11711180 {
11721181 mRasterLayer ->setMinimumValue (cboGray->currentText (), leGrayMin->text ().toDouble (), false );
@@ -1474,7 +1483,6 @@ void QgsRasterLayerProperties::apply()
14741483 // Becuase Min Max values can be set during the redraw if a strech is requested we need to resync after apply
14751484 if (mRasterLayerIsGdal && QgsContrastEnhancement::NO_STRETCH != mRasterLayer ->getContrastEnhancementAlgorithm ())
14761485 {
1477-
14781486 // set the stdDevs and min max values
14791487 if (rbtnThreeBand->isChecked ())
14801488 {
@@ -1485,6 +1493,7 @@ void QgsRasterLayerProperties::apply()
14851493
14861494 if (rbtnThreeBandMinMax->isEnabled ())
14871495 {
1496+ mRGBActualMinimumMaximum = mRasterLayer ->getActualRGBMinMaxFlag ();
14881497 if (mRasterLayer ->getRedBandName () != TRSTRING_NOT_SET)
14891498 {
14901499 leRedMin->setText (QString::number (mRasterLayer ->getMinimumValue (mRasterLayer ->getRedBandName ())));
@@ -1500,6 +1509,7 @@ void QgsRasterLayerProperties::apply()
15001509 leBlueMin->setText (QString::number (mRasterLayer ->getMinimumValue (mRasterLayer ->getBlueBandName ())));
15011510 leBlueMax->setText (QString::number (mRasterLayer ->getMaximumValue (mRasterLayer ->getBlueBandName ())));
15021511 }
1512+ setMinimumMaximumEstimateWarning ();
15031513 }
15041514 }
15051515 else
@@ -1511,11 +1521,13 @@ void QgsRasterLayerProperties::apply()
15111521
15121522 if (rbtnSingleBandMinMax->isEnabled ())
15131523 {
1524+ mGrayActualMinimumMaximum = mRasterLayer ->getActualGrayMinMaxFlag ();
15141525 if (mRasterLayer ->getGrayBandName () != TRSTRING_NOT_SET)
15151526 {
15161527 leGrayMin->setText (QString::number (mRasterLayer ->getMinimumValue (mRasterLayer ->getGrayBandName ())));
15171528 leGrayMax->setText (QString::number (mRasterLayer ->getMaximumValue (mRasterLayer ->getGrayBandName ())));
15181529 }
1530+ setMinimumMaximumEstimateWarning ();
15191531 }
15201532 }
15211533 }
@@ -1741,35 +1753,6 @@ void QgsRasterLayerProperties::on_cboxColorMap_currentIndexChanged(const QString
17411753 }
17421754}
17431755
1744- void QgsRasterLayerProperties::on_cboxTransparencyLayer_currentIndexChanged (const QString& theText)
1745- {
1746- if (theText == TRSTRING_NOT_SET)
1747- {
1748- cboxTransparencyBand->clear ();
1749- cboxTransparencyBand->addItem (TRSTRING_NOT_SET);
1750- }
1751- else
1752- {
1753- QMap<QString, QgsMapLayer *> myLayers = QgsMapLayerRegistry::instance ()->mapLayers ();
1754- QMap<QString, QgsMapLayer *>::iterator it;
1755- for (it = myLayers.begin (); it != myLayers.end (); it++)
1756- {
1757- if (theText == it.value ()->name () && QgsMapLayer::RASTER == it.value ()->type ())
1758- {
1759- QgsRasterLayer* myRasterLayer = (QgsRasterLayer*)it.value ();
1760- int myBandCount = myRasterLayer->getBandCount ();
1761- cboxTransparencyBand->clear ();
1762- cboxTransparencyBand->addItem (TRSTRING_NOT_SET);
1763- for (int bandRunner = 1 ; bandRunner <= myBandCount; bandRunner++)
1764- {
1765- cboxTransparencyBand->addItem (myRasterLayer->getRasterBandName (bandRunner));
1766- }
1767- break ;
1768- }
1769- }
1770- }
1771- }
1772-
17731756void QgsRasterLayerProperties::on_pbnDefaultValues_clicked ()
17741757{
17751758
@@ -2512,7 +2495,7 @@ void QgsRasterLayerProperties::on_rbtnThreeBand_toggled(bool theState)
25122495 mRasterLayer ->getRasterLayerType () == QgsRasterLayer::PALETTE)
25132496 {
25142497 pbtnLoadMinMax->setEnabled (false );
2515- cboxContrastEnhancementAlgorithm->setCurrentText ( tr (" No Stretch" ));
2498+ cboxContrastEnhancementAlgorithm->setCurrentIndex (cboxContrastEnhancementAlgorithm-> findText ( tr (" No Stretch" ) ));
25162499 cboxContrastEnhancementAlgorithm->setEnabled (false );
25172500 labelContrastEnhancement->setEnabled (false );
25182501 sboxThreeBandStdDev->setEnabled (false );
@@ -2614,6 +2597,7 @@ void QgsRasterLayerProperties::userDefinedMinMax_textEdited(QString theString)
26142597 ignoreSpinBoxEvent = true ;
26152598 sboxThreeBandStdDev->setValue (0.0 );
26162599 }
2600+ mRGBActualMinimumMaximum = false ;
26172601 }
26182602 else
26192603 {
@@ -2622,7 +2606,9 @@ void QgsRasterLayerProperties::userDefinedMinMax_textEdited(QString theString)
26222606 ignoreSpinBoxEvent = true ;
26232607 sboxSingleBandStdDev->setValue (0.0 );
26242608 }
2609+ mGrayActualMinimumMaximum = false ;
26252610 }
2611+ setMinimumMaximumEstimateWarning ();
26262612}
26272613
26282614void QgsRasterLayerProperties::on_mClassifyButton_clicked ()
@@ -2737,6 +2723,7 @@ void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
27372723 myRasterBandStats = mRasterLayer ->getRasterBandStats (mRasterLayer ->getRasterBandNumber (cboBlue->currentText ()));
27382724 leBlueMin->setText (QString::number (myRasterBandStats.minVal ));
27392725 leBlueMax->setText (QString::number (myRasterBandStats.maxVal ));
2726+ mRGBActualMinimumMaximum = true ;
27402727 }
27412728 else
27422729 {
@@ -2751,6 +2738,7 @@ void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
27512738 mRasterLayer ->computeMinimumMaximumEstimates (mRasterLayer ->getRasterBandNumber (cboBlue->currentText ()), myMinimumMaximum);
27522739 leBlueMin->setText (QString::number (myMinimumMaximum[0 ]));
27532740 leBlueMax->setText (QString::number (myMinimumMaximum[1 ]));
2741+ mRGBActualMinimumMaximum = false ;
27542742 }
27552743
27562744 }
@@ -2762,6 +2750,7 @@ void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
27622750 myRasterBandStats = mRasterLayer ->getRasterBandStats (mRasterLayer ->getRasterBandNumber (cboGray->currentText ()));
27632751 leGrayMin->setText (QString::number (myRasterBandStats.minVal ));
27642752 leGrayMax->setText (QString::number (myRasterBandStats.maxVal ));
2753+ mGrayActualMinimumMaximum = true ;
27652754 }
27662755 else
27672756 {
@@ -2770,8 +2759,10 @@ void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
27702759 mRasterLayer ->computeMinimumMaximumEstimates (mRasterLayer ->getRasterBandNumber (cboGray->currentText ()), myMinimumMaximum);
27712760 leGrayMin->setText (QString::number (myMinimumMaximum[0 ]));
27722761 leGrayMax->setText (QString::number (myMinimumMaximum[1 ]));
2762+ mGrayActualMinimumMaximum = false ;
27732763 }
27742764 }
2765+ setMinimumMaximumEstimateWarning ();
27752766 }
27762767}
27772768
0 commit comments