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 int bandNumber = mBandComboBox->currentBand();
123 renderer->setClassificationMin( lineEditValue( mMinLineEdit ) );
124 renderer->setClassificationMax( lineEditValue( mMaxLineEdit ) );
138 return mBandComboBox->currentBand();
145 mColorRampShaderWidget->setExtent( mMinMaxWidget->
extent() );
154 mMinMaxWidget->
setBands( QList< int >() << pr->
band() );
155 mColorRampShaderWidget->setRasterBand( pr->
band() );
167 if ( colorRampShader )
169 mColorRampShaderWidget->setFromShader( *colorRampShader );
175 mMinMaxWidget->
setBands( QList< int >() << mBandComboBox->currentBand() );
176 mColorRampShaderWidget->setRasterBand( mBandComboBox->currentBand() );
180 void QgsSingleBandPseudoColorRendererWidget::bandChanged()
183 bands.append( mBandComboBox->currentBand() );
185 mColorRampShaderWidget->setRasterBand( mBandComboBox->currentBand() );
186 mColorRampShaderWidget->classify();
191 QgsDebugMsg( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg(
min ).arg(
max ) );
193 if ( std::isnan(
min ) )
199 whileBlocking( mMinLineEdit )->setText( displayValueWithMaxPrecision(
min ) );
202 if ( std::isnan(
max ) )
208 whileBlocking( mMaxLineEdit )->setText( displayValueWithMaxPrecision(
max ) );
214 if ( mMinLineEdit->text() != displayValueWithMaxPrecision(
min ) || mMaxLineEdit->text() != displayValueWithMaxPrecision(
max ) )
216 whileBlocking( mColorRampShaderWidget )->setRasterBand( bandNo );
224 whileBlocking( mMinLineEdit )->setText( displayValueWithMaxPrecision(
min ) );
225 whileBlocking( mMaxLineEdit )->setText( displayValueWithMaxPrecision(
max ) );
230 void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
233 if ( !std::isnan( value ) )
235 s = displayValueWithMaxPrecision( value );
237 lineEdit->setText( s );
240 double QgsSingleBandPseudoColorRendererWidget::lineEditValue(
const QLineEdit *lineEdit )
const
242 if ( lineEdit->text().isEmpty() )
244 return std::numeric_limits<double>::quiet_NaN();
250 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited(
const QString & )
253 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
257 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited(
const QString & )
260 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
264 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged(
const QString & )
266 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
270 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged(
const QString & )
272 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
277 void QgsSingleBandPseudoColorRendererWidget::minMaxModified()
282 QString QgsSingleBandPseudoColorRendererWidget::displayValueWithMaxPrecision(
const double value )
291 return QLocale().toString( value,
'g' );