16#include <QIntValidator> 
   21#include <QRegularExpression> 
   40  , TRSTRING_NOT_SET( tr( 
"Not Set" ) )
 
   41  , mRasterLayer( layer )
 
   42  , mMapCanvas( canvas )
 
   45  connect( pbnAddValuesFromDisplay, &QToolButton::clicked, 
this, &QgsRasterTransparencyWidget::pbnAddValuesFromDisplay_clicked );
 
   46  connect( pbnAddValuesManually, &QToolButton::clicked, 
this, &QgsRasterTransparencyWidget::pbnAddValuesManually_clicked );
 
   47  connect( pbnDefaultValues, &QToolButton::clicked, 
this, &QgsRasterTransparencyWidget::pbnDefaultValues_clicked );
 
   48  connect( pbnExportTransparentPixelValues, &QToolButton::clicked, 
this, &QgsRasterTransparencyWidget::pbnExportTransparentPixelValues_clicked );
 
   49  connect( pbnImportTransparentPixelValues, &QToolButton::clicked, 
this, &QgsRasterTransparencyWidget::pbnImportTransparentPixelValues_clicked );
 
   50  connect( pbnRemoveSelectedRow, &QToolButton::clicked, 
this, &QgsRasterTransparencyWidget::pbnRemoveSelectedRow_clicked );
 
   52  mNodataColorButton->setShowNoColor( 
true );
 
   53  mNodataColorButton->setColorDialogTitle( tr( 
"Select NoData Color" ) );
 
   60  leNoDataValue->setValidator( 
new QgsDoubleValidator( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), 
this ) );
 
   63  mPixelSelectorTool = 
nullptr;
 
   71    pbnAddValuesFromDisplay->setEnabled( 
false );
 
 
   95      expContext << generator->createExpressionContextScope();
 
 
  125      gboxNoDataValue->setEnabled( 
false );
 
  126      gboxCustomTransparency->setEnabled( 
false );
 
  129    cboxTransparencyBand->setShowNotSetOption( 
true, tr( 
"None" ) );
 
  130    cboxTransparencyBand->setLayer( mRasterLayer );
 
  137      lblSrcNoDataValue->setText( tr( 
"not defined" ) );
 
  144    mSrcNoDataValueCheckBox->setEnabled( enableSrcNoData );
 
  145    lblSrcNoDataValue->setEnabled( enableSrcNoData );
 
  151      mNodataColorButton->setColor( renderer->
nodataColor() );
 
  153      mNodataColorButton->setToNull();
 
  155    mOpacityWidget->setOpacity( renderer->
opacity() );
 
  157    cboxTransparencyBand->setBand( renderer->
alphaBand() );
 
  163    QgsDebugMsgLevel( QStringLiteral( 
"noDataRangeList.size = %1" ).arg( noDataRangeList.size() ), 2 );
 
  164    if ( !noDataRangeList.isEmpty() )
 
  167      leNoDataValue->setText( QLocale().toString( v ) );
 
  171      leNoDataValue->setText( QString() );
 
  176    leNoDataValue->setText( QString() );
 
  182  populateTransparencyTable( mRasterLayer->
renderer() );
 
 
  185void QgsRasterTransparencyWidget::transparencyCellTextEdited( 
const QString &text )
 
  194  const int nBands = renderer->
usesBands().size();
 
  197    QLineEdit *lineEdit = qobject_cast<QLineEdit *>( sender() );
 
  198    if ( !lineEdit ) 
return;
 
  201    for ( 
int r = 0; r < tableTransparency->rowCount(); r++ )
 
  203      for ( 
int c = 0; 
c < tableTransparency->columnCount(); 
c++ )
 
  205        if ( tableTransparency->cellWidget( r, 
c ) == sender() )
 
  212      if ( row != -1 ) 
break;
 
  214    QgsDebugMsgLevel( QStringLiteral( 
"row = %1 column =%2" ).arg( row ).arg( column ), 2 );
 
  218      QLineEdit *toLineEdit = 
dynamic_cast<QLineEdit *
>( tableTransparency->cellWidget( row, 1 ) );
 
  219      if ( !toLineEdit ) 
return;
 
  220      const bool toChanged = mTransparencyToEdited.value( row );
 
  224        toLineEdit->setText( lineEdit->text() );
 
  227    else if ( column == 1 )
 
  229      setTransparencyToEdited( row );
 
  235void QgsRasterTransparencyWidget::pbnAddValuesFromDisplay_clicked()
 
  237  if ( mMapCanvas && mPixelSelectorTool )
 
  243void QgsRasterTransparencyWidget::pbnAddValuesManually_clicked()
 
  251  tableTransparency->insertRow( tableTransparency->rowCount() );
 
  256  for ( 
int i = 0; i < n; i++ )
 
  258    setTransparencyCell( tableTransparency->rowCount() - 1, i, std::numeric_limits<double>::quiet_NaN() );
 
  261  setTransparencyCell( tableTransparency->rowCount() - 1, n, 100 );
 
  267void QgsRasterTransparencyWidget::pbnDefaultValues_clicked()
 
  275  const int nBands = r->
usesBands().size();
 
  277  setupTransparencyTable( nBands );
 
  284void QgsRasterTransparencyWidget::pbnExportTransparentPixelValues_clicked()
 
  287  const QString myLastDir = myQSettings.
value( QStringLiteral( 
"lastRasterFileFilterDir" ), QDir::homePath() ).toString();
 
  288  QString myFileName = QFileDialog::getSaveFileName( 
this, tr( 
"Save Pixel Values as File" ), myLastDir, tr( 
"Textfile" ) + 
" (*.txt)" );
 
  289  if ( !myFileName.isEmpty() )
 
  291    if ( !myFileName.endsWith( QLatin1String( 
".txt" ), Qt::CaseInsensitive ) )
 
  293      myFileName = myFileName + 
".txt";
 
  296    QFile myOutputFile( myFileName );
 
  297    if ( myOutputFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
 
  299      QTextStream myOutputStream( &myOutputFile );
 
  300      myOutputStream << 
"# " << tr( 
"QGIS Generated Transparent Pixel Value Export File" ) << 
'\n';
 
  301      if ( rasterIsMultiBandColor() )
 
  303        myOutputStream << 
"#\n#\n# " << tr( 
"Red" ) << 
"\t" << tr( 
"Green" ) << 
"\t" << tr( 
"Blue" ) << 
"\t" << tr( 
"Percent Transparent" );
 
  304        for ( 
int myTableRunner = 0; myTableRunner < tableTransparency->rowCount(); myTableRunner++ )
 
  306          myOutputStream << 
'\n' << QString::number( transparencyCellValue( myTableRunner, 0 ) ) << 
"\t" 
  307                         << QString::number( transparencyCellValue( myTableRunner, 1 ) ) << 
"\t" 
  308                         << QString::number( transparencyCellValue( myTableRunner, 2 ) ) << 
"\t" 
  309                         << QString::number( transparencyCellValue( myTableRunner, 3 ) );
 
  314        myOutputStream << 
"#\n#\n# " << tr( 
"Value" ) << 
"\t" << tr( 
"Percent Transparent" );
 
  316        for ( 
int myTableRunner = 0; myTableRunner < tableTransparency->rowCount(); myTableRunner++ )
 
  318          myOutputStream << 
'\n' << QString::number( transparencyCellValue( myTableRunner, 0 ) ) << 
"\t" 
  319                         << QString::number( transparencyCellValue( myTableRunner, 1 ) ) << 
"\t" 
  320                         << QString::number( transparencyCellValue( myTableRunner, 2 ) );
 
  326      QMessageBox::warning( 
this, tr( 
"Save Pixel Values as File" ), tr( 
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
 
  331void QgsRasterTransparencyWidget::pbnImportTransparentPixelValues_clicked()
 
  333  int myLineCounter = 0;
 
  334  bool myImportError = 
false;
 
  337  const QString myLastDir = myQSettings.
value( QStringLiteral( 
"lastRasterFileFilterDir" ), QDir::homePath() ).toString();
 
  338  const QString myFileName = QFileDialog::getOpenFileName( 
this, tr( 
"Load Pixel Values from File" ), myLastDir, tr( 
"Textfile" ) + 
" (*.txt)" );
 
  339  QFile myInputFile( myFileName );
 
  340  if ( myInputFile.open( QFile::ReadOnly ) )
 
  342    QTextStream myInputStream( &myInputFile );
 
  344    if ( rasterIsMultiBandColor() )
 
  346      for ( 
int myTableRunner = tableTransparency->rowCount() - 1; myTableRunner >= 0; myTableRunner-- )
 
  348        tableTransparency->removeRow( myTableRunner );
 
  351      while ( !myInputStream.atEnd() )
 
  354        myInputLine = myInputStream.readLine();
 
  355        if ( !myInputLine.isEmpty() )
 
  357          if ( !myInputLine.simplified().startsWith( 
'#' ) )
 
  359            QStringList myTokens = myInputLine.split( QRegularExpression( 
"\\s+" ), Qt::SkipEmptyParts );
 
  360            if ( myTokens.count() != 4 )
 
  362              myImportError = 
true;
 
  363              myBadLines = myBadLines + QString::number( myLineCounter ) + 
":\t[" + myInputLine + 
"]\n";
 
  367              tableTransparency->insertRow( tableTransparency->rowCount() );
 
  368              for ( 
int col = 0; col < 4; col++ )
 
  370                setTransparencyCell( tableTransparency->rowCount() - 1, col, myTokens[col].toDouble() );
 
  379      for ( 
int myTableRunner = tableTransparency->rowCount() - 1; myTableRunner >= 0; myTableRunner-- )
 
  381        tableTransparency->removeRow( myTableRunner );
 
  384      while ( !myInputStream.atEnd() )
 
  387        myInputLine = myInputStream.readLine();
 
  388        if ( !myInputLine.isEmpty() )
 
  390          if ( !myInputLine.simplified().startsWith( 
'#' ) )
 
  392            QStringList myTokens = myInputLine.split( QRegularExpression( 
"\\s+" ), Qt::SkipEmptyParts );
 
  393            if ( myTokens.count() != 3 && myTokens.count() != 2 ) 
 
  395              myImportError = 
true;
 
  396              myBadLines = myBadLines + QString::number( myLineCounter ) + 
":\t[" + myInputLine + 
"]\n";
 
  400              if ( myTokens.count() == 2 )
 
  402                myTokens.insert( 1, myTokens[0] ); 
 
  404              tableTransparency->insertRow( tableTransparency->rowCount() );
 
  405              for ( 
int col = 0; col < 3; col++ )
 
  407                setTransparencyCell( tableTransparency->rowCount() - 1, col, myTokens[col].toDouble() );
 
  417      QMessageBox::warning( 
this, tr( 
"Load Pixel Values from File" ), tr( 
"The following lines contained errors\n\n%1" ).arg( myBadLines ) );
 
  420  else if ( !myFileName.isEmpty() )
 
  422    QMessageBox::warning( 
this, tr( 
"Load Pixel Values from File" ), tr( 
"Read access denied. Adjust the file permissions and try again.\n\n" ) );
 
  429void QgsRasterTransparencyWidget::pbnRemoveSelectedRow_clicked()
 
  431  if ( 0 < tableTransparency->rowCount() )
 
  433    tableTransparency->removeRow( tableTransparency->currentRow() );
 
  438bool QgsRasterTransparencyWidget::rasterIsMultiBandColor()
 
  447  if ( 
"" != leNoDataValue->text() )
 
  449    bool myDoubleOk = 
false;
 
  453      const QgsRasterRange myNoDataRange( myNoDataValue, myNoDataValue );
 
  454      myNoDataRangeList << myNoDataRange;
 
  459    for ( 
int bandNo = 1; bandNo <= provider->bandCount(); bandNo++ )
 
  461      provider->setUserNoDataValue( bandNo, myNoDataRangeList );
 
  462      provider->setUseSourceNoDataValue( bandNo, mSrcNoDataValueCheckBox->isChecked() );
 
  468  if ( rasterRenderer )
 
  470    rasterRenderer->
setAlphaBand( cboxTransparencyBand->currentBand() );
 
  475    if ( tableTransparency->columnCount() == 4 )
 
  477      QVector<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
 
  478      myTransparentThreeValuePixelList.reserve( tableTransparency->rowCount() );
 
  479      for ( 
int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
 
  481        const double red = transparencyCellValue( myListRunner, 0 );
 
  482        const double green = transparencyCellValue( myListRunner, 1 );
 
  483        const double blue = transparencyCellValue( myListRunner, 2 );
 
  484        const double opacity = 1.0 - transparencyCellValue( myListRunner, 3 ) / 100.0;
 
  485        myTransparentThreeValuePixelList.append(
 
  491    else if ( tableTransparency->columnCount() == 3 )
 
  493      QVector<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
 
  494      myTransparentSingleValuePixelList.reserve( tableTransparency->rowCount() );
 
  495      for ( 
int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
 
  497        const double min = transparencyCellValue( myListRunner, 0 );
 
  498        const double max = transparencyCellValue( myListRunner, 1 );
 
  499        const double opacity = 1.0 - transparencyCellValue( myListRunner, 2 ) / 100.0;
 
  501        myTransparentSingleValuePixelList.append(
 
  511    rasterRenderer->
setOpacity( mOpacityWidget->opacity() );
 
 
  519  button->blockSignals( 
true );
 
  523  button->blockSignals( 
false );
 
 
  528  const auto propertyOverrideButtons { findChildren< QgsPropertyOverrideButton * >() };
 
 
  547void QgsRasterTransparencyWidget::updateProperty()
 
  555void QgsRasterTransparencyWidget::pixelSelected( 
const QgsPointXY &canvasPoint )
 
  564  if ( mMapCanvas && mPixelSelectorTool && mRasterLayer->
dataProvider() )
 
  573    const int myWidth = mMapCanvas->
extent().
width() / mapUnitsPerPixel;
 
  574    const int myHeight = mMapCanvas->
extent().
height() / mapUnitsPerPixel;
 
  578    const QList<int> bands = renderer->
usesBands();
 
  580    QList<double> values;
 
  581    for ( 
int i = 0; i < bands.size(); ++i )
 
  583      const int bandNo = bands.value( i );
 
  584      if ( myPixelMap.count( bandNo ) == 1 )
 
  590        const double value = myPixelMap.value( bandNo ).toDouble();
 
  591        QgsDebugMsgLevel( QStringLiteral( 
"value = %1" ).arg( value, 0, 
'g', 17 ), 2 );
 
  592        values.append( value );
 
  595    if ( bands.size() == 1 )
 
  598      values.insert( 1, values.value( 0 ) );
 
  600    tableTransparency->insertRow( tableTransparency->rowCount() );
 
  601    for ( 
int i = 0; i < values.size(); i++ )
 
  603      setTransparencyCell( tableTransparency->rowCount() - 1, i, values.value( i ) );
 
  605    setTransparencyCell( tableTransparency->rowCount() - 1, tableTransparency->columnCount() - 1, 100 );
 
  612void QgsRasterTransparencyWidget::populateTransparencyTable( 
QgsRasterRenderer *renderer )
 
  624  const int nBands = renderer->
usesBands().size();
 
  625  setupTransparencyTable( nBands );
 
  628  if ( !rasterTransparency )
 
  636    for ( 
int i = 0; i < pixelList.size(); ++i )
 
  638      tableTransparency->insertRow( i );
 
  639      setTransparencyCell( i, 0, pixelList[i].min );
 
  640      setTransparencyCell( i, 1, pixelList[i].max );
 
  641      setTransparencyCell( i, 2, 100 * ( 1 - pixelList[i].opacity ) );
 
  643      if ( pixelList[i].min != pixelList[i].max )
 
  645        setTransparencyToEdited( i );
 
  649  else if ( nBands == 3 )
 
  652    for ( 
int i = 0; i < pixelList.size(); ++i )
 
  654      tableTransparency->insertRow( i );
 
  655      setTransparencyCell( i, 0, pixelList[i].red );
 
  656      setTransparencyCell( i, 1, pixelList[i].green );
 
  657      setTransparencyCell( i, 2, pixelList[i].blue );
 
  658      setTransparencyCell( i, 3, 100 * ( 1 - pixelList[i].opacity ) );
 
  662  tableTransparency->resizeColumnsToContents();
 
  663  tableTransparency->resizeRowsToContents();
 
  667void QgsRasterTransparencyWidget::setupTransparencyTable( 
int nBands )
 
  669  tableTransparency->clear();
 
  670  tableTransparency->setColumnCount( 0 );
 
  671  tableTransparency->setRowCount( 0 );
 
  672  mTransparencyToEdited.clear();
 
  676    tableTransparency->setColumnCount( 4 );
 
  677    tableTransparency->setHorizontalHeaderItem( 0, 
new QTableWidgetItem( tr( 
"Red" ) ) );
 
  678    tableTransparency->setHorizontalHeaderItem( 1, 
new QTableWidgetItem( tr( 
"Green" ) ) );
 
  679    tableTransparency->setHorizontalHeaderItem( 2, 
new QTableWidgetItem( tr( 
"Blue" ) ) );
 
  680    tableTransparency->setHorizontalHeaderItem( 3, 
new QTableWidgetItem( tr( 
"Percent Transparent" ) ) );
 
  684    tableTransparency->setColumnCount( 3 );
 
  687    if ( QgsRasterLayer::PalettedColor != mRasterLayer->drawingStyle() &&
 
  688         QgsRasterLayer::PalettedSingleBandGray != mRasterLayer->drawingStyle() &&
 
  689         QgsRasterLayer::PalettedSingleBandPseudoColor != mRasterLayer->drawingStyle() &&
 
  690         QgsRasterLayer::PalettedMultiBandColor != mRasterLayer->drawingStyle() )
 
  692      tableTransparency->setHorizontalHeaderItem( 0, 
new QTableWidgetItem( tr( 
"Gray" ) ) );
 
  696      tableTransparency->setHorizontalHeaderItem( 0, 
new QTableWidgetItem( tr( 
"Indexed Value" ) ) );
 
  699    tableTransparency->setHorizontalHeaderItem( 0, 
new QTableWidgetItem( tr( 
"From" ) ) );
 
  700    tableTransparency->setHorizontalHeaderItem( 1, 
new QTableWidgetItem( tr( 
"To" ) ) );
 
  701    tableTransparency->setHorizontalHeaderItem( 2, 
new QTableWidgetItem( tr( 
"Percent Transparent" ) ) );
 
  705void QgsRasterTransparencyWidget::setTransparencyCell( 
int row, 
int column, 
double value )
 
  707  QgsDebugMsgLevel( QStringLiteral( 
"value = %1" ).arg( value, 0, 
'g', 17 ), 2 );
 
  715  const int nBands = renderer->
usesBands().size();
 
  717  QLineEdit *lineEdit = 
new QLineEdit();
 
  718  lineEdit->setFrame( 
false ); 
 
  720  lineEdit->setContentsMargins( 1, 1, 1, 1 );
 
  722  if ( column == tableTransparency->columnCount() - 1 )
 
  726    lineEdit->setValidator( 
new QIntValidator( 
nullptr ) );
 
  727    lineEdit->setText( QString::number( 
static_cast<int>( value ) ) );
 
  738        if ( !std::isnan( value ) )
 
  741          valueString = QLocale().toString( v );
 
  745        lineEdit->setValidator( 
new QIntValidator( 
nullptr ) );
 
  746        if ( !std::isnan( value ) )
 
  748          valueString = QString::number( 
static_cast<int>( value ) );
 
  752    lineEdit->setText( valueString );
 
  755  tableTransparency->setCellWidget( row, column, lineEdit );
 
  756  adjustTransparencyCellWidth( row, column );
 
  758  if ( nBands == 1 && ( column == 0 || column == 1 ) )
 
  760    connect( lineEdit, &QLineEdit::textEdited, 
this, &QgsRasterTransparencyWidget::transparencyCellTextEdited );
 
  766void QgsRasterTransparencyWidget::adjustTransparencyCellWidth( 
int row, 
int column )
 
  768  QLineEdit *lineEdit = 
dynamic_cast<QLineEdit *
>( tableTransparency->cellWidget( row, column ) );
 
  769  if ( !lineEdit ) 
return;
 
  771  int width = std::max( lineEdit->fontMetrics().boundingRect( lineEdit->text() ).width() + 10, 100 );
 
  772  width = std::max( width, tableTransparency->columnWidth( column ) );
 
  774  lineEdit->setFixedWidth( width );
 
  777void QgsRasterTransparencyWidget::setTransparencyToEdited( 
int row )
 
  779  if ( row >= mTransparencyToEdited.size() )
 
  781    mTransparencyToEdited.resize( row + 1 );
 
  783  mTransparencyToEdited[row] = 
true;
 
  786double QgsRasterTransparencyWidget::transparencyCellValue( 
int row, 
int column )
 
  788  QLineEdit *lineEdit = 
dynamic_cast<QLineEdit *
>( tableTransparency->cellWidget( row, column ) );
 
  789  if ( !lineEdit || lineEdit->text().isEmpty() )
 
  791    return std::numeric_limits<double>::quiet_NaN();
 
  799  return mPixelSelectorTool;
 
 
@ Float32
Thirty two bit floating point (float)
 
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
 
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
 
@ Float64
Sixty four bit floating point (double)
 
@ Value
Numerical pixel value.
 
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
 
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
 
Abstract interface for generating an expression context scope.
 
Single scope for storing variables and functions for use within a QgsExpressionContext.
 
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
 
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
 
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
 
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
 
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
 
Map canvas is a class for displaying all GIS data types on a canvas.
 
void unsetMapTool(QgsMapTool *mapTool)
Unset the current map tool or last non zoom tool.
 
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
 
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
 
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
 
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
 
The QgsMapSettings class contains configuration for rendering of the map.
 
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
 
Renderer for multiband images with the color components.
 
A class to represent a 2D point.
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
 
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
 
void bandChanged(int band)
Emitted when the currently selected band changes.
 
static QString printValue(double value, bool localized=false)
Print double value with all necessary significant digits.
 
Base class for raster data providers.
 
virtual bool sourceHasNoDataValue(int bandNo) const
Returns true if source band has no data value.
 
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
 
Qgis::DataType sourceDataType(int bandNo) const override=0
Returns source data type for the band specified by number, source data type may be shorter than dataT...
 
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
 
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
 
virtual QgsRasterIdentifyResult identify(const QgsPointXY &point, Qgis::RasterIdentifyFormat format, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Identify raster value(s) found on the point position.
 
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
 
QMap< int, QVariant > results() const
Returns the identify results.
 
Represents a raster layer.
 
QgsRasterPipe * pipe()
Returns the raster pipe.
 
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
 
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
 
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the pipe's property collection, used for data defined overrides.
 
Property
Data definable properties.
 
@ RendererOpacity
Raster renderer global opacity.
 
static QgsPropertiesDefinition propertyDefinitions()
Returns the definitions for data defined properties available for use in raster pipes.
 
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the pipe's property collection, used for data defined overrides.
 
Raster values range container.
 
Raster renderer pipe that applies colors to a raster.
 
QColor nodataColor() const
Returns the color to use for shading nodata pixels.
 
const QgsRasterTransparency * rasterTransparency() const
 
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
 
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
 
void setAlphaBand(int band)
 
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
 
void setRasterTransparency(QgsRasterTransparency *t)
 
void setNodataColor(const QColor &color)
Sets the color to use for shading nodata pixels.
 
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
 
void setTransparentSingleValuePixelList(const QVector< QgsRasterTransparency::TransparentSingleValuePixel > &newList)
Sets the transparent single value pixel list, replacing the whole existing list.
 
QVector< QgsRasterTransparency::TransparentSingleValuePixel > transparentSingleValuePixelList() const
Returns the transparent single value pixel list.
 
void setTransparentThreeValuePixelList(const QVector< QgsRasterTransparency::TransparentThreeValuePixel > &newList)
Sets the transparent three value pixel list, replacing the whole existing list.
 
QVector< QgsRasterTransparency::TransparentThreeValuePixel > transparentThreeValuePixelList() const
Returns the transparent three value pixel list.
 
A rectangle specified with double values.
 
double width() const
Returns the width of the rectangle.
 
double height() const
Returns the height of the rectangle.
 
This class is a composition of two QSettings instances:
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
 
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
 
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
 
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
 
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
 
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
 
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
 
#define QgsDebugMsgLevel(str, level)
 
QList< QgsRasterRange > QgsRasterRangeList
 
Defines the transparency for a range of single-band pixel values.
 
Defines the transparency for a RGB pixel value.