23#include "moc_qgsresamplingutils.cpp"
29#include <QDoubleSpinBox>
34QgsResamplingUtils::QgsResamplingUtils() =
default;
37 QComboBox *zoomedInResamplingComboBox,
38 QComboBox *zoomedOutResamplingComboBox,
39 QDoubleSpinBox *maximumOversamplingSpinBox,
40 QCheckBox *cbEarlyResampling )
42 mRasterLayer = rasterLayer;
43 mZoomedInResamplingComboBox = zoomedInResamplingComboBox;
44 mZoomedOutResamplingComboBox = zoomedOutResamplingComboBox;
45 mMaximumOversamplingSpinBox = maximumOversamplingSpinBox;
46 mCbEarlyResampling = cbEarlyResampling;
48 for ( QComboBox *combo : {mZoomedInResamplingComboBox, mZoomedOutResamplingComboBox } )
55 if ( mCbEarlyResampling->isChecked() )
57 addExtraEarlyResamplingMethodsToCombos();
60 QObject::connect( mCbEarlyResampling, &QCheckBox::toggled,
this, [ = ](
bool state )
63 addExtraEarlyResamplingMethodsToCombos();
65 removeExtraEarlyResamplingMethodsFromCombos();
69void QgsResamplingUtils::refreshWidgetsFromLayer()
72 mCbEarlyResampling->setVisible(
76 switch ( mRasterLayer->resamplingStage() )
79 removeExtraEarlyResamplingMethodsFromCombos();
82 addExtraEarlyResamplingMethodsToCombos();
88 mZoomedInResamplingComboBox->setCurrentIndex( mZoomedInResamplingComboBox->findData(
static_cast<int>( provider->
zoomedInResamplingMethod() ) ) );
89 mZoomedOutResamplingComboBox->setCurrentIndex( mZoomedOutResamplingComboBox->findData(
static_cast<int>( provider->
zoomedOutResamplingMethod() ) ) );
100 if ( zoomedInResampler )
102 if ( zoomedInResampler->
type() == QLatin1String(
"bilinear" ) )
106 else if ( zoomedInResampler->
type() == QLatin1String(
"cubic" ) )
117 if ( zoomedOutResampler )
119 if ( zoomedOutResampler->
type() == QLatin1String(
"bilinear" ) )
123 else if ( zoomedOutResampler->
type() == QLatin1String(
"cubic" ) )
132 mMaximumOversamplingSpinBox->setValue( resampleFilter->
maxOversampling() );
138void QgsResamplingUtils::refreshLayerFromWidgets()
142 mZoomedInResamplingComboBox->itemData( mZoomedInResamplingComboBox->currentIndex() ).toInt() );
145 mZoomedOutResamplingComboBox->itemData( mZoomedOutResamplingComboBox->currentIndex() ).toInt() );
158 if ( resampleFilter )
160 std::unique_ptr< QgsRasterResampler > zoomedInResampler;
162 switch ( zoomedInMethod )
168 zoomedInResampler = std::make_unique< QgsBilinearRasterResampler >();
172 zoomedInResampler = std::make_unique< QgsCubicRasterResampler >();
188 std::unique_ptr< QgsRasterResampler > zoomedOutResampler;
190 switch ( zoomedOutMethod )
196 zoomedOutResampler = std::make_unique< QgsBilinearRasterResampler >();
200 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)
Base class for raster data providers.
ResamplingMethod zoomedOutResamplingMethod() const
Returns resampling method 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.
virtual Qgis::RasterProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
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.
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.