21#include "moc_qgscolorrampshaderwidget.cpp"
36#include <QInputDialog>
50 mLoadFromBandButton->setVisible(
false );
52 connect( mAddEntryButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mAddEntryButton_clicked );
53 connect( mDeleteEntryButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mDeleteEntryButton_clicked );
54 connect( mLoadFromBandButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mLoadFromBandButton_clicked );
55 connect( mLoadFromFileButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mLoadFromFileButton_clicked );
56 connect( mExportToFileButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::mExportToFileButton_clicked );
57 connect( mUnitLineEdit, &QLineEdit::textEdited,
this, &QgsColorRampShaderWidget::mUnitLineEdit_textEdited );
58 connect( mColormapTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemDoubleClicked );
59 connect( mColorInterpolationComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampShaderWidget::mColorInterpolationComboBox_currentIndexChanged );
60 connect( mClassificationModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampShaderWidget::mClassificationModeComboBox_currentIndexChanged );
62 connect( mLegendSettingsButton, &QPushButton::clicked,
this, &QgsColorRampShaderWidget::showLegendSettings );
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() ) );
70 mColormapTreeWidget->setItemDelegateForColumn( ValueColumn, mValueDelegate );
72 mColormapTreeWidget->setColumnWidth( ColorColumn,
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 6.6 );
74 mColormapTreeWidget->setContextMenuPolicy( Qt::CustomContextMenu );
75 mColormapTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
76 connect( mColormapTreeWidget, &QTreeView::customContextMenuRequested,
this, [ = ]( QPoint ) { contextMenu->exec( QCursor::pos() ); } );
78 QString defaultPalette = settings.
value( QStringLiteral(
"Raster/defaultPalette" ),
"" ).toString();
79 btnColorRamp->setColorRampFromName( defaultPalette );
91 mNumberOfEntriesSpinBox->setValue( 5 );
93 mClassificationModeComboBox_currentIndexChanged( 0 );
95 resetClassifyButton();
103 connect( mLabelPrecisionSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [ = ](
int )
107 if ( !mBlockChanges )
122 mRasterDataProvider = dp;
123 mLoadFromBandButton->setVisible(
static_cast< bool>( mRasterDataProvider ) );
134 mLabelPrecisionSpinBox->setMaximum( maxDigits );
135 mValueDelegate->setDataType( dataType );
149 colorRampShader.
setClip( mClipCheckBox->isChecked() );
152 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
153 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
154 QTreeWidgetItem *currentItem =
nullptr;
155 for (
int i = 0; i < topLevelItemCount; ++i )
157 currentItem = mColormapTreeWidget->topLevelItem( i );
163 newColorRampItem.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
164 newColorRampItem.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
165 newColorRampItem.
label = currentItem->text( LabelColumn );
166 colorRampItems.append( newColorRampItem );
169 std::sort( colorRampItems.begin(), colorRampItems.end() );
172 if ( !btnColorRamp->isNull() )
178 return colorRampShader;
181void QgsColorRampShaderWidget::autoLabel()
183 mColormapTreeWidget->sortItems( ValueColumn, Qt::AscendingOrder );
189 const QString unit = mUnitLineEdit->text();
190 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
192 QTreeWidgetItem *currentItem =
nullptr;
193 for (
int i = 0; i < topLevelItemCount; ++i )
195 currentItem = mColormapTreeWidget->topLevelItem( i );
197 if ( !currentItem || currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString().isEmpty() )
202 const QString lbl = createLabel( currentItem, i, unit );
204 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
206 currentItem->setText( LabelColumn, lbl );
207 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 ) ) };
264 .arg( labelData[ Qt::ItemDataRole::DisplayRole ].toString(),
265 valueData[ Qt::ItemDataRole::DisplayRole ].toString() ), 2 );
270void QgsColorRampShaderWidget::mAddEntryButton_clicked()
273 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, 0 );
274 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, QColor( Qt::magenta ) );
275 newItem->setText( LabelColumn, QString() );
276 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
278 this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited );
286void QgsColorRampShaderWidget::mDeleteEntryButton_clicked()
288 QList<QTreeWidgetItem *> itemList;
289 itemList = mColormapTreeWidget->selectedItems();
290 if ( itemList.isEmpty() )
295 const auto constItemList = itemList;
296 for ( QTreeWidgetItem *item : constItemList )
308 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
309 if ( !ramp || std::isnan( mMin ) || std::isnan( mMax ) )
322 colorRampShader->classifyColorRamp( mNumberOfEntriesSpinBox->value(),
325 mRasterDataProvider );
326 colorRampShader->setClip( mClipCheckBox->isChecked() );
328 mColormapTreeWidget->clear();
330 const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->colorRampItemList();
331 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin();
332 for ( ; it != colorRampItemList.end(); ++it )
335 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
336 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
337 newItem->setText( LabelColumn, QString() );
338 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
340 this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited );
343 mClipCheckBox->setChecked( colorRampShader->clip() );
349void QgsColorRampShaderWidget::mClassificationModeComboBox_currentIndexChanged(
int index )
356void QgsColorRampShaderWidget::updateColorRamp()
358 std::unique_ptr< QgsColorRamp > ramp(
shader().createColorRamp() );
362void QgsColorRampShaderWidget::applyColorRamp()
364 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
370 if ( !btnColorRamp->colorRampName().isEmpty() )
374 settings.
setValue( QStringLiteral(
"Raster/defaultPalette" ), btnColorRamp->colorRampName() );
377 bool enableContinuous = ( ramp->count() > 0 );
378 mClassificationModeComboBox->setEnabled( enableContinuous );
379 if ( !enableContinuous )
384 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
385 if ( topLevelItemCount > 0 )
389 if ( std::isnan( mMin ) || std::isnan( mMax ) )
391 colormapMinMax( min, max );
400 QTreeWidgetItem *currentItem =
nullptr;
401 for (
int i = 0; i < topLevelItemCount; ++i )
403 currentItem = mColormapTreeWidget->topLevelItem( i );
409 double value = currentItem->data( ValueColumn, Qt::ItemDataRole::EditRole ).toDouble( );
410 double position = ( value - min ) / ( max - min );
424 mColormapTreeWidget->clear();
425 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin();
427 for ( ; it != colorRampItems.constEnd(); ++it )
430 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
431 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
432 newItem->setText( LabelColumn, it->label );
433 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
435 this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited );
446 const QString unit = mUnitLineEdit->text();
447 for ( i = 0; i < mColormapTreeWidget->topLevelItemCount(); i++ )
450 QString lbl { createLabel( currentItem, i, unit )};
451 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
453 currentItem->setText( LabelColumn, lbl );
454 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
460void QgsColorRampShaderWidget::mLoadFromBandButton_clicked()
462 if ( !mRasterDataProvider )
465 QList<QgsColorRampShader::ColorRampItem> colorRampList = mRasterDataProvider->colorTable( mBand );
466 if ( !colorRampList.isEmpty() )
473 QMessageBox::warning(
this, tr(
"Load Color Map" ), tr(
"The color map for band %1 has no entries." ).arg( mBand ) );
479void QgsColorRampShaderWidget::mLoadFromFileButton_clicked()
482 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
483 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Color Map from File" ), lastDir, tr(
"Textfile (*.txt)" ) );
484 if ( fileName.isEmpty() )
487 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
493 mColormapTreeWidget->clear();
495 mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( type ) ) );
499 if ( !errors.empty() )
501 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"The following lines contained errors\n\n" ) + errors.join(
'\n' ) );
506 const QString error = tr(
"An error occurred while reading the color map\n\n" ) + errors.join(
'\n' );
507 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), error );
510 QFileInfo fileInfo( fileName );
511 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
518void QgsColorRampShaderWidget::mExportToFileButton_clicked()
521 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
522 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Color Map as File" ), lastDir, tr(
"Textfile (*.txt)" ) );
523 if ( fileName.isEmpty() )
528 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
529 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
530 for (
int i = 0; i < topLevelItemCount; ++i )
532 QTreeWidgetItem *currentItem = mColormapTreeWidget->topLevelItem( i );
539 item.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble( );
540 item.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
541 item.
label = currentItem->text( LabelColumn );
542 colorRampItems << item;
547 QMessageBox::warning(
this, tr(
"Save Color Map as File" ), tr(
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
550 QFileInfo fileInfo( fileName );
551 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
554void QgsColorRampShaderWidget::mUnitLineEdit_textEdited(
const QString & )
558 if ( !mBlockChanges )
562void QgsColorRampShaderWidget::mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int column )
569 if ( column == LabelColumn )
572 item->setForeground( LabelColumn, QBrush() );
576void QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *item,
int column )
616 whileBlocking( mColorInterpolationComboBox )->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( colorRampShader.
colorRampType() ) ) );
617 mColorInterpolationComboBox_currentIndexChanged( mColorInterpolationComboBox->currentIndex() );
618 whileBlocking( mClassificationModeComboBox )->setCurrentIndex( mClassificationModeComboBox->findData( QVariant::fromValue( colorRampShader.
classificationMode() ) ) );
619 mClassificationModeComboBox_currentIndexChanged( mClassificationModeComboBox->currentIndex() );
629 QString defaultPalette = settings.
value( QStringLiteral(
"/Raster/defaultPalette" ),
"Spectral" ).toString();
630 btnColorRamp->setColorRampFromName( defaultPalette );
633 mLabelPrecisionSpinBox->setValue( colorRampShader.
labelPrecision() );
644void QgsColorRampShaderWidget::mColorInterpolationComboBox_currentIndexChanged(
int index )
651 QString valueToolTip;
652 switch ( interpolation )
655 valueLabel = tr(
"Value" );
656 valueToolTip = tr(
"Value for color stop" );
657 mLegendSettingsButton->setEnabled(
true );
660 valueLabel = tr(
"Value <=" );
661 valueToolTip = tr(
"Maximum value for class" );
662 mLegendSettingsButton->setEnabled(
false );
665 valueLabel = tr(
"Value =" );
666 valueToolTip = tr(
"Value for color" );
667 mLegendSettingsButton->setEnabled(
false );
671 QTreeWidgetItem *header = mColormapTreeWidget->headerItem();
672 header->setText( ValueColumn, valueLabel );
673 header->setToolTip( ValueColumn, valueToolTip );
692 resetClassifyButton();
705bool QgsColorRampShaderWidget::colormapMinMax(
double &min,
double &max )
const
707 QTreeWidgetItem *item = mColormapTreeWidget->topLevelItem( 0 );
722 min = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
723 item = mColormapTreeWidget->topLevelItem( mColormapTreeWidget->topLevelItemCount() - 1 );
724 max = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
731 double min = 0, max = 0;
732 if ( ! colormapMinMax( min, max ) )
745void QgsColorRampShaderWidget::resetClassifyButton()
747 mClassifyButton->setEnabled(
true );
748 if ( std::isnan( mMin ) || std::isnan( mMax ) || mMin >= mMax )
750 mClassifyButton->setEnabled(
false );
754QString QgsColorRampShaderWidget::createLabel( QTreeWidgetItem *currentItem,
int row,
const QString unit )
756 auto applyPrecision = [ = ](
const QString & value )
758 double val { value.toDouble( ) };
773 return QLocale().toString( std::round( val ),
'f', 0 );
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() );
790 if ( mLabelPrecisionSpinBox->value() < 0 )
792 const double factor = std::pow( 10, - mLabelPrecisionSpinBox->value() );
793 val =
static_cast<qlonglong
>( val / factor ) * factor;
794 return QLocale().toString( val,
'f', 0 );
796 return QLocale().toString( val,
'f', mLabelPrecisionSpinBox->value() );
810 lbl =
"<= " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
812 else if ( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble( ) == std::numeric_limits<double>::infinity() )
814 lbl =
"> " + applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
818 lbl = applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) +
" - " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
823 lbl = applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
830void QgsColorRampShaderWidget::changeColor()
832 QList<QTreeWidgetItem *> itemList;
833 itemList = mColormapTreeWidget->selectedItems();
834 if ( itemList.isEmpty() )
838 QTreeWidgetItem *firstItem = itemList.first();
840 QColor currentColor = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
842 if ( panel && panel->dockMode() )
849 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
851 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
857 panel->openPanel( colorWidget );
863 if ( newColor.isValid() )
865 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
867 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
876void QgsColorRampShaderWidget::changeOpacity()
878 QList<QTreeWidgetItem *> itemList;
879 itemList = mColormapTreeWidget->selectedItems();
880 if ( itemList.isEmpty() )
884 QTreeWidgetItem *firstItem = itemList.first();
887 double oldOpacity = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>().alpha() / 255 * 100;
888 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change color opacity [%]" ), oldOpacity, 0.0, 100.0, 0, &ok );
891 int newOpacity =
static_cast<int>( opacity / 100 * 255 );
892 const auto constItemList = itemList;
893 for ( QTreeWidgetItem *item : constItemList )
895 QColor newColor = item->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
896 newColor.setAlpha( newOpacity );
897 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
905void QgsColorRampShaderWidget::showLegendSettings()
915 mLegendSettings = legendPanel->
settings();
923 dialog.setWindowTitle( tr(
"Legend Settings" ) );
926 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.
A dialog for configuring a QgsColorRampLegendNode (QgsColorRampLegendNodeSettings).
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.
This class is a composition of two QSettings instances:
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)