34 #include <QPushButton> 35 #include <QInputDialog> 36 #include <QFileDialog> 38 #include <QMessageBox> 39 #include <QTextStream> 50 connect( mAddEntryButton, &QPushButton::clicked,
this, &QgsSingleBandPseudoColorRendererWidget::mAddEntryButton_clicked );
51 connect( mDeleteEntryButton, &QPushButton::clicked,
this, &QgsSingleBandPseudoColorRendererWidget::mDeleteEntryButton_clicked );
52 connect( mLoadFromBandButton, &QPushButton::clicked,
this, &QgsSingleBandPseudoColorRendererWidget::mLoadFromBandButton_clicked );
53 connect( mLoadFromFileButton, &QPushButton::clicked,
this, &QgsSingleBandPseudoColorRendererWidget::mLoadFromFileButton_clicked );
54 connect( mExportToFileButton, &QPushButton::clicked,
this, &QgsSingleBandPseudoColorRendererWidget::mExportToFileButton_clicked );
55 connect( mUnitLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mUnitLineEdit_textEdited );
56 connect( mColormapTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemDoubleClicked );
57 connect( mColorInterpolationComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSingleBandPseudoColorRendererWidget::mColorInterpolationComboBox_currentIndexChanged );
58 connect( mMinLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textChanged );
59 connect( mMaxLineEdit, &QLineEdit::textChanged,
this, &QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textChanged );
60 connect( mMinLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited );
61 connect( mMaxLineEdit, &QLineEdit::textEdited,
this, &QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited );
62 connect( mClassificationModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSingleBandPseudoColorRendererWidget::mClassificationModeComboBox_currentIndexChanged );
64 contextMenu =
new QMenu( tr(
"Options" ),
this );
65 contextMenu->addAction( tr(
"Change Color…" ),
this, SLOT( changeColor() ) );
66 contextMenu->addAction( tr(
"Change Opacity…" ),
this, SLOT( changeOpacity() ) );
68 mColormapTreeWidget->setColumnWidth( ColorColumn, 50 );
69 mColormapTreeWidget->setContextMenuPolicy( Qt::CustomContextMenu );
70 mColormapTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
71 connect( mColormapTreeWidget, &QTreeView::customContextMenuRequested,
this, [ = ]( QPoint ) { contextMenu->exec( QCursor::pos() ); }
74 QString defaultPalette = settings.
value( QStringLiteral(
"Raster/defaultPalette" ),
"" ).toString();
75 btnColorRamp->setColorRampFromName( defaultPalette );
89 mMinLineEdit->setValidator(
new QDoubleValidator( mMinLineEdit ) );
90 mMaxLineEdit->setValidator(
new QDoubleValidator( mMaxLineEdit ) );
96 QHBoxLayout *layout =
new QHBoxLayout();
97 layout->setContentsMargins( 0, 0, 0, 0 );
98 mMinMaxContainerWidget->setLayout( layout );
99 layout->addWidget( mMinMaxWidget );
113 mNumberOfEntriesSpinBox->setValue( 5 );
121 if ( mMinLineEdit->text().isEmpty() || mMaxLineEdit->text().isEmpty() )
132 mClassificationModeComboBox_currentIndexChanged( 0 );
134 resetClassifyButton();
137 connect( mClassifyButton, &QPushButton::clicked,
this, &QgsSingleBandPseudoColorRendererWidget::applyColorRamp );
149 colorRampShader->
setColorRampType( static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ) );
150 colorRampShader->
setClassificationMode( static_cast< QgsColorRampShader::ClassificationMode >( mClassificationModeComboBox->currentData().toInt() ) );
151 colorRampShader->
setClip( mClipCheckBox->isChecked() );
154 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
155 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
156 QTreeWidgetItem *currentItem =
nullptr;
157 for (
int i = 0; i < topLevelItemCount; ++i )
159 currentItem = mColormapTreeWidget->topLevelItem( i );
165 newColorRampItem.
value = currentItem->text( ValueColumn ).toDouble();
166 newColorRampItem.
color = currentItem->background( ColorColumn ).color();
167 newColorRampItem.
label = currentItem->text( LabelColumn );
168 colorRampItems.append( newColorRampItem );
171 std::sort( colorRampItems.begin(), colorRampItems.end() );
174 if ( !btnColorRamp->isNull() )
181 int bandNumber = mBandComboBox->currentBand();
200 void QgsSingleBandPseudoColorRendererWidget::autoLabel()
204 QString unit = mUnitLineEdit->text();
206 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
207 QTreeWidgetItem *currentItem =
nullptr;
208 for (
int i = 0; i < topLevelItemCount; ++i )
210 currentItem = mColormapTreeWidget->topLevelItem( i );
212 if ( !currentItem || currentItem->text( ValueColumn ).isEmpty() )
221 label =
"<= " + currentItem->text( ValueColumn ) + unit;
223 else if ( currentItem->text( ValueColumn ).toDouble() == std::numeric_limits<double>::infinity() )
225 label =
"> " + mColormapTreeWidget->topLevelItem( i - 1 )->text( ValueColumn ) + unit;
229 label = mColormapTreeWidget->topLevelItem( i - 1 )->text( ValueColumn ) +
" - " + currentItem->text( ValueColumn ) + unit;
234 label = currentItem->text( ValueColumn ) + unit;
237 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == label || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
239 currentItem->setText( LabelColumn, label );
240 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
245 void QgsSingleBandPseudoColorRendererWidget::setUnitFromLabels()
249 QStringList allSuffixes;
251 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
252 QTreeWidgetItem *currentItem =
nullptr;
253 for (
int i = 0; i < topLevelItemCount; ++i )
255 currentItem = mColormapTreeWidget->topLevelItem( i );
257 if ( !currentItem || currentItem->text( ValueColumn ).isEmpty() )
266 label =
"<= " + currentItem->text( ValueColumn );
268 else if ( currentItem->text( ValueColumn ).toDouble() == std::numeric_limits<double>::infinity() )
270 label =
"> " + mColormapTreeWidget->topLevelItem( i - 1 )->text( ValueColumn );
274 label = mColormapTreeWidget->topLevelItem( i - 1 )->text( ValueColumn ) +
" - " + currentItem->text( ValueColumn );
279 label = currentItem->text( ValueColumn );
282 if ( currentItem->text( LabelColumn ).startsWith( label ) )
284 allSuffixes.append( currentItem->text( LabelColumn ).mid( label.length() ) );
288 QStringList suffixes = QStringList( allSuffixes );
289 suffixes.removeDuplicates();
292 for (
int i = 0; i < suffixes.count(); ++i )
294 int n = allSuffixes.count( suffixes[i] );
304 mUnitLineEdit->setText( unit );
309 void QgsSingleBandPseudoColorRendererWidget::mAddEntryButton_clicked()
312 newItem->setText( ValueColumn, QStringLiteral(
"0" ) );
313 newItem->setBackground( ColorColumn, QBrush( QColor( Qt::magenta ) ) );
314 newItem->setText( LabelColumn, QString() );
315 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
317 this, &QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited );
318 mColormapTreeWidget->sortItems( ValueColumn, Qt::AscendingOrder );
325 void QgsSingleBandPseudoColorRendererWidget::mDeleteEntryButton_clicked()
327 QList<QTreeWidgetItem *> itemList;
328 itemList = mColormapTreeWidget->selectedItems();
329 if ( itemList.isEmpty() )
334 Q_FOREACH ( QTreeWidgetItem *item, itemList )
345 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
346 if ( !ramp || std::isnan( lineEditValue( mMinLineEdit ) ) || std::isnan( lineEditValue( mMaxLineEdit ) ) )
354 pr->
createShader( ramp.get(),
static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ), static_cast< QgsColorRampShader::ClassificationMode >( mClassificationModeComboBox->currentData().toInt() ), mNumberOfEntriesSpinBox->value(), mClipCheckBox->isChecked(),
minMaxWidget()->
extent() );
360 if ( colorRampShader )
362 mColormapTreeWidget->clear();
364 const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->
colorRampItemList();
365 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin();
366 for ( ; it != colorRampItemList.end(); ++it )
369 newItem->setText( ValueColumn, QString::number( it->value,
'g', 15 ) );
370 newItem->setBackground( ColorColumn, QBrush( it->color ) );
371 newItem->setText( LabelColumn, it->label );
372 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
374 this, &QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited );
376 mClipCheckBox->setChecked( colorRampShader->
clip() );
384 void QgsSingleBandPseudoColorRendererWidget::mClassificationModeComboBox_currentIndexChanged(
int index )
392 void QgsSingleBandPseudoColorRendererWidget::applyColorRamp()
394 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
400 if ( !btnColorRamp->colorRampName().isEmpty() )
404 settings.
setValue( QStringLiteral(
"Raster/defaultPalette" ), btnColorRamp->colorRampName() );
407 bool enableContinuous = ( ramp->count() > 0 );
408 mClassificationModeComboBox->setEnabled( enableContinuous );
409 if ( !enableContinuous )
417 void QgsSingleBandPseudoColorRendererWidget::populateColormapTreeWidget(
const QList<QgsColorRampShader::ColorRampItem> &colorRampItems )
419 mColormapTreeWidget->clear();
420 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin();
421 for ( ; it != colorRampItems.constEnd(); ++it )
424 newItem->setText( ValueColumn, QString::number( it->value,
'g', 15 ) );
425 newItem->setBackground( ColorColumn, QBrush( it->color ) );
426 newItem->setText( LabelColumn, it->label );
427 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
429 this, &QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited );
434 void QgsSingleBandPseudoColorRendererWidget::mLoadFromBandButton_clicked()
441 int bandIndex = mBandComboBox->currentBand();
445 if ( !colorRampList.isEmpty() )
447 populateColormapTreeWidget( colorRampList );
452 QMessageBox::warning(
this, tr(
"Load Color Map" ), tr(
"The color map for band %1 has no entries." ).arg( bandIndex ) );
459 void QgsSingleBandPseudoColorRendererWidget::mLoadFromFileButton_clicked()
462 bool importError =
false;
465 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
466 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Color Map from File" ), lastDir, tr(
"Textfile (*.txt)" ) );
467 QFile inputFile( fileName );
468 if ( inputFile.open( QFile::ReadOnly ) )
471 mColormapTreeWidget->clear();
473 QTextStream inputStream( &inputFile );
475 QStringList inputStringComponents;
476 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
479 while ( !inputStream.atEnd() )
482 inputLine = inputStream.readLine();
483 if ( !inputLine.isEmpty() )
485 if ( !inputLine.simplified().startsWith(
'#' ) )
487 if ( inputLine.contains( QLatin1String(
"INTERPOLATION" ), Qt::CaseInsensitive ) )
489 inputStringComponents = inputLine.split(
':' );
490 if ( inputStringComponents.size() == 2 )
492 if ( inputStringComponents[1].trimmed().toUpper().compare( QLatin1String(
"INTERPOLATED" ), Qt::CaseInsensitive ) == 0 )
496 else if ( inputStringComponents[1].trimmed().toUpper().compare( QLatin1String(
"DISCRETE" ), Qt::CaseInsensitive ) == 0 )
508 badLines = badLines + QString::number( lineCounter ) +
":\t[" + inputLine +
"]\n";
513 inputStringComponents = inputLine.split(
',' );
514 if ( inputStringComponents.size() == 6 )
517 QColor::fromRgb( inputStringComponents[1].toInt(), inputStringComponents[2].toInt(),
518 inputStringComponents[3].toInt(), inputStringComponents[4].toInt() ),
519 inputStringComponents[5] );
520 colorRampItems.push_back( currentItem );
525 badLines = badLines + QString::number( lineCounter ) +
":\t[" + inputLine +
"]\n";
532 populateColormapTreeWidget( colorRampItems );
534 QFileInfo fileInfo( fileName );
535 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
539 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"The following lines contained errors\n\n" ) + badLines );
542 else if ( !fileName.isEmpty() )
544 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"Read access denied. Adjust the file permissions and try again.\n\n" ) );
551 void QgsSingleBandPseudoColorRendererWidget::mExportToFileButton_clicked()
554 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
555 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Color Map as File" ), lastDir, tr(
"Textfile (*.txt)" ) );
556 if ( !fileName.isEmpty() )
558 if ( !fileName.endsWith( QLatin1String(
".txt" ), Qt::CaseInsensitive ) )
560 fileName = fileName +
".txt";
563 QFile outputFile( fileName );
564 if ( outputFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
566 QTextStream outputStream( &outputFile );
567 outputStream <<
"# " << tr(
"QGIS Generated Color Map Export File" ) <<
'\n';
568 outputStream <<
"INTERPOLATION:";
570 switch ( interpolation )
573 outputStream <<
"INTERPOLATED\n";
576 outputStream <<
"DISCRETE\n";
579 outputStream <<
"EXACT\n";
583 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
584 QTreeWidgetItem *currentItem =
nullptr;
586 for (
int i = 0; i < topLevelItemCount; ++i )
588 currentItem = mColormapTreeWidget->topLevelItem( i );
593 color = currentItem->background( ColorColumn ).color();
594 outputStream << currentItem->text( ValueColumn ).toDouble() <<
',';
595 outputStream << color.red() <<
',' << color.green() <<
',' << color.blue() <<
',' << color.alpha() <<
',';
596 if ( currentItem->text( LabelColumn ).isEmpty() )
598 outputStream <<
"Color entry " << i + 1 <<
'\n';
602 outputStream << currentItem->text( LabelColumn ) <<
'\n';
605 outputStream.flush();
608 QFileInfo fileInfo( fileName );
609 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
613 QMessageBox::warning(
this, tr(
"Save Color Map as File" ), tr(
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
618 void QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int column )
625 if ( column == ColorColumn )
627 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
628 QColor newColor =
QgsColorDialog::getColor( item->background( column ).color(),
this, QStringLiteral(
"Change Color" ), true );
629 if ( newColor.isValid() )
631 item->setBackground( ColorColumn, QBrush( newColor ) );
638 if ( column == LabelColumn )
641 item->setForeground( LabelColumn, QBrush() );
643 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
647 void QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *item,
int column )
651 if ( column == ValueColumn )
653 mColormapTreeWidget->sortItems( ValueColumn, Qt::AscendingOrder );
660 else if ( column == LabelColumn )
674 mMinMaxWidget->
setBands( QList< int >() << pr->
band() );
680 if ( colorRampShader )
689 QString defaultPalette = settings.
value( QStringLiteral(
"/Raster/defaultPalette" ),
"Spectral" ).toString();
690 btnColorRamp->setColorRampFromName( defaultPalette );
693 mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( colorRampShader->
colorRampType() ) );
695 const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->
colorRampItemList();
696 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin();
697 for ( ; it != colorRampItemList.end(); ++it )
700 newItem->setText( ValueColumn, QString::number( it->value,
'g', 15 ) );
701 newItem->setBackground( ColorColumn, QBrush( it->color ) );
702 newItem->setText( LabelColumn, it->label );
703 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
705 this, &QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited );
708 mClipCheckBox->setChecked( colorRampShader->
clip() );
710 mClassificationModeComboBox->setCurrentIndex( mClassificationModeComboBox->findData( colorRampShader->
classificationMode() ) );
711 mNumberOfEntriesSpinBox->setValue( colorRampShader->
colorRampItemList().count() );
721 mMinMaxWidget->
setBands( QList< int >() << mBandComboBox->currentBand() );
725 void QgsSingleBandPseudoColorRendererWidget::bandChanged()
728 bands.append( mBandComboBox->currentBand() );
732 void QgsSingleBandPseudoColorRendererWidget::mColorInterpolationComboBox_currentIndexChanged(
int index )
739 QString valueToolTip;
740 switch ( interpolation )
743 valueLabel = tr(
"Value" );
744 valueToolTip = tr(
"Value for color stop" );
747 valueLabel = tr(
"Value <=" );
748 valueToolTip = tr(
"Maximum value for class" );
751 valueLabel = tr(
"Value =" );
752 valueToolTip = tr(
"Value for color" );
756 QTreeWidgetItem *header = mColormapTreeWidget->headerItem();
757 header->setText( ValueColumn, valueLabel );
758 header->setToolTip( ValueColumn, valueToolTip );
767 QgsDebugMsg( QString(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg( min ).arg( max ) );
769 double oldMin = lineEditValue( mMinLineEdit );
770 double oldMax = lineEditValue( mMaxLineEdit );
772 if ( std::isnan( min ) )
778 whileBlocking( mMinLineEdit )->setText( QString::number( min ) );
781 if ( std::isnan( max ) )
787 whileBlocking( mMaxLineEdit )->setText( QString::number( max ) );
790 if ( oldMin != min || oldMax != max )
798 QTreeWidgetItem *item = mColormapTreeWidget->topLevelItem( 0 );
804 double min = item->text( ValueColumn ).toDouble();
805 item = mColormapTreeWidget->topLevelItem( mColormapTreeWidget->topLevelItemCount() - 1 );
806 double max = item->text( ValueColumn ).toDouble();
808 whileBlocking( mMinLineEdit )->setText( QString::number( min ) );
809 whileBlocking( mMaxLineEdit )->setText( QString::number( max ) );
813 void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
816 if ( !std::isnan( value ) )
818 s = QString::number( value );
820 lineEdit->setText( s );
823 double QgsSingleBandPseudoColorRendererWidget::lineEditValue(
const QLineEdit *lineEdit )
const 825 if ( lineEdit->text().isEmpty() )
827 return std::numeric_limits<double>::quiet_NaN();
830 return lineEdit->text().toDouble();
833 void QgsSingleBandPseudoColorRendererWidget::resetClassifyButton()
835 mClassifyButton->setEnabled(
true );
836 double min = lineEditValue( mMinLineEdit );
837 double max = lineEditValue( mMaxLineEdit );
838 if ( std::isnan( min ) || std::isnan( max ) || min >= max )
840 mClassifyButton->setEnabled(
false );
844 void QgsSingleBandPseudoColorRendererWidget::changeColor()
846 QList<QTreeWidgetItem *> itemList;
847 itemList = mColormapTreeWidget->selectedItems();
848 if ( itemList.isEmpty() )
852 QTreeWidgetItem *firstItem = itemList.first();
854 QColor newColor =
QgsColorDialog::getColor( firstItem->background( ColorColumn ).color(),
this, QStringLiteral(
"Change Color" ), true );
855 if ( newColor.isValid() )
857 Q_FOREACH ( QTreeWidgetItem *item, itemList )
859 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
860 item->setBackground( ColorColumn, QBrush( newColor ) );
868 void QgsSingleBandPseudoColorRendererWidget::changeOpacity()
870 QList<QTreeWidgetItem *> itemList;
871 itemList = mColormapTreeWidget->selectedItems();
872 if ( itemList.isEmpty() )
876 QTreeWidgetItem *firstItem = itemList.first();
879 double oldOpacity = firstItem->background( ColorColumn ).color().alpha() / 255 * 100;
880 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change color opacity [%]" ), oldOpacity, 0.0, 100.0, 0, &ok );
883 int newOpacity = opacity / 100 * 255;
884 Q_FOREACH ( QTreeWidgetItem *item, itemList )
886 QColor newColor = item->background( ColorColumn ).color();
887 newColor.setAlpha( newOpacity );
888 item->setBackground( ColorColumn, QBrush( newColor ) );
896 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited(
const QString & )
902 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited(
const QString & )
908 void QgsSingleBandPseudoColorRendererWidget::minMaxModified()
QgsRasterMinMaxOrigin::Limits limits() const
Return limits.
A rectangle specified with double values.
double classificationMin() const
Interface for all raster shaders.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Set custom colormap.
Uses quantile (i.e. equal pixel) count.
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.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QList< QgsColorRampShader::ColorRampItem > colorRampItemList() const
Get the custom colormap.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
QgsRasterRenderer * renderer() const
void setClip(bool clip)
Sets whether the shader should not render values out of range.
QgsRasterShader * shader()
Returns the raster shader.
void setClassificationMax(double max)
Map canvas is a class for displaying all GIS data types on a canvas.
Type
Supported methods for color interpolation.
void setColorRampType(QgsColorRampShader::Type colorRampType)
Set the color ramp type.
QgsRasterDataProvider * dataProvider() override
void setValue(const QString &key, const QVariant &value, const QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
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 setSourceColorRamp(QgsColorRamp *colorramp)
Set the source color ramp.
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
void setLimits(QgsRasterMinMaxOrigin::Limits limits)
Set limits.
Type colorRampType() const
Get the color ramp type.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), const bool allowOpacity=false)
Return a color selection from a color dialog.
void setClassificationMin(double min)
Assigns the color of the exact matching value in the color ramp item list.
Uses breaks from color palette.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
void setClassificationMode(ClassificationMode classificationMode)
Sets classification mode.
bool clip() const
Returns whether the shader will clip values which are out of range.
void setBand(int bandNo)
Sets the band used by the renderer.
Interpolates the color between two class breaks linearly.
void createShader(QgsColorRamp *colorRamp=nullptr, QgsColorRampShader::Type colorRampType=QgsColorRampShader::Interpolated, QgsColorRampShader::ClassificationMode classificationMode=QgsColorRampShader::Continuous, int classes=0, bool clip=false, const QgsRectangle &extent=QgsRectangle())
Creates a color ramp shader.
ClassificationMode
Classification modes used to create the color ramp shader.
Assigns the color of the higher class for every pixel between two class breaks.
ClassificationMode classificationMode() const
Returns the classification mode.
QgsColorRamp * sourceColorRamp() const
Get the source color ramp.
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.