19#include "moc_qgssinglebandpseudocolorrendererwidget.cpp"
32#include <QInputDialog>
47 mColorRampShaderWidget->initializeForUseWithRasterLayer();
49 connect( mMinLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged );
50 connect( mMaxLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged );
51 connect( mMinLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited );
52 connect( mMaxLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited );
73 QHBoxLayout *layout =
new QHBoxLayout();
74 layout->setContentsMargins( 0, 0, 0, 0 );
75 mMinMaxContainerWidget->setLayout( layout );
76 layout->addWidget( mMinMaxWidget );
78 mColorRampShaderWidget->setRasterDataProvider( provider );
87 if ( mMinLineEdit->text().isEmpty() || mMaxLineEdit->text().isEmpty() )
98 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
109 mColorRampShaderWidget->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
110 mColorRampShaderWidget->setExtent( mMinMaxWidget->
extent() );
115 const int bandNumber = mBandComboBox->currentBand();
117 renderer->setClassificationMin( lineEditValue( mMinLineEdit ) );
118 renderer->setClassificationMax( lineEditValue( mMaxLineEdit ) );
134 mColorRampShaderWidget->setExtent( mMinMaxWidget->
extent() );
144 mColorRampShaderWidget->setRasterBand( pr->
inputBand() );
156 if ( colorRampShader )
158 mColorRampShaderWidget->setFromShader( *colorRampShader );
164 mMinMaxWidget->
setBands( QList<int>() << mBandComboBox->currentBand() );
165 mColorRampShaderWidget->setRasterBand( mBandComboBox->currentBand() );
169void QgsSingleBandPseudoColorRendererWidget::bandChanged()
172 bands.append( mBandComboBox->currentBand() );
174 mColorRampShaderWidget->setRasterBand( mBandComboBox->currentBand() );
175 mColorRampShaderWidget->classify();
180 QgsDebugMsgLevel( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg(
min ).arg(
max ), 2 );
182 const QString oldMinTextvalue = mMinLineEdit->text();
183 const QString oldMaxTextvalue = mMaxLineEdit->text();
185 if ( std::isnan(
min ) )
191 whileBlocking( mMinLineEdit )->setText( displayValueWithMaxPrecision(
min ) );
194 if ( std::isnan(
max ) )
200 whileBlocking( mMaxLineEdit )->setText( displayValueWithMaxPrecision(
max ) );
206 if ( mMinLineEdit->text() != oldMinTextvalue || mMaxLineEdit->text() != oldMaxTextvalue )
208 whileBlocking( mColorRampShaderWidget )->setRasterBand( bandNo );
216 whileBlocking( mMinLineEdit )->setText( displayValueWithMaxPrecision(
min ) );
217 whileBlocking( mMaxLineEdit )->setText( displayValueWithMaxPrecision(
max ) );
222void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
225 if ( !std::isnan( value ) )
227 s = displayValueWithMaxPrecision( value );
229 lineEdit->setText( s );
232double QgsSingleBandPseudoColorRendererWidget::lineEditValue(
const QLineEdit *lineEdit )
const
234 if ( lineEdit->text().isEmpty() )
236 return std::numeric_limits<double>::quiet_NaN();
242void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited(
const QString & )
245 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
249void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited(
const QString & )
252 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
256void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged(
const QString & )
258 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
262void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged(
const QString & )
264 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
269void QgsSingleBandPseudoColorRendererWidget::minMaxModified()
274QString QgsSingleBandPseudoColorRendererWidget::displayValueWithMaxPrecision(
const double value )
283 return QLocale().toString( value,
'g' );
289 mMinLineEdit->setText( value );
291 mColorRampShaderWidget->classify();
296 mMaxLineEdit->setText( value );
298 mColorRampShaderWidget->classify();
@ MinimumMaximum
Real min-max values.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
Map canvas is a class for displaying all GIS data types on a canvas.
void bandChanged(int band)
Emitted when the currently selected band changes.
Base class for raster data providers.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
Represents a raster layer.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
This class describes the origin of min/max values.
void setLimits(Qgis::RasterRangeLimit limits)
Sets the limits.
Qgis::RasterRangeLimit limits() const
Returns the raster limits.
Raster renderer pipe that applies colors to a raster.
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
Interface for all raster shaders.
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
QgsRasterShaderFunction * rasterShaderFunction()
A rectangle specified with double values.
This class is a composition of two QSettings instances:
Raster renderer pipe for single band pseudocolor.
Q_DECL_DEPRECATED void setBand(int bandNo)
Sets the band used by the renderer.
double classificationMin() const
QgsRasterShader * shader()
Returns the raster shader.
double classificationMax() const
int inputBand() const override
Returns the input band for the renderer, or -1 if no input band is available.
QString displayValueWithMaximumDecimals(const Qgis::DataType dataType, const double value, bool displayTrailingZeroes)
Returns a localized string representation of the value with the appropriate number of decimals suppor...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
#define QgsDebugMsgLevel(str, level)