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();
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 double oldMin = lineEditValue( mMinLineEdit );
190 double oldMax = lineEditValue( mMaxLineEdit );
192 if ( std::isnan( min ) )
198 whileBlocking( mMinLineEdit )->setText( QString::number( min ) );
201 if ( std::isnan( max ) )
207 whileBlocking( mMaxLineEdit )->setText( QString::number( max ) );
212 whileBlocking( mColorRampShaderWidget )->setRasterBand( bandNo );
213 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( min, max );
220 whileBlocking( mMinLineEdit )->setText( QString::number( min ) );
221 whileBlocking( mMaxLineEdit )->setText( QString::number( max ) );
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()
QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits.
A rectangle specified with double values.
double classificationMin() const
Interface for all raster shaders.
This class is a composition of two QSettings instances:
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
QgsRasterRenderer * renderer() const
QgsRasterShader * shader()
Returns the raster shader.
void setClassificationMax(double max)
Map canvas is a class for displaying all GIS data types on a canvas.
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider, it may be null.
This class describes the origin of min/max values.
void bandChanged(int band)
This signal is emitted when the currently selected band changes.
QgsRasterShaderFunction * rasterShaderFunction()
double classificationMax() const
Raster renderer pipe for single band pseudocolor.
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
void setLimits(QgsRasterMinMaxOrigin::Limits limits)
Sets the limits.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
void setClassificationMin(double min)
void setBand(int bandNo)
Sets the band used by the renderer.
Raster renderer pipe that applies colors to a raster.
int band() const
Returns the band used by the renderer.
Base class for raster data providers.