35#include <QInputDialog>
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, SLOT( changeColor() ) );
65 contextMenu->addAction( tr(
"Change Opacity…" ),
this, SLOT( 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, [ = ]( 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, [ = ](
int )
106 if ( !mBlockChanges )
121 mRasterDataProvider = dp;
122 mLoadFromBandButton->setVisible(
static_cast< bool>( mRasterDataProvider ) );
133 mLabelPrecisionSpinBox->setMaximum( maxDigits );
134 mValueDelegate->setDataType( dataType );
148 colorRampShader.
setClip( mClipCheckBox->isChecked() );
151 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
152 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
153 QTreeWidgetItem *currentItem =
nullptr;
154 for (
int i = 0; i < topLevelItemCount; ++i )
156 currentItem = mColormapTreeWidget->topLevelItem( i );
162 newColorRampItem.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
163 newColorRampItem.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
164 newColorRampItem.
label = currentItem->text( LabelColumn );
165 colorRampItems.append( newColorRampItem );
168 std::sort( colorRampItems.begin(), colorRampItems.end() );
171 if ( !btnColorRamp->isNull() )
177 return colorRampShader;
180void QgsColorRampShaderWidget::autoLabel()
182 mColormapTreeWidget->sortItems( ValueColumn, Qt::AscendingOrder );
188 const QString unit = mUnitLineEdit->text();
189 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
191 QTreeWidgetItem *currentItem =
nullptr;
192 for (
int i = 0; i < topLevelItemCount; ++i )
194 currentItem = mColormapTreeWidget->topLevelItem( i );
196 if ( !currentItem || currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString().isEmpty() )
201 const QString lbl = createLabel( currentItem, i, unit );
203 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
205 currentItem->setText( LabelColumn, lbl );
206 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
212void QgsColorRampShaderWidget::setUnitFromLabels()
214 QStringList allSuffixes;
216 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
217 QTreeWidgetItem *currentItem =
nullptr;
218 for (
int i = 0; i < topLevelItemCount; ++i )
220 currentItem = mColormapTreeWidget->topLevelItem( i );
222 if ( !currentItem || currentItem->text( ValueColumn ).isEmpty() )
227 label = createLabel( currentItem, i, QString() );
229 if ( currentItem->text( LabelColumn ).startsWith( label ) )
231 allSuffixes.append( currentItem->text( LabelColumn ).mid( label.length() ) );
235 QStringList suffixes = QStringList( allSuffixes );
236 suffixes.removeDuplicates();
239 for (
int i = 0; i < suffixes.count(); ++i )
241 int n = allSuffixes.count( suffixes[i] );
251 mUnitLineEdit->setText( unit );
256void QgsColorRampShaderWidget::dumpClasses()
258 for (
int row = 0; row < mColormapTreeWidget->model()->rowCount(); ++row )
260 const auto labelData { mColormapTreeWidget->model()->itemData( mColormapTreeWidget->model()->index( row, LabelColumn ) ) };
261 const auto valueData { mColormapTreeWidget->model()->itemData( mColormapTreeWidget->model()->index( row, ValueColumn ) ) };
263 .arg( labelData[ Qt::ItemDataRole::DisplayRole ].toString(),
264 valueData[ Qt::ItemDataRole::DisplayRole ].toString() ), 2 );
269void QgsColorRampShaderWidget::mAddEntryButton_clicked()
272 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, 0 );
273 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, QColor( Qt::magenta ) );
274 newItem->setText( LabelColumn, QString() );
275 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
277 this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited );
285void QgsColorRampShaderWidget::mDeleteEntryButton_clicked()
287 QList<QTreeWidgetItem *> itemList;
288 itemList = mColormapTreeWidget->selectedItems();
289 if ( itemList.isEmpty() )
294 const auto constItemList = itemList;
295 for ( QTreeWidgetItem *item : constItemList )
307 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
308 if ( !ramp || std::isnan( mMin ) || std::isnan( mMax ) )
321 colorRampShader->classifyColorRamp( mNumberOfEntriesSpinBox->value(),
324 mRasterDataProvider );
325 colorRampShader->setClip( mClipCheckBox->isChecked() );
327 mColormapTreeWidget->clear();
329 const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->colorRampItemList();
330 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin();
331 for ( ; it != colorRampItemList.end(); ++it )
334 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
335 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
336 newItem->setText( LabelColumn, QString() );
337 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
339 this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited );
342 mClipCheckBox->setChecked( colorRampShader->clip() );
348void QgsColorRampShaderWidget::mClassificationModeComboBox_currentIndexChanged(
int index )
355void QgsColorRampShaderWidget::updateColorRamp()
357 std::unique_ptr< QgsColorRamp > ramp(
shader().createColorRamp() );
361void QgsColorRampShaderWidget::applyColorRamp()
363 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
369 if ( !btnColorRamp->colorRampName().isEmpty() )
373 settings.
setValue( QStringLiteral(
"Raster/defaultPalette" ), btnColorRamp->colorRampName() );
376 bool enableContinuous = ( ramp->count() > 0 );
377 mClassificationModeComboBox->setEnabled( enableContinuous );
378 if ( !enableContinuous )
383 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
384 if ( topLevelItemCount > 0 )
388 if ( std::isnan( mMin ) || std::isnan( mMax ) )
390 colormapMinMax( min, max );
399 QTreeWidgetItem *currentItem =
nullptr;
400 for (
int i = 0; i < topLevelItemCount; ++i )
402 currentItem = mColormapTreeWidget->topLevelItem( i );
408 double value = currentItem->data( ValueColumn, Qt::ItemDataRole::EditRole ).toDouble( );
409 double position = ( value - min ) / ( max - min );
423 mColormapTreeWidget->clear();
424 QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin();
426 for ( ; it != colorRampItems.constEnd(); ++it )
429 newItem->
setData( ValueColumn, Qt::ItemDataRole::DisplayRole, it->value );
430 newItem->
setData( ColorColumn, Qt::ItemDataRole::EditRole, it->color );
431 newItem->setText( LabelColumn, it->label );
432 newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
434 this, &QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited );
445 const QString unit = mUnitLineEdit->text();
446 for ( i = 0; i < mColormapTreeWidget->topLevelItemCount(); i++ )
449 QString lbl { createLabel( currentItem, i, unit )};
450 if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == lbl || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) )
452 currentItem->setText( LabelColumn, lbl );
453 currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) );
459void QgsColorRampShaderWidget::mLoadFromBandButton_clicked()
461 if ( !mRasterDataProvider )
464 QList<QgsColorRampShader::ColorRampItem> colorRampList = mRasterDataProvider->colorTable( mBand );
465 if ( !colorRampList.isEmpty() )
472 QMessageBox::warning(
this, tr(
"Load Color Map" ), tr(
"The color map for band %1 has no entries." ).arg( mBand ) );
478void QgsColorRampShaderWidget::mLoadFromFileButton_clicked()
481 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
482 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Color Map from File" ), lastDir, tr(
"Textfile (*.txt)" ) );
483 if ( fileName.isEmpty() )
486 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
492 mColormapTreeWidget->clear();
494 mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( type ) ) );
498 if ( !errors.empty() )
500 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), tr(
"The following lines contained errors\n\n" ) + errors.join(
'\n' ) );
505 const QString error = tr(
"An error occurred while reading the color map\n\n" ) + errors.join(
'\n' );
506 QMessageBox::warning(
this, tr(
"Load Color Map from File" ), error );
509 QFileInfo fileInfo( fileName );
510 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
517void QgsColorRampShaderWidget::mExportToFileButton_clicked()
520 QString lastDir = settings.
value( QStringLiteral(
"lastColorMapDir" ), QDir::homePath() ).toString();
521 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save Color Map as File" ), lastDir, tr(
"Textfile (*.txt)" ) );
522 if ( fileName.isEmpty() )
527 QList<QgsColorRampShader::ColorRampItem> colorRampItems;
528 int topLevelItemCount = mColormapTreeWidget->topLevelItemCount();
529 for (
int i = 0; i < topLevelItemCount; ++i )
531 QTreeWidgetItem *currentItem = mColormapTreeWidget->topLevelItem( i );
538 item.
value = currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble( );
539 item.
color = currentItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
540 item.
label = currentItem->text( LabelColumn );
541 colorRampItems << item;
546 QMessageBox::warning(
this, tr(
"Save Color Map as File" ), tr(
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
549 QFileInfo fileInfo( fileName );
550 settings.
setValue( QStringLiteral(
"lastColorMapDir" ), fileInfo.absoluteDir().absolutePath() );
553void QgsColorRampShaderWidget::mUnitLineEdit_textEdited(
const QString & )
557 if ( !mBlockChanges )
561void QgsColorRampShaderWidget::mColormapTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int column )
568 if ( column == LabelColumn )
571 item->setForeground( LabelColumn, QBrush() );
575void QgsColorRampShaderWidget::mColormapTreeWidget_itemEdited( QTreeWidgetItem *item,
int column )
615 whileBlocking( mColorInterpolationComboBox )->setCurrentIndex( mColorInterpolationComboBox->findData( QVariant::fromValue( colorRampShader.
colorRampType() ) ) );
616 mColorInterpolationComboBox_currentIndexChanged( mColorInterpolationComboBox->currentIndex() );
617 whileBlocking( mClassificationModeComboBox )->setCurrentIndex( mClassificationModeComboBox->findData( QVariant::fromValue( colorRampShader.
classificationMode() ) ) );
618 mClassificationModeComboBox_currentIndexChanged( mClassificationModeComboBox->currentIndex() );
628 QString defaultPalette = settings.
value( QStringLiteral(
"/Raster/defaultPalette" ),
"Spectral" ).toString();
629 btnColorRamp->setColorRampFromName( defaultPalette );
632 mLabelPrecisionSpinBox->setValue( colorRampShader.
labelPrecision() );
643void QgsColorRampShaderWidget::mColorInterpolationComboBox_currentIndexChanged(
int index )
650 QString valueToolTip;
651 switch ( interpolation )
654 valueLabel = tr(
"Value" );
655 valueToolTip = tr(
"Value for color stop" );
656 mLegendSettingsButton->setEnabled(
true );
659 valueLabel = tr(
"Value <=" );
660 valueToolTip = tr(
"Maximum value for class" );
661 mLegendSettingsButton->setEnabled(
false );
664 valueLabel = tr(
"Value =" );
665 valueToolTip = tr(
"Value for color" );
666 mLegendSettingsButton->setEnabled(
false );
670 QTreeWidgetItem *header = mColormapTreeWidget->headerItem();
671 header->setText( ValueColumn, valueLabel );
672 header->setToolTip( ValueColumn, valueToolTip );
691 resetClassifyButton();
704bool QgsColorRampShaderWidget::colormapMinMax(
double &min,
double &max )
const
706 QTreeWidgetItem *item = mColormapTreeWidget->topLevelItem( 0 );
721 min = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
722 item = mColormapTreeWidget->topLevelItem( mColormapTreeWidget->topLevelItemCount() - 1 );
723 max = item->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble();
730 double min = 0, max = 0;
731 if ( ! colormapMinMax( min, max ) )
744void QgsColorRampShaderWidget::resetClassifyButton()
746 mClassifyButton->setEnabled(
true );
747 if ( std::isnan( mMin ) || std::isnan( mMax ) || mMin >= mMax )
749 mClassifyButton->setEnabled(
false );
753QString QgsColorRampShaderWidget::createLabel( QTreeWidgetItem *currentItem,
int row,
const QString unit )
755 auto applyPrecision = [ = ](
const QString & value )
757 double val { value.toDouble( ) };
772 return QLocale().toString( std::round( val ),
'f', 0 );
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() );
789 if ( mLabelPrecisionSpinBox->value() < 0 )
791 const double factor = std::pow( 10, - mLabelPrecisionSpinBox->value() );
792 val =
static_cast<qlonglong
>( val / factor ) * factor;
793 return QLocale().toString( val,
'f', 0 );
795 return QLocale().toString( val,
'f', mLabelPrecisionSpinBox->value() );
809 lbl =
"<= " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
811 else if ( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toDouble( ) == std::numeric_limits<double>::infinity() )
813 lbl =
"> " + applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
817 lbl = applyPrecision( mColormapTreeWidget->topLevelItem( row - 1 )->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) +
" - " + applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
822 lbl = applyPrecision( currentItem->data( ValueColumn, Qt::ItemDataRole::DisplayRole ).toString() ) + unit;
829void QgsColorRampShaderWidget::changeColor()
831 QList<QTreeWidgetItem *> itemList;
832 itemList = mColormapTreeWidget->selectedItems();
833 if ( itemList.isEmpty() )
837 QTreeWidgetItem *firstItem = itemList.first();
839 QColor currentColor = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
841 if ( panel && panel->dockMode() )
848 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
850 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
856 panel->openPanel( colorWidget );
862 if ( newColor.isValid() )
864 for ( QTreeWidgetItem *item : std::as_const( itemList ) )
866 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
875void QgsColorRampShaderWidget::changeOpacity()
877 QList<QTreeWidgetItem *> itemList;
878 itemList = mColormapTreeWidget->selectedItems();
879 if ( itemList.isEmpty() )
883 QTreeWidgetItem *firstItem = itemList.first();
886 double oldOpacity = firstItem->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>().alpha() / 255 * 100;
887 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change color opacity [%]" ), oldOpacity, 0.0, 100.0, 0, &ok );
890 int newOpacity =
static_cast<int>( opacity / 100 * 255 );
891 const auto constItemList = itemList;
892 for ( QTreeWidgetItem *item : constItemList )
894 QColor newColor = item->data( ColorColumn, Qt::ItemDataRole::EditRole ).value<QColor>();
895 newColor.setAlpha( newOpacity );
896 item->setData( ColorColumn, Qt::ItemDataRole::EditRole, newColor );
904void QgsColorRampShaderWidget::showLegendSettings()
914 mLegendSettings = legendPanel->
settings();
922 dialog.setWindowTitle( tr(
"Legend Settings" ) );
925 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)