67#include <QDesktopServices>
68#include <QTableWidgetItem>
75#include <QLinearGradient>
76#include <QPainterPath>
78#include <QColorDialog>
85#include <QRegularExpressionValidator>
86#include <QRegularExpression>
91 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
92 , mDefaultStandardDeviation( 0 )
93 , mDefaultRedBand( 0 )
94 , mDefaultGreenBand( 0 )
95 , mDefaultBlueBand( 0 )
97 , mGradientHeight( 0.0 )
98 , mGradientWidth( 0.0 )
99 , mMapCanvas( canvas )
100 , mMetadataFilled( false )
102 mGrayMinimumMaximumEstimated =
true;
103 mRGBMinimumMaximumEstimated =
true;
108 mOptsPage_Information->layout()->addWidget( mMetadataViewer );
112 transparencyScrollArea->setWidget( mRasterTransparencyWidget );
114 connect( buttonBuildPyramids, &QPushButton::clicked,
this, &QgsRasterLayerProperties::buttonBuildPyramids_clicked );
116 connect( mRenderTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged );
117 connect( mResetColorRenderingBtn, &QToolButton::clicked,
this, &QgsRasterLayerProperties::mResetColorRenderingBtn_clicked );
118 connect( buttonRemoveMetadataUrl, &QPushButton::clicked,
this, &QgsRasterLayerProperties::removeSelectedMetadataUrl );
119 connect( buttonAddMetadataUrl, &QPushButton::clicked,
this, &QgsRasterLayerProperties::addMetadataUrl );
124 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRasterLayerProperties::showHelp );
126 mSourceGroupBox->hide();
128 mBtnStyle =
new QPushButton( tr(
"Style" ) );
129 QMenu *menuStyle =
new QMenu(
this );
130 menuStyle->addAction( tr(
"Load Style…" ),
this, &QgsRasterLayerProperties::loadStyle_clicked );
131 menuStyle->addAction( tr(
"Save Style…" ),
this, &QgsRasterLayerProperties::saveStyleAs_clicked );
132 menuStyle->addSeparator();
133 menuStyle->addAction( tr(
"Save as Default" ),
this, &QgsRasterLayerProperties::saveDefaultStyle_clicked );
134 menuStyle->addAction( tr(
"Restore Default" ),
this, &QgsRasterLayerProperties::loadDefaultStyle_clicked );
135 mBtnStyle->setMenu( menuStyle );
136 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsRasterLayerProperties::aboutToShowStyleMenu );
137 buttonBox->addButton( mBtnStyle, QDialogButtonBox::ResetRole );
139 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
140 QMenu *menuMetadata =
new QMenu(
this );
141 mActionLoadMetadata = menuMetadata->addAction( tr(
"Load Metadata…" ),
this, &QgsRasterLayerProperties::loadMetadata );
142 mActionSaveMetadataAs = menuMetadata->addAction( tr(
"Save Metadata…" ),
this, &QgsRasterLayerProperties::saveMetadataAs );
143 menuMetadata->addSeparator();
144 menuMetadata->addAction( tr(
"Save as Default" ),
this, &QgsRasterLayerProperties::saveDefaultMetadata );
145 menuMetadata->addAction( tr(
"Restore Default" ),
this, &QgsRasterLayerProperties::loadDefaultMetadata );
146 mBtnMetadata->setMenu( menuMetadata );
147 buttonBox->addButton( mBtnMetadata, QDialogButtonBox::ResetRole );
151 connect(
this, &QDialog::accepted,
this, &QgsRasterLayerProperties::apply );
152 connect(
this, &QDialog::rejected,
this, &QgsRasterLayerProperties::onCancel );
154 connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked,
this, &QgsRasterLayerProperties::apply );
156 cbxPyramidsFormat->addItem( tr(
"External" ), QVariant::fromValue( Qgis::RasterPyramidFormat::GeoTiff ) );
157 cbxPyramidsFormat->addItem( tr(
"Internal (if possible)" ), QVariant::fromValue( Qgis::RasterPyramidFormat::Internal ) );
158 cbxPyramidsFormat->addItem( tr(
"External (Erdas Imagine)" ), QVariant::fromValue( Qgis::RasterPyramidFormat::Erdas ) );
161 connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
162 connect( mBrightnessSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
163 mBrightnessSpinBox->setClearValue( 0 );
165 connect( mSliderContrast, &QAbstractSlider::valueChanged, mContrastSpinBox, &QSpinBox::setValue );
166 connect( mContrastSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderContrast, &QAbstractSlider::setValue );
167 mContrastSpinBox->setClearValue( 0 );
170 connect( mSliderGamma, &QAbstractSlider::valueChanged,
this, &QgsRasterLayerProperties::updateGammaSpinBox );
171 connect( mGammaSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterLayerProperties::updateGammaSlider );
172 mGammaSpinBox->setClearValue( 1.0 );
175 connect( sliderSaturation, &QAbstractSlider::valueChanged, spinBoxSaturation, &QSpinBox::setValue );
176 connect( spinBoxSaturation,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderSaturation, &QAbstractSlider::setValue );
177 spinBoxSaturation->setClearValue( 0 );
180 connect( sliderColorizeStrength, &QAbstractSlider::valueChanged, spinColorizeStrength, &QSpinBox::setValue );
181 connect( spinColorizeStrength,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderColorizeStrength, &QAbstractSlider::setValue );
182 spinColorizeStrength->setClearValue( 100 );
185 connect( comboGrayscale,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLayerProperties::toggleSaturationControls );
188 connect( mColorizeCheck, &QAbstractButton::toggled,
this, &QgsRasterLayerProperties::toggleColorizeControls );
191 connect( lbxPyramidResolutions, &QListWidget::itemSelectionChanged,
this, &QgsRasterLayerProperties::toggleBuildPyramidsButton );
193 connect( mRefreshLayerCheckBox, &QCheckBox::toggled, mRefreshLayerIntervalSpinBox, &QDoubleSpinBox::setEnabled );
196 mScaleRangeWidget->setMapCanvas( mMapCanvas );
201 tableViewMetadataUrl->setSelectionMode( QAbstractItemView::SingleSelection );
202 tableViewMetadataUrl->setSelectionBehavior( QAbstractItemView::SelectRows );
203 tableViewMetadataUrl->horizontalHeader()->setStretchLastSection(
true );
204 tableViewMetadataUrl->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch );
206 mMetadataUrlModel =
new QStandardItemModel( tableViewMetadataUrl );
207 mMetadataUrlModel->clear();
208 mMetadataUrlModel->setColumnCount( 3 );
209 QStringList metadataUrlHeaders;
210 metadataUrlHeaders << tr(
"URL" ) << tr(
"Type" ) << tr(
"Format" );
211 mMetadataUrlModel->setHorizontalHeaderLabels( metadataUrlHeaders );
212 tableViewMetadataUrl->setModel( mMetadataUrlModel );
213 tableViewMetadataUrl->setItemDelegate(
new MetadataUrlItemDelegate(
this ) );
220 mRasterTransparencyWidget->pbnAddValuesFromDisplay->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionContextHelp.png" ) ) );
223 mRasterTransparencyWidget->pbnImportTransparentPixelValues->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionFileOpen.svg" ) ) );
224 mRasterTransparencyWidget->pbnExportTransparentPixelValues->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionFileSave.svg" ) ) );
232 updateRasterAttributeTableOptionsPage();
236 connect( mCreateRasterAttributeTableButton, &QPushButton::clicked,
this, [ = ]
241 QgsCreateRasterAttributeTableDialog dlg { mRasterLayer };
242 dlg.setOpenWhenDoneVisible(
false );
243 if ( dlg.exec() == QDialog::Accepted )
245 updateRasterAttributeTableOptionsPage();
250 connect( mLoadRasterAttributeTableFromFileButton, &QPushButton::clicked,
this, [ = ]
255 if ( dlg.exec() == QDialog::Accepted )
257 updateRasterAttributeTableOptionsPage();
261 mBackupCrs = mRasterLayer->crs();
264 if ( mMapCanvas && mRasterTransparencyWidget->pixelSelectorTool() )
276 connect( mRasterTransparencyWidget->pbnAddValuesFromDisplay, &QPushButton::clicked,
this, [ = ]
282 mMapCanvas->window()->raise();
283 mMapCanvas->window()->activateWindow();
284 mMapCanvas->window()->setFocus();
301 mMapTipExpressionWidget->registerExpressionContextGenerator(
this );
303 connect( mInsertExpressionButton, &QAbstractButton::clicked,
this, [ = ]
305 QString expression = QStringLiteral(
"[% " );
306 expression += mMapTipExpressionWidget->expression();
307 expression += QLatin1String(
" %]" );
308 mMapTipWidget->insertText( expression );
317 cboResamplingMethod->clear();
320 for (
const QPair<QString, QString> &method : std::as_const( constProviderType ) )
322 cboResamplingMethod->addItem( method.second, method.first );
326 QString prefix = provider->name() +
"/driverOptions/_pyramids/";
328 QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
329 int idx = cboResamplingMethod->findData( defaultMethod );
331 cboResamplingMethod->setCurrentIndex( idx );
335 const QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
339 if ( pyramid.getExists() )
341 lbxPyramidResolutions->addItem(
new QListWidgetItem( myPyramidPixmap,
342 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
343 QString::number( pyramid.getYDim() ) ) );
347 lbxPyramidResolutions->addItem(
new QListWidgetItem( myNoPyramidPixmap,
348 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
349 QString::number( pyramid.getYDim() ) ) );
356 mOptsPage_Pyramids->setEnabled(
false );
365 mOptsPage_Histogram->setEnabled(
false );
368 QVBoxLayout *layout =
new QVBoxLayout( metadataFrame );
369 layout->setContentsMargins( 0, 0, 0, 0 );
371 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
372 mMetadataWidget->setMapCanvas( mMapCanvas );
373 layout->addWidget( mMetadataWidget );
374 metadataFrame->setLayout( layout );
376 QVBoxLayout *temporalLayout =
new QVBoxLayout( temporalFrame );
377 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
379 temporalLayout->addWidget( mTemporalWidget );
382 QgsDebugMsgLevel(
"Setting crs to " + mRasterLayer->crs().userFriendlyIdentifier(), 2 );
383 mCrsSelector->setCrs( mRasterLayer->crs() );
386 QString pyramidFormat( QStringLiteral(
"<h2>%1</h2><p>%2 %3 %4</p><b><font color='red'><p>%5</p><p>%6</p>" ) );
387 QString pyramidHeader = tr(
"Description" );
388 QString pyramidSentence1 = tr(
"Large resolution raster layers can slow navigation in QGIS." );
389 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." );
390 QString pyramidSentence3 = tr(
"You must have write access in the directory where the original data is stored to build pyramids." );
391 QString pyramidSentence4 = tr(
"Please note that building internal pyramids may alter the original data file and once created they cannot be removed!" );
392 QString pyramidSentence5 = tr(
"Please note that building internal pyramids could corrupt your image - always make a backup of your data first!" );
394 tePyramidDescription->setHtml( pyramidFormat.arg( pyramidHeader,
399 pyramidSentence5 ) );
402 mResamplingGroupBox->setSaveCheckedState(
true );
403 mResamplingUtils.initWidgets( mRasterLayer, mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox, mMaximumOversamplingSpinBox, mCbEarlyResampling );
404 mResamplingUtils.refreshWidgetsFromLayer();
408 btnColorizeColor->setColorDialogTitle( tr(
"Select Color" ) );
409 btnColorizeColor->setContext( QStringLiteral(
"symbology" ) );
414 if ( hueSaturationFilter )
416 sliderSaturation->setValue( hueSaturationFilter->
saturation() );
417 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->
grayscaleMode() );
420 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->
grayscaleMode() ) );
423 mColorizeCheck->setChecked( hueSaturationFilter->
colorizeOn() );
424 btnColorizeColor->setColor( hueSaturationFilter->
colorizeColor() );
425 toggleColorizeControls( hueSaturationFilter->
colorizeOn() );
426 sliderColorizeStrength->setValue( hueSaturationFilter->
colorizeStrength() );
427 mInvertColorsCheck->setChecked( hueSaturationFilter->
invertColors() );
432 mBlendModeComboBox->setBlendMode( mRasterLayer->blendMode() );
437 mRasterTransparencyWidget->cboxTransparencyBand->setShowNotSetOption(
true, tr(
"None" ) );
438 mRasterTransparencyWidget->cboxTransparencyBand->setLayer( mRasterLayer );
447 cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->
alphaBand() ) );
454 mHistogramWidget =
nullptr;
455 if ( mOptsPage_Histogram->isEnabled() )
458 mHistogramStackedWidget->addWidget( mHistogramWidget );
471 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
473 for (
const QString &name : constRenderersList )
477 if ( ( mRasterLayer->rasterType() != Qgis::RasterLayerType::SingleBandColorData && entry.
name != QLatin1String(
"singlebandcolordata" ) ) ||
478 ( mRasterLayer->rasterType() == Qgis::RasterLayerType::SingleBandColorData && entry.
name == QLatin1String(
"singlebandcolordata" ) ) )
484 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
489 QString rendererType = renderer->
type();
490 widgetIndex = mRenderTypeComboBox->findData( rendererType );
491 if ( widgetIndex != -1 )
493 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
494 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
495 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
498 if ( rendererType == QLatin1String(
"singlebandcolordata" ) && mRenderTypeComboBox->count() == 1 )
501 QSizePolicy sizep = mBandRenderingGrpBx->sizePolicy();
502 sizep.setVerticalStretch( 0 );
503 sizep.setVerticalPolicy( QSizePolicy::Maximum );
504 mBandRenderingGrpBx->setSizePolicy( sizep );
505 mBandRenderingGrpBx->updateGeometry();
508 if ( mRasterLayer->providerType() != QLatin1String(
"wms" ) )
510 mWMSPrintGroupBox->hide();
511 mPublishDataSourceUrlCheckBox->hide();
512 mBackgroundLayerCheckBox->hide();
519 const int horizontalDpi = logicalDpiX();
522 if ( horizontalDpi > 96 )
524 mMetadataViewer->setZoomFactor( mMetadataViewer->zoomFactor() * 0.9 );
526 mMetadataViewer->page()->setLinkDelegationPolicy( QWebPage::LinkDelegationPolicy::DelegateAllLinks );
527 connect( mMetadataViewer->page(), &QWebPage::linkClicked,
this, &QgsRasterLayerProperties::urlClicked );
528 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
529 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
535 mRenderTypeComboBox_currentIndexChanged( widgetIndex );
543 if ( !settings.
contains( QStringLiteral(
"/Windows/RasterLayerProperties/tab" ) ) )
545 settings.
setValue( QStringLiteral(
"Windows/RasterLayerProperties/tab" ),
546 mOptStackedWidget->indexOf( mOptsPage_Style ) );
551 QString title = tr(
"Layer Properties — %1" ).arg( lyr->name() );
553 if ( !mRasterLayer->styleManager()->isDefault( mRasterLayer->styleManager()->currentStyle() ) )
554 title += QStringLiteral(
" (%1)" ).arg( mRasterLayer->styleManager()->currentStyle() );
555 restoreOptionsBaseUi( title );
556 optionsStackedWidget_CurrentChanged( mOptionsStackedWidget->currentIndex() );
559 mOptsPage_Information->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#information-properties" ) );
560 mOptsPage_Source->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#source-properties" ) );
561 mOptsPage_Style->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#symbology-properties" ) );
562 mOptsPage_Transparency->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#transparency-properties" ) );
564 if ( mOptsPage_Histogram )
565 mOptsPage_Histogram->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#histogram-properties" ) );
567 mOptsPage_Rendering->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#rendering-properties" ) );
568 mOptsPage_Temporal->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#temporal-properties" ) );
570 if ( mOptsPage_Pyramids )
571 mOptsPage_Pyramids->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#pyramids-properties" ) );
573 if ( mOptsPage_Display )
574 mOptsPage_Display->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#display-properties" ) );
576 mOptsPage_Metadata->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#metadata-properties" ) );
577 mOptsPage_Legend->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#legend-properties" ) );
578 mOptsPage_Server->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#server-properties" ) );
593 mLayerPropertiesPages << page;
596 if ( beforePage.isEmpty() )
614void QgsRasterLayerProperties::updateRasterAttributeTableOptionsPage( )
616 if ( mRasterAttributeTableWidget )
618 mOptsPage_RasterAttributeTable->layout()->removeWidget( mRasterAttributeTableWidget );
619 mRasterAttributeTableWidget =
nullptr;
626 mOptsPage_RasterAttributeTable->layout()->addWidget( mRasterAttributeTableWidget );
629 mNoRasterAttributeTableWidget->hide();
633 mNoRasterAttributeTableWidget->show();
638void QgsRasterLayerProperties::setRendererWidget(
const QString &rendererName )
651 opacity = oldRenderer->
opacity();
660 QgsDebugMsgLevel( QStringLiteral(
"renderer has widgetCreateFunction" ), 3 );
663 if ( oldWidget && ( !oldRenderer || rendererName != oldRenderer->
type() ) )
665 if ( rendererName == QLatin1String(
"singlebandgray" ) )
668 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
670 else if ( rendererName == QLatin1String(
"multibandcolor" ) )
673 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
681 mRendererStackedWidget->addWidget( mRendererWidget );
685 std::unique_ptr<QgsRasterRenderer> oldRenderer;
686 oldRenderer.reset( oldWidget->
renderer() );
687 std::unique_ptr<QgsRasterRenderer> newRenderer;
688 newRenderer.reset( mRendererWidget->
renderer() );
689 const QList<int> oldBands = oldRenderer->
usesBands();
690 const QList<int> newBands = newRenderer->usesBands();
691 if ( oldBands != newBands )
699 const int widgetIndex = mRenderTypeComboBox->findData( rendererName );
700 if ( widgetIndex != -1 )
702 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
703 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
704 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
707 if ( mRendererWidget != oldWidget )
710 if ( mHistogramWidget )
716void QgsRasterLayerProperties::sync()
720 if ( !mSourceWidget )
725 QHBoxLayout *layout =
new QHBoxLayout();
726 layout->addWidget( mSourceWidget );
727 mSourceGroupBox->setLayout( layout );
728 mSourceGroupBox->show();
732 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
733 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
751 mRasterTransparencyWidget->gboxNoDataValue->setEnabled(
false );
752 mRasterTransparencyWidget->gboxCustomTransparency->setEnabled(
false );
753 mOptionsStackedWidget->setCurrentWidget( mOptsPage_Server );
759 if ( mOptsPage_Pyramids )
761 delete mOptsPage_Pyramids;
762 mOptsPage_Pyramids =
nullptr;
768 if ( mOptsPage_Histogram )
770 delete mOptsPage_Histogram;
771 mOptsPage_Histogram =
nullptr;
772 delete mHistogramWidget;
773 mHistogramWidget =
nullptr;
785 if ( brightnessFilter )
787 mSliderBrightness->setValue( brightnessFilter->
brightness() );
788 mSliderContrast->setValue( brightnessFilter->
contrast() );
789 mGammaSpinBox->setValue( brightnessFilter->
gamma() );
795 if ( hueSaturationFilter )
797 sliderSaturation->setValue( hueSaturationFilter->
saturation() );
798 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->
grayscaleMode() );
801 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->
grayscaleMode() ) );
804 mColorizeCheck->setChecked( hueSaturationFilter->
colorizeOn() );
805 btnColorizeColor->setColor( hueSaturationFilter->
colorizeColor() );
806 toggleColorizeControls( hueSaturationFilter->
colorizeOn() );
807 sliderColorizeStrength->setValue( hueSaturationFilter->
colorizeStrength() );
808 mInvertColorsCheck->setChecked( hueSaturationFilter->
invertColors() );
821 mLayerOrigNameLineEd->setText( mRasterLayer->
name() );
828 updateInformationContent();
831 mLayerShortNameLineEdit->setText( mRasterLayer->
shortName() );
834 mLayerShortNameLineEdit->setValidator( shortNameValidator );
837 mLayerTitleLineEdit->setText( mRasterLayer->
title() );
838 mLayerAbstractTextEdit->setPlainText( mRasterLayer->
abstract() );
839 mLayerKeywordListLineEdit->setText( mRasterLayer->
keywordList() );
840 mLayerDataUrlLineEdit->setText( mRasterLayer->
dataUrl() );
841 mLayerDataUrlFormatComboBox->setCurrentIndex(
842 mLayerDataUrlFormatComboBox->findText(
848 mLayerAttributionLineEdit->setText( mRasterLayer->
attribution() );
849 mLayerAttributionUrlLineEdit->setText( mRasterLayer->
attributionUrl() );
855 const int row = mMetadataUrlModel->rowCount();
856 mMetadataUrlModel->setItem( row, 0,
new QStandardItem( metaUrl.url ) );
857 mMetadataUrlModel->setItem( row, 1,
new QStandardItem( metaUrl.type ) );
858 mMetadataUrlModel->setItem( row, 2,
new QStandardItem( metaUrl.format ) );
862 mLayerLegendUrlLineEdit->setText( mRasterLayer->
legendUrl() );
863 mLayerLegendUrlFormatComboBox->setCurrentIndex( mLayerLegendUrlFormatComboBox->findText( mRasterLayer->
legendUrlFormat() ) );
868 QVariant wmsPrintLayer = mRasterLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
869 if ( wmsPrintLayer.isValid() )
871 mWMSPrintLayerLineEdit->setText( wmsPrintLayer.toString() );
874 QVariant wmsPublishDataSourceUrl = mRasterLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
875 mPublishDataSourceUrlCheckBox->setChecked( wmsPublishDataSourceUrl.toBool() );
877 QVariant wmsBackgroundLayer = mRasterLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ),
false );
878 mBackgroundLayerCheckBox->setChecked( wmsBackgroundLayer.toBool() );
880 mLegendPlaceholderWidget->setLastPathSettingsKey( QStringLiteral(
"lastLegendPlaceholderDir" ) );
882 mLegendConfigEmbeddedWidget->setLayer( mRasterLayer );
887 updateDataDefinedButtons();
891 page->syncToLayer( mRasterLayer );
896void QgsRasterLayerProperties::apply()
900 const QString newSource = mSourceWidget->
sourceUri();
901 if ( newSource != mRasterLayer->
source() )
908 if ( !mRasterLayer->
isValid() )
922 mLegendConfigEmbeddedWidget->applyToLayer();
943 if (
"" != mRasterTransparencyWidget->leNoDataValue->text() )
945 bool myDoubleOk =
false;
950 myNoDataRangeList << myNoDataRange;
953 for (
int bandNo = 1; bandNo <= mRasterLayer->
dataProvider()->bandCount(); bandNo++ )
961 if ( rendererWidget )
968 mBackupCrs = mRasterLayer->
crs();
970 mMetadataFilled =
false;
974 if ( rasterRenderer )
976 rasterRenderer->
setAlphaBand( mRasterTransparencyWidget->cboxTransparencyBand->currentBand() );
977 rasterRenderer->
setNodataColor( mRasterTransparencyWidget->mNodataColorButton->color() );
981 if ( mRasterTransparencyWidget->tableTransparency->columnCount() == 4 )
984 QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
985 for (
int myListRunner = 0; myListRunner < mRasterTransparencyWidget->tableTransparency->rowCount(); myListRunner++ )
987 myTransparentPixel.
red = transparencyCellValue( myListRunner, 0 );
988 myTransparentPixel.
green = transparencyCellValue( myListRunner, 1 );
989 myTransparentPixel.
blue = transparencyCellValue( myListRunner, 2 );
991 myTransparentThreeValuePixelList.append( myTransparentPixel );
995 else if ( mRasterTransparencyWidget->tableTransparency->columnCount() == 3 )
998 QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
999 for (
int myListRunner = 0; myListRunner < mRasterTransparencyWidget->tableTransparency->rowCount(); myListRunner++ )
1001 myTransparentPixel.
min = transparencyCellValue( myListRunner, 0 );
1002 myTransparentPixel.
max = transparencyCellValue( myListRunner, 1 );
1005 myTransparentSingleValuePixelList.append( myTransparentPixel );
1016 rasterRenderer->
setOpacity( mRasterTransparencyWidget->mOpacityWidget->opacity() );
1023 mRasterLayer->
setName( mLayerOrigNameLineEd->text() );
1038 mResamplingUtils.refreshLayerFromWidgets();
1042 if ( hueSaturationFilter )
1044 hueSaturationFilter->
setSaturation( sliderSaturation->value() );
1046 hueSaturationFilter->
setColorizeOn( mColorizeCheck->checkState() );
1049 hueSaturationFilter->
setInvertColors( mInvertColorsCheck->isChecked() );
1053 mRasterLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
1058 mRasterLayer->
setCrs( mCrsSelector->crs() );
1060 if ( mRasterLayer->
shortName() != mLayerShortNameLineEdit->text() )
1061 mMetadataFilled =
false;
1062 mRasterLayer->
setShortName( mLayerShortNameLineEdit->text() );
1064 if ( mRasterLayer->
title() != mLayerTitleLineEdit->text() )
1065 mMetadataFilled =
false;
1066 mRasterLayer->
setTitle( mLayerTitleLineEdit->text() );
1068 if ( mRasterLayer->
abstract() != mLayerAbstractTextEdit->toPlainText() )
1069 mMetadataFilled =
false;
1070 mRasterLayer->
setAbstract( mLayerAbstractTextEdit->toPlainText() );
1072 if ( mRasterLayer->
keywordList() != mLayerKeywordListLineEdit->text() )
1073 mMetadataFilled =
false;
1074 mRasterLayer->
setKeywordList( mLayerKeywordListLineEdit->text() );
1076 if ( mRasterLayer->
dataUrl() != mLayerDataUrlLineEdit->text() )
1077 mMetadataFilled =
false;
1078 mRasterLayer->
setDataUrl( mLayerDataUrlLineEdit->text() );
1080 if ( mRasterLayer->
dataUrlFormat() != mLayerDataUrlFormatComboBox->currentText() )
1081 mMetadataFilled =
false;
1082 mRasterLayer->
setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
1085 if ( mRasterLayer->
attribution() != mLayerAttributionLineEdit->text() )
1086 mMetadataFilled =
false;
1087 mRasterLayer->
setAttribution( mLayerAttributionLineEdit->text() );
1089 if ( mRasterLayer->
attributionUrl() != mLayerAttributionUrlLineEdit->text() )
1090 mMetadataFilled =
false;
1094 QList<QgsMapLayerServerProperties::MetadataUrl> metaUrls;
1095 for (
int row = 0; row < mMetadataUrlModel->rowCount() ; row++ )
1098 metaUrl.
url = mMetadataUrlModel->item( row, 0 )->text();
1099 metaUrl.
type = mMetadataUrlModel->item( row, 1 )->text();
1100 metaUrl.
format = mMetadataUrlModel->item( row, 2 )->text();
1101 metaUrls.append( metaUrl );
1102 mMetadataFilled =
false;
1106 if ( mRasterLayer->
legendUrl() != mLayerLegendUrlLineEdit->text() )
1107 mMetadataFilled =
false;
1108 mRasterLayer->
setLegendUrl( mLayerLegendUrlLineEdit->text() );
1110 if ( mRasterLayer->
legendUrlFormat() != mLayerLegendUrlFormatComboBox->currentText() )
1111 mMetadataFilled =
false;
1114 if ( !mWMSPrintLayerLineEdit->text().isEmpty() )
1116 mRasterLayer->
setCustomProperty( QStringLiteral(
"WMSPrintLayer" ), mWMSPrintLayerLineEdit->text() );
1119 mRasterLayer->
setCustomProperty(
"WMSPublishDataSourceUrl", mPublishDataSourceUrlCheckBox->isChecked() );
1120 mRasterLayer->
setCustomProperty(
"WMSBackgroundLayer", mBackgroundLayerCheckBox->isChecked() );
1136void QgsRasterLayerProperties::buttonBuildPyramids_clicked()
1148 for (
int myCounterInt = 0; myCounterInt < lbxPyramidResolutions->count(); myCounterInt++ )
1150 QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt );
1152 myPyramidList[myCounterInt].setBuild( myItem->isSelected() || myPyramidList[myCounterInt].getExists() );
1156 QString prefix = provider->
name() +
"/driverOptions/_pyramids/";
1158 QString resamplingMethod( cboResamplingMethod->currentData().toString() );
1159 mySettings.
setValue( prefix +
"resampling", resamplingMethod );
1166 QApplication::setOverrideCursor( Qt::WaitCursor );
1173 QApplication::restoreOverrideCursor();
1174 mPyramidProgress->setValue( 0 );
1175 buttonBuildPyramids->setEnabled(
false );
1176 if ( !res.isNull() )
1178 if ( res == QLatin1String(
"CANCELED" ) )
1182 else if ( res == QLatin1String(
"ERROR_WRITE_ACCESS" ) )
1184 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1185 tr(
"Write access denied. Adjust the file permissions and try again." ) );
1187 else if ( res == QLatin1String(
"ERROR_WRITE_FORMAT" ) )
1189 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1190 tr(
"The file was not writable. Some formats do not "
1191 "support pyramid overviews. Consult the GDAL documentation if in doubt." ) );
1193 else if ( res == QLatin1String(
"FAILED_NOT_SUPPORTED" ) )
1195 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1196 tr(
"Building pyramid overviews is not supported on this type of raster." ) );
1198 else if ( res == QLatin1String(
"ERROR_JPEG_COMPRESSION" ) )
1200 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1201 tr(
"Building internal pyramid overviews is not supported on raster layers with JPEG compression and your current libtiff library." ) );
1203 else if ( res == QLatin1String(
"ERROR_VIRTUAL" ) )
1205 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1206 tr(
"Building pyramid overviews is not supported on this type of raster." ) );
1214 lbxPyramidResolutions->clear();
1222 if ( pyramid.getExists() )
1224 lbxPyramidResolutions->addItem(
new QListWidgetItem( myPyramidPixmap,
1225 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
1226 QString::number( pyramid.getYDim() ) ) );
1230 lbxPyramidResolutions->addItem(
new QListWidgetItem( myNoPyramidPixmap,
1231 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
1232 QString::number( pyramid.getYDim() ) ) );
1241 updateInformationContent();
1244void QgsRasterLayerProperties::urlClicked(
const QUrl &url )
1246 QFileInfo file( url.toLocalFile() );
1247 if ( file.exists() && !file.isDir() )
1250 QDesktopServices::openUrl( url );
1253void QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged(
int index )
1255 if ( index < 0 || mDisableRenderTypeComboBoxCurrentIndexChanged || ! mRasterLayer->renderer() )
1260 QString rendererName = mRenderTypeComboBox->itemData( index ).toString();
1261 setRendererWidget( rendererName );
1271void QgsRasterLayerProperties::setTransparencyCell(
int row,
int column,
double value )
1273 QgsDebugMsgLevel( QStringLiteral(
"value = %1" ).arg( value, 0,
'g', 17 ), 3 );
1275 if ( !provider )
return;
1278 if ( !renderer )
return;
1279 int nBands = renderer->
usesBands().size();
1281 QLineEdit *lineEdit =
new QLineEdit();
1282 lineEdit->setFrame(
false );
1284 lineEdit->setContentsMargins( 1, 1, 1, 1 );
1286 if ( column == mRasterTransparencyWidget->tableTransparency->columnCount() - 1 )
1290 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
1291 lineEdit->setText( QString::number(
static_cast<int>( value ) ) );
1296 QString valueString;
1302 if ( !std::isnan( value ) )
1305 valueString = QLocale().toString( v,
'g' ) ;
1309 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
1310 if ( !std::isnan( value ) )
1312 valueString = QLocale().toString(
static_cast<int>( value ) );
1316 lineEdit->setText( valueString );
1318 mRasterTransparencyWidget->tableTransparency->setCellWidget( row, column, lineEdit );
1319 adjustTransparencyCellWidth( row, column );
1321 if ( nBands == 1 && ( column == 0 || column == 1 ) )
1323 connect( lineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerProperties::transparencyCellTextEdited );
1325 mRasterTransparencyWidget->tableTransparency->resizeColumnsToContents();
1328void QgsRasterLayerProperties::setTransparencyCellValue(
int row,
int column,
double value )
1330 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1331 if ( !lineEdit )
return;
1333 lineEdit->setText( QLocale().toString( v,
'g' ) );
1334 lineEdit->adjustSize();
1335 adjustTransparencyCellWidth( row, column );
1336 mRasterTransparencyWidget->tableTransparency->resizeColumnsToContents();
1339double QgsRasterLayerProperties::transparencyCellValue(
int row,
int column )
1341 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1342 if ( !lineEdit || lineEdit->text().isEmpty() )
1344 return std::numeric_limits<double>::quiet_NaN();
1346 return QLocale().toDouble( lineEdit->text() );
1349void QgsRasterLayerProperties::adjustTransparencyCellWidth(
int row,
int column )
1351 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1352 if ( !lineEdit )
return;
1354 int width = std::max( lineEdit->fontMetrics().boundingRect( lineEdit->text() ).width() + 10, 100 );
1355 width = std::max( width, mRasterTransparencyWidget->tableTransparency->columnWidth( column ) );
1357 lineEdit->setFixedWidth( width );
1360void QgsRasterLayerProperties::transparencyCellTextEdited(
const QString &text )
1369 int nBands = renderer->
usesBands().size();
1372 QLineEdit *lineEdit = qobject_cast<QLineEdit *>( sender() );
1373 if ( !lineEdit )
return;
1376 for (
int r = 0; r < mRasterTransparencyWidget->tableTransparency->rowCount(); r++ )
1378 for (
int c = 0;
c < mRasterTransparencyWidget->tableTransparency->columnCount();
c++ )
1380 if ( mRasterTransparencyWidget->tableTransparency->cellWidget( r,
c ) == sender() )
1387 if ( row != -1 )
break;
1389 QgsDebugMsgLevel( QStringLiteral(
"row = %1 column =%2" ).arg( row ).arg( column ), 3 );
1393 QLineEdit *toLineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, 1 ) );
1394 if ( !toLineEdit )
return;
1395 bool toChanged = mTransparencyToEdited.value( row );
1396 QgsDebugMsgLevel( QStringLiteral(
"toChanged = %1" ).arg( toChanged ), 3 );
1399 toLineEdit->setText( lineEdit->text() );
1402 else if ( column == 1 )
1404 setTransparencyToEdited( row );
1409void QgsRasterLayerProperties::aboutToShowStyleMenu()
1413 QMenu *m = qobject_cast<QMenu *>( sender() );
1421void QgsRasterLayerProperties::syncToLayer()
1426 setRendererWidget( renderer->
type() );
1432void QgsRasterLayerProperties::setTransparencyToEdited(
int row )
1434 if ( row >= mTransparencyToEdited.size() )
1436 mTransparencyToEdited.resize( row + 1 );
1438 mTransparencyToEdited[row] =
true;
1445 bool isMetadataPanel = ( index ==
mOptStackedWidget->indexOf( mOptsPage_Metadata ) );
1446 mBtnStyle->setVisible( ! isMetadataPanel );
1447 mBtnMetadata->setVisible( isMetadataPanel );
1449 if ( !mHistogramWidget )
1461 if ( index ==
mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
1464 updateInformationContent();
1470 button->blockSignals(
true );
1474 button->blockSignals(
false );
1477void QgsRasterLayerProperties::updateDataDefinedButtons()
1479 const auto propertyOverrideButtons { findChildren< QgsPropertyOverrideButton * >() };
1482 updateDataDefinedButton( button );
1498void QgsRasterLayerProperties::updateProperty()
1505void QgsRasterLayerProperties::toggleSaturationControls(
int grayscaleMode )
1508 if ( grayscaleMode == 0 )
1510 sliderSaturation->setEnabled(
true );
1511 spinBoxSaturation->setEnabled(
true );
1515 sliderSaturation->setEnabled(
false );
1516 spinBoxSaturation->setEnabled(
false );
1520void QgsRasterLayerProperties::toggleColorizeControls(
bool colorizeEnabled )
1523 btnColorizeColor->setEnabled( colorizeEnabled );
1524 sliderColorizeStrength->setEnabled( colorizeEnabled );
1525 spinColorizeStrength->setEnabled( colorizeEnabled );
1529QLinearGradient QgsRasterLayerProperties::redGradient()
1533 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1534 myGradient.setColorAt( 0.0, QColor( 242, 14, 25, 190 ) );
1535 myGradient.setColorAt( 0.5, QColor( 175, 29, 37, 190 ) );
1536 myGradient.setColorAt( 1.0, QColor( 114, 17, 22, 190 ) );
1539QLinearGradient QgsRasterLayerProperties::greenGradient()
1543 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1544 myGradient.setColorAt( 0.0, QColor( 48, 168, 5, 190 ) );
1545 myGradient.setColorAt( 0.8, QColor( 36, 122, 4, 190 ) );
1546 myGradient.setColorAt( 1.0, QColor( 21, 71, 2, 190 ) );
1549QLinearGradient QgsRasterLayerProperties::blueGradient()
1553 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1554 myGradient.setColorAt( 0.0, QColor( 30, 0, 106, 190 ) );
1555 myGradient.setColorAt( 0.2, QColor( 30, 72, 128, 190 ) );
1556 myGradient.setColorAt( 1.0, QColor( 30, 223, 196, 190 ) );
1559QLinearGradient QgsRasterLayerProperties::grayGradient()
1563 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1564 myGradient.setColorAt( 0.0, QColor( 5, 5, 5, 190 ) );
1565 myGradient.setColorAt( 0.8, QColor( 122, 122, 122, 190 ) );
1566 myGradient.setColorAt( 1.0, QColor( 220, 220, 220, 190 ) );
1569QLinearGradient QgsRasterLayerProperties::highlightGradient()
1573 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1574 myGradient.setColorAt( 1.0, QColor( 255, 255, 255, 50 ) );
1575 myGradient.setColorAt( 0.5, QColor( 255, 255, 255, 100 ) );
1576 myGradient.setColorAt( 0.0, QColor( 255, 255, 255, 150 ) );
1580void QgsRasterLayerProperties::addMetadataUrl()
1582 const int row = mMetadataUrlModel->rowCount();
1583 mMetadataUrlModel->setItem( row, 0,
new QStandardItem( QLatin1String() ) );
1584 mMetadataUrlModel->setItem( row, 1,
new QStandardItem( QLatin1String() ) );
1585 mMetadataUrlModel->setItem( row, 2,
new QStandardItem( QLatin1String() ) );
1588void QgsRasterLayerProperties::removeSelectedMetadataUrl()
1590 const QModelIndexList selectedRows = tableViewMetadataUrl->selectionModel()->selectedRows();
1591 if ( selectedRows.empty() )
1593 mMetadataUrlModel->removeRow( selectedRows[0].row() );
1602void QgsRasterLayerProperties::loadDefaultStyle_clicked()
1604 bool defaultLoadedFlag =
false;
1607 if ( defaultLoadedFlag )
1614 QMessageBox::information(
this,
1615 tr(
"Default Style" ),
1621void QgsRasterLayerProperties::saveDefaultStyle_clicked()
1627 bool defaultSavedFlag =
false;
1635 if ( !defaultSavedFlag )
1638 QMessageBox::information(
this,
1639 tr(
"Default Style" ),
1646void QgsRasterLayerProperties::loadStyle_clicked()
1649 QString lastUsedDir = settings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
1651 QString fileName = QFileDialog::getOpenFileName(
1653 tr(
"Load layer properties from style file" ),
1655 tr(
"QGIS Layer Style File" ) +
" (*.qml)" );
1656 if ( fileName.isEmpty() )
1660 if ( !fileName.endsWith( QLatin1String(
".qml" ), Qt::CaseInsensitive ) )
1661 fileName += QLatin1String(
".qml" );
1665 bool defaultLoadedFlag =
false;
1666 QString message = mRasterLayer->
loadNamedStyle( fileName, defaultLoadedFlag );
1667 if ( defaultLoadedFlag )
1669 settings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( fileName ).absolutePath() );
1674 QMessageBox::information(
this, tr(
"Save Style" ), message );
1679void QgsRasterLayerProperties::saveStyleAs_clicked()
1682 QString lastUsedDir = settings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
1684 QString selectedFilter;
1685 QString outputFileName = QFileDialog::getSaveFileName(
1687 tr(
"Save layer properties as style file" ),
1689 tr(
"QGIS Layer Style File" ) +
" (*.qml)" +
";;" + tr(
"Styled Layer Descriptor" ) +
" (*.sld)",
1691 if ( outputFileName.isEmpty() )
1696 if ( selectedFilter.contains( QStringLiteral(
".qml" ), Qt::CaseInsensitive ) )
1699 type = StyleType::QML;
1704 type = StyleType::SLD;
1710 bool defaultLoadedFlag =
false;
1716 message = mRasterLayer->
saveNamedStyle( outputFileName, defaultLoadedFlag );
1721 message = mRasterLayer->
saveSldStyle( outputFileName, defaultLoadedFlag );
1725 if ( defaultLoadedFlag )
1727 settings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( outputFileName ).absolutePath() );
1731 QMessageBox::information(
this, tr(
"Save Style" ), message );
1734void QgsRasterLayerProperties::restoreWindowModality()
1749void QgsRasterLayerProperties::loadMetadata()
1752 QString myLastUsedDir = myQSettings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
1754 QString myFileName = QFileDialog::getOpenFileName(
this, tr(
"Load layer metadata from metadata file" ), myLastUsedDir,
1755 tr(
"QGIS Layer Metadata File" ) +
" (*.qmd)" );
1756 if ( myFileName.isNull() )
1762 bool defaultLoadedFlag =
false;
1766 if ( defaultLoadedFlag )
1773 QMessageBox::warning(
this, tr(
"Load Metadata" ), myMessage );
1776 QFileInfo myFI( myFileName );
1777 QString myPath = myFI.path();
1778 myQSettings.
setValue( QStringLiteral(
"style/lastStyleDir" ), myPath );
1783void QgsRasterLayerProperties::saveMetadataAs()
1786 QString myLastUsedDir = myQSettings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
1788 QString myOutputFileName = QFileDialog::getSaveFileName(
this, tr(
"Save Layer Metadata as QMD" ),
1789 myLastUsedDir, tr(
"QMD File" ) +
" (*.qmd)" );
1790 if ( myOutputFileName.isNull() )
1803 bool defaultLoadedFlag =
false;
1804 QString message = mRasterLayer->
saveNamedMetadata( myOutputFileName, defaultLoadedFlag );
1805 if ( defaultLoadedFlag )
1806 myQSettings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( myOutputFileName ).absolutePath() );
1808 QMessageBox::information(
this, tr(
"Save Metadata" ), message );
1811void QgsRasterLayerProperties::saveDefaultMetadata()
1815 bool defaultSavedFlag =
false;
1817 if ( !defaultSavedFlag )
1819 QMessageBox::warning(
this, tr(
"Default Metadata" ), errorMsg );
1823void QgsRasterLayerProperties::loadDefaultMetadata()
1825 bool defaultLoadedFlag =
false;
1828 if ( defaultLoadedFlag )
1834 QMessageBox::information(
this, tr(
"Default Metadata" ), myMessage );
1839void QgsRasterLayerProperties::toggleBuildPyramidsButton()
1841 if ( lbxPyramidResolutions->selectedItems().empty() )
1843 buttonBuildPyramids->setEnabled(
false );
1847 buttonBuildPyramids->setEnabled(
true );
1851void QgsRasterLayerProperties::mResetColorRenderingBtn_clicked()
1853 mBlendModeComboBox->setBlendMode( QPainter::CompositionMode_SourceOver );
1854 mSliderBrightness->setValue( 0 );
1855 mSliderContrast->setValue( 0 );
1856 mGammaSpinBox->setValue( 1.0 );
1857 sliderSaturation->setValue( 0 );
1859 mColorizeCheck->setChecked(
false );
1860 sliderColorizeStrength->setValue( 100 );
1861 mInvertColorsCheck->setChecked(
false );
1864bool QgsRasterLayerProperties::rasterIsMultiBandColor()
1869void QgsRasterLayerProperties::updateInformationContent()
1873 const QString html { mRasterLayer->
htmlMetadata().replace( QLatin1String(
"<head>" ), QStringLiteral( R
"raw(<head><style type="text/css">%1</style>)raw" ) ).arg( myStyle ) };
1874 mMetadataViewer->setHtml( html );
1875 mMetadataFilled = true;
1878void QgsRasterLayerProperties::onCancel()
1882 if ( mRasterAttributeTableWidget && mRasterAttributeTableWidget->
isDirty() )
1884 mRasterAttributeTableWidget->
setEditable(
false,
false );
1891 QDomDocument doc( QStringLiteral(
"qgis" ) );
1892 int errorLine, errorColumn;
1893 doc.setContent( mOldStyle.
xmlData(),
false, &myMessage, &errorLine, &errorColumn );
1897 if ( mBackupCrs != mRasterLayer->
crs() )
1898 mRasterLayer->
setCrs( mBackupCrs );
1901void QgsRasterLayerProperties::showHelp()
1903 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
1905 if ( helpPage.isValid() )
1911 QgsHelp::openHelp( QStringLiteral(
"working_with_raster/raster_properties.html" ) );
1915void QgsRasterLayerProperties::updateGammaSpinBox(
int value )
1920void QgsRasterLayerProperties::updateGammaSlider(
double value )
RasterPyramidFormat
Raster pyramid formats.
@ SingleBandGray
A single band image drawn as a range of gray colors.
@ MultiBandColor
A layer containing 2 or more bands, mapped to RGB color space. In the case of a multiband with only t...
@ 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.
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).
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
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 * mapLayerPositionScope(const QgsPointXY &position)
Sets the expression context variables which are available for expressions triggered by moving the mou...
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
The QgsLoadRasterAttributeTableDialog dialog let the user select a VAT.DBF file and associate the res...
void setOpenWhenDoneVisible(bool visible)
Sets the visibility of the "Open newly created raster attribute table" option to visible,...
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.
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.
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.
void rendererChanged()
Signal emitted when renderer is changed.
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 setMapTipTemplate(const QString &mapTipTemplate)
The mapTip is a pretty, html representation for feature information.
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.
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", Qgis::RasterPyramidFormat format=Qgis::RasterPyramidFormat::GeoTiff, 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.
bool canCreateRasterAttributeTable()
Returns true if the raster renderer is suitable for creation of a raster attribute table.
int attributeTableCount() const
Returns the number of attribute tables for the raster by counting the number of bands that have an as...
QgsRasterPipe * pipe()
Returns the raster pipe.
QgsBrightnessContrastFilter * brightnessFilter() const
Returns the raster's brightness/contrast filter.
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)
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