28 #include <QDoubleSpinBox> 
   33 QgsResamplingUtils::QgsResamplingUtils() = 
default;
 
   36                                       QComboBox  *zoomedInResamplingComboBox,
 
   37                                       QComboBox *zoomedOutResamplingComboBox,
 
   38                                       QDoubleSpinBox *maximumOversamplingSpinBox,
 
   39                                       QCheckBox *cbEarlyResampling )
 
   41   mRasterLayer = rasterLayer;
 
   42   mZoomedInResamplingComboBox = zoomedInResamplingComboBox;
 
   43   mZoomedOutResamplingComboBox = zoomedOutResamplingComboBox;
 
   44   mMaximumOversamplingSpinBox = maximumOversamplingSpinBox;
 
   45   mCbEarlyResampling = cbEarlyResampling;
 
   47   for ( QComboBox *combo :  {mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
 
   54   if ( mCbEarlyResampling->isChecked() )
 
   56     addExtraEarlyResamplingMethodsToCombos();
 
   59   QObject::connect( mCbEarlyResampling, &QCheckBox::toggled, 
this, [ = ]( 
bool state )
 
   62       addExtraEarlyResamplingMethodsToCombos();
 
   64       removeExtraEarlyResamplingMethodsFromCombos();
 
   68 void QgsResamplingUtils::refreshWidgetsFromLayer()
 
   71   mCbEarlyResampling->setVisible(
 
   75   switch ( mRasterLayer->resamplingStage() )
 
   78       removeExtraEarlyResamplingMethodsFromCombos();
 
   81       addExtraEarlyResamplingMethodsToCombos();
 
   87     mZoomedInResamplingComboBox->setCurrentIndex( mZoomedInResamplingComboBox->findData( 
static_cast<int>( provider->
zoomedInResamplingMethod() ) ) );
 
   88     mZoomedOutResamplingComboBox->setCurrentIndex( mZoomedOutResamplingComboBox->findData( 
static_cast<int>( provider->
zoomedOutResamplingMethod() ) ) );
 
   99       if ( zoomedInResampler )
 
  101         if ( zoomedInResampler->
type() == QLatin1String( 
"bilinear" ) )
 
  105         else if ( zoomedInResampler->
type() == QLatin1String( 
"cubic" ) )
 
  116       if ( zoomedOutResampler )
 
  118         if ( zoomedOutResampler->
type() == QLatin1String( 
"bilinear" ) )
 
  122         else if ( zoomedOutResampler->
type() == QLatin1String( 
"cubic" ) )
 
  131       mMaximumOversamplingSpinBox->setValue( resampleFilter->
maxOversampling() );
 
  137 void QgsResamplingUtils::refreshLayerFromWidgets()
 
  141       mZoomedInResamplingComboBox->itemData( mZoomedInResamplingComboBox->currentIndex() ).toInt() );
 
  144       mZoomedOutResamplingComboBox->itemData( mZoomedOutResamplingComboBox->currentIndex() ).toInt() );
 
  157   if ( resampleFilter )
 
  159     std::unique_ptr< QgsRasterResampler > zoomedInResampler;
 
  161     switch ( zoomedInMethod )
 
  167         zoomedInResampler = qgis::make_unique< QgsBilinearRasterResampler >();
 
  171         zoomedInResampler = qgis::make_unique< QgsCubicRasterResampler >();
 
  187     std::unique_ptr< QgsRasterResampler > zoomedOutResampler;
 
  189     switch ( zoomedOutMethod )
 
  195         zoomedOutResampler = qgis::make_unique< QgsBilinearRasterResampler >();
 
  199         zoomedOutResampler = qgis::make_unique< QgsCubicRasterResampler >();
 
  218 void QgsResamplingUtils::addExtraEarlyResamplingMethodsToCombos()
 
  223   for ( QComboBox *combo : {mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
 
  233 void QgsResamplingUtils::removeExtraEarlyResamplingMethodsFromCombos()
 
  238   for ( QComboBox *combo : {mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
 
  249       combo->removeItem( combo->findData( 
static_cast< int >( method ) ) );
 
Base class for raster data providers.
ResamplingMethod zoomedOutResamplingMethod() const
Returns resampling method for zoomed-out operations.
virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
virtual bool setMaxOversampling(double factor)
Sets maximum oversampling factor for zoomed-out operations.
double maxOversampling() const
Returns maximum oversampling factor for zoomed-out operations.
@ ProviderHintCanPerformProviderResampling
Provider can perform resampling (to be opposed to post rendering resampling) (since QGIS 3....
virtual bool setZoomedInResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-in operations.
ResamplingMethod zoomedInResamplingMethod() const
Returns resampling method for zoomed-in operations.
ResamplingMethod
Resampling method for 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.
virtual bool setZoomedOutResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
Represents a raster layer.
@ Provider
Resampling occurs in Provider.
@ ResampleFilter
Resampling occurs in ResamplingFilter.
Resample filter pipe for rasters.
void setZoomedOutResampler(QgsRasterResampler *r)
Sets resampler for zoomed out scales. Takes ownership of the object.
void setMaxOversampling(double os)
const QgsRasterResampler * zoomedOutResampler() const
double maxOversampling() const
const QgsRasterResampler * zoomedInResampler() 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.