Skip to content
Permalink
Browse files
Add type name to renderers. Restore the corresponding renderer widget…
… in raster properties
  • Loading branch information
mhugent committed Feb 20, 2012
1 parent 9b8423e commit a14beda830bb1ef2a47d882028861a58d7e4c079
@@ -345,6 +345,15 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
{
mRenderTypeComboBox->addItem( rendererIt->visibleName, rendererIt->name );
}

if ( renderer )
{
int widgetIndex = mRenderTypeComboBox->findData( renderer->type() );
if ( widgetIndex != -1 )
{
mRenderTypeComboBox->setCurrentIndex( widgetIndex );
}
}
on_mRenderTypeComboBox_currentIndexChanged( mRenderTypeComboBox->currentIndex() );
} // QgsRasterLayerProperties ctor

@@ -26,7 +26,7 @@ QgsMultiBandColorRenderer::QgsMultiBandColorRenderer( QgsRasterDataProvider* pro
QgsContrastEnhancement* redEnhancement,
QgsContrastEnhancement* greenEnhancement,
QgsContrastEnhancement* blueEnhancement ):
QgsRasterRenderer( provider ), mRedBand( redBand ), mGreenBand( greenBand ), mBlueBand( blueBand ),
QgsRasterRenderer( provider, "multibandcolor" ), mRedBand( redBand ), mGreenBand( greenBand ), mBlueBand( blueBand ),
mRedContrastEnhancement( redEnhancement ), mGreenContrastEnhancement( greenEnhancement ), mBlueContrastEnhancement( blueEnhancement )
{
}
@@ -23,7 +23,7 @@

QgsPalettedRasterRenderer::QgsPalettedRasterRenderer( QgsRasterDataProvider* provider, int bandNumber,
QColor* colorArray, int nColors ):
QgsRasterRenderer( provider ), mBandNumber( bandNumber ), mColors( colorArray ), mNColors( nColors )
QgsRasterRenderer( provider, "paletted" ), mBandNumber( bandNumber ), mColors( colorArray ), mNColors( nColors )
{
}

@@ -24,8 +24,9 @@
#include <QImage>
#include <QPainter>

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

@@ -43,8 +43,10 @@ class QgsRasterRenderer
QgsRasterProjector* prj; //raster projector (or 0 if no reprojection is done)
};

QgsRasterRenderer( QgsRasterDataProvider* provider );
QgsRasterRenderer( QgsRasterDataProvider* provider, const QString& type );
virtual ~QgsRasterRenderer();

virtual QString type() const { return mType; }
virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel ) = 0;

bool usesTransparency( QgsCoordinateReferenceSystem& srcSRS, QgsCoordinateReferenceSystem& dstSRS ) const;
@@ -97,6 +99,7 @@ class QgsRasterRenderer


QgsRasterDataProvider* mProvider;
QString mType;
/**Resampler used if screen resolution is higher than raster resolution (zoomed in). 0 means no resampling (nearest neighbour)*/
QgsRasterResampler* mZoomedInResampler;
/**Resampler used if raster resolution is higher than raster resolution (zoomed out). 0 mean no resampling (nearest neighbour)*/
@@ -20,7 +20,7 @@
#include <QImage>

QgsSingleBandColorDataRenderer::QgsSingleBandColorDataRenderer( QgsRasterDataProvider* provider, int band ):
QgsRasterRenderer( provider ), mBand( band )
QgsRasterRenderer( provider, "singlebandcolordata" ), mBand( band )
{

}
@@ -29,6 +29,11 @@ QgsSingleBandColorDataRenderer::~QgsSingleBandColorDataRenderer()
{
}

QgsRasterRenderer* QgsSingleBandColorDataRenderer::create( const QDomElement& elem )
{
return 0;
}

void QgsSingleBandColorDataRenderer::draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel )
{
if ( !p || !mProvider || !viewPort || !theQgsMapToPixel )
@@ -20,12 +20,16 @@

#include "qgsrasterrenderer.h"

class QDomElement;

class QgsSingleBandColorDataRenderer: public QgsRasterRenderer
{
public:
QgsSingleBandColorDataRenderer( QgsRasterDataProvider* provider, int band );
~QgsSingleBandColorDataRenderer();

static QgsRasterRenderer* create( const QDomElement& elem );

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

private:
@@ -21,14 +21,19 @@
#include <QImage>

QgsSingleBandGrayRenderer::QgsSingleBandGrayRenderer( QgsRasterDataProvider* provider, int grayBand ):
QgsRasterRenderer( provider ), mGrayBand( grayBand ), mContrastEnhancement( 0 )
QgsRasterRenderer( provider, "singlebandgray" ), mGrayBand( grayBand ), mContrastEnhancement( 0 )
{
}

QgsSingleBandGrayRenderer::~QgsSingleBandGrayRenderer()
{
}

QgsRasterRenderer* QgsSingleBandGrayRenderer::create( const QDomElement& elem )
{
return 0;
}

void QgsSingleBandGrayRenderer::draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel )
{
if ( !p || !mProvider || !viewPort || !theQgsMapToPixel )
@@ -21,13 +21,16 @@
#include "qgsrasterrenderer.h"

class QgsContrastEnhancement;
class QDomElement;

class QgsSingleBandGrayRenderer: public QgsRasterRenderer
{
public:
QgsSingleBandGrayRenderer( QgsRasterDataProvider* provider, int grayBand );
~QgsSingleBandGrayRenderer();

static QgsRasterRenderer* create( const QDomElement& elem );

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

const QgsContrastEnhancement* contrastEnhancement() const { return mContrastEnhancement; }
@@ -22,14 +22,19 @@
#include <QImage>

QgsSingleBandPseudoColorRenderer::QgsSingleBandPseudoColorRenderer( QgsRasterDataProvider* provider, int band, QgsRasterShader* shader ):
QgsRasterRenderer( provider ), mShader( shader ), mBand( band )
QgsRasterRenderer( provider, "singlebandpseudocolor" ), mShader( shader ), mBand( band )
{
}

QgsSingleBandPseudoColorRenderer::~QgsSingleBandPseudoColorRenderer()
{
}

QgsRasterRenderer* QgsSingleBandPseudoColorRenderer::create( const QDomElement& elem )
{
return 0;
}

void QgsSingleBandPseudoColorRenderer::draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel )
{
if ( !p || !mProvider || !viewPort || !theQgsMapToPixel || !mShader )
@@ -20,6 +20,7 @@

#include "qgsrasterrenderer.h"

class QDomElement;
class QgsRasterShader;

class QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer
@@ -28,6 +29,8 @@ class QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer
QgsSingleBandPseudoColorRenderer( QgsRasterDataProvider* provider, int band, QgsRasterShader* shader );
~QgsSingleBandPseudoColorRenderer();

static QgsRasterRenderer* create( const QDomElement& elem );

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

private:

0 comments on commit a14beda

Please sign in to comment.