34#include <QInputDialog>
41#include "moc_qgscolorrampshaderwidget.cpp"
49 mLoadFromBandButton->setVisible(
false );
51 connect( mAddEntryButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mAddEntryButton_clicked );
52 connect( mDeleteEntryButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mDeleteEntryButton_clicked );
53 connect( mLoadFromBandButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mLoadFromBandButton_clicked );
54 connect( mLoadFromFileButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mLoadFromFileButton_clicked );
55 connect( mExportToFileButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mExportToFileButton_clicked );
56 connect( mUnitLineEdit, &QLineEdit::textEdited,
this, &QgsColorRampShaderWidget::mUnitLineEdit_textEdited );
57 connect( mColormapTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemDoubleClicked );
58 connect( mColorInterpolationComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampShaderWidget::mColorInterpolationComboBox_currentIndexChanged );
59 connect( mClassificationModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampShaderWidget::mClassificationModeComboBox_currentIndexChanged );
61 connect( mLegendSettingsButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::showLegendSettings );
63 contextMenu =
new QMenu( tr(
"Options" ),
this );
64 contextMenu->addAction( tr(
"Change Color…" ),
this, &QgsColorRampShaderWidget::changeColor );
65 contextMenu->addAction( tr(
"Change Opacity…" ),
this, &QgsColorRampShaderWidget::changeOpacity );
69 mColormapTreeWidget->setItemDelegateForColumn( ValueColumn, mValueDelegate );
71 mColormapTreeWidget->setColumnWidth( ColorColumn,
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 6.6 );
73 mColormapTreeWidget->setContextMenuPolicy( Qt::CustomContextMenu );
74 mColormapTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
75 connect( mColormapTreeWidget, &QTreeView::customContextMenuRequested,
this, [
this]( QPoint ) { contextMenu->exec( QCursor::pos() ); } );
77 QString defaultPalette = settings.
value( QStringLiteral(
"Raster/defaultPalette" ),
"" ).toString();
78 btnColorRamp->setColorRampFromName( defaultPalette );
90 mNumberOfEntriesSpinBox->setValue( 5 );
92 mClassificationModeComboBox_currentIndexChanged( 0 );
94 resetClassifyButton();
102 connect( mLabelPrecisionSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int ) {
105 if ( !mBlockChanges )
120 mRasterDataProvider = dp;
121 mLoadFromBandButton->setVisible(
static_cast<bool>( mRasterDataProvider ) );
132 mLabelPrecisionSpinBox->setMaximum( maxDigits );
133 mValueDelegate->setDataType( dataType );
147 colorRampShader.
setClip( mClipCheckBox->isChecked() );
150 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
151 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
152 QTreeWidgetItem *currentItem =
nullptr;
153 for (
int i = 0; i < topLevelItemCount; ++i )
155 currentItem = mColormapTreeWidget->topLevelItem( i );
161 newColorRampItem.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
162 newColorRampItem.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
163 newColorRampItem.
label = currentItem->text( LabelColumn );
164 colorRampItems.append( newColorRampItem );
167 std::sort( colorRampItems.begin(), colorRampItems.end() );
170 if ( !btnColorRamp->isNull() )
176 return colorRampShader;
179void QgsColorRampShaderWidget::autoLabel()
181 mColormapTreeWidget->sortItems( ValueColumn, Qt::AscendingOrder );
187 const QString unit = mUnitLineEdit->text();
188 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
190 QTreeWidgetItem *currentItem =
nullptr;
191 for (
int i = 0; i < topLevelItemCount; ++i )
193 currentItem = mColormapTreeWidget->topLevelItem( i );
195 if ( !currentItem || currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString().isEmpty() )
200 const QString lbl = createLabel( currentItem, i, unit );
202 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
204 currentItem->setText( LabelColumn, lbl );
205 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
210void QgsColorRampShaderWidget::setUnitFromLabels()
212 QStringList allSuffixes;
214 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
215 QTreeWidgetItem *currentItem =
nullptr;
216 for (
int i = 0; i < topLevelItemCount; ++i )
218 currentItem = mColormapTreeWidget->topLevelItem( i );
220 if ( !currentItem || currentItem->text( ValueColumn ).isEmpty() )
225 label = createLabel( currentItem, i, QString() );
227 if ( currentItem->text( LabelColumn ).startsWith( label ) )
229 allSuffixes.append( currentItem->text( LabelColumn ).mid( label.length() ) );
233 QStringList suffixes = QStringList( allSuffixes );
234 suffixes.removeDuplicates();
237 for (
int i = 0; i < suffixes.count(); ++i )
239 int n = allSuffixes.count( suffixes[i] );
249 mUnitLineEdit->setText( unit );
254void QgsColorRampShaderWidget::dumpClasses()
256 for (
int row = 0; row < mColormapTreeWidget->model()->rowCount(); ++row )
258 const auto labelData { mColormapTreeWidget->model()->itemData( mColormapTreeWidget->model()->index( row, LabelColumn ) ) };
259 const auto valueData { mColormapTreeWidget->model()->itemData( mColormapTreeWidget->model()->index( row, ValueColumn ) ) };
260 QgsDebugMsgLevel( QStringLiteral(
"Class %1 : %2 %3" ).arg( row ).arg( labelData[Qt::ItemDataRole::DisplayRole].toString(), valueData[Qt::ItemDataRole::DisplayRole].toString() ), 2 );
265void QgsColorRampShaderWidget::mAddEntryButton_clicked()
267 QgsTreeWidgetItemObject *newItem =
new QgsTreeWidgetItemObject( mColormapTreeWidget );
268 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, 0 );
269 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, QColor( Qt::magenta ) );
270 newItem->setText( LabelColumn, QString() );
271 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
280void QgsColorRampShaderWidget::mDeleteEntryButton_clicked()
282 QList<QTreeWidgetItem *> itemList;
283 itemList = mColormapTreeWidget->selectedItems();
284 if ( itemList.isEmpty() )
289 const auto constItemList = itemList;
290 for ( QTreeWidgetItem *item : constItemList )
302 std::unique_ptr<QgsColorRamp> ramp( btnColorRamp->colorRamp() );
303 if ( !ramp || std::isnan( mMin ) || std::isnan( mMax ) )
317 colorRampShader->classifyColorRamp( mNumberOfEntriesSpinBox->value(), mBand, mExtent, mRasterDataProvider );
318 colorRampShader->setClip( mClipCheckBox->isChecked() );
320 mColormapTreeWidget->clear();
322 const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->colorRampItemList();
323 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin();
324 for ( ; it != colorRampItemList.end(); ++it )
327 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
328 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
329 newItem->setText( LabelColumn, QString() );
330 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
334 mClipCheckBox->setChecked( colorRampShader->clip() );
340void QgsColorRampShaderWidget::mClassificationModeComboBox_currentIndexChanged(
int index )
347void QgsColorRampShaderWidget::updateColorRamp()
349 std::unique_ptr<QgsColorRamp> ramp(
shader().createColorRamp() );
353void QgsColorRampShaderWidget::applyColorRamp()
355 std::unique_ptr<QgsColorRamp> ramp( btnColorRamp->colorRamp() );
361 if ( !btnColorRamp->colorRampName().isEmpty() )
364 QgsSettings settings;
365 settings.
setValue( QStringLiteral(
"Raster/defaultPalette" ), btnColorRamp->colorRampName() );
368 bool enableContinuous = ( ramp->count() > 0 );
369 mClassificationModeComboBox->setEnabled( enableContinuous );
370 if ( !enableContinuous )
375 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
376 if ( topLevelItemCount > 0 )
380 if ( std::isnan( mMin ) || std::isnan( mMax ) )
382 colormapMinMax( min, max );
391 QTreeWidgetItem *currentItem =
nullptr;
392 for (
int i = 0; i < topLevelItemCount; ++i )
394 currentItem = mColormapTreeWidget->topLevelItem( i );
400 double value = currentItem->data( ValueColumn, Qt::ItemDataRole::EditRole ).toDouble();
401 double position = ( value - min ) / ( max - min );
402 whileBlocking(
static_cast<QgsTreeWidgetItemObject *
>( currentItem ) )->setData( ColorColumn, Qt::ItemDataRole::EditRole, ramp->color( position ) );
415 mColormapTreeWidget->clear();
416 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin();
418 for ( ; it != colorRampItems.constEnd(); ++it )
421 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
422 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
423 newItem->setText( LabelColumn, it->label );
424 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
436 const QString unit = mUnitLineEdit->text();
437 for ( i = 0; i < mColormapTreeWidget->topLevelItemCount(); i++ )
440 QString lbl { createLabel( currentItem, i, unit ) };
441 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
443 currentItem->setText( LabelColumn, lbl );
444 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
449void QgsColorRampShaderWidget::mLoadFromBandButton_clicked()
451 if ( !mRasterDataProvider )
454 QList<QgsColorRampShader::ColorRampItem> colorRampList = mRasterDataProvider->colorTable( mBand );
455 if ( !colorRampList.isEmpty() )
462 QMessageBox::warning(
this, tr(
"Load Color Map" ), tr(
"The color map for band %1 has no entries." ).arg( mBand ) );
468void QgsColorRampShaderWidget::mLoadFromFileButton_clicked()
470 QgsSettings settings;
471 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
472 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Color Map from File" ), lastDir, tr(
"Textfile (*.txt)" ) );
473 if ( fileName.isEmpty() )
476 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
482 mColormapTreeWidget->clear();
484 mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( type ) ) );
488 if ( !errors.empty() )
490 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"The following lines contained errors\n\n" ) + errors.join(
'\n' ) );
495 const QString error = tr(
"An error occurred while reading the color map\n\n" ) + errors.join(
'\n' );
496 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), error );
499 QFileInfo fileInfo( fileName );
500 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
507void QgsColorRampShaderWidget::mExportToFileButton_clicked()
509 QgsSettings settings;
510 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
511 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Color Map as File" ), lastDir, tr(
"Textfile (*.txt)" ) );
512 if ( fileName.isEmpty() )
517 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
518 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
519 for (
int i = 0; i < topLevelItemCount; ++i )
521 QTreeWidgetItem *currentItem = mColormapTreeWidget->topLevelItem( i );
527 QgsColorRampShader::ColorRampItem item;
528 item.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
529 item.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
530 item.
label = currentItem->text( LabelColumn );
531 colorRampItems << item;
536 QMessageBox::warning(
this, tr(
"Save Color Map as File" ), tr(
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
539 QFileInfo fileInfo( fileName );
540 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
543void QgsColorRampShaderWidget::mUnitLineEdit_textEdited(
const QString & )
547 if ( !mBlockChanges )
551void QgsColorRampShaderWidget::mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int column )
558 if ( column == LabelColumn )
561 item->setForeground( LabelColumn, QBrush() );
565void QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *item,
int column )
605 whileBlocking( mColorInterpolationComboBox )->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( colorRampShader.
colorRampType() ) ) );
606 mColorInterpolationComboBox_currentIndexChanged( mColorInterpolationComboBox->currentIndex() );
607 whileBlocking( mClassificationModeComboBox )->setCurrentIndex( mClassificationModeComboBox->findData( QVariant::fromValue( colorRampShader.
classificationMode() ) ) );
608 mClassificationModeComboBox_currentIndexChanged( mClassificationModeComboBox->currentIndex() );
618 QString defaultPalette = settings.
value( QStringLiteral(
"/Raster/defaultPalette" ),
"Spectral" ).toString();
619 btnColorRamp->setColorRampFromName( defaultPalette );
622 mLabelPrecisionSpinBox->setValue( colorRampShader.
labelPrecision() );
633void QgsColorRampShaderWidget::mColorInterpolationComboBox_currentIndexChanged(
int index )
640 QString valueToolTip;
641 switch ( interpolation )
644 valueLabel = tr(
"Value" );
645 valueToolTip = tr(
"Value for color stop" );
646 mLegendSettingsButton->setEnabled(
true );
649 valueLabel = tr(
"Value <=" );
650 valueToolTip = tr(
"Maximum value for class" );
651 mLegendSettingsButton->setEnabled(
false );
654 valueLabel = tr(
"Value =" );
655 valueToolTip = tr(
"Value for color" );
656 mLegendSettingsButton->setEnabled(
false );
660 QTreeWidgetItem *header = mColormapTreeWidget->headerItem();
661 header->setText( ValueColumn, valueLabel );
662 header->setToolTip( ValueColumn, valueToolTip );
681 resetClassifyButton();
694bool QgsColorRampShaderWidget::colormapMinMax(
double &min,
double &max )
const
696 QTreeWidgetItem *item = mColormapTreeWidget->topLevelItem( 0 );
711 min = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
712 item = mColormapTreeWidget->topLevelItem( mColormapTreeWidget->topLevelItemCount() - 1 );
713 max = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
720 double min = 0, max = 0;
721 if ( !colormapMinMax( min, max ) )
734void QgsColorRampShaderWidget::resetClassifyButton()
736 mClassifyButton->setEnabled(
true );
737 if ( std::isnan( mMin ) || std::isnan( mMax ) || mMin >= mMax )
739 mClassifyButton->setEnabled(
false );
743QString QgsColorRampShaderWidget::createLabel( QTreeWidgetItem *currentItem,
int row,
const QString unit )
745 auto applyPrecision = [
this](
const QString &value ) {
746 double val { value.toDouble() };
761 return QLocale().toString( std::round( val ),
'f', 0 );
766 if ( mLabelPrecisionSpinBox->value() < 0 )
768 const double factor = std::pow( 10, -mLabelPrecisionSpinBox->value() );
769 val =
static_cast<qlonglong
>( val / factor ) * factor;
770 return QLocale().toString( val,
'f', 0 );
772 return QLocale().toString( val,
'f', mLabelPrecisionSpinBox->value() );
778 if ( mLabelPrecisionSpinBox->value() < 0 )
780 const double factor = std::pow( 10, -mLabelPrecisionSpinBox->value() );
781 val =
static_cast<qlonglong
>( val / factor ) * factor;
782 return QLocale().toString( val,
'f', 0 );
784 return QLocale().toString( val,
'f', mLabelPrecisionSpinBox->value() );
798 lbl =
"<= " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
800 else if ( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble() == std::numeric_limits<double>::infinity() )
802 lbl =
"> " + applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
806 lbl = applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) +
" - " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
811 lbl = applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
817void QgsColorRampShaderWidget::changeColor()
819 QList<QTreeWidgetItem *> itemList;
820 itemList = mColormapTreeWidget->selectedItems();
821 if ( itemList.isEmpty() )
825 QTreeWidgetItem *firstItem = itemList.first();
827 QColor currentColor = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
829 if ( panel && panel->dockMode() )
835 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
837 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
843 panel->openPanel( colorWidget );
849 if ( newColor.isValid() )
851 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
853 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
862void QgsColorRampShaderWidget::changeOpacity()
864 QList<QTreeWidgetItem *> itemList;
865 itemList = mColormapTreeWidget->selectedItems();
866 if ( itemList.isEmpty() )
870 QTreeWidgetItem *firstItem = itemList.first();
873 double oldOpacity = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>().alpha() / 255 * 100;
874 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change color opacity [%]" ), oldOpacity, 0.0, 100.0, 0, &ok );
877 int newOpacity =
static_cast<int>( opacity / 100 * 255 );
878 const auto constItemList = itemList;
879 for ( QTreeWidgetItem *item : constItemList )
881 QColor newColor = item->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
882 newColor.setAlpha( newOpacity );
883 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
891void QgsColorRampShaderWidget::showLegendSettings()
896 QgsColorRampLegendNodeWidget *legendPanel =
new QgsColorRampLegendNodeWidget();
900 mLegendSettings = legendPanel->
settings();
907 QgsColorRampLegendNodeDialog dialog( mLegendSettings,
this );
908 dialog.setWindowTitle( tr(
"Legend Settings" ) );
911 mLegendSettings = dialog.settings();
ShaderInterpolationMethod
Color ramp shader interpolation methods.
@ Exact
Assigns the color of the exact matching value in the color ramp item list.
@ Linear
Interpolates the color between two class breaks linearly.
@ Discrete
Assigns the color of the higher class for every pixel between two class breaks.
ShaderClassificationMethod
Color ramp shader classification methods.
@ Continuous
Uses breaks from color palette.
@ Quantile
Uses quantile (i.e. equal pixel) count.
@ EqualInterval
Uses equal interval.
DataType
Raster data types.
@ Float32
Thirty two bit floating point (float).
@ CFloat64
Complex Float64.
@ Int16
Sixteen bit signed integer (qint16).
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
@ Int8
Eight bit signed integer (qint8) (added in QGIS 3.30).
@ UInt16
Sixteen bit unsigned integer (quint16).
@ Byte
Eight bit unsigned integer (quint8).
@ UnknownDataType
Unknown or unspecified type.
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
@ Int32
Thirty two bit signed integer (qint32).
@ Float64
Sixty four bit floating point (double).
@ CFloat32
Complex Float32.
@ UInt32
Thirty two bit unsigned integer (quint32).
static const double UI_SCALE_FACTOR
UI scaling factor.
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), bool allowOpacity=false)
Returns a color selection from a color dialog.
Settings for a color ramp legend node.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Qgis::ShaderClassificationMethod classificationMode() const
Returns the classification mode.
Qgis::ShaderInterpolationMethod colorRampType() const
Returns the color ramp interpolation method.
const QgsColorRampLegendNodeSettings * legendSettings() const
Returns the color ramp shader legend settings.
void setSourceColorRamp(QgsColorRamp *colorramp)
Set the source color ramp.
void setClassificationMode(Qgis::ShaderClassificationMethod classificationMode)
Sets the classification mode.
QList< QgsColorRampShader::ColorRampItem > colorRampItemList() const
Returns the custom color map.
void setClip(bool clip)
Sets whether the shader should not render values out of range.
bool clip() const
Returns whether the shader will clip values which are out of range.
QgsColorRamp * sourceColorRamp() const
Returns the source color ramp.
void setColorRampType(Qgis::ShaderInterpolationMethod colorRampType)
Sets the color ramp interpolation method.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a custom color map.
void setLegendSettings(QgsColorRampLegendNodeSettings *settings)
Sets the color ramp shader legend settings.
A delegate for showing a color swatch in a list.
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
Base class for raster data providers.
static bool saveColorMapFile(const QString &path, const QList< QgsColorRampShader::ColorRampItem > &items, Qgis::ShaderInterpolationMethod type)
Exports a list of color ramp items and ramp shader type to a color map file at the specified path.
static bool parseColorMapFile(const QString &path, QList< QgsColorRampShader::ColorRampItem > &items, Qgis::ShaderInterpolationMethod &type, QStringList &errors)
Parses an exported color map file at the specified path and extracts the stored color ramp items and ...
void setLabelPrecision(int labelPrecision)
Sets label precision to labelPrecision.
int labelPrecision() const
Returns label precision.
A rectangle specified with double values.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
int significantDigits(const Qgis::DataType rasterDataType)
Returns the maximum number of significant digits a for the given rasterDataType.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
#define QgsDebugMsgLevel(str, level)