23#include "moc_qgsresamplingutils.cpp" 
   29#include <QDoubleSpinBox> 
   34QgsResamplingUtils::QgsResamplingUtils() = 
default;
 
   36void QgsResamplingUtils::initWidgets( 
QgsRasterLayer *rasterLayer, QComboBox *zoomedInResamplingComboBox, QComboBox *zoomedOutResamplingComboBox, QDoubleSpinBox *maximumOversamplingSpinBox, QCheckBox *cbEarlyResampling )
 
   38  mRasterLayer = rasterLayer;
 
   39  mZoomedInResamplingComboBox = zoomedInResamplingComboBox;
 
   40  mZoomedOutResamplingComboBox = zoomedOutResamplingComboBox;
 
   41  mMaximumOversamplingSpinBox = maximumOversamplingSpinBox;
 
   42  mCbEarlyResampling = cbEarlyResampling;
 
   44  for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
 
   51  if ( mCbEarlyResampling->isChecked() )
 
   53    addExtraEarlyResamplingMethodsToCombos();
 
   56  QObject::connect( mCbEarlyResampling, &QCheckBox::toggled, 
this, [
this]( 
bool state ) {
 
   58      addExtraEarlyResamplingMethodsToCombos();
 
   60      removeExtraEarlyResamplingMethodsFromCombos();
 
   64void QgsResamplingUtils::refreshWidgetsFromLayer()
 
   67  mCbEarlyResampling->setVisible(
 
   72  switch ( mRasterLayer->resamplingStage() )
 
   75      removeExtraEarlyResamplingMethodsFromCombos();
 
   78      addExtraEarlyResamplingMethodsToCombos();
 
   84    mZoomedInResamplingComboBox->setCurrentIndex( mZoomedInResamplingComboBox->findData( 
static_cast<int>( provider->
zoomedInResamplingMethod() ) ) );
 
   85    mZoomedOutResamplingComboBox->setCurrentIndex( mZoomedOutResamplingComboBox->findData( 
static_cast<int>( provider->
zoomedOutResamplingMethod() ) ) );
 
   96      if ( zoomedInResampler )
 
   98        if ( zoomedInResampler->
type() == QLatin1String( 
"bilinear" ) )
 
  102        else if ( zoomedInResampler->
type() == QLatin1String( 
"cubic" ) )
 
  113      if ( zoomedOutResampler )
 
  115        if ( zoomedOutResampler->
type() == QLatin1String( 
"bilinear" ) )
 
  119        else if ( zoomedOutResampler->
type() == QLatin1String( 
"cubic" ) )
 
  128      mMaximumOversamplingSpinBox->setValue( resampleFilter->
maxOversampling() );
 
  134void QgsResamplingUtils::refreshLayerFromWidgets()
 
  137    mZoomedInResamplingComboBox->itemData( mZoomedInResamplingComboBox->currentIndex() ).toInt()
 
  140    mZoomedOutResamplingComboBox->itemData( mZoomedOutResamplingComboBox->currentIndex() ).toInt()
 
  154  if ( resampleFilter )
 
  156    std::unique_ptr<QgsRasterResampler> zoomedInResampler;
 
  159    switch ( zoomedInMethod )
 
  165        zoomedInResampler = std::make_unique<QgsBilinearRasterResampler>();
 
  169        zoomedInResampler = std::make_unique<QgsCubicRasterResampler>();
 
  186    std::unique_ptr<QgsRasterResampler> zoomedOutResampler;
 
  189    switch ( zoomedOutMethod )
 
  195        zoomedOutResampler = std::make_unique<QgsBilinearRasterResampler>();
 
  199        zoomedOutResampler = std::make_unique<QgsCubicRasterResampler>();
 
  219void QgsResamplingUtils::addExtraEarlyResamplingMethodsToCombos()
 
  224  for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
 
  234void QgsResamplingUtils::removeExtraEarlyResamplingMethodsFromCombos()
 
  239  for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
 
  250      combo->removeItem( combo->findData( 
static_cast<int>( method ) ) );
 
@ Provider
Resampling occurs in Provider.
 
@ ResampleFilter
Resampling occurs in ResamplingFilter.
 
@ ProviderHintCanPerformProviderResampling
Provider can perform resampling (to be opposed to post rendering resampling)
 
RasterResamplingMethod
Resampling method for raster provider-level resampling.
 
@ Lanczos
Lanczos windowed sinc interpolation (6x6 kernel)
 
@ Nearest
Nearest-neighbour resampling.
 
@ Mode
Mode (selects the value which appears most often of all the sampled points)
 
@ Bilinear
Bilinear (2x2 kernel) resampling.
 
@ Average
Average resampling.
 
@ CubicSpline
Cubic B-Spline Approximation (4x4 kernel)
 
@ Cubic
Cubic Convolution Approximation (4x4 kernel) resampling.
 
Base class for raster data providers.
 
Qgis::RasterResamplingMethod zoomedInResamplingMethod() const
Returns resampling method for zoomed-in operations.
 
virtual bool setZoomedInResamplingMethod(Qgis::RasterResamplingMethod method)
Set resampling method to apply for zoomed-in operations.
 
virtual bool setZoomedOutResamplingMethod(Qgis::RasterResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
 
virtual bool setMaxOversampling(double factor)
Sets maximum oversampling factor for zoomed-out operations.
 
double maxOversampling() const
Returns maximum oversampling factor for zoomed-out operations.
 
Qgis::RasterResamplingMethod zoomedOutResamplingMethod() const
Returns resampling method for zoomed-out operations.
 
virtual Qgis::RasterProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
 
Represents a raster layer.
 
Resample filter pipe for rasters.
 
void setZoomedOutResampler(QgsRasterResampler *r)
Sets resampler for zoomed out scales. Takes ownership of the object.
 
const QgsRasterResampler * zoomedInResampler() const
 
void setMaxOversampling(double os)
 
const QgsRasterResampler * zoomedOutResampler() const
 
double maxOversampling() const
 
void setZoomedInResampler(QgsRasterResampler *r)
Sets resampler for zoomed in scales. Takes ownership of the object.
 
Interface for resampling rasters (e.g.
 
virtual QString type() const =0
Gets a descriptive type identifier for this raster resampler.