@@ -52,7 +52,36 @@ QgsSingleBandPseudoColorRendererWidget::QgsSingleBandPseudoColorRendererWidget(
52
52
QgsSingleBandPseudoColorRenderer* r = dynamic_cast <QgsSingleBandPseudoColorRenderer*>( layer->renderer () );
53
53
if ( r )
54
54
{
55
- // todo...
55
+ QgsRasterShader* rasterShader = r->shader ();
56
+ if ( rasterShader )
57
+ {
58
+ QgsColorRampShader* colorRampShader = dynamic_cast <QgsColorRampShader*>( rasterShader->rasterShaderFunction () );
59
+ if ( colorRampShader )
60
+ {
61
+ if ( colorRampShader->colorRampType () == QgsColorRampShader::INTERPOLATED )
62
+ {
63
+ mColorInterpolationComboBox ->setCurrentIndex ( mColorInterpolationComboBox ->findText ( tr ( " Linear" ) ) );
64
+ }
65
+ else if ( colorRampShader->colorRampType () == QgsColorRampShader::DISCRETE )
66
+ {
67
+ mColorInterpolationComboBox ->setCurrentIndex ( mColorInterpolationComboBox ->findText ( tr ( " Discrete" ) ) );
68
+ }
69
+ else
70
+ {
71
+ mColorInterpolationComboBox ->setCurrentIndex ( mColorInterpolationComboBox ->findText ( tr ( " Exact" ) ) );
72
+ }
73
+
74
+ const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->colorRampItemList ();
75
+ QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin ();
76
+ for ( ; it != colorRampItemList.end (); ++it )
77
+ {
78
+ QTreeWidgetItem* newItem = new QTreeWidgetItem ( mColormapTreeWidget );
79
+ newItem->setText ( 0 , QString::number ( it->value , ' f' ) );
80
+ newItem->setBackground ( 1 , QBrush ( it->color ) );
81
+ newItem->setText ( 2 , it->label );
82
+ }
83
+ }
84
+ }
56
85
}
57
86
}
58
87
@@ -107,7 +136,7 @@ QgsRasterRenderer* QgsSingleBandPseudoColorRendererWidget::renderer()
107
136
void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked ()
108
137
{
109
138
int bandComboIndex = mBandComboBox ->currentIndex ();
110
- if ( bandComboIndex == -1 )
139
+ if ( bandComboIndex == -1 || ! mRasterLayer )
111
140
{
112
141
return ;
113
142
}
0 commit comments