76#include <QDesktopServices>
77#include <QTableWidgetItem>
84#include <QLinearGradient>
85#include <QPainterPath>
87#include <QColorDialog>
94#include <QRegularExpressionValidator>
95#include <QRegularExpression>
100 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
101 , mDefaultStandardDeviation( 0 )
102 , mDefaultRedBand( 0 )
103 , mDefaultGreenBand( 0 )
104 , mDefaultBlueBand( 0 )
106 , mGradientHeight( 0.0 )
107 , mGradientWidth( 0.0 )
108 , mMapCanvas( canvas )
109 , mMetadataFilled( false )
111 mGrayMinimumMaximumEstimated =
true;
112 mRGBMinimumMaximumEstimated =
true;
117 mOptsPage_Information->layout()->addWidget( mMetadataViewer );
121 transparencyScrollArea->setWidget( mRasterTransparencyWidget );
123 connect( buttonBuildPyramids, &QPushButton::clicked,
this, &QgsRasterLayerProperties::buttonBuildPyramids_clicked );
125 connect( mRenderTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged );
126 connect( mResetColorRenderingBtn, &QToolButton::clicked,
this, &QgsRasterLayerProperties::mResetColorRenderingBtn_clicked );
127 connect( buttonRemoveMetadataUrl, &QPushButton::clicked,
this, &QgsRasterLayerProperties::removeSelectedMetadataUrl );
128 connect( buttonAddMetadataUrl, &QPushButton::clicked,
this, &QgsRasterLayerProperties::addMetadataUrl );
133 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRasterLayerProperties::showHelp );
135 mSourceGroupBox->hide();
137 mBtnStyle =
new QPushButton( tr(
"Style" ) );
138 QMenu *menuStyle =
new QMenu(
this );
139 menuStyle->addAction( tr(
"Load Style…" ),
this, &QgsRasterLayerProperties::loadStyle_clicked );
140 menuStyle->addAction( tr(
"Save Style…" ),
this, &QgsRasterLayerProperties::saveStyleAs_clicked );
141 menuStyle->addSeparator();
142 menuStyle->addAction( tr(
"Save as Default" ),
this, &QgsRasterLayerProperties::saveDefaultStyle_clicked );
143 menuStyle->addAction( tr(
"Restore Default" ),
this, &QgsRasterLayerProperties::loadDefaultStyle_clicked );
144 mBtnStyle->setMenu( menuStyle );
145 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsRasterLayerProperties::aboutToShowStyleMenu );
146 buttonBox->addButton( mBtnStyle, QDialogButtonBox::ResetRole );
148 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
149 QMenu *menuMetadata =
new QMenu(
this );
150 mActionLoadMetadata = menuMetadata->addAction( tr(
"Load Metadata…" ),
this, &QgsRasterLayerProperties::loadMetadata );
151 mActionSaveMetadataAs = menuMetadata->addAction( tr(
"Save Metadata…" ),
this, &QgsRasterLayerProperties::saveMetadataAs );
152 menuMetadata->addSeparator();
153 menuMetadata->addAction( tr(
"Save as Default" ),
this, &QgsRasterLayerProperties::saveDefaultMetadata );
154 menuMetadata->addAction( tr(
"Restore Default" ),
this, &QgsRasterLayerProperties::loadDefaultMetadata );
155 mBtnMetadata->setMenu( menuMetadata );
156 buttonBox->addButton( mBtnMetadata, QDialogButtonBox::ResetRole );
160 connect(
this, &QDialog::accepted,
this, &QgsRasterLayerProperties::apply );
161 connect(
this, &QDialog::rejected,
this, &QgsRasterLayerProperties::onCancel );
163 connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked,
this, &QgsRasterLayerProperties::apply );
166 connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
167 connect( mBrightnessSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
168 mBrightnessSpinBox->setClearValue( 0 );
170 connect( mSliderContrast, &QAbstractSlider::valueChanged, mContrastSpinBox, &QSpinBox::setValue );
171 connect( mContrastSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderContrast, &QAbstractSlider::setValue );
172 mContrastSpinBox->setClearValue( 0 );
175 connect( mSliderGamma, &QAbstractSlider::valueChanged,
this, &QgsRasterLayerProperties::updateGammaSpinBox );
176 connect( mGammaSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterLayerProperties::updateGammaSlider );
177 mGammaSpinBox->setClearValue( 1.0 );
180 connect( sliderSaturation, &QAbstractSlider::valueChanged, spinBoxSaturation, &QSpinBox::setValue );
181 connect( spinBoxSaturation,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderSaturation, &QAbstractSlider::setValue );
182 spinBoxSaturation->setClearValue( 0 );
185 connect( sliderColorizeStrength, &QAbstractSlider::valueChanged, spinColorizeStrength, &QSpinBox::setValue );
186 connect( spinColorizeStrength,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderColorizeStrength, &QAbstractSlider::setValue );
187 spinColorizeStrength->setClearValue( 100 );
190 connect( comboGrayscale,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLayerProperties::toggleSaturationControls );
193 connect( mColorizeCheck, &QAbstractButton::toggled,
this, &QgsRasterLayerProperties::toggleColorizeControls );
196 connect( lbxPyramidResolutions, &QListWidget::itemSelectionChanged,
this, &QgsRasterLayerProperties::toggleBuildPyramidsButton );
198 connect( mRefreshLayerCheckBox, &QCheckBox::toggled, mRefreshLayerIntervalSpinBox, &QDoubleSpinBox::setEnabled );
201 mScaleRangeWidget->setMapCanvas( mMapCanvas );
206 tableViewMetadataUrl->setSelectionMode( QAbstractItemView::SingleSelection );
207 tableViewMetadataUrl->setSelectionBehavior( QAbstractItemView::SelectRows );
208 tableViewMetadataUrl->horizontalHeader()->setStretchLastSection(
true );
209 tableViewMetadataUrl->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch );
211 mMetadataUrlModel =
new QStandardItemModel( tableViewMetadataUrl );
212 mMetadataUrlModel->clear();
213 mMetadataUrlModel->setColumnCount( 3 );
214 QStringList metadataUrlHeaders;
215 metadataUrlHeaders << tr(
"URL" ) << tr(
"Type" ) << tr(
"Format" );
216 mMetadataUrlModel->setHorizontalHeaderLabels( metadataUrlHeaders );
217 tableViewMetadataUrl->setModel( mMetadataUrlModel );
218 tableViewMetadataUrl->setItemDelegate(
new MetadataUrlItemDelegate(
this ) );
225 mRasterTransparencyWidget->pbnAddValuesFromDisplay->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionContextHelp.png" ) ) );
228 mRasterTransparencyWidget->pbnImportTransparentPixelValues->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionFileOpen.svg" ) ) );
229 mRasterTransparencyWidget->pbnExportTransparentPixelValues->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionFileSave.svg" ) ) );
237 mBackupCrs = mRasterLayer->
crs();
252 connect( mRasterTransparencyWidget->pbnAddValuesFromDisplay, &QPushButton::clicked,
this, [ = ]
258 mMapCanvas->window()->raise();
259 mMapCanvas->window()->activateWindow();
260 mMapCanvas->window()->setFocus();
277 cboResamplingMethod->clear();
280 for (
const QPair<QString, QString> &method : std::as_const( constProviderType ) )
282 cboResamplingMethod->addItem( method.second, method.first );
286 QString prefix = provider->
name() +
"/driverOptions/_pyramids/";
288 QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
289 int idx = cboResamplingMethod->findData( defaultMethod );
291 cboResamplingMethod->setCurrentIndex( idx );
295 const QList< QgsRasterPyramid > myPyramidList = provider->
buildPyramidList();
299 if ( pyramid.getExists() )
301 lbxPyramidResolutions->addItem(
new QListWidgetItem( myPyramidPixmap,
302 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
303 QString::number( pyramid.getYDim() ) ) );
307 lbxPyramidResolutions->addItem(
new QListWidgetItem( myNoPyramidPixmap,
308 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
309 QString::number( pyramid.getYDim() ) ) );
316 mOptsPage_Pyramids->setEnabled(
false );
325 mOptsPage_Histogram->setEnabled(
false );
328 QVBoxLayout *layout =
new QVBoxLayout( metadataFrame );
329 layout->setContentsMargins( 0, 0, 0, 0 );
331 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
333 layout->addWidget( mMetadataWidget );
334 metadataFrame->setLayout( layout );
336 QVBoxLayout *temporalLayout =
new QVBoxLayout( temporalFrame );
337 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
339 temporalLayout->addWidget( mTemporalWidget );
343 mCrsSelector->setCrs( mRasterLayer->
crs() );
346 QString pyramidFormat( QStringLiteral(
"<h2>%1</h2><p>%2 %3 %4</p><b><font color='red'><p>%5</p><p>%6</p>" ) );
347 QString pyramidHeader = tr(
"Description" );
348 QString pyramidSentence1 = tr(
"Large resolution raster layers can slow navigation in QGIS." );
349 QString pyramidSentence2 = tr(
"By creating lower resolution copies of the data (pyramids) performance can be considerably improved as QGIS selects the most suitable resolution to use depending on the level of zoom." );
350 QString pyramidSentence3 = tr(
"You must have write access in the directory where the original data is stored to build pyramids." );
351 QString pyramidSentence4 = tr(
"Please note that building internal pyramids may alter the original data file and once created they cannot be removed!" );
352 QString pyramidSentence5 = tr(
"Please note that building internal pyramids could corrupt your image - always make a backup of your data first!" );
354 tePyramidDescription->setHtml( pyramidFormat.arg( pyramidHeader,
359 pyramidSentence5 ) );
362 mResamplingGroupBox->setSaveCheckedState(
true );
363 mResamplingUtils.initWidgets( mRasterLayer, mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox, mMaximumOversamplingSpinBox, mCbEarlyResampling );
364 mResamplingUtils.refreshWidgetsFromLayer();
368 btnColorizeColor->setColorDialogTitle( tr(
"Select Color" ) );
369 btnColorizeColor->setContext( QStringLiteral(
"symbology" ) );
374 if ( hueSaturationFilter )
376 sliderSaturation->setValue( hueSaturationFilter->
saturation() );
377 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->
grayscaleMode() );
380 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->
grayscaleMode() ) );
383 mColorizeCheck->setChecked( hueSaturationFilter->
colorizeOn() );
384 btnColorizeColor->setColor( hueSaturationFilter->
colorizeColor() );
385 toggleColorizeControls( hueSaturationFilter->
colorizeOn() );
386 sliderColorizeStrength->setValue( hueSaturationFilter->
colorizeStrength() );
387 mInvertColorsCheck->setChecked( hueSaturationFilter->
invertColors() );
392 mBlendModeComboBox->setBlendMode( mRasterLayer->
blendMode() );
397 mRasterTransparencyWidget->cboxTransparencyBand->setShowNotSetOption(
true, tr(
"None" ) );
398 mRasterTransparencyWidget->cboxTransparencyBand->setLayer( mRasterLayer );
407 cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->
alphaBand() ) );
414 mHistogramWidget =
nullptr;
415 if ( mOptsPage_Histogram->isEnabled() )
418 mHistogramStackedWidget->addWidget( mHistogramWidget );
431 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
433 for (
const QString &name : constRenderersList )
444 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
449 QString rendererType = renderer->
type();
450 widgetIndex = mRenderTypeComboBox->findData( rendererType );
451 if ( widgetIndex != -1 )
453 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
454 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
455 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
458 if ( rendererType == QLatin1String(
"singlebandcolordata" ) && mRenderTypeComboBox->count() == 1 )
461 QSizePolicy sizep = mBandRenderingGrpBx->sizePolicy();
462 sizep.setVerticalStretch( 0 );
463 sizep.setVerticalPolicy( QSizePolicy::Maximum );
464 mBandRenderingGrpBx->setSizePolicy( sizep );
465 mBandRenderingGrpBx->updateGeometry();
468 if ( mRasterLayer->
providerType() != QLatin1String(
"wms" ) )
470 mWMSPrintGroupBox->hide();
471 mPublishDataSourceUrlCheckBox->hide();
472 mBackgroundLayerCheckBox->hide();
479 const int horizontalDpi = logicalDpiX();
482 if ( horizontalDpi > 96 )
484 mMetadataViewer->setZoomFactor( mMetadataViewer->zoomFactor() * 0.9 );
486 mMetadataViewer->page()->setLinkDelegationPolicy( QWebPage::LinkDelegationPolicy::DelegateAllLinks );
487 connect( mMetadataViewer->page(), &QWebPage::linkClicked,
this, &QgsRasterLayerProperties::urlClicked );
488 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
489 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
495 mRenderTypeComboBox_currentIndexChanged( widgetIndex );
503 if ( !settings.
contains( QStringLiteral(
"/Windows/RasterLayerProperties/tab" ) ) )
505 settings.
setValue( QStringLiteral(
"Windows/RasterLayerProperties/tab" ),
511 QString title = tr(
"Layer Properties — %1" ).arg( lyr->
name() );
519 mOptsPage_Information->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#information-properties" ) );
520 mOptsPage_Source->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#source-properties" ) );
521 mOptsPage_Style->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#symbology-properties" ) );
522 mOptsPage_Transparency->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#transparency-properties" ) );
524 if ( mOptsPage_Histogram )
525 mOptsPage_Histogram->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#histogram-properties" ) );
527 mOptsPage_Rendering->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#rendering-properties" ) );
528 mOptsPage_Temporal->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#temporal-properties" ) );
530 if ( mOptsPage_Pyramids )
531 mOptsPage_Pyramids->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#pyramids-properties" ) );
533 mOptsPage_Metadata->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#metadata-properties" ) );
534 mOptsPage_Legend->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#legend-properties" ) );
535 mOptsPage_Server->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#server-properties" ) );
550 mLayerPropertiesPages << page;
553 if ( beforePage.isEmpty() )
571void QgsRasterLayerProperties::setRendererWidget(
const QString &rendererName )
584 opacity = oldRenderer->
opacity();
593 QgsDebugMsgLevel( QStringLiteral(
"renderer has widgetCreateFunction" ), 3 );
596 if ( oldWidget && ( !oldRenderer || rendererName != oldRenderer->
type() ) )
598 if ( rendererName == QLatin1String(
"singlebandgray" ) )
601 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
603 else if ( rendererName == QLatin1String(
"multibandcolor" ) )
606 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
614 mRendererStackedWidget->addWidget( mRendererWidget );
618 std::unique_ptr<QgsRasterRenderer> oldRenderer;
619 oldRenderer.reset( oldWidget->
renderer() );
620 std::unique_ptr<QgsRasterRenderer> newRenderer;
621 newRenderer.reset( mRendererWidget->
renderer() );
622 const QList<int> oldBands = oldRenderer->
usesBands();
623 const QList<int> newBands = newRenderer->usesBands();
624 if ( oldBands != newBands )
632 const int widgetIndex = mRenderTypeComboBox->findData( rendererName );
633 if ( widgetIndex != -1 )
635 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
636 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
637 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
640 if ( mRendererWidget != oldWidget )
643 if ( mHistogramWidget )
649void QgsRasterLayerProperties::sync()
653 if ( !mSourceWidget )
658 QHBoxLayout *layout =
new QHBoxLayout();
659 layout->addWidget( mSourceWidget );
660 mSourceGroupBox->setLayout( layout );
661 mSourceGroupBox->show();
665 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
666 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
686 mRasterTransparencyWidget->gboxNoDataValue->setEnabled(
false );
687 mRasterTransparencyWidget->gboxCustomTransparency->setEnabled(
false );
688 mOptionsStackedWidget->setCurrentWidget( mOptsPage_Server );
694 if ( mOptsPage_Pyramids )
696 delete mOptsPage_Pyramids;
697 mOptsPage_Pyramids =
nullptr;
703 if ( mOptsPage_Histogram )
705 delete mOptsPage_Histogram;
706 mOptsPage_Histogram =
nullptr;
707 delete mHistogramWidget;
708 mHistogramWidget =
nullptr;
720 if ( brightnessFilter )
722 mSliderBrightness->setValue( brightnessFilter->
brightness() );
723 mSliderContrast->setValue( brightnessFilter->
contrast() );
724 mGammaSpinBox->setValue( brightnessFilter->
gamma() );
730 if ( hueSaturationFilter )
732 sliderSaturation->setValue( hueSaturationFilter->
saturation() );
733 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->
grayscaleMode() );
736 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->
grayscaleMode() ) );
739 mColorizeCheck->setChecked( hueSaturationFilter->
colorizeOn() );
740 btnColorizeColor->setColor( hueSaturationFilter->
colorizeColor() );
741 toggleColorizeControls( hueSaturationFilter->
colorizeOn() );
742 sliderColorizeStrength->setValue( hueSaturationFilter->
colorizeStrength() );
743 mInvertColorsCheck->setChecked( hueSaturationFilter->
invertColors() );
756 mLayerOrigNameLineEd->setText( mRasterLayer->
name() );
763 updateInformationContent();
766 mLayerShortNameLineEdit->setText( mRasterLayer->
shortName() );
769 mLayerShortNameLineEdit->setValidator( shortNameValidator );
772 mLayerTitleLineEdit->setText( mRasterLayer->
title() );
773 mLayerAbstractTextEdit->setPlainText( mRasterLayer->
abstract() );
774 mLayerKeywordListLineEdit->setText( mRasterLayer->
keywordList() );
775 mLayerDataUrlLineEdit->setText( mRasterLayer->
dataUrl() );
776 mLayerDataUrlFormatComboBox->setCurrentIndex(
777 mLayerDataUrlFormatComboBox->findText(
783 mLayerAttributionLineEdit->setText( mRasterLayer->
attribution() );
784 mLayerAttributionUrlLineEdit->setText( mRasterLayer->
attributionUrl() );
790 const int row = mMetadataUrlModel->rowCount();
791 mMetadataUrlModel->setItem( row, 0,
new QStandardItem( metaUrl.url ) );
792 mMetadataUrlModel->setItem( row, 1,
new QStandardItem( metaUrl.type ) );
793 mMetadataUrlModel->setItem( row, 2,
new QStandardItem( metaUrl.format ) );
797 mLayerLegendUrlLineEdit->setText( mRasterLayer->
legendUrl() );
798 mLayerLegendUrlFormatComboBox->setCurrentIndex( mLayerLegendUrlFormatComboBox->findText( mRasterLayer->
legendUrlFormat() ) );
801 QVariant wmsPrintLayer = mRasterLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
802 if ( wmsPrintLayer.isValid() )
804 mWMSPrintLayerLineEdit->setText( wmsPrintLayer.toString() );
807 QVariant wmsPublishDataSourceUrl = mRasterLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
808 mPublishDataSourceUrlCheckBox->setChecked( wmsPublishDataSourceUrl.toBool() );
810 QVariant wmsBackgroundLayer = mRasterLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ),
false );
811 mBackgroundLayerCheckBox->setChecked( wmsBackgroundLayer.toBool() );
813 mLegendPlaceholderWidget->setLastPathSettingsKey( QStringLiteral(
"lastLegendPlaceholderDir" ) );
815 mLegendConfigEmbeddedWidget->setLayer( mRasterLayer );
820 updateDataDefinedButtons();
824 page->syncToLayer( mRasterLayer );
829void QgsRasterLayerProperties::apply()
833 const QString newSource = mSourceWidget->
sourceUri();
834 if ( newSource != mRasterLayer->
source() )
841 if ( !mRasterLayer->
isValid() )
855 mLegendConfigEmbeddedWidget->applyToLayer();
876 if (
"" != mRasterTransparencyWidget->leNoDataValue->text() )
878 bool myDoubleOk =
false;
883 myNoDataRangeList << myNoDataRange;
886 for (
int bandNo = 1; bandNo <= mRasterLayer->
dataProvider()->bandCount(); bandNo++ )
894 if ( rendererWidget )
901 mBackupCrs = mRasterLayer->
crs();
903 mMetadataFilled =
false;
907 if ( rasterRenderer )
909 rasterRenderer->
setAlphaBand( mRasterTransparencyWidget->cboxTransparencyBand->currentBand() );
910 rasterRenderer->
setNodataColor( mRasterTransparencyWidget->mNodataColorButton->color() );
914 if ( mRasterTransparencyWidget->tableTransparency->columnCount() == 4 )
917 QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
918 for (
int myListRunner = 0; myListRunner < mRasterTransparencyWidget->tableTransparency->rowCount(); myListRunner++ )
920 myTransparentPixel.
red = transparencyCellValue( myListRunner, 0 );
921 myTransparentPixel.
green = transparencyCellValue( myListRunner, 1 );
922 myTransparentPixel.
blue = transparencyCellValue( myListRunner, 2 );
924 myTransparentThreeValuePixelList.append( myTransparentPixel );
928 else if ( mRasterTransparencyWidget->tableTransparency->columnCount() == 3 )
931 QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
932 for (
int myListRunner = 0; myListRunner < mRasterTransparencyWidget->tableTransparency->rowCount(); myListRunner++ )
934 myTransparentPixel.
min = transparencyCellValue( myListRunner, 0 );
935 myTransparentPixel.
max = transparencyCellValue( myListRunner, 1 );
938 myTransparentSingleValuePixelList.append( myTransparentPixel );
949 rasterRenderer->
setOpacity( mRasterTransparencyWidget->mOpacityWidget->opacity() );
956 mRasterLayer->
setName( mLayerOrigNameLineEd->text() );
971 mResamplingUtils.refreshLayerFromWidgets();
975 if ( hueSaturationFilter )
977 hueSaturationFilter->
setSaturation( sliderSaturation->value() );
979 hueSaturationFilter->
setColorizeOn( mColorizeCheck->checkState() );
982 hueSaturationFilter->
setInvertColors( mInvertColorsCheck->isChecked() );
986 mRasterLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
991 mRasterLayer->
setCrs( mCrsSelector->crs() );
993 if ( mRasterLayer->
shortName() != mLayerShortNameLineEdit->text() )
994 mMetadataFilled =
false;
995 mRasterLayer->
setShortName( mLayerShortNameLineEdit->text() );
997 if ( mRasterLayer->
title() != mLayerTitleLineEdit->text() )
998 mMetadataFilled =
false;
999 mRasterLayer->
setTitle( mLayerTitleLineEdit->text() );
1001 if ( mRasterLayer->
abstract() != mLayerAbstractTextEdit->toPlainText() )
1002 mMetadataFilled =
false;
1003 mRasterLayer->
setAbstract( mLayerAbstractTextEdit->toPlainText() );
1005 if ( mRasterLayer->
keywordList() != mLayerKeywordListLineEdit->text() )
1006 mMetadataFilled =
false;
1007 mRasterLayer->
setKeywordList( mLayerKeywordListLineEdit->text() );
1009 if ( mRasterLayer->
dataUrl() != mLayerDataUrlLineEdit->text() )
1010 mMetadataFilled =
false;
1011 mRasterLayer->
setDataUrl( mLayerDataUrlLineEdit->text() );
1013 if ( mRasterLayer->
dataUrlFormat() != mLayerDataUrlFormatComboBox->currentText() )
1014 mMetadataFilled =
false;
1015 mRasterLayer->
setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
1018 if ( mRasterLayer->
attribution() != mLayerAttributionLineEdit->text() )
1019 mMetadataFilled =
false;
1020 mRasterLayer->
setAttribution( mLayerAttributionLineEdit->text() );
1022 if ( mRasterLayer->
attributionUrl() != mLayerAttributionUrlLineEdit->text() )
1023 mMetadataFilled =
false;
1027 QList<QgsMapLayerServerProperties::MetadataUrl> metaUrls;
1028 for (
int row = 0; row < mMetadataUrlModel->rowCount() ; row++ )
1031 metaUrl.
url = mMetadataUrlModel->item( row, 0 )->text();
1032 metaUrl.
type = mMetadataUrlModel->item( row, 1 )->text();
1033 metaUrl.
format = mMetadataUrlModel->item( row, 2 )->text();
1034 metaUrls.append( metaUrl );
1035 mMetadataFilled =
false;
1039 if ( mRasterLayer->
legendUrl() != mLayerLegendUrlLineEdit->text() )
1040 mMetadataFilled =
false;
1041 mRasterLayer->
setLegendUrl( mLayerLegendUrlLineEdit->text() );
1043 if ( mRasterLayer->
legendUrlFormat() != mLayerLegendUrlFormatComboBox->currentText() )
1044 mMetadataFilled =
false;
1047 if ( !mWMSPrintLayerLineEdit->text().isEmpty() )
1049 mRasterLayer->
setCustomProperty( QStringLiteral(
"WMSPrintLayer" ), mWMSPrintLayerLineEdit->text() );
1052 mRasterLayer->
setCustomProperty(
"WMSPublishDataSourceUrl", mPublishDataSourceUrlCheckBox->isChecked() );
1053 mRasterLayer->
setCustomProperty(
"WMSBackgroundLayer", mBackgroundLayerCheckBox->isChecked() );
1067void QgsRasterLayerProperties::buttonBuildPyramids_clicked()
1079 for (
int myCounterInt = 0; myCounterInt < lbxPyramidResolutions->count(); myCounterInt++ )
1081 QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt );
1083 myPyramidList[myCounterInt].setBuild( myItem->isSelected() || myPyramidList[myCounterInt].getExists() );
1087 QString prefix = provider->
name() +
"/driverOptions/_pyramids/";
1089 QString resamplingMethod( cboResamplingMethod->currentData().toString() );
1090 mySettings.
setValue( prefix +
"resampling", resamplingMethod );
1097 QApplication::setOverrideCursor( Qt::WaitCursor );
1104 QApplication::restoreOverrideCursor();
1105 mPyramidProgress->setValue( 0 );
1106 buttonBuildPyramids->setEnabled(
false );
1107 if ( !res.isNull() )
1109 if ( res == QLatin1String(
"CANCELED" ) )
1113 else if ( res == QLatin1String(
"ERROR_WRITE_ACCESS" ) )
1115 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1116 tr(
"Write access denied. Adjust the file permissions and try again." ) );
1118 else if ( res == QLatin1String(
"ERROR_WRITE_FORMAT" ) )
1120 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1121 tr(
"The file was not writable. Some formats do not "
1122 "support pyramid overviews. Consult the GDAL documentation if in doubt." ) );
1124 else if ( res == QLatin1String(
"FAILED_NOT_SUPPORTED" ) )
1126 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1127 tr(
"Building pyramid overviews is not supported on this type of raster." ) );
1129 else if ( res == QLatin1String(
"ERROR_JPEG_COMPRESSION" ) )
1131 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1132 tr(
"Building internal pyramid overviews is not supported on raster layers with JPEG compression and your current libtiff library." ) );
1134 else if ( res == QLatin1String(
"ERROR_VIRTUAL" ) )
1136 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1137 tr(
"Building pyramid overviews is not supported on this type of raster." ) );
1145 lbxPyramidResolutions->clear();
1153 if ( pyramid.getExists() )
1155 lbxPyramidResolutions->addItem(
new QListWidgetItem( myPyramidPixmap,
1156 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
1157 QString::number( pyramid.getYDim() ) ) );
1161 lbxPyramidResolutions->addItem(
new QListWidgetItem( myNoPyramidPixmap,
1162 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
1163 QString::number( pyramid.getYDim() ) ) );
1172 updateInformationContent();
1175void QgsRasterLayerProperties::urlClicked(
const QUrl &url )
1177 QFileInfo file( url.toLocalFile() );
1178 if ( file.exists() && !file.isDir() )
1181 QDesktopServices::openUrl( url );
1184void QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged(
int index )
1186 if ( index < 0 || mDisableRenderTypeComboBoxCurrentIndexChanged || ! mRasterLayer->renderer() )
1191 QString rendererName = mRenderTypeComboBox->itemData( index ).toString();
1192 setRendererWidget( rendererName );
1202void QgsRasterLayerProperties::setTransparencyCell(
int row,
int column,
double value )
1204 QgsDebugMsgLevel( QStringLiteral(
"value = %1" ).arg( value, 0,
'g', 17 ), 3 );
1206 if ( !provider )
return;
1209 if ( !renderer )
return;
1210 int nBands = renderer->
usesBands().size();
1212 QLineEdit *lineEdit =
new QLineEdit();
1213 lineEdit->setFrame(
false );
1215 lineEdit->setContentsMargins( 1, 1, 1, 1 );
1217 if ( column == mRasterTransparencyWidget->tableTransparency->columnCount() - 1 )
1221 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
1222 lineEdit->setText( QString::number(
static_cast<int>( value ) ) );
1227 QString valueString;
1233 if ( !std::isnan( value ) )
1236 valueString = QLocale().toString( v,
'g' ) ;
1240 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
1241 if ( !std::isnan( value ) )
1243 valueString = QLocale().toString(
static_cast<int>( value ) );
1247 lineEdit->setText( valueString );
1249 mRasterTransparencyWidget->tableTransparency->setCellWidget( row, column, lineEdit );
1250 adjustTransparencyCellWidth( row, column );
1252 if ( nBands == 1 && ( column == 0 || column == 1 ) )
1254 connect( lineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerProperties::transparencyCellTextEdited );
1256 mRasterTransparencyWidget->tableTransparency->resizeColumnsToContents();
1259void QgsRasterLayerProperties::setTransparencyCellValue(
int row,
int column,
double value )
1261 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1262 if ( !lineEdit )
return;
1264 lineEdit->setText( QLocale().toString( v,
'g' ) );
1265 lineEdit->adjustSize();
1266 adjustTransparencyCellWidth( row, column );
1267 mRasterTransparencyWidget->tableTransparency->resizeColumnsToContents();
1270double QgsRasterLayerProperties::transparencyCellValue(
int row,
int column )
1272 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1273 if ( !lineEdit || lineEdit->text().isEmpty() )
1275 return std::numeric_limits<double>::quiet_NaN();
1277 return QLocale().toDouble( lineEdit->text() );
1280void QgsRasterLayerProperties::adjustTransparencyCellWidth(
int row,
int column )
1282 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1283 if ( !lineEdit )
return;
1285 int width = std::max( lineEdit->fontMetrics().boundingRect( lineEdit->text() ).width() + 10, 100 );
1286 width = std::max( width, mRasterTransparencyWidget->tableTransparency->columnWidth( column ) );
1288 lineEdit->setFixedWidth( width );
1291void QgsRasterLayerProperties::transparencyCellTextEdited(
const QString &text )
1300 int nBands = renderer->
usesBands().size();
1303 QLineEdit *lineEdit = qobject_cast<QLineEdit *>( sender() );
1304 if ( !lineEdit )
return;
1307 for (
int r = 0; r < mRasterTransparencyWidget->tableTransparency->rowCount(); r++ )
1309 for (
int c = 0;
c < mRasterTransparencyWidget->tableTransparency->columnCount();
c++ )
1311 if ( mRasterTransparencyWidget->tableTransparency->cellWidget( r,
c ) == sender() )
1318 if ( row != -1 )
break;
1320 QgsDebugMsgLevel( QStringLiteral(
"row = %1 column =%2" ).arg( row ).arg( column ), 3 );
1324 QLineEdit *toLineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, 1 ) );
1325 if ( !toLineEdit )
return;
1326 bool toChanged = mTransparencyToEdited.value( row );
1327 QgsDebugMsgLevel( QStringLiteral(
"toChanged = %1" ).arg( toChanged ), 3 );
1330 toLineEdit->setText( lineEdit->text() );
1333 else if ( column == 1 )
1335 setTransparencyToEdited( row );
1340void QgsRasterLayerProperties::aboutToShowStyleMenu()
1344 QMenu *m = qobject_cast<QMenu *>( sender() );
1352void QgsRasterLayerProperties::syncToLayer()
1357 setRendererWidget( renderer->
type() );
1363void QgsRasterLayerProperties::setTransparencyToEdited(
int row )
1365 if ( row >= mTransparencyToEdited.size() )
1367 mTransparencyToEdited.resize( row + 1 );
1369 mTransparencyToEdited[row] =
true;
1376 bool isMetadataPanel = ( index ==
mOptStackedWidget->indexOf( mOptsPage_Metadata ) );
1377 mBtnStyle->setVisible( ! isMetadataPanel );
1378 mBtnMetadata->setVisible( isMetadataPanel );
1380 if ( !mHistogramWidget )
1392 if ( index ==
mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
1395 updateInformationContent();
1401 button->blockSignals(
true );
1405 button->blockSignals(
false );
1408void QgsRasterLayerProperties::updateDataDefinedButtons()
1410 const auto propertyOverrideButtons { findChildren< QgsPropertyOverrideButton * >() };
1413 updateDataDefinedButton( button );
1429void QgsRasterLayerProperties::updateProperty()
1436void QgsRasterLayerProperties::toggleSaturationControls(
int grayscaleMode )
1439 if ( grayscaleMode == 0 )
1441 sliderSaturation->setEnabled(
true );
1442 spinBoxSaturation->setEnabled(
true );
1446 sliderSaturation->setEnabled(
false );
1447 spinBoxSaturation->setEnabled(
false );
1451void QgsRasterLayerProperties::toggleColorizeControls(
bool colorizeEnabled )
1454 btnColorizeColor->setEnabled( colorizeEnabled );
1455 sliderColorizeStrength->setEnabled( colorizeEnabled );
1456 spinColorizeStrength->setEnabled( colorizeEnabled );
1460QLinearGradient QgsRasterLayerProperties::redGradient()
1464 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1465 myGradient.setColorAt( 0.0, QColor( 242, 14, 25, 190 ) );
1466 myGradient.setColorAt( 0.5, QColor( 175, 29, 37, 190 ) );
1467 myGradient.setColorAt( 1.0, QColor( 114, 17, 22, 190 ) );
1470QLinearGradient QgsRasterLayerProperties::greenGradient()
1474 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1475 myGradient.setColorAt( 0.0, QColor( 48, 168, 5, 190 ) );
1476 myGradient.setColorAt( 0.8, QColor( 36, 122, 4, 190 ) );
1477 myGradient.setColorAt( 1.0, QColor( 21, 71, 2, 190 ) );
1480QLinearGradient QgsRasterLayerProperties::blueGradient()
1484 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1485 myGradient.setColorAt( 0.0, QColor( 30, 0, 106, 190 ) );
1486 myGradient.setColorAt( 0.2, QColor( 30, 72, 128, 190 ) );
1487 myGradient.setColorAt( 1.0, QColor( 30, 223, 196, 190 ) );
1490QLinearGradient QgsRasterLayerProperties::grayGradient()
1494 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1495 myGradient.setColorAt( 0.0, QColor( 5, 5, 5, 190 ) );
1496 myGradient.setColorAt( 0.8, QColor( 122, 122, 122, 190 ) );
1497 myGradient.setColorAt( 1.0, QColor( 220, 220, 220, 190 ) );
1500QLinearGradient QgsRasterLayerProperties::highlightGradient()
1504 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1505 myGradient.setColorAt( 1.0, QColor( 255, 255, 255, 50 ) );
1506 myGradient.setColorAt( 0.5, QColor( 255, 255, 255, 100 ) );
1507 myGradient.setColorAt( 0.0, QColor( 255, 255, 255, 150 ) );
1511void QgsRasterLayerProperties::addMetadataUrl()
1513 const int row = mMetadataUrlModel->rowCount();
1514 mMetadataUrlModel->setItem( row, 0,
new QStandardItem( QLatin1String() ) );
1515 mMetadataUrlModel->setItem( row, 1,
new QStandardItem( QLatin1String() ) );
1516 mMetadataUrlModel->setItem( row, 2,
new QStandardItem( QLatin1String() ) );
1519void QgsRasterLayerProperties::removeSelectedMetadataUrl()
1521 const QModelIndexList selectedRows = tableViewMetadataUrl->selectionModel()->selectedRows();
1522 if ( selectedRows.empty() )
1524 mMetadataUrlModel->removeRow( selectedRows[0].row() );
1533void QgsRasterLayerProperties::loadDefaultStyle_clicked()
1535 bool defaultLoadedFlag =
false;
1538 if ( defaultLoadedFlag )
1545 QMessageBox::information(
this,
1546 tr(
"Default Style" ),
1552void QgsRasterLayerProperties::saveDefaultStyle_clicked()
1558 bool defaultSavedFlag =
false;
1566 if ( !defaultSavedFlag )
1569 QMessageBox::information(
this,
1570 tr(
"Default Style" ),
1577void QgsRasterLayerProperties::loadStyle_clicked()
1580 QString lastUsedDir = settings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
1582 QString fileName = QFileDialog::getOpenFileName(
1584 tr(
"Load layer properties from style file" ),
1586 tr(
"QGIS Layer Style File" ) +
" (*.qml)" );
1587 if ( fileName.isEmpty() )
1591 if ( !fileName.endsWith( QLatin1String(
".qml" ), Qt::CaseInsensitive ) )
1592 fileName += QLatin1String(
".qml" );
1596 bool defaultLoadedFlag =
false;
1597 QString message = mRasterLayer->
loadNamedStyle( fileName, defaultLoadedFlag );
1598 if ( defaultLoadedFlag )
1600 settings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( fileName ).absolutePath() );
1605 QMessageBox::information(
this, tr(
"Save Style" ), message );
1610void QgsRasterLayerProperties::saveStyleAs_clicked()
1613 QString lastUsedDir = settings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
1615 QString selectedFilter;
1616 QString outputFileName = QFileDialog::getSaveFileName(
1618 tr(
"Save layer properties as style file" ),
1620 tr(
"QGIS Layer Style File" ) +
" (*.qml)" +
";;" + tr(
"Styled Layer Descriptor" ) +
" (*.sld)",
1622 if ( outputFileName.isEmpty() )
1627 if ( selectedFilter.contains( QStringLiteral(
".qml" ), Qt::CaseInsensitive ) )
1641 bool defaultLoadedFlag =
false;
1647 message = mRasterLayer->
saveNamedStyle( outputFileName, defaultLoadedFlag );
1652 message = mRasterLayer->
saveSldStyle( outputFileName, defaultLoadedFlag );
1656 if ( defaultLoadedFlag )
1658 settings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( outputFileName ).absolutePath() );
1662 QMessageBox::information(
this, tr(
"Save Style" ), message );
1665void QgsRasterLayerProperties::restoreWindowModality()
1680void QgsRasterLayerProperties::loadMetadata()
1683 QString myLastUsedDir = myQSettings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
1685 QString myFileName = QFileDialog::getOpenFileName(
this, tr(
"Load layer metadata from metadata file" ), myLastUsedDir,
1686 tr(
"QGIS Layer Metadata File" ) +
" (*.qmd)" );
1687 if ( myFileName.isNull() )
1693 bool defaultLoadedFlag =
false;
1697 if ( defaultLoadedFlag )
1704 QMessageBox::warning(
this, tr(
"Load Metadata" ), myMessage );
1707 QFileInfo myFI( myFileName );
1708 QString myPath = myFI.path();
1709 myQSettings.
setValue( QStringLiteral(
"style/lastStyleDir" ), myPath );
1714void QgsRasterLayerProperties::saveMetadataAs()
1717 QString myLastUsedDir = myQSettings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
1719 QString myOutputFileName = QFileDialog::getSaveFileName(
this, tr(
"Save Layer Metadata as QMD" ),
1720 myLastUsedDir, tr(
"QMD File" ) +
" (*.qmd)" );
1721 if ( myOutputFileName.isNull() )
1734 bool defaultLoadedFlag =
false;
1735 QString message = mRasterLayer->
saveNamedMetadata( myOutputFileName, defaultLoadedFlag );
1736 if ( defaultLoadedFlag )
1737 myQSettings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( myOutputFileName ).absolutePath() );
1739 QMessageBox::information(
this, tr(
"Save Metadata" ), message );
1742void QgsRasterLayerProperties::saveDefaultMetadata()
1746 bool defaultSavedFlag =
false;
1748 if ( !defaultSavedFlag )
1750 QMessageBox::warning(
this, tr(
"Default Metadata" ), errorMsg );
1754void QgsRasterLayerProperties::loadDefaultMetadata()
1756 bool defaultLoadedFlag =
false;
1759 if ( defaultLoadedFlag )
1765 QMessageBox::information(
this, tr(
"Default Metadata" ), myMessage );
1770void QgsRasterLayerProperties::toggleBuildPyramidsButton()
1772 if ( lbxPyramidResolutions->selectedItems().empty() )
1774 buttonBuildPyramids->setEnabled(
false );
1778 buttonBuildPyramids->setEnabled(
true );
1782void QgsRasterLayerProperties::mResetColorRenderingBtn_clicked()
1784 mBlendModeComboBox->setBlendMode( QPainter::CompositionMode_SourceOver );
1785 mSliderBrightness->setValue( 0 );
1786 mSliderContrast->setValue( 0 );
1787 mGammaSpinBox->setValue( 1.0 );
1788 sliderSaturation->setValue( 0 );
1790 mColorizeCheck->setChecked(
false );
1791 sliderColorizeStrength->setValue( 100 );
1792 mInvertColorsCheck->setChecked(
false );
1795bool QgsRasterLayerProperties::rasterIsMultiBandColor()
1800void QgsRasterLayerProperties::updateInformationContent()
1804 const QString html { mRasterLayer->
htmlMetadata().replace( QLatin1String(
"<head>" ), QStringLiteral( R
"raw(<head><style type="text/css">%1</style>)raw" ) ).arg( myStyle ) };
1805 mMetadataViewer->setHtml( html );
1806 mMetadataFilled = true;
1809void QgsRasterLayerProperties::onCancel()
1815 QDomDocument doc( QStringLiteral(
"qgis" ) );
1816 int errorLine, errorColumn;
1817 doc.setContent( mOldStyle.
xmlData(),
false, &myMessage, &errorLine, &errorColumn );
1821 if ( mBackupCrs != mRasterLayer->
crs() )
1822 mRasterLayer->
setCrs( mBackupCrs );
1825void QgsRasterLayerProperties::showHelp()
1827 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
1829 if ( helpPage.isValid() )
1835 QgsHelp::openHelp( QStringLiteral(
"working_with_raster/raster_properties.html" ) );
1839void QgsRasterLayerProperties::updateGammaSpinBox(
int value )
1844void QgsRasterLayerProperties::updateGammaSlider(
double value )
@ Float32
Thirty two bit floating point (float)
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
@ Float64
Sixty four bit floating point (double)
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers.
@ WebBrowser
StyleSheet for Qt GUI widgets (based on QLabel or QTextBrowser), supports basic CSS and Qt extensions...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QRegularExpression shortNameRegularExpression()
Returns the short name regular expression for line edit validator.
Brightness/contrast and gamma correction filter pipe for rasters.
int contrast() const
Returns current contrast level.
int brightness() const
Returns current brightness level.
double gamma() const
Returns current gamma value.
void setGamma(double gamma)
Set gamma value.
void setContrast(int contrast)
Set contrast level.
void setBrightness(int brightness)
Set brightness level.
This class represents a coordinate reference system (CRS).
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
virtual QString name() const =0
Returns a provider name.
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
static QgsProviderSourceWidgetProviderRegistry * sourceWidgetProviderRegistry()
Returns the registry of provider source widget providers.
static QgsNative * nativePlatformInterface()
Returns the global native interface, which offers abstraction to the host OS's underlying public inte...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Color and saturation filter pipe for rasters.
void setColorizeOn(bool colorizeOn)
void setSaturation(int saturation)
int colorizeStrength() const
bool invertColors() const
Returns true if the filter inverts colors.
void setGrayscaleMode(QgsHueSaturationFilter::GrayscaleMode grayscaleMode)
void setInvertColors(bool invertColors)
Sets whether the filter will invert colors.
QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const
void setColorizeColor(const QColor &colorizeColor)
void setColorizeStrength(int colorizeStrength)
QColor colorizeColor() const
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
static QgsMapLayerLegend * defaultRasterLegend(QgsRasterLayer *rl)
Create new legend implementation for raster layer.
void removesExtraMenuSeparators(QMenu *m)
removes extra separators from the menu
void addStyleManagerActions(QMenu *m, QgsMapLayer *layer)
adds actions to the menu in accordance to the layer
static QgsMapLayerStyleGuiUtils * instance()
returns a singleton instance of this class
QString currentStyle() const
Returns name of the current style.
static bool isDefault(const QString &styleName)
Returns true if this is the default style.
QgsMapLayerStyle style(const QString &name) const
Returns data of a stored style - accessed by its unique name.
void currentStyleChanged(const QString ¤tName)
Emitted when the current style has been changed.
QString xmlData() const
Returns XML content of the style.
Base class for all map layer types.
void setShortName(const QString &shortName)
Sets the short name of the layer used by QGIS Server to identify the layer.
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Import the properties of this layer from a QDomDocument.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
virtual QString saveSldStyle(const QString &uri, bool &resultFlag) const
Saves the properties of this layer to an SLD format file.
QString source() const
Returns the source for the layer.
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
QgsCoordinateReferenceSystem crs
QString legendPlaceholderImage() const
Returns path to the placeholder image or an empty string if a generated legend is shown.
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
virtual QString loadNamedMetadata(const QString &uri, bool &resultFlag)
Retrieve a named metadata for this layer if one exists (either as a .qmd file on disk or as a record ...
bool hasAutoRefreshEnabled() const
Returns true if auto refresh is enabled for the layer.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
void setAttributionUrl(const QString &attribUrl)
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
void setAutoRefreshEnabled(bool enabled)
Sets whether auto refresh is enabled for the layer.
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
QgsLayerMetadata metadata
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
void setKeywordList(const QString &keywords)
Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
virtual QString saveDefaultMetadata(bool &resultFlag)
Save the current metadata of this layer as the default metadata (either as a .qmd file on disk or as ...
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
virtual QString loadNamedStyle(const QString &uri, bool &resultFlag, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
static QString extensionPropertyType(PropertyType type)
Returns the extension of a Property.
void setName(const QString &name)
Set the display name of the layer.
void setAutoRefreshInterval(int interval)
Sets the auto refresh interval (in milliseconds) for the layer.
QString saveNamedMetadata(const QString &uri, bool &resultFlag)
Save the current metadata of this layer as a named metadata (either as a .qmd file on disk or as a re...
void setLegendPlaceholderImage(const QString &imgPath)
Set placeholder image for legend.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
double minimumScale() const
Returns the minimum map scale (i.e.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
QString legendUrl() const
Returns the URL for the layer's legend.
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
virtual QString saveNamedStyle(const QString &uri, bool &resultFlag, StyleCategories categories=AllStyleCategories)
Save the properties of this layer as a named style (either as a .qml file on disk or as a record in t...
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
virtual QString metadataUri() const
Retrieve the metadata URI for this layer (either as a .qmd file on disk or as a record in the users s...
virtual QString saveDefaultStyle(bool &resultFlag, StyleCategories categories)
Save the properties of this layer as the default style (either as a .qml file on disk or as a record ...
double maximumScale() const
Returns the maximum map scale (i.e.
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
void setTitle(const QString &title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
QgsRectangle outputExtentToLayerExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS
Renderer for multiband images with the color components.
A base dialog for options and properties dialogs that offers vertical tabs.
void addPage(const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget, const QStringList &path=QStringList())
Adds a new page to the dialog pages.
virtual void optionsStackedWidget_CurrentChanged(int index)
Select relevant tab on current page change.
void insertPage(const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget, const QString &before, const QStringList &path=QStringList())
Inserts a new page into the dialog pages.
void restoreOptionsBaseUi(const QString &title=QString())
Restore the base ui.
QStackedWidget * mOptStackedWidget
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
static bool layerIsContainedInGroupLayer(QgsProject *project, QgsMapLayer *layer)
Returns true if the specified layer is a child layer from any QgsGroupLayer in the given project.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setDirty(bool b=true)
Flag the project as dirty (modified).
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
Feedback object tailored for raster block reading.
static QString printValue(double value)
Print double value with all necessary significant digits.
Base class for raster data providers.
virtual QString buildPyramids(const QList< QgsRasterPyramid > &pyramidList, const QString &resamplingMethod="NEAREST", QgsRaster::RasterPyramidsFormat format=QgsRaster::PyramidsGTiff, const QStringList &configOptions=QStringList(), QgsRasterBlockFeedback *feedback=nullptr)
Creates pyramid overviews.
Qgis::DataType sourceDataType(int bandNo) const override=0
Returns source data type for the band specified by number, source data type may be shorter than dataT...
virtual void setUseSourceNoDataValue(int bandNo, bool use)
Sets the source nodata value usage.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
virtual QList< QgsRasterPyramid > buildPyramidList(const QList< int > &overviewList=QList< int >())
Returns the raster layers pyramid list.
@ BuildPyramids
Supports building of pyramids (overviews)
@ Size
Original data source size (and thus resolution) is known, it is not always available,...
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
StyleType
enumeration for the different types of style
void addPropertiesPageFactory(const QgsMapLayerConfigWidgetFactory *factory)
Adds a properties page factory to the raster layer properties dialog.
QgsRasterLayerProperties(QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent=nullptr, Qt::WindowFlags=QgsGuiUtils::ModalDialogFlags)
Constructor.
void optionsStackedWidget_CurrentChanged(int index) override
auto slot executed when the active page in the main widget stack is changed
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Represents a raster layer.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
QgsRasterPipe * pipe()
Returns the raster pipe.
QgsBrightnessContrastFilter * brightnessFilter() const
Returns the raster's brightness/contrast filter.
LayerType rasterType()
Returns the raster layer type (which is a read only property).
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
void setRenderer(QgsRasterRenderer *renderer)
Sets the raster's renderer.
QgsHueSaturationFilter * hueSaturationFilter() const
Returns the raster's hue/saturation filter.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the pipe's property collection, used for data defined overrides.
static QgsPropertiesDefinition propertyDefinitions()
Returns the definitions for data defined properties available for use in raster pipes.
Property
Data definable properties.
@ RendererOpacity
Raster renderer global opacity.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the pipe's property collection, used for data defined overrides.
This struct is used to store pyramid info for the raster layer.
Raster values range container.
void insertWidgetFunction(const QString &rendererName, QgsRasterRendererWidgetCreateFunc func)
bool rendererData(const QString &rendererName, QgsRasterRendererRegistryEntry &data) const
QStringList renderersList() const
Raster renderer pipe that applies colors to a raster.
QColor nodataColor() const
Returns the color to use for shading nodata pixels.
virtual QString type() const
Returns a unique string representation of the renderer type.
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
void setAlphaBand(int band)
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
void setRasterTransparency(QgsRasterTransparency *t)
void setNodataColor(const QColor &color)
Sets the color to use for shading nodata pixels.
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
void setTransparentSingleValuePixelList(const QList< QgsRasterTransparency::TransparentSingleValuePixel > &newList)
Sets the transparent single value pixel list, replacing the whole existing list.
void setTransparentThreeValuePixelList(const QList< QgsRasterTransparency::TransparentThreeValuePixel > &newList)
Sets the transparent three value pixel list, replacing the whole existing list.
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.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
The QgsWebView class is a collection of stubs to mimic the API of QWebView on systems where the real ...
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
#define QgsDebugMsgLevel(str, level)
QList< QgsRasterRange > QgsRasterRangeList
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.
Registry for raster renderer entries.
QgsRasterRendererWidgetCreateFunc widgetCreateFunction
double percentTransparent
double percentTransparent