Skip to content

Commit 2c9320a

Browse files
committed
Expose maxOversampling parameter to user
1 parent 3b36620 commit 2c9320a

5 files changed

+48
-3
lines changed

src/app/qgsrasterlayerproperties.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
327327
{
328328
mZoomedOutResamplingComboBox->setCurrentIndex( 0 );
329329
}
330+
mMaximumOversamplingSpinBox->setValue( renderer->maxOversampling() );
330331
}
331332
} // QgsRasterLayerProperties ctor
332333

@@ -1520,6 +1521,11 @@ void QgsRasterLayerProperties::apply()
15201521
rasterRenderer->setZoomedOutResampler( zoomedOutResampler );
15211522
}
15221523

1524+
if ( rasterRenderer )
1525+
{
1526+
rasterRenderer->setMaxOversampling( mMaximumOversamplingSpinBox->value() );
1527+
}
1528+
15231529

15241530
//get the thumbnail for the layer
15251531
QPixmap myQPixmap = QPixmap( pixmapThumbnail->width(), pixmapThumbnail->height() );

src/core/raster/qgsrasterlayer.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -3188,6 +3188,22 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
31883188
}
31893189

31903190
//resampler
3191+
3192+
//max oversampling
3193+
if ( mRenderer )
3194+
{
3195+
QDomElement maxOversamplingElem = mnl.firstChildElement( "MaxOversampling" );
3196+
if ( !maxOversamplingElem.isNull() )
3197+
{
3198+
bool conversion;
3199+
double maxOversampling = maxOversamplingElem.text().toDouble( &conversion );
3200+
if ( conversion )
3201+
{
3202+
mRenderer->setMaxOversampling( maxOversampling );
3203+
}
3204+
}
3205+
}
3206+
31913207
QDomElement zoomedInResamplerElem = mnl.firstChildElement( "zoomedInResampler" );
31923208
if ( mRenderer && !zoomedInResamplerElem.isNull() )
31933209
{
@@ -3348,6 +3364,12 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum
33483364
// resampler
33493365
if ( mRenderer )
33503366
{
3367+
//Max oversampling
3368+
QDomElement maxOversamplingElem = document.createElement( "MaxOversampling" );
3369+
QDomText maxOversamplingText = document.createTextNode( QString::number( mRenderer->maxOversampling() ) );
3370+
maxOversamplingElem.appendChild( maxOversamplingText );
3371+
rasterPropertiesElement.appendChild( maxOversamplingElem );
3372+
33513373
QString zoomedInResamplerString = "nearest";
33523374
const QgsRasterResampler* zoomedInResampler = mRenderer->zoomedInResampler();
33533375
if ( zoomedInResampler )

src/core/raster/qgsrasterrenderer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <QPainter>
2626

2727
QgsRasterRenderer::QgsRasterRenderer( QgsRasterDataProvider* provider ): mProvider( provider ), mZoomedInResampler( 0 ), mZoomedOutResampler( 0 ),
28-
mOpacity( 1.0 ), mRasterTransparency( 0 ), mAlphaBand( -1 ), mInvertColor( false )
28+
mOpacity( 1.0 ), mRasterTransparency( 0 ), mAlphaBand( -1 ), mInvertColor( false ), mMaxOversampling( 2.0 )
2929
{
3030
}
3131

@@ -76,7 +76,7 @@ void QgsRasterRenderer::startRasterRead( int bandNumber, QgsRasterViewPort* view
7676
providerExtent = t.transformBoundingBox( providerExtent );
7777
}
7878
double pixelRatio = mapToPixel->mapUnitsPerPixel() / ( providerExtent.width() / mProvider->xSize() );
79-
oversampling = ( pixelRatio > 4.0 ) ? 4.0 : pixelRatio;
79+
oversampling = ( pixelRatio > mMaxOversampling ) ? mMaxOversampling : pixelRatio;
8080
}
8181

8282
//set oversampling back to 1.0 if no resampler for zoomed in / zoomed out (nearest neighbour)

src/core/raster/qgsrasterrenderer.h

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class QgsRasterRenderer
6969
void setZoomedOutResampler( QgsRasterResampler* r );
7070
const QgsRasterResampler* zoomedOutResampler() const { return mZoomedOutResampler; }
7171

72+
void setMaxOversampling( double os ) { mMaxOversampling = os; }
73+
double maxOversampling() const { return mMaxOversampling; }
74+
7275
protected:
7376
inline double readValue( void *data, QgsRasterDataProvider::DataType type, int index );
7477

@@ -110,6 +113,9 @@ class QgsRasterRenderer
110113

111114
bool mInvertColor;
112115

116+
/**Maximum boundary for oversampling (to avoid too much data traffic). Default: 2.0*/
117+
double mMaxOversampling;
118+
113119
private:
114120
/**Remove part into and release memory*/
115121
void removePartInfo( int bandNumer );

src/ui/qgsrasterlayerpropertiesbase.ui

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>691</width>
10-
<height>598</height>
10+
<height>617</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -776,6 +776,16 @@
776776
<item row="3" column="0">
777777
<widget class="QComboBox" name="mZoomedOutResamplingComboBox"/>
778778
</item>
779+
<item row="5" column="0">
780+
<widget class="QDoubleSpinBox" name="mMaximumOversamplingSpinBox"/>
781+
</item>
782+
<item row="4" column="0">
783+
<widget class="QLabel" name="mMaximumOversamplingLabel">
784+
<property name="text">
785+
<string>Maximum oversampling</string>
786+
</property>
787+
</widget>
788+
</item>
779789
</layout>
780790
</widget>
781791
</item>
@@ -1834,6 +1844,7 @@ p, li { white-space: pre-wrap; }
18341844
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
18351845
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
18361846
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
1847+
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
18371848
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;&quot;&gt;&lt;/p&gt;
18381849
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;&quot;&gt;&lt;/p&gt;
18391850
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;&quot;&gt;&lt;/p&gt;

0 commit comments

Comments
 (0)