37 #include <QPushButton>
38 #include <QInputDialog>
39 #include <QFileDialog>
41 #include <QMessageBox>
42 #include <QTextStream>
53 mColorRampShaderWidget->initializeForUseWithRasterLayer();
55 connect( mMinLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged );
56 connect( mMaxLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged );
57 connect( mMinLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited );
58 connect( mMaxLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited );
79 QHBoxLayout *layout =
new QHBoxLayout();
80 layout->setContentsMargins( 0, 0, 0, 0 );
81 mMinMaxContainerWidget->setLayout( layout );
82 layout->addWidget( mMinMaxWidget );
84 mColorRampShaderWidget->setRasterDataProvider( provider );
93 if ( mMinLineEdit->text().isEmpty() || mMaxLineEdit->text().isEmpty() )
104 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
115 mColorRampShaderWidget->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
116 mColorRampShaderWidget->setExtent( mMinMaxWidget->
extent() );
121 const int bandNumber = mBandComboBox->currentBand();
123 renderer->setClassificationMin( lineEditValue( mMinLineEdit ) );
124 renderer->setClassificationMax( lineEditValue( mMaxLineEdit ) );
140 mColorRampShaderWidget->setExtent( mMinMaxWidget->
extent() );
149 mMinMaxWidget->
setBands( QList< int >() << pr->
band() );
150 mColorRampShaderWidget->setRasterBand( pr->
band() );
162 if ( colorRampShader )
164 mColorRampShaderWidget->setFromShader( *colorRampShader );
170 mMinMaxWidget->
setBands( QList< int >() << mBandComboBox->currentBand() );
171 mColorRampShaderWidget->setRasterBand( mBandComboBox->currentBand() );
175 void QgsSingleBandPseudoColorRendererWidget::bandChanged()
178 bands.append( mBandComboBox->currentBand() );
180 mColorRampShaderWidget->setRasterBand( mBandComboBox->currentBand() );
181 mColorRampShaderWidget->classify();
186 QgsDebugMsgLevel( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg(
min ).arg(
max ), 2 );
188 const QString oldMinTextvalue = mMinLineEdit->text();
189 const QString oldMaxTextvalue = mMaxLineEdit->text();
191 if ( std::isnan(
min ) )
197 whileBlocking( mMinLineEdit )->setText( displayValueWithMaxPrecision(
min ) );
200 if ( std::isnan(
max ) )
206 whileBlocking( mMaxLineEdit )->setText( displayValueWithMaxPrecision(
max ) );
212 if ( mMinLineEdit->text() != oldMinTextvalue || mMaxLineEdit->text() != oldMaxTextvalue )
214 whileBlocking( mColorRampShaderWidget )->setRasterBand( bandNo );
222 whileBlocking( mMinLineEdit )->setText( displayValueWithMaxPrecision(
min ) );
223 whileBlocking( mMaxLineEdit )->setText( displayValueWithMaxPrecision(
max ) );
228 void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
231 if ( !std::isnan( value ) )
233 s = displayValueWithMaxPrecision( value );
235 lineEdit->setText( s );
238 double QgsSingleBandPseudoColorRendererWidget::lineEditValue(
const QLineEdit *lineEdit )
const
240 if ( lineEdit->text().isEmpty() )
242 return std::numeric_limits<double>::quiet_NaN();
248 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited(
const QString & )
251 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
255 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited(
const QString & )
258 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
262 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged(
const QString & )
264 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
268 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged(
const QString & )
270 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
275 void QgsSingleBandPseudoColorRendererWidget::minMaxModified()
280 QString QgsSingleBandPseudoColorRendererWidget::displayValueWithMaxPrecision(
const double value )
289 return QLocale().toString( value,
'g' );
295 mMinLineEdit->setText( value );
297 mColorRampShaderWidget->classify();
302 mMaxLineEdit->setText( value );
304 mColorRampShaderWidget->classify();