QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 : [email protected]
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 
18 #include <limits>
19 #include <typeinfo>
20 
21 #include "qgsgui.h"
22 #include "qgsapplication.h"
24 #include "qgscontrastenhancement.h"
25 #include "qgscoordinatetransform.h"
27 #include "qgslogger.h"
28 #include "qgsmapcanvas.h"
30 #include "qgsmaptoolemitpoint.h"
31 #include "qgsmaptopixel.h"
32 #include "qgsmetadatawidget.h"
35 #include "qgsnative.h"
37 #include "qgsproject.h"
38 #include "qgsrasterbandstats.h"
40 #include "qgsrasterdataprovider.h"
43 #include "qgsrasterlayer.h"
45 #include "qgsrasterpyramid.h"
46 #include "qgsrasterrange.h"
47 #include "qgsrasterrenderer.h"
49 #include "qgsrastertransparency.h"
52 #include "qgshuesaturationfilter.h"
54 #include "qgssettings.h"
56 #include "qgsmaplayerlegend.h"
57 #include "qgsfileutils.h"
58 #include "qgswebview.h"
59 #include "qgsvectorlayer.h"
60 #include "qgsprovidermetadata.h"
61 #include "qgsproviderregistry.h"
63 #include "qgsdoublevalidator.h"
64 
66 #include "qgsprojecttimesettings.h"
67 
68 #include <QDesktopServices>
69 #include <QTableWidgetItem>
70 #include <QHeaderView>
71 #include <QTextStream>
72 #include <QFile>
73 #include <QFileDialog>
74 #include <QMessageBox>
75 #include <QPainter>
76 #include <QLinearGradient>
77 #include <QPainterPath>
78 #include <QPolygonF>
79 #include <QColorDialog>
80 #include <QList>
81 #include <QMouseEvent>
82 #include <QVector>
83 #include <QUrl>
84 #include <QMenu>
85 #include <QScreen>
86 
87 QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent, Qt::WindowFlags fl )
88  : QgsOptionsDialogBase( QStringLiteral( "RasterLayerProperties" ), parent, fl )
89  // Constant that signals property not used.
90  , TRSTRING_NOT_SET( tr( "Not Set" ) )
91  , mDefaultStandardDeviation( 0 )
92  , mDefaultRedBand( 0 )
93  , mDefaultGreenBand( 0 )
94  , mDefaultBlueBand( 0 )
95  , mRasterLayer( qobject_cast<QgsRasterLayer *>( lyr ) )
96  , mGradientHeight( 0.0 )
97  , mGradientWidth( 0.0 )
98  , mMapCanvas( canvas )
99  , mMetadataFilled( false )
100 {
101  mGrayMinimumMaximumEstimated = true;
102  mRGBMinimumMaximumEstimated = true;
103 
104  setupUi( this );
105  connect( mLayerOrigNameLineEd, &QLineEdit::textEdited, this, &QgsRasterLayerProperties::mLayerOrigNameLineEd_textEdited );
106  connect( buttonBuildPyramids, &QPushButton::clicked, this, &QgsRasterLayerProperties::buttonBuildPyramids_clicked );
107  connect( pbnAddValuesFromDisplay, &QToolButton::clicked, this, &QgsRasterLayerProperties::pbnAddValuesFromDisplay_clicked );
108  connect( pbnAddValuesManually, &QToolButton::clicked, this, &QgsRasterLayerProperties::pbnAddValuesManually_clicked );
109  connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsRasterLayerProperties::mCrsSelector_crsChanged );
110  connect( pbnDefaultValues, &QToolButton::clicked, this, &QgsRasterLayerProperties::pbnDefaultValues_clicked );
111  connect( pbnExportTransparentPixelValues, &QToolButton::clicked, this, &QgsRasterLayerProperties::pbnExportTransparentPixelValues_clicked );
112  connect( pbnImportTransparentPixelValues, &QToolButton::clicked, this, &QgsRasterLayerProperties::pbnImportTransparentPixelValues_clicked );
113  connect( pbnRemoveSelectedRow, &QToolButton::clicked, this, &QgsRasterLayerProperties::pbnRemoveSelectedRow_clicked );
114  connect( mRenderTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged );
115  connect( mResetColorRenderingBtn, &QToolButton::clicked, this, &QgsRasterLayerProperties::mResetColorRenderingBtn_clicked );
116  // QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
117  // switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left),
118  // and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots
119  initOptionsBase( false );
120  connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsRasterLayerProperties::showHelp );
121 
122  connect( mSetEndAsStartStaticButton, &QPushButton::clicked, this, &QgsRasterLayerProperties::setEndAsStartStaticButton_clicked );
123  connect( mProjectTemporalRange, &QRadioButton::toggled, this, &QgsRasterLayerProperties::passProjectTemporalRange_toggled );
124  connect( mStaticTemporalRange, &QRadioButton::toggled, this, &QgsRasterLayerProperties::staticTemporalRange_toggled );
125 
126  connect( mStaticTemporalRange, &QRadioButton::toggled, mStaticWmstFrame, &QWidget::setEnabled );
127  connect( mReferenceTime, &QCheckBox::toggled, mWmstReferenceTimeFrame, &QWidget::setEnabled );
128 
129  if ( mRasterLayer && mRasterLayer->temporalProperties() )
130  connect( mRasterLayer->temporalProperties(), &QgsRasterLayerTemporalProperties::changed, this, &QgsRasterLayerProperties::temporalPropertiesChange );
131 
132  mBtnStyle = new QPushButton( tr( "Style" ) );
133  QMenu *menuStyle = new QMenu( this );
134  menuStyle->addAction( tr( "Load Style…" ), this, &QgsRasterLayerProperties::loadStyle_clicked );
135  menuStyle->addAction( tr( "Save Style…" ), this, &QgsRasterLayerProperties::saveStyleAs_clicked );
136  menuStyle->addSeparator();
137  menuStyle->addAction( tr( "Save as Default" ), this, &QgsRasterLayerProperties::saveDefaultStyle_clicked );
138  menuStyle->addAction( tr( "Restore Default" ), this, &QgsRasterLayerProperties::loadDefaultStyle_clicked );
139  mBtnStyle->setMenu( menuStyle );
140  connect( menuStyle, &QMenu::aboutToShow, this, &QgsRasterLayerProperties::aboutToShowStyleMenu );
141  buttonBox->addButton( mBtnStyle, QDialogButtonBox::ResetRole );
142 
143  mBtnMetadata = new QPushButton( tr( "Metadata" ), this );
144  QMenu *menuMetadata = new QMenu( this );
145  mActionLoadMetadata = menuMetadata->addAction( tr( "Load Metadata…" ), this, &QgsRasterLayerProperties::loadMetadata );
146  mActionSaveMetadataAs = menuMetadata->addAction( tr( "Save Metadata…" ), this, &QgsRasterLayerProperties::saveMetadataAs );
147  menuMetadata->addSeparator();
148  menuMetadata->addAction( tr( "Save as Default" ), this, &QgsRasterLayerProperties::saveDefaultMetadata );
149  menuMetadata->addAction( tr( "Restore Default" ), this, &QgsRasterLayerProperties::loadDefaultMetadata );
150  mBtnMetadata->setMenu( menuMetadata );
151  buttonBox->addButton( mBtnMetadata, QDialogButtonBox::ResetRole );
152 
153  connect( lyr->styleManager(), &QgsMapLayerStyleManager::currentStyleChanged, this, &QgsRasterLayerProperties::syncToLayer );
154 
155  connect( this, &QDialog::accepted, this, &QgsRasterLayerProperties::apply );
156  connect( this, &QDialog::rejected, this, &QgsRasterLayerProperties::onCancel );
157 
158  connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsRasterLayerProperties::apply );
159 
160  // brightness/contrast controls
161  connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
162  connect( mBrightnessSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
163  mBrightnessSpinBox->setClearValue( 0 );
164 
165  connect( mSliderContrast, &QAbstractSlider::valueChanged, mContrastSpinBox, &QSpinBox::setValue );
166  connect( mContrastSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mSliderContrast, &QAbstractSlider::setValue );
167  mContrastSpinBox->setClearValue( 0 );
168 
169  // gamma correction controls
170  connect( mSliderGamma, &QAbstractSlider::valueChanged, this, &QgsRasterLayerProperties::updateGammaSpinBox );
171  connect( mGammaSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterLayerProperties::updateGammaSlider );
172  mGammaSpinBox->setClearValue( 1.0 );
173 
174  // Connect saturation slider and spin box
175  connect( sliderSaturation, &QAbstractSlider::valueChanged, spinBoxSaturation, &QSpinBox::setValue );
176  connect( spinBoxSaturation, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), sliderSaturation, &QAbstractSlider::setValue );
177  spinBoxSaturation->setClearValue( 0 );
178 
179  // Connect colorize strength slider and spin box
180  connect( sliderColorizeStrength, &QAbstractSlider::valueChanged, spinColorizeStrength, &QSpinBox::setValue );
181  connect( spinColorizeStrength, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), sliderColorizeStrength, &QAbstractSlider::setValue );
182  spinColorizeStrength->setClearValue( 100 );
183 
184  // enable or disable saturation slider and spin box depending on grayscale combo choice
185  connect( comboGrayscale, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerProperties::toggleSaturationControls );
186 
187  // enable or disable colorize colorbutton with colorize checkbox
188  connect( mColorizeCheck, &QAbstractButton::toggled, this, &QgsRasterLayerProperties::toggleColorizeControls );
189 
190  // enable or disable Build Pyramids button depending on selection in pyramid list
191  connect( lbxPyramidResolutions, &QListWidget::itemSelectionChanged, this, &QgsRasterLayerProperties::toggleBuildPyramidsButton );
192 
193  connect( mRefreshLayerCheckBox, &QCheckBox::toggled, mRefreshLayerIntervalSpinBox, &QDoubleSpinBox::setEnabled );
194 
195  // set up the scale based layer visibility stuff....
196  mScaleRangeWidget->setMapCanvas( mMapCanvas );
197  chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
198  mScaleRangeWidget->setScaleRange( lyr->minimumScale(), lyr->maximumScale() );
199 
200  leNoDataValue->setValidator( new QgsDoubleValidator( -std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), 1000, this ) );
201 
202  // build GUI components
203  QIcon myPyramidPixmap( QgsApplication::getThemeIcon( "/mIconPyramid.svg" ) );
204  QIcon myNoPyramidPixmap( QgsApplication::getThemeIcon( "/mIconNoPyramid.svg" ) );
205 
206  pbnAddValuesManually->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/symbologyAdd.svg" ) ) );
207  pbnAddValuesFromDisplay->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionContextHelp.png" ) ) );
208  pbnRemoveSelectedRow->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/symbologyRemove.svg" ) ) );
209  pbnDefaultValues->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOpenTable.svg" ) ) );
210  pbnImportTransparentPixelValues->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionFileOpen.svg" ) ) );
211  pbnExportTransparentPixelValues->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionFileSave.svg" ) ) );
212 
213  if ( mMapCanvas )
214  {
215  mPixelSelectorTool = qgis::make_unique<QgsMapToolEmitPoint>( canvas );
216  connect( mPixelSelectorTool.get(), &QgsMapToolEmitPoint::canvasClicked, this, &QgsRasterLayerProperties::pixelSelected );
217  connect( mPixelSelectorTool.get(), &QgsMapToolEmitPoint::deactivated, this, &QgsRasterLayerProperties::restoreWindowModality );
218  }
219  else
220  {
221  pbnAddValuesFromDisplay->setEnabled( false );
222  }
223 
224  if ( !mRasterLayer )
225  {
226  return;
227  }
228 
229  QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
230 
231  // Only do pyramids if dealing directly with GDAL.
232  if ( provider && provider->capabilities() & QgsRasterDataProvider::BuildPyramids )
233  {
234  // initialize resampling methods
235  cboResamplingMethod->clear();
236 
237  const auto constProviderType = QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() );
238  for ( QPair<QString, QString> method : constProviderType )
239  {
240  cboResamplingMethod->addItem( method.second, method.first );
241  }
242 
243  // keep it in sync with qgsrasterpyramidsoptionwidget.cpp
244  QString prefix = provider->name() + "/driverOptions/_pyramids/";
245  QgsSettings mySettings;
246  QString defaultMethod = mySettings.value( prefix + "resampling", "AVERAGE" ).toString();
247  int idx = cboResamplingMethod->findData( defaultMethod );
248  if ( idx >= 0 )
249  cboResamplingMethod->setCurrentIndex( idx );
250 
251 
252  // build pyramid list
253  QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
254  QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
255 
256  for ( myRasterPyramidIterator = myPyramidList.begin();
257  myRasterPyramidIterator != myPyramidList.end();
258  ++myRasterPyramidIterator )
259  {
260  if ( myRasterPyramidIterator->exists )
261  {
262  lbxPyramidResolutions->addItem( new QListWidgetItem( myPyramidPixmap,
263  QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( " x " ) +
264  QString::number( myRasterPyramidIterator->yDim ) ) );
265  }
266  else
267  {
268  lbxPyramidResolutions->addItem( new QListWidgetItem( myNoPyramidPixmap,
269  QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( " x " ) +
270  QString::number( myRasterPyramidIterator->yDim ) ) );
271  }
272  }
273  }
274  else
275  {
276  // disable Pyramids tab completely
277  mOptsPage_Pyramids->setEnabled( false );
278  }
279 
280  // We can calculate histogram for all data sources but estimated only if
281  // size is unknown - could also be enabled if well supported (estimated histogram
282  // and let user know that it is estimated)
283  if ( !provider || !( provider->capabilities() & QgsRasterDataProvider::Size ) )
284  {
285  // disable Histogram tab completely
286  mOptsPage_Histogram->setEnabled( false );
287  }
288 
289  QVBoxLayout *layout = new QVBoxLayout( metadataFrame );
290  layout->setContentsMargins( 0, 0, 0, 0 );
291  mMetadataWidget = new QgsMetadataWidget( this, mRasterLayer );
292  mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
293  mMetadataWidget->setMapCanvas( mMapCanvas );
294  layout->addWidget( mMetadataWidget );
295  metadataFrame->setLayout( layout );
296 
297  QVBoxLayout *temporalLayout = new QVBoxLayout( temporalFrame );
298  temporalLayout->setContentsMargins( 0, 0, 0, 0 );
299  mTemporalWidget = new QgsRasterLayerTemporalPropertiesWidget( this, mRasterLayer );
300  temporalLayout->addWidget( mTemporalWidget );
301 
302  setSourceStaticTimeState();
303  mWmstGroup->setVisible( mRasterLayer->providerType() == QLatin1String( "wms" ) && mRasterLayer->dataProvider() && mRasterLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() );
304 
305  // This group is used to define the temporal capabilities of the PG raster layer
306  if ( mRasterLayer->dataProvider() && mRasterLayer->providerType() == QLatin1String( "postgresraster" ) )
307  {
308  mPostgresRasterTemporalGroup->setEnabled( true );
309  mPostgresRasterTemporalGroup->setVisible( true );
310  mPostgresRasterTemporalGroup->setChecked( false );
311  const QgsFields fields { mRasterLayer->dataProvider()->fields() };
312  mPostgresRasterTemporalFieldComboBox->setFields( fields );
313  mPostgresRasterTemporalFieldComboBox->setFilters( QgsFieldProxyModel::Filter::Date |
314  QgsFieldProxyModel::Filter::DateTime |
315  QgsFieldProxyModel::Filter::String );
316  mPostgresRasterTemporalFieldComboBox->setAllowEmptyFieldName( true );
317  connect( mPostgresRasterTemporalFieldComboBox, &QgsFieldComboBox::fieldChanged, this, [ = ]( const QString & fieldName )
318  {
319  mPostgresRasterDefaultTime->setEnabled( ! fieldName.isEmpty() );
320  } );
321  mPostgresRasterDefaultTime->setAllowNull( true );
322  mPostgresRasterDefaultTime->setEmpty();
323  if ( mRasterLayer->dataProvider()->uri().hasParam( QStringLiteral( "temporalFieldIndex" ) ) )
324  {
325  bool ok;
326  const int fieldIdx { mRasterLayer->dataProvider()->uri().param( QStringLiteral( "temporalFieldIndex" ) ).toInt( &ok ) };
327  if ( ok && fields.exists( fieldIdx ) )
328  {
329  mPostgresRasterTemporalGroup->setChecked( true );
330  mPostgresRasterTemporalFieldComboBox->setField( fields.field( fieldIdx ).name() );
331  if ( mRasterLayer->dataProvider()->uri().hasParam( QStringLiteral( "temporalDefaultTime" ) ) )
332  {
333  const QDateTime defaultDateTime { QDateTime::fromString( mRasterLayer->dataProvider()->uri().param( QStringLiteral( "temporalDefaultTime" ) ), Qt::DateFormat::ISODate ) };
334  if ( defaultDateTime.isValid() )
335  {
336  mPostgresRasterDefaultTime->setDateTime( defaultDateTime );
337  }
338  }
339  }
340  }
341  }
342  else
343  {
344  mPostgresRasterTemporalGroup->setEnabled( false );
345  mPostgresRasterTemporalGroup->setVisible( false );
346  }
347 
348  QgsDebugMsg( "Setting crs to " + mRasterLayer->crs().toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) );
349  QgsDebugMsg( "Setting crs to " + mRasterLayer->crs().userFriendlyIdentifier() );
350  mCrsSelector->setCrs( mRasterLayer->crs() );
351 
352  // Set text for pyramid info box
353  QString pyramidFormat( QStringLiteral( "<h2>%1</h2><p>%2 %3 %4</p><b><font color='red'><p>%5</p><p>%6</p>" ) );
354  QString pyramidHeader = tr( "Description" );
355  QString pyramidSentence1 = tr( "Large resolution raster layers can slow navigation in QGIS." );
356  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." );
357  QString pyramidSentence3 = tr( "You must have write access in the directory where the original data is stored to build pyramids." );
358  QString pyramidSentence4 = tr( "Please note that building internal pyramids may alter the original data file and once created they cannot be removed!" );
359  QString pyramidSentence5 = tr( "Please note that building internal pyramids could corrupt your image - always make a backup of your data first!" );
360 
361  tePyramidDescription->setHtml( pyramidFormat.arg( pyramidHeader,
362  pyramidSentence1,
363  pyramidSentence2,
364  pyramidSentence3,
365  pyramidSentence4,
366  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( QStringLiteral( "symbology" ) );
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  }
395 
396  //blend mode
397  mBlendModeComboBox->setBlendMode( mRasterLayer->blendMode() );
398 
399  //transparency band
400  if ( provider )
401  {
402  cboxTransparencyBand->setShowNotSetOption( true, tr( "None" ) );
403  cboxTransparencyBand->setLayer( mRasterLayer );
404 
405 // Alpha band is set in sync()
406 #if 0
407  if ( renderer )
408  {
409  QgsDebugMsg( QStringLiteral( "alphaBand = %1" ).arg( renderer->alphaBand() ) );
410  if ( renderer->alphaBand() > 0 )
411  {
412  cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->alphaBand() ) );
413  }
414  }
415 #endif
416  }
417 
418  // create histogram widget
419  mHistogramWidget = nullptr;
420  if ( mOptsPage_Histogram->isEnabled() )
421  {
422  mHistogramWidget = new QgsRasterHistogramWidget( mRasterLayer, mOptsPage_Histogram );
423  mHistogramStackedWidget->addWidget( mHistogramWidget );
424  }
425 
426  //insert renderer widgets into registry
433 
434  //fill available renderers into combo box
436  mDisableRenderTypeComboBoxCurrentIndexChanged = true;
437  const auto constRenderersList = QgsApplication::rasterRendererRegistry()->renderersList();
438  for ( const QString &name : constRenderersList )
439  {
440  if ( QgsApplication::rasterRendererRegistry()->rendererData( name, entry ) )
441  {
442  if ( ( mRasterLayer->rasterType() != QgsRasterLayer::ColorLayer && entry.name != QLatin1String( "singlebandcolordata" ) ) ||
443  ( mRasterLayer->rasterType() == QgsRasterLayer::ColorLayer && entry.name == QLatin1String( "singlebandcolordata" ) ) )
444  {
445  mRenderTypeComboBox->addItem( entry.visibleName, entry.name );
446  }
447  }
448  }
449  mDisableRenderTypeComboBoxCurrentIndexChanged = false;
450 
451  int widgetIndex = 0;
452  if ( renderer )
453  {
454  QString rendererType = renderer->type();
455  widgetIndex = mRenderTypeComboBox->findData( rendererType );
456  if ( widgetIndex != -1 )
457  {
458  mDisableRenderTypeComboBoxCurrentIndexChanged = true;
459  mRenderTypeComboBox->setCurrentIndex( widgetIndex );
460  mDisableRenderTypeComboBoxCurrentIndexChanged = false;
461  }
462 
463  if ( rendererType == QLatin1String( "singlebandcolordata" ) && mRenderTypeComboBox->count() == 1 )
464  {
465  // no band rendering options for singlebandcolordata, so minimize group box
466  QSizePolicy sizep = mBandRenderingGrpBx->sizePolicy();
467  sizep.setVerticalStretch( 0 );
468  sizep.setVerticalPolicy( QSizePolicy::Maximum );
469  mBandRenderingGrpBx->setSizePolicy( sizep );
470  mBandRenderingGrpBx->updateGeometry();
471  }
472 
473  if ( mRasterLayer->providerType() != QLatin1String( "wms" ) )
474  {
475  mWMSPrintGroupBox->hide();
476  mPublishDataSourceUrlCheckBox->hide();
477  mBackgroundLayerCheckBox->hide();
478  }
479  }
480 
481 #ifdef WITH_QTWEBKIT
482  // Setup information tab
483 
484 #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
485  const int horizontalDpi = qApp->desktop()->screen()->logicalDpiX();
486 #else
487  const int horizontalDpi = logicalDpiX();
488 #endif
489 
490  // Adjust zoom: text is ok, but HTML seems rather big at least on Linux/KDE
491  if ( horizontalDpi > 96 )
492  {
493  mMetadataViewer->setZoomFactor( mMetadataViewer->zoomFactor() * 0.9 );
494  }
495  mMetadataViewer->page()->setLinkDelegationPolicy( QWebPage::LinkDelegationPolicy::DelegateAllLinks );
496  connect( mMetadataViewer->page(), &QWebPage::linkClicked, this, &QgsRasterLayerProperties::urlClicked );
497  mMetadataViewer->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true );
498  mMetadataViewer->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled, true );
499 
500 #endif
501 
502  mRenderTypeComboBox_currentIndexChanged( widgetIndex );
503 
504  // update based on lyr's current state
505  sync();
506 
507  QgsSettings settings;
508  // if dialog hasn't been opened/closed yet, default to Styles tab, which is used most often
509  // this will be read by restoreOptionsBaseUi()
510  if ( !settings.contains( QStringLiteral( "/Windows/RasterLayerProperties/tab" ) ) )
511  {
512  settings.setValue( QStringLiteral( "Windows/RasterLayerProperties/tab" ),
513  mOptStackedWidget->indexOf( mOptsPage_Style ) );
514  }
515 
516  mResetColorRenderingBtn->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionUndo.svg" ) ) );
517 
518  QString title = tr( "Layer Properties — %1" ).arg( lyr->name() );
519 
520  if ( !mRasterLayer->styleManager()->isDefault( mRasterLayer->styleManager()->currentStyle() ) )
521  title += QStringLiteral( " (%1)" ).arg( mRasterLayer->styleManager()->currentStyle() );
522  restoreOptionsBaseUi( title );
523  optionsStackedWidget_CurrentChanged( mOptionsStackedWidget->currentIndex() );
524 
525  //Add help page references
526  mOptsPage_Information->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#information-properties" ) );
527  mOptsPage_Source->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#source-properties" ) );
528  mOptsPage_Style->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#symbology-properties" ) );
529  mOptsPage_Transparency->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#transparency-properties" ) );
530 
531  if ( mOptsPage_Histogram )
532  mOptsPage_Histogram->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#histogram-properties" ) );
533 
534  mOptsPage_Rendering->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#rendering-properties" ) );
535 
536  if ( mOptsPage_Pyramids )
537  mOptsPage_Pyramids->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#pyramids-properties" ) );
538 
539  mOptsPage_Metadata->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#metadata-properties" ) );
540  mOptsPage_Legend->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#legend-properties" ) );
541  mOptsPage_Server->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#server-properties" ) );
542 }
543 
544 void QgsRasterLayerProperties::setupTransparencyTable( int nBands )
545 {
546  tableTransparency->clear();
547  tableTransparency->setColumnCount( 0 );
548  tableTransparency->setRowCount( 0 );
549  mTransparencyToEdited.clear();
550 
551  if ( nBands == 3 )
552  {
553  tableTransparency->setColumnCount( 4 );
554  tableTransparency->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "Red" ) ) );
555  tableTransparency->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr( "Green" ) ) );
556  tableTransparency->setHorizontalHeaderItem( 2, new QTableWidgetItem( tr( "Blue" ) ) );
557  tableTransparency->setHorizontalHeaderItem( 3, new QTableWidgetItem( tr( "Percent Transparent" ) ) );
558  }
559  else //1 band
560  {
561  tableTransparency->setColumnCount( 3 );
562 // Is it important to distinguish the header? It becomes difficult with range.
563 #if 0
564  if ( QgsRasterLayer::PalettedColor != mRasterLayer->drawingStyle() &&
565  QgsRasterLayer::PalettedSingleBandGray != mRasterLayer->drawingStyle() &&
566  QgsRasterLayer::PalettedSingleBandPseudoColor != mRasterLayer->drawingStyle() &&
567  QgsRasterLayer::PalettedMultiBandColor != mRasterLayer->drawingStyle() )
568  {
569  tableTransparency->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "Gray" ) ) );
570  }
571  else
572  {
573  tableTransparency->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "Indexed Value" ) ) );
574  }
575 #endif
576  tableTransparency->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "From" ) ) );
577  tableTransparency->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr( "To" ) ) );
578  tableTransparency->setHorizontalHeaderItem( 2, new QTableWidgetItem( tr( "Percent Transparent" ) ) );
579  }
580 
581  tableTransparency->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
582  tableTransparency->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::Stretch );
583 }
584 
585 void QgsRasterLayerProperties::populateTransparencyTable( QgsRasterRenderer *renderer )
586 {
587  if ( !mRasterLayer )
588  {
589  return;
590  }
591 
592  if ( !renderer )
593  {
594  return;
595  }
596 
597  int nBands = renderer->usesBands().size();
598  setupTransparencyTable( nBands );
599 
600  const QgsRasterTransparency *rasterTransparency = renderer->rasterTransparency();
601  if ( !rasterTransparency )
602  {
603  return;
604  }
605 
606  if ( nBands == 1 )
607  {
608  QList<QgsRasterTransparency::TransparentSingleValuePixel> pixelList = rasterTransparency->transparentSingleValuePixelList();
609  for ( int i = 0; i < pixelList.size(); ++i )
610  {
611  tableTransparency->insertRow( i );
612  setTransparencyCell( i, 0, pixelList[i].min );
613  setTransparencyCell( i, 1, pixelList[i].max );
614  setTransparencyCell( i, 2, pixelList[i].percentTransparent );
615  // break synchronization only if values differ
616  if ( pixelList[i].min != pixelList[i].max )
617  {
618  setTransparencyToEdited( i );
619  }
620  }
621  }
622  else if ( nBands == 3 )
623  {
624  QList<QgsRasterTransparency::TransparentThreeValuePixel> pixelList = rasterTransparency->transparentThreeValuePixelList();
625  for ( int i = 0; i < pixelList.size(); ++i )
626  {
627  tableTransparency->insertRow( i );
628  setTransparencyCell( i, 0, pixelList[i].red );
629  setTransparencyCell( i, 1, pixelList[i].green );
630  setTransparencyCell( i, 2, pixelList[i].blue );
631  setTransparencyCell( i, 3, pixelList[i].percentTransparent );
632  }
633  }
634 
635  tableTransparency->resizeColumnsToContents();
636  tableTransparency->resizeRowsToContents();
637 }
638 
639 void QgsRasterLayerProperties::setRendererWidget( const QString &rendererName )
640 {
641  QgsDebugMsg( "rendererName = " + rendererName );
642  QgsRasterRendererWidget *oldWidget = mRendererWidget;
643  QgsRasterRenderer *oldRenderer = mRasterLayer->renderer();
644 
645  int alphaBand = -1;
646  double opacity = 1;
647  QColor nodataColor;
648  if ( oldRenderer )
649  {
650  // Retain alpha band and opacity when switching renderer
651  alphaBand = oldRenderer->alphaBand();
652  opacity = oldRenderer->opacity();
653  nodataColor = oldRenderer->nodataColor();
654  }
655 
656  QgsRasterRendererRegistryEntry rendererEntry;
657  if ( QgsApplication::rasterRendererRegistry()->rendererData( rendererName, rendererEntry ) )
658  {
659  if ( rendererEntry.widgetCreateFunction ) //single band color data renderer e.g. has no widget
660  {
661  QgsDebugMsg( QStringLiteral( "renderer has widgetCreateFunction" ) );
662  // Current canvas extent (used to calc min/max) in layer CRS
663  QgsRectangle myExtent = mMapCanvas->mapSettings().outputExtentToLayerExtent( mRasterLayer, mMapCanvas->extent() );
664  if ( oldWidget && ( !oldRenderer || rendererName != oldRenderer->type() ) )
665  {
666  if ( rendererName == QLatin1String( "singlebandgray" ) )
667  {
668  whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::SingleBandGray, mRasterLayer->dataProvider() ) );
669  whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
670  }
671  else if ( rendererName == QLatin1String( "multibandcolor" ) )
672  {
673  whileBlocking( mRasterLayer )->setRenderer( QgsApplication::rasterRendererRegistry()->defaultRendererForDrawingStyle( QgsRaster::MultiBandColor, mRasterLayer->dataProvider() ) );
674  whileBlocking( mRasterLayer )->setDefaultContrastEnhancement();
675  }
676  }
677  mRasterLayer->renderer()->setAlphaBand( alphaBand );
678  mRasterLayer->renderer()->setOpacity( opacity );
679  mRasterLayer->renderer()->setNodataColor( nodataColor );
680  mRendererWidget = rendererEntry.widgetCreateFunction( mRasterLayer, myExtent );
681  mRendererWidget->setMapCanvas( mMapCanvas );
682  mRendererStackedWidget->addWidget( mRendererWidget );
683  if ( oldWidget )
684  {
685  //compare used bands in new and old renderer and reset transparency dialog if different
686  QgsRasterRenderer *oldRenderer = oldWidget->renderer();
687  QgsRasterRenderer *newRenderer = mRendererWidget->renderer();
688  QList<int> oldBands = oldRenderer->usesBands();
689  QList<int> newBands = newRenderer->usesBands();
690  if ( oldBands != newBands )
691  {
692  populateTransparencyTable( newRenderer );
693  }
694  delete oldRenderer;
695  delete newRenderer;
696  }
697  }
698  }
699 
700  const int widgetIndex = mRenderTypeComboBox->findData( rendererName );
701  if ( widgetIndex != -1 )
702  {
703  mDisableRenderTypeComboBoxCurrentIndexChanged = true;
704  mRenderTypeComboBox->setCurrentIndex( widgetIndex );
705  mDisableRenderTypeComboBoxCurrentIndexChanged = false;
706  }
707 
708  if ( mRendererWidget != oldWidget )
709  delete oldWidget;
710 
711  if ( mHistogramWidget )
712  {
713  mHistogramWidget->setRendererWidget( rendererName, mRendererWidget );
714  }
715 }
716 
726 void QgsRasterLayerProperties::sync()
727 {
728  QgsSettings myQSettings;
729 
730  const QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
731  if ( !provider )
732  return;
733 
734  if ( provider->dataType( 1 ) == Qgis::ARGB32
735  || provider->dataType( 1 ) == Qgis::ARGB32_Premultiplied )
736  {
737  gboxNoDataValue->setEnabled( false );
738  gboxCustomTransparency->setEnabled( false );
739  mOptionsStackedWidget->setCurrentWidget( mOptsPage_Server );
740  }
741 
742  // TODO: Wouldn't it be better to just removeWidget() the tabs than delete them? [LS]
743  if ( !( provider->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
744  {
745  if ( mOptsPage_Pyramids )
746  {
747  delete mOptsPage_Pyramids;
748  mOptsPage_Pyramids = nullptr;
749  }
750  }
751 
752  if ( !( provider->capabilities() & QgsRasterDataProvider::Size ) )
753  {
754  if ( mOptsPage_Histogram )
755  {
756  delete mOptsPage_Histogram;
757  mOptsPage_Histogram = nullptr;
758  delete mHistogramWidget;
759  mHistogramWidget = nullptr;
760  }
761  }
762 
763  QgsDebugMsg( QStringLiteral( "populate transparency tab" ) );
764 
765  /*
766  * Style tab
767  */
768 
769  //set brightness, contrast and gamma
770  QgsBrightnessContrastFilter *brightnessFilter = mRasterLayer->brightnessFilter();
771  if ( brightnessFilter )
772  {
773  mSliderBrightness->setValue( brightnessFilter->brightness() );
774  mSliderContrast->setValue( brightnessFilter->contrast() );
775  mGammaSpinBox->setValue( brightnessFilter->gamma() );
776  }
777 
778  // Hue and saturation color control
779  const QgsHueSaturationFilter *hueSaturationFilter = mRasterLayer->hueSaturationFilter();
780  //set hue and saturation controls to current values
781  if ( hueSaturationFilter )
782  {
783  sliderSaturation->setValue( hueSaturationFilter->saturation() );
784  comboGrayscale->setCurrentIndex( ( int ) hueSaturationFilter->grayscaleMode() );
785 
786  // Set state of saturation controls based on grayscale mode choice
787  toggleSaturationControls( static_cast<int>( hueSaturationFilter->grayscaleMode() ) );
788 
789  // Set state of colorize controls
790  mColorizeCheck->setChecked( hueSaturationFilter->colorizeOn() );
791  btnColorizeColor->setColor( hueSaturationFilter->colorizeColor() );
792  toggleColorizeControls( hueSaturationFilter->colorizeOn() );
793  sliderColorizeStrength->setValue( hueSaturationFilter->colorizeStrength() );
794  }
795 
796  /*
797  * Transparent Pixel Tab
798  */
799 
800  //set the transparency slider
801  QgsRasterRenderer *renderer = mRasterLayer->renderer();
802  if ( renderer )
803  {
804  mOpacityWidget->setOpacity( renderer->opacity() );
805  cboxTransparencyBand->setBand( renderer->alphaBand() );
806  }
807 
808  //add current NoDataValue to NoDataValue line edit
809  // TODO: should be per band
810  // TODO: no data ranges
811  if ( provider->sourceHasNoDataValue( 1 ) )
812  {
813  double v = QgsRasterBlock::printValue( provider->sourceNoDataValue( 1 ) ).toDouble();
814  lblSrcNoDataValue->setText( QLocale().toString( v, 'g' ) );
815  }
816  else
817  {
818  lblSrcNoDataValue->setText( tr( "not defined" ) );
819  }
820 
821  mSrcNoDataValueCheckBox->setChecked( provider->useSourceNoDataValue( 1 ) );
822 
823  bool enableSrcNoData = provider->sourceHasNoDataValue( 1 ) && !std::isnan( provider->sourceNoDataValue( 1 ) );
824 
825  mSrcNoDataValueCheckBox->setEnabled( enableSrcNoData );
826  lblSrcNoDataValue->setEnabled( enableSrcNoData );
827 
828  QgsRasterRangeList noDataRangeList = provider->userNoDataValues( 1 );
829  QgsDebugMsg( QStringLiteral( "noDataRangeList.size = %1" ).arg( noDataRangeList.size() ) );
830  if ( !noDataRangeList.isEmpty() )
831  {
832  leNoDataValue->insert( QgsRasterBlock::printValue( noDataRangeList.value( 0 ).min() ) );
833  }
834  else
835  {
836  leNoDataValue->insert( QString() );
837  }
838 
839  mRefreshLayerCheckBox->setChecked( mRasterLayer->hasAutoRefreshEnabled() );
840  mRefreshLayerIntervalSpinBox->setEnabled( mRasterLayer->hasAutoRefreshEnabled() );
841  mRefreshLayerIntervalSpinBox->setValue( mRasterLayer->autoRefreshInterval() / 1000.0 );
842 
843  populateTransparencyTable( mRasterLayer->renderer() );
844 
845  QgsDebugMsg( QStringLiteral( "populate colormap tab" ) );
846  /*
847  * Transparent Pixel Tab
848  */
849 
850  QgsDebugMsg( QStringLiteral( "populate general tab" ) );
851  /*
852  * General Tab
853  */
854 
855  //these properties (layer name and label) are provided by the qgsmaplayer superclass
856  mLayerOrigNameLineEd->setText( mRasterLayer->name() );
857  leDisplayName->setText( mRasterLayer->name() );
858 
859  //get the thumbnail for the layer
860  QPixmap thumbnail = QPixmap::fromImage( mRasterLayer->previewAsImage( pixmapThumbnail->size() ) );
861  pixmapThumbnail->setPixmap( thumbnail );
862 
863  // TODO fix legend + palette pixmap
864 
865  //update the legend pixmap on this dialog
866 #if 0
867  pixmapLegend->setPixmap( mRasterLayer->legendAsPixmap() );
868  pixmapLegend->setScaledContents( true );
869  pixmapLegend->repaint();
870 
871  //set the palette pixmap
872  pixmapPalette->setPixmap( mRasterLayer->paletteAsPixmap( mRasterLayer->bandNumber( mRasterLayer->grayBandName() ) ) );
873  pixmapPalette->setScaledContents( true );
874  pixmapPalette->repaint();
875 #endif
876 
877  QgsDebugMsgLevel( QStringLiteral( "populate metadata tab" ), 2 );
878  /*
879  * Metadata Tab
880  */
881  //populate the metadata tab's text browser widget with gdal metadata info
882  updateInformationContent();
883 
884  // WMS Name as layer short name
885  mLayerShortNameLineEdit->setText( mRasterLayer->shortName() );
886  // WMS Name validator
887  QValidator *shortNameValidator = new QRegExpValidator( QgsApplication::shortNameRegExp(), this );
888  mLayerShortNameLineEdit->setValidator( shortNameValidator );
889 
890  //layer title and abstract
891  mLayerTitleLineEdit->setText( mRasterLayer->title() );
892  mLayerAbstractTextEdit->setPlainText( mRasterLayer->abstract() );
893  mLayerKeywordListLineEdit->setText( mRasterLayer->keywordList() );
894  mLayerDataUrlLineEdit->setText( mRasterLayer->dataUrl() );
895  mLayerDataUrlFormatComboBox->setCurrentIndex(
896  mLayerDataUrlFormatComboBox->findText(
897  mRasterLayer->dataUrlFormat()
898  )
899  );
900 
901  //layer attribution and metadataUrl
902  mLayerAttributionLineEdit->setText( mRasterLayer->attribution() );
903  mLayerAttributionUrlLineEdit->setText( mRasterLayer->attributionUrl() );
904  mLayerMetadataUrlLineEdit->setText( mRasterLayer->metadataUrl() );
905  mLayerMetadataUrlTypeComboBox->setCurrentIndex(
906  mLayerMetadataUrlTypeComboBox->findText(
907  mRasterLayer->metadataUrlType()
908  )
909  );
910  mLayerMetadataUrlFormatComboBox->setCurrentIndex(
911  mLayerMetadataUrlFormatComboBox->findText(
912  mRasterLayer->metadataUrlFormat()
913  )
914  );
915 
916  mLayerLegendUrlLineEdit->setText( mRasterLayer->legendUrl() );
917  mLayerLegendUrlFormatComboBox->setCurrentIndex( mLayerLegendUrlFormatComboBox->findText( mRasterLayer->legendUrlFormat() ) );
918 
919  //WMS print layer
920  QVariant wmsPrintLayer = mRasterLayer->customProperty( QStringLiteral( "WMSPrintLayer" ) );
921  if ( wmsPrintLayer.isValid() )
922  {
923  mWMSPrintLayerLineEdit->setText( wmsPrintLayer.toString() );
924  }
925 
926  QVariant wmsPublishDataSourceUrl = mRasterLayer->customProperty( QStringLiteral( "WMSPublishDataSourceUrl" ), false );
927  mPublishDataSourceUrlCheckBox->setChecked( wmsPublishDataSourceUrl.toBool() );
928 
929  QVariant wmsBackgroundLayer = mRasterLayer->customProperty( QStringLiteral( "WMSBackgroundLayer" ), false );
930  mBackgroundLayerCheckBox->setChecked( wmsBackgroundLayer.toBool() );
931 
932  mLegendConfigEmbeddedWidget->setLayer( mRasterLayer );
933 
934  mTemporalWidget->syncToLayer();
935 }
936 
937 void QgsRasterLayerProperties::apply()
938 {
939 
940  // Do nothing on "bad" layers
941  if ( !mRasterLayer->isValid() )
942  return;
943 
944  /*
945  * Legend Tab
946  */
947  mLegendConfigEmbeddedWidget->applyToLayer();
948 
949  QgsDebugMsg( QStringLiteral( "apply processing symbology tab" ) );
950  /*
951  * Symbology Tab
952  */
953 
954  //set whether the layer histogram should be inverted
955  //mRasterLayer->setInvertHistogram( cboxInvertColorMap->isChecked() );
956 
957  mRasterLayer->brightnessFilter()->setBrightness( mSliderBrightness->value() );
958  mRasterLayer->brightnessFilter()->setContrast( mSliderContrast->value() );
959  mRasterLayer->brightnessFilter()->setGamma( mGammaSpinBox->value() );
960 
961  QgsDebugMsg( QStringLiteral( "processing transparency tab" ) );
962  /*
963  * Transparent Pixel Tab
964  */
965 
966  //set NoDataValue
967  QgsRasterRangeList myNoDataRangeList;
968  if ( "" != leNoDataValue->text() )
969  {
970  bool myDoubleOk = false;
971  double myNoDataValue = QgsDoubleValidator::toDouble( leNoDataValue->text(), &myDoubleOk );
972  if ( myDoubleOk )
973  {
974  QgsRasterRange myNoDataRange( myNoDataValue, myNoDataValue );
975  myNoDataRangeList << myNoDataRange;
976  }
977  }
978  for ( int bandNo = 1; bandNo <= mRasterLayer->dataProvider()->bandCount(); bandNo++ )
979  {
980  mRasterLayer->dataProvider()->setUserNoDataValue( bandNo, myNoDataRangeList );
981  mRasterLayer->dataProvider()->setUseSourceNoDataValue( bandNo, mSrcNoDataValueCheckBox->isChecked() );
982  }
983 
984  //set renderer from widget
985  QgsRasterRendererWidget *rendererWidget = dynamic_cast<QgsRasterRendererWidget *>( mRendererStackedWidget->currentWidget() );
986  if ( rendererWidget )
987  {
988  rendererWidget->doComputations();
989 
990  mRasterLayer->setRenderer( rendererWidget->renderer() );
991  }
992 
993  mMetadataWidget->acceptMetadata();
994  mMetadataFilled = false;
995 
996  //transparency settings
997  QgsRasterRenderer *rasterRenderer = mRasterLayer->renderer();
998  if ( rasterRenderer )
999  {
1000  rasterRenderer->setAlphaBand( cboxTransparencyBand->currentBand() );
1001 
1002  //Walk through each row in table and test value. If not valid set to 0.0 and continue building transparency list
1003  QgsRasterTransparency *rasterTransparency = new QgsRasterTransparency();
1004  if ( tableTransparency->columnCount() == 4 )
1005  {
1007  QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
1008  for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
1009  {
1010  myTransparentPixel.red = transparencyCellValue( myListRunner, 0 );
1011  myTransparentPixel.green = transparencyCellValue( myListRunner, 1 );
1012  myTransparentPixel.blue = transparencyCellValue( myListRunner, 2 );
1013  myTransparentPixel.percentTransparent = transparencyCellValue( myListRunner, 3 );
1014  myTransparentThreeValuePixelList.append( myTransparentPixel );
1015  }
1016  rasterTransparency->setTransparentThreeValuePixelList( myTransparentThreeValuePixelList );
1017  }
1018  else if ( tableTransparency->columnCount() == 3 )
1019  {
1021  QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
1022  for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
1023  {
1024  myTransparentPixel.min = transparencyCellValue( myListRunner, 0 );
1025  myTransparentPixel.max = transparencyCellValue( myListRunner, 1 );
1026  myTransparentPixel.percentTransparent = transparencyCellValue( myListRunner, 2 );
1027 
1028  myTransparentSingleValuePixelList.append( myTransparentPixel );
1029  }
1030  rasterTransparency->setTransparentSingleValuePixelList( myTransparentSingleValuePixelList );
1031  }
1032 
1033  rasterRenderer->setRasterTransparency( rasterTransparency );
1034 
1035  //set global transparency
1036  rasterRenderer->setOpacity( mOpacityWidget->opacity() );
1037  }
1038 
1039  QgsDebugMsg( QStringLiteral( "processing general tab" ) );
1040  /*
1041  * General Tab
1042  */
1043  mRasterLayer->setName( mLayerOrigNameLineEd->text() );
1044 
1045  // set up the scale based layer visibility stuff....
1046  mRasterLayer->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
1047  mRasterLayer->setMinimumScale( mScaleRangeWidget->minimumScale() );
1048  mRasterLayer->setMaximumScale( mScaleRangeWidget->maximumScale() );
1049 
1050  mRasterLayer->setAutoRefreshInterval( mRefreshLayerIntervalSpinBox->value() * 1000.0 );
1051  mRasterLayer->setAutoRefreshEnabled( mRefreshLayerCheckBox->isChecked() );
1052 
1053  //update the legend pixmap
1054  // pixmapLegend->setPixmap( mRasterLayer->legendAsPixmap() );
1055  // pixmapLegend->setScaledContents( true );
1056  // pixmapLegend->repaint();
1057 
1058  mResamplingUtils.refreshLayerFromWidgets();
1059 
1060  // Hue and saturation controls
1061  QgsHueSaturationFilter *hueSaturationFilter = mRasterLayer->hueSaturationFilter();
1062  if ( hueSaturationFilter )
1063  {
1064  hueSaturationFilter->setSaturation( sliderSaturation->value() );
1065  hueSaturationFilter->setGrayscaleMode( ( QgsHueSaturationFilter::GrayscaleMode ) comboGrayscale->currentIndex() );
1066  hueSaturationFilter->setColorizeOn( mColorizeCheck->checkState() );
1067  hueSaturationFilter->setColorizeColor( btnColorizeColor->color() );
1068  hueSaturationFilter->setColorizeStrength( sliderColorizeStrength->value() );
1069  }
1070 
1071  //set the blend mode for the layer
1072  mRasterLayer->setBlendMode( mBlendModeComboBox->blendMode() );
1073 
1074  updateSourceStaticTime();
1075 
1076  // Update temporal field
1077  if ( mRasterLayer->dataProvider() )
1078  {
1079  QgsDataSourceUri uri { mRasterLayer->dataProvider()->uri() };
1080  if ( mPostgresRasterTemporalGroup->isEnabled() &&
1081  mPostgresRasterTemporalGroup->isChecked() &&
1082  ! mPostgresRasterTemporalFieldComboBox->currentField().isEmpty() )
1083  {
1084  const QString originaUri { uri.uri() };
1085  const int fieldIdx { mRasterLayer->dataProvider()->fields().lookupField( mPostgresRasterTemporalFieldComboBox->currentField() ) };
1086  uri.removeParam( QStringLiteral( "temporalFieldIndex" ) );
1087  uri.removeParam( QStringLiteral( "temporalDefaultTime" ) );
1088  if ( fieldIdx >= 0 )
1089  {
1090  uri.setParam( QStringLiteral( "temporalFieldIndex" ), QString::number( fieldIdx ) );
1091  if ( mPostgresRasterDefaultTime->dateTime().isValid() )
1092  {
1093  QDateTime defaultDateTime { mPostgresRasterDefaultTime->dateTime() };
1094  const QTime defaultTime { defaultDateTime.time() };
1095  // Set secs to 0
1096  defaultDateTime.setTime( { defaultTime.hour(), defaultTime.minute(), 0 } );
1097  uri.setParam( QStringLiteral( "temporalDefaultTime" ), defaultDateTime.toString( Qt::DateFormat::ISODate ) );
1098  }
1099  if ( uri.uri( ) != originaUri )
1100  mRasterLayer->setDataSource( uri.uri(), mRasterLayer->name(), mRasterLayer->providerType(), QgsDataProvider::ProviderOptions() );
1101  }
1102  }
1103  else if ( uri.hasParam( QStringLiteral( "temporalFieldIndex" ) ) )
1104  {
1105  uri.removeParam( QStringLiteral( "temporalFieldIndex" ) );
1106  uri.removeParam( QStringLiteral( "temporalDefaultTime" ) );
1107  mRasterLayer->setDataSource( uri.uri(), mRasterLayer->name(), mRasterLayer->providerType(), QgsDataProvider::ProviderOptions() );
1108  }
1109  }
1110 
1111  // Update temporal properties
1112  mTemporalWidget->saveTemporalProperties();
1113 
1114  mRasterLayer->setCrs( mCrsSelector->crs() );
1115 
1116  //get the thumbnail for the layer
1117  QPixmap thumbnail = QPixmap::fromImage( mRasterLayer->previewAsImage( pixmapThumbnail->size() ) );
1118  pixmapThumbnail->setPixmap( thumbnail );
1119 
1120  if ( mRasterLayer->shortName() != mLayerShortNameLineEdit->text() )
1121  mMetadataFilled = false;
1122  mRasterLayer->setShortName( mLayerShortNameLineEdit->text() );
1123 
1124  if ( mRasterLayer->title() != mLayerTitleLineEdit->text() )
1125  mMetadataFilled = false;
1126  mRasterLayer->setTitle( mLayerTitleLineEdit->text() );
1127 
1128  if ( mRasterLayer->abstract() != mLayerAbstractTextEdit->toPlainText() )
1129  mMetadataFilled = false;
1130  mRasterLayer->setAbstract( mLayerAbstractTextEdit->toPlainText() );
1131 
1132  if ( mRasterLayer->keywordList() != mLayerKeywordListLineEdit->text() )
1133  mMetadataFilled = false;
1134  mRasterLayer->setKeywordList( mLayerKeywordListLineEdit->text() );
1135 
1136  if ( mRasterLayer->dataUrl() != mLayerDataUrlLineEdit->text() )
1137  mMetadataFilled = false;
1138  mRasterLayer->setDataUrl( mLayerDataUrlLineEdit->text() );
1139 
1140  if ( mRasterLayer->dataUrlFormat() != mLayerDataUrlFormatComboBox->currentText() )
1141  mMetadataFilled = false;
1142  mRasterLayer->setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
1143 
1144  //layer attribution and metadataUrl
1145  if ( mRasterLayer->attribution() != mLayerAttributionLineEdit->text() )
1146  mMetadataFilled = false;
1147  mRasterLayer->setAttribution( mLayerAttributionLineEdit->text() );
1148 
1149  if ( mRasterLayer->attributionUrl() != mLayerAttributionUrlLineEdit->text() )
1150  mMetadataFilled = false;
1151  mRasterLayer->setAttributionUrl( mLayerAttributionUrlLineEdit->text() );
1152 
1153  if ( mRasterLayer->metadataUrl() != mLayerMetadataUrlLineEdit->text() )
1154  mMetadataFilled = false;
1155  mRasterLayer->setMetadataUrl( mLayerMetadataUrlLineEdit->text() );
1156 
1157  if ( mRasterLayer->metadataUrlType() != mLayerMetadataUrlTypeComboBox->currentText() )
1158  mMetadataFilled = false;
1159  mRasterLayer->setMetadataUrlType( mLayerMetadataUrlTypeComboBox->currentText() );
1160 
1161  if ( mRasterLayer->metadataUrlFormat() != mLayerMetadataUrlFormatComboBox->currentText() )
1162  mMetadataFilled = false;
1163  mRasterLayer->setMetadataUrlFormat( mLayerMetadataUrlFormatComboBox->currentText() );
1164 
1165  if ( mRasterLayer->legendUrl() != mLayerLegendUrlLineEdit->text() )
1166  mMetadataFilled = false;
1167  mRasterLayer->setLegendUrl( mLayerLegendUrlLineEdit->text() );
1168 
1169  if ( mRasterLayer->legendUrlFormat() != mLayerLegendUrlFormatComboBox->currentText() )
1170  mMetadataFilled = false;
1171  mRasterLayer->setLegendUrlFormat( mLayerLegendUrlFormatComboBox->currentText() );
1172 
1173  if ( !mWMSPrintLayerLineEdit->text().isEmpty() )
1174  {
1175  mRasterLayer->setCustomProperty( QStringLiteral( "WMSPrintLayer" ), mWMSPrintLayerLineEdit->text() );
1176  }
1177 
1178  mRasterLayer->setCustomProperty( "WMSPublishDataSourceUrl", mPublishDataSourceUrlCheckBox->isChecked() );
1179  mRasterLayer->setCustomProperty( "WMSBackgroundLayer", mBackgroundLayerCheckBox->isChecked() );
1180 
1181  // Force a redraw of the legend
1182  mRasterLayer->setLegend( QgsMapLayerLegend::defaultRasterLegend( mRasterLayer ) );
1183 
1184  //make sure the layer is redrawn
1185  mRasterLayer->triggerRepaint();
1186 
1187  // notify the project we've made a change
1188  QgsProject::instance()->setDirty( true );
1189 }//apply
1190 
1191 void QgsRasterLayerProperties::updateSourceStaticTime()
1192 {
1194  mRasterLayer->providerType() );
1195  const QVariantMap currentUri = metadata->decodeUri( mRasterLayer->dataProvider()->dataSourceUri() );
1196 
1197  QVariantMap uri = currentUri;
1198 
1199  if ( mWmstGroup->isVisibleTo( this ) )
1200  uri[ QStringLiteral( "allowTemporalUpdates" ) ] = mWmstGroup->isChecked();
1201 
1202 
1203  if ( mWmstGroup->isEnabled() &&
1204  mRasterLayer->dataProvider() &&
1206  {
1207  bool enableTime = !mDisableTime->isChecked();
1208 
1209  uri[ QStringLiteral( "enableTime" ) ] = enableTime;
1210  qobject_cast< QgsRasterLayerTemporalProperties * >( mRasterLayer->temporalProperties() )->setIntervalHandlingMethod( static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >(
1211  mFetchModeComboBox->currentData().toInt() ) );
1212 
1213  // Don't do static temporal updates if temporal properties are active
1214  if ( !mRasterLayer->temporalProperties()->isActive() )
1215  {
1216  if ( mStaticTemporalRange->isChecked() )
1217  {
1218  QString time = mStartStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs ) + '/' +
1219  mEndStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
1220  uri[ QStringLiteral( "time" ) ] = time;
1221  uri[ QStringLiteral( "temporalSource" ) ] = QLatin1String( "provider" );
1222  }
1223 
1224  if ( mProjectTemporalRange->isChecked() )
1225  {
1226  QgsDateTimeRange range;
1227 
1228  if ( QgsProject::instance()->timeSettings() )
1230  if ( range.begin().isValid() && range.end().isValid() )
1231  {
1232  QString time = range.begin().toString( Qt::ISODateWithMs ) + '/' +
1233  range.end().toString( Qt::ISODateWithMs );
1234 
1235  uri[ QStringLiteral( "time" ) ] = time;
1236  uri[ QStringLiteral( "temporalSource" ) ] = QLatin1String( "project" );
1237  }
1238  }
1239  }
1240 
1241  if ( mReferenceTime->isChecked() )
1242  {
1243  QString referenceTime = mReferenceDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
1244  uri[ QStringLiteral( "referenceTime" ) ] = referenceTime;
1245  }
1246  else
1247  {
1248  if ( uri.contains( QStringLiteral( "referenceTime" ) ) )
1249  uri.remove( QStringLiteral( "referenceTime" ) );
1250  }
1251  }
1252 
1253  if ( currentUri != uri )
1254  mRasterLayer->setDataSource( metadata->encodeUri( uri ), mRasterLayer->name(), mRasterLayer->providerType(), QgsDataProvider::ProviderOptions() );
1255 }
1256 
1257 void QgsRasterLayerProperties::setSourceStaticTimeState()
1258 {
1259  if ( mRasterLayer->dataProvider() && mRasterLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
1260  {
1261  const QgsDateTimeRange availableProviderRange = mRasterLayer->dataProvider()->temporalCapabilities()->availableTemporalRange();
1262  const QgsDateTimeRange availableReferenceRange = mRasterLayer->dataProvider()->temporalCapabilities()->availableReferenceTemporalRange();
1263 
1265  mRasterLayer->providerType() );
1266 
1267  QVariantMap uri = metadata->decodeUri( mRasterLayer->dataProvider()->dataSourceUri() );
1268 
1269  mStartStaticDateTimeEdit->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
1270  mEndStaticDateTimeEdit->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
1271  mReferenceDateTimeEdit->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
1272 
1273  // setup maximum extents for widgets, based on provider's capabilities
1274  if ( availableProviderRange.begin().isValid() && availableProviderRange.end().isValid() )
1275  {
1276  mStartStaticDateTimeEdit->setDateTimeRange( availableProviderRange.begin(),
1277  availableProviderRange.end() );
1278  mStartStaticDateTimeEdit->setDateTime( availableProviderRange.begin() );
1279  mEndStaticDateTimeEdit->setDateTimeRange( availableProviderRange.begin(),
1280  availableProviderRange.end() );
1281  mEndStaticDateTimeEdit->setDateTime( availableProviderRange.end() );
1282  }
1283  if ( availableReferenceRange.begin().isValid() && availableReferenceRange.end().isValid() )
1284  {
1285  mReferenceDateTimeEdit->setDateTimeRange( availableReferenceRange.begin(),
1286  availableReferenceRange.end() );
1287  mReferenceDateTimeEdit->setDateTime( availableReferenceRange.begin() );
1288  }
1289 
1290  const QString time = uri.value( QStringLiteral( "time" ) ).toString();
1291  if ( !time.isEmpty() )
1292  {
1293  QStringList parts = time.split( '/' );
1294  mStartStaticDateTimeEdit->setDateTime( QDateTime::fromString( parts.at( 0 ), Qt::ISODateWithMs ) );
1295  mEndStaticDateTimeEdit->setDateTime( QDateTime::fromString( parts.at( 1 ), Qt::ISODateWithMs ) );
1296  }
1297 
1298  const QString referenceTimeExtent = uri.value( QStringLiteral( "referenceTimeDimensionExtent" ) ).toString();
1299 
1300  mReferenceTime->setEnabled( !referenceTimeExtent.isEmpty() );
1301  mReferenceDateTimeEdit->setVisible( !referenceTimeExtent.isEmpty() );
1302 
1303  QString referenceTimeLabelText = referenceTimeExtent.isEmpty() ?
1304  tr( "There is no reference time in the layer's capabilities." ) : QString();
1305  mReferenceTimeLabel->setText( referenceTimeLabelText );
1306 
1307  const QString referenceTime = uri.value( QStringLiteral( "referenceTime" ) ).toString();
1308 
1309  mReferenceTime->setChecked( !referenceTime.isEmpty() );
1310 
1311  if ( !referenceTime.isEmpty() && !referenceTimeExtent.isEmpty() )
1312  {
1313  mReferenceDateTimeEdit->setDateTime( QDateTime::fromString( referenceTime, Qt::ISODateWithMs ) );
1314  }
1315 
1316  mFetchModeComboBox->addItem( tr( "Use Whole Temporal Range" ), QgsRasterDataProviderTemporalCapabilities::MatchUsingWholeRange );
1317  mFetchModeComboBox->addItem( tr( "Match to Start of Range" ), QgsRasterDataProviderTemporalCapabilities::MatchExactUsingStartOfRange );
1318  mFetchModeComboBox->addItem( tr( "Match to End of Range" ), QgsRasterDataProviderTemporalCapabilities::MatchExactUsingEndOfRange );
1319  mFetchModeComboBox->addItem( tr( "Closest Match to Start of Range" ), QgsRasterDataProviderTemporalCapabilities::FindClosestMatchToStartOfRange );
1320  mFetchModeComboBox->addItem( tr( "Closest Match to End of Range" ), QgsRasterDataProviderTemporalCapabilities::FindClosestMatchToEndOfRange );
1321  mFetchModeComboBox->setCurrentIndex( mFetchModeComboBox->findData( qobject_cast< QgsRasterLayerTemporalProperties * >( mRasterLayer->temporalProperties() )->intervalHandlingMethod() ) );
1322 
1323  const QString temporalSource = uri.value( QStringLiteral( "temporalSource" ) ).toString();
1324  bool enableTime = uri.value( QStringLiteral( "enableTime" ), true ).toBool();
1325 
1326  if ( temporalSource == QLatin1String( "provider" ) )
1327  mStaticTemporalRange->setChecked( !time.isEmpty() );
1328  else if ( temporalSource == QLatin1String( "project" ) )
1329  mProjectTemporalRange->setChecked( !time.isEmpty() );
1330 
1331  mDisableTime->setChecked( !enableTime );
1332 
1333  mWmstOptions->setEnabled( !mRasterLayer->temporalProperties()->isActive() );
1334 
1335  if ( mRasterLayer->temporalProperties()->isActive() )
1336  mWmstOptionsLabel->setText( tr( "The static temporal options below are disabled because the layer "
1337  "temporal properties are active, to enable them disable temporal properties "
1338  "in the temporal tab. " ) );
1339  QgsDateTimeRange range;
1340  if ( QgsProject::instance()->timeSettings() )
1342 
1343  if ( !range.begin().isValid() || !range.end().isValid() )
1344  {
1345  mProjectTemporalRange->setEnabled( false );
1346  mProjectTemporalRangeLabel->setText( tr( "The option below is disabled because the project temporal range "
1347  "is not valid, update the project temporal range in the project properties "
1348  "with valid values in order to use it here." ) );
1349  }
1350 
1351  mWmstGroup->setChecked( uri.contains( QStringLiteral( "allowTemporalUpdates" ) ) &&
1352  uri.value( QStringLiteral( "allowTemporalUpdates" ), true ).toBool() );
1353  }
1354 }
1355 
1356 void QgsRasterLayerProperties::staticTemporalRange_toggled( bool checked )
1357 {
1358  if ( checked )
1359  {
1360  mLabel->clear();
1361  }
1362 }
1363 
1364 void QgsRasterLayerProperties::passProjectTemporalRange_toggled( bool checked )
1365 {
1366  if ( checked )
1367  {
1368  QgsDateTimeRange range;
1369  if ( QgsProject::instance()->timeSettings() )
1371 
1372  if ( range.begin().isValid() && range.end().isValid() )
1373  mLabel->setText( tr( "Project temporal range is set from %1 to %2" ).arg(
1374  range.begin().toString( "yyyy-MM-dd HH:mm:ss" ),
1375  range.end().toString( "yyyy-MM-dd HH:mm:ss" )
1376  ) );
1377  else
1378  mLabel->setText( tr( "Project temporal range is not valid, can't use it here" ) );
1379  }
1380 }
1381 
1382 void QgsRasterLayerProperties::temporalPropertiesChange()
1383 {
1384  mWmstOptions->setEnabled( !mRasterLayer->temporalProperties()->isActive() );
1385 
1386  if ( mRasterLayer->temporalProperties()->isActive() )
1387  mWmstOptionsLabel->setText( tr( "The static temporal options below are disabled because the layer "
1388  "temporal properties are active, to enable them disable temporal properties "
1389  "in the temporal tab. " ) );
1390  else
1391  mWmstOptionsLabel->clear();
1392 }
1393 
1394 void QgsRasterLayerProperties::mLayerOrigNameLineEd_textEdited( const QString &text )
1395 {
1396  leDisplayName->setText( mRasterLayer->formatLayerName( text ) );
1397 }
1398 
1399 void QgsRasterLayerProperties::buttonBuildPyramids_clicked()
1400 {
1401  QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
1402 
1403  std::unique_ptr< QgsRasterBlockFeedback > feedback( new QgsRasterBlockFeedback() );
1404 
1405  connect( feedback.get(), &QgsRasterBlockFeedback::progressChanged, mPyramidProgress, &QProgressBar::setValue );
1406  //
1407  // Go through the list marking any files that are selected in the listview
1408  // as true so that we can generate pyramids for them.
1409  //
1410  QList< QgsRasterPyramid> myPyramidList = provider->buildPyramidList();
1411  for ( int myCounterInt = 0; myCounterInt < lbxPyramidResolutions->count(); myCounterInt++ )
1412  {
1413  QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt );
1414  //mark to be pyramided
1415  myPyramidList[myCounterInt].build = myItem->isSelected() || myPyramidList[myCounterInt].exists;
1416  }
1417 
1418  // keep it in sync with qgsrasterpyramidsoptionwidget.cpp
1419  QString prefix = provider->name() + "/driverOptions/_pyramids/";
1420  QgsSettings mySettings;
1421  QString resamplingMethod( cboResamplingMethod->currentData().toString() );
1422  mySettings.setValue( prefix + "resampling", resamplingMethod );
1423 
1424  //
1425  // Ask raster layer to build the pyramids
1426  //
1427 
1428  // let the user know we're going to possibly be taking a while
1429  QApplication::setOverrideCursor( Qt::WaitCursor );
1430  QString res = provider->buildPyramids(
1431  myPyramidList,
1432  resamplingMethod,
1433  ( QgsRaster::RasterPyramidsFormat ) cbxPyramidsFormat->currentIndex(),
1434  QStringList(),
1435  feedback.get() );
1436  QApplication::restoreOverrideCursor();
1437  mPyramidProgress->setValue( 0 );
1438  buttonBuildPyramids->setEnabled( false );
1439  if ( !res.isNull() )
1440  {
1441  if ( res == QLatin1String( "CANCELED" ) )
1442  {
1443  // user canceled
1444  }
1445  else if ( res == QLatin1String( "ERROR_WRITE_ACCESS" ) )
1446  {
1447  QMessageBox::warning( this, tr( "Building Pyramids" ),
1448  tr( "Write access denied. Adjust the file permissions and try again." ) );
1449  }
1450  else if ( res == QLatin1String( "ERROR_WRITE_FORMAT" ) )
1451  {
1452  QMessageBox::warning( this, tr( "Building Pyramids" ),
1453  tr( "The file was not writable. Some formats do not "
1454  "support pyramid overviews. Consult the GDAL documentation if in doubt." ) );
1455  }
1456  else if ( res == QLatin1String( "FAILED_NOT_SUPPORTED" ) )
1457  {
1458  QMessageBox::warning( this, tr( "Building Pyramids" ),
1459  tr( "Building pyramid overviews is not supported on this type of raster." ) );
1460  }
1461  else if ( res == QLatin1String( "ERROR_JPEG_COMPRESSION" ) )
1462  {
1463  QMessageBox::warning( this, tr( "Building Pyramids" ),
1464  tr( "Building internal pyramid overviews is not supported on raster layers with JPEG compression and your current libtiff library." ) );
1465  }
1466  else if ( res == QLatin1String( "ERROR_VIRTUAL" ) )
1467  {
1468  QMessageBox::warning( this, tr( "Building Pyramids" ),
1469  tr( "Building pyramid overviews is not supported on this type of raster." ) );
1470  }
1471 
1472  }
1473 
1474  //
1475  // repopulate the pyramids list
1476  //
1477  lbxPyramidResolutions->clear();
1478  // Need to rebuild list as some or all pyramids may have failed to build
1479  myPyramidList = provider->buildPyramidList();
1480  QIcon myPyramidPixmap( QgsApplication::getThemeIcon( "/mIconPyramid.svg" ) );
1481  QIcon myNoPyramidPixmap( QgsApplication::getThemeIcon( "/mIconNoPyramid.svg" ) );
1482 
1483  QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
1484  for ( myRasterPyramidIterator = myPyramidList.begin();
1485  myRasterPyramidIterator != myPyramidList.end();
1486  ++myRasterPyramidIterator )
1487  {
1488  if ( myRasterPyramidIterator->exists )
1489  {
1490  lbxPyramidResolutions->addItem( new QListWidgetItem( myPyramidPixmap,
1491  QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( " x " ) +
1492  QString::number( myRasterPyramidIterator->yDim ) ) );
1493  }
1494  else
1495  {
1496  lbxPyramidResolutions->addItem( new QListWidgetItem( myNoPyramidPixmap,
1497  QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( " x " ) +
1498  QString::number( myRasterPyramidIterator->yDim ) ) );
1499  }
1500  }
1501  //update the legend pixmap
1502  // pixmapLegend->setPixmap( mRasterLayer->legendAsPixmap() );
1503  // pixmapLegend->setScaledContents( true );
1504  // pixmapLegend->repaint();
1505 
1506  //populate the metadata tab's text browser widget with gdal metadata info
1507  updateInformationContent();
1508 }
1509 
1510 void QgsRasterLayerProperties::urlClicked( const QUrl &url )
1511 {
1512  QFileInfo file( url.toLocalFile() );
1513  if ( file.exists() && !file.isDir() )
1514  QgsGui::instance()->nativePlatformInterface()->openFileExplorerAndSelectFile( url.toLocalFile() );
1515  else
1516  QDesktopServices::openUrl( url );
1517 }
1518 
1519 void QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged( int index )
1520 {
1521  if ( index < 0 || mDisableRenderTypeComboBoxCurrentIndexChanged || ! mRasterLayer->renderer() )
1522  {
1523  return;
1524  }
1525 
1526  QString rendererName = mRenderTypeComboBox->itemData( index ).toString();
1527  setRendererWidget( rendererName );
1528 }
1529 
1530 void QgsRasterLayerProperties::pbnAddValuesFromDisplay_clicked()
1531 {
1532  if ( mMapCanvas && mPixelSelectorTool )
1533  {
1534  //Need to work around the modality of the dialog but can not just hide() it.
1535  // According to Qt5 docs, to change modality the dialog needs to be hidden
1536  // and shown again.
1537  hide();
1538  setModal( false );
1539 
1540  // Transfer focus to the canvas to use the selector tool
1541  mMapCanvas->window()->raise();
1542  mMapCanvas->window()->activateWindow();
1543  mMapCanvas->window()->setFocus();
1544  mMapCanvas->setMapTool( mPixelSelectorTool.get() );
1545 
1546  }
1547 }
1548 
1549 void QgsRasterLayerProperties::pbnAddValuesManually_clicked()
1550 {
1551  QgsRasterRenderer *renderer = mRendererWidget->renderer();
1552  if ( !renderer )
1553  {
1554  return;
1555  }
1556 
1557  tableTransparency->insertRow( tableTransparency->rowCount() );
1558 
1559  int n = renderer->usesBands().size();
1560  if ( n == 1 ) n++;
1561 
1562  for ( int i = 0; i < n; i++ )
1563  {
1564  setTransparencyCell( tableTransparency->rowCount() - 1, i, std::numeric_limits<double>::quiet_NaN() );
1565  }
1566 
1567  setTransparencyCell( tableTransparency->rowCount() - 1, n, 100 );
1568 
1569  tableTransparency->resizeColumnsToContents();
1570  tableTransparency->resizeRowsToContents();
1571 }
1572 
1573 void QgsRasterLayerProperties::mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs )
1574 {
1575  QgsDatumTransformDialog::run( crs, QgsProject::instance()->crs(), this, mMapCanvas, tr( "Select Transformation" ) );
1576  mRasterLayer->setCrs( crs );
1577  mMetadataWidget->crsChanged();
1578 }
1579 
1580 void QgsRasterLayerProperties::pbnDefaultValues_clicked()
1581 {
1582  if ( !mRendererWidget )
1583  {
1584  return;
1585  }
1586 
1587  QgsRasterRenderer *r = mRendererWidget->renderer();
1588  if ( !r )
1589  {
1590  return;
1591  }
1592 
1593  int nBands = r->usesBands().size();
1594  delete r; // really delete?
1595 
1596  setupTransparencyTable( nBands );
1597 
1598  tableTransparency->resizeColumnsToContents(); // works only with values
1599  tableTransparency->resizeRowsToContents();
1600 }
1601 
1602 void QgsRasterLayerProperties::setTransparencyCell( int row, int column, double value )
1603 {
1604  QgsDebugMsg( QStringLiteral( "value = %1" ).arg( value, 0, 'g', 17 ) );
1605  QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
1606  if ( !provider ) return;
1607 
1608  QgsRasterRenderer *renderer = mRendererWidget->renderer();
1609  if ( !renderer ) return;
1610  int nBands = renderer->usesBands().size();
1611 
1612  QLineEdit *lineEdit = new QLineEdit();
1613  lineEdit->setFrame( false ); // frame looks bad in table
1614  // Without margins row selection is not displayed (important for delete row)
1615  lineEdit->setContentsMargins( 1, 1, 1, 1 );
1616 
1617  if ( column == tableTransparency->columnCount() - 1 )
1618  {
1619  // transparency
1620  // Who needs transparency as floating point?
1621  lineEdit->setValidator( new QIntValidator( nullptr ) );
1622  lineEdit->setText( QString::number( static_cast<int>( value ) ) );
1623  }
1624  else
1625  {
1626  // value
1627  QString valueString;
1628  switch ( provider->sourceDataType( 1 ) )
1629  {
1630  case Qgis::Float32:
1631  case Qgis::Float64:
1632  lineEdit->setValidator( new QgsDoubleValidator( nullptr ) );
1633  if ( !std::isnan( value ) )
1634  {
1635  double v = QgsRasterBlock::printValue( value ).toDouble();
1636  valueString = QLocale().toString( v, 'g' ) ;
1637  }
1638  break;
1639  default:
1640  lineEdit->setValidator( new QIntValidator( nullptr ) );
1641  if ( !std::isnan( value ) )
1642  {
1643  valueString = QLocale().toString( static_cast<int>( value ) );
1644  }
1645  break;
1646  }
1647  lineEdit->setText( valueString );
1648  }
1649  tableTransparency->setCellWidget( row, column, lineEdit );
1650  adjustTransparencyCellWidth( row, column );
1651 
1652  if ( nBands == 1 && ( column == 0 || column == 1 ) )
1653  {
1654  connect( lineEdit, &QLineEdit::textEdited, this, &QgsRasterLayerProperties::transparencyCellTextEdited );
1655  }
1656  tableTransparency->resizeColumnsToContents();
1657 }
1658 
1659 void QgsRasterLayerProperties::setTransparencyCellValue( int row, int column, double value )
1660 {
1661  QLineEdit *lineEdit = dynamic_cast<QLineEdit *>( tableTransparency->cellWidget( row, column ) );
1662  if ( !lineEdit ) return;
1663  double v = QgsRasterBlock::printValue( value ).toDouble();
1664  lineEdit->setText( QLocale().toString( v, 'g' ) );
1665  lineEdit->adjustSize();
1666  adjustTransparencyCellWidth( row, column );
1667  tableTransparency->resizeColumnsToContents();
1668 }
1669 
1670 double QgsRasterLayerProperties::transparencyCellValue( int row, int column )
1671 {
1672  QLineEdit *lineEdit = dynamic_cast<QLineEdit *>( tableTransparency->cellWidget( row, column ) );
1673  if ( !lineEdit || lineEdit->text().isEmpty() )
1674  {
1675  return std::numeric_limits<double>::quiet_NaN();
1676  }
1677  return lineEdit->text().toDouble();
1678 }
1679 
1680 void QgsRasterLayerProperties::adjustTransparencyCellWidth( int row, int column )
1681 {
1682  QLineEdit *lineEdit = dynamic_cast<QLineEdit *>( tableTransparency->cellWidget( row, column ) );
1683  if ( !lineEdit ) return;
1684 
1685  int width = std::max( lineEdit->fontMetrics().boundingRect( lineEdit->text() ).width() + 10, 100 );
1686  width = std::max( width, tableTransparency->columnWidth( column ) );
1687 
1688  lineEdit->setFixedWidth( width );
1689 }
1690 
1691 void QgsRasterLayerProperties::pbnExportTransparentPixelValues_clicked()
1692 {
1693  QgsSettings myQSettings;
1694  QString myLastDir = myQSettings.value( QStringLiteral( "lastRasterFileFilterDir" ), QDir::homePath() ).toString();
1695  QString myFileName = QFileDialog::getSaveFileName( this, tr( "Save File" ), myLastDir, tr( "Textfile" ) + " (*.txt)" );
1696  if ( !myFileName.isEmpty() )
1697  {
1698  if ( !myFileName.endsWith( QLatin1String( ".txt" ), Qt::CaseInsensitive ) )
1699  {
1700  myFileName = myFileName + ".txt";
1701  }
1702 
1703  QFile myOutputFile( myFileName );
1704  if ( myOutputFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
1705  {
1706  QTextStream myOutputStream( &myOutputFile );
1707  myOutputStream << "# " << tr( "QGIS Generated Transparent Pixel Value Export File" ) << '\n';
1708  if ( rasterIsMultiBandColor() )
1709  {
1710  myOutputStream << "#\n#\n# " << tr( "Red" ) << "\t" << tr( "Green" ) << "\t" << tr( "Blue" ) << "\t" << tr( "Percent Transparent" );
1711  for ( int myTableRunner = 0; myTableRunner < tableTransparency->rowCount(); myTableRunner++ )
1712  {
1713  myOutputStream << '\n' << QString::number( transparencyCellValue( myTableRunner, 0 ) ) << "\t"
1714  << QString::number( transparencyCellValue( myTableRunner, 1 ) ) << "\t"
1715  << QString::number( transparencyCellValue( myTableRunner, 2 ) ) << "\t"
1716  << QString::number( transparencyCellValue( myTableRunner, 3 ) );
1717  }
1718  }
1719  else
1720  {
1721  myOutputStream << "#\n#\n# " << tr( "Value" ) << "\t" << tr( "Percent Transparent" );
1722 
1723  for ( int myTableRunner = 0; myTableRunner < tableTransparency->rowCount(); myTableRunner++ )
1724  {
1725  myOutputStream << '\n' << QString::number( transparencyCellValue( myTableRunner, 0 ) ) << "\t"
1726  << QString::number( transparencyCellValue( myTableRunner, 1 ) ) << "\t"
1727  << QString::number( transparencyCellValue( myTableRunner, 2 ) );
1728  }
1729  }
1730  }
1731  else
1732  {
1733  QMessageBox::warning( this, tr( "Export Transparent Pixels" ), tr( "Write access denied. Adjust the file permissions and try again.\n\n" ) );
1734  }
1735  }
1736 }
1737 
1738 void QgsRasterLayerProperties::transparencyCellTextEdited( const QString &text )
1739 {
1740  Q_UNUSED( text )
1741  QgsDebugMsg( QStringLiteral( "text = %1" ).arg( text ) );
1742  QgsRasterRenderer *renderer = mRendererWidget->renderer();
1743  if ( !renderer )
1744  {
1745  return;
1746  }
1747  int nBands = renderer->usesBands().size();
1748  if ( nBands == 1 )
1749  {
1750  QLineEdit *lineEdit = qobject_cast<QLineEdit *>( sender() );
1751  if ( !lineEdit ) return;
1752  int row = -1;
1753  int column = -1;
1754  for ( int r = 0; r < tableTransparency->rowCount(); r++ )
1755  {
1756  for ( int c = 0; c < tableTransparency->columnCount(); c++ )
1757  {
1758  if ( tableTransparency->cellWidget( r, c ) == sender() )
1759  {
1760  row = r;
1761  column = c;
1762  break;
1763  }
1764  }
1765  if ( row != -1 ) break;
1766  }
1767  QgsDebugMsg( QStringLiteral( "row = %1 column =%2" ).arg( row ).arg( column ) );
1768 
1769  if ( column == 0 )
1770  {
1771  QLineEdit *toLineEdit = dynamic_cast<QLineEdit *>( tableTransparency->cellWidget( row, 1 ) );
1772  if ( !toLineEdit ) return;
1773  bool toChanged = mTransparencyToEdited.value( row );
1774  QgsDebugMsg( QStringLiteral( "toChanged = %1" ).arg( toChanged ) );
1775  if ( !toChanged )
1776  {
1777  toLineEdit->setText( lineEdit->text() );
1778  }
1779  }
1780  else if ( column == 1 )
1781  {
1782  setTransparencyToEdited( row );
1783  }
1784  }
1785 }
1786 
1787 void QgsRasterLayerProperties::aboutToShowStyleMenu()
1788 {
1789  // this should be unified with QgsVectorLayerProperties::aboutToShowStyleMenu()
1790 
1791  QMenu *m = qobject_cast<QMenu *>( sender() );
1792 
1794  // re-add style manager actions!
1795  m->addSeparator();
1797 }
1798 
1799 void QgsRasterLayerProperties::syncToLayer()
1800 {
1801  QgsRasterRenderer *renderer = mRasterLayer->renderer();
1802  if ( renderer )
1803  {
1804  setRendererWidget( renderer->type() );
1805  }
1806  sync();
1807  mRasterLayer->triggerRepaint();
1808 }
1809 
1810 void QgsRasterLayerProperties::setTransparencyToEdited( int row )
1811 {
1812  if ( row >= mTransparencyToEdited.size() )
1813  {
1814  mTransparencyToEdited.resize( row + 1 );
1815  }
1816  mTransparencyToEdited[row] = true;
1817 }
1818 
1820 {
1822 
1823  bool isMetadataPanel = ( index == mOptStackedWidget->indexOf( mOptsPage_Metadata ) );
1824  mBtnStyle->setVisible( ! isMetadataPanel );
1825  mBtnMetadata->setVisible( isMetadataPanel );
1826 
1827  if ( !mHistogramWidget )
1828  return;
1829 
1830  if ( index == mOptStackedWidget->indexOf( mOptsPage_Histogram ) )
1831  {
1832  mHistogramWidget->setActive( true );
1833  }
1834  else
1835  {
1836  mHistogramWidget->setActive( false );
1837  }
1838 
1839  if ( index == mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
1840  {
1841  //set the metadata contents (which can be expensive)
1842  updateInformationContent();
1843  }
1844 }
1845 
1846 void QgsRasterLayerProperties::setEndAsStartStaticButton_clicked()
1847 {
1848  mEndStaticDateTimeEdit->setDateTime( mStartStaticDateTimeEdit->dateTime() );
1849 }
1850 
1851 void QgsRasterLayerProperties::pbnImportTransparentPixelValues_clicked()
1852 {
1853  int myLineCounter = 0;
1854  bool myImportError = false;
1855  QString myBadLines;
1856  QgsSettings myQSettings;
1857  QString myLastDir = myQSettings.value( QStringLiteral( "lastRasterFileFilterDir" ), QDir::homePath() ).toString();
1858  QString myFileName = QFileDialog::getOpenFileName( this, tr( "Open file" ), myLastDir, tr( "Textfile" ) + " (*.txt)" );
1859  QFile myInputFile( myFileName );
1860  if ( myInputFile.open( QFile::ReadOnly ) )
1861  {
1862  QTextStream myInputStream( &myInputFile );
1863  QString myInputLine;
1864  if ( rasterIsMultiBandColor() )
1865  {
1866  for ( int myTableRunner = tableTransparency->rowCount() - 1; myTableRunner >= 0; myTableRunner-- )
1867  {
1868  tableTransparency->removeRow( myTableRunner );
1869  }
1870 
1871  while ( !myInputStream.atEnd() )
1872  {
1873  myLineCounter++;
1874  myInputLine = myInputStream.readLine();
1875  if ( !myInputLine.isEmpty() )
1876  {
1877  if ( !myInputLine.simplified().startsWith( '#' ) )
1878  {
1879  QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
1880  if ( myTokens.count() != 4 )
1881  {
1882  myImportError = true;
1883  myBadLines = myBadLines + QString::number( myLineCounter ) + ":\t[" + myInputLine + "]\n";
1884  }
1885  else
1886  {
1887  tableTransparency->insertRow( tableTransparency->rowCount() );
1888  for ( int col = 0; col < 4; col++ )
1889  {
1890  setTransparencyCell( tableTransparency->rowCount() - 1, col, myTokens[col].toDouble() );
1891  }
1892  }
1893  }
1894  }
1895  }
1896  }
1897  else
1898  {
1899  for ( int myTableRunner = tableTransparency->rowCount() - 1; myTableRunner >= 0; myTableRunner-- )
1900  {
1901  tableTransparency->removeRow( myTableRunner );
1902  }
1903 
1904  while ( !myInputStream.atEnd() )
1905  {
1906  myLineCounter++;
1907  myInputLine = myInputStream.readLine();
1908  if ( !myInputLine.isEmpty() )
1909  {
1910  if ( !myInputLine.simplified().startsWith( '#' ) )
1911  {
1912  QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
1913  if ( myTokens.count() != 3 && myTokens.count() != 2 ) // 2 for QGIS < 1.9 compatibility
1914  {
1915  myImportError = true;
1916  myBadLines = myBadLines + QString::number( myLineCounter ) + ":\t[" + myInputLine + "]\n";
1917  }
1918  else
1919  {
1920  if ( myTokens.count() == 2 )
1921  {
1922  myTokens.insert( 1, myTokens[0] ); // add 'to' value, QGIS < 1.9 compatibility
1923  }
1924  tableTransparency->insertRow( tableTransparency->rowCount() );
1925  for ( int col = 0; col < 3; col++ )
1926  {
1927  setTransparencyCell( tableTransparency->rowCount() - 1, col, myTokens[col].toDouble() );
1928  }
1929  }
1930  }
1931  }
1932  }
1933  }
1934 
1935  if ( myImportError )
1936  {
1937  QMessageBox::warning( this, tr( "Import Transparent Pixels" ), tr( "The following lines contained errors\n\n%1" ).arg( myBadLines ) );
1938  }
1939  }
1940  else if ( !myFileName.isEmpty() )
1941  {
1942  QMessageBox::warning( this, tr( "Import Transparent Pixels" ), tr( "Read access denied. Adjust the file permissions and try again.\n\n" ) );
1943  }
1944  tableTransparency->resizeColumnsToContents();
1945  tableTransparency->resizeRowsToContents();
1946 }
1947 
1948 void QgsRasterLayerProperties::pbnRemoveSelectedRow_clicked()
1949 {
1950  if ( 0 < tableTransparency->rowCount() )
1951  {
1952  tableTransparency->removeRow( tableTransparency->currentRow() );
1953  }
1954 }
1955 
1956 void QgsRasterLayerProperties::pixelSelected( const QgsPointXY &canvasPoint, const Qt::MouseButton &btn )
1957 {
1958  Q_UNUSED( btn )
1959  QgsRasterRenderer *renderer = mRendererWidget->renderer();
1960  if ( !renderer )
1961  {
1962  return;
1963  }
1964 
1965  //Get the pixel values and add a new entry to the transparency table
1966  if ( mMapCanvas && mPixelSelectorTool )
1967  {
1968  mMapCanvas->unsetMapTool( mPixelSelectorTool.get() );
1969 
1970  const QgsMapSettings &ms = mMapCanvas->mapSettings();
1971  QgsPointXY myPoint = ms.mapToLayerCoordinates( mRasterLayer, canvasPoint );
1972 
1973  QgsRectangle myExtent = ms.mapToLayerCoordinates( mRasterLayer, mMapCanvas->extent() );
1974  double mapUnitsPerPixel = mMapCanvas->mapUnitsPerPixel();
1975  int myWidth = mMapCanvas->extent().width() / mapUnitsPerPixel;
1976  int myHeight = mMapCanvas->extent().height() / mapUnitsPerPixel;
1977 
1978  QMap<int, QVariant> myPixelMap = mRasterLayer->dataProvider()->identify( myPoint, QgsRaster::IdentifyFormatValue, myExtent, myWidth, myHeight ).results();
1979 
1980  QList<int> bands = renderer->usesBands();
1981 
1982  QList<double> values;
1983  for ( int i = 0; i < bands.size(); ++i )
1984  {
1985  int bandNo = bands.value( i );
1986  if ( myPixelMap.count( bandNo ) == 1 )
1987  {
1988  if ( myPixelMap.value( bandNo ).isNull() )
1989  {
1990  return; // Don't add nodata, transparent anyway
1991  }
1992  double value = myPixelMap.value( bandNo ).toDouble();
1993  QgsDebugMsg( QStringLiteral( "value = %1" ).arg( value, 0, 'g', 17 ) );
1994  values.append( value );
1995  }
1996  }
1997  if ( bands.size() == 1 )
1998  {
1999  // Set 'to'
2000  values.insert( 1, values.value( 0 ) );
2001  }
2002  tableTransparency->insertRow( tableTransparency->rowCount() );
2003  for ( int i = 0; i < values.size(); i++ )
2004  {
2005  setTransparencyCell( tableTransparency->rowCount() - 1, i, values.value( i ) );
2006  }
2007  setTransparencyCell( tableTransparency->rowCount() - 1, tableTransparency->columnCount() - 1, 100 );
2008  }
2009  delete renderer;
2010 
2011  tableTransparency->resizeColumnsToContents();
2012  tableTransparency->resizeRowsToContents();
2013 }
2014 
2015 void QgsRasterLayerProperties::toggleSaturationControls( int grayscaleMode )
2016 {
2017  // Enable or disable saturation controls based on choice of grayscale mode
2018  if ( grayscaleMode == 0 )
2019  {
2020  sliderSaturation->setEnabled( true );
2021  spinBoxSaturation->setEnabled( true );
2022  }
2023  else
2024  {
2025  sliderSaturation->setEnabled( false );
2026  spinBoxSaturation->setEnabled( false );
2027  }
2028 }
2029 
2030 void QgsRasterLayerProperties::toggleColorizeControls( bool colorizeEnabled )
2031 {
2032  // Enable or disable colorize controls based on checkbox
2033  btnColorizeColor->setEnabled( colorizeEnabled );
2034  sliderColorizeStrength->setEnabled( colorizeEnabled );
2035  spinColorizeStrength->setEnabled( colorizeEnabled );
2036 }
2037 
2038 
2039 QLinearGradient QgsRasterLayerProperties::redGradient()
2040 {
2041  //define a gradient
2042  // TODO change this to actual polygon dims
2043  QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2044  myGradient.setColorAt( 0.0, QColor( 242, 14, 25, 190 ) );
2045  myGradient.setColorAt( 0.5, QColor( 175, 29, 37, 190 ) );
2046  myGradient.setColorAt( 1.0, QColor( 114, 17, 22, 190 ) );
2047  return myGradient;
2048 }
2049 QLinearGradient QgsRasterLayerProperties::greenGradient()
2050 {
2051  //define a gradient
2052  // TODO change this to actual polygon dims
2053  QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2054  myGradient.setColorAt( 0.0, QColor( 48, 168, 5, 190 ) );
2055  myGradient.setColorAt( 0.8, QColor( 36, 122, 4, 190 ) );
2056  myGradient.setColorAt( 1.0, QColor( 21, 71, 2, 190 ) );
2057  return myGradient;
2058 }
2059 QLinearGradient QgsRasterLayerProperties::blueGradient()
2060 {
2061  //define a gradient
2062  // TODO change this to actual polygon dims
2063  QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2064  myGradient.setColorAt( 0.0, QColor( 30, 0, 106, 190 ) );
2065  myGradient.setColorAt( 0.2, QColor( 30, 72, 128, 190 ) );
2066  myGradient.setColorAt( 1.0, QColor( 30, 223, 196, 190 ) );
2067  return myGradient;
2068 }
2069 QLinearGradient QgsRasterLayerProperties::grayGradient()
2070 {
2071  //define a gradient
2072  // TODO change this to actual polygon dims
2073  QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2074  myGradient.setColorAt( 0.0, QColor( 5, 5, 5, 190 ) );
2075  myGradient.setColorAt( 0.8, QColor( 122, 122, 122, 190 ) );
2076  myGradient.setColorAt( 1.0, QColor( 220, 220, 220, 190 ) );
2077  return myGradient;
2078 }
2079 QLinearGradient QgsRasterLayerProperties::highlightGradient()
2080 {
2081  //define another gradient for the highlight
2082  // TODO change this to actual polygon dims
2083  QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
2084  myGradient.setColorAt( 1.0, QColor( 255, 255, 255, 50 ) );
2085  myGradient.setColorAt( 0.5, QColor( 255, 255, 255, 100 ) );
2086  myGradient.setColorAt( 0.0, QColor( 255, 255, 255, 150 ) );
2087  return myGradient;
2088 }
2089 
2090 
2091 
2092 //
2093 //
2094 // Next four methods for saving and restoring qml style state
2095 //
2096 //
2097 void QgsRasterLayerProperties::loadDefaultStyle_clicked()
2098 {
2099  bool defaultLoadedFlag = false;
2100  QString myMessage = mRasterLayer->loadDefaultStyle( defaultLoadedFlag );
2101  //reset if the default style was loaded OK only
2102  if ( defaultLoadedFlag )
2103  {
2104  syncToLayer();
2105  }
2106  else
2107  {
2108  //otherwise let the user know what went wrong
2109  QMessageBox::information( this,
2110  tr( "Default Style" ),
2111  myMessage
2112  );
2113  }
2114 }
2115 
2116 void QgsRasterLayerProperties::saveDefaultStyle_clicked()
2117 {
2118 
2119  apply(); // make sure the style to save is up-to-date
2120 
2121  // a flag passed by reference
2122  bool defaultSavedFlag = false;
2123  // after calling this the above flag will be set true for success
2124  // or false if the save operation failed
2125  QString myMessage = mRasterLayer->saveDefaultStyle( defaultSavedFlag );
2126  if ( !defaultSavedFlag )
2127  {
2128  //let the user know what went wrong
2129  QMessageBox::information( this,
2130  tr( "Default Style" ),
2131  myMessage
2132  );
2133  }
2134 }
2135 
2136 
2137 void QgsRasterLayerProperties::loadStyle_clicked()
2138 {
2139  QgsSettings settings;
2140  QString lastUsedDir = settings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString();
2141 
2142  QString fileName = QFileDialog::getOpenFileName(
2143  this,
2144  tr( "Load layer properties from style file" ),
2145  lastUsedDir,
2146  tr( "QGIS Layer Style File" ) + " (*.qml)" );
2147  if ( fileName.isEmpty() )
2148  return;
2149 
2150  // ensure the user never omits the extension from the file name
2151  if ( !fileName.endsWith( QLatin1String( ".qml" ), Qt::CaseInsensitive ) )
2152  fileName += QLatin1String( ".qml" );
2153 
2154  mOldStyle = mRasterLayer->styleManager()->style( mRasterLayer->styleManager()->currentStyle() );
2155 
2156  bool defaultLoadedFlag = false;
2157  QString message = mRasterLayer->loadNamedStyle( fileName, defaultLoadedFlag );
2158  if ( defaultLoadedFlag )
2159  {
2160  settings.setValue( QStringLiteral( "style/lastStyleDir" ), QFileInfo( fileName ).absolutePath() );
2161  syncToLayer();
2162  }
2163  else
2164  {
2165  QMessageBox::information( this, tr( "Save Style" ), message );
2166  }
2167 }
2168 
2169 
2170 void QgsRasterLayerProperties::saveStyleAs_clicked()
2171 {
2172  QgsSettings settings;
2173  QString lastUsedDir = settings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString();
2174 
2175  QString selectedFilter;
2176  QString outputFileName = QFileDialog::getSaveFileName(
2177  this,
2178  tr( "Save layer properties as style file" ),
2179  lastUsedDir,
2180  tr( "QGIS Layer Style File" ) + " (*.qml)" + ";;" + tr( "Styled Layer Descriptor" ) + " (*.sld)",
2181  &selectedFilter );
2182  if ( outputFileName.isEmpty() )
2183  return;
2184 
2185  StyleType type;
2186  // use selectedFilter to set style type
2187  if ( selectedFilter.contains( QStringLiteral( ".qml" ), Qt::CaseInsensitive ) )
2188  {
2189  outputFileName = QgsFileUtils::ensureFileNameHasExtension( outputFileName, QStringList() << QStringLiteral( "qml" ) );
2190  type = StyleType::QML;
2191  }
2192  else
2193  {
2194  outputFileName = QgsFileUtils::ensureFileNameHasExtension( outputFileName, QStringList() << QStringLiteral( "sld" ) );
2195  type = StyleType::SLD;
2196  }
2197 
2198  apply(); // make sure the style to save is up-to-date
2199 
2200  // then export style
2201  bool defaultLoadedFlag = false;
2202  QString message;
2203  switch ( type )
2204  {
2205  case QML:
2206  {
2207  message = mRasterLayer->saveNamedStyle( outputFileName, defaultLoadedFlag );
2208  break;
2209  }
2210  case SLD:
2211  {
2212  message = mRasterLayer->saveSldStyle( outputFileName, defaultLoadedFlag );
2213  break;
2214  }
2215  }
2216  if ( defaultLoadedFlag )
2217  {
2218  settings.setValue( QStringLiteral( "style/lastStyleDir" ), QFileInfo( outputFileName ).absolutePath() );
2219  sync();
2220  }
2221  else
2222  QMessageBox::information( this, tr( "Save Style" ), message );
2223 }
2224 
2225 void QgsRasterLayerProperties::restoreWindowModality()
2226 {
2227  hide();
2228  setModal( true );
2229  show();
2230  raise();
2231  activateWindow();
2232 }
2233 
2234 //
2235 //
2236 // Next four methods for saving and restoring QMD metadata
2237 //
2238 //
2239 
2240 void QgsRasterLayerProperties::loadMetadata()
2241 {
2242  QgsSettings myQSettings; // where we keep last used filter in persistent state
2243  QString myLastUsedDir = myQSettings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString();
2244 
2245  QString myFileName = QFileDialog::getOpenFileName( this, tr( "Load layer metadata from metadata file" ), myLastUsedDir,
2246  tr( "QGIS Layer Metadata File" ) + " (*.qmd)" );
2247  if ( myFileName.isNull() )
2248  {
2249  return;
2250  }
2251 
2252  QString myMessage;
2253  bool defaultLoadedFlag = false;
2254  myMessage = mRasterLayer->loadNamedMetadata( myFileName, defaultLoadedFlag );
2255 
2256  //reset if the default style was loaded OK only
2257  if ( defaultLoadedFlag )
2258  {
2259  mMetadataWidget->setMetadata( &mRasterLayer->metadata() );
2260  }
2261  else
2262  {
2263  //let the user know what went wrong
2264  QMessageBox::warning( this, tr( "Load Metadata" ), myMessage );
2265  }
2266 
2267  QFileInfo myFI( myFileName );
2268  QString myPath = myFI.path();
2269  myQSettings.setValue( QStringLiteral( "style/lastStyleDir" ), myPath );
2270 
2271  activateWindow(); // set focus back to properties dialog
2272 }
2273 
2274 void QgsRasterLayerProperties::saveMetadataAs()
2275 {
2276  QgsSettings myQSettings; // where we keep last used filter in persistent state
2277  QString myLastUsedDir = myQSettings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString();
2278 
2279  QString myOutputFileName = QFileDialog::getSaveFileName( this, tr( "Save Layer Metadata as QMD" ),
2280  myLastUsedDir, tr( "QMD File" ) + " (*.qmd)" );
2281  if ( myOutputFileName.isNull() ) //dialog canceled
2282  {
2283  return;
2284  }
2285 
2286  mMetadataWidget->acceptMetadata();
2287 
2288  //ensure the user never omitted the extension from the file name
2289  if ( !myOutputFileName.endsWith( QgsMapLayer::extensionPropertyType( QgsMapLayer::Metadata ), Qt::CaseInsensitive ) )
2290  {
2292  }
2293 
2294  bool defaultLoadedFlag = false;
2295  QString message = mRasterLayer->saveNamedMetadata( myOutputFileName, defaultLoadedFlag );
2296  if ( defaultLoadedFlag )
2297  myQSettings.setValue( QStringLiteral( "style/lastStyleDir" ), QFileInfo( myOutputFileName ).absolutePath() );
2298  else
2299  QMessageBox::information( this, tr( "Save Metadata" ), message );
2300 }
2301 
2302 void QgsRasterLayerProperties::saveDefaultMetadata()
2303 {
2304  mMetadataWidget->acceptMetadata();
2305 
2306  bool defaultSavedFlag = false;
2307  QString errorMsg = mRasterLayer->saveDefaultMetadata( defaultSavedFlag );
2308  if ( !defaultSavedFlag )
2309  {
2310  QMessageBox::warning( this, tr( "Default Metadata" ), errorMsg );
2311  }
2312 }
2313 
2314 void QgsRasterLayerProperties::loadDefaultMetadata()
2315 {
2316  bool defaultLoadedFlag = false;
2317  QString myMessage = mRasterLayer->loadNamedMetadata( mRasterLayer->metadataUri(), defaultLoadedFlag );
2318  //reset if the default metadata was loaded OK only
2319  if ( defaultLoadedFlag )
2320  {
2321  mMetadataWidget->setMetadata( &mRasterLayer->metadata() );
2322  }
2323  else
2324  {
2325  QMessageBox::information( this, tr( "Default Metadata" ), myMessage );
2326  }
2327 }
2328 
2329 
2330 void QgsRasterLayerProperties::toggleBuildPyramidsButton()
2331 {
2332  if ( lbxPyramidResolutions->selectedItems().empty() )
2333  {
2334  buttonBuildPyramids->setEnabled( false );
2335  }
2336  else
2337  {
2338  buttonBuildPyramids->setEnabled( true );
2339  }
2340 }
2341 
2342 void QgsRasterLayerProperties::mResetColorRenderingBtn_clicked()
2343 {
2344  mBlendModeComboBox->setBlendMode( QPainter::CompositionMode_SourceOver );
2345  mSliderBrightness->setValue( 0 );
2346  mSliderContrast->setValue( 0 );
2347  mGammaSpinBox->setValue( 1.0 );
2348  sliderSaturation->setValue( 0 );
2349  comboGrayscale->setCurrentIndex( ( int ) QgsHueSaturationFilter::GrayscaleOff );
2350  mColorizeCheck->setChecked( false );
2351  sliderColorizeStrength->setValue( 100 );
2352 }
2353 
2354 bool QgsRasterLayerProperties::rasterIsMultiBandColor()
2355 {
2356  return mRasterLayer && nullptr != dynamic_cast<QgsMultiBandColorRenderer *>( mRasterLayer->renderer() );
2357 }
2358 
2359 void QgsRasterLayerProperties::updateInformationContent()
2360 {
2361  const QString myStyle = QgsApplication::reportStyleSheet( QgsApplication::StyleSheetType::WebBrowser );
2362  // Inject the stylesheet
2363  const QString html { mRasterLayer->htmlMetadata().replace( QLatin1String( "<head>" ), QStringLiteral( R"raw(<head><style type="text/css">%1</style>)raw" ) ).arg( myStyle ) };
2364  mMetadataViewer->setHtml( html );
2365  mMetadataFilled = true;
2366 }
2367 
2368 void QgsRasterLayerProperties::onCancel()
2369 {
2370  if ( mOldStyle.xmlData() != mRasterLayer->styleManager()->style( mRasterLayer->styleManager()->currentStyle() ).xmlData() )
2371  {
2372  // need to reset style to previous - style applied directly to the layer (not in apply())
2373  QString myMessage;
2374  QDomDocument doc( QStringLiteral( "qgis" ) );
2375  int errorLine, errorColumn;
2376  doc.setContent( mOldStyle.xmlData(), false, &myMessage, &errorLine, &errorColumn );
2377  mRasterLayer->importNamedStyle( doc, myMessage );
2378  syncToLayer();
2379  }
2380 }
2381 
2382 void QgsRasterLayerProperties::showHelp()
2383 {
2384  const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property( "helpPage" );
2385 
2386  if ( helpPage.isValid() )
2387  {
2388  QgsHelp::openHelp( helpPage.toString() );
2389  }
2390  else
2391  {
2392  QgsHelp::openHelp( QStringLiteral( "working_with_raster/raster_properties.html" ) );
2393  }
2394 }
2395 
2396 void QgsRasterLayerProperties::updateGammaSpinBox( int value )
2397 {
2398  whileBlocking( mGammaSpinBox )->setValue( value / 100.0 );
2399 }
2400 
2401 void QgsRasterLayerProperties::updateGammaSlider( double value )
2402 {
2403  whileBlocking( mSliderGamma )->setValue( value * 100 );
2404 }
QgsMetadataWidget::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas)
Sets a map canvas associated with the widget.
Definition: qgsmetadatawidget.cpp:958
QgsMapLayer::setAbstract
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:301
QgsApplication::rasterRendererRegistry
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers.
Definition: qgsapplication.cpp:2153
QgsRasterDataProvider::setUserNoDataValue
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
Definition: qgsrasterdataprovider.cpp:396
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:89
QgsRasterTransparency::setTransparentThreeValuePixelList
void setTransparentThreeValuePixelList(const QList< QgsRasterTransparency::TransparentThreeValuePixel > &newList)
Sets the transparent three value pixel list, replacing the whole existing list.
Definition: qgsrastertransparency.cpp:69
qgsrasterbandstats.h
QgsRasterBlock::printValue
static QString printValue(double value)
Print double value with all necessary significant digits.
Definition: qgsrasterblock.cpp:626
QgsRasterContourRendererWidget::create
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Widget creation function (mainly for the use by the renderer registry)
Definition: qgsrastercontourrendererwidget.h:37
Qgis::Float32
@ Float32
Thirty two bit floating point (float)
Definition: qgis.h:109
qgspalettedrendererwidget.h
QgsRectangle::height
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
Definition: qgsrectangle.h:209
QgsMapLayer::hasAutoRefreshEnabled
bool hasAutoRefreshEnabled() const
Returns true if auto refresh is enabled for the layer.
Definition: qgsmaplayer.cpp:683
QgsRasterLayer::paletteAsPixmap
QPixmap paletteAsPixmap(int bandNumber=1)
Returns a 100x100 pixmap of the color palette.
Definition: qgsrasterlayer.cpp:507
QgsDataSourceUri
Class for storing the component parts of a RDBMS data source URI (e.g.
Definition: qgsdatasourceuri.h:36
QgsMapCanvas::extent
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
Definition: qgsmapcanvas.cpp:1056
QgsMapLayer::attributionUrl
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:401
QgsMapSettings::mapToLayerCoordinates
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
Definition: qgsmapsettings.cpp:537
qgsrasterlayer.h
QgsMapLayer::setMetadataUrl
void setMetadataUrl(const QString &metaUrl)
Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:412
QgsTemporalProperty::changed
void changed()
Emitted when the temporal properties have changed.
QgsRasterRenderer::setRasterTransparency
void setRasterTransparency(QgsRasterTransparency *t)
Definition: qgsrasterrenderer.cpp:98
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Definition: qgsapplication.cpp:626
QgsMapLayer::autoRefreshInterval
int autoRefreshInterval
Definition: qgsmaplayer.h:87
QgsRasterDataProvider::dataType
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
QgsMapLayer::dataUrlFormat
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:363
QgsOptionsDialogBase
A base dialog for options and properties dialogs that offers vertical tabs.
Definition: qgsoptionsdialogbase.h:63
QgsMetadataWidget::setMetadata
void setMetadata(const QgsAbstractMetadataBase *metadata)
Sets the metadata to display in the widget.
Definition: qgsmetadatawidget.cpp:166
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:105
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:174
QgsPalettedRendererWidget::create
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Definition: qgspalettedrendererwidget.h:161
qgsmapcanvas.h
QgsRasterInterface::Size
@ Size
Definition: qgsrasterinterface.h:186
QgsCoordinateReferenceSystem::userFriendlyIdentifier
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
Definition: qgscoordinatereferencesystem.cpp:1338
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsRasterDataProvider::useSourceNoDataValue
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
Definition: qgsrasterdataprovider.h:249
QgsRasterDataProviderTemporalCapabilities::availableTemporalRange
const QgsDateTimeRange & availableTemporalRange() const
Returns the datetime range extent from which temporal data is available from the provider.
Definition: qgsrasterdataprovidertemporalcapabilities.cpp:33
QgsRasterTransparency::transparentSingleValuePixelList
QList< QgsRasterTransparency::TransparentSingleValuePixel > transparentSingleValuePixelList() const
Returns the transparent single value pixel list.
Definition: qgsrastertransparency.cpp:27
qgsrasteridentifyresult.h
QgsMapLayer::blendMode
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
Definition: qgsmaplayer.cpp:212
qgsmaptopixel.h
QgsMapLayer::setCustomProperty
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
Definition: qgsmaplayer.cpp:1708
QgsCoordinateReferenceSystem::WKT_PREFERRED
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
Definition: qgscoordinatereferencesystem.h:679
QgsRasterLayerProperties::QgsRasterLayerProperties
QgsRasterLayerProperties(QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent=nullptr, Qt::WindowFlags=QgsGuiUtils::ModalDialogFlags)
Constructor.
Definition: qgsrasterlayerproperties.cpp:87
QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod
IntervalHandlingMethod
Method to use when resolving a temporal range to a data provider layer or band.
Definition: qgsrasterdataprovidertemporalcapabilities.h:52
QgsMapCanvas::mapSettings
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Definition: qgsmapcanvas.cpp:391
QgsApplication::shortNameRegExp
static QRegExp shortNameRegExp()
Returns the short name regular expression for line edit validator.
Definition: qgsapplication.cpp:1092
qgscontrastenhancement.h
qgsgui.h
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsRasterTransparency::transparentThreeValuePixelList
QList< QgsRasterTransparency::TransparentThreeValuePixel > transparentThreeValuePixelList() const
Returns the transparent three value pixel list.
Definition: qgsrastertransparency.cpp:32
QgsRasterHistogramWidget::setRendererWidget
void setRendererWidget(const QString &name, QgsRasterRendererWidget *rendererWidget=nullptr)
Sets the renderer widget (or just its name if there is no widget)
Definition: qgsrasterhistogramwidget.cpp:247
QgsMapLayer::importNamedStyle
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Import the properties of this layer from a QDomDocument.
Definition: qgsmaplayer.cpp:1037
QgsMapSettings::outputExtentToLayerExtent
QgsRectangle outputExtentToLayerExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS
Definition: qgsmapsettings.cpp:458
QgsRaster::SingleBandGray
@ SingleBandGray
Definition: qgsraster.h:92
QgsRasterLayer::ColorLayer
@ ColorLayer
Definition: qgsrasterlayer.h:184
QgsRasterTransparency::TransparentSingleValuePixel::min
double min
Definition: qgsrastertransparency.h:55
QgsMapLayer::shortName
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
Definition: qgsmaplayer.cpp:179
QgsRaster::RasterPyramidsFormat
RasterPyramidsFormat
Definition: qgsraster.h:82
QgsProjectionSelectionWidget::crsChanged
void crsChanged(const QgsCoordinateReferenceSystem &)
Emitted when the selected CRS is changed.
QgsRasterRenderer::nodataColor
QColor nodataColor() const
Returns the color to use for shading nodata pixels.
Definition: qgsrasterrenderer.h:100
QgsRasterRendererRegistryEntry::name
QString name
Definition: qgsrasterrendererregistry.h:53
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsRasterRendererRegistryEntry
Registry for raster renderer entries.
Definition: qgsrasterrendererregistry.h:45
QgsHueSaturationFilter::GrayscaleMode
GrayscaleMode
Definition: qgshuesaturationfilter.h:37
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
QgsMapLayer::setMetadataUrlType
void setMetadataUrlType(const QString &metaUrlType)
Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType ind...
Definition: qgsmaplayer.h:430
QgsMapLayer::styleManager
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
Definition: qgsmaplayer.cpp:1806
QgsMapLayer::formatLayerName
static QString formatLayerName(const QString &name)
A convenience function to capitalize and format a layer name.
Definition: qgsmaplayer.cpp:791
QgsRasterHistogramWidget::setActive
void setActive(bool activeFlag)
Activate the histogram widget.
Definition: qgsrasterhistogramwidget.cpp:255
QgsRasterInterface::BuildPyramids
@ BuildPyramids
Definition: qgsrasterinterface.h:189
qgsrasterlayertemporalpropertieswidget.h
QgsMapLayer::Metadata
@ Metadata
Definition: qgsmaplayer.h:138
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:468
QgsMapLayerStyleManager::currentStyleChanged
void currentStyleChanged(const QString &currentName)
Emitted when the current style has been changed.
QgsMapLayer::abstract
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:309
qgsrasterrenderer.h
QgsRasterTransparency::TransparentThreeValuePixel::percentTransparent
double percentTransparent
Definition: qgsrastertransparency.h:50
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QgsMapLayer::setBlendMode
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
Definition: qgsmaplayer.cpp:202
qgsrasterrendererregistry.h
QgsMapToolEmitPoint::canvasClicked
void canvasClicked(const QgsPointXY &point, Qt::MouseButton button)
signal emitted on canvas click
QgsRasterRenderer::type
virtual QString type() const
Definition: qgsrasterrenderer.h:64
QgsRasterLayer::htmlMetadata
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
Definition: qgsrasterlayer.cpp:316
QgsMapLayer::isValid
bool isValid
Definition: qgsmaplayer.h:91
QgsMapLayer::saveNamedStyle
virtual QString saveNamedStyle(const QString &uri, bool &resultFlag, StyleCategories categories=AllStyleCategories)
Save the properties of this layer as a named style (either as a .qml file on disk or as a record in t...
Definition: qgsmaplayer.cpp:1381
QgsRasterRendererRegistry::insertWidgetFunction
void insertWidgetFunction(const QString &rendererName, QgsRasterRendererWidgetCreateFunc func)
Definition: qgsrasterrendererregistry.cpp:73
qgsmaplayerstyleguiutils.h
QgsRasterLayer::setDataSource
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag=false) override
Updates the data source of the layer.
Definition: qgsrasterlayer.cpp:864
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsRasterDataProviderTemporalCapabilities::MatchUsingWholeRange
@ MatchUsingWholeRange
Use an exact match to the whole temporal range.
Definition: qgsrasterdataprovidertemporalcapabilities.h:53
QgsMapLayer::saveSldStyle
virtual QString saveSldStyle(const QString &uri, bool &resultFlag) const
Saves the properties of this layer to an SLD format file.
Definition: qgsmaplayer.cpp:1463
QgsSingleBandPseudoColorRendererWidget::create
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Creates new raster renderer widget.
Definition: qgssinglebandpseudocolorrendererwidget.h:49
QgsDataProvider::dataSourceUri
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
Definition: qgsdataprovider.h:159
QgsRasterLayer::previewAsImage
QImage previewAsImage(QSize size, const QColor &bgColor=Qt::white, QImage::Format format=QImage::Format_ARGB32_Premultiplied)
Draws a preview of the rasterlayer into a QImage.
Definition: qgsrasterlayer.cpp:1696
qgsrasterlayerproperties.h
QgsProjectTimeSettings::temporalRange
QgsDateTimeRange temporalRange() const
Returns the project's temporal range, which indicates the earliest and latest datetime ranges associa...
Definition: qgsprojecttimesettings.cpp:34
QgsMapLayer::setCrs
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
Definition: qgsmaplayer.cpp:771
QgsRasterRenderer::usesBands
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
Definition: qgsrasterrenderer.h:133
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsRasterLayer::setRenderer
void setRenderer(QgsRasterRenderer *renderer)
Sets the raster's renderer.
Definition: qgsrasterlayer.cpp:1659
QgsMapLayer::dataUrl
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:345
QgsMapLayer::saveNamedMetadata
QString saveNamedMetadata(const QString &uri, bool &resultFlag)
Save the current metadata of this layer as a named metadata (either as a .qmd file on disk or as a re...
Definition: qgsmaplayer.cpp:1140
qgsmultibandcolorrendererwidget.h
QgsRasterLayerProperties::QML
@ QML
Definition: qgsrasterlayerproperties.h:64
QgsSingleBandGrayRendererWidget::create
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Definition: qgssinglebandgrayrendererwidget.h:38
QgsMapLayer::setLegendUrlFormat
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
Definition: qgsmaplayer.h:993
QgsHueSaturationFilter::setSaturation
void setSaturation(int saturation)
Definition: qgshuesaturationfilter.cpp:314
QgsRasterDataProvider::sourceHasNoDataValue
virtual bool sourceHasNoDataValue(int bandNo) const
Returns true if source band has no data value.
Definition: qgsrasterdataprovider.h:246
QgsRasterDataProviderTemporalCapabilities::FindClosestMatchToStartOfRange
@ FindClosestMatchToStartOfRange
Definition: qgsrasterdataprovidertemporalcapabilities.h:56
qgsapplication.h
qgsprojectionselectiondialog.h
QgsMapLayer::saveDefaultMetadata
virtual QString saveDefaultMetadata(bool &resultFlag)
Save the current metadata of this layer as the default metadata (either as a .qmd file on disk or as ...
Definition: qgsmaplayer.cpp:847
QgsDataSourceUri::param
QString param(const QString &key) const
Returns a generic parameter value corresponding to the specified key.
Definition: qgsdatasourceuri.cpp:823
QgsMapLayer::triggerRepaint
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
Definition: qgsmaplayer.cpp:1826
QgsRasterTransparency::TransparentSingleValuePixel::percentTransparent
double percentTransparent
Definition: qgsrastertransparency.h:57
QgsRasterRendererWidget::setMapCanvas
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
Definition: qgsrasterrendererwidget.cpp:23
QgsRasterTransparency::TransparentThreeValuePixel::blue
double blue
Definition: qgsrastertransparency.h:49
qgsprovidermetadata.h
QgsHueSaturationFilter::setColorizeColor
void setColorizeColor(const QColor &colorizeColor)
Definition: qgshuesaturationfilter.cpp:322
QgsProviderMetadata::encodeUri
virtual QString encodeUri(const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
Definition: qgsprovidermetadata.cpp:133
QgsMapLayerStyleGuiUtils::addStyleManagerActions
void addStyleManagerActions(QMenu *m, QgsMapLayer *layer)
adds actions to the menu in accordance to the layer
Definition: qgsmaplayerstyleguiutils.cpp:82
QgsRaster::IdentifyFormatValue
@ IdentifyFormatValue
Definition: qgsraster.h:60
QgsMapLayer::keywordList
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:325
QgsHueSaturationFilter::grayscaleMode
QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const
Definition: qgshuesaturationfilter.h:60
QgsHueSaturationFilter::setGrayscaleMode
void setGrayscaleMode(QgsHueSaturationFilter::GrayscaleMode grayscaleMode)
Definition: qgshuesaturationfilter.h:59
qgssinglebandpseudocolorrendererwidget.h
QgsMapLayer::legendUrlFormat
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
Definition: qgsmaplayer.h:998
qgsproviderregistry.h
QgsMapLayer::metadataUrlFormat
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:457
QgsTemporalProperty::isActive
bool isActive() const
Returns true if the temporal property is active.
Definition: qgstemporalproperty.cpp:36
QgsRasterIdentifyResult::results
QMap< int, QVariant > results() const
Returns the identify results.
Definition: qgsrasteridentifyresult.h:66
whileBlocking
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:262
QgsMetadataWidget::acceptMetadata
void acceptMetadata()
Saves the metadata to the layer.
Definition: qgsmetadatawidget.cpp:978
QgsRasterRenderer
Raster renderer pipe that applies colors to a raster.
Definition: qgsrasterrenderer.h:39
QgsBrightnessContrastFilter::brightness
int brightness() const
Returns current brightness level.
Definition: qgsbrightnesscontrastfilter.h:73
QgsRasterRenderer::rasterTransparency
const QgsRasterTransparency * rasterTransparency() const
Definition: qgsrasterrenderer.h:114
QgsRasterDataProvider::temporalCapabilities
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
Definition: qgsrasterdataprovider.cpp:427
qgsmetadatawidget.h
QgsRasterLayerProperties::StyleType
StyleType
enumeration for the different types of style
Definition: qgsrasterlayerproperties.h:63
QgsRasterLayer::temporalProperties
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
Definition: qgsrasterlayer.cpp:1006
QgsHueSaturationFilter::colorizeOn
bool colorizeOn() const
Definition: qgshuesaturationfilter.h:63
QgsHueSaturationFilter::setColorizeStrength
void setColorizeStrength(int colorizeStrength)
Definition: qgshuesaturationfilter.h:66
QgsMapLayer::setMaximumScale
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
Definition: qgsmaplayer.cpp:722
QgsRasterRenderer::setAlphaBand
void setAlphaBand(int band)
Definition: qgsrasterrenderer.h:116
QgsDoubleValidator
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
Definition: qgsdoublevalidator.h:39
QgsRasterDataProvider::pyramidResamplingMethods
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
Definition: qgsrasterdataprovider.cpp:366
QgsMapLayerStyleGuiUtils::instance
static QgsMapLayerStyleGuiUtils * instance()
returns a singleton instance of this class
Definition: qgsmaplayerstyleguiutils.cpp:28
QgsRasterDataProvider::identify
virtual QgsRasterIdentifyResult identify(const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Identify raster value(s) found on the point position.
Definition: qgsrasterdataprovider.cpp:265
QgsCoordinateReferenceSystem::toWkt
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Definition: qgscoordinatereferencesystem.cpp:1954
QgsMapLayer::loadDefaultStyle
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
Definition: qgsmaplayer.cpp:862
QgsRasterLayer::dataProvider
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
Definition: qgsrasterlayer.cpp:234
QgsRasterHistogramWidget
Histogram widget.
Definition: qgsrasterhistogramwidget.h:42
QgsRasterDataProvider::buildPyramids
virtual QString buildPyramids(const QList< QgsRasterPyramid > &pyramidList, const QString &resamplingMethod="NEAREST", QgsRaster::RasterPyramidsFormat format=QgsRaster::PyramidsGTiff, const QStringList &configOptions=QStringList(), QgsRasterBlockFeedback *feedback=nullptr)
Create pyramid overviews.
Definition: qgsrasterdataprovider.h:319
QgsRasterTransparency::TransparentSingleValuePixel::max
double max
Definition: qgsrastertransparency.h:56
QgsHueSaturationFilter::colorizeColor
QColor colorizeColor() const
Definition: qgshuesaturationfilter.h:65
qgscoordinatetransform.h
QgsMapLayer::setKeywordList
void setKeywordList(const QString &keywords)
Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:317
QgsOptionsDialogBase::initOptionsBase
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
Definition: qgsoptionsdialogbase.cpp:65
QgsRasterRangeList
QList< QgsRasterRange > QgsRasterRangeList
Definition: qgsrasterrange.h:26
QgsRasterTransparency::setTransparentSingleValuePixelList
void setTransparentSingleValuePixelList(const QList< QgsRasterTransparency::TransparentSingleValuePixel > &newList)
Sets the transparent single value pixel list, replacing the whole existing list.
Definition: qgsrastertransparency.cpp:64
QgsRasterDataProvider::sourceNoDataValue
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
Definition: qgsrasterdataprovider.h:255
QgsRasterTransparency::TransparentSingleValuePixel
Definition: qgsrastertransparency.h:54
QgsRasterRendererRegistryEntry::visibleName
QString visibleName
Definition: qgsrasterrendererregistry.h:54
QgsMapLayer::title
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:293
QgsFeedback::progressChanged
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
QgsProject::setDirty
void setDirty(bool b=true)
Flag the project as dirty (modified).
Definition: qgsproject.cpp:519
QgsMapLayer::setTitle
void setTitle(const QString &title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:285
qgsrasterpyramid.h
qgsrasterhistogramwidget.h
QgsHueSaturationFilter
Color and saturation filter pipe for rasters.
Definition: qgshuesaturationfilter.h:32
QgsProviderRegistry::providerMetadata
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
Definition: qgsproviderregistry.cpp:724
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:289
QgsMultiBandColorRenderer
Renderer for multiband images with the color components.
Definition: qgsmultibandcolorrenderer.h:33
QgsMapLayer::hasScaleBasedVisibility
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
Definition: qgsmaplayer.cpp:678
QgsRasterLayer
Represents a raster layer.
Definition: qgsrasterlayer.h:71
QgsRasterTransparency
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
Definition: qgsrastertransparency.h:33
qgsrastertransparency.h
qgsrastercontourrendererwidget.h
QgsMapCanvas::setMapTool
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
Definition: qgsmapcanvas.cpp:2006
QgsRasterDataProvider::fields
virtual QgsFields fields() const
Returns the fields of the raster layer for data providers that expose them, the default implementatio...
Definition: qgsrasterdataprovider.h:145
QgsBrightnessContrastFilter::contrast
int contrast() const
Returns current contrast level.
Definition: qgsbrightnesscontrastfilter.h:85
QgsMapLayer::minimumScale
double minimumScale() const
Returns the minimum map scale (i.e.
Definition: qgsmaplayer.cpp:743
QgsMapLayerStyleManager::currentStyle
QString currentStyle() const
Returns name of the current style.
Definition: qgsmaplayerstylemanager.cpp:164
QgsMapLayer::maximumScale
double maximumScale() const
Returns the maximum map scale (i.e.
Definition: qgsmaplayer.cpp:727
QgsGui::nativePlatformInterface
static QgsNative * nativePlatformInterface()
Returns the global native interface, which offers abstraction to the host OS's underlying public inte...
Definition: qgsgui.cpp:69
qgsbrightnesscontrastfilter.h
qgsfileutils.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsMultiBandColorRendererWidget::create
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Definition: qgsmultibandcolorrendererwidget.h:42
QgsProject::timeSettings
const QgsProjectTimeSettings * timeSettings() const
Returns the project's time settings, which contains the project's temporal range and other time based...
Definition: qgsproject.cpp:3080
QgsProviderMetadata
Holds data provider key, description, and associated shared library file or function pointer informat...
Definition: qgsprovidermetadata.h:137
QgsHueSaturationFilter::saturation
int saturation() const
Definition: qgshuesaturationfilter.h:57
QgsHillshadeRendererWidget::create
static QgsRasterRendererWidget * create(QgsRasterLayer *layer, const QgsRectangle &extent)
Factory method to create the renderer for this type.
Definition: qgshillshaderendererwidget.h:49
qgsvectorlayer.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:44
QgsHueSaturationFilter::colorizeStrength
int colorizeStrength() const
Definition: qgshuesaturationfilter.h:67
qgsprojecttimesettings.h
QgsDataSourceUri::hasParam
bool hasParam(const QString &key) const
Returns true if a parameter with the specified key exists.
Definition: qgsdatasourceuri.cpp:849
QgsMapLayerLegend::defaultRasterLegend
static QgsMapLayerLegend * defaultRasterLegend(QgsRasterLayer *rl)
Create new legend implementation for raster layer.
Definition: qgsmaplayerlegend.cpp:52
QgsMetadataWidget::crsChanged
void crsChanged()
If the CRS is updated.
Definition: qgsmetadatawidget.cpp:303
QgsMapLayer::setMetadataUrlFormat
void setMetadataUrlFormat(const QString &metaUrlFormat)
Sets the metadata format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:448
QgsRasterDataProviderTemporalCapabilities::MatchExactUsingStartOfRange
@ MatchExactUsingStartOfRange
Match the start of the temporal range to a corresponding layer or band, and only use exact matching r...
Definition: qgsrasterdataprovidertemporalcapabilities.h:54
QgsMapLayer::setAttributionUrl
void setAttributionUrl(const QString &attribUrl)
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:392
QgsMapLayer::legendUrl
QString legendUrl() const
Returns the URL for the layer's legend.
Definition: qgsmaplayer.h:988
QgsRasterDataProvider::sourceDataType
Qgis::DataType sourceDataType(int bandNo) const override=0
Returns source data type for the band specified by number, source data type may be shorter than dataT...
qgshuesaturationfilter.h
QgsMapLayerStyleManager::isDefault
bool isDefault(const QString &styleName) const
Returns true if this is the default style.
Definition: qgsmaplayerstylemanager.cpp:229
qgssinglebandgrayrendererwidget.h
QgsRasterDataProvider::buildPyramidList
virtual QList< QgsRasterPyramid > buildPyramidList(QList< int > overviewList=QList< int >())
Returns the raster layers pyramid list.
Definition: qgsrasterdataprovider.h:341
Qgis::ARGB32_Premultiplied
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
Definition: qgis.h:116
QgsFileUtils::ensureFileNameHasExtension
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
Definition: qgsfileutils.cpp:59
QgsDatumTransformDialog::run
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...
Definition: qgsdatumtransformdialog.cpp:36
QgsMapLayer::setScaleBasedVisibility
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer.
Definition: qgsmaplayer.cpp:738
QgsMapLayerStyleManager::style
QgsMapLayerStyle style(const QString &name) const
Returns data of a stored style - accessed by its unique name.
Definition: qgsmaplayerstylemanager.cpp:96
QgsRasterDataProvider::userNoDataValues
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
Definition: qgsrasterdataprovider.h:260
QgsMapLayer::extensionPropertyType
static QString extensionPropertyType(PropertyType type)
Returns the extension of a Property.
Definition: qgsmaplayer.cpp:58
QgsMapLayer::customProperty
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Definition: qgsmaplayer.cpp:1723
QgsGui::instance
static QgsGui * instance()
Returns a pointer to the singleton instance.
Definition: qgsgui.cpp:63
QgsRasterLayer::providerType
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
Definition: qgsrasterlayer.cpp:562
QgsMapLayerStyleGuiUtils::removesExtraMenuSeparators
void removesExtraMenuSeparators(QMenu *m)
removes extra separators from the menu
Definition: qgsmaplayerstyleguiutils.cpp:97
QgsBrightnessContrastFilter
Brightness/contrast and gamma correction filter pipe for rasters.
Definition: qgsbrightnesscontrastfilter.h:32
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1
QgsMapLayer::setName
void setName(const QString &name)
Set the display name of the layer.
Definition: qgsmaplayer.cpp:153
QgsMapLayer::setDataUrlFormat
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:354
QgsHelp::openHelp
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition: qgshelp.cpp:36
QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged
virtual void optionsStackedWidget_CurrentChanged(int index)
Select relevant tab on current page change.
Definition: qgsoptionsdialogbase.cpp:468
qgshillshaderendererwidget.h
QgsRectangle::width
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
Definition: qgsrectangle.h:202
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsRasterLayerTemporalPropertiesWidget
A widget for configuring the temporal properties for a raster layer.
Definition: qgsrasterlayertemporalpropertieswidget.h:35
QgsMapLayer::setLegendUrl
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
Definition: qgsmaplayer.h:983
QgsHueSaturationFilter::GrayscaleOff
@ GrayscaleOff
Definition: qgshuesaturationfilter.h:38
QgsRasterRenderer::alphaBand
int alphaBand() const
Definition: qgsrasterrenderer.h:117
QgsMapLayer::setAutoRefreshInterval
void setAutoRefreshInterval(int interval)
Sets the auto refresh interval (in milliseconds) for the layer.
Definition: qgsmaplayer.cpp:693
QgsRasterDataProvider::setUseSourceNoDataValue
virtual void setUseSourceNoDataValue(int bandNo, bool use)
Sets the source nodata value usage.
Definition: qgsrasterdataprovider.cpp:34
qgsmultibandcolorrenderer.h
QgsDoubleValidator::toDouble
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
Definition: qgsdoublevalidator.cpp:122
QgsRasterBlockFeedback
Feedback object tailored for raster block reading.
Definition: qgsrasterinterface.h:41
qgssettings.h
QgsRasterLayer::hueSaturationFilter
QgsHueSaturationFilter * hueSaturationFilter() const
Returns the raster's hue/saturation filter.
Definition: qgsrasterlayer.h:270
QgsMapLayer::metadataUrl
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:421
QgsRasterTransparency::TransparentThreeValuePixel
Definition: qgsrastertransparency.h:46
QgsMapLayerStyle::xmlData
QString xmlData() const
Returns XML content of the style.
Definition: qgsmaplayerstyle.cpp:43
QgsMapLayer::name
QString name
Definition: qgsmaplayer.h:86
QgsRasterRange
Raster values range container.
Definition: qgsrasterrange.h:36
QgsRasterLayer::brightnessFilter
QgsBrightnessContrastFilter * brightnessFilter() const
Returns the raster's brightness/contrast filter.
Definition: qgsrasterlayer.h:262
qgsmaplayerlegend.h
QgsMapLayer::setAutoRefreshEnabled
void setAutoRefreshEnabled(bool enabled)
Sets whether auto refresh is enabled for the layer.
Definition: qgsmaplayer.cpp:707
QgsRasterLayerTemporalPropertiesWidget::saveTemporalProperties
void saveTemporalProperties()
Save widget temporal properties inputs.
Definition: qgsrasterlayertemporalpropertieswidget.cpp:48
QgsMapCanvas::unsetMapTool
void unsetMapTool(QgsMapTool *mapTool)
Unset the current map tool or last non zoom tool.
Definition: qgsmapcanvas.cpp:2046
QgsRaster::MultiBandColor
@ MultiBandColor
Definition: qgsraster.h:100
qgsdatumtransformdialog.h
QgsMetadataWidget
A wizard to edit metadata on a map layer.
Definition: qgsmetadatawidget.h:42
QgsDataSourceUri::uri
QString uri(bool expandAuthConfig=true) const
Returns the complete URI as a string.
Definition: qgsdatasourceuri.cpp:538
QgsMapLayer::setMinimumScale
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
Definition: qgsmaplayer.cpp:733
QgsMapLayer::setAttribution
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:374
QgsOptionsDialogBase::mOptStackedWidget
QStackedWidget * mOptStackedWidget
Definition: qgsoptionsdialogbase.h:185
QgsBrightnessContrastFilter::setContrast
void setContrast(int contrast)
Set contrast level.
Definition: qgsbrightnesscontrastfilter.h:79
QgsRasterLayerTemporalPropertiesWidget::syncToLayer
void syncToLayer()
Updates the widget state to match the current layer state.
Definition: qgsrasterlayertemporalpropertieswidget.cpp:64
QgsRasterRenderer::setNodataColor
void setNodataColor(const QColor &color)
Sets the color to use for shading nodata pixels.
Definition: qgsrasterrenderer.h:111
QgsRasterLayer::renderer
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
Definition: qgsrasterlayer.h:246
qgsrasterlayertemporalproperties.h
QgsHueSaturationFilter::setColorizeOn
void setColorizeOn(bool colorizeOn)
Definition: qgshuesaturationfilter.h:62
QgsRasterRendererWidget::doComputations
virtual void doComputations()
Load programmatically with current values.
Definition: qgsrasterrendererwidget.h:78
QgsRasterTransparency::TransparentThreeValuePixel::red
double red
Definition: qgsrastertransparency.h:47
QgsDataProvider::uri
QgsDataSourceUri uri() const
Gets the data source specification.
Definition: qgsdataprovider.h:197
QgsSettings::contains
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
Definition: qgssettings.cpp:188
QgsBrightnessContrastFilter::setBrightness
void setBrightness(int brightness)
Set brightness level.
Definition: qgsbrightnesscontrastfilter.h:67
QgsMapLayer::metadataUri
virtual QString metadataUri() const
Retrieve the metadata URI for this layer (either as a .qmd file on disk or as a record in the users s...
Definition: qgsmaplayer.cpp:842
qgsrasterrange.h
qgswebview.h
QgsMapLayer::saveDefaultStyle
virtual QString saveDefaultStyle(bool &resultFlag)
Save the properties of this layer as the default style (either as a .qml file on disk or as a record ...
Definition: qgsmaplayer.cpp:1135
QgsRasterRendererWidget
Definition: qgsrasterrendererwidget.h:37
QgsDataProvider::name
virtual QString name() const =0
Returns a provider name.
QgsRasterRendererWidget::renderer
virtual QgsRasterRenderer * renderer()=0
Qgis::ARGB32
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
Definition: qgis.h:115
QgsDataProviderTemporalCapabilities::hasTemporalCapabilities
bool hasTemporalCapabilities() const
Returns true if the provider has temporal capabilities available.
Definition: qgsdataprovidertemporalcapabilities.h:74
QgsRasterDataProviderTemporalCapabilities::availableReferenceTemporalRange
const QgsDateTimeRange & availableReferenceTemporalRange() const
Returns the available reference datetime range, which indicates the maximum extent of datetime values...
Definition: qgsrasterdataprovidertemporalcapabilities.cpp:46
qgsdoublevalidator.h
qgslogger.h
QgsBrightnessContrastFilter::setGamma
void setGamma(double gamma)
Set gamma value.
Definition: qgsbrightnesscontrastfilter.h:93
QgsBrightnessContrastFilter::gamma
double gamma() const
Returns current gamma value.
Definition: qgsbrightnesscontrastfilter.h:101
QgsMapLayer::setDataUrl
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:336
QgsRasterLayerProperties::SLD
@ SLD
Definition: qgsrasterlayerproperties.h:65
QgsFields::lookupField
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Definition: qgsfields.cpp:344
QgsMapCanvas::mapUnitsPerPixel
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
Definition: qgsmapcanvas.cpp:2160
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map.
Definition: qgsmapsettings.h:88
QgsRasterTransparency::TransparentThreeValuePixel::green
double green
Definition: qgsrastertransparency.h:48
QgsRasterLayer::rasterType
LayerType rasterType()
Returns the raster layer type (which is a read only property).
Definition: qgsrasterlayer.h:233
QgsRasterRenderer::setOpacity
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
Definition: qgsrasterrenderer.h:81
QgsMapLayer::setShortName
void setShortName(const QString &shortName)
Sets the short name of the layer used by QGIS Server to identify the layer.
Definition: qgsmaplayer.h:271
QgsProviderRegistry::instance
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Definition: qgsproviderregistry.cpp:48
QgsMapLayer::attribution
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:383
QgsMapLayer::metadataUrlType
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:439
QgsMapLayer::loadNamedStyle
virtual QString loadNamedStyle(const QString &uri, bool &resultFlag, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
Definition: qgsmaplayer.cpp:928
QgsApplication::reportStyleSheet
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
Definition: qgsapplication.cpp:1363
QgsRasterInterface::capabilities
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
Definition: qgsrasterinterface.h:206
QgsMapLayer::loadNamedMetadata
virtual QString loadNamedMetadata(const QString &uri, bool &resultFlag)
Retrieve a named metadata for this layer if one exists (either as a .qmd file on disk or as a record ...
Definition: qgsmaplayer.cpp:1145
QgsRasterDataProviderTemporalCapabilities::FindClosestMatchToEndOfRange
@ FindClosestMatchToEndOfRange
Match the start of the temporal range to the least previous closest datetime.
Definition: qgsrasterdataprovidertemporalcapabilities.h:57
QgsRasterDataProvider
Base class for raster data providers.
Definition: qgsrasterdataprovider.h:89
QgsRasterRendererRegistry::renderersList
QStringList renderersList() const
Definition: qgsrasterrendererregistry.cpp:93
qgsproject.h
QgsMapLayer::setLegend
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
Definition: qgsmaplayer.cpp:1784
QgsOptionsDialogBase::restoreOptionsBaseUi
void restoreOptionsBaseUi(const QString &title=QString())
Restore the base ui.
Definition: qgsoptionsdialogbase.cpp:161
QgsMapLayer::metadata
QgsLayerMetadata metadata
Definition: qgsmaplayer.h:88
QgsRasterLayerProperties::optionsStackedWidget_CurrentChanged
void optionsStackedWidget_CurrentChanged(int index) override
auto slot executed when the active page in the main widget stack is changed
Definition: qgsrasterlayerproperties.cpp:1819
QgsProviderMetadata::decodeUri
virtual QVariantMap decodeUri(const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
Definition: qgsprovidermetadata.cpp:128
QgsFieldComboBox::fieldChanged
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
qgsmaptoolemitpoint.h
QgsMapTool::deactivated
void deactivated()
signal emitted once the map tool is deactivated
QgsRasterDataProviderTemporalCapabilities::MatchExactUsingEndOfRange
@ MatchExactUsingEndOfRange
Match the end of the temporal range to a corresponding layer or band, and only use exact matching res...
Definition: qgsrasterdataprovidertemporalcapabilities.h:55
qgsrasterdataprovider.h
QgsRasterRenderer::opacity
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
Definition: qgsrasterrenderer.h:88
Qgis::Float64
@ Float64
Sixty four bit floating point (double)
Definition: qgis.h:110
QgsRasterRendererRegistryEntry::widgetCreateFunction
QgsRasterRendererWidgetCreateFunc widgetCreateFunction
Definition: qgsrasterrendererregistry.h:57