26 #include "qgssettings.h" 
   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   const QString oldMinTextvalue = mMinLineEdit->text();
 
  194   const QString oldMaxTextvalue = mMaxLineEdit->text();
 
  196   if ( std::isnan( 
min ) )
 
  202     whileBlocking( mMinLineEdit )->setText( displayValueWithMaxPrecision( 
min ) );
 
  205   if ( std::isnan( 
max ) )
 
  211     whileBlocking( mMaxLineEdit )->setText( displayValueWithMaxPrecision( 
max ) );
 
  217   if ( mMinLineEdit->text() != oldMinTextvalue || mMaxLineEdit->text() != oldMaxTextvalue )
 
  219     whileBlocking( mColorRampShaderWidget )->setRasterBand( bandNo );
 
  227   whileBlocking( mMinLineEdit )->setText( displayValueWithMaxPrecision( 
min ) );
 
  228   whileBlocking( mMaxLineEdit )->setText( displayValueWithMaxPrecision( 
max ) );
 
  233 void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit *lineEdit, 
double value )
 
  236   if ( !std::isnan( value ) )
 
  238     s = displayValueWithMaxPrecision( value );
 
  240   lineEdit->setText( s );
 
  243 double QgsSingleBandPseudoColorRendererWidget::lineEditValue( 
const QLineEdit *lineEdit )
 const 
  245   if ( lineEdit->text().isEmpty() )
 
  247     return std::numeric_limits<double>::quiet_NaN();
 
  253 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited( 
const QString & )
 
  256   whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
 
  260 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited( 
const QString & )
 
  263   whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
 
  267 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged( 
const QString & )
 
  269   whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
 
  273 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged( 
const QString & )
 
  275   whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( lineEditValue( mMinLineEdit ), lineEditValue( mMaxLineEdit ) );
 
  280 void QgsSingleBandPseudoColorRendererWidget::minMaxModified()
 
  285 QString QgsSingleBandPseudoColorRendererWidget::displayValueWithMaxPrecision( 
const double value )
 
  294     return QLocale().toString( value, 
'g' );
 
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.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
This class describes the origin of min/max values.
QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits.
void setLimits(QgsRasterMinMaxOrigin::Limits limits)
Sets the limits.
@ MinMax
Real min-max values.
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.
QgsRasterShaderFunction * rasterShaderFunction()
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
A rectangle specified with double values.
Raster renderer pipe for single band pseudocolor.
int band() const
Returns the band used by the renderer.
QgsRasterShader * shader()
Returns the raster shader.
void setBand(int bandNo)
Sets the band used by the renderer.
double classificationMin() const
double classificationMax() const
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.