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 ) )
311 std::unique_ptr<QgsColorRampShader> colorRampShader(
316 colorRampShader->classifyColorRamp( mNumberOfEntriesSpinBox->value(), mBand, mExtent, mRasterDataProvider );
317 colorRampShader->setClip( mClipCheckBox->isChecked() );
319 mColormapTreeWidget->clear();
321 const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->colorRampItemList();
322 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin();
323 for ( ; it != colorRampItemList.end(); ++it )
326 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
327 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
328 newItem->setText( LabelColumn, QString() );
329 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
333 mClipCheckBox->setChecked( colorRampShader->clip() );
339void QgsColorRampShaderWidget::mClassificationModeComboBox_currentIndexChanged(
int index )
346void QgsColorRampShaderWidget::updateColorRamp()
348 std::unique_ptr<QgsColorRamp> ramp(
shader().createColorRamp() );
352void QgsColorRampShaderWidget::applyColorRamp()
354 std::unique_ptr<QgsColorRamp> ramp( btnColorRamp->colorRamp() );
360 if ( !btnColorRamp->colorRampName().isEmpty() )
363 QgsSettings settings;
364 settings.
setValue( u
"Raster/defaultPalette"_s, btnColorRamp->colorRampName() );
367 bool enableContinuous = ( ramp->count() > 0 );
368 mClassificationModeComboBox->setEnabled( enableContinuous );
369 if ( !enableContinuous )
374 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
375 if ( topLevelItemCount > 0 )
379 if ( std::isnan( mMin ) || std::isnan( mMax ) )
381 colormapMinMax( min, max );
390 QTreeWidgetItem *currentItem =
nullptr;
391 for (
int i = 0; i < topLevelItemCount; ++i )
393 currentItem = mColormapTreeWidget->topLevelItem( i );
399 double value = currentItem->data( ValueColumn, Qt::ItemDataRole::EditRole ).toDouble();
400 double position = ( value - min ) / ( max - min );
401 whileBlocking(
static_cast<QgsTreeWidgetItemObject *
>( currentItem ) )->setData( ColorColumn, Qt::ItemDataRole::EditRole, ramp->color( position ) );
414 mColormapTreeWidget->clear();
415 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin();
417 for ( ; it != colorRampItems.constEnd(); ++it )
420 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
421 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
422 newItem->setText( LabelColumn, it->label );
423 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
435 const QString unit = mUnitLineEdit->text();
436 for ( i = 0; i < mColormapTreeWidget->topLevelItemCount(); i++ )
439 QString lbl { createLabel( currentItem, i, unit ) };
440 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
442 currentItem->setText( LabelColumn, lbl );
443 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
448void QgsColorRampShaderWidget::mLoadFromBandButton_clicked()
450 if ( !mRasterDataProvider )
453 QList<QgsColorRampShader::ColorRampItem> colorRampList = mRasterDataProvider->colorTable( mBand );
454 if ( !colorRampList.isEmpty() )
461 QMessageBox::warning(
this, tr(
"Load Color Map" ), tr(
"The color map for band %1 has no entries." ).arg( mBand ) );
467void QgsColorRampShaderWidget::mLoadFromFileButton_clicked()
469 QgsSettings settings;
470 QString lastDir = settings.
value( u
"lastColorMapDir"_s, QDir::homePath() ).toString();
471 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Color Map from File" ), lastDir, tr(
"Textfile (*.txt)" ) );
472 if ( fileName.isEmpty() )
475 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
481 mColormapTreeWidget->clear();
483 mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( type ) ) );
487 if ( !errors.empty() )
489 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"The following lines contained errors\n\n" ) + errors.join(
'\n' ) );
494 const QString error = tr(
"An error occurred while reading the color map\n\n" ) + errors.join(
'\n' );
495 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), error );
498 QFileInfo fileInfo( fileName );
499 settings.
setValue( u
"lastColorMapDir"_s, fileInfo.absoluteDir().absolutePath() );
506void QgsColorRampShaderWidget::mExportToFileButton_clicked()
508 QgsSettings settings;
509 QString lastDir = settings.
value( u
"lastColorMapDir"_s, QDir::homePath() ).toString();
510 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Color Map as File" ), lastDir, tr(
"Textfile (*.txt)" ) );
511 if ( fileName.isEmpty() )
516 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
517 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
518 for (
int i = 0; i < topLevelItemCount; ++i )
520 QTreeWidgetItem *currentItem = mColormapTreeWidget->topLevelItem( i );
526 QgsColorRampShader::ColorRampItem item;
527 item.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
528 item.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
529 item.
label = currentItem->text( LabelColumn );
530 colorRampItems << item;
535 QMessageBox::warning(
this, tr(
"Save Color Map as File" ), tr(
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
538 QFileInfo fileInfo( fileName );
539 settings.
setValue( u
"lastColorMapDir"_s, fileInfo.absoluteDir().absolutePath() );
542void QgsColorRampShaderWidget::mUnitLineEdit_textEdited(
const QString & )
546 if ( !mBlockChanges )
550void QgsColorRampShaderWidget::mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int column )
557 if ( column == LabelColumn )
560 item->setForeground( LabelColumn, QBrush() );
564void QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *item,
int column )
604 whileBlocking( mColorInterpolationComboBox )->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( colorRampShader.
colorRampType() ) ) );
605 mColorInterpolationComboBox_currentIndexChanged( mColorInterpolationComboBox->currentIndex() );
606 whileBlocking( mClassificationModeComboBox )->setCurrentIndex( mClassificationModeComboBox->findData( QVariant::fromValue( colorRampShader.
classificationMode() ) ) );
607 mClassificationModeComboBox_currentIndexChanged( mClassificationModeComboBox->currentIndex() );
617 QString defaultPalette = settings.
value( u
"/Raster/defaultPalette"_s,
"Spectral" ).toString();
618 btnColorRamp->setColorRampFromName( defaultPalette );
621 mLabelPrecisionSpinBox->setValue( colorRampShader.
labelPrecision() );
632void QgsColorRampShaderWidget::mColorInterpolationComboBox_currentIndexChanged(
int index )
639 QString valueToolTip;
640 switch ( interpolation )
643 valueLabel = tr(
"Value" );
644 valueToolTip = tr(
"Value for color stop" );
645 mLegendSettingsButton->setEnabled(
true );
648 valueLabel = tr(
"Value <=" );
649 valueToolTip = tr(
"Maximum value for class" );
650 mLegendSettingsButton->setEnabled(
false );
653 valueLabel = tr(
"Value =" );
654 valueToolTip = tr(
"Value for color" );
655 mLegendSettingsButton->setEnabled(
false );
659 QTreeWidgetItem *header = mColormapTreeWidget->headerItem();
660 header->setText( ValueColumn, valueLabel );
661 header->setToolTip( ValueColumn, valueToolTip );
680 resetClassifyButton();
693bool QgsColorRampShaderWidget::colormapMinMax(
double &min,
double &max )
const
695 QTreeWidgetItem *item = mColormapTreeWidget->topLevelItem( 0 );
710 min = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
711 item = mColormapTreeWidget->topLevelItem( mColormapTreeWidget->topLevelItemCount() - 1 );
712 max = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
719 double min = 0, max = 0;
720 if ( !colormapMinMax( min, max ) )
733void QgsColorRampShaderWidget::resetClassifyButton()
735 mClassifyButton->setEnabled(
true );
736 if ( std::isnan( mMin ) || std::isnan( mMax ) || mMin >= mMax )
738 mClassifyButton->setEnabled(
false );
742QString QgsColorRampShaderWidget::createLabel( QTreeWidgetItem *currentItem,
int row,
const QString unit )
744 auto applyPrecision = [
this](
const QString &value ) {
745 double val { value.toDouble() };
760 return QLocale().toString( std::round( val ),
'f', 0 );
765 if ( mLabelPrecisionSpinBox->value() < 0 )
767 const double factor = std::pow( 10, -mLabelPrecisionSpinBox->value() );
768 val =
static_cast<qlonglong
>( val / factor ) * factor;
769 return QLocale().toString( val,
'f', 0 );
771 return QLocale().toString( val,
'f', mLabelPrecisionSpinBox->value() );
777 if ( mLabelPrecisionSpinBox->value() < 0 )
779 const double factor = std::pow( 10, -mLabelPrecisionSpinBox->value() );
780 val =
static_cast<qlonglong
>( val / factor ) * factor;
781 return QLocale().toString( val,
'f', 0 );
783 return QLocale().toString( val,
'f', mLabelPrecisionSpinBox->value() );
797 lbl =
"<= " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
799 else if ( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble() == std::numeric_limits<double>::infinity() )
801 lbl =
"> " + applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
805 lbl = applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() )
807 + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() )
813 lbl = applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
819void QgsColorRampShaderWidget::changeColor()
821 QList<QTreeWidgetItem *> itemList;
822 itemList = mColormapTreeWidget->selectedItems();
823 if ( itemList.isEmpty() )
827 QTreeWidgetItem *firstItem = itemList.first();
829 QColor currentColor = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
831 if ( panel && panel->dockMode() )
837 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
839 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
845 panel->openPanel( colorWidget );
851 if ( newColor.isValid() )
853 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
855 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
864void QgsColorRampShaderWidget::changeOpacity()
866 QList<QTreeWidgetItem *> itemList;
867 itemList = mColormapTreeWidget->selectedItems();
868 if ( itemList.isEmpty() )
872 QTreeWidgetItem *firstItem = itemList.first();
875 double oldOpacity = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>().alpha() / 255 * 100;
876 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change color opacity [%]" ), oldOpacity, 0.0, 100.0, 0, &ok );
879 int newOpacity =
static_cast<int>( opacity / 100 * 255 );
880 const auto constItemList = itemList;
881 for ( QTreeWidgetItem *item : constItemList )
883 QColor newColor = item->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
884 newColor.setAlpha( newOpacity );
885 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
893void QgsColorRampShaderWidget::showLegendSettings()
898 QgsColorRampLegendNodeWidget *legendPanel =
new QgsColorRampLegendNodeWidget();
902 mLegendSettings = legendPanel->
settings();
909 QgsColorRampLegendNodeDialog dialog( mLegendSettings,
this );
910 dialog.setWindowTitle( tr(
"Legend Settings" ) );
913 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)