29#include <QDoubleSpinBox>
33#include "moc_qgsresamplingutils.cpp"
35using namespace Qt::StringLiterals;
39QgsResamplingUtils::QgsResamplingUtils() =
default;
41void QgsResamplingUtils::initWidgets(
42 QgsRasterLayer *rasterLayer, QComboBox *zoomedInResamplingComboBox, QComboBox *zoomedOutResamplingComboBox, QDoubleSpinBox *maximumOversamplingSpinBox, QCheckBox *cbEarlyResampling
45 mRasterLayer = rasterLayer;
46 mZoomedInResamplingComboBox = zoomedInResamplingComboBox;
47 mZoomedOutResamplingComboBox = zoomedOutResamplingComboBox;
48 mMaximumOversamplingSpinBox = maximumOversamplingSpinBox;
49 mCbEarlyResampling = cbEarlyResampling;
51 for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
58 if ( mCbEarlyResampling->isChecked() )
60 addExtraEarlyResamplingMethodsToCombos();
63 QObject::connect( mCbEarlyResampling, &QCheckBox::toggled,
this, [
this](
bool state ) {
65 addExtraEarlyResamplingMethodsToCombos();
67 removeExtraEarlyResamplingMethodsFromCombos();
71void QgsResamplingUtils::refreshWidgetsFromLayer()
77 switch ( mRasterLayer->resamplingStage() )
80 removeExtraEarlyResamplingMethodsFromCombos();
83 addExtraEarlyResamplingMethodsToCombos();
89 mZoomedInResamplingComboBox->setCurrentIndex( mZoomedInResamplingComboBox->findData(
static_cast<int>( provider->
zoomedInResamplingMethod() ) ) );
90 mZoomedOutResamplingComboBox->setCurrentIndex( mZoomedOutResamplingComboBox->findData(
static_cast<int>( provider->
zoomedOutResamplingMethod() ) ) );
101 if ( zoomedInResampler )
103 if ( zoomedInResampler->
type() ==
"bilinear"_L1 )
107 else if ( zoomedInResampler->
type() ==
"cubic"_L1 )
118 if ( zoomedOutResampler )
120 if ( zoomedOutResampler->
type() ==
"bilinear"_L1 )
124 else if ( zoomedOutResampler->
type() ==
"cubic"_L1 )
133 mMaximumOversamplingSpinBox->setValue( resampleFilter->
maxOversampling() );
139void QgsResamplingUtils::refreshLayerFromWidgets()
155 if ( resampleFilter )
157 std::unique_ptr<QgsRasterResampler> zoomedInResampler;
160 switch ( zoomedInMethod )
166 zoomedInResampler = std::make_unique<QgsBilinearRasterResampler>();
170 zoomedInResampler = std::make_unique<QgsCubicRasterResampler>();
187 std::unique_ptr<QgsRasterResampler> zoomedOutResampler;
190 switch ( zoomedOutMethod )
196 zoomedOutResampler = std::make_unique<QgsBilinearRasterResampler>();
200 zoomedOutResampler = std::make_unique<QgsCubicRasterResampler>();
220void QgsResamplingUtils::addExtraEarlyResamplingMethodsToCombos()
225 for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
235void QgsResamplingUtils::removeExtraEarlyResamplingMethodsFromCombos()
240 for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
245 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.