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