Skip to content

Commit

Permalink
Add type name to renderers. Restore the corresponding renderer widget…
Browse files Browse the repository at this point in the history
… in raster properties
  • Loading branch information
mhugent committed Feb 20, 2012
1 parent 9b8423e commit a14beda
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 18 deletions.
9 changes: 9 additions & 0 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsmultibandcolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgspalettedrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
}

Expand Down
5 changes: 3 additions & 2 deletions src/core/raster/qgsrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
}

Expand Down
5 changes: 4 additions & 1 deletion src/core/raster/qgsrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)*/
Expand Down
7 changes: 6 additions & 1 deletion src/core/raster/qgssinglebandcolordatarenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <QImage>

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

}
Expand All @@ -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 )
Expand Down
4 changes: 4 additions & 0 deletions src/core/raster/qgssinglebandcolordatarenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion src/core/raster/qgssinglebandgrayrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions src/core/raster/qgssinglebandgrayrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
7 changes: 6 additions & 1 deletion src/core/raster/qgssinglebandpseudocolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions src/core/raster/qgssinglebandpseudocolorrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "qgsrasterrenderer.h"

class QDomElement;
class QgsRasterShader;

class QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer
Expand All @@ -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:
Expand Down

0 comments on commit a14beda

Please sign in to comment.