QGIS API Documentation 3.99.0-Master (e9821da5c6b)
Loading...
Searching...
No Matches
qgsrasterlayerproperties.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasterlayerproperties.cpp - description
3 -------------------
4 begin : 1/1/2004
5 copyright : (C) 2004 Tim Sutton
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include <limits>
21#include <typeinfo>
22
23#include "qgsapplication.h"
27#include "qgsdoublevalidator.h"
30#include "qgsexpressionfinder.h"
31#include "qgsfileutils.h"
32#include "qgsgui.h"
33#include "qgshelp.h"
37#include "qgslogger.h"
38#include "qgsmapcanvas.h"
40#include "qgsmaplayerlegend.h"
43#include "qgsmaptip.h"
44#include "qgsmaptoolemitpoint.h"
46#include "qgsmetadatawidget.h"
50#include "qgsproject.h"
51#include "qgsprojectutils.h"
59#include "qgsrasterlayer.h"
61#include "qgsrasterpyramid.h"
62#include "qgsrasterrange.h"
63#include "qgsrasterrenderer.h"
68#include "qgssettings.h"
71#include "qgsvectorlayer.h"
72#include "qgswebframe.h"
73#include "qgswebview.h"
74
75#include <QColorDialog>
76#include <QDesktopServices>
77#include <QFile>
78#include <QFileDialog>
79#include <QHeaderView>
80#include <QLinearGradient>
81#include <QList>
82#include <QMenu>
83#include <QMessageBox>
84#include <QMouseEvent>
85#include <QPainter>
86#include <QPainterPath>
87#include <QPolygonF>
88#include <QRegularExpression>
89#include <QRegularExpressionValidator>
90#include <QScreen>
91#include <QString>
92#include <QTableWidgetItem>
93#include <QTextStream>
94#include <QUrl>
95#include <QVector>
96
97#include "moc_qgsrasterlayerproperties.cpp"
98
99using namespace Qt::StringLiterals;
100
101QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent, Qt::WindowFlags fl )
102 : QgsLayerPropertiesDialog( lyr, canvas, u"RasterLayerProperties"_s, parent, fl )
103 // Constant that signals property not used.
104 , TRSTRING_NOT_SET( tr( "Not Set" ) )
105 , mRasterLayer( qobject_cast<QgsRasterLayer *>( lyr ) )
106{
107 mGrayMinimumMaximumEstimated = true;
108 mRGBMinimumMaximumEstimated = true;
109
110 setupUi( this );
111
112 mMetadataViewer = new QgsWebView( this );
113 mOptsPage_Information->layout()->addWidget( mMetadataViewer );
114
115 mRasterTransparencyWidget = new QgsRasterTransparencyWidget( mRasterLayer, canvas, this );
116
117 transparencyScrollArea->setWidget( mRasterTransparencyWidget );
118
119 mLabelingWidget = new QgsRasterLabelingWidget( mRasterLayer, canvas, this );
120 QVBoxLayout *vl = new QVBoxLayout();
121 vl->setContentsMargins( 0, 0, 0, 0 );
122 vl->addWidget( mLabelingWidget );
123 mOptsPage_Labeling->setLayout( vl );
124
125 connect( buttonBuildPyramids, &QPushButton::clicked, this, &QgsRasterLayerProperties::buttonBuildPyramids_clicked );
126 connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsRasterLayerProperties::mCrsSelector_crsChanged );
127 connect( mRenderTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged );
128 connect( mResetColorRenderingBtn, &QToolButton::clicked, this, &QgsRasterLayerProperties::mResetColorRenderingBtn_clicked );
129 // QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
130 // switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left),
131 // and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots
132 initOptionsBase( false );
133 connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsRasterLayerProperties::showHelp );
134
135 mSourceGroupBox->hide();
136
137 mBtnStyle = new QPushButton( tr( "Style" ) );
138 buttonBox->addButton( mBtnStyle, QDialogButtonBox::ResetRole );
139
140 connect( lyr->styleManager(), &QgsMapLayerStyleManager::currentStyleChanged, this, &QgsRasterLayerProperties::syncToLayer );
141
142 connect( this, &QDialog::accepted, this, &QgsRasterLayerProperties::apply );
143 connect( this, &QDialog::rejected, this, &QgsRasterLayerProperties::rollback );
144
145 connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsRasterLayerProperties::apply );
146
147 cbxPyramidsFormat->addItem( tr( "External" ), QVariant::fromValue( Qgis::RasterPyramidFormat::GeoTiff ) );
148 cbxPyramidsFormat->addItem( tr( "Internal (if possible)" ), QVariant::fromValue( Qgis::RasterPyramidFormat::Internal ) );
149 cbxPyramidsFormat->addItem( tr( "External (Erdas Imagine)" ), QVariant::fromValue( Qgis::RasterPyramidFormat::Erdas ) );
150
151 // brightness/contrast controls
152 connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
153 connect( mBrightnessSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
154 mBrightnessSpinBox->setClearValue( 0 );
155
156 connect( mSliderContrast, &QAbstractSlider::valueChanged, mContrastSpinBox, &QSpinBox::setValue );
157 connect( mContrastSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), mSliderContrast, &QAbstractSlider::setValue );
158 mContrastSpinBox->setClearValue( 0 );
159
160 // gamma correction controls
161 connect( mSliderGamma, &QAbstractSlider::valueChanged, this, &QgsRasterLayerProperties::updateGammaSpinBox );
162 connect( mGammaSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterLayerProperties::updateGammaSlider );
163 mGammaSpinBox->setClearValue( 1.0 );
164
165 // Connect saturation slider and spin box
166 connect( sliderSaturation, &QAbstractSlider::valueChanged, spinBoxSaturation, &QSpinBox::setValue );
167 connect( spinBoxSaturation, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), sliderSaturation, &QAbstractSlider::setValue );
168 spinBoxSaturation->setClearValue( 0 );
169
170 // Connect colorize strength slider and spin box
171 connect( sliderColorizeStrength, &QAbstractSlider::valueChanged, spinColorizeStrength, &QSpinBox::setValue );
172 connect( spinColorizeStrength, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), sliderColorizeStrength, &QAbstractSlider::setValue );
173 spinColorizeStrength->setClearValue( 100 );
174
175 // enable or disable saturation slider and spin box depending on grayscale combo choice
176 connect( comboGrayscale, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerProperties::toggleSaturationControls );
177
178 // enable or disable colorize colorbutton with colorize checkbox
179 connect( mColorizeCheck, &QAbstractButton::toggled, this, &QgsRasterLayerProperties::toggleColorizeControls );
180
181 // enable or disable Build Pyramids button depending on selection in pyramid list
182 connect( lbxPyramidResolutions, &QListWidget::itemSelectionChanged, this, &QgsRasterLayerProperties::toggleBuildPyramidsButton );
183
184 mRefreshSettingsWidget->setLayer( mRasterLayer );
185 mMapLayerServerPropertiesWidget->setHasWfsTitle( false );
186 mMapLayerServerPropertiesWidget->setServerProperties( mRasterLayer->serverProperties() );
187
188 // set up the scale based layer visibility stuff....
189 mScaleRangeWidget->setMapCanvas( mCanvas );
190 chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
191 mScaleRangeWidget->setScaleRange( lyr->minimumScale(), lyr->maximumScale() );
192
193 // build GUI components
194 QIcon myPyramidPixmap( QgsApplication::getThemeIcon( "/mIconPyramid.svg" ) );
195 QIcon myNoPyramidPixmap( QgsApplication::getThemeIcon( "/mIconNoPyramid.svg" ) );
196
197 initMapTipPreview();
198
199 if ( !mRasterLayer )
200 {
201 return;
202 }
203
204 mEnableMapTips->setChecked( mRasterLayer->mapTipsEnabled() );
205
206 updateRasterAttributeTableOptionsPage();
207
208 connect( mRasterLayer, &QgsRasterLayer::rendererChanged, this, &QgsRasterLayerProperties::updateRasterAttributeTableOptionsPage );
209
210 connect( mCreateRasterAttributeTableButton, &QPushButton::clicked, this, [this] {
211 if ( mRasterLayer->canCreateRasterAttributeTable() )
212 {
213 // Create the attribute table from the renderer
214 QgsCreateRasterAttributeTableDialog dlg { mRasterLayer };
215 dlg.setOpenWhenDoneVisible( false );
216 if ( dlg.exec() == QDialog::Accepted )
217 {
218 updateRasterAttributeTableOptionsPage();
219 }
220 }
221 } );
222
223 connect( mLoadRasterAttributeTableFromFileButton, &QPushButton::clicked, this, [this] {
224 // Load the attribute table from a VAT.DBF file
225 QgsLoadRasterAttributeTableDialog dlg { mRasterLayer };
226 dlg.setOpenWhenDoneVisible( false );
227 if ( dlg.exec() == QDialog::Accepted )
228 {
229 updateRasterAttributeTableOptionsPage();
230 }
231 } );
232
233 mBackupCrs = mRasterLayer->crs();
234
235 // Handles window modality raising canvas
236 if ( mCanvas && mRasterTransparencyWidget->pixelSelectorTool() )
237 {
238 connect( mRasterTransparencyWidget->pixelSelectorTool(), &QgsMapToolEmitPoint::deactivated, this, [this] {
239 hide();
240 setModal( true );
241 show();
242 raise();
243 activateWindow();
244 } );
245
246 connect( mRasterTransparencyWidget->pbnAddValuesFromDisplay, &QPushButton::clicked, this, [this] {
247 hide();
248 setModal( false );
249
250 // Transfer focus to the canvas to use the selector tool
251 mCanvas->window()->raise();
252 mCanvas->window()->activateWindow();
253 mCanvas->window()->setFocus();
254 } );
255 }
256
257 if ( mCanvas )
258 {
259 mContext = mCanvas->createExpressionContext();
260 }
261 else
262 {
267 }
268
269 // Initialize with layer center
270 mContext << QgsExpressionContextUtils::mapLayerPositionScope( mRasterLayer->extent().center() );
271 mContext << QgsExpressionContextUtils::layerScope( mRasterLayer );
272
273 connect( mInsertExpressionButton, &QAbstractButton::clicked, this, [this] {
274 // Get the linear indexes if the start and end of the selection
275 int selectionStart = mMapTipWidget->selectionStart();
276 int selectionEnd = mMapTipWidget->selectionEnd();
277 QString expression = QgsExpressionFinder::findAndSelectActiveExpression( mMapTipWidget );
278 QgsExpressionBuilderDialog exprDlg( nullptr, expression, this, u"generic"_s, mContext );
279
280 exprDlg.setWindowTitle( tr( "Insert Expression" ) );
281 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
282 mMapTipWidget->insertText( "[%" + exprDlg.expressionText().trimmed() + "%]" );
283 else // Restore the selection
284 mMapTipWidget->setLinearSelection( selectionStart, selectionEnd );
285 } );
286
287 QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
288
289 // Only do pyramids if dealing directly with GDAL.
290 if ( provider && ( provider->capabilities() & Qgis::RasterInterfaceCapability::BuildPyramids || provider->providerCapabilities() & Qgis::RasterProviderCapability::BuildPyramids ) )
291 {
292 // initialize resampling methods
293 cboResamplingMethod->clear();
294
295 const auto constProviderType = QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() );
296 for ( const QPair<QString, QString> &method : std::as_const( constProviderType ) )
297 {
298 cboResamplingMethod->addItem( method.second, method.first );
299 }
300
301 // keep it in sync with qgsrasterpyramidsoptionwidget.cpp
302 QString prefix = provider->name() + "/driverOptions/_pyramids/";
303 QgsSettings mySettings;
304 QString defaultMethod = mySettings.value( prefix + "resampling", "AVERAGE" ).toString();
305 int idx = cboResamplingMethod->findData( defaultMethod );
306 if ( idx >= 0 )
307 cboResamplingMethod->setCurrentIndex( idx );
308
309
310 // build pyramid list
311 const QList<QgsRasterPyramid> myPyramidList = provider->buildPyramidList();
312
313 for ( const QgsRasterPyramid &pyramid : myPyramidList )
314 {
315 if ( pyramid.getExists() )
316 {
317 lbxPyramidResolutions->addItem( new QListWidgetItem( myPyramidPixmap, QString::number( pyramid.getXDim() ) + u" x "_s + QString::number( pyramid.getYDim() ) ) );
318 }
319 else
320 {
321 lbxPyramidResolutions->addItem( new QListWidgetItem( myNoPyramidPixmap, QString::number( pyramid.getXDim() ) + u" x "_s + QString::number( pyramid.getYDim() ) ) );
322 }
323 }
324 }
325 else
326 {
327 // disable Pyramids tab completely
328 mOptsPage_Pyramids->setEnabled( false );
329 }
330
331 // We can calculate histogram for all data sources but estimated only if
332 // size is unknown - could also be enabled if well supported (estimated histogram
333 // and let user know that it is estimated)
334 if ( !provider || !( provider->capabilities() & Qgis::RasterInterfaceCapability::Size ) )
335 {
336 // disable Histogram tab completely
337 mOptsPage_Histogram->setEnabled( false );
338 }
339
340 QVBoxLayout *layout = new QVBoxLayout( metadataFrame );
341 layout->setContentsMargins( 0, 0, 0, 0 );
342 mMetadataWidget = new QgsMetadataWidget( this, mRasterLayer );
343 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
344 mMetadataWidget->setMapCanvas( mCanvas );
345 layout->addWidget( mMetadataWidget );
346 metadataFrame->setLayout( layout );
347
348 QVBoxLayout *temporalLayout = new QVBoxLayout( temporalFrame );
349 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
350 mTemporalWidget = new QgsRasterLayerTemporalPropertiesWidget( this, mRasterLayer );
351 temporalLayout->addWidget( mTemporalWidget );
352
353 QgsDebugMsgLevel( "Setting crs to " + mRasterLayer->crs().toWkt( Qgis::CrsWktVariant::Preferred ), 2 );
354 QgsDebugMsgLevel( "Setting crs to " + mRasterLayer->crs().userFriendlyIdentifier(), 2 );
355 mCrsSelector->setCrs( mRasterLayer->crs() );
356
357 // Set text for pyramid info box
358 QString pyramidFormat( u"<h2>%1</h2><p>%2 %3 %4</p><b><font color='red'><p>%5</p><p>%6</p>"_s );
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!" );
365
366 tePyramidDescription->setHtml( pyramidFormat.arg( pyramidHeader, pyramidSentence1, pyramidSentence2, pyramidSentence3, pyramidSentence4, pyramidSentence5 ) );
367
368 //resampling
369 mResamplingGroupBox->setSaveCheckedState( true );
370 mResamplingUtils.initWidgets( mRasterLayer, mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox, mMaximumOversamplingSpinBox, mCbEarlyResampling );
371 mResamplingUtils.refreshWidgetsFromLayer();
372
373 const QgsRasterRenderer *renderer = mRasterLayer->renderer();
374
375 btnColorizeColor->setColorDialogTitle( tr( "Select Color" ) );
376 btnColorizeColor->setContext( u"symbology"_s );
377
378 // Hue and saturation color control
379 const QgsHueSaturationFilter *hueSaturationFilter = mRasterLayer->hueSaturationFilter();
380 //set hue and saturation controls to current values
381 if ( hueSaturationFilter )
382 {
383 sliderSaturation->setValue( hueSaturationFilter->saturation() );
384 comboGrayscale->setCurrentIndex( ( int ) hueSaturationFilter->grayscaleMode() );
385
386 // Set initial state of saturation controls based on grayscale mode choice
387 toggleSaturationControls( static_cast<int>( hueSaturationFilter->grayscaleMode() ) );
388
389 // Set initial state of colorize controls
390 mColorizeCheck->setChecked( hueSaturationFilter->colorizeOn() );
391 btnColorizeColor->setColor( hueSaturationFilter->colorizeColor() );
392 toggleColorizeControls( hueSaturationFilter->colorizeOn() );
393 sliderColorizeStrength->setValue( hueSaturationFilter->colorizeStrength() );
394 mInvertColorsCheck->setChecked( hueSaturationFilter->invertColors() );
395 }
396
397 //blend mode
398 mBlendModeComboBox->setShowClippingModes( QgsProjectUtils::layerIsContainedInGroupLayer( QgsProject::instance(), mRasterLayer ) );
399 mBlendModeComboBox->setBlendMode( mRasterLayer->blendMode() );
400
401 //transparency band
402 if ( provider )
403 {
404 mRasterTransparencyWidget->cboxTransparencyBand->setShowNotSetOption( true, tr( "None" ) );
405 mRasterTransparencyWidget->cboxTransparencyBand->setLayer( mRasterLayer );
406
407// Alpha band is set in sync()
408#if 0
409 if ( renderer )
410 {
411 QgsDebugMsgLevel( u"alphaBand = %1"_s.arg( renderer->alphaBand() ), 2 );
412 if ( renderer->alphaBand() > 0 )
413 {
414 cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->alphaBand() ) );
415 }
416 }
417#endif
418 }
419
420 // create histogram widget
421 mHistogramWidget = nullptr;
422 if ( mOptsPage_Histogram->isEnabled() )
423 {
424 mHistogramWidget = new QgsRasterHistogramWidget( mRasterLayer, mOptsPage_Histogram );
425 mHistogramStackedWidget->addWidget( mHistogramWidget );
426 }
427
428 //insert renderer widgets into registry
436
437 //fill available renderers into combo box
439 mDisableRenderTypeComboBoxCurrentIndexChanged = true;
440 const auto constRenderersList = QgsApplication::rasterRendererRegistry()->renderersList();
441 for ( const QString &name : constRenderersList )
442 {
443 if ( QgsApplication::rasterRendererRegistry()->rendererData( name, entry ) )
444 {
445 if ( ( mRasterLayer->rasterType() != Qgis::RasterLayerType::SingleBandColorData && entry.name != "singlebandcolordata"_L1 ) || ( mRasterLayer->rasterType() == Qgis::RasterLayerType::SingleBandColorData && entry.name == "singlebandcolordata"_L1 ) )
446 {
447 mRenderTypeComboBox->addItem( entry.visibleName, entry.name );
448 }
449 }
450 }
451 mDisableRenderTypeComboBoxCurrentIndexChanged = false;
452
453 int widgetIndex = 0;
454 if ( renderer )
455 {
456 QString rendererType = renderer->type();
457 widgetIndex = mRenderTypeComboBox->findData( rendererType );
458 if ( widgetIndex != -1 )
459 {
460 mDisableRenderTypeComboBoxCurrentIndexChanged = true;
461 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
462 mDisableRenderTypeComboBoxCurrentIndexChanged = false;
463 }
464
465 if ( rendererType == "singlebandcolordata"_L1 && mRenderTypeComboBox->count() == 1 )
466 {
467 // no band rendering options for singlebandcolordata, so minimize group box
468 QSizePolicy sizep = mBandRenderingGrpBx->sizePolicy();
469 sizep.setVerticalStretch( 0 );
470 sizep.setVerticalPolicy( QSizePolicy::Maximum );
471 mBandRenderingGrpBx->setSizePolicy( sizep );
472 mBandRenderingGrpBx->updateGeometry();
473 }
474
475 if ( mRasterLayer->providerType() != "wms"_L1 )
476 {
477 mWMSPrintGroupBox->hide();
478 mPublishDataSourceUrlCheckBox->hide();
479 mBackgroundLayerCheckBox->hide();
480 }
481 }
482
483 initializeDataDefinedButton( mRasterTransparencyWidget->mOpacityDDBtn, QgsRasterPipe::Property::RendererOpacity );
484
485 mRenderTypeComboBox_currentIndexChanged( widgetIndex );
486
487 setMetadataWidget( mMetadataWidget, mOptsPage_Metadata );
488
489 QMenu *menuStyle = new QMenu( this );
490 menuStyle->addAction( tr( "Load Style…" ), this, &QgsRasterLayerProperties::loadStyle );
491 menuStyle->addAction( tr( "Save Style…" ), this, &QgsRasterLayerProperties::saveStyleAs );
492 menuStyle->addSeparator();
493 menuStyle->addAction( tr( "Save as Default" ), this, &QgsRasterLayerProperties::saveStyleAsDefault );
494 menuStyle->addAction( tr( "Restore Default" ), this, &QgsRasterLayerProperties::loadDefaultStyle );
495 mBtnStyle->setMenu( menuStyle );
496 connect( menuStyle, &QMenu::aboutToShow, this, &QgsRasterLayerProperties::aboutToShowStyleMenu );
497
498 mBtnMetadata = new QPushButton( tr( "Metadata" ), this );
499 QMenu *menuMetadata = new QMenu( this );
500 mActionLoadMetadata = menuMetadata->addAction( tr( "Load Metadata…" ), this, &QgsRasterLayerProperties::loadMetadataFromFile );
501 mActionSaveMetadataAs = menuMetadata->addAction( tr( "Save Metadata…" ), this, &QgsRasterLayerProperties::saveMetadataToFile );
502 menuMetadata->addSeparator();
503 menuMetadata->addAction( tr( "Save as Default" ), this, &QgsRasterLayerProperties::saveMetadataAsDefault );
504 menuMetadata->addAction( tr( "Restore Default" ), this, &QgsRasterLayerProperties::loadDefaultMetadata );
505 mBtnMetadata->setMenu( menuMetadata );
506 buttonBox->addButton( mBtnMetadata, QDialogButtonBox::ResetRole );
507
508 // update based on lyr's current state
509 sync();
510
511 QgsSettings settings;
512 // if dialog hasn't been opened/closed yet, default to Styles tab, which is used most often
513 // this will be read by restoreOptionsBaseUi()
514 if ( !settings.contains( u"/Windows/RasterLayerProperties/tab"_s ) )
515 {
516 settings.setValue( u"Windows/RasterLayerProperties/tab"_s, mOptStackedWidget->indexOf( mOptsPage_Style ) );
517 }
518
519 mResetColorRenderingBtn->setIcon( QgsApplication::getThemeIcon( u"/mActionUndo.svg"_s ) );
520
521 optionsStackedWidget_CurrentChanged( mOptionsStackedWidget->currentIndex() );
522
523 //Add help page references
524 mOptsPage_Information->setProperty( "helpPage", u"working_with_raster/raster_properties.html#information-properties"_s );
525 mOptsPage_Source->setProperty( "helpPage", u"working_with_raster/raster_properties.html#source-properties"_s );
526 mOptsPage_Style->setProperty( "helpPage", u"working_with_raster/raster_properties.html#symbology-properties"_s );
527 mOptsPage_Transparency->setProperty( "helpPage", u"working_with_raster/raster_properties.html#transparency-properties"_s );
528
529 if ( mOptsPage_Histogram )
530 mOptsPage_Histogram->setProperty( "helpPage", u"working_with_raster/raster_properties.html#histogram-properties"_s );
531
532 mOptsPage_Rendering->setProperty( "helpPage", u"working_with_raster/raster_properties.html#rendering-properties"_s );
533 mOptsPage_Temporal->setProperty( "helpPage", u"working_with_raster/raster_properties.html#temporal-properties"_s );
534
535 if ( mOptsPage_Pyramids )
536 mOptsPage_Pyramids->setProperty( "helpPage", u"working_with_raster/raster_properties.html#pyramids-properties"_s );
537
538 if ( mOptsPage_Display )
539 mOptsPage_Display->setProperty( "helpPage", u"working_with_raster/raster_properties.html#display-properties"_s );
540
541 mOptsPage_Metadata->setProperty( "helpPage", u"working_with_raster/raster_properties.html#metadata-properties"_s );
542 mOptsPage_Legend->setProperty( "helpPage", u"working_with_raster/raster_properties.html#legend-properties"_s );
543 mOptsPage_Server->setProperty( "helpPage", u"working_with_raster/raster_properties.html#server-properties"_s );
544
545 initialize();
546}
547
549{
550 if ( !factory->supportsLayer( mRasterLayer ) || !factory->supportLayerPropertiesDialog() )
551 {
552 return;
553 }
554
555 QgsMapLayerConfigWidget *page = factory->createWidget( mRasterLayer, nullptr, false, this );
556 switch ( factory->parentPage() )
557 {
559 {
560 mConfigWidgets << page;
561
562 const QString beforePage = factory->layerPropertiesPagePositionHint();
563 if ( beforePage.isEmpty() )
564 addPage( factory->title(), factory->title(), factory->icon(), page );
565 else
566 insertPage( factory->title(), factory->title(), factory->icon(), page, beforePage );
567 break;
568 }
569
571 mTemporalWidget->addWidget( page );
572 break;
573 }
574}
575
580
581void QgsRasterLayerProperties::updateRasterAttributeTableOptionsPage()
582{
583 if ( mRasterAttributeTableWidget )
584 {
585 mOptsPage_RasterAttributeTable->layout()->removeWidget( mRasterAttributeTableWidget );
586 mRasterAttributeTableWidget = nullptr;
587 }
588
589 // Setup raster attribute table
590 if ( mRasterLayer->attributeTableCount() > 0 )
591 {
592 mRasterAttributeTableWidget = new QgsRasterAttributeTableWidget( this, mRasterLayer );
593 mOptsPage_RasterAttributeTable->layout()->addWidget( mRasterAttributeTableWidget );
594 // When the renderer changes we need to sync the style options page
595 connect( mRasterAttributeTableWidget, &QgsRasterAttributeTableWidget::rendererChanged, this, &QgsRasterLayerProperties::syncToLayer );
596 mNoRasterAttributeTableWidget->hide();
597 }
598 else
599 {
600 mNoRasterAttributeTableWidget->show();
601 mCreateRasterAttributeTableButton->setEnabled( mRasterLayer->canCreateRasterAttributeTable() );
602 }
603}
604
605void QgsRasterLayerProperties::setRendererWidget( const QString &rendererName )
606{
607 QgsDebugMsgLevel( "rendererName = " + rendererName, 3 );
608 QgsRasterRendererWidget *oldWidget = mRendererWidget;
609 QgsRasterRenderer *oldRenderer = mRasterLayer->renderer();
610
611 int alphaBand = -1;
612 double opacity = 1;
613 QColor nodataColor;
614 const QList<int> oldBands = oldRenderer ? oldRenderer->usesBands() : QList<int>();
615 if ( oldRenderer )
616 {
617 // Retain alpha band and opacity when switching renderer
618 alphaBand = oldRenderer->alphaBand();
619 opacity = oldRenderer->opacity();
620 nodataColor = oldRenderer->nodataColor();
621 }
622
623 QgsRasterRendererRegistryEntry rendererEntry;
624 if ( QgsApplication::rasterRendererRegistry()->rendererData( rendererName, rendererEntry ) )
625 {
626 if ( rendererEntry.widgetCreateFunction ) //single band color data renderer e.g. has no widget
627 {
628 QgsDebugMsgLevel( u"renderer has widgetCreateFunction"_s, 3 );
629 // Current canvas extent (used to calc min/max) in layer CRS
630 QgsRectangle myExtent = mCanvas->mapSettings().outputExtentToLayerExtent( mRasterLayer, mCanvas->extent() );
631 if ( oldWidget && ( !oldRenderer || rendererName != oldRenderer->type() ) )
632 {
633 if ( rendererName == "singlebandgray"_L1 )
634 {
635 whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( Qgis::RasterDrawingStyle::SingleBandGray, mRasterLayer->dataProvider() ) );
636 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
637 }
638 else if ( rendererName == "multibandcolor"_L1 )
639 {
640 whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( Qgis::RasterDrawingStyle::MultiBandColor, mRasterLayer->dataProvider() ) );
641 whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
642 }
643 }
644 mRasterLayer->renderer()->setAlphaBand( alphaBand );
645 mRasterLayer->renderer()->setOpacity( opacity );
646 mRasterLayer->renderer()->setNodataColor( nodataColor );
647 mRendererWidget = rendererEntry.widgetCreateFunction( mRasterLayer, myExtent );
648 mRendererWidget->setMapCanvas( mCanvas );
649 mRendererStackedWidget->addWidget( mRendererWidget );
650 if ( oldWidget )
651 {
652 //compare used bands in new and old renderer and reset transparency dialog if different
653 std::unique_ptr<QgsRasterRenderer> newRenderer;
654 newRenderer.reset( mRendererWidget->renderer() );
655 const QList<int> newBands = newRenderer->usesBands();
656 if ( oldBands != newBands )
657 {
658 mRasterTransparencyWidget->syncToLayer();
659 }
660 }
661 }
662 }
663
664 const int widgetIndex = mRenderTypeComboBox->findData( rendererName );
665 if ( widgetIndex != -1 )
666 {
667 mDisableRenderTypeComboBoxCurrentIndexChanged = true;
668 mRenderTypeComboBox->setCurrentIndex( widgetIndex );
669 mDisableRenderTypeComboBoxCurrentIndexChanged = false;
670 }
671
672 if ( mRendererWidget != oldWidget )
673 delete oldWidget;
674
675 if ( mHistogramWidget )
676 {
677 mHistogramWidget->setRendererWidget( rendererName, mRendererWidget );
678 }
679}
680
681void QgsRasterLayerProperties::sync()
682{
683 QgsSettings myQSettings;
684
685 if ( !mSourceWidget )
686 {
687 mSourceWidget = QgsGui::sourceWidgetProviderRegistry()->createWidget( mRasterLayer );
688 if ( mSourceWidget )
689 {
690 QHBoxLayout *layout = new QHBoxLayout();
691 layout->addWidget( mSourceWidget );
692 mSourceGroupBox->setLayout( layout );
693 if ( !mSourceWidget->groupTitle().isEmpty() )
694 mSourceGroupBox->setTitle( mSourceWidget->groupTitle() );
695 mSourceGroupBox->show();
696
697 connect( mSourceWidget, &QgsProviderSourceWidget::validChanged, this, [this]( bool isValid ) {
698 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
699 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
700 } );
701 }
702 }
703
704 if ( mSourceWidget )
705 {
706 mSourceWidget->setMapCanvas( mCanvas );
707 mSourceWidget->setSourceUri( mRasterLayer->source() );
708 }
709
710 const QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
711 if ( !provider )
712 return;
713
714 mRasterTransparencyWidget->syncToLayer();
715 mLabelingWidget->syncToLayer( mRasterLayer );
716
717 if ( provider->dataType( 1 ) == Qgis::DataType::ARGB32
719 {
720 mRasterTransparencyWidget->gboxNoDataValue->setEnabled( false );
721 mRasterTransparencyWidget->gboxCustomTransparency->setEnabled( false );
722 mOptionsStackedWidget->setCurrentWidget( mOptsPage_Server );
723 }
724
725 // TODO: Wouldn't it be better to just removeWidget() the tabs than delete them? [LS]
728 {
729 if ( mOptsPage_Pyramids )
730 {
731 delete mOptsPage_Pyramids;
732 mOptsPage_Pyramids = nullptr;
733 }
734 }
735
737 {
738 if ( mOptsPage_Histogram )
739 {
740 delete mOptsPage_Histogram;
741 mOptsPage_Histogram = nullptr;
742 delete mHistogramWidget;
743 mHistogramWidget = nullptr;
744 }
745 }
746
747 QgsDebugMsgLevel( u"populate transparency tab"_s, 3 );
748
749 /*
750 * Style tab
751 */
752
753 //set brightness, contrast and gamma
754 QgsBrightnessContrastFilter *brightnessFilter = mRasterLayer->brightnessFilter();
755 if ( brightnessFilter )
756 {
757 mSliderBrightness->setValue( brightnessFilter->brightness() );
758 mSliderContrast->setValue( brightnessFilter->contrast() );
759 mGammaSpinBox->setValue( brightnessFilter->gamma() );
760 }
761
762 // Hue and saturation color control
763 const QgsHueSaturationFilter *hueSaturationFilter = mRasterLayer->hueSaturationFilter();
764 //set hue and saturation controls to current values
765 if ( hueSaturationFilter )
766 {
767 sliderSaturation->setValue( hueSaturationFilter->saturation() );
768 comboGrayscale->setCurrentIndex( ( int ) hueSaturationFilter->grayscaleMode() );
769
770 // Set state of saturation controls based on grayscale mode choice
771 toggleSaturationControls( static_cast<int>( hueSaturationFilter->grayscaleMode() ) );
772
773 // Set state of colorize controls
774 mColorizeCheck->setChecked( hueSaturationFilter->colorizeOn() );
775 btnColorizeColor->setColor( hueSaturationFilter->colorizeColor() );
776 toggleColorizeControls( hueSaturationFilter->colorizeOn() );
777 sliderColorizeStrength->setValue( hueSaturationFilter->colorizeStrength() );
778 mInvertColorsCheck->setChecked( hueSaturationFilter->invertColors() );
779 }
780
781 // Resampling
782 mResamplingUtils.refreshWidgetsFromLayer();
783
784 mRefreshSettingsWidget->syncToLayer();
785 mMapLayerServerPropertiesWidget->sync();
786
787 QgsDebugMsgLevel( u"populate general tab"_s, 3 );
788 /*
789 * General Tab
790 */
791
792 mLayerOrigNameLineEd->setText( mRasterLayer->name() );
793
794 QgsDebugMsgLevel( u"populate metadata tab"_s, 2 );
795 /*
796 * Metadata Tab
797 */
798 //populate the metadata tab's text browser widget with gdal metadata info
799 updateInformationContent();
800
801 mEnableMapTips->setChecked( mRasterLayer->mapTipsEnabled() );
802 mMapTipWidget->setText( mRasterLayer->mapTipTemplate() );
803
804 //WMS print layer
805 QVariant wmsPrintLayer = mRasterLayer->customProperty( u"WMSPrintLayer"_s );
806 if ( wmsPrintLayer.isValid() )
807 {
808 mWMSPrintLayerLineEdit->setText( wmsPrintLayer.toString() );
809 }
810
811 QVariant wmsPublishDataSourceUrl = mRasterLayer->customProperty( u"WMSPublishDataSourceUrl"_s, false );
812 mPublishDataSourceUrlCheckBox->setChecked( wmsPublishDataSourceUrl.toBool() );
813
814 QVariant wmsBackgroundLayer = mRasterLayer->customProperty( u"WMSBackgroundLayer"_s, false );
815 mBackgroundLayerCheckBox->setChecked( wmsBackgroundLayer.toBool() );
816
817 mLegendPlaceholderWidget->setLastPathSettingsKey( u"lastLegendPlaceholderDir"_s );
818 mLegendPlaceholderWidget->setSource( mRasterLayer->legendPlaceholderImage() );
819 mLegendConfigEmbeddedWidget->setLayer( mRasterLayer );
820 mIncludeByDefaultInLayoutLegendsCheck->setChecked( mRasterLayer->legend() && !mRasterLayer->legend()->flags().testFlag( Qgis::MapLayerLegendFlag::ExcludeByDefault ) );
821
822 mTemporalWidget->syncToLayer();
823
824 mPropertyCollection = mRasterLayer->pipe()->dataDefinedProperties();
825 updateDataDefinedButtons();
826
827 for ( QgsMapLayerConfigWidget *page : std::as_const( mConfigWidgets ) )
828 {
829 page->syncToLayer( mRasterLayer );
830 }
831}
832
834{
835 if ( mSourceWidget )
836 {
837 const QString newSource = mSourceWidget->sourceUri();
838 if ( newSource != mRasterLayer->source() )
839 {
840 mRasterLayer->setDataSource( newSource, mRasterLayer->name(), mRasterLayer->providerType(), QgsDataProvider::ProviderOptions() );
841 }
842 }
843
844 // Do nothing on "bad" layers
845 if ( !mRasterLayer->isValid() )
846 return;
847
848 // apply all plugin dialogs
849 for ( QgsMapLayerConfigWidget *page : std::as_const( mConfigWidgets ) )
850 {
851 page->apply();
852 }
853
854
855 /*
856 * Legend Tab
857 */
858 mRasterLayer->setLegendPlaceholderImage( mLegendPlaceholderWidget->source() );
859 mLegendConfigEmbeddedWidget->applyToLayer();
860
861 QgsDebugMsgLevel( u"apply processing symbology tab"_s, 3 );
862 /*
863 * Symbology Tab
864 */
865
866 //set whether the layer histogram should be inverted
867 //mRasterLayer->setInvertHistogram( cboxInvertColorMap->isChecked() );
868
869 mRasterLayer->brightnessFilter()->setBrightness( mSliderBrightness->value() );
870 mRasterLayer->brightnessFilter()->setContrast( mSliderContrast->value() );
871 mRasterLayer->brightnessFilter()->setGamma( mGammaSpinBox->value() );
872
873 QgsDebugMsgLevel( u"processing transparency tab"_s, 3 );
874 /*
875 * Transparent Pixel Tab
876 */
877
878 mRasterTransparencyWidget->applyToRasterProvider( mRasterLayer->dataProvider() );
879
880 //set renderer from widget
881 QgsRasterRendererWidget *rendererWidget = dynamic_cast<QgsRasterRendererWidget *>( mRendererStackedWidget->currentWidget() );
882 if ( rendererWidget )
883 {
884 rendererWidget->doComputations();
885
886 mRasterLayer->setRenderer( rendererWidget->renderer() );
887 }
888
889 mBackupCrs = mRasterLayer->crs();
890 mMetadataWidget->acceptMetadata();
891 mMetadataFilled = false;
892
893 //transparency settings
894 QgsRasterRenderer *rasterRenderer = mRasterLayer->renderer();
895 mRasterTransparencyWidget->applyToRasterRenderer( rasterRenderer );
896
897 mLabelingWidget->apply();
898
899 if ( rasterRenderer )
900 {
901 // Sync the layer styling widget
902 mRasterLayer->emitStyleChanged();
903 }
904
905 QgsDebugMsgLevel( u"processing general tab"_s, 3 );
906 /*
907 * General Tab
908 */
909 mRasterLayer->setName( mLayerOrigNameLineEd->text() );
910
911 // set up the scale based layer visibility stuff....
912 mRasterLayer->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
913 mRasterLayer->setMinimumScale( mScaleRangeWidget->minimumScale() );
914 mRasterLayer->setMaximumScale( mScaleRangeWidget->maximumScale() );
915
916 mRefreshSettingsWidget->saveToLayer();
917 if ( mMapLayerServerPropertiesWidget->save() )
918 mMetadataFilled = true;
919
920 //update the legend pixmap
921 // pixmapLegend->setPixmap( mRasterLayer->legendAsPixmap() );
922 // pixmapLegend->setScaledContents( true );
923 // pixmapLegend->repaint();
924
925 mResamplingUtils.refreshLayerFromWidgets();
926
927 // Hue and saturation controls
928 QgsHueSaturationFilter *hueSaturationFilter = mRasterLayer->hueSaturationFilter();
929 if ( hueSaturationFilter )
930 {
931 hueSaturationFilter->setSaturation( sliderSaturation->value() );
932 hueSaturationFilter->setGrayscaleMode( ( QgsHueSaturationFilter::GrayscaleMode ) comboGrayscale->currentIndex() );
933 hueSaturationFilter->setColorizeOn( mColorizeCheck->checkState() );
934 hueSaturationFilter->setColorizeColor( btnColorizeColor->color() );
935 hueSaturationFilter->setColorizeStrength( sliderColorizeStrength->value() );
936 hueSaturationFilter->setInvertColors( mInvertColorsCheck->isChecked() );
937 }
938
939 //set the blend mode for the layer
940 mRasterLayer->setBlendMode( mBlendModeComboBox->blendMode() );
941
942 // Update temporal properties
943 mTemporalWidget->saveTemporalProperties();
944
945 mRasterLayer->setCrs( mCrsSelector->crs() );
946
947 if ( !mWMSPrintLayerLineEdit->text().isEmpty() )
948 {
949 mRasterLayer->setCustomProperty( u"WMSPrintLayer"_s, mWMSPrintLayerLineEdit->text() );
950 }
951
952 mRasterLayer->setCustomProperty( "WMSPublishDataSourceUrl", mPublishDataSourceUrlCheckBox->isChecked() );
953 mRasterLayer->setCustomProperty( "WMSBackgroundLayer", mBackgroundLayerCheckBox->isChecked() );
954
955 mRasterLayer->pipe()->setDataDefinedProperties( mPropertyCollection );
956
957 mRasterLayer->setMapTipsEnabled( mEnableMapTips->isChecked() );
958 mRasterLayer->setMapTipTemplate( mMapTipWidget->text() );
959
960 // Force a redraw of the legend
961 mRasterLayer->setLegend( QgsMapLayerLegend::defaultRasterLegend( mRasterLayer ) );
962 if ( QgsMapLayerLegend *legend = mRasterLayer->legend() )
963 {
964 legend->setFlag( Qgis::MapLayerLegendFlag::ExcludeByDefault, !mIncludeByDefaultInLayoutLegendsCheck->isChecked() );
965 }
966
967 //make sure the layer is redrawn
968 mRasterLayer->triggerRepaint();
969
970 // notify the project we've made a change
972}
973
974void QgsRasterLayerProperties::buttonBuildPyramids_clicked()
975{
976 QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
977
978 auto feedback = std::make_unique<QgsRasterBlockFeedback>();
979
980 connect( feedback.get(), &QgsRasterBlockFeedback::progressChanged, mPyramidProgress, &QProgressBar::setValue );
981 //
982 // Go through the list marking any files that are selected in the listview
983 // as true so that we can generate pyramids for them.
984 //
985 QList<QgsRasterPyramid> myPyramidList = provider->buildPyramidList();
986 for ( int myCounterInt = 0; myCounterInt < lbxPyramidResolutions->count(); myCounterInt++ )
987 {
988 QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt );
989 //mark to be pyramided
990 myPyramidList[myCounterInt].setBuild( myItem->isSelected() || myPyramidList[myCounterInt].getExists() );
991 }
992
993 // keep it in sync with qgsrasterpyramidsoptionwidget.cpp
994 QString prefix = provider->name() + "/driverOptions/_pyramids/";
995 QgsSettings mySettings;
996 QString resamplingMethod( cboResamplingMethod->currentData().toString() );
997 mySettings.setValue( prefix + "resampling", resamplingMethod );
998
999 //
1000 // Ask raster layer to build the pyramids
1001 //
1002
1003 // let the user know we're going to possibly be taking a while
1004 QApplication::setOverrideCursor( Qt::WaitCursor );
1005 QString res = provider->buildPyramids(
1006 myPyramidList,
1007 resamplingMethod,
1008 cbxPyramidsFormat->currentData().value<Qgis::RasterPyramidFormat>(),
1009 QStringList(),
1010 feedback.get()
1011 );
1012 QApplication::restoreOverrideCursor();
1013 mPyramidProgress->setValue( 0 );
1014 buttonBuildPyramids->setEnabled( false );
1015 if ( !res.isNull() )
1016 {
1017 if ( res == "CANCELED"_L1 )
1018 {
1019 // user canceled
1020 }
1021 else if ( res == "ERROR_WRITE_ACCESS"_L1 )
1022 {
1023 QMessageBox::warning( this, tr( "Building Pyramids" ), tr( "Write access denied. Adjust the file permissions and try again." ) );
1024 }
1025 else if ( res == "ERROR_WRITE_FORMAT"_L1 )
1026 {
1027 QMessageBox::warning( this, tr( "Building Pyramids" ), tr( "The file was not writable. Some formats do not "
1028 "support pyramid overviews. Consult the GDAL documentation if in doubt." ) );
1029 }
1030 else if ( res == "FAILED_NOT_SUPPORTED"_L1 )
1031 {
1032 QMessageBox::warning( this, tr( "Building Pyramids" ), tr( "Building pyramid overviews is not supported on this type of raster." ) );
1033 }
1034 else if ( res == "ERROR_JPEG_COMPRESSION"_L1 )
1035 {
1036 QMessageBox::warning( this, tr( "Building Pyramids" ), tr( "Building internal pyramid overviews is not supported on raster layers with JPEG compression and your current libtiff library." ) );
1037 }
1038 else if ( res == "ERROR_VIRTUAL"_L1 )
1039 {
1040 QMessageBox::warning( this, tr( "Building Pyramids" ), tr( "Building pyramid overviews is not supported on this type of raster." ) );
1041 }
1042 }
1043
1044 //
1045 // repopulate the pyramids list
1046 //
1047 lbxPyramidResolutions->clear();
1048 // Need to rebuild list as some or all pyramids may have failed to build
1049 myPyramidList = provider->buildPyramidList();
1050 QIcon myPyramidPixmap( QgsApplication::getThemeIcon( "/mIconPyramid.svg" ) );
1051 QIcon myNoPyramidPixmap( QgsApplication::getThemeIcon( "/mIconNoPyramid.svg" ) );
1052
1053 for ( const QgsRasterPyramid &pyramid : std::as_const( myPyramidList ) )
1054 {
1055 if ( pyramid.getExists() )
1056 {
1057 lbxPyramidResolutions->addItem( new QListWidgetItem( myPyramidPixmap, QString::number( pyramid.getXDim() ) + u" x "_s + QString::number( pyramid.getYDim() ) ) );
1058 }
1059 else
1060 {
1061 lbxPyramidResolutions->addItem( new QListWidgetItem( myNoPyramidPixmap, QString::number( pyramid.getXDim() ) + u" x "_s + QString::number( pyramid.getYDim() ) ) );
1062 }
1063 }
1064 //update the legend pixmap
1065 // pixmapLegend->setPixmap( mRasterLayer->legendAsPixmap() );
1066 // pixmapLegend->setScaledContents( true );
1067 // pixmapLegend->repaint();
1068
1069 //populate the metadata tab's text browser widget with gdal metadata info
1070 updateInformationContent();
1071}
1072
1073void QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged( int index )
1074{
1075 if ( index < 0 || mDisableRenderTypeComboBoxCurrentIndexChanged || !mRasterLayer->renderer() )
1076 {
1077 return;
1078 }
1079
1080 QString rendererName = mRenderTypeComboBox->itemData( index ).toString();
1081 setRendererWidget( rendererName );
1082}
1083
1084void QgsRasterLayerProperties::mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs )
1085{
1086 QgsDatumTransformDialog::run( crs, QgsProject::instance()->crs(), this, mCanvas, tr( "Select Transformation" ) );
1087 mRasterLayer->setCrs( crs );
1088 mMetadataWidget->crsChanged();
1089}
1090
1091void QgsRasterLayerProperties::aboutToShowStyleMenu()
1092{
1093 // this should be unified with QgsVectorLayerProperties::aboutToShowStyleMenu()
1094
1095 QMenu *m = qobject_cast<QMenu *>( sender() );
1096
1098 // re-add style manager actions!
1099 m->addSeparator();
1101}
1102
1104{
1105 QgsRasterRenderer *renderer = mRasterLayer->renderer();
1106 if ( renderer )
1107 {
1108 setRendererWidget( renderer->type() );
1109 }
1110 sync();
1111 mRasterLayer->triggerRepaint();
1112}
1113
1115{
1117
1118 if ( !mHistogramWidget )
1119 return;
1120
1121 if ( index == mOptStackedWidget->indexOf( mOptsPage_Histogram ) )
1122 {
1123 mHistogramWidget->setActive( true );
1124 }
1125 else
1126 {
1127 mHistogramWidget->setActive( false );
1128 }
1129
1130 if ( index == mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
1131 {
1132 //set the metadata contents (which can be expensive)
1133 updateInformationContent();
1134 }
1135}
1136
1137void QgsRasterLayerProperties::initializeDataDefinedButton( QgsPropertyOverrideButton *button, QgsRasterPipe::Property key )
1138{
1139 button->blockSignals( true );
1140 button->init( static_cast<int>( key ), mPropertyCollection, QgsRasterPipe::propertyDefinitions(), nullptr );
1141 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsRasterLayerProperties::updateProperty );
1142 button->registerExpressionContextGenerator( this );
1143 button->blockSignals( false );
1144}
1145
1146void QgsRasterLayerProperties::updateDataDefinedButtons()
1147{
1148 const QList<QgsPropertyOverrideButton *> propertyOverrideButtons { findChildren<QgsPropertyOverrideButton *>() };
1149 for ( QgsPropertyOverrideButton *button : propertyOverrideButtons )
1150 {
1151 updateDataDefinedButton( button );
1152 }
1153}
1154
1155void QgsRasterLayerProperties::updateDataDefinedButton( QgsPropertyOverrideButton *button )
1156{
1157 if ( !button )
1158 return;
1159
1160 if ( button->propertyKey() < 0 )
1161 return;
1162
1163 QgsRasterPipe::Property key = static_cast<QgsRasterPipe::Property>( button->propertyKey() );
1164 whileBlocking( button )->setToProperty( mPropertyCollection.property( key ) );
1165}
1166
1167void QgsRasterLayerProperties::updateProperty()
1168{
1169 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
1170 QgsRasterPipe::Property key = static_cast<QgsRasterPipe::Property>( button->propertyKey() );
1171 mPropertyCollection.setProperty( key, button->toProperty() );
1172}
1173
1174void QgsRasterLayerProperties::toggleSaturationControls( int grayscaleMode )
1175{
1176 // Enable or disable saturation controls based on choice of grayscale mode
1177 if ( grayscaleMode == 0 )
1178 {
1179 sliderSaturation->setEnabled( true );
1180 spinBoxSaturation->setEnabled( true );
1181 }
1182 else
1183 {
1184 sliderSaturation->setEnabled( false );
1185 spinBoxSaturation->setEnabled( false );
1186 }
1187}
1188
1189void QgsRasterLayerProperties::toggleColorizeControls( bool colorizeEnabled )
1190{
1191 // Enable or disable colorize controls based on checkbox
1192 btnColorizeColor->setEnabled( colorizeEnabled );
1193 sliderColorizeStrength->setEnabled( colorizeEnabled );
1194 spinColorizeStrength->setEnabled( colorizeEnabled );
1195}
1196
1197
1198QLinearGradient QgsRasterLayerProperties::redGradient()
1199{
1200 //define a gradient
1201 // TODO change this to actual polygon dims
1202 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1203 myGradient.setColorAt( 0.0, QColor( 242, 14, 25, 190 ) );
1204 myGradient.setColorAt( 0.5, QColor( 175, 29, 37, 190 ) );
1205 myGradient.setColorAt( 1.0, QColor( 114, 17, 22, 190 ) );
1206 return myGradient;
1207}
1208QLinearGradient QgsRasterLayerProperties::greenGradient()
1209{
1210 //define a gradient
1211 // TODO change this to actual polygon dims
1212 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1213 myGradient.setColorAt( 0.0, QColor( 48, 168, 5, 190 ) );
1214 myGradient.setColorAt( 0.8, QColor( 36, 122, 4, 190 ) );
1215 myGradient.setColorAt( 1.0, QColor( 21, 71, 2, 190 ) );
1216 return myGradient;
1217}
1218QLinearGradient QgsRasterLayerProperties::blueGradient()
1219{
1220 //define a gradient
1221 // TODO change this to actual polygon dims
1222 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1223 myGradient.setColorAt( 0.0, QColor( 30, 0, 106, 190 ) );
1224 myGradient.setColorAt( 0.2, QColor( 30, 72, 128, 190 ) );
1225 myGradient.setColorAt( 1.0, QColor( 30, 223, 196, 190 ) );
1226 return myGradient;
1227}
1228QLinearGradient QgsRasterLayerProperties::grayGradient()
1229{
1230 //define a gradient
1231 // TODO change this to actual polygon dims
1232 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1233 myGradient.setColorAt( 0.0, QColor( 5, 5, 5, 190 ) );
1234 myGradient.setColorAt( 0.8, QColor( 122, 122, 122, 190 ) );
1235 myGradient.setColorAt( 1.0, QColor( 220, 220, 220, 190 ) );
1236 return myGradient;
1237}
1238QLinearGradient QgsRasterLayerProperties::highlightGradient()
1239{
1240 //define another gradient for the highlight
1241 // TODO change this to actual polygon dims
1242 QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
1243 myGradient.setColorAt( 1.0, QColor( 255, 255, 255, 50 ) );
1244 myGradient.setColorAt( 0.5, QColor( 255, 255, 255, 100 ) );
1245 myGradient.setColorAt( 0.0, QColor( 255, 255, 255, 150 ) );
1246 return myGradient;
1247}
1248
1249//
1250//
1251// Next four methods for saving and restoring qml style state
1252//
1253//
1254
1259
1260void QgsRasterLayerProperties::restoreWindowModality()
1261{
1262 hide();
1263 setModal( true );
1264 show();
1265 raise();
1266 activateWindow();
1267}
1268
1269void QgsRasterLayerProperties::toggleBuildPyramidsButton()
1270{
1271 if ( lbxPyramidResolutions->selectedItems().empty() )
1272 {
1273 buttonBuildPyramids->setEnabled( false );
1274 }
1275 else
1276 {
1277 buttonBuildPyramids->setEnabled( true );
1278 }
1279}
1280
1281void QgsRasterLayerProperties::mResetColorRenderingBtn_clicked()
1282{
1283 mBlendModeComboBox->setBlendMode( QPainter::CompositionMode_SourceOver );
1284 mSliderBrightness->setValue( 0 );
1285 mSliderContrast->setValue( 0 );
1286 mGammaSpinBox->setValue( 1.0 );
1287 sliderSaturation->setValue( 0 );
1288 comboGrayscale->setCurrentIndex( ( int ) QgsHueSaturationFilter::GrayscaleOff );
1289 mColorizeCheck->setChecked( false );
1290 sliderColorizeStrength->setValue( 100 );
1291 mInvertColorsCheck->setChecked( false );
1292}
1293
1294bool QgsRasterLayerProperties::rasterIsMultiBandColor()
1295{
1296 return mRasterLayer && nullptr != dynamic_cast<QgsMultiBandColorRenderer *>( mRasterLayer->renderer() );
1297}
1298
1299void QgsRasterLayerProperties::updateInformationContent()
1300{
1302 // Inject the stylesheet
1303 const QString html { mRasterLayer->htmlMetadata().replace( "<head>"_L1, QStringLiteral( R"raw(<head><style type="text/css">%1</style>)raw" ) ).arg( myStyle ) };
1304 mMetadataViewer->setHtml( html );
1305 mMetadataFilled = true;
1306}
1307
1309{
1310 // Give the user a chance to save the raster attribute table edits.
1311 if ( mRasterAttributeTableWidget && mRasterAttributeTableWidget->isDirty() )
1312 {
1313 mRasterAttributeTableWidget->setEditable( false, false );
1314 }
1316
1317 if ( mBackupCrs != mRasterLayer->crs() )
1318 mRasterLayer->setCrs( mBackupCrs );
1319}
1320
1321void QgsRasterLayerProperties::showHelp()
1322{
1323 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property( "helpPage" );
1324
1325 if ( helpPage.isValid() )
1326 {
1327 QgsHelp::openHelp( helpPage.toString() );
1328 }
1329 else
1330 {
1331 QgsHelp::openHelp( u"working_with_raster/raster_properties.html"_s );
1332 }
1333}
1334
1335void QgsRasterLayerProperties::updateGammaSpinBox( int value )
1336{
1337 whileBlocking( mGammaSpinBox )->setValue( value / 100.0 );
1338}
1339
1340void QgsRasterLayerProperties::updateGammaSlider( double value )
1341{
1342 whileBlocking( mSliderGamma )->setValue( value * 100 );
1343}
1344
1345
1346bool QgsRasterLayerProperties::eventFilter( QObject *obj, QEvent *ev )
1347{
1348 // If the map tip preview container is resized, resize the map tip
1349 if ( obj == mMapTipPreviewContainer && ev->type() == QEvent::Resize )
1350 {
1351 resizeMapTip();
1352 }
1353 return QgsOptionsDialogBase::eventFilter( obj, ev );
1354}
1355
1356void QgsRasterLayerProperties::initMapTipPreview()
1357{
1358 // HTML editor and preview are in a splitter. By default, the editor takes 2/3 of the space
1359 mMapTipSplitter->setSizes( { 400, 200 } );
1360 // Event filter is used to resize the map tip when the container is resized
1361 mMapTipPreviewContainer->installEventFilter( this );
1362
1363 // Note: there's quite a bit of overlap between this and the code in QgsMapTip::showMapTip
1364 // Create the WebView
1365 mMapTipPreview = new QgsWebView( mMapTipPreviewContainer );
1366 mMapTipPreviewLayout->addWidget( mMapTipPreview );
1367
1368 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true );
1369 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled, true );
1370 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::LocalStorageEnabled, true );
1371
1372 // Disable scrollbars, avoid random resizing issues
1373 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
1374 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
1375
1376
1377 // Update the map tip preview when the expression or the map tip template changes
1378 connect( mMapTipWidget, &QgsCodeEditorHTML::textChanged, this, &QgsRasterLayerProperties::updateMapTipPreview );
1379}
1380
1381void QgsRasterLayerProperties::updateMapTipPreview()
1382{
1383 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1384 const QString htmlContent = QgsMapTip::rasterMapTipPreviewText( mRasterLayer, mCanvas, mMapTipWidget->text() );
1385 mMapTipPreview->setHtml( htmlContent );
1386}
1387
1388void QgsRasterLayerProperties::resizeMapTip()
1389{
1390 // Ensure the map tip is not bigger than the container
1391 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1392 mMapTipPreview->adjustSize();
1393}
@ BuildPyramids
Supports building of pyramids (overviews) (since QGIS 3.38 – this is a replacement for RasterInterfac...
Definition qgis.h:4991
@ SingleBandColorData
Single band containing color data.
Definition qgis.h:4863
RasterPyramidFormat
Raster pyramid formats.
Definition qgis.h:4898
@ GeoTiff
Geotiff .ovr (external).
Definition qgis.h:4899
@ Erdas
Erdas Image .aux (external).
Definition qgis.h:4901
@ SingleBandGray
A single band image drawn as a range of gray colors.
Definition qgis.h:4877
@ MultiBandColor
A layer containing 2 or more bands, mapped to RGB color space. In the case of a multiband with only t...
Definition qgis.h:4885
@ BuildPyramids
Supports building of pyramids (overviews) (Deprecated since QGIS 3.38 – use RasterProviderCapability:...
Definition qgis.h:4954
@ Size
Original data source size (and thus resolution) is known, it is not always available,...
Definition qgis.h:4951
@ ExcludeByDefault
If set, the layer should not be included in legends by default, and must be manually added by a user.
Definition qgis.h:4638
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
Definition qgis.h:394
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
Definition qgis.h:393
@ Preferred
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
Definition qgis.h:2497
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 embedded browsers (QtWebKit), supports full standard CSS.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
int contrast() const
Returns current contrast level.
int brightness() const
Returns current brightness level.
double gamma() const
Returns current gamma value.
Represents a coordinate reference system (CRS).
A dialog which collects the information required to create a new raster attribute table.
void setOpenWhenDoneVisible(bool visible)
Sets the visibility of the "Open newly created raster attribute table" option to visible,...
virtual QString name() const =0
Returns a provider name.
static bool run(const QgsCoordinateReferenceSystem &sourceCrs=QgsCoordinateReferenceSystem(), const QgsCoordinateReferenceSystem &destinationCrs=QgsCoordinateReferenceSystem(), QWidget *parent=nullptr, QgsMapCanvas *mapCanvas=nullptr, const QString &windowTitle=QString())
Runs the dialog (if required) prompting for the desired transform to use from sourceCrs to destinatio...
A generic dialog for building expression strings.
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...
static QString findAndSelectActiveExpression(QgsCodeEditor *editor, const QString &pattern=QString())
Find the expression under the cursor in the given editor and select it.
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
static QgsProviderSourceWidgetProviderRegistry * sourceWidgetProviderRegistry()
Returns the registry of provider source widget providers.
Definition qgsgui.cpp:134
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition qgshelp.cpp:41
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Factory method to create the renderer for this type.
Color and saturation filter pipe for rasters.
void setColorizeOn(bool colorizeOn)
void setSaturation(int saturation)
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)
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 setMetadataWidget(QgsMetadataWidget *widget, QWidget *page)
Sets the metadata widget and page associated with the dialog.
void loadDefaultStyle()
Reloads the default style for the layer.
void saveStyleAs()
Saves a style when appriate button is pressed.
virtual void syncToLayer()=0
Resets the dialog to the current layer state.
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.
QgsLayerPropertiesDialog(QgsMapLayer *layer, QgsMapCanvas *canvas, const QString &settingsKey, QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags(), QgsSettings *settings=nullptr)
Constructor for QgsLayerPropertiesDialog.
void loadMetadataFromFile()
Allows the user to load layer metadata from a file.
QPushButton * mBtnMetadata
Metadata button.
void initialize()
Initialize the dialog.
void saveMetadataAsDefault()
Saves the current layer metadata as the default for the layer.
A dialog allowing selection of a VAT.DBF file and associating the resulting raster attribute table wi...
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.
Factory class for creating custom map layer property pages.
virtual bool supportsLayer(QgsMapLayer *layer) const
Check if the layer is supported for this widget.
virtual QIcon icon() const
The icon that will be shown in the UI for the panel.
virtual QgsMapLayerConfigWidget * createWidget(QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget=true, QWidget *parent=nullptr) const =0
Factory function to create the widget on demand as needed by the dock.
virtual ParentPage parentPage() const
Returns the associated parent page, for factories which create sub-components of a standard page.
virtual QString title() const
The title of the panel.
virtual bool supportLayerPropertiesDialog() const
Flag if widget is supported for use in layer properties dialog.
@ Temporal
Factory creates sub-components of the temporal properties page (only supported for raster layer tempo...
@ NoParent
Factory creates pages itself, not sub-components.
virtual QString layerPropertiesPagePositionHint() const
Returns a tab name hinting at where this page should be inserted into the layer properties tab list.
A panel widget that can be shown in the map style dock.
An abstract interface for implementations of legends for one map layer.
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 &currentName)
Emitted when the current style has been changed.
Base class for all map layer types.
Definition qgsmaplayer.h:83
void rendererChanged()
Signal emitted when renderer is changed.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
double minimumScale() const
Returns the minimum map scale (i.e.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
double maximumScale() const
Returns the maximum map scale (i.e.
Contains configuration for rendering maps.
static QString rasterMapTipPreviewText(QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate)
Returns the html that would be displayed in a maptip for a given layer.
void deactivated()
Emitted when the map tool is deactivated.
A wizard to edit metadata on a map layer.
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
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 QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
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).
void crsChanged(const QgsCoordinateReferenceSystem &crs)
Emitted when the selected CRS is changed.
A button for controlling property overrides which may apply to a widget.
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
void changed()
Emitted when property definition changes.
void init(int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
Initialize a newly constructed property button (useful if button was included in a UI layout).
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
int propertyKey() const
Returns the property key linked to the button.
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
QgsProviderSourceWidget * createWidget(QgsMapLayer *layer, QWidget *parent=nullptr)
Creates a new widget to configure the source of the specified layer.
void validChanged(bool isValid)
Emitted whenever the validation status of the widget changes.
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Widget creation function (mainly for the use by the renderer registry).
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 dataType(int bandNo) const override=0
Returns data type for the band specified by number.
virtual Qgis::RasterProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
virtual QList< QgsRasterPyramid > buildPyramidList(const QList< int > &overviewList=QList< int >())
Returns the raster layers pyramid list.
A widget for display and configuring a raster layer histogram.
virtual Qgis::RasterInterfaceCapabilities capabilities() const
Returns the capabilities supported by the interface.
Master widget for configuration of labeling of a raster layer.
void addPropertiesPageFactory(const QgsMapLayerConfigWidgetFactory *factory) final
Adds properties page from a factory.
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
void optionsStackedWidget_CurrentChanged(int index) final
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
A widget for configuring the temporal properties for a raster layer.
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
Property
Data definable properties.
@ RendererOpacity
Raster renderer global opacity.
static QgsPropertiesDefinition propertyDefinitions()
Returns the definitions for data defined properties available for use in raster pipes.
This struct is used to store pyramid info for the raster layer.
void insertWidgetFunction(const QString &rendererName, QgsRasterRendererWidgetCreateFunc func)
Sets the widget creation function for a renderer.
QStringList renderersList() const
Returns a list of the names of registered renderers.
Abstract base class for widgets which configure a QgsRasterRenderer.
virtual void doComputations()
Load programmatically with current values.
virtual QgsRasterRenderer * renderer()=0
Creates a new renderer, using the properties defined in the widget.
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.
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Widget creation function (use by the renderer registry).
A widget for controlling a raster layer's transparency and related options.
Stores settings for use within QGIS.
Definition qgssettings.h:68
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.
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Creates new raster renderer widget.
A collection of stubs to mimic the API of QWebView on systems where the real library is not available...
Definition qgswebview.h:39
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:6828
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:63
Setting options for creating vector data providers.
Registry for raster renderer entries.
QgsRasterRendererWidgetCreateFunc widgetCreateFunction