34#include <QInputDialog>
42#include "moc_qgscolorrampshaderwidget.cpp"
44using namespace Qt::StringLiterals;
52 mLoadFromBandButton->setVisible(
false );
54 connect( mAddEntryButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mAddEntryButton_clicked );
55 connect( mDeleteEntryButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mDeleteEntryButton_clicked );
56 connect( mLoadFromBandButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mLoadFromBandButton_clicked );
57 connect( mLoadFromFileButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mLoadFromFileButton_clicked );
58 connect( mExportToFileButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mExportToFileButton_clicked );
59 connect( mUnitLineEdit, &QLineEdit::textEdited,
this, &QgsColorRampShaderWidget::mUnitLineEdit_textEdited );
60 connect( mColormapTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemDoubleClicked );
61 connect( mColorInterpolationComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampShaderWidget::mColorInterpolationComboBox_currentIndexChanged );
62 connect( mClassificationModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampShaderWidget::mClassificationModeComboBox_currentIndexChanged );
64 connect( mLegendSettingsButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::showLegendSettings );
66 contextMenu =
new QMenu( tr(
"Options" ),
this );
67 contextMenu->addAction( tr(
"Change Color…" ),
this, &QgsColorRampShaderWidget::changeColor );
68 contextMenu->addAction( tr(
"Change Opacity…" ),
this, &QgsColorRampShaderWidget::changeOpacity );
72 mColormapTreeWidget->setItemDelegateForColumn( ValueColumn, mValueDelegate );
74 mColormapTreeWidget->setColumnWidth( ColorColumn,
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 6.6 );
76 mColormapTreeWidget->setContextMenuPolicy( Qt::CustomContextMenu );
77 mColormapTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
78 connect( mColormapTreeWidget, &QTreeView::customContextMenuRequested,
this, [
this]( QPoint ) { contextMenu->exec( QCursor::pos() ); } );
80 QString defaultPalette = settings.
value( u
"Raster/defaultPalette"_s,
"" ).toString();
81 btnColorRamp->setColorRampFromName( defaultPalette );
93 mNumberOfEntriesSpinBox->setValue( 5 );
95 mClassificationModeComboBox_currentIndexChanged( 0 );
97 resetClassifyButton();
105 connect( mLabelPrecisionSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int ) {
108 if ( !mBlockChanges )
123 mRasterDataProvider = dp;
124 mLoadFromBandButton->setVisible(
static_cast<bool>( mRasterDataProvider ) );
135 mLabelPrecisionSpinBox->setMaximum( maxDigits );
136 mValueDelegate->setDataType( dataType );
150 colorRampShader.
setClip( mClipCheckBox->isChecked() );
153 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
154 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
155 QTreeWidgetItem *currentItem =
nullptr;
156 for (
int i = 0; i < topLevelItemCount; ++i )
158 currentItem = mColormapTreeWidget->topLevelItem( i );
164 newColorRampItem.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
165 newColorRampItem.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
166 newColorRampItem.
label = currentItem->text( LabelColumn );
167 colorRampItems.append( newColorRampItem );
170 std::sort( colorRampItems.begin(), colorRampItems.end() );
173 if ( !btnColorRamp->isNull() )
179 return colorRampShader;
182void QgsColorRampShaderWidget::autoLabel()
184 mColormapTreeWidget->sortItems( ValueColumn, Qt::AscendingOrder );
190 const QString unit = mUnitLineEdit->text();
191 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
193 QTreeWidgetItem *currentItem =
nullptr;
194 for (
int i = 0; i < topLevelItemCount; ++i )
196 currentItem = mColormapTreeWidget->topLevelItem( i );
198 if ( !currentItem || currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString().isEmpty() )
203 const QString lbl = createLabel( currentItem, i, unit );
205 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
207 currentItem->setText( LabelColumn, lbl );
208 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
213void QgsColorRampShaderWidget::setUnitFromLabels()
215 QStringList allSuffixes;
217 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
218 QTreeWidgetItem *currentItem =
nullptr;
219 for (
int i = 0; i < topLevelItemCount; ++i )
221 currentItem = mColormapTreeWidget->topLevelItem( i );
223 if ( !currentItem || currentItem->text( ValueColumn ).isEmpty() )
228 label = createLabel( currentItem, i, QString() );
230 if ( currentItem->text( LabelColumn ).startsWith( label ) )
232 allSuffixes.append( currentItem->text( LabelColumn ).mid( label.length() ) );
236 QStringList suffixes = QStringList( allSuffixes );
237 suffixes.removeDuplicates();
240 for (
int i = 0; i < suffixes.count(); ++i )
242 int n = allSuffixes.count( suffixes[i] );
252 mUnitLineEdit->setText( unit );
257void QgsColorRampShaderWidget::dumpClasses()
259 for (
int row = 0; row < mColormapTreeWidget->model()->rowCount(); ++row )
261 const auto labelData { mColormapTreeWidget->model()->itemData( mColormapTreeWidget->model()->index( row, LabelColumn ) ) };
262 const auto valueData { mColormapTreeWidget->model()->itemData( mColormapTreeWidget->model()->index( row, ValueColumn ) ) };
263 QgsDebugMsgLevel( u
"Class %1 : %2 %3"_s.arg( row ).arg( labelData[Qt::ItemDataRole::DisplayRole].toString(), valueData[Qt::ItemDataRole::DisplayRole].toString() ), 2 );
268void QgsColorRampShaderWidget::mAddEntryButton_clicked()
270 QgsTreeWidgetItemObject *newItem =
new QgsTreeWidgetItemObject( mColormapTreeWidget );
271 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, 0 );
272 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, QColor( Qt::magenta ) );
273 newItem->setText( LabelColumn, QString() );
274 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
283void QgsColorRampShaderWidget::mDeleteEntryButton_clicked()
285 QList<QTreeWidgetItem *> itemList;
286 itemList = mColormapTreeWidget->selectedItems();
287 if ( itemList.isEmpty() )
292 const auto constItemList = itemList;
293 for ( QTreeWidgetItem *item : constItemList )
305 std::unique_ptr<QgsColorRamp> ramp( btnColorRamp->colorRamp() );
306 if ( !ramp || std::isnan( mMin ) || std::isnan( mMax ) )
320 colorRampShader->classifyColorRamp( mNumberOfEntriesSpinBox->value(), mBand, mExtent, mRasterDataProvider );
321 colorRampShader->setClip( mClipCheckBox->isChecked() );
323 mColormapTreeWidget->clear();
325 const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->colorRampItemList();
326 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin();
327 for ( ; it != colorRampItemList.end(); ++it )
330 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
331 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
332 newItem->setText( LabelColumn, QString() );
333 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
337 mClipCheckBox->setChecked( colorRampShader->clip() );
343void QgsColorRampShaderWidget::mClassificationModeComboBox_currentIndexChanged(
int index )
350void QgsColorRampShaderWidget::updateColorRamp()
352 std::unique_ptr<QgsColorRamp> ramp(
shader().createColorRamp() );
356void QgsColorRampShaderWidget::applyColorRamp()
358 std::unique_ptr<QgsColorRamp> ramp( btnColorRamp->colorRamp() );
364 if ( !btnColorRamp->colorRampName().isEmpty() )
367 QgsSettings settings;
368 settings.
setValue( u
"Raster/defaultPalette"_s, btnColorRamp->colorRampName() );
371 bool enableContinuous = ( ramp->count() > 0 );
372 mClassificationModeComboBox->setEnabled( enableContinuous );
373 if ( !enableContinuous )
378 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
379 if ( topLevelItemCount > 0 )
383 if ( std::isnan( mMin ) || std::isnan( mMax ) )
385 colormapMinMax( min, max );
394 QTreeWidgetItem *currentItem =
nullptr;
395 for (
int i = 0; i < topLevelItemCount; ++i )
397 currentItem = mColormapTreeWidget->topLevelItem( i );
403 double value = currentItem->data( ValueColumn, Qt::ItemDataRole::EditRole ).toDouble();
404 double position = ( value - min ) / ( max - min );
405 whileBlocking(
static_cast<QgsTreeWidgetItemObject *
>( currentItem ) )->setData( ColorColumn, Qt::ItemDataRole::EditRole, ramp->color( position ) );
418 mColormapTreeWidget->clear();
419 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin();
421 for ( ; it != colorRampItems.constEnd(); ++it )
424 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
425 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
426 newItem->setText( LabelColumn, it->label );
427 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
439 const QString unit = mUnitLineEdit->text();
440 for ( i = 0; i < mColormapTreeWidget->topLevelItemCount(); i++ )
443 QString lbl { createLabel( currentItem, i, unit ) };
444 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
446 currentItem->setText( LabelColumn, lbl );
447 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
452void QgsColorRampShaderWidget::mLoadFromBandButton_clicked()
454 if ( !mRasterDataProvider )
457 QList<QgsColorRampShader::ColorRampItem> colorRampList = mRasterDataProvider->colorTable( mBand );
458 if ( !colorRampList.isEmpty() )
465 QMessageBox::warning(
this, tr(
"Load Color Map" ), tr(
"The color map for band %1 has no entries." ).arg( mBand ) );
471void QgsColorRampShaderWidget::mLoadFromFileButton_clicked()
473 QgsSettings settings;
474 QString lastDir = settings.
value( u
"lastColorMapDir"_s, QDir::homePath() ).toString();
475 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Color Map from File" ), lastDir, tr(
"Textfile (*.txt)" ) );
476 if ( fileName.isEmpty() )
479 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
485 mColormapTreeWidget->clear();
487 mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( type ) ) );
491 if ( !errors.empty() )
493 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"The following lines contained errors\n\n" ) + errors.join(
'\n' ) );
498 const QString error = tr(
"An error occurred while reading the color map\n\n" ) + errors.join(
'\n' );
499 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), error );
502 QFileInfo fileInfo( fileName );
503 settings.
setValue( u
"lastColorMapDir"_s, fileInfo.absoluteDir().absolutePath() );
510void QgsColorRampShaderWidget::mExportToFileButton_clicked()
512 QgsSettings settings;
513 QString lastDir = settings.
value( u
"lastColorMapDir"_s, QDir::homePath() ).toString();
514 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Color Map as File" ), lastDir, tr(
"Textfile (*.txt)" ) );
515 if ( fileName.isEmpty() )
520 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
521 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
522 for (
int i = 0; i < topLevelItemCount; ++i )
524 QTreeWidgetItem *currentItem = mColormapTreeWidget->topLevelItem( i );
530 QgsColorRampShader::ColorRampItem item;
531 item.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
532 item.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
533 item.
label = currentItem->text( LabelColumn );
534 colorRampItems << item;
539 QMessageBox::warning(
this, tr(
"Save Color Map as File" ), tr(
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
542 QFileInfo fileInfo( fileName );
543 settings.
setValue( u
"lastColorMapDir"_s, fileInfo.absoluteDir().absolutePath() );
546void QgsColorRampShaderWidget::mUnitLineEdit_textEdited(
const QString & )
550 if ( !mBlockChanges )
554void QgsColorRampShaderWidget::mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int column )
561 if ( column == LabelColumn )
564 item->setForeground( LabelColumn, QBrush() );
568void QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *item,
int column )
608 whileBlocking( mColorInterpolationComboBox )->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( colorRampShader.
colorRampType() ) ) );
609 mColorInterpolationComboBox_currentIndexChanged( mColorInterpolationComboBox->currentIndex() );
610 whileBlocking( mClassificationModeComboBox )->setCurrentIndex( mClassificationModeComboBox->findData( QVariant::fromValue( colorRampShader.
classificationMode() ) ) );
611 mClassificationModeComboBox_currentIndexChanged( mClassificationModeComboBox->currentIndex() );
621 QString defaultPalette = settings.
value( u
"/Raster/defaultPalette"_s,
"Spectral" ).toString();
622 btnColorRamp->setColorRampFromName( defaultPalette );
625 mLabelPrecisionSpinBox->setValue( colorRampShader.
labelPrecision() );
636void QgsColorRampShaderWidget::mColorInterpolationComboBox_currentIndexChanged(
int index )
643 QString valueToolTip;
644 switch ( interpolation )
647 valueLabel = tr(
"Value" );
648 valueToolTip = tr(
"Value for color stop" );
649 mLegendSettingsButton->setEnabled(
true );
652 valueLabel = tr(
"Value <=" );
653 valueToolTip = tr(
"Maximum value for class" );
654 mLegendSettingsButton->setEnabled(
false );
657 valueLabel = tr(
"Value =" );
658 valueToolTip = tr(
"Value for color" );
659 mLegendSettingsButton->setEnabled(
false );
663 QTreeWidgetItem *header = mColormapTreeWidget->headerItem();
664 header->setText( ValueColumn, valueLabel );
665 header->setToolTip( ValueColumn, valueToolTip );
684 resetClassifyButton();
697bool QgsColorRampShaderWidget::colormapMinMax(
double &min,
double &max )
const
699 QTreeWidgetItem *item = mColormapTreeWidget->topLevelItem( 0 );
714 min = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
715 item = mColormapTreeWidget->topLevelItem( mColormapTreeWidget->topLevelItemCount() - 1 );
716 max = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
723 double min = 0, max = 0;
724 if ( !colormapMinMax( min, max ) )
737void QgsColorRampShaderWidget::resetClassifyButton()
739 mClassifyButton->setEnabled(
true );
740 if ( std::isnan( mMin ) || std::isnan( mMax ) || mMin >= mMax )
742 mClassifyButton->setEnabled(
false );
746QString QgsColorRampShaderWidget::createLabel( QTreeWidgetItem *currentItem,
int row,
const QString unit )
748 auto applyPrecision = [
this](
const QString &value ) {
749 double val { value.toDouble() };
764 return QLocale().toString( std::round( val ),
'f', 0 );
769 if ( mLabelPrecisionSpinBox->value() < 0 )
771 const double factor = std::pow( 10, -mLabelPrecisionSpinBox->value() );
772 val =
static_cast<qlonglong
>( val / factor ) * factor;
773 return QLocale().toString( val,
'f', 0 );
775 return QLocale().toString( val,
'f', mLabelPrecisionSpinBox->value() );
781 if ( mLabelPrecisionSpinBox->value() < 0 )
783 const double factor = std::pow( 10, -mLabelPrecisionSpinBox->value() );
784 val =
static_cast<qlonglong
>( val / factor ) * factor;
785 return QLocale().toString( val,
'f', 0 );
787 return QLocale().toString( val,
'f', mLabelPrecisionSpinBox->value() );
801 lbl =
"<= " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
803 else if ( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble() == std::numeric_limits<double>::infinity() )
805 lbl =
"> " + applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
809 lbl = applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) +
" - " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
814 lbl = applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
820void QgsColorRampShaderWidget::changeColor()
822 QList<QTreeWidgetItem *> itemList;
823 itemList = mColormapTreeWidget->selectedItems();
824 if ( itemList.isEmpty() )
828 QTreeWidgetItem *firstItem = itemList.first();
830 QColor currentColor = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
832 if ( panel && panel->dockMode() )
838 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
840 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
846 panel->openPanel( colorWidget );
852 if ( newColor.isValid() )
854 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
856 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
865void QgsColorRampShaderWidget::changeOpacity()
867 QList<QTreeWidgetItem *> itemList;
868 itemList = mColormapTreeWidget->selectedItems();
869 if ( itemList.isEmpty() )
873 QTreeWidgetItem *firstItem = itemList.first();
876 double oldOpacity = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>().alpha() / 255 * 100;
877 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change color opacity [%]" ), oldOpacity, 0.0, 100.0, 0, &ok );
880 int newOpacity =
static_cast<int>( opacity / 100 * 255 );
881 const auto constItemList = itemList;
882 for ( QTreeWidgetItem *item : constItemList )
884 QColor newColor = item->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
885 newColor.setAlpha( newOpacity );
886 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
894void QgsColorRampShaderWidget::showLegendSettings()
899 QgsColorRampLegendNodeWidget *legendPanel =
new QgsColorRampLegendNodeWidget();
903 mLegendSettings = legendPanel->
settings();
910 QgsColorRampLegendNodeDialog dialog( mLegendSettings,
this );
911 dialog.setWindowTitle( tr(
"Legend Settings" ) );
914 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)