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 = std::make_unique< QgsBilinearRasterResampler >();
171 zoomedInResampler = std::make_unique< QgsCubicRasterResampler >();
187 std::unique_ptr< QgsRasterResampler > zoomedOutResampler;
189 switch ( zoomedOutMethod )
195 zoomedOutResampler = std::make_unique< QgsBilinearRasterResampler >();
199 zoomedOutResampler = std::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 ) ) );