Skip to content
Permalink
Browse files

Expose maxOversampling parameter to user

  • Loading branch information
mhugent committed Jan 28, 2012
1 parent 3b36620 commit 2c9320a0d5ac43fb8bfec18c6e1b0005665c0a7e
@@ -327,6 +327,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
{
mZoomedOutResamplingComboBox->setCurrentIndex( 0 );
}
mMaximumOversamplingSpinBox->setValue( renderer->maxOversampling() );
}
} // QgsRasterLayerProperties ctor

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

if ( rasterRenderer )
{
rasterRenderer->setMaxOversampling( mMaximumOversamplingSpinBox->value() );
}


//get the thumbnail for the layer
QPixmap myQPixmap = QPixmap( pixmapThumbnail->width(), pixmapThumbnail->height() );
@@ -3188,6 +3188,22 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
}

//resampler

//max oversampling
if ( mRenderer )
{
QDomElement maxOversamplingElem = mnl.firstChildElement( "MaxOversampling" );
if ( !maxOversamplingElem.isNull() )
{
bool conversion;
double maxOversampling = maxOversamplingElem.text().toDouble( &conversion );
if ( conversion )
{
mRenderer->setMaxOversampling( maxOversampling );
}
}
}

QDomElement zoomedInResamplerElem = mnl.firstChildElement( "zoomedInResampler" );
if ( mRenderer && !zoomedInResamplerElem.isNull() )
{
@@ -3348,6 +3364,12 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum
// resampler
if ( mRenderer )
{
//Max oversampling
QDomElement maxOversamplingElem = document.createElement( "MaxOversampling" );
QDomText maxOversamplingText = document.createTextNode( QString::number( mRenderer->maxOversampling() ) );
maxOversamplingElem.appendChild( maxOversamplingText );
rasterPropertiesElement.appendChild( maxOversamplingElem );

QString zoomedInResamplerString = "nearest";
const QgsRasterResampler* zoomedInResampler = mRenderer->zoomedInResampler();
if ( zoomedInResampler )
@@ -25,7 +25,7 @@
#include <QPainter>

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

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

//set oversampling back to 1.0 if no resampler for zoomed in / zoomed out (nearest neighbour)
@@ -69,6 +69,9 @@ class QgsRasterRenderer
void setZoomedOutResampler( QgsRasterResampler* r );
const QgsRasterResampler* zoomedOutResampler() const { return mZoomedOutResampler; }

void setMaxOversampling( double os ) { mMaxOversampling = os; }
double maxOversampling() const { return mMaxOversampling; }

protected:
inline double readValue( void *data, QgsRasterDataProvider::DataType type, int index );

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

bool mInvertColor;

/**Maximum boundary for oversampling (to avoid too much data traffic). Default: 2.0*/
double mMaxOversampling;

private:
/**Remove part into and release memory*/
void removePartInfo( int bandNumer );
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>691</width>
<height>598</height>
<height>617</height>
</rect>
</property>
<property name="windowTitle">
@@ -776,6 +776,16 @@
<item row="3" column="0">
<widget class="QComboBox" name="mZoomedOutResamplingComboBox"/>
</item>
<item row="5" column="0">
<widget class="QDoubleSpinBox" name="mMaximumOversamplingSpinBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mMaximumOversamplingLabel">
<property name="text">
<string>Maximum oversampling</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -1834,6 +1844,7 @@ p, li { white-space: pre-wrap; }
&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;
&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;
&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;
&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;
&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;
&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;
&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 comments on commit 2c9320a

Please sign in to comment.
You can’t perform that action at this time.