@@ -71,8 +71,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
71
71
mGrayMinimumMaximumEstimated = true ;
72
72
mRGBMinimumMaximumEstimated = true ;
73
73
74
- mRasterLayerIsInternal = mRasterLayer ->dataProvider () == 0 ;
75
-
76
74
setupUi ( this );
77
75
connect ( buttonBox, SIGNAL ( accepted () ), this , SLOT ( accept () ) );
78
76
connect ( this , SIGNAL ( accepted () ), this , SLOT ( apply () ) );
@@ -218,7 +216,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
218
216
219
217
220
218
// Only do pyramids if dealing directly with GDAL.
221
- if ( mRasterLayerIsInternal )
219
+ if ( mRasterLayer -> dataProvider ()-> capabilities () & QgsRasterDataProvider::BuildPyramids )
222
220
{
223
221
QgsRasterLayer::RasterPyramidList myPyramidList = mRasterLayer ->buildPyramidList ();
224
222
QgsRasterLayer::RasterPyramidList::iterator myRasterPyramidIterator;
@@ -518,19 +516,25 @@ void QgsRasterLayerProperties::sync()
518
516
break ;
519
517
}
520
518
521
- if ( ! mRasterLayerIsInternal )
519
+ if ( mRasterLayer -> dataProvider ()-> dataType ( 1 ) == QgsRasterDataProvider::ARGBDataType )
522
520
{
523
521
delete tabPageSymbology;
524
522
delete tabPageColormap;
525
- delete tabPagePyramids;
526
- delete tabPageHistogram;
527
-
528
523
gboxNoDataValue->setEnabled ( false );
529
524
gboxCustomTransparency->setEnabled ( false );
530
-
531
525
tabBar->setCurrentWidget ( tabPageMetadata );
532
526
}
533
527
528
+ if ( ! ( mRasterLayer ->dataProvider ()->capabilities () & QgsRasterDataProvider::BuildPyramids ) )
529
+ {
530
+ delete tabPagePyramids;
531
+ }
532
+
533
+ if ( ! ( mRasterLayer ->dataProvider ()->capabilities () & QgsRasterDataProvider::Histogram ) )
534
+ {
535
+ delete tabPageHistogram;
536
+ }
537
+
534
538
#if 0
535
539
if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
536
540
{
@@ -558,35 +562,38 @@ void QgsRasterLayerProperties::sync()
558
562
//
559
563
// Populate the various controls on the form
560
564
//
561
- QgsDebugMsg ( " colorShadingAlgorithm = " + QString::number ( mRasterLayer ->colorShadingAlgorithm () ) );
562
- if ( mRasterLayer ->drawingStyle () == QgsRasterLayer::SingleBandPseudoColor ||
563
- mRasterLayer ->drawingStyle () == QgsRasterLayer::PalettedColor ||
564
- mRasterLayer ->drawingStyle () == QgsRasterLayer::PalettedSingleBandPseudoColor ||
565
- mRasterLayer ->drawingStyle () == QgsRasterLayer::MultiBandSingleBandPseudoColor )
566
- {
567
- if ( mRasterLayer ->colorShadingAlgorithm () == QgsRasterLayer::PseudoColorShader )
568
- {
569
- cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " Pseudocolor" ) ) );
570
- }
571
- else if ( mRasterLayer ->colorShadingAlgorithm () == QgsRasterLayer::FreakOutShader )
572
- {
573
- cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " Freak Out" ) ) );
574
- }
575
- else if ( mRasterLayer ->colorShadingAlgorithm () == QgsRasterLayer::ColorRampShader )
576
- {
577
- cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " Colormap" ) ) );
565
+ if ( mRasterLayer ->dataProvider ()->dataType (1 ) != QgsRasterDataProvider::ARGBDataType )
566
+ {
567
+ QgsDebugMsg ( " colorShadingAlgorithm = " + QString::number ( mRasterLayer ->colorShadingAlgorithm () ) );
568
+ if ( mRasterLayer ->drawingStyle () == QgsRasterLayer::SingleBandPseudoColor ||
569
+ mRasterLayer ->drawingStyle () == QgsRasterLayer::PalettedColor ||
570
+ mRasterLayer ->drawingStyle () == QgsRasterLayer::PalettedSingleBandPseudoColor ||
571
+ mRasterLayer ->drawingStyle () == QgsRasterLayer::MultiBandSingleBandPseudoColor )
572
+ {
573
+ if ( mRasterLayer ->colorShadingAlgorithm () == QgsRasterLayer::PseudoColorShader )
574
+ {
575
+ cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " Pseudocolor" ) ) );
576
+ }
577
+ else if ( mRasterLayer ->colorShadingAlgorithm () == QgsRasterLayer::FreakOutShader )
578
+ {
579
+ cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " Freak Out" ) ) );
580
+ }
581
+ else if ( mRasterLayer ->colorShadingAlgorithm () == QgsRasterLayer::ColorRampShader )
582
+ {
583
+ cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " Colormap" ) ) );
584
+ }
585
+ else if ( mRasterLayer ->colorShadingAlgorithm () == QgsRasterLayer::UserDefinedShader )
586
+ {
587
+ cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " User Defined" ) ) );
588
+ }
578
589
}
579
- else if ( mRasterLayer -> colorShadingAlgorithm () == QgsRasterLayer::UserDefinedShader )
590
+ else
580
591
{
581
- cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " User Defined " ) ) );
592
+ cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " Grayscale " ) ) );
582
593
}
583
594
}
584
- else if ( mRasterLayerIsInternal )
585
- {
586
- cboxColorMap->setCurrentIndex ( cboxColorMap->findText ( tr ( " Grayscale" ) ) );
587
- }
588
595
589
- if ( mRasterLayerIsInternal )
596
+ if ( mRasterLayer -> dataProvider ()-> dataType ( 1 ) != QgsRasterDataProvider::ARGBDataType )
590
597
{
591
598
if ( rbtnThreeBand->isChecked () )
592
599
{
@@ -774,10 +781,24 @@ void QgsRasterLayerProperties::sync()
774
781
leDisplayName->setText ( mRasterLayer ->name () );
775
782
776
783
// display the raster dimensions and no data value
777
- if ( mRasterLayerIsInternal )
778
- {
784
+ if ( mRasterLayer -> dataProvider ()-> capabilities () & QgsRasterDataProvider:: Size )
785
+ {
779
786
lblColumns->setText ( tr ( " Columns: %1" ).arg ( mRasterLayer ->width () ) );
780
787
lblRows->setText ( tr ( " Rows: %1" ).arg ( mRasterLayer ->height () ) );
788
+ }
789
+ else
790
+ {
791
+ // TODO: Account for fixedWidth and fixedHeight WMS layers
792
+ lblColumns->setText ( tr ( " Columns: " ) + tr ( " n/a" ) );
793
+ lblRows->setText ( tr ( " Rows: " ) + tr ( " n/a" ) );
794
+ }
795
+
796
+ if ( mRasterLayer ->dataProvider ()->dataType (1 ) == QgsRasterDataProvider::ARGBDataType )
797
+ {
798
+ lblNoData->setText ( tr ( " No-Data Value: " ) + tr ( " n/a" ) );
799
+ }
800
+ else
801
+ {
781
802
if ( mRasterLayer ->isNoDataValueValid () )
782
803
{
783
804
lblNoData->setText ( tr ( " No-Data Value: %1" ).arg ( mRasterLayer ->noDataValue () ) );
@@ -787,13 +808,6 @@ void QgsRasterLayerProperties::sync()
787
808
lblNoData->setText ( tr ( " No-Data Value: Not Set" ) );
788
809
}
789
810
}
790
- else
791
- {
792
- // TODO: Account for fixedWidth and fixedHeight WMS layers
793
- lblColumns->setText ( tr ( " Columns: " ) + tr ( " n/a" ) );
794
- lblRows->setText ( tr ( " Rows: " ) + tr ( " n/a" ) );
795
- lblNoData->setText ( tr ( " No-Data Value: " ) + tr ( " n/a" ) );
796
- }
797
811
798
812
// get the thumbnail for the layer
799
813
QPixmap myQPixmap = QPixmap ( pixmapThumbnail->width (), pixmapThumbnail->height () );
@@ -824,12 +838,12 @@ void QgsRasterLayerProperties::sync()
824
838
void QgsRasterLayerProperties::syncColormapTab ()
825
839
{
826
840
QgsDebugMsg ( " populate color ramp tab" );
827
- if ( !mRasterLayerIsInternal )
841
+ if ( !mRasterLayer || ! mRasterLayer -> dataProvider () )
828
842
{
829
843
return ;
830
844
}
831
845
832
- if ( ! mRasterLayer )
846
+ if ( mRasterLayer -> dataProvider ()-> dataType ( 1 ) == QgsRasterDataProvider::ARGBDataType )
833
847
{
834
848
return ;
835
849
}
@@ -921,7 +935,7 @@ bool QgsRasterLayerProperties::validUserDefinedMinMax()
921
935
*/
922
936
void QgsRasterLayerProperties::apply ()
923
937
{
924
- if ( mRasterLayerIsInternal )
938
+ if ( mRasterLayer -> dataProvider ()-> dataType ( 1 ) != QgsRasterDataProvider::ARGBDataType )
925
939
{
926
940
QgsDebugMsg ( " apply processing symbology tab" );
927
941
/*
@@ -1411,7 +1425,7 @@ void QgsRasterLayerProperties::apply()
1411
1425
mRasterLayer ->triggerRepaint ();
1412
1426
1413
1427
// Because Min Max values can be set during the redraw if a strech is requested we need to resync after apply
1414
- if ( mRasterLayerIsInternal )
1428
+ if ( mRasterLayer -> dataProvider ()-> dataType ( 1 ) != QgsRasterDataProvider::ARGBDataType )
1415
1429
{
1416
1430
if ( QgsContrastEnhancement::NoEnhancement != mRasterLayer ->contrastEnhancementAlgorithm () )
1417
1431
{
@@ -1581,7 +1595,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
1581
1595
1582
1596
void QgsRasterLayerProperties::on_cboBlue_currentIndexChanged ( const QString& theText )
1583
1597
{
1584
- if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
1598
+ if ( TRSTRING_NOT_SET != theText )
1585
1599
{
1586
1600
leBlueMin->setText ( QString::number ( mRasterLayer ->minimumValue ( theText ) ) );
1587
1601
leBlueMax->setText ( QString::number ( mRasterLayer ->maximumValue ( theText ) ) );
@@ -1590,7 +1604,7 @@ void QgsRasterLayerProperties::on_cboBlue_currentIndexChanged( const QString& th
1590
1604
1591
1605
void QgsRasterLayerProperties::on_cboGray_currentIndexChanged ( const QString& theText )
1592
1606
{
1593
- if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
1607
+ if ( TRSTRING_NOT_SET != theText )
1594
1608
{
1595
1609
leGrayMin->setText ( QString::number ( mRasterLayer ->minimumValue ( theText ) ) );
1596
1610
leGrayMax->setText ( QString::number ( mRasterLayer ->maximumValue ( theText ) ) );
@@ -1599,7 +1613,7 @@ void QgsRasterLayerProperties::on_cboGray_currentIndexChanged( const QString& th
1599
1613
1600
1614
void QgsRasterLayerProperties::on_cboGreen_currentIndexChanged ( const QString& theText )
1601
1615
{
1602
- if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
1616
+ if ( TRSTRING_NOT_SET != theText )
1603
1617
{
1604
1618
leGreenMin->setText ( QString::number ( mRasterLayer ->minimumValue ( theText ) ) );
1605
1619
leGreenMax->setText ( QString::number ( mRasterLayer ->maximumValue ( theText ) ) );
@@ -1608,7 +1622,7 @@ void QgsRasterLayerProperties::on_cboGreen_currentIndexChanged( const QString& t
1608
1622
1609
1623
void QgsRasterLayerProperties::on_cboRed_currentIndexChanged ( const QString& theText )
1610
1624
{
1611
- if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
1625
+ if ( TRSTRING_NOT_SET != theText )
1612
1626
{
1613
1627
leRedMin->setText ( QString::number ( mRasterLayer ->minimumValue ( theText ) ) );
1614
1628
leRedMax->setText ( QString::number ( mRasterLayer ->maximumValue ( theText ) ) );
@@ -1654,8 +1668,10 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
1654
1668
1655
1669
void QgsRasterLayerProperties::on_cboxColorMap_currentIndexChanged ( const QString& theText )
1656
1670
{
1657
- if ( !mRasterLayerIsInternal )
1671
+ if ( mRasterLayer ->dataProvider ()->dataType (1 ) == QgsRasterDataProvider::ARGBDataType )
1672
+ {
1658
1673
return ;
1674
+ }
1659
1675
1660
1676
if ( theText == tr ( " Pseudocolor" ) || theText == tr ( " Freak Out" ) )
1661
1677
{
@@ -2570,10 +2586,9 @@ void QgsRasterLayerProperties::on_pbtnLoadColorMapFromFile_clicked()
2570
2586
2571
2587
void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked ()
2572
2588
{
2573
- if ( mRasterLayerIsInternal &&
2574
- ( mRasterLayer ->drawingStyle () == QgsRasterLayer::SingleBandGray
2589
+ if ( mRasterLayer ->drawingStyle () == QgsRasterLayer::SingleBandGray
2575
2590
|| mRasterLayer ->drawingStyle () == QgsRasterLayer::MultiBandSingleBandGray
2576
- || mRasterLayer ->drawingStyle () == QgsRasterLayer::MultiBandColor ) )
2591
+ || mRasterLayer ->drawingStyle () == QgsRasterLayer::MultiBandColor )
2577
2592
{
2578
2593
QgsRasterBandStats myRasterBandStats;
2579
2594
double myMinimumMaximum[2 ];
@@ -2994,16 +3009,13 @@ void QgsPixelSelectorTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
2994
3009
void QgsRasterLayerProperties::on_btnResetNull_clicked ( )
2995
3010
{
2996
3011
// If reset NoDataValue is checked do this first, will ignore what ever is in the LineEdit
2997
- if ( mRasterLayerIsInternal )
3012
+ mRasterLayer ->resetNoDataValue ();
3013
+ if ( mRasterLayer ->isNoDataValueValid () )
2998
3014
{
2999
- mRasterLayer ->resetNoDataValue ();
3000
- if ( mRasterLayer ->isNoDataValueValid () )
3001
- {
3002
- leNoDataValue->setText ( QString::number ( mRasterLayer ->noDataValue (), ' f' ) );
3003
- }
3004
- else
3005
- {
3006
- leNoDataValue->clear ();
3007
- }
3015
+ leNoDataValue->setText ( QString::number ( mRasterLayer ->noDataValue (), ' f' ) );
3016
+ }
3017
+ else
3018
+ {
3019
+ leNoDataValue->clear ();
3008
3020
}
3009
3021
}
0 commit comments