29#include <QDoubleSpinBox>
32#include "moc_qgsresamplingutils.cpp"
36QgsResamplingUtils::QgsResamplingUtils() =
default;
38void QgsResamplingUtils::initWidgets(
QgsRasterLayer *rasterLayer, QComboBox *zoomedInResamplingComboBox, QComboBox *zoomedOutResamplingComboBox, QDoubleSpinBox *maximumOversamplingSpinBox, QCheckBox *cbEarlyResampling )
40 mRasterLayer = rasterLayer;
41 mZoomedInResamplingComboBox = zoomedInResamplingComboBox;
42 mZoomedOutResamplingComboBox = zoomedOutResamplingComboBox;
43 mMaximumOversamplingSpinBox = maximumOversamplingSpinBox;
44 mCbEarlyResampling = cbEarlyResampling;
46 for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
53 if ( mCbEarlyResampling->isChecked() )
55 addExtraEarlyResamplingMethodsToCombos();
58 QObject::connect( mCbEarlyResampling, &QCheckBox::toggled,
this, [
this](
bool state ) {
60 addExtraEarlyResamplingMethodsToCombos();
62 removeExtraEarlyResamplingMethodsFromCombos();
66void QgsResamplingUtils::refreshWidgetsFromLayer()
69 mCbEarlyResampling->setVisible(
74 switch ( mRasterLayer->resamplingStage() )
77 removeExtraEarlyResamplingMethodsFromCombos();
80 addExtraEarlyResamplingMethodsToCombos();
86 mZoomedInResamplingComboBox->setCurrentIndex( mZoomedInResamplingComboBox->findData(
static_cast<int>( provider->
zoomedInResamplingMethod() ) ) );
87 mZoomedOutResamplingComboBox->setCurrentIndex( mZoomedOutResamplingComboBox->findData(
static_cast<int>( provider->
zoomedOutResamplingMethod() ) ) );
98 if ( zoomedInResampler )
100 if ( zoomedInResampler->
type() == QLatin1String(
"bilinear" ) )
104 else if ( zoomedInResampler->
type() == QLatin1String(
"cubic" ) )
115 if ( zoomedOutResampler )
117 if ( zoomedOutResampler->
type() == QLatin1String(
"bilinear" ) )
121 else if ( zoomedOutResampler->
type() == QLatin1String(
"cubic" ) )
130 mMaximumOversamplingSpinBox->setValue( resampleFilter->
maxOversampling() );
136void QgsResamplingUtils::refreshLayerFromWidgets()
139 mZoomedInResamplingComboBox->itemData( mZoomedInResamplingComboBox->currentIndex() ).toInt()
142 mZoomedOutResamplingComboBox->itemData( mZoomedOutResamplingComboBox->currentIndex() ).toInt()
156 if ( resampleFilter )
158 std::unique_ptr<QgsRasterResampler> zoomedInResampler;
161 switch ( zoomedInMethod )
167 zoomedInResampler = std::make_unique<QgsBilinearRasterResampler>();
171 zoomedInResampler = std::make_unique<QgsCubicRasterResampler>();
188 std::unique_ptr<QgsRasterResampler> zoomedOutResampler;
191 switch ( zoomedOutMethod )
197 zoomedOutResampler = std::make_unique<QgsBilinearRasterResampler>();
201 zoomedOutResampler = std::make_unique<QgsCubicRasterResampler>();
221void QgsResamplingUtils::addExtraEarlyResamplingMethodsToCombos()
226 for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
236void QgsResamplingUtils::removeExtraEarlyResamplingMethodsFromCombos()
241 for ( QComboBox *combo : { mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
252 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.