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