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 ) ) )
352 pr->setClassificationMin( lineEditValue( mMinLineEdit ) );
353 pr->setClassificationMax( lineEditValue( mMaxLineEdit ) );
354 pr->createShader( ramp.release(),
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();
368 newItem->setText( ValueColumn, QString::number( item.value,
'g', 15 ) );
369 newItem->setBackground( ColorColumn, QBrush( item.color ) );
370 newItem->setText( LabelColumn, item.label );
371 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
373 this, &QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited );
375 mClipCheckBox->setChecked( colorRampShader->
clip() );
383 void QgsSingleBandPseudoColorRendererWidget::mClassificationModeComboBox_currentIndexChanged(
int index )
391 void QgsSingleBandPseudoColorRendererWidget::applyColorRamp()
393 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
399 if ( !btnColorRamp->colorRampName().isEmpty() )
403 settings.
setValue( QStringLiteral(
"Raster/defaultPalette" ), btnColorRamp->colorRampName() );
406 bool enableContinuous = ( ramp->count() > 0 );
407 mClassificationModeComboBox->setEnabled( enableContinuous );
408 if ( !enableContinuous )
416 void QgsSingleBandPseudoColorRendererWidget::populateColormapTreeWidget(
const QList<QgsColorRampShader::ColorRampItem> &colorRampItems )
418 mColormapTreeWidget->clear();
419 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin();
420 for ( ; it != colorRampItems.constEnd(); ++it )
423 newItem->setText( ValueColumn, QString::number( it->value,
'g', 15 ) );
424 newItem->setBackground( ColorColumn, QBrush( it->color ) );
425 newItem->setText( LabelColumn, it->label );
426 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
428 this, &QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited );
433 void QgsSingleBandPseudoColorRendererWidget::mLoadFromBandButton_clicked()
440 int bandIndex = mBandComboBox->currentBand();
444 if ( !colorRampList.isEmpty() )
446 populateColormapTreeWidget( colorRampList );
451 QMessageBox::warning(
this, tr(
"Load Color Map" ), tr(
"The color map for band %1 has no entries." ).arg( bandIndex ) );
458 void QgsSingleBandPseudoColorRendererWidget::mLoadFromFileButton_clicked()
461 bool importError =
false;
464 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
465 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Color Map from File" ), lastDir, tr(
"Textfile (*.txt)" ) );
466 QFile inputFile( fileName );
467 if ( inputFile.open( QFile::ReadOnly ) )
470 mColormapTreeWidget->clear();
472 QTextStream inputStream( &inputFile );
474 QStringList inputStringComponents;
475 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
478 while ( !inputStream.atEnd() )
481 inputLine = inputStream.readLine();
482 if ( !inputLine.isEmpty() )
484 if ( !inputLine.simplified().startsWith(
'#' ) )
486 if ( inputLine.contains( QLatin1String(
"INTERPOLATION" ), Qt::CaseInsensitive ) )
488 inputStringComponents = inputLine.split(
':' );
489 if ( inputStringComponents.size() == 2 )
491 if ( inputStringComponents[1].trimmed().toUpper().compare( QLatin1String(
"INTERPOLATED" ), Qt::CaseInsensitive ) == 0 )
495 else if ( inputStringComponents[1].trimmed().toUpper().compare( QLatin1String(
"DISCRETE" ), Qt::CaseInsensitive ) == 0 )
507 badLines = badLines + QString::number( lineCounter ) +
":\t[" + inputLine +
"]\n";
512 inputStringComponents = inputLine.split(
',' );
513 if ( inputStringComponents.size() == 6 )
516 QColor::fromRgb( inputStringComponents[1].toInt(), inputStringComponents[2].toInt(),
517 inputStringComponents[3].toInt(), inputStringComponents[4].toInt() ),
518 inputStringComponents[5] );
519 colorRampItems.push_back( currentItem );
524 badLines = badLines + QString::number( lineCounter ) +
":\t[" + inputLine +
"]\n";
531 populateColormapTreeWidget( colorRampItems );
533 QFileInfo fileInfo( fileName );
534 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
538 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"The following lines contained errors\n\n" ) + badLines );
541 else if ( !fileName.isEmpty() )
543 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"Read access denied. Adjust the file permissions and try again.\n\n" ) );
550 void QgsSingleBandPseudoColorRendererWidget::mExportToFileButton_clicked()
553 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
554 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Color Map as File" ), lastDir, tr(
"Textfile (*.txt)" ) );
555 if ( !fileName.isEmpty() )
557 if ( !fileName.endsWith( QLatin1String(
".txt" ), Qt::CaseInsensitive ) )
559 fileName = fileName +
".txt";
562 QFile outputFile( fileName );
563 if ( outputFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
565 QTextStream outputStream( &outputFile );
566 outputStream <<
"# " << tr(
"QGIS Generated Color Map Export File" ) <<
'\n';
567 outputStream <<
"INTERPOLATION:";
569 switch ( interpolation )
572 outputStream <<
"INTERPOLATED\n";
575 outputStream <<
"DISCRETE\n";
578 outputStream <<
"EXACT\n";
582 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
583 QTreeWidgetItem *currentItem =
nullptr;
585 for (
int i = 0; i < topLevelItemCount; ++i )
587 currentItem = mColormapTreeWidget->topLevelItem( i );
592 color = currentItem->background( ColorColumn ).color();
593 outputStream << currentItem->text( ValueColumn ).toDouble() <<
',';
594 outputStream << color.red() <<
',' << color.green() <<
',' << color.blue() <<
',' << color.alpha() <<
',';
595 if ( currentItem->text( LabelColumn ).isEmpty() )
597 outputStream <<
"Color entry " << i + 1 <<
'\n';
601 outputStream << currentItem->text( LabelColumn ) <<
'\n';
604 outputStream.flush();
607 QFileInfo fileInfo( fileName );
608 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
612 QMessageBox::warning(
this, tr(
"Save Color Map as File" ), tr(
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
617 void QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int column )
624 if ( column == ColorColumn )
626 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
627 QColor newColor =
QgsColorDialog::getColor( item->background( column ).color(),
this, QStringLiteral(
"Change Color" ), true );
628 if ( newColor.isValid() )
630 item->setBackground( ColorColumn, QBrush( newColor ) );
637 if ( column == LabelColumn )
640 item->setForeground( LabelColumn, QBrush() );
642 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
646 void QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *item,
int column )
650 if ( column == ValueColumn )
652 mColormapTreeWidget->sortItems( ValueColumn, Qt::AscendingOrder );
659 else if ( column == LabelColumn )
673 mMinMaxWidget->
setBands( QList< int >() << pr->
band() );
679 if ( colorRampShader )
688 QString defaultPalette = settings.
value( QStringLiteral(
"/Raster/defaultPalette" ),
"Spectral" ).toString();
689 btnColorRamp->setColorRampFromName( defaultPalette );
692 mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( colorRampShader->
colorRampType() ) );
694 const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->
colorRampItemList();
695 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin();
696 for ( ; it != colorRampItemList.end(); ++it )
699 newItem->setText( ValueColumn, QString::number( it->value,
'g', 15 ) );
700 newItem->setBackground( ColorColumn, QBrush( it->color ) );
701 newItem->setText( LabelColumn, it->label );
702 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
704 this, &QgsSingleBandPseudoColorRendererWidget::mColormapTreeWidget_itemEdited );
707 mClipCheckBox->setChecked( colorRampShader->
clip() );
709 mClassificationModeComboBox->setCurrentIndex( mClassificationModeComboBox->findData( colorRampShader->
classificationMode() ) );
710 mNumberOfEntriesSpinBox->setValue( colorRampShader->
colorRampItemList().count() );
720 mMinMaxWidget->
setBands( QList< int >() << mBandComboBox->currentBand() );
724 void QgsSingleBandPseudoColorRendererWidget::bandChanged()
727 bands.append( mBandComboBox->currentBand() );
731 void QgsSingleBandPseudoColorRendererWidget::mColorInterpolationComboBox_currentIndexChanged(
int index )
738 QString valueToolTip;
739 switch ( interpolation )
742 valueLabel = tr(
"Value" );
743 valueToolTip = tr(
"Value for color stop" );
746 valueLabel = tr(
"Value <=" );
747 valueToolTip = tr(
"Maximum value for class" );
750 valueLabel = tr(
"Value =" );
751 valueToolTip = tr(
"Value for color" );
755 QTreeWidgetItem *header = mColormapTreeWidget->headerItem();
756 header->setText( ValueColumn, valueLabel );
757 header->setToolTip( ValueColumn, valueToolTip );
766 QgsDebugMsg( QString(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg( min ).arg( max ) );
768 double oldMin = lineEditValue( mMinLineEdit );
769 double oldMax = lineEditValue( mMaxLineEdit );
771 if ( std::isnan( min ) )
777 whileBlocking( mMinLineEdit )->setText( QString::number( min ) );
780 if ( std::isnan( max ) )
786 whileBlocking( mMaxLineEdit )->setText( QString::number( max ) );
789 if ( oldMin != min || oldMax != max )
797 QTreeWidgetItem *item = mColormapTreeWidget->topLevelItem( 0 );
803 double min = item->text( ValueColumn ).toDouble();
804 item = mColormapTreeWidget->topLevelItem( mColormapTreeWidget->topLevelItemCount() - 1 );
805 double max = item->text( ValueColumn ).toDouble();
807 whileBlocking( mMinLineEdit )->setText( QString::number( min ) );
808 whileBlocking( mMaxLineEdit )->setText( QString::number( max ) );
812 void QgsSingleBandPseudoColorRendererWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
815 if ( !std::isnan( value ) )
817 s = QString::number( value );
819 lineEdit->setText( s );
822 double QgsSingleBandPseudoColorRendererWidget::lineEditValue(
const QLineEdit *lineEdit )
const 824 if ( lineEdit->text().isEmpty() )
826 return std::numeric_limits<double>::quiet_NaN();
829 return lineEdit->text().toDouble();
832 void QgsSingleBandPseudoColorRendererWidget::resetClassifyButton()
834 mClassifyButton->setEnabled(
true );
835 double min = lineEditValue( mMinLineEdit );
836 double max = lineEditValue( mMaxLineEdit );
837 if ( std::isnan( min ) || std::isnan( max ) || min >= max )
839 mClassifyButton->setEnabled(
false );
843 void QgsSingleBandPseudoColorRendererWidget::changeColor()
845 QList<QTreeWidgetItem *> itemList;
846 itemList = mColormapTreeWidget->selectedItems();
847 if ( itemList.isEmpty() )
851 QTreeWidgetItem *firstItem = itemList.first();
853 QColor newColor =
QgsColorDialog::getColor( firstItem->background( ColorColumn ).color(),
this, QStringLiteral(
"Change Color" ), true );
854 if ( newColor.isValid() )
856 Q_FOREACH ( QTreeWidgetItem *item, itemList )
858 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
859 item->setBackground( ColorColumn, QBrush( newColor ) );
867 void QgsSingleBandPseudoColorRendererWidget::changeOpacity()
869 QList<QTreeWidgetItem *> itemList;
870 itemList = mColormapTreeWidget->selectedItems();
871 if ( itemList.isEmpty() )
875 QTreeWidgetItem *firstItem = itemList.first();
878 double oldOpacity = firstItem->background( ColorColumn ).color().alpha() / 255 * 100;
879 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change color opacity [%]" ), oldOpacity, 0.0, 100.0, 0, &ok );
882 int newOpacity = opacity / 100 * 255;
883 Q_FOREACH ( QTreeWidgetItem *item, itemList )
885 QColor newColor = item->background( ColorColumn ).color();
886 newColor.setAlpha( newOpacity );
887 item->setBackground( ColorColumn, QBrush( newColor ) );
895 void QgsSingleBandPseudoColorRendererWidget::mMinLineEdit_textEdited(
const QString & )
901 void QgsSingleBandPseudoColorRendererWidget::mMaxLineEdit_textEdited(
const QString & )
907 void QgsSingleBandPseudoColorRendererWidget::minMaxModified()
QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits.
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), bool allowOpacity=false)
Returns a color selection from a color dialog.
A rectangle specified with double values.
double classificationMin() const
Interface for all raster shaders.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a 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
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QList< QgsColorRampShader::ColorRampItem > colorRampItemList() const
Returns 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)
Sets the color ramp type.
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider.
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)
Sets the limits.
Type colorRampType() const
Returns the color ramp type.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
void setClassificationMin(double min)
Assigns the color of the exact matching value in the color ramp item list.
Uses breaks from color palette.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
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.
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
Gets 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.