35 #include "qgsnative.h"
71 #include <QDesktopServices>
72 #include <QTableWidgetItem>
73 #include <QHeaderView>
74 #include <QTextStream>
76 #include <QFileDialog>
77 #include <QMessageBox>
79 #include <QLinearGradient>
80 #include <QPainterPath>
82 #include <QColorDialog>
84 #include <QMouseEvent>
93 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
94 , mDefaultStandardDeviation( 0 )
95 , mDefaultRedBand( 0 )
96 , mDefaultGreenBand( 0 )
97 , mDefaultBlueBand( 0 )
99 , mGradientHeight( 0.0 )
100 , mGradientWidth( 0.0 )
101 , mMapCanvas( canvas )
102 , mMetadataFilled( false )
104 mGrayMinimumMaximumEstimated =
true;
105 mRGBMinimumMaximumEstimated =
true;
108 connect( mLayerOrigNameLineEd, &QLineEdit::textEdited,
this, &QgsRasterLayerProperties::mLayerOrigNameLineEd_textEdited );
109 connect( buttonBuildPyramids, &QPushButton::clicked,
this, &QgsRasterLayerProperties::buttonBuildPyramids_clicked );
110 connect( pbnAddValuesFromDisplay, &QToolButton::clicked,
this, &QgsRasterLayerProperties::pbnAddValuesFromDisplay_clicked );
111 connect( pbnAddValuesManually, &QToolButton::clicked,
this, &QgsRasterLayerProperties::pbnAddValuesManually_clicked );
113 connect( pbnDefaultValues, &QToolButton::clicked,
this, &QgsRasterLayerProperties::pbnDefaultValues_clicked );
114 connect( pbnExportTransparentPixelValues, &QToolButton::clicked,
this, &QgsRasterLayerProperties::pbnExportTransparentPixelValues_clicked );
115 connect( pbnImportTransparentPixelValues, &QToolButton::clicked,
this, &QgsRasterLayerProperties::pbnImportTransparentPixelValues_clicked );
116 connect( pbnRemoveSelectedRow, &QToolButton::clicked,
this, &QgsRasterLayerProperties::pbnRemoveSelectedRow_clicked );
117 connect( mRenderTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged );
118 connect( mResetColorRenderingBtn, &QToolButton::clicked,
this, &QgsRasterLayerProperties::mResetColorRenderingBtn_clicked );
123 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRasterLayerProperties::showHelp );
125 connect( mSetEndAsStartStaticButton, &QPushButton::clicked,
this, &QgsRasterLayerProperties::setEndAsStartStaticButton_clicked );
126 connect( mProjectTemporalRange, &QRadioButton::toggled,
this, &QgsRasterLayerProperties::passProjectTemporalRange_toggled );
127 connect( mStaticTemporalRange, &QRadioButton::toggled,
this, &QgsRasterLayerProperties::staticTemporalRange_toggled );
129 connect( mStaticTemporalRange, &QRadioButton::toggled, mStaticWmstFrame, &QWidget::setEnabled );
130 connect( mReferenceTime, &QCheckBox::toggled, mWmstReferenceTimeFrame, &QWidget::setEnabled );
135 mSourceGroupBox->hide();
137 mBtnStyle =
new QPushButton( tr(
"Style" ) );
138 QMenu *menuStyle =
new QMenu(
this );
139 menuStyle->addAction( tr(
"Load Style…" ),
this, &QgsRasterLayerProperties::loadStyle_clicked );
140 menuStyle->addAction( tr(
"Save Style…" ),
this, &QgsRasterLayerProperties::saveStyleAs_clicked );
141 menuStyle->addSeparator();
142 menuStyle->addAction( tr(
"Save as Default" ),
this, &QgsRasterLayerProperties::saveDefaultStyle_clicked );
143 menuStyle->addAction( tr(
"Restore Default" ),
this, &QgsRasterLayerProperties::loadDefaultStyle_clicked );
144 mBtnStyle->setMenu( menuStyle );
145 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsRasterLayerProperties::aboutToShowStyleMenu );
146 buttonBox->addButton( mBtnStyle, QDialogButtonBox::ResetRole );
148 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
149 QMenu *menuMetadata =
new QMenu(
this );
150 mActionLoadMetadata = menuMetadata->addAction( tr(
"Load Metadata…" ),
this, &QgsRasterLayerProperties::loadMetadata );
151 mActionSaveMetadataAs = menuMetadata->addAction( tr(
"Save Metadata…" ),
this, &QgsRasterLayerProperties::saveMetadataAs );
152 menuMetadata->addSeparator();
153 menuMetadata->addAction( tr(
"Save as Default" ),
this, &QgsRasterLayerProperties::saveDefaultMetadata );
154 menuMetadata->addAction( tr(
"Restore Default" ),
this, &QgsRasterLayerProperties::loadDefaultMetadata );
155 mBtnMetadata->setMenu( menuMetadata );
156 buttonBox->addButton( mBtnMetadata, QDialogButtonBox::ResetRole );
160 connect(
this, &QDialog::accepted,
this, &QgsRasterLayerProperties::apply );
161 connect(
this, &QDialog::rejected,
this, &QgsRasterLayerProperties::onCancel );
163 connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked,
this, &QgsRasterLayerProperties::apply );
166 connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
167 connect( mBrightnessSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
168 mBrightnessSpinBox->setClearValue( 0 );
170 connect( mSliderContrast, &QAbstractSlider::valueChanged, mContrastSpinBox, &QSpinBox::setValue );
171 connect( mContrastSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mSliderContrast, &QAbstractSlider::setValue );
172 mContrastSpinBox->setClearValue( 0 );
175 connect( mSliderGamma, &QAbstractSlider::valueChanged,
this, &QgsRasterLayerProperties::updateGammaSpinBox );
176 connect( mGammaSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterLayerProperties::updateGammaSlider );
177 mGammaSpinBox->setClearValue( 1.0 );
180 connect( sliderSaturation, &QAbstractSlider::valueChanged, spinBoxSaturation, &QSpinBox::setValue );
181 connect( spinBoxSaturation,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderSaturation, &QAbstractSlider::setValue );
182 spinBoxSaturation->setClearValue( 0 );
185 connect( sliderColorizeStrength, &QAbstractSlider::valueChanged, spinColorizeStrength, &QSpinBox::setValue );
186 connect( spinColorizeStrength,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), sliderColorizeStrength, &QAbstractSlider::setValue );
187 spinColorizeStrength->setClearValue( 100 );
190 connect( comboGrayscale,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLayerProperties::toggleSaturationControls );
193 connect( mColorizeCheck, &QAbstractButton::toggled,
this, &QgsRasterLayerProperties::toggleColorizeControls );
196 connect( lbxPyramidResolutions, &QListWidget::itemSelectionChanged,
this, &QgsRasterLayerProperties::toggleBuildPyramidsButton );
198 connect( mRefreshLayerCheckBox, &QCheckBox::toggled, mRefreshLayerIntervalSpinBox, &QDoubleSpinBox::setEnabled );
201 mScaleRangeWidget->setMapCanvas( mMapCanvas );
205 leNoDataValue->setValidator(
new QgsDoubleValidator( -std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), 1000,
this ) );
220 mPixelSelectorTool = qgis::make_unique<QgsMapToolEmitPoint>( canvas );
226 pbnAddValuesFromDisplay->setEnabled(
false );
240 cboResamplingMethod->clear();
243 for ( QPair<QString, QString> method : constProviderType )
245 cboResamplingMethod->addItem( method.second, method.first );
249 QString prefix = provider->
name() +
"/driverOptions/_pyramids/";
251 QString defaultMethod = mySettings.
value( prefix +
"resampling",
"AVERAGE" ).toString();
252 int idx = cboResamplingMethod->findData( defaultMethod );
254 cboResamplingMethod->setCurrentIndex( idx );
259 QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
261 for ( myRasterPyramidIterator = myPyramidList.begin();
262 myRasterPyramidIterator != myPyramidList.end();
263 ++myRasterPyramidIterator )
265 if ( myRasterPyramidIterator->exists )
267 lbxPyramidResolutions->addItem(
new QListWidgetItem( myPyramidPixmap,
268 QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral(
" x " ) +
269 QString::number( myRasterPyramidIterator->yDim ) ) );
273 lbxPyramidResolutions->addItem(
new QListWidgetItem( myNoPyramidPixmap,
274 QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral(
" x " ) +
275 QString::number( myRasterPyramidIterator->yDim ) ) );
282 mOptsPage_Pyramids->setEnabled(
false );
291 mOptsPage_Histogram->setEnabled(
false );
294 QVBoxLayout *layout =
new QVBoxLayout( metadataFrame );
295 layout->setContentsMargins( 0, 0, 0, 0 );
297 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
299 layout->addWidget( mMetadataWidget );
300 metadataFrame->setLayout( layout );
302 QVBoxLayout *temporalLayout =
new QVBoxLayout( temporalFrame );
303 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
305 temporalLayout->addWidget( mTemporalWidget );
307 setSourceStaticTimeState();
313 mPostgresRasterTemporalGroup->setEnabled(
true );
314 mPostgresRasterTemporalGroup->setVisible(
true );
315 mPostgresRasterTemporalGroup->setChecked(
false );
317 mPostgresRasterTemporalFieldComboBox->setFields( fields );
318 mPostgresRasterTemporalFieldComboBox->setFilters( QgsFieldProxyModel::Filter::Date |
319 QgsFieldProxyModel::Filter::DateTime |
320 QgsFieldProxyModel::Filter::String );
321 mPostgresRasterTemporalFieldComboBox->setAllowEmptyFieldName(
true );
324 mPostgresRasterDefaultTime->setEnabled( ! fieldName.isEmpty() );
326 mPostgresRasterDefaultTime->setAllowNull(
true );
327 mPostgresRasterDefaultTime->setEmpty();
331 const int fieldIdx { mRasterLayer->
dataProvider()->
uri().
param( QStringLiteral(
"temporalFieldIndex" ) ).toInt( &ok ) };
332 if ( ok && fields.exists( fieldIdx ) )
334 mPostgresRasterTemporalGroup->setChecked(
true );
335 mPostgresRasterTemporalFieldComboBox->setField( fields.field( fieldIdx ).name() );
338 const QDateTime defaultDateTime { QDateTime::fromString( mRasterLayer->
dataProvider()->
uri().
param( QStringLiteral(
"temporalDefaultTime" ) ), Qt::DateFormat::ISODate ) };
339 if ( defaultDateTime.isValid() )
341 mPostgresRasterDefaultTime->setDateTime( defaultDateTime );
349 mPostgresRasterTemporalGroup->setEnabled(
false );
350 mPostgresRasterTemporalGroup->setVisible(
false );
355 mCrsSelector->setCrs( mRasterLayer->
crs() );
358 QString pyramidFormat( QStringLiteral(
"<h2>%1</h2><p>%2 %3 %4</p><b><font color='red'><p>%5</p><p>%6</p>" ) );
359 QString pyramidHeader = tr(
"Description" );
360 QString pyramidSentence1 = tr(
"Large resolution raster layers can slow navigation in QGIS." );
361 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." );
362 QString pyramidSentence3 = tr(
"You must have write access in the directory where the original data is stored to build pyramids." );
363 QString pyramidSentence4 = tr(
"Please note that building internal pyramids may alter the original data file and once created they cannot be removed!" );
364 QString pyramidSentence5 = tr(
"Please note that building internal pyramids could corrupt your image - always make a backup of your data first!" );
366 tePyramidDescription->setHtml( pyramidFormat.arg( pyramidHeader,
371 pyramidSentence5 ) );
374 mResamplingGroupBox->setSaveCheckedState(
true );
375 mResamplingUtils.initWidgets( mRasterLayer, mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox, mMaximumOversamplingSpinBox, mCbEarlyResampling );
376 mResamplingUtils.refreshWidgetsFromLayer();
380 btnColorizeColor->setColorDialogTitle( tr(
"Select Color" ) );
381 btnColorizeColor->setContext( QStringLiteral(
"symbology" ) );
386 if ( hueSaturationFilter )
388 sliderSaturation->setValue( hueSaturationFilter->
saturation() );
389 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->
grayscaleMode() );
392 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->
grayscaleMode() ) );
395 mColorizeCheck->setChecked( hueSaturationFilter->
colorizeOn() );
396 btnColorizeColor->setColor( hueSaturationFilter->
colorizeColor() );
397 toggleColorizeControls( hueSaturationFilter->
colorizeOn() );
398 sliderColorizeStrength->setValue( hueSaturationFilter->
colorizeStrength() );
402 mBlendModeComboBox->setBlendMode( mRasterLayer->
blendMode() );
407 cboxTransparencyBand->setShowNotSetOption(
true, tr(
"None" ) );
408 cboxTransparencyBand->setLayer( mRasterLayer );
417 cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->
alphaBand() ) );
424 mHistogramWidget =
nullptr;
425 if ( mOptsPage_Histogram->isEnabled() )
428 mHistogramStackedWidget->addWidget( mHistogramWidget );
441 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
443 for (
const QString &name : constRenderersList )
454 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
459 QString rendererType = renderer->
type();
460 widgetIndex = mRenderTypeComboBox->findData( rendererType );
461 if ( widgetIndex != -1 )
463 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
464 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
465 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
468 if ( rendererType == QLatin1String(
"singlebandcolordata" ) && mRenderTypeComboBox->count() == 1 )
471 QSizePolicy sizep = mBandRenderingGrpBx->sizePolicy();
472 sizep.setVerticalStretch( 0 );
473 sizep.setVerticalPolicy( QSizePolicy::Maximum );
474 mBandRenderingGrpBx->setSizePolicy( sizep );
475 mBandRenderingGrpBx->updateGeometry();
478 if ( mRasterLayer->
providerType() != QLatin1String(
"wms" ) )
480 mWMSPrintGroupBox->hide();
481 mPublishDataSourceUrlCheckBox->hide();
482 mBackgroundLayerCheckBox->hide();
489 #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
490 const int horizontalDpi = qApp->desktop()->screen()->logicalDpiX();
492 const int horizontalDpi = logicalDpiX();
496 if ( horizontalDpi > 96 )
498 mMetadataViewer->setZoomFactor( mMetadataViewer->zoomFactor() * 0.9 );
500 mMetadataViewer->page()->setLinkDelegationPolicy( QWebPage::LinkDelegationPolicy::DelegateAllLinks );
501 connect( mMetadataViewer->page(), &QWebPage::linkClicked,
this, &QgsRasterLayerProperties::urlClicked );
502 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
503 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
507 mRenderTypeComboBox_currentIndexChanged( widgetIndex );
515 if ( !settings.
contains( QStringLiteral(
"/Windows/RasterLayerProperties/tab" ) ) )
517 settings.
setValue( QStringLiteral(
"Windows/RasterLayerProperties/tab" ),
523 QString title = tr(
"Layer Properties — %1" ).arg( lyr->
name() );
531 mOptsPage_Information->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#information-properties" ) );
532 mOptsPage_Source->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#source-properties" ) );
533 mOptsPage_Style->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#symbology-properties" ) );
534 mOptsPage_Transparency->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#transparency-properties" ) );
536 if ( mOptsPage_Histogram )
537 mOptsPage_Histogram->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#histogram-properties" ) );
539 mOptsPage_Rendering->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#rendering-properties" ) );
541 if ( mOptsPage_Pyramids )
542 mOptsPage_Pyramids->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#pyramids-properties" ) );
544 mOptsPage_Metadata->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#metadata-properties" ) );
545 mOptsPage_Legend->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#legend-properties" ) );
546 mOptsPage_Server->setProperty(
"helpPage", QStringLiteral(
"working_with_raster/raster_properties.html#server-properties" ) );
557 mLayerPropertiesPages << page;
560 if ( beforePage.isEmpty() )
566 void QgsRasterLayerProperties::setupTransparencyTable(
int nBands )
568 tableTransparency->clear();
569 tableTransparency->setColumnCount( 0 );
570 tableTransparency->setRowCount( 0 );
571 mTransparencyToEdited.clear();
575 tableTransparency->setColumnCount( 4 );
576 tableTransparency->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"Red" ) ) );
577 tableTransparency->setHorizontalHeaderItem( 1,
new QTableWidgetItem( tr(
"Green" ) ) );
578 tableTransparency->setHorizontalHeaderItem( 2,
new QTableWidgetItem( tr(
"Blue" ) ) );
579 tableTransparency->setHorizontalHeaderItem( 3,
new QTableWidgetItem( tr(
"Percent Transparent" ) ) );
583 tableTransparency->setColumnCount( 3 );
586 if ( QgsRasterLayer::PalettedColor != mRasterLayer->drawingStyle() &&
587 QgsRasterLayer::PalettedSingleBandGray != mRasterLayer->drawingStyle() &&
588 QgsRasterLayer::PalettedSingleBandPseudoColor != mRasterLayer->drawingStyle() &&
589 QgsRasterLayer::PalettedMultiBandColor != mRasterLayer->drawingStyle() )
591 tableTransparency->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"Gray" ) ) );
595 tableTransparency->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"Indexed Value" ) ) );
598 tableTransparency->setHorizontalHeaderItem( 0,
new QTableWidgetItem( tr(
"From" ) ) );
599 tableTransparency->setHorizontalHeaderItem( 1,
new QTableWidgetItem( tr(
"To" ) ) );
600 tableTransparency->setHorizontalHeaderItem( 2,
new QTableWidgetItem( tr(
"Percent Transparent" ) ) );
603 tableTransparency->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
604 tableTransparency->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::Stretch );
607 void QgsRasterLayerProperties::populateTransparencyTable(
QgsRasterRenderer *renderer )
619 int nBands = renderer->
usesBands().size();
620 setupTransparencyTable( nBands );
623 if ( !rasterTransparency )
631 for (
int i = 0; i < pixelList.size(); ++i )
633 tableTransparency->insertRow( i );
634 setTransparencyCell( i, 0, pixelList[i].min );
635 setTransparencyCell( i, 1, pixelList[i].max );
636 setTransparencyCell( i, 2, pixelList[i].percentTransparent );
638 if ( pixelList[i].min != pixelList[i].max )
640 setTransparencyToEdited( i );
644 else if ( nBands == 3 )
647 for (
int i = 0; i < pixelList.size(); ++i )
649 tableTransparency->insertRow( i );
650 setTransparencyCell( i, 0, pixelList[i].red );
651 setTransparencyCell( i, 1, pixelList[i].green );
652 setTransparencyCell( i, 2, pixelList[i].blue );
653 setTransparencyCell( i, 3, pixelList[i].percentTransparent );
657 tableTransparency->resizeColumnsToContents();
658 tableTransparency->resizeRowsToContents();
661 void QgsRasterLayerProperties::setRendererWidget(
const QString &rendererName )
674 opacity = oldRenderer->
opacity();
683 QgsDebugMsgLevel( QStringLiteral(
"renderer has widgetCreateFunction" ), 3 );
686 if ( oldWidget && ( !oldRenderer || rendererName != oldRenderer->
type() ) )
688 if ( rendererName == QLatin1String(
"singlebandgray" ) )
691 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
693 else if ( rendererName == QLatin1String(
"multibandcolor" ) )
696 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
704 mRendererStackedWidget->addWidget( mRendererWidget );
710 QList<int> oldBands = oldRenderer->
usesBands();
711 QList<int> newBands = newRenderer->
usesBands();
712 if ( oldBands != newBands )
714 populateTransparencyTable( newRenderer );
722 const int widgetIndex = mRenderTypeComboBox->findData( rendererName );
723 if ( widgetIndex != -1 )
725 mDisableRenderTypeComboBoxCurrentIndexChanged =
true;
726 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
727 mDisableRenderTypeComboBoxCurrentIndexChanged =
false;
730 if ( mRendererWidget != oldWidget )
733 if ( mHistogramWidget )
739 void QgsRasterLayerProperties::sync()
743 if ( !mSourceWidget )
748 QHBoxLayout *layout =
new QHBoxLayout();
749 layout->addWidget( mSourceWidget );
750 mSourceGroupBox->setLayout( layout );
751 mSourceGroupBox->show();
755 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
756 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
771 gboxNoDataValue->setEnabled(
false );
772 gboxCustomTransparency->setEnabled(
false );
773 mOptionsStackedWidget->setCurrentWidget( mOptsPage_Server );
779 if ( mOptsPage_Pyramids )
781 delete mOptsPage_Pyramids;
782 mOptsPage_Pyramids =
nullptr;
788 if ( mOptsPage_Histogram )
790 delete mOptsPage_Histogram;
791 mOptsPage_Histogram =
nullptr;
792 delete mHistogramWidget;
793 mHistogramWidget =
nullptr;
805 if ( brightnessFilter )
807 mSliderBrightness->setValue( brightnessFilter->
brightness() );
808 mSliderContrast->setValue( brightnessFilter->
contrast() );
809 mGammaSpinBox->setValue( brightnessFilter->
gamma() );
815 if ( hueSaturationFilter )
817 sliderSaturation->setValue( hueSaturationFilter->
saturation() );
818 comboGrayscale->setCurrentIndex( (
int ) hueSaturationFilter->
grayscaleMode() );
821 toggleSaturationControls(
static_cast<int>( hueSaturationFilter->
grayscaleMode() ) );
824 mColorizeCheck->setChecked( hueSaturationFilter->
colorizeOn() );
825 btnColorizeColor->setColor( hueSaturationFilter->
colorizeColor() );
826 toggleColorizeControls( hueSaturationFilter->
colorizeOn() );
827 sliderColorizeStrength->setValue( hueSaturationFilter->
colorizeStrength() );
839 cboxTransparencyBand->setBand( renderer->
alphaBand() );
848 lblSrcNoDataValue->setText( QLocale().toString( v,
'g' ) );
852 lblSrcNoDataValue->setText( tr(
"not defined" ) );
859 mSrcNoDataValueCheckBox->setEnabled( enableSrcNoData );
860 lblSrcNoDataValue->setEnabled( enableSrcNoData );
863 QgsDebugMsgLevel( QStringLiteral(
"noDataRangeList.size = %1" ).arg( noDataRangeList.size() ), 3 );
864 if ( !noDataRangeList.isEmpty() )
870 leNoDataValue->insert( QString() );
877 populateTransparencyTable( mRasterLayer->
renderer() );
890 mLayerOrigNameLineEd->setText( mRasterLayer->
name() );
891 leDisplayName->setText( mRasterLayer->
name() );
898 updateInformationContent();
901 mLayerShortNameLineEdit->setText( mRasterLayer->
shortName() );
904 mLayerShortNameLineEdit->setValidator( shortNameValidator );
907 mLayerTitleLineEdit->setText( mRasterLayer->
title() );
908 mLayerAbstractTextEdit->setPlainText( mRasterLayer->
abstract() );
909 mLayerKeywordListLineEdit->setText( mRasterLayer->
keywordList() );
910 mLayerDataUrlLineEdit->setText( mRasterLayer->
dataUrl() );
911 mLayerDataUrlFormatComboBox->setCurrentIndex(
912 mLayerDataUrlFormatComboBox->findText(
918 mLayerAttributionLineEdit->setText( mRasterLayer->
attribution() );
919 mLayerAttributionUrlLineEdit->setText( mRasterLayer->
attributionUrl() );
920 mLayerMetadataUrlLineEdit->setText( mRasterLayer->
metadataUrl() );
921 mLayerMetadataUrlTypeComboBox->setCurrentIndex(
922 mLayerMetadataUrlTypeComboBox->findText(
926 mLayerMetadataUrlFormatComboBox->setCurrentIndex(
927 mLayerMetadataUrlFormatComboBox->findText(
932 mLayerLegendUrlLineEdit->setText( mRasterLayer->
legendUrl() );
933 mLayerLegendUrlFormatComboBox->setCurrentIndex( mLayerLegendUrlFormatComboBox->findText( mRasterLayer->
legendUrlFormat() ) );
936 QVariant wmsPrintLayer = mRasterLayer->
customProperty( QStringLiteral(
"WMSPrintLayer" ) );
937 if ( wmsPrintLayer.isValid() )
939 mWMSPrintLayerLineEdit->setText( wmsPrintLayer.toString() );
942 QVariant wmsPublishDataSourceUrl = mRasterLayer->
customProperty( QStringLiteral(
"WMSPublishDataSourceUrl" ),
false );
943 mPublishDataSourceUrlCheckBox->setChecked( wmsPublishDataSourceUrl.toBool() );
945 QVariant wmsBackgroundLayer = mRasterLayer->
customProperty( QStringLiteral(
"WMSBackgroundLayer" ),
false );
946 mBackgroundLayerCheckBox->setChecked( wmsBackgroundLayer.toBool() );
948 mLegendConfigEmbeddedWidget->setLayer( mRasterLayer );
954 page->syncToLayer( mRasterLayer );
959 void QgsRasterLayerProperties::apply()
963 const QString newSource = mSourceWidget->
sourceUri();
964 if ( newSource != mRasterLayer->
source() )
971 if ( !mRasterLayer->
isValid() )
977 mLegendConfigEmbeddedWidget->applyToLayer();
998 if (
"" != leNoDataValue->text() )
1000 bool myDoubleOk =
false;
1005 myNoDataRangeList << myNoDataRange;
1008 for (
int bandNo = 1; bandNo <= mRasterLayer->
dataProvider()->bandCount(); bandNo++ )
1016 if ( rendererWidget )
1024 mMetadataFilled =
false;
1028 if ( rasterRenderer )
1030 rasterRenderer->
setAlphaBand( cboxTransparencyBand->currentBand() );
1034 if ( tableTransparency->columnCount() == 4 )
1037 QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
1038 for (
int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
1040 myTransparentPixel.
red = transparencyCellValue( myListRunner, 0 );
1041 myTransparentPixel.
green = transparencyCellValue( myListRunner, 1 );
1042 myTransparentPixel.
blue = transparencyCellValue( myListRunner, 2 );
1044 myTransparentThreeValuePixelList.append( myTransparentPixel );
1048 else if ( tableTransparency->columnCount() == 3 )
1051 QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
1052 for (
int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
1054 myTransparentPixel.
min = transparencyCellValue( myListRunner, 0 );
1055 myTransparentPixel.
max = transparencyCellValue( myListRunner, 1 );
1058 myTransparentSingleValuePixelList.append( myTransparentPixel );
1066 rasterRenderer->
setOpacity( mOpacityWidget->opacity() );
1073 mRasterLayer->
setName( mLayerOrigNameLineEd->text() );
1088 mResamplingUtils.refreshLayerFromWidgets();
1092 if ( hueSaturationFilter )
1094 hueSaturationFilter->
setSaturation( sliderSaturation->value() );
1096 hueSaturationFilter->
setColorizeOn( mColorizeCheck->checkState() );
1102 mRasterLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
1104 updateSourceStaticTime();
1110 if ( mPostgresRasterTemporalGroup->isEnabled() &&
1111 mPostgresRasterTemporalGroup->isChecked() &&
1112 ! mPostgresRasterTemporalFieldComboBox->currentField().isEmpty() )
1114 const QString originaUri { uri.
uri() };
1116 uri.removeParam( QStringLiteral(
"temporalFieldIndex" ) );
1117 uri.removeParam( QStringLiteral(
"temporalDefaultTime" ) );
1118 if ( fieldIdx >= 0 )
1120 uri.setParam( QStringLiteral(
"temporalFieldIndex" ), QString::number( fieldIdx ) );
1121 if ( mPostgresRasterDefaultTime->dateTime().isValid() )
1123 QDateTime defaultDateTime { mPostgresRasterDefaultTime->dateTime() };
1124 const QTime defaultTime { defaultDateTime.time() };
1126 defaultDateTime.setTime( { defaultTime.hour(), defaultTime.minute(), 0 } );
1127 uri.setParam( QStringLiteral(
"temporalDefaultTime" ), defaultDateTime.toString( Qt::DateFormat::ISODate ) );
1129 if ( uri.uri( ) != originaUri )
1133 else if ( uri.hasParam( QStringLiteral(
"temporalFieldIndex" ) ) )
1135 uri.removeParam( QStringLiteral(
"temporalFieldIndex" ) );
1136 uri.removeParam( QStringLiteral(
"temporalDefaultTime" ) );
1144 mRasterLayer->
setCrs( mCrsSelector->crs() );
1146 if ( mRasterLayer->
shortName() != mLayerShortNameLineEdit->text() )
1147 mMetadataFilled =
false;
1148 mRasterLayer->
setShortName( mLayerShortNameLineEdit->text() );
1150 if ( mRasterLayer->
title() != mLayerTitleLineEdit->text() )
1151 mMetadataFilled =
false;
1152 mRasterLayer->
setTitle( mLayerTitleLineEdit->text() );
1154 if ( mRasterLayer->
abstract() != mLayerAbstractTextEdit->toPlainText() )
1155 mMetadataFilled =
false;
1156 mRasterLayer->
setAbstract( mLayerAbstractTextEdit->toPlainText() );
1158 if ( mRasterLayer->
keywordList() != mLayerKeywordListLineEdit->text() )
1159 mMetadataFilled =
false;
1160 mRasterLayer->
setKeywordList( mLayerKeywordListLineEdit->text() );
1162 if ( mRasterLayer->
dataUrl() != mLayerDataUrlLineEdit->text() )
1163 mMetadataFilled =
false;
1164 mRasterLayer->
setDataUrl( mLayerDataUrlLineEdit->text() );
1166 if ( mRasterLayer->
dataUrlFormat() != mLayerDataUrlFormatComboBox->currentText() )
1167 mMetadataFilled =
false;
1168 mRasterLayer->
setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
1171 if ( mRasterLayer->
attribution() != mLayerAttributionLineEdit->text() )
1172 mMetadataFilled =
false;
1173 mRasterLayer->
setAttribution( mLayerAttributionLineEdit->text() );
1175 if ( mRasterLayer->
attributionUrl() != mLayerAttributionUrlLineEdit->text() )
1176 mMetadataFilled =
false;
1179 if ( mRasterLayer->
metadataUrl() != mLayerMetadataUrlLineEdit->text() )
1180 mMetadataFilled =
false;
1181 mRasterLayer->
setMetadataUrl( mLayerMetadataUrlLineEdit->text() );
1183 if ( mRasterLayer->
metadataUrlType() != mLayerMetadataUrlTypeComboBox->currentText() )
1184 mMetadataFilled =
false;
1187 if ( mRasterLayer->
metadataUrlFormat() != mLayerMetadataUrlFormatComboBox->currentText() )
1188 mMetadataFilled =
false;
1191 if ( mRasterLayer->
legendUrl() != mLayerLegendUrlLineEdit->text() )
1192 mMetadataFilled =
false;
1193 mRasterLayer->
setLegendUrl( mLayerLegendUrlLineEdit->text() );
1195 if ( mRasterLayer->
legendUrlFormat() != mLayerLegendUrlFormatComboBox->currentText() )
1196 mMetadataFilled =
false;
1199 if ( !mWMSPrintLayerLineEdit->text().isEmpty() )
1201 mRasterLayer->
setCustomProperty( QStringLiteral(
"WMSPrintLayer" ), mWMSPrintLayerLineEdit->text() );
1204 mRasterLayer->
setCustomProperty(
"WMSPublishDataSourceUrl", mPublishDataSourceUrlCheckBox->isChecked() );
1205 mRasterLayer->
setCustomProperty(
"WMSBackgroundLayer", mBackgroundLayerCheckBox->isChecked() );
1217 void QgsRasterLayerProperties::updateSourceStaticTime()
1223 QVariantMap uri = currentUri;
1225 if ( mWmstGroup->isVisibleTo(
this ) )
1226 uri[ QStringLiteral(
"allowTemporalUpdates" ) ] = mWmstGroup->isChecked();
1229 if ( mWmstGroup->isEnabled() &&
1233 bool enableTime = !mDisableTime->isChecked();
1235 uri[ QStringLiteral(
"enableTime" ) ] = enableTime;
1237 mFetchModeComboBox->currentData().toInt() ) );
1242 if ( mStaticTemporalRange->isChecked() )
1244 QString time = mStartStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs ) +
'/' +
1245 mEndStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
1246 uri[ QStringLiteral(
"time" ) ] = time;
1247 uri[ QStringLiteral(
"temporalSource" ) ] = QLatin1String(
"provider" );
1250 if ( mProjectTemporalRange->isChecked() )
1252 QgsDateTimeRange range;
1256 if ( range.begin().isValid() && range.end().isValid() )
1258 QString time = range.begin().toString( Qt::ISODateWithMs ) +
'/' +
1259 range.end().toString( Qt::ISODateWithMs );
1261 uri[ QStringLiteral(
"time" ) ] = time;
1262 uri[ QStringLiteral(
"temporalSource" ) ] = QLatin1String(
"project" );
1267 if ( mReferenceTime->isChecked() )
1269 QString referenceTime = mReferenceDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
1270 uri[ QStringLiteral(
"referenceTime" ) ] = referenceTime;
1274 if ( uri.contains( QStringLiteral(
"referenceTime" ) ) )
1275 uri.remove( QStringLiteral(
"referenceTime" ) );
1279 if ( currentUri != uri )
1283 void QgsRasterLayerProperties::setSourceStaticTimeState()
1295 mStartStaticDateTimeEdit->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
1296 mEndStaticDateTimeEdit->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
1297 mReferenceDateTimeEdit->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
1300 if ( availableProviderRange.begin().isValid() && availableProviderRange.end().isValid() )
1302 mStartStaticDateTimeEdit->setDateTimeRange( availableProviderRange.begin(),
1303 availableProviderRange.end() );
1304 mStartStaticDateTimeEdit->setDateTime( availableProviderRange.begin() );
1305 mEndStaticDateTimeEdit->setDateTimeRange( availableProviderRange.begin(),
1306 availableProviderRange.end() );
1307 mEndStaticDateTimeEdit->setDateTime( availableProviderRange.end() );
1309 if ( availableReferenceRange.begin().isValid() && availableReferenceRange.end().isValid() )
1311 mReferenceDateTimeEdit->setDateTimeRange( availableReferenceRange.begin(),
1312 availableReferenceRange.end() );
1313 mReferenceDateTimeEdit->setDateTime( availableReferenceRange.begin() );
1316 const QString time = uri.value( QStringLiteral(
"time" ) ).toString();
1317 if ( !time.isEmpty() )
1319 QStringList parts = time.split(
'/' );
1320 mStartStaticDateTimeEdit->setDateTime( QDateTime::fromString( parts.at( 0 ), Qt::ISODateWithMs ) );
1321 mEndStaticDateTimeEdit->setDateTime( QDateTime::fromString( parts.at( 1 ), Qt::ISODateWithMs ) );
1324 const QString referenceTimeExtent = uri.value( QStringLiteral(
"referenceTimeDimensionExtent" ) ).toString();
1326 mReferenceTime->setEnabled( !referenceTimeExtent.isEmpty() );
1327 mReferenceDateTimeEdit->setVisible( !referenceTimeExtent.isEmpty() );
1329 QString referenceTimeLabelText = referenceTimeExtent.isEmpty() ?
1330 tr(
"There is no reference time in the layer's capabilities." ) : QString();
1331 mReferenceTimeLabel->setText( referenceTimeLabelText );
1333 const QString referenceTime = uri.value( QStringLiteral(
"referenceTime" ) ).toString();
1335 mReferenceTime->setChecked( !referenceTime.isEmpty() );
1337 if ( !referenceTime.isEmpty() && !referenceTimeExtent.isEmpty() )
1339 mReferenceDateTimeEdit->setDateTime( QDateTime::fromString( referenceTime, Qt::ISODateWithMs ) );
1347 mFetchModeComboBox->setCurrentIndex( mFetchModeComboBox->findData( qobject_cast< QgsRasterLayerTemporalProperties * >( mRasterLayer->
temporalProperties() )->intervalHandlingMethod() ) );
1349 const QString temporalSource = uri.value( QStringLiteral(
"temporalSource" ) ).toString();
1350 bool enableTime = uri.value( QStringLiteral(
"enableTime" ),
true ).toBool();
1352 if ( temporalSource == QLatin1String(
"provider" ) )
1353 mStaticTemporalRange->setChecked( !time.isEmpty() );
1354 else if ( temporalSource == QLatin1String(
"project" ) )
1355 mProjectTemporalRange->setChecked( !time.isEmpty() );
1357 mDisableTime->setChecked( !enableTime );
1362 mWmstOptionsLabel->setText( tr(
"The static temporal options below are disabled because the layer "
1363 "temporal properties are active, to enable them disable temporal properties "
1364 "in the temporal tab. " ) );
1365 QgsDateTimeRange range;
1369 if ( !range.begin().isValid() || !range.end().isValid() )
1371 mProjectTemporalRange->setEnabled(
false );
1372 mProjectTemporalRangeLabel->setText( tr(
"The option below is disabled because the project temporal range "
1373 "is not valid, update the project temporal range in the project properties "
1374 "with valid values in order to use it here." ) );
1377 mWmstGroup->setChecked( uri.contains( QStringLiteral(
"allowTemporalUpdates" ) ) &&
1378 uri.value( QStringLiteral(
"allowTemporalUpdates" ),
true ).toBool() );
1382 void QgsRasterLayerProperties::staticTemporalRange_toggled(
bool checked )
1390 void QgsRasterLayerProperties::passProjectTemporalRange_toggled(
bool checked )
1394 QgsDateTimeRange range;
1398 if ( range.begin().isValid() && range.end().isValid() )
1399 mLabel->setText( tr(
"Project temporal range is set from %1 to %2" ).arg(
1400 range.begin().toString(
"yyyy-MM-dd HH:mm:ss" ),
1401 range.end().toString(
"yyyy-MM-dd HH:mm:ss" )
1404 mLabel->setText( tr(
"Project temporal range is not valid, can't use it here" ) );
1408 void QgsRasterLayerProperties::temporalPropertiesChange()
1413 mWmstOptionsLabel->setText( tr(
"The static temporal options below are disabled because the layer "
1414 "temporal properties are active, to enable them disable temporal properties "
1415 "in the temporal tab. " ) );
1417 mWmstOptionsLabel->clear();
1420 void QgsRasterLayerProperties::mLayerOrigNameLineEd_textEdited(
const QString &text )
1425 void QgsRasterLayerProperties::buttonBuildPyramids_clicked()
1437 for (
int myCounterInt = 0; myCounterInt < lbxPyramidResolutions->count(); myCounterInt++ )
1439 QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt );
1441 myPyramidList[myCounterInt].build = myItem->isSelected() || myPyramidList[myCounterInt].exists;
1445 QString prefix = provider->
name() +
"/driverOptions/_pyramids/";
1447 QString resamplingMethod( cboResamplingMethod->currentData().toString() );
1448 mySettings.
setValue( prefix +
"resampling", resamplingMethod );
1455 QApplication::setOverrideCursor( Qt::WaitCursor );
1462 QApplication::restoreOverrideCursor();
1463 mPyramidProgress->setValue( 0 );
1464 buttonBuildPyramids->setEnabled(
false );
1465 if ( !res.isNull() )
1467 if ( res == QLatin1String(
"CANCELED" ) )
1471 else if ( res == QLatin1String(
"ERROR_WRITE_ACCESS" ) )
1473 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1474 tr(
"Write access denied. Adjust the file permissions and try again." ) );
1476 else if ( res == QLatin1String(
"ERROR_WRITE_FORMAT" ) )
1478 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1479 tr(
"The file was not writable. Some formats do not "
1480 "support pyramid overviews. Consult the GDAL documentation if in doubt." ) );
1482 else if ( res == QLatin1String(
"FAILED_NOT_SUPPORTED" ) )
1484 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1485 tr(
"Building pyramid overviews is not supported on this type of raster." ) );
1487 else if ( res == QLatin1String(
"ERROR_JPEG_COMPRESSION" ) )
1489 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1490 tr(
"Building internal pyramid overviews is not supported on raster layers with JPEG compression and your current libtiff library." ) );
1492 else if ( res == QLatin1String(
"ERROR_VIRTUAL" ) )
1494 QMessageBox::warning(
this, tr(
"Building Pyramids" ),
1495 tr(
"Building pyramid overviews is not supported on this type of raster." ) );
1503 lbxPyramidResolutions->clear();
1509 QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
1510 for ( myRasterPyramidIterator = myPyramidList.begin();
1511 myRasterPyramidIterator != myPyramidList.end();
1512 ++myRasterPyramidIterator )
1514 if ( myRasterPyramidIterator->exists )
1516 lbxPyramidResolutions->addItem(
new QListWidgetItem( myPyramidPixmap,
1517 QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral(
" x " ) +
1518 QString::number( myRasterPyramidIterator->yDim ) ) );
1522 lbxPyramidResolutions->addItem(
new QListWidgetItem( myNoPyramidPixmap,
1523 QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral(
" x " ) +
1524 QString::number( myRasterPyramidIterator->yDim ) ) );
1533 updateInformationContent();
1536 void QgsRasterLayerProperties::urlClicked(
const QUrl &url )
1538 QFileInfo file( url.toLocalFile() );
1539 if ( file.exists() && !file.isDir() )
1542 QDesktopServices::openUrl( url );
1545 void QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged(
int index )
1547 if ( index < 0 || mDisableRenderTypeComboBoxCurrentIndexChanged || ! mRasterLayer->renderer() )
1552 QString rendererName = mRenderTypeComboBox->itemData( index ).toString();
1553 setRendererWidget( rendererName );
1556 void QgsRasterLayerProperties::pbnAddValuesFromDisplay_clicked()
1558 if ( mMapCanvas && mPixelSelectorTool )
1567 mMapCanvas->window()->raise();
1568 mMapCanvas->window()->activateWindow();
1569 mMapCanvas->window()->setFocus();
1570 mMapCanvas->
setMapTool( mPixelSelectorTool.get() );
1575 void QgsRasterLayerProperties::pbnAddValuesManually_clicked()
1583 tableTransparency->insertRow( tableTransparency->rowCount() );
1588 for (
int i = 0; i < n; i++ )
1590 setTransparencyCell( tableTransparency->rowCount() - 1, i, std::numeric_limits<double>::quiet_NaN() );
1593 setTransparencyCell( tableTransparency->rowCount() - 1, n, 100 );
1595 tableTransparency->resizeColumnsToContents();
1596 tableTransparency->resizeRowsToContents();
1606 void QgsRasterLayerProperties::pbnDefaultValues_clicked()
1608 if ( !mRendererWidget )
1622 setupTransparencyTable( nBands );
1624 tableTransparency->resizeColumnsToContents();
1625 tableTransparency->resizeRowsToContents();
1628 void QgsRasterLayerProperties::setTransparencyCell(
int row,
int column,
double value )
1630 QgsDebugMsgLevel( QStringLiteral(
"value = %1" ).arg( value, 0,
'g', 17 ), 3 );
1632 if ( !provider )
return;
1635 if ( !renderer )
return;
1636 int nBands = renderer->
usesBands().size();
1638 QLineEdit *lineEdit =
new QLineEdit();
1639 lineEdit->setFrame(
false );
1641 lineEdit->setContentsMargins( 1, 1, 1, 1 );
1643 if ( column == tableTransparency->columnCount() - 1 )
1647 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
1648 lineEdit->setText( QString::number(
static_cast<int>( value ) ) );
1653 QString valueString;
1659 if ( !std::isnan( value ) )
1662 valueString = QLocale().toString( v,
'g' ) ;
1666 lineEdit->setValidator(
new QIntValidator(
nullptr ) );
1667 if ( !std::isnan( value ) )
1669 valueString = QLocale().toString(
static_cast<int>( value ) );
1673 lineEdit->setText( valueString );
1675 tableTransparency->setCellWidget( row, column, lineEdit );
1676 adjustTransparencyCellWidth( row, column );
1678 if ( nBands == 1 && ( column == 0 || column == 1 ) )
1680 connect( lineEdit, &QLineEdit::textEdited,
this, &QgsRasterLayerProperties::transparencyCellTextEdited );
1682 tableTransparency->resizeColumnsToContents();
1685 void QgsRasterLayerProperties::setTransparencyCellValue(
int row,
int column,
double value )
1687 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( tableTransparency->cellWidget( row, column ) );
1688 if ( !lineEdit )
return;
1690 lineEdit->setText( QLocale().toString( v,
'g' ) );
1691 lineEdit->adjustSize();
1692 adjustTransparencyCellWidth( row, column );
1693 tableTransparency->resizeColumnsToContents();
1696 double QgsRasterLayerProperties::transparencyCellValue(
int row,
int column )
1698 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( tableTransparency->cellWidget( row, column ) );
1699 if ( !lineEdit || lineEdit->text().isEmpty() )
1701 return std::numeric_limits<double>::quiet_NaN();
1703 return lineEdit->text().toDouble();
1706 void QgsRasterLayerProperties::adjustTransparencyCellWidth(
int row,
int column )
1708 QLineEdit *lineEdit =
dynamic_cast<QLineEdit *
>( tableTransparency->cellWidget( row, column ) );
1709 if ( !lineEdit )
return;
1711 int width = std::max( lineEdit->fontMetrics().boundingRect( lineEdit->text() ).width() + 10, 100 );
1712 width = std::max( width, tableTransparency->columnWidth( column ) );
1714 lineEdit->setFixedWidth( width );
1717 void QgsRasterLayerProperties::pbnExportTransparentPixelValues_clicked()
1720 QString myLastDir = myQSettings.
value( QStringLiteral(
"lastRasterFileFilterDir" ), QDir::homePath() ).toString();
1721 QString myFileName = QFileDialog::getSaveFileName(
this, tr(
"Save File" ), myLastDir, tr(
"Textfile" ) +
" (*.txt)" );
1722 if ( !myFileName.isEmpty() )
1724 if ( !myFileName.endsWith( QLatin1String(
".txt" ), Qt::CaseInsensitive ) )
1726 myFileName = myFileName +
".txt";
1729 QFile myOutputFile( myFileName );
1730 if ( myOutputFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
1732 QTextStream myOutputStream( &myOutputFile );
1733 myOutputStream <<
"# " << tr(
"QGIS Generated Transparent Pixel Value Export File" ) <<
'\n';
1734 if ( rasterIsMultiBandColor() )
1736 myOutputStream <<
"#\n#\n# " << tr(
"Red" ) <<
"\t" << tr(
"Green" ) <<
"\t" << tr(
"Blue" ) <<
"\t" << tr(
"Percent Transparent" );
1737 for (
int myTableRunner = 0; myTableRunner < tableTransparency->rowCount(); myTableRunner++ )
1739 myOutputStream <<
'\n' << QString::number( transparencyCellValue( myTableRunner, 0 ) ) <<
"\t"
1740 << QString::number( transparencyCellValue( myTableRunner, 1 ) ) <<
"\t"
1741 << QString::number( transparencyCellValue( myTableRunner, 2 ) ) <<
"\t"
1742 << QString::number( transparencyCellValue( myTableRunner, 3 ) );
1747 myOutputStream <<
"#\n#\n# " << tr(
"Value" ) <<
"\t" << tr(
"Percent Transparent" );
1749 for (
int myTableRunner = 0; myTableRunner < tableTransparency->rowCount(); myTableRunner++ )
1751 myOutputStream <<
'\n' << QString::number( transparencyCellValue( myTableRunner, 0 ) ) <<
"\t"
1752 << QString::number( transparencyCellValue( myTableRunner, 1 ) ) <<
"\t"
1753 << QString::number( transparencyCellValue( myTableRunner, 2 ) );
1759 QMessageBox::warning(
this, tr(
"Export Transparent Pixels" ), tr(
"Write access denied. Adjust the file permissions and try again.\n\n" ) );
1764 void QgsRasterLayerProperties::transparencyCellTextEdited(
const QString &text )
1773 int nBands = renderer->
usesBands().size();
1776 QLineEdit *lineEdit = qobject_cast<QLineEdit *>( sender() );
1777 if ( !lineEdit )
return;
1780 for (
int r = 0; r < tableTransparency->rowCount(); r++ )
1782 for (
int c = 0;
c < tableTransparency->columnCount();
c++ )
1784 if ( tableTransparency->cellWidget( r,
c ) == sender() )
1791 if ( row != -1 )
break;
1793 QgsDebugMsgLevel( QStringLiteral(
"row = %1 column =%2" ).arg( row ).arg( column ), 3 );
1797 QLineEdit *toLineEdit =
dynamic_cast<QLineEdit *
>( tableTransparency->cellWidget( row, 1 ) );
1798 if ( !toLineEdit )
return;
1799 bool toChanged = mTransparencyToEdited.value( row );
1800 QgsDebugMsgLevel( QStringLiteral(
"toChanged = %1" ).arg( toChanged ), 3 );
1803 toLineEdit->setText( lineEdit->text() );
1806 else if ( column == 1 )
1808 setTransparencyToEdited( row );
1813 void QgsRasterLayerProperties::aboutToShowStyleMenu()
1817 QMenu *m = qobject_cast<QMenu *>( sender() );
1825 void QgsRasterLayerProperties::syncToLayer()
1830 setRendererWidget( renderer->
type() );
1836 void QgsRasterLayerProperties::setTransparencyToEdited(
int row )
1838 if ( row >= mTransparencyToEdited.size() )
1840 mTransparencyToEdited.resize( row + 1 );
1842 mTransparencyToEdited[row] =
true;
1849 bool isMetadataPanel = ( index ==
mOptStackedWidget->indexOf( mOptsPage_Metadata ) );
1850 mBtnStyle->setVisible( ! isMetadataPanel );
1851 mBtnMetadata->setVisible( isMetadataPanel );
1853 if ( !mHistogramWidget )
1865 if ( index ==
mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
1868 updateInformationContent();
1872 void QgsRasterLayerProperties::setEndAsStartStaticButton_clicked()
1874 mEndStaticDateTimeEdit->setDateTime( mStartStaticDateTimeEdit->dateTime() );
1877 void QgsRasterLayerProperties::pbnImportTransparentPixelValues_clicked()
1879 int myLineCounter = 0;
1880 bool myImportError =
false;
1883 QString myLastDir = myQSettings.
value( QStringLiteral(
"lastRasterFileFilterDir" ), QDir::homePath() ).toString();
1884 QString myFileName = QFileDialog::getOpenFileName(
this, tr(
"Open file" ), myLastDir, tr(
"Textfile" ) +
" (*.txt)" );
1885 QFile myInputFile( myFileName );
1886 if ( myInputFile.open( QFile::ReadOnly ) )
1888 QTextStream myInputStream( &myInputFile );
1889 QString myInputLine;
1890 if ( rasterIsMultiBandColor() )
1892 for (
int myTableRunner = tableTransparency->rowCount() - 1; myTableRunner >= 0; myTableRunner-- )
1894 tableTransparency->removeRow( myTableRunner );
1897 while ( !myInputStream.atEnd() )
1900 myInputLine = myInputStream.readLine();
1901 if ( !myInputLine.isEmpty() )
1903 if ( !myInputLine.simplified().startsWith(
'#' ) )
1905 QStringList myTokens = myInputLine.split( QRegExp(
"\\s+" ), QString::SkipEmptyParts );
1906 if ( myTokens.count() != 4 )
1908 myImportError =
true;
1909 myBadLines = myBadLines + QString::number( myLineCounter ) +
":\t[" + myInputLine +
"]\n";
1913 tableTransparency->insertRow( tableTransparency->rowCount() );
1914 for (
int col = 0; col < 4; col++ )
1916 setTransparencyCell( tableTransparency->rowCount() - 1, col, myTokens[col].toDouble() );
1925 for (
int myTableRunner = tableTransparency->rowCount() - 1; myTableRunner >= 0; myTableRunner-- )
1927 tableTransparency->removeRow( myTableRunner );
1930 while ( !myInputStream.atEnd() )
1933 myInputLine = myInputStream.readLine();
1934 if ( !myInputLine.isEmpty() )
1936 if ( !myInputLine.simplified().startsWith(
'#' ) )
1938 QStringList myTokens = myInputLine.split( QRegExp(
"\\s+" ), QString::SkipEmptyParts );
1939 if ( myTokens.count() != 3 && myTokens.count() != 2 )
1941 myImportError =
true;
1942 myBadLines = myBadLines + QString::number( myLineCounter ) +
":\t[" + myInputLine +
"]\n";
1946 if ( myTokens.count() == 2 )
1948 myTokens.insert( 1, myTokens[0] );
1950 tableTransparency->insertRow( tableTransparency->rowCount() );
1951 for (
int col = 0; col < 3; col++ )
1953 setTransparencyCell( tableTransparency->rowCount() - 1, col, myTokens[col].toDouble() );
1961 if ( myImportError )
1963 QMessageBox::warning(
this, tr(
"Import Transparent Pixels" ), tr(
"The following lines contained errors\n\n%1" ).arg( myBadLines ) );
1966 else if ( !myFileName.isEmpty() )
1968 QMessageBox::warning(
this, tr(
"Import Transparent Pixels" ), tr(
"Read access denied. Adjust the file permissions and try again.\n\n" ) );
1970 tableTransparency->resizeColumnsToContents();
1971 tableTransparency->resizeRowsToContents();
1974 void QgsRasterLayerProperties::pbnRemoveSelectedRow_clicked()
1976 if ( 0 < tableTransparency->rowCount() )
1978 tableTransparency->removeRow( tableTransparency->currentRow() );
1982 void QgsRasterLayerProperties::pixelSelected(
const QgsPointXY &canvasPoint,
const Qt::MouseButton &btn )
1992 if ( mMapCanvas && mPixelSelectorTool )
2001 int myWidth = mMapCanvas->
extent().
width() / mapUnitsPerPixel;
2002 int myHeight = mMapCanvas->
extent().
height() / mapUnitsPerPixel;
2006 QList<int> bands = renderer->
usesBands();
2008 QList<double> values;
2009 for (
int i = 0; i < bands.size(); ++i )
2011 int bandNo = bands.value( i );
2012 if ( myPixelMap.count( bandNo ) == 1 )
2014 if ( myPixelMap.value( bandNo ).isNull() )
2018 double value = myPixelMap.value( bandNo ).toDouble();
2019 QgsDebugMsgLevel( QStringLiteral(
"value = %1" ).arg( value, 0,
'g', 17 ), 3 );
2020 values.append( value );
2023 if ( bands.size() == 1 )
2026 values.insert( 1, values.value( 0 ) );
2028 tableTransparency->insertRow( tableTransparency->rowCount() );
2029 for (
int i = 0; i < values.size(); i++ )
2031 setTransparencyCell( tableTransparency->rowCount() - 1, i, values.value( i ) );
2033 setTransparencyCell( tableTransparency->rowCount() - 1, tableTransparency->columnCount() - 1, 100 );
2037 tableTransparency->resizeColumnsToContents();
2038 tableTransparency->resizeRowsToContents();
2041 void QgsRasterLayerProperties::toggleSaturationControls(
int grayscaleMode )
2044 if ( grayscaleMode == 0 )
2046 sliderSaturation->setEnabled(
true );
2047 spinBoxSaturation->setEnabled(
true );
2051 sliderSaturation->setEnabled(
false );
2052 spinBoxSaturation->setEnabled(
false );
2056 void QgsRasterLayerProperties::toggleColorizeControls(
bool colorizeEnabled )
2059 btnColorizeColor->setEnabled( colorizeEnabled );
2060 sliderColorizeStrength->setEnabled( colorizeEnabled );
2061 spinColorizeStrength->setEnabled( colorizeEnabled );
2065 QLinearGradient QgsRasterLayerProperties::redGradient()
2069 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2070 myGradient.setColorAt( 0.0, QColor( 242, 14, 25, 190 ) );
2071 myGradient.setColorAt( 0.5, QColor( 175, 29, 37, 190 ) );
2072 myGradient.setColorAt( 1.0, QColor( 114, 17, 22, 190 ) );
2075 QLinearGradient QgsRasterLayerProperties::greenGradient()
2079 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2080 myGradient.setColorAt( 0.0, QColor( 48, 168, 5, 190 ) );
2081 myGradient.setColorAt( 0.8, QColor( 36, 122, 4, 190 ) );
2082 myGradient.setColorAt( 1.0, QColor( 21, 71, 2, 190 ) );
2085 QLinearGradient QgsRasterLayerProperties::blueGradient()
2089 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2090 myGradient.setColorAt( 0.0, QColor( 30, 0, 106, 190 ) );
2091 myGradient.setColorAt( 0.2, QColor( 30, 72, 128, 190 ) );
2092 myGradient.setColorAt( 1.0, QColor( 30, 223, 196, 190 ) );
2095 QLinearGradient QgsRasterLayerProperties::grayGradient()
2099 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2100 myGradient.setColorAt( 0.0, QColor( 5, 5, 5, 190 ) );
2101 myGradient.setColorAt( 0.8, QColor( 122, 122, 122, 190 ) );
2102 myGradient.setColorAt( 1.0, QColor( 220, 220, 220, 190 ) );
2105 QLinearGradient QgsRasterLayerProperties::highlightGradient()
2109 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2110 myGradient.setColorAt( 1.0, QColor( 255, 255, 255, 50 ) );
2111 myGradient.setColorAt( 0.5, QColor( 255, 255, 255, 100 ) );
2112 myGradient.setColorAt( 0.0, QColor( 255, 255, 255, 150 ) );
2123 void QgsRasterLayerProperties::loadDefaultStyle_clicked()
2125 bool defaultLoadedFlag =
false;
2128 if ( defaultLoadedFlag )
2135 QMessageBox::information(
this,
2136 tr(
"Default Style" ),
2142 void QgsRasterLayerProperties::saveDefaultStyle_clicked()
2148 bool defaultSavedFlag =
false;
2152 if ( !defaultSavedFlag )
2155 QMessageBox::information(
this,
2156 tr(
"Default Style" ),
2163 void QgsRasterLayerProperties::loadStyle_clicked()
2166 QString lastUsedDir = settings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
2168 QString fileName = QFileDialog::getOpenFileName(
2170 tr(
"Load layer properties from style file" ),
2172 tr(
"QGIS Layer Style File" ) +
" (*.qml)" );
2173 if ( fileName.isEmpty() )
2177 if ( !fileName.endsWith( QLatin1String(
".qml" ), Qt::CaseInsensitive ) )
2178 fileName += QLatin1String(
".qml" );
2182 bool defaultLoadedFlag =
false;
2183 QString message = mRasterLayer->
loadNamedStyle( fileName, defaultLoadedFlag );
2184 if ( defaultLoadedFlag )
2186 settings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( fileName ).absolutePath() );
2191 QMessageBox::information(
this, tr(
"Save Style" ), message );
2196 void QgsRasterLayerProperties::saveStyleAs_clicked()
2199 QString lastUsedDir = settings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
2201 QString selectedFilter;
2202 QString outputFileName = QFileDialog::getSaveFileName(
2204 tr(
"Save layer properties as style file" ),
2206 tr(
"QGIS Layer Style File" ) +
" (*.qml)" +
";;" + tr(
"Styled Layer Descriptor" ) +
" (*.sld)",
2208 if ( outputFileName.isEmpty() )
2213 if ( selectedFilter.contains( QStringLiteral(
".qml" ), Qt::CaseInsensitive ) )
2216 type = StyleType::QML;
2221 type = StyleType::SLD;
2227 bool defaultLoadedFlag =
false;
2233 message = mRasterLayer->
saveNamedStyle( outputFileName, defaultLoadedFlag );
2238 message = mRasterLayer->
saveSldStyle( outputFileName, defaultLoadedFlag );
2242 if ( defaultLoadedFlag )
2244 settings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( outputFileName ).absolutePath() );
2248 QMessageBox::information(
this, tr(
"Save Style" ), message );
2251 void QgsRasterLayerProperties::restoreWindowModality()
2266 void QgsRasterLayerProperties::loadMetadata()
2269 QString myLastUsedDir = myQSettings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
2271 QString myFileName = QFileDialog::getOpenFileName(
this, tr(
"Load layer metadata from metadata file" ), myLastUsedDir,
2272 tr(
"QGIS Layer Metadata File" ) +
" (*.qmd)" );
2273 if ( myFileName.isNull() )
2279 bool defaultLoadedFlag =
false;
2283 if ( defaultLoadedFlag )
2290 QMessageBox::warning(
this, tr(
"Load Metadata" ), myMessage );
2293 QFileInfo myFI( myFileName );
2294 QString myPath = myFI.path();
2295 myQSettings.
setValue( QStringLiteral(
"style/lastStyleDir" ), myPath );
2300 void QgsRasterLayerProperties::saveMetadataAs()
2303 QString myLastUsedDir = myQSettings.
value( QStringLiteral(
"style/lastStyleDir" ), QDir::homePath() ).toString();
2305 QString myOutputFileName = QFileDialog::getSaveFileName(
this, tr(
"Save Layer Metadata as QMD" ),
2306 myLastUsedDir, tr(
"QMD File" ) +
" (*.qmd)" );
2307 if ( myOutputFileName.isNull() )
2320 bool defaultLoadedFlag =
false;
2321 QString message = mRasterLayer->
saveNamedMetadata( myOutputFileName, defaultLoadedFlag );
2322 if ( defaultLoadedFlag )
2323 myQSettings.
setValue( QStringLiteral(
"style/lastStyleDir" ), QFileInfo( myOutputFileName ).absolutePath() );
2325 QMessageBox::information(
this, tr(
"Save Metadata" ), message );
2328 void QgsRasterLayerProperties::saveDefaultMetadata()
2332 bool defaultSavedFlag =
false;
2334 if ( !defaultSavedFlag )
2336 QMessageBox::warning(
this, tr(
"Default Metadata" ), errorMsg );
2340 void QgsRasterLayerProperties::loadDefaultMetadata()
2342 bool defaultLoadedFlag =
false;
2345 if ( defaultLoadedFlag )
2351 QMessageBox::information(
this, tr(
"Default Metadata" ), myMessage );
2356 void QgsRasterLayerProperties::toggleBuildPyramidsButton()
2358 if ( lbxPyramidResolutions->selectedItems().empty() )
2360 buttonBuildPyramids->setEnabled(
false );
2364 buttonBuildPyramids->setEnabled(
true );
2368 void QgsRasterLayerProperties::mResetColorRenderingBtn_clicked()
2370 mBlendModeComboBox->setBlendMode( QPainter::CompositionMode_SourceOver );
2371 mSliderBrightness->setValue( 0 );
2372 mSliderContrast->setValue( 0 );
2373 mGammaSpinBox->setValue( 1.0 );
2374 sliderSaturation->setValue( 0 );
2376 mColorizeCheck->setChecked(
false );
2377 sliderColorizeStrength->setValue( 100 );
2380 bool QgsRasterLayerProperties::rasterIsMultiBandColor()
2385 void QgsRasterLayerProperties::updateInformationContent()
2389 const QString html { mRasterLayer->
htmlMetadata().replace( QLatin1String(
"<head>" ), QStringLiteral( R
"raw(<head><style type="text/css">%1</style>)raw" ) ).arg( myStyle ) };
2390 mMetadataViewer->setHtml( html );
2391 mMetadataFilled = true;
2394 void QgsRasterLayerProperties::onCancel()
2400 QDomDocument doc( QStringLiteral(
"qgis" ) );
2401 int errorLine, errorColumn;
2402 doc.setContent( mOldStyle.
xmlData(),
false, &myMessage, &errorLine, &errorColumn );
2408 void QgsRasterLayerProperties::showHelp()
2410 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
2412 if ( helpPage.isValid() )
2418 QgsHelp::openHelp( QStringLiteral(
"working_with_raster/raster_properties.html" ) );
2422 void QgsRasterLayerProperties::updateGammaSpinBox(
int value )
2427 void QgsRasterLayerProperties::updateGammaSlider(
double value )
@ Float32
Thirty two bit floating point (float)
@ Float64
Sixty four bit floating point (double)
@ 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.
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 QRegExp shortNameRegExp()
Returns the short name regular expression for line edit validator.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Brightness/contrast and gamma correction filter pipe for rasters.
int contrast() const
Returns current contrast level.
int brightness() const
Returns current brightness level.
double gamma() const
Returns current gamma value.
void setGamma(double gamma)
Set gamma value.
void setContrast(int contrast)
Set contrast level.
void setBrightness(int brightness)
Set brightness level.
This class represents a coordinate reference system (CRS).
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
bool hasTemporalCapabilities() const
Returns true if the provider has temporal capabilities available.
virtual QString name() const =0
Returns a provider name.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
QgsDataSourceUri uri() const
Gets the data source specification.
Class for storing the component parts of a RDBMS data source URI (e.g.
bool hasParam(const QString &key) const
Returns true if a parameter with the specified key exists.
QString uri(bool expandAuthConfig=true) const
Returns the complete URI as a string.
QString param(const QString &key) const
Returns a generic parameter value corresponding to the specified key.
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
Container of fields for a vector layer.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
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 QgsGui * instance()
Returns a pointer to the singleton instance.
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
void setGrayscaleMode(QgsHueSaturationFilter::GrayscaleMode grayscaleMode)
QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const
void setColorizeColor(const QColor &colorizeColor)
void setColorizeStrength(int colorizeStrength)
QColor colorizeColor() const
Map canvas is a class for displaying all GIS data types on a canvas.
void unsetMapTool(QgsMapTool *mapTool)
Unset the current map tool or last non zoom tool.
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the 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.
bool isDefault(const QString &styleName) const
Returns true if this is the default style.
QgsMapLayerStyle style(const QString &name) const
Returns data of a stored style - accessed by its unique name.
void currentStyleChanged(const QString ¤tName)
Emitted when the current style has been changed.
QString xmlData() const
Returns XML content of the style.
Base class for all map layer types.
void setShortName(const QString &shortName)
Sets the short name of the layer used by QGIS Server to identify the layer.
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Import the properties of this layer from a QDomDocument.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
virtual QString saveSldStyle(const QString &uri, bool &resultFlag) const
Saves the properties of this layer to an SLD format file.
QString source() const
Returns the source for the layer.
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
QgsCoordinateReferenceSystem crs
QString 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
static QString formatLayerName(const QString &name)
A convenience function to capitalize and format a layer name.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
virtual QString saveDefaultStyle(bool &resultFlag)
Save the properties of this layer as the default style (either as a .qml file on disk or as a record ...
void setKeywordList(const QString &keywords)
Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
virtual QString saveDefaultMetadata(bool &resultFlag)
Save the current metadata of this layer as the default metadata (either as a .qmd file on disk or as ...
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
virtual QString loadNamedStyle(const QString &uri, bool &resultFlag, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
void setMetadataUrlFormat(const QString &metaUrlFormat)
Sets the metadata format of the layer used by QGIS Server in GetCapabilities request.
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 metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
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...
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
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 setMetadataUrl(const QString &metaUrl)
Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request.
void setMetadataUrlType(const QString &metaUrlType)
Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType ind...
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...
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
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.
The QgsMapSettings class contains configuration for rendering of the map.
QgsRectangle outputExtentToLayerExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates 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 insertPage(const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget, const QString &before)
Inserts a new page into the dialog pages.
virtual void optionsStackedWidget_CurrentChanged(int index)
Select relevant tab on current page change.
void addPage(const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget)
Adds a new page to the dialog pages.
void restoreOptionsBaseUi(const QString &title=QString())
Restore the base ui.
QStackedWidget * mOptStackedWidget
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
A class to represent a 2D point.
QgsDateTimeRange temporalRange() const
Returns the project's temporal range, which indicates the earliest and latest datetime ranges associa...
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setDirty(bool b=true)
Flag the project as dirty (modified).
const QgsProjectTimeSettings * timeSettings() const
Returns the project's time settings, which contains the project's temporal range and other time based...
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
Feedback object tailored for raster block reading.
static QString printValue(double value)
Print double value with all necessary significant digits.
IntervalHandlingMethod
Method to use when resolving a temporal range to a data provider layer or band.
@ MatchExactUsingStartOfRange
Match the start of the temporal range to a corresponding layer or band, and only use exact matching r...
@ MatchExactUsingEndOfRange
Match the end of the temporal range to a corresponding layer or band, and only use exact matching res...
@ MatchUsingWholeRange
Use an exact match to the whole temporal range.
@ FindClosestMatchToStartOfRange
@ FindClosestMatchToEndOfRange
Match the start of the temporal range to the least previous closest datetime.
const QgsDateTimeRange & availableReferenceTemporalRange() const
Returns the available reference datetime range, which indicates the maximum extent of datetime values...
const QgsDateTimeRange & availableTemporalRange() const
Returns the datetime range extent from which temporal data is available from the provider.
Base class for raster data providers.
virtual QgsFields fields() const
Returns the fields of the raster layer for data providers that expose them, the default implementatio...
virtual QString buildPyramids(const QList< QgsRasterPyramid > &pyramidList, const QString &resamplingMethod="NEAREST", QgsRaster::RasterPyramidsFormat format=QgsRaster::PyramidsGTiff, const QStringList &configOptions=QStringList(), QgsRasterBlockFeedback *feedback=nullptr)
Create pyramid overviews.
virtual bool sourceHasNoDataValue(int bandNo) const
Returns true if source band has no data value.
virtual QList< QgsRasterPyramid > buildPyramidList(QList< int > overviewList=QList< int >())
Returns the raster layers pyramid list.
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
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.
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
virtual QgsRasterIdentifyResult identify(const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Identify raster value(s) found on the point position.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
QMap< int, QVariant > results() const
Returns the identify results.
@ 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(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
Represents a raster layer.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
QgsHueSaturationFilter * hueSaturationFilter() const
Returns the raster's hue/saturation filter.
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag=false) override
Updates the data source of the layer.
LayerType rasterType()
Returns the raster layer type (which is a read only property).
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
QgsBrightnessContrastFilter * brightnessFilter() const
Returns the raster's brightness/contrast filter.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
void setRenderer(QgsRasterRenderer *renderer)
Sets the raster's renderer.
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.
const QgsRasterTransparency * rasterTransparency() const
virtual QString type() const
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
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)
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
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.
QList< QgsRasterTransparency::TransparentThreeValuePixel > transparentThreeValuePixelList() const
Returns the transparent three value pixel list.
void setTransparentThreeValuePixelList(const QList< QgsRasterTransparency::TransparentThreeValuePixel > &newList)
Sets the transparent three value pixel list, replacing the whole existing list.
QList< QgsRasterTransparency::TransparentSingleValuePixel > transparentSingleValuePixelList() const
Returns the transparent single value pixel list.
A rectangle specified with double values.
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
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.
void changed()
Emitted when the temporal properties have changed.
bool isActive() const
Returns true if the temporal property is active.
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