73#include <QDesktopServices>
74#include <QTableWidgetItem>
81#include <QLinearGradient>
82#include <QPainterPath>
84#include <QColorDialog>
91#include <QRegularExpressionValidator>
92#include <QRegularExpression>
97 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
98 , mDefaultStandardDeviation( 0 )
99 , mDefaultRedBand( 0 )
100 , mDefaultGreenBand( 0 )
101 , mDefaultBlueBand( 0 )
103 , mGradientHeight( 0.0 )
104 , mGradientWidth( 0.0 )
105 , mMetadataFilled( false )
107 mGrayMinimumMaximumEstimated =
true;
108 mRGBMinimumMaximumEstimated =
true;
113 mOptsPage_Information->layout()->addWidget( mMetadataViewer );
117 transparencyScrollArea->setWidget( mRasterTransparencyWidget );
119 connect( buttonBuildPyramids, &QPushButton::clicked,
this, &QgsRasterLayerProperties::buttonBuildPyramids_clicked );
121 connect( mRenderTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged );
122 connect( mResetColorRenderingBtn, &QToolButton::clicked,
this, &QgsRasterLayerProperties::mResetColorRenderingBtn_clicked );
123 connect( buttonRemoveMetadataUrl, &QPushButton::clicked,
this, &QgsRasterLayerProperties::removeSelectedMetadataUrl );
124 connect( buttonAddMetadataUrl, &QPushButton::clicked,
this, &QgsRasterLayerProperties::addMetadataUrl );
129 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRasterLayerProperties::showHelp );
131 mSourceGroupBox->hide();
133 mBtnStyle =
new QPushButton( tr(
"Style" ) );
134 buttonBox->addButton(
mBtnStyle, QDialogButtonBox::ResetRole );
148 connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
149 connect( mBrightnessSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
150 mBrightnessSpinBox->setClearValue( 0 );
152 connect( mSliderContrast, &QAbstractSlider::valueChanged, mContrastSpinBox, &QSpinBox::setValue );
153 connect( mContrastSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderContrast, &QAbstractSlider::setValue );
154 mContrastSpinBox->setClearValue( 0 );
157 connect( mSliderGamma, &QAbstractSlider::valueChanged,
this, &QgsRasterLayerProperties::updateGammaSpinBox );
158 connect( mGammaSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterLayerProperties::updateGammaSlider );
159 mGammaSpinBox->setClearValue( 1.0 );
162 connect( sliderSaturation, &QAbstractSlider::valueChanged, spinBoxSaturation, &QSpinBox::setValue );
163 connect( spinBoxSaturation,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderSaturation, &QAbstractSlider::setValue );
164 spinBoxSaturation->setClearValue( 0 );
167 connect( sliderColorizeStrength, &QAbstractSlider::valueChanged, spinColorizeStrength, &QSpinBox::setValue );
168 connect( spinColorizeStrength,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderColorizeStrength, &QAbstractSlider::setValue );
169 spinColorizeStrength->setClearValue( 100 );
172 connect( comboGrayscale,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLayerProperties::toggleSaturationControls );
175 connect( mColorizeCheck, &QAbstractButton::toggled,
this, &QgsRasterLayerProperties::toggleColorizeControls );
178 connect( lbxPyramidResolutions, &QListWidget::itemSelectionChanged,
this, &QgsRasterLayerProperties::toggleBuildPyramidsButton );
180 mRefreshSettingsWidget->setLayer( mRasterLayer );
183 mScaleRangeWidget->setMapCanvas(
mCanvas );
188 tableViewMetadataUrl->setSelectionMode( QAbstractItemView::SingleSelection );
189 tableViewMetadataUrl->setSelectionBehavior( QAbstractItemView::SelectRows );
190 tableViewMetadataUrl->horizontalHeader()->setStretchLastSection(
true );
191 tableViewMetadataUrl->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch );
193 mMetadataUrlModel =
new QStandardItemModel( tableViewMetadataUrl );
194 mMetadataUrlModel->clear();
195 mMetadataUrlModel->setColumnCount( 3 );
196 QStringList metadataUrlHeaders;
197 metadataUrlHeaders << tr(
"URL" ) << tr(
"Type" ) << tr(
"Format" );
198 mMetadataUrlModel->setHorizontalHeaderLabels( metadataUrlHeaders );
199 tableViewMetadataUrl->setModel( mMetadataUrlModel );
200 tableViewMetadataUrl->setItemDelegate(
new MetadataUrlItemDelegate(
this ) );
207 mRasterTransparencyWidget->pbnAddValuesFromDisplay->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionContextHelp.png" ) ) );
210 mRasterTransparencyWidget->pbnImportTransparentPixelValues->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionFileOpen.svg" ) ) );
211 mRasterTransparencyWidget->pbnExportTransparentPixelValues->setIcon(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionFileSave.svg" ) ) );
219 connect( mEnableMapTips, &QAbstractButton::toggled, mHtmlMapTipGroupBox, &QWidget::setEnabled );
222 updateRasterAttributeTableOptionsPage();
226 connect( mCreateRasterAttributeTableButton, &QPushButton::clicked,
this, [ = ]
231 QgsCreateRasterAttributeTableDialog dlg { mRasterLayer };
232 dlg.setOpenWhenDoneVisible(
false );
233 if ( dlg.exec() == QDialog::Accepted )
235 updateRasterAttributeTableOptionsPage();
240 connect( mLoadRasterAttributeTableFromFileButton, &QPushButton::clicked,
this, [ = ]
245 if ( dlg.exec() == QDialog::Accepted )
247 updateRasterAttributeTableOptionsPage();
251 mBackupCrs = mRasterLayer->crs();
254 if ( mCanvas && mRasterTransparencyWidget->pixelSelectorTool() )
266 connect( mRasterTransparencyWidget->pbnAddValuesFromDisplay, &QPushButton::clicked,
this, [ = ]
272 mCanvas->window()->raise();
273 mCanvas->window()->activateWindow();
274 mCanvas->window()->setFocus();
291 mMapTipExpressionWidget->registerExpressionContextGenerator(
this );
293 connect( mInsertExpressionButton, &QAbstractButton::clicked,
this, [ = ]
295 QString expression = QStringLiteral(
"[% " );
296 expression += mMapTipExpressionWidget->expression();
297 expression += QLatin1String(
" %]" );
298 mMapTipWidget->insertText( expression );
307 cboResamplingMethod->clear();
310 for (
const QPair<QString, QString> &method : std::as_const( constProviderType ) )
312 cboResamplingMethod->addItem( method.second, method.first );
316 QString prefix = provider->name() +
"/driverOptions/_pyramids/";
318 QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
319 int idx = cboResamplingMethod->findData( defaultMethod );
321 cboResamplingMethod->setCurrentIndex( idx );
325 const QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
329 if ( pyramid.getExists() )
331 lbxPyramidResolutions->addItem(
new QListWidgetItem( myPyramidPixmap,
332 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
333 QString::number( pyramid.getYDim() ) ) );
337 lbxPyramidResolutions->addItem(
new QListWidgetItem( myNoPyramidPixmap,
338 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
339 QString::number( pyramid.getYDim() ) ) );
346 mOptsPage_Pyramids->setEnabled(
false );
355 mOptsPage_Histogram->setEnabled(
false );
358 QVBoxLayout *layout =
new QVBoxLayout( metadataFrame );
359 layout->setContentsMargins( 0, 0, 0, 0 );
361 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
362 mMetadataWidget->setMapCanvas( mCanvas );
363 layout->addWidget( mMetadataWidget );
364 metadataFrame->setLayout( layout );
366 QVBoxLayout *temporalLayout =
new QVBoxLayout( temporalFrame );
367 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
369 temporalLayout->addWidget( mTemporalWidget );
372 QgsDebugMsgLevel(
"Setting crs to " + mRasterLayer->crs().userFriendlyIdentifier(), 2 );
373 mCrsSelector->setCrs( mRasterLayer->crs() );
376 QString pyramidFormat( QStringLiteral(
"<h2>%1</h2><p>%2 %3 %4</p><b><font color='red'><p>%5</p><p>%6</p>" ) );
377 QString pyramidHeader = tr(
"Description" );
378 QString pyramidSentence1 = tr(
"Large resolution raster layers can slow navigation in QGIS." );
379 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." );
380 QString pyramidSentence3 = tr(
"You must have write access in the directory where the original data is stored to build pyramids." );
381 QString pyramidSentence4 = tr(
"Please note that building internal pyramids may alter the original data file and once created they cannot be removed!" );
382 QString pyramidSentence5 = tr(
"Please note that building internal pyramids could corrupt your image - always make a backup of your data first!" );
384 tePyramidDescription->setHtml( pyramidFormat.arg( pyramidHeader,
389 pyramidSentence5 ) );
392 mResamplingGroupBox->setSaveCheckedState(
true );
393 mResamplingUtils.initWidgets( mRasterLayer, mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox, mMaximumOversamplingSpinBox, mCbEarlyResampling );
394 mResamplingUtils.refreshWidgetsFromLayer();
398 btnColorizeColor->setColorDialogTitle( tr(
"Select Color" ) );
399 btnColorizeColor->setContext( QStringLiteral(
"symbology" ) );
404 if ( hueSaturationFilter )
406 sliderSaturation->setValue( hueSaturationFilter->
saturation() );
407 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->
grayscaleMode() );
410 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->
grayscaleMode() ) );
413 mColorizeCheck->setChecked( hueSaturationFilter->
colorizeOn() );
414 btnColorizeColor->setColor( hueSaturationFilter->
colorizeColor() );
415 toggleColorizeControls( hueSaturationFilter->
colorizeOn() );
416 sliderColorizeStrength->setValue( hueSaturationFilter->
colorizeStrength() );
417 mInvertColorsCheck->setChecked( hueSaturationFilter->
invertColors() );
422 mBlendModeComboBox->setBlendMode( mRasterLayer->blendMode() );
427 mRasterTransparencyWidget->cboxTransparencyBand->setShowNotSetOption(
true, tr(
"None" ) );
428 mRasterTransparencyWidget->cboxTransparencyBand->setLayer( mRasterLayer );
437 cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->
alphaBand() ) );
444 mHistogramWidget =
nullptr;
445 if ( mOptsPage_Histogram->isEnabled() )
448 mHistogramStackedWidget->addWidget( mHistogramWidget );
461 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
463 for (
const QString &name : constRenderersList )
474 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
479 QString rendererType = renderer->
type();
480 widgetIndex = mRenderTypeComboBox->findData( rendererType );
481 if ( widgetIndex != -1 )
483 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
484 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
485 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
488 if ( rendererType == QLatin1String(
"singlebandcolordata" ) && mRenderTypeComboBox->count() == 1 )
491 QSizePolicy sizep = mBandRenderingGrpBx->sizePolicy();
492 sizep.setVerticalStretch( 0 );
493 sizep.setVerticalPolicy( QSizePolicy::Maximum );
494 mBandRenderingGrpBx->setSizePolicy( sizep );
495 mBandRenderingGrpBx->updateGeometry();
498 if ( mRasterLayer->providerType() != QLatin1String(
"wms" ) )
500 mWMSPrintGroupBox->hide();
501 mPublishDataSourceUrlCheckBox->hide();
502 mBackgroundLayerCheckBox->hide();
509 const int horizontalDpi = logicalDpiX();
512 if ( horizontalDpi > 96 )
514 mMetadataViewer->setZoomFactor( mMetadataViewer->zoomFactor() * 0.9 );
516 mMetadataViewer->page()->setLinkDelegationPolicy( QWebPage::LinkDelegationPolicy::DelegateAllLinks );
518 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
519 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
525 mRenderTypeComboBox_currentIndexChanged( widgetIndex );
527 setMetadataWidget( mMetadataWidget, mOptsPage_Metadata );
529 QMenu *menuStyle =
new QMenu(
this );
532 menuStyle->addSeparator();
535 mBtnStyle->setMenu( menuStyle );
536 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsRasterLayerProperties::aboutToShowStyleMenu );
538 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
539 QMenu *menuMetadata =
new QMenu(
this );
542 menuMetadata->addSeparator();
545 mBtnMetadata->setMenu( menuMetadata );
546 buttonBox->addButton( mBtnMetadata, QDialogButtonBox::ResetRole );
554 if ( !settings.
contains( QStringLiteral(
"/Windows/RasterLayerProperties/tab" ) ) )
556 settings.
setValue( QStringLiteral(
"Windows/RasterLayerProperties/tab" ),
557 mOptStackedWidget->indexOf( mOptsPage_Style ) );
562 optionsStackedWidget_CurrentChanged( mOptionsStackedWidget->currentIndex() );
565 mOptsPage_Information->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#information-properties" ) );
566 mOptsPage_Source->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#source-properties" ) );
567 mOptsPage_Style->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#symbology-properties" ) );
568 mOptsPage_Transparency->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#transparency-properties" ) );
570 if ( mOptsPage_Histogram )
571 mOptsPage_Histogram->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#histogram-properties" ) );
573 mOptsPage_Rendering->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#rendering-properties" ) );
574 mOptsPage_Temporal->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#temporal-properties" ) );
576 if ( mOptsPage_Pyramids )
577 mOptsPage_Pyramids->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#pyramids-properties" ) );
579 if ( mOptsPage_Display )
580 mOptsPage_Display->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#display-properties" ) );
582 mOptsPage_Metadata->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#metadata-properties" ) );
583 mOptsPage_Legend->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#legend-properties" ) );
584 mOptsPage_Server->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#server-properties" ) );
604 if ( beforePage.isEmpty() )
622void QgsRasterLayerProperties::updateRasterAttributeTableOptionsPage( )
624 if ( mRasterAttributeTableWidget )
626 mOptsPage_RasterAttributeTable->layout()->removeWidget( mRasterAttributeTableWidget );
627 mRasterAttributeTableWidget =
nullptr;
633 mRasterAttributeTableWidget =
new QgsRasterAttributeTableWidget(
this, mRasterLayer );
634 mOptsPage_RasterAttributeTable->layout()->addWidget( mRasterAttributeTableWidget );
636 connect( mRasterAttributeTableWidget, &QgsRasterAttributeTableWidget::rendererChanged,
this, &QgsRasterLayerProperties::syncToLayer );
637 mNoRasterAttributeTableWidget->hide();
641 mNoRasterAttributeTableWidget->show();
646void QgsRasterLayerProperties::setRendererWidget(
const QString &rendererName )
659 opacity = oldRenderer->
opacity();
668 QgsDebugMsgLevel( QStringLiteral(
"renderer has widgetCreateFunction" ), 3 );
671 if ( oldWidget && ( !oldRenderer || rendererName != oldRenderer->
type() ) )
673 if ( rendererName == QLatin1String(
"singlebandgray" ) )
676 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
678 else if ( rendererName == QLatin1String(
"multibandcolor" ) )
681 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
689 mRendererStackedWidget->addWidget( mRendererWidget );
693 std::unique_ptr<QgsRasterRenderer> oldRenderer;
694 oldRenderer.reset( oldWidget->
renderer() );
695 std::unique_ptr<QgsRasterRenderer> newRenderer;
696 newRenderer.reset( mRendererWidget->
renderer() );
697 const QList<int> oldBands = oldRenderer->
usesBands();
698 const QList<int> newBands = newRenderer->usesBands();
699 if ( oldBands != newBands )
707 const int widgetIndex = mRenderTypeComboBox->findData( rendererName );
708 if ( widgetIndex != -1 )
710 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
711 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
712 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
715 if ( mRendererWidget != oldWidget )
718 if ( mHistogramWidget )
724void QgsRasterLayerProperties::sync()
728 if ( !mSourceWidget )
733 QHBoxLayout *layout =
new QHBoxLayout();
734 layout->addWidget( mSourceWidget );
735 mSourceGroupBox->setLayout( layout );
736 mSourceGroupBox->show();
740 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
741 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
761 mRasterTransparencyWidget->gboxNoDataValue->setEnabled(
false );
762 mRasterTransparencyWidget->gboxCustomTransparency->setEnabled(
false );
763 mOptionsStackedWidget->setCurrentWidget( mOptsPage_Server );
769 if ( mOptsPage_Pyramids )
771 delete mOptsPage_Pyramids;
772 mOptsPage_Pyramids =
nullptr;
778 if ( mOptsPage_Histogram )
780 delete mOptsPage_Histogram;
781 mOptsPage_Histogram =
nullptr;
782 delete mHistogramWidget;
783 mHistogramWidget =
nullptr;
795 if ( brightnessFilter )
797 mSliderBrightness->setValue( brightnessFilter->
brightness() );
798 mSliderContrast->setValue( brightnessFilter->
contrast() );
799 mGammaSpinBox->setValue( brightnessFilter->
gamma() );
805 if ( hueSaturationFilter )
807 sliderSaturation->setValue( hueSaturationFilter->
saturation() );
808 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->
grayscaleMode() );
811 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->
grayscaleMode() ) );
814 mColorizeCheck->setChecked( hueSaturationFilter->
colorizeOn() );
815 btnColorizeColor->setColor( hueSaturationFilter->
colorizeColor() );
816 toggleColorizeControls( hueSaturationFilter->
colorizeOn() );
817 sliderColorizeStrength->setValue( hueSaturationFilter->
colorizeStrength() );
818 mInvertColorsCheck->setChecked( hueSaturationFilter->
invertColors() );
821 mRefreshSettingsWidget->syncToLayer();
828 mLayerOrigNameLineEd->setText( mRasterLayer->
name() );
835 updateInformationContent();
838 mLayerShortNameLineEdit->setText( mRasterLayer->
shortName() );
841 mLayerShortNameLineEdit->setValidator( shortNameValidator );
844 mLayerTitleLineEdit->setText( mRasterLayer->
title() );
845 mLayerAbstractTextEdit->setPlainText( mRasterLayer->
abstract() );
846 mLayerKeywordListLineEdit->setText( mRasterLayer->
keywordList() );
847 mLayerDataUrlLineEdit->setText( mRasterLayer->
dataUrl() );
848 mLayerDataUrlFormatComboBox->setCurrentIndex(
849 mLayerDataUrlFormatComboBox->findText(
855 mLayerAttributionLineEdit->setText( mRasterLayer->
attribution() );
856 mLayerAttributionUrlLineEdit->setText( mRasterLayer->
attributionUrl() );
862 const int row = mMetadataUrlModel->rowCount();
863 mMetadataUrlModel->setItem( row, 0,
new QStandardItem( metaUrl.url ) );
864 mMetadataUrlModel->setItem( row, 1,
new QStandardItem( metaUrl.type ) );
865 mMetadataUrlModel->setItem( row, 2,
new QStandardItem( metaUrl.format ) );
869 mLayerLegendUrlLineEdit->setText( mRasterLayer->
legendUrl() );
870 mLayerLegendUrlFormatComboBox->setCurrentIndex( mLayerLegendUrlFormatComboBox->findText( mRasterLayer->
legendUrlFormat() ) );
876 QVariant wmsPrintLayer = mRasterLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
877 if ( wmsPrintLayer.isValid() )
879 mWMSPrintLayerLineEdit->setText( wmsPrintLayer.toString() );
882 QVariant wmsPublishDataSourceUrl = mRasterLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
883 mPublishDataSourceUrlCheckBox->setChecked( wmsPublishDataSourceUrl.toBool() );
885 QVariant wmsBackgroundLayer = mRasterLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ),
false );
886 mBackgroundLayerCheckBox->setChecked( wmsBackgroundLayer.toBool() );
888 mLegendPlaceholderWidget->setLastPathSettingsKey( QStringLiteral(
"lastLegendPlaceholderDir" ) );
890 mLegendConfigEmbeddedWidget->setLayer( mRasterLayer );
895 updateDataDefinedButtons();
899 page->syncToLayer( mRasterLayer );
908 const QString newSource = mSourceWidget->
sourceUri();
909 if ( newSource != mRasterLayer->
source() )
916 if ( !mRasterLayer->
isValid() )
930 mLegendConfigEmbeddedWidget->applyToLayer();
951 if (
"" != mRasterTransparencyWidget->leNoDataValue->text() )
953 bool myDoubleOk =
false;
958 myNoDataRangeList << myNoDataRange;
961 for (
int bandNo = 1; bandNo <= mRasterLayer->
dataProvider()->bandCount(); bandNo++ )
969 if ( rendererWidget )
976 mBackupCrs = mRasterLayer->
crs();
978 mMetadataFilled =
false;
982 if ( rasterRenderer )
984 rasterRenderer->
setAlphaBand( mRasterTransparencyWidget->cboxTransparencyBand->currentBand() );
985 rasterRenderer->
setNodataColor( mRasterTransparencyWidget->mNodataColorButton->color() );
989 if ( mRasterTransparencyWidget->tableTransparency->columnCount() == 4 )
992 QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
993 for (
int myListRunner = 0; myListRunner < mRasterTransparencyWidget->tableTransparency->rowCount(); myListRunner++ )
995 myTransparentPixel.
red = transparencyCellValue( myListRunner, 0 );
996 myTransparentPixel.
green = transparencyCellValue( myListRunner, 1 );
997 myTransparentPixel.
blue = transparencyCellValue( myListRunner, 2 );
999 myTransparentThreeValuePixelList.append( myTransparentPixel );
1003 else if ( mRasterTransparencyWidget->tableTransparency->columnCount() == 3 )
1006 QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
1007 for (
int myListRunner = 0; myListRunner < mRasterTransparencyWidget->tableTransparency->rowCount(); myListRunner++ )
1009 myTransparentPixel.
min = transparencyCellValue( myListRunner, 0 );
1010 myTransparentPixel.
max = transparencyCellValue( myListRunner, 1 );
1013 myTransparentSingleValuePixelList.append( myTransparentPixel );
1024 rasterRenderer->
setOpacity( mRasterTransparencyWidget->mOpacityWidget->opacity() );
1031 mRasterLayer->
setName( mLayerOrigNameLineEd->text() );
1038 mRefreshSettingsWidget->saveToLayer();
1045 mResamplingUtils.refreshLayerFromWidgets();
1049 if ( hueSaturationFilter )
1051 hueSaturationFilter->
setSaturation( sliderSaturation->value() );
1053 hueSaturationFilter->
setColorizeOn( mColorizeCheck->checkState() );
1056 hueSaturationFilter->
setInvertColors( mInvertColorsCheck->isChecked() );
1060 mRasterLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
1065 mRasterLayer->
setCrs( mCrsSelector->crs() );
1067 if ( mRasterLayer->
shortName() != mLayerShortNameLineEdit->text() )
1068 mMetadataFilled =
false;
1069 mRasterLayer->
setShortName( mLayerShortNameLineEdit->text() );
1071 if ( mRasterLayer->
title() != mLayerTitleLineEdit->text() )
1072 mMetadataFilled =
false;
1073 mRasterLayer->
setTitle( mLayerTitleLineEdit->text() );
1075 if ( mRasterLayer->
abstract() != mLayerAbstractTextEdit->toPlainText() )
1076 mMetadataFilled =
false;
1077 mRasterLayer->
setAbstract( mLayerAbstractTextEdit->toPlainText() );
1079 if ( mRasterLayer->
keywordList() != mLayerKeywordListLineEdit->text() )
1080 mMetadataFilled =
false;
1081 mRasterLayer->
setKeywordList( mLayerKeywordListLineEdit->text() );
1083 if ( mRasterLayer->
dataUrl() != mLayerDataUrlLineEdit->text() )
1084 mMetadataFilled =
false;
1085 mRasterLayer->
setDataUrl( mLayerDataUrlLineEdit->text() );
1087 if ( mRasterLayer->
dataUrlFormat() != mLayerDataUrlFormatComboBox->currentText() )
1088 mMetadataFilled =
false;
1089 mRasterLayer->
setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
1092 if ( mRasterLayer->
attribution() != mLayerAttributionLineEdit->text() )
1093 mMetadataFilled =
false;
1094 mRasterLayer->
setAttribution( mLayerAttributionLineEdit->text() );
1096 if ( mRasterLayer->
attributionUrl() != mLayerAttributionUrlLineEdit->text() )
1097 mMetadataFilled =
false;
1101 QList<QgsMapLayerServerProperties::MetadataUrl> metaUrls;
1102 for (
int row = 0; row < mMetadataUrlModel->rowCount() ; row++ )
1105 metaUrl.
url = mMetadataUrlModel->item( row, 0 )->text();
1106 metaUrl.
type = mMetadataUrlModel->item( row, 1 )->text();
1107 metaUrl.
format = mMetadataUrlModel->item( row, 2 )->text();
1108 metaUrls.append( metaUrl );
1109 mMetadataFilled =
false;
1113 if ( mRasterLayer->
legendUrl() != mLayerLegendUrlLineEdit->text() )
1114 mMetadataFilled =
false;
1115 mRasterLayer->
setLegendUrl( mLayerLegendUrlLineEdit->text() );
1117 if ( mRasterLayer->
legendUrlFormat() != mLayerLegendUrlFormatComboBox->currentText() )
1118 mMetadataFilled =
false;
1121 if ( !mWMSPrintLayerLineEdit->text().isEmpty() )
1123 mRasterLayer->
setCustomProperty( QStringLiteral(
"WMSPrintLayer" ), mWMSPrintLayerLineEdit->text() );
1126 mRasterLayer->
setCustomProperty(
"WMSPublishDataSourceUrl", mPublishDataSourceUrlCheckBox->isChecked() );
1127 mRasterLayer->
setCustomProperty(
"WMSBackgroundLayer", mBackgroundLayerCheckBox->isChecked() );
1144void QgsRasterLayerProperties::buttonBuildPyramids_clicked()
1156 for (
int myCounterInt = 0; myCounterInt < lbxPyramidResolutions->count(); myCounterInt++ )
1158 QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt );
1160 myPyramidList[myCounterInt].setBuild( myItem->isSelected() || myPyramidList[myCounterInt].getExists() );
1164 QString prefix = provider->
name() +
"/driverOptions/_pyramids/";
1166 QString resamplingMethod( cboResamplingMethod->currentData().toString() );
1167 mySettings.
setValue( prefix +
"resampling", resamplingMethod );
1174 QApplication::setOverrideCursor( Qt::WaitCursor );
1181 QApplication::restoreOverrideCursor();
1182 mPyramidProgress->setValue( 0 );
1183 buttonBuildPyramids->setEnabled(
false );
1184 if ( !res.isNull() )
1186 if ( res == QLatin1String(
"CANCELED" ) )
1190 else if ( res == QLatin1String(
"ERROR_WRITE_ACCESS" ) )
1192 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1193 tr(
"Write access denied. Adjust the file permissions and try again." ) );
1195 else if ( res == QLatin1String(
"ERROR_WRITE_FORMAT" ) )
1197 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1198 tr(
"The file was not writable. Some formats do not "
1199 "support pyramid overviews. Consult the GDAL documentation if in doubt." ) );
1201 else if ( res == QLatin1String(
"FAILED_NOT_SUPPORTED" ) )
1203 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1204 tr(
"Building pyramid overviews is not supported on this type of raster." ) );
1206 else if ( res == QLatin1String(
"ERROR_JPEG_COMPRESSION" ) )
1208 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1209 tr(
"Building internal pyramid overviews is not supported on raster layers with JPEG compression and your current libtiff library." ) );
1211 else if ( res == QLatin1String(
"ERROR_VIRTUAL" ) )
1213 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1214 tr(
"Building pyramid overviews is not supported on this type of raster." ) );
1222 lbxPyramidResolutions->clear();
1230 if ( pyramid.getExists() )
1232 lbxPyramidResolutions->addItem(
new QListWidgetItem( myPyramidPixmap,
1233 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
1234 QString::number( pyramid.getYDim() ) ) );
1238 lbxPyramidResolutions->addItem(
new QListWidgetItem( myNoPyramidPixmap,
1239 QString::number( pyramid.getXDim() ) + QStringLiteral(
" x " ) +
1240 QString::number( pyramid.getYDim() ) ) );
1249 updateInformationContent();
1252void QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged(
int index )
1254 if ( index < 0 || mDisableRenderTypeComboBoxCurrentIndexChanged || ! mRasterLayer->renderer() )
1259 QString rendererName = mRenderTypeComboBox->itemData( index ).toString();
1260 setRendererWidget( rendererName );
1270void QgsRasterLayerProperties::setTransparencyCell(
int row,
int column,
double value )
1272 QgsDebugMsgLevel( QStringLiteral(
"value = %1" ).arg( value, 0,
'g', 17 ), 3 );
1274 if ( !provider )
return;
1277 if ( !renderer )
return;
1278 int nBands = renderer->
usesBands().size();
1280 QLineEdit *lineEdit =
new QLineEdit();
1281 lineEdit->setFrame(
false );
1283 lineEdit->setContentsMargins( 1, 1, 1, 1 );
1285 if ( column == mRasterTransparencyWidget->tableTransparency->columnCount() - 1 )
1289 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
1290 lineEdit->setText( QString::number(
static_cast<int>( value ) ) );
1295 QString valueString;
1301 if ( !std::isnan( value ) )
1304 valueString = QLocale().toString( v,
'g' ) ;
1308 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
1309 if ( !std::isnan( value ) )
1311 valueString = QLocale().toString(
static_cast<int>( value ) );
1315 lineEdit->setText( valueString );
1317 mRasterTransparencyWidget->tableTransparency->setCellWidget( row, column, lineEdit );
1318 adjustTransparencyCellWidth( row, column );
1320 if ( nBands == 1 && ( column == 0 || column == 1 ) )
1322 connect( lineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerProperties::transparencyCellTextEdited );
1324 mRasterTransparencyWidget->tableTransparency->resizeColumnsToContents();
1327void QgsRasterLayerProperties::setTransparencyCellValue(
int row,
int column,
double value )
1329 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1330 if ( !lineEdit )
return;
1332 lineEdit->setText( QLocale().toString( v,
'g' ) );
1333 lineEdit->adjustSize();
1334 adjustTransparencyCellWidth( row, column );
1335 mRasterTransparencyWidget->tableTransparency->resizeColumnsToContents();
1338double QgsRasterLayerProperties::transparencyCellValue(
int row,
int column )
1340 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1341 if ( !lineEdit || lineEdit->text().isEmpty() )
1343 return std::numeric_limits<double>::quiet_NaN();
1345 return QLocale().toDouble( lineEdit->text() );
1348void QgsRasterLayerProperties::adjustTransparencyCellWidth(
int row,
int column )
1350 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, column ) );
1351 if ( !lineEdit )
return;
1353 int width = std::max( lineEdit->fontMetrics().boundingRect( lineEdit->text() ).width() + 10, 100 );
1354 width = std::max( width, mRasterTransparencyWidget->tableTransparency->columnWidth( column ) );
1356 lineEdit->setFixedWidth( width );
1359void QgsRasterLayerProperties::transparencyCellTextEdited(
const QString &text )
1368 int nBands = renderer->
usesBands().size();
1371 QLineEdit *lineEdit = qobject_cast<QLineEdit *>( sender() );
1372 if ( !lineEdit )
return;
1375 for (
int r = 0; r < mRasterTransparencyWidget->tableTransparency->rowCount(); r++ )
1377 for (
int c = 0;
c < mRasterTransparencyWidget->tableTransparency->columnCount();
c++ )
1379 if ( mRasterTransparencyWidget->tableTransparency->cellWidget( r,
c ) == sender() )
1386 if ( row != -1 )
break;
1388 QgsDebugMsgLevel( QStringLiteral(
"row = %1 column =%2" ).arg( row ).arg( column ), 3 );
1392 QLineEdit *toLineEdit =
dynamic_cast<QLineEdit *
>( mRasterTransparencyWidget->tableTransparency->cellWidget( row, 1 ) );
1393 if ( !toLineEdit )
return;
1394 bool toChanged = mTransparencyToEdited.value( row );
1395 QgsDebugMsgLevel( QStringLiteral(
"toChanged = %1" ).arg( toChanged ), 3 );
1398 toLineEdit->setText( lineEdit->text() );
1401 else if ( column == 1 )
1403 setTransparencyToEdited( row );
1408void QgsRasterLayerProperties::aboutToShowStyleMenu()
1412 QMenu *m = qobject_cast<QMenu *>( sender() );
1420void QgsRasterLayerProperties::syncToLayer()
1425 setRendererWidget( renderer->
type() );
1431void QgsRasterLayerProperties::setTransparencyToEdited(
int row )
1433 if ( row >= mTransparencyToEdited.size() )
1435 mTransparencyToEdited.resize( row + 1 );
1437 mTransparencyToEdited[row] =
true;
1444 if ( !mHistogramWidget )
1456 if ( index ==
mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
1459 updateInformationContent();
1465 button->blockSignals(
true );
1469 button->blockSignals(
false );
1472void QgsRasterLayerProperties::updateDataDefinedButtons()
1474 const auto propertyOverrideButtons { findChildren< QgsPropertyOverrideButton * >() };
1477 updateDataDefinedButton( button );
1493void QgsRasterLayerProperties::updateProperty()
1500void QgsRasterLayerProperties::toggleSaturationControls(
int grayscaleMode )
1503 if ( grayscaleMode == 0 )
1505 sliderSaturation->setEnabled(
true );
1506 spinBoxSaturation->setEnabled(
true );
1510 sliderSaturation->setEnabled(
false );
1511 spinBoxSaturation->setEnabled(
false );
1515void QgsRasterLayerProperties::toggleColorizeControls(
bool colorizeEnabled )
1518 btnColorizeColor->setEnabled( colorizeEnabled );
1519 sliderColorizeStrength->setEnabled( colorizeEnabled );
1520 spinColorizeStrength->setEnabled( colorizeEnabled );
1524QLinearGradient QgsRasterLayerProperties::redGradient()
1528 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1529 myGradient.setColorAt( 0.0, QColor( 242, 14, 25, 190 ) );
1530 myGradient.setColorAt( 0.5, QColor( 175, 29, 37, 190 ) );
1531 myGradient.setColorAt( 1.0, QColor( 114, 17, 22, 190 ) );
1534QLinearGradient QgsRasterLayerProperties::greenGradient()
1538 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1539 myGradient.setColorAt( 0.0, QColor( 48, 168, 5, 190 ) );
1540 myGradient.setColorAt( 0.8, QColor( 36, 122, 4, 190 ) );
1541 myGradient.setColorAt( 1.0, QColor( 21, 71, 2, 190 ) );
1544QLinearGradient QgsRasterLayerProperties::blueGradient()
1548 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1549 myGradient.setColorAt( 0.0, QColor( 30, 0, 106, 190 ) );
1550 myGradient.setColorAt( 0.2, QColor( 30, 72, 128, 190 ) );
1551 myGradient.setColorAt( 1.0, QColor( 30, 223, 196, 190 ) );
1554QLinearGradient QgsRasterLayerProperties::grayGradient()
1558 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1559 myGradient.setColorAt( 0.0, QColor( 5, 5, 5, 190 ) );
1560 myGradient.setColorAt( 0.8, QColor( 122, 122, 122, 190 ) );
1561 myGradient.setColorAt( 1.0, QColor( 220, 220, 220, 190 ) );
1564QLinearGradient QgsRasterLayerProperties::highlightGradient()
1568 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1569 myGradient.setColorAt( 1.0, QColor( 255, 255, 255, 50 ) );
1570 myGradient.setColorAt( 0.5, QColor( 255, 255, 255, 100 ) );
1571 myGradient.setColorAt( 0.0, QColor( 255, 255, 255, 150 ) );
1575void QgsRasterLayerProperties::addMetadataUrl()
1577 const int row = mMetadataUrlModel->rowCount();
1578 mMetadataUrlModel->setItem( row, 0,
new QStandardItem( QLatin1String() ) );
1579 mMetadataUrlModel->setItem( row, 1,
new QStandardItem( QLatin1String() ) );
1580 mMetadataUrlModel->setItem( row, 2,
new QStandardItem( QLatin1String() ) );
1583void QgsRasterLayerProperties::removeSelectedMetadataUrl()
1585 const QModelIndexList selectedRows = tableViewMetadataUrl->selectionModel()->selectedRows();
1586 if ( selectedRows.empty() )
1588 mMetadataUrlModel->removeRow( selectedRows[0].row() );
1603void QgsRasterLayerProperties::restoreWindowModality()
1612void QgsRasterLayerProperties::toggleBuildPyramidsButton()
1614 if ( lbxPyramidResolutions->selectedItems().empty() )
1616 buttonBuildPyramids->setEnabled(
false );
1620 buttonBuildPyramids->setEnabled(
true );
1624void QgsRasterLayerProperties::mResetColorRenderingBtn_clicked()
1626 mBlendModeComboBox->setBlendMode( QPainter::CompositionMode_SourceOver );
1627 mSliderBrightness->setValue( 0 );
1628 mSliderContrast->setValue( 0 );
1629 mGammaSpinBox->setValue( 1.0 );
1630 sliderSaturation->setValue( 0 );
1632 mColorizeCheck->setChecked(
false );
1633 sliderColorizeStrength->setValue( 100 );
1634 mInvertColorsCheck->setChecked(
false );
1637bool QgsRasterLayerProperties::rasterIsMultiBandColor()
1642void QgsRasterLayerProperties::updateInformationContent()
1646 const QString html { mRasterLayer->
htmlMetadata().replace( QLatin1String(
"<head>" ), QStringLiteral( R
"raw(<head><style type="text/css">%1</style>)raw" ) ).arg( myStyle ) };
1647 mMetadataViewer->setHtml( html );
1648 mMetadataFilled = true;
1654 if ( mRasterAttributeTableWidget && mRasterAttributeTableWidget->isDirty() )
1656 mRasterAttributeTableWidget->setEditable(
false,
false );
1660 if ( mBackupCrs != mRasterLayer->
crs() )
1661 mRasterLayer->
setCrs( mBackupCrs );
1664void QgsRasterLayerProperties::showHelp()
1666 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
1668 if ( helpPage.isValid() )
1674 QgsHelp::openHelp( QStringLiteral(
"working_with_raster/raster_properties.html" ) );
1678void QgsRasterLayerProperties::updateGammaSpinBox(
int value )
1683void QgsRasterLayerProperties::updateGammaSlider(
double value )
1692 if ( obj == mMapTipPreviewContainer && ev->type() == QEvent::Resize )
1696 return QgsOptionsDialogBase::eventFilter( obj, ev );
1699void QgsRasterLayerProperties::initMapTipPreview()
1702 mMapTipSplitter->setSizes( { 400, 200 } );
1704 mMapTipPreviewContainer->installEventFilter(
this );
1708 mMapTipPreview =
new QgsWebView( mMapTipPreviewContainer );
1711 mMapTipPreview->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
1712 mMapTipPreview->setContextMenuPolicy( Qt::NoContextMenu );
1713 connect( mMapTipPreview, &QWebView::loadFinished,
this, &QgsRasterLayerProperties::resizeMapTip );
1716 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
1717 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
1718 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::LocalStorageEnabled,
true );
1721 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
1722 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
1726 connect( mMapTipWidget, &QgsCodeEditorHTML::textChanged,
this, &QgsRasterLayerProperties::updateMapTipPreview );
1729void QgsRasterLayerProperties::updateMapTipPreview()
1731 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1733 mMapTipPreview->setHtml( htmlContent );
1736void QgsRasterLayerProperties::resizeMapTip()
1739 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1742 const QWebElement container = mMapTipPreview->page()->mainFrame()->findFirstElement(
1743 QStringLiteral(
"#QgsWebViewContainer" ) );
1744 const int width = container.geometry().width();
1745 const int height = container.geometry().height();
1746 mMapTipPreview->resize( width, height );
1749 mMapTipPreview->move( ( mMapTipPreviewContainer->width() - mMapTipPreview->width() ) / 2,
1750 ( mMapTipPreviewContainer->height() - mMapTipPreview->height() ) / 2 );
1753 mMapTipPreview->adjustSize();
@ SingleBandColorData
Single band containing color data.
RasterPyramidFormat
Raster pyramid formats.
@ GeoTiff
Geotiff .ovr (external)
@ Erdas
Erdas Image .aux (external)
@ 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.
@ 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).
@ 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 QgsProviderSourceWidgetProviderRegistry * sourceWidgetProviderRegistry()
Returns the registry of provider source widget providers.
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
Base class for "layer properties" dialogs, containing common utilities for handling functionality in ...
QPushButton * mBtnStyle
Style button.
void saveMetadataToFile()
Allows the user to save the layer's metadata as a file.
virtual void rollback()
Rolls back changes made to the layer.
void optionsStackedWidget_CurrentChanged(int index) override
void saveStyleAsDefault()
Saves the current layer style as the default for the layer.
QList< QgsMapLayerConfigWidget * > mConfigWidgets
Layer config widgets.
void loadDefaultStyle()
Reloads the default style for the layer.
void saveStyleAs()
Saves a style when appriate button is pressed.
void loadStyle()
Triggers a dialog to load a saved style.
QgsMapCanvas * mCanvas
Associated map canvas.
void loadDefaultMetadata()
Reloads the default layer metadata for the layer.
void loadMetadataFromFile()
Allows the user to load layer metadata from a file.
void saveMetadataAsDefault()
Saves the current layer metadata as the default for the layer.
void openUrl(const QUrl &url)
Handles opening a url from the dialog.
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
void currentStyleChanged(const QString ¤tName)
Emitted when the current style has been changed.
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.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
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.
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 setMaximumScale(double scale)
Sets the maximum map scale (i.e.
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.
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.
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
void setName(const QString &name)
Set the display name of the layer.
void setLegendPlaceholderImage(const QString &imgPath)
Set placeholder image for legend.
void setMapTipsEnabled(bool enabled)
Enable or disable map tips for this layer.
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.
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.
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
static QString rasterMapTipPreviewText(QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate)
Returns the html that would be displayed in a maptip for a given layer.
Renderer for multiband images with the color components.
void addPage(const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget, const QStringList &path=QStringList(), const QString &key=QString())
Adds a new page to the dialog pages.
QStackedWidget * mOptStackedWidget
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
void insertPage(const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget, const QString &before, const QStringList &path=QStringList(), const QString &key=QString())
Inserts a new page into the dialog pages.
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.
Q_DECL_DEPRECATED void saveDefaultStyle()
Saves the default style when appropriate button is pressed.
QgsRasterLayerProperties(QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent=nullptr, Qt::WindowFlags=QgsGuiUtils::ModalDialogFlags)
Constructor.
bool eventFilter(QObject *obj, QEvent *ev) override
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void optionsStackedWidget_CurrentChanged(int index) FINAL
void addPropertiesPageFactory(const QgsMapLayerConfigWidgetFactory *factory) FINAL
Adds properties page from a factory.
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
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