35 #include <QPushButton>
36 #include <QInputDialog>
37 #include <QFileDialog>
39 #include <QMessageBox>
40 #include <QTextStream>
51 mColorRampShaderWidget->initializeForUseWithRasterLayer();
53 connect( mMinLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged );
54 connect( mMaxLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged );
55 connect( mMinLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited );
56 connect( mMaxLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited );
70 mMinLineEdit->setValidator(
new QDoubleValidator( mMinLineEdit ) );
71 mMaxLineEdit->setValidator(
new QDoubleValidator( mMaxLineEdit ) );
77 QHBoxLayout *layout =
new QHBoxLayout();
78 layout->setContentsMargins( 0, 0, 0, 0 );
79 mMinMaxContainerWidget->setLayout( layout );
80 layout->addWidget( mMinMaxWidget );
82 mColorRampShaderWidget->setRasterDataProvider( provider );
91 if ( mMinLineEdit->text().isEmpty() || mMaxLineEdit->text().isEmpty() )
102 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
113 mColorRampShaderWidget->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
114 mColorRampShaderWidget->setExtent( mMinMaxWidget->
extent() );
119 int bandNumber = mBandComboBox->currentBand();
121 renderer->setClassificationMin( lineEditValue( mMinLineEdit ) );
122 renderer->setClassificationMax( lineEditValue( mMaxLineEdit ) );
136 return mBandComboBox->currentBand();
143 mColorRampShaderWidget->setExtent( mMinMaxWidget->
extent() );
152 mMinMaxWidget->
setBands( QList< int >() << pr->
band() );
153 mColorRampShaderWidget->setRasterBand( pr->
band() );
159 if ( colorRampShader )
161 mColorRampShaderWidget->setFromShader( *colorRampShader );
171 mMinMaxWidget->
setBands( QList< int >() << mBandComboBox->currentBand() );
175 void QgsSingleBandPseudoColorRendererWidget::bandChanged()
178 bands.append( mBandComboBox->currentBand() );
180 mColorRampShaderWidget->setRasterBand( mBandComboBox->currentBand() );
181 mColorRampShaderWidget->classify();
187 QgsDebugMsg( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg(
min ).arg(
max ) );
189 if ( std::isnan(
min ) )
198 if ( std::isnan(
max ) )
210 if ( mMinLineEdit->text() != QString::number(
min ) || mMaxLineEdit->text() != QString::number(
max ) )
212 whileBlocking( mColorRampShaderWidget )->setRasterBand( bandNo );
226 void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
229 if ( !std::isnan( value ) )
231 s = QString::number( value );
233 lineEdit->setText( s );
236 double QgsSingleBandPseudoColorRendererWidget::lineEditValue(
const QLineEdit *lineEdit )
const
238 if ( lineEdit->text().isEmpty() )
240 return std::numeric_limits<double>::quiet_NaN();
243 return lineEdit->text().toDouble();
246 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited(
const QString & )
249 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
253 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited(
const QString & )
256 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
260 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged(
const QString & )
262 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
266 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged(
const QString & )
268 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
273 void QgsSingleBandPseudoColorRendererWidget::minMaxModified()