Skip to content
Permalink
Browse files

removed raster layer drawing style getter/setter

  • Loading branch information
blazek committed May 15, 2013
1 parent d64ee56 commit 378a55ec9ba0e4c39e21d5fbb5cf606d1fd9bde3
@@ -113,7 +113,7 @@ class QgsRasterLayer : QgsMapLayer
void setDataProvider( const QString & provider );

/** \brief Accessor for drawing style */
DrawingStyle drawingStyle();
//DrawingStyle drawingStyle();

/** \brief Accessor that returns the width of the (unclipped) raster */
int width();
@@ -125,7 +125,7 @@ class QgsRasterLayer : QgsMapLayer
LayerType rasterType();

/** \brief Mutator for drawing style */
void setDrawingStyle( const DrawingStyle & theDrawingStyle );
//void setDrawingStyle( const DrawingStyle & theDrawingStyle );

/**Set raster renderer. Takes ownership of the renderer object*/
void setRenderer( QgsRasterRenderer* theRenderer /Transfer/ );
@@ -32,6 +32,7 @@
#include "qgsmaprenderer.h"
#include "qgsmaptoolemitpoint.h"
#include "qgsmaptopixel.h"
#include "qgsmultibandcolorrenderer.h"
#include "qgsmultibandcolorrendererwidget.h"
#include "qgspalettedrendererwidget.h"
#include "qgsproject.h"
@@ -1206,7 +1207,7 @@ void QgsRasterLayerProperties::on_pbnExportTransparentPixelValues_clicked()
{
QTextStream myOutputStream( &myOutputFile );
myOutputStream << "# " << tr( "QGIS Generated Transparent Pixel Value Export File" ) << "\n";
if ( /*rbtnThreeBand->isChecked() &&*/ QgsRasterLayer::MultiBandColor == mRasterLayer->drawingStyle() )
if ( rasterIsMultiBandColor() )
{
myOutputStream << "#\n#\n# " << tr( "Red" ) << "\t" << tr( "Green" ) << "\t" << tr( "Blue" ) << "\t" << tr( "Percent Transparent" );
for ( int myTableRunner = 0; myTableRunner < tableTransparency->rowCount(); myTableRunner++ )
@@ -1219,17 +1220,7 @@ void QgsRasterLayerProperties::on_pbnExportTransparentPixelValues_clicked()
}
else
{
if ( QgsRasterLayer::PalettedColor != mRasterLayer->drawingStyle() &&
QgsRasterLayer::PalettedSingleBandGray != mRasterLayer->drawingStyle() &&
QgsRasterLayer::PalettedSingleBandPseudoColor != mRasterLayer->drawingStyle() &&
QgsRasterLayer::PalettedMultiBandColor != mRasterLayer->drawingStyle() )
{
myOutputStream << "#\n#\n# " << tr( "Gray" ) << "\t" << tr( "Percent Transparent" );
}
else
{
myOutputStream << "#\n#\n# " << tr( "Indexed Value" ) << "\t" << tr( "Percent Transparent" );
}
myOutputStream << "#\n#\n# " << tr( "Value" ) << "\t" << tr( "Percent Transparent" );

for ( int myTableRunner = 0; myTableRunner < tableTransparency->rowCount(); myTableRunner++ )
{
@@ -1331,7 +1322,7 @@ void QgsRasterLayerProperties::on_pbnImportTransparentPixelValues_clicked()
{
QTextStream myInputStream( &myInputFile );
QString myInputLine;
if ( /*rbtnThreeBand->isChecked() &&*/ QgsRasterLayer::MultiBandColor == mRasterLayer->drawingStyle() )
if ( rasterIsMultiBandColor() )
{
for ( int myTableRunner = tableTransparency->rowCount() - 1; myTableRunner >= 0; myTableRunner-- )
{
@@ -1714,3 +1705,9 @@ void QgsRasterLayerProperties::on_mResetColorRenderingBtn_clicked()
mColorizeCheck->setChecked( false );
sliderColorizeStrength->setValue( 100 );
}

bool QgsRasterLayerProperties::rasterIsMultiBandColor()
{
return mRasterLayer && dynamic_cast<QgsMultiBandColorRenderer*>( mRasterLayer->renderer() ) != 0;
}

@@ -155,6 +155,8 @@ class QgsRasterLayerProperties : public QgsOptionsDialogBase, private Ui::QgsRas

QgsRasterRendererWidget* mRendererWidget;

bool rasterIsMultiBandColor();

void setupTransparencyTable( int nBands );

/** \brief Clear the current transparency table and populate the table with the correct types for current drawing mode and data type*/
@@ -788,7 +788,7 @@ void QgsRasterLayer::init()
{
mRasterType = QgsRasterLayer::GrayOrUndefined;

setDrawingStyle( QgsRasterLayer::UndefinedDrawingStyle );
setRendererForDrawingStyle( QgsRasterLayer::UndefinedDrawingStyle );

//Initialize the last view port structure, should really be a class
mLastViewPort.mWidth = 0;
@@ -895,16 +895,16 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
QgsDebugMsg( "mRasterType = " + QString::number( mRasterType ) );
if ( mRasterType == ColorLayer )
{
QgsDebugMsg( "Setting mDrawingStyle to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
setDrawingStyle( SingleBandColorDataStyle );
QgsDebugMsg( "Setting drawing style to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
setRendererForDrawingStyle( SingleBandColorDataStyle );
}
else if ( mRasterType == Palette && mDataProvider->colorInterpretation( 1 ) == QgsRaster::PaletteIndex )
{
setDrawingStyle( PalettedColor ); //sensible default
setRendererForDrawingStyle( PalettedColor ); //sensible default
}
else if ( mRasterType == Palette && mDataProvider->colorInterpretation( 1 ) == QgsRaster::ContinuousPalette )
{
setDrawingStyle( SingleBandPseudoColor );
setRendererForDrawingStyle( SingleBandPseudoColor );
// Load color table
QList<QgsColorRampShader::ColorRampItem> colorTable = mDataProvider->colorTable( 1 );
QgsSingleBandPseudoColorRenderer* r = dynamic_cast<QgsSingleBandPseudoColorRenderer*>( renderer() );
@@ -921,11 +921,11 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
}
else if ( mRasterType == Multiband )
{
setDrawingStyle( MultiBandColor ); //sensible default
setRendererForDrawingStyle( MultiBandColor ); //sensible default
}
else //GrayOrUndefined
{
setDrawingStyle( SingleBandGray ); //sensible default
setRendererForDrawingStyle( SingleBandGray ); //sensible default
}

// Auto set alpha band
@@ -1092,19 +1092,20 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh

void QgsRasterLayer::setDefaultContrastEnhancement()
{
QgsDebugMsg( QString( "mDrawingStyle = %1" ).arg( mDrawingStyle ) );
QgsDebugMsg( "Entered" );

QSettings mySettings;

QString myKey;
QString myDefault;

if ( mDrawingStyle == SingleBandGray || mDrawingStyle == MultiBandSingleBandGray )
// TODO: we should not test renderer class here, move it somehow to renderers
if ( dynamic_cast<QgsSingleBandGrayRenderer*>( renderer() ) )
{
myKey = "singleBand";
myDefault = "StretchToMinimumMaximum";
}
else if ( mDrawingStyle == MultiBandColor )
else if ( dynamic_cast<QgsMultiBandColorRenderer*>( renderer() ) )
{
if ( QgsRasterBlock::typeSize( dataProvider()->srcDataType( 1 ) ) == 1 )
{
@@ -1148,52 +1149,54 @@ void QgsRasterLayer::setDefaultContrastEnhancement()
void QgsRasterLayer::setDrawingStyle( QString const & theDrawingStyleQString )
{
QgsDebugMsg( "DrawingStyle = " + theDrawingStyleQString );
DrawingStyle drawingStyle;
if ( theDrawingStyleQString == "SingleBandGray" )//no need to tr() this its not shown in ui
{
mDrawingStyle = SingleBandGray;
drawingStyle = SingleBandGray;
}
else if ( theDrawingStyleQString == "SingleBandPseudoColor" )//no need to tr() this its not shown in ui
{
mDrawingStyle = SingleBandPseudoColor;
drawingStyle = SingleBandPseudoColor;
}
else if ( theDrawingStyleQString == "PalettedColor" )//no need to tr() this its not shown in ui
{
mDrawingStyle = PalettedColor;
drawingStyle = PalettedColor;
}
else if ( theDrawingStyleQString == "PalettedSingleBandGray" )//no need to tr() this its not shown in ui
{
mDrawingStyle = PalettedSingleBandGray;
drawingStyle = PalettedSingleBandGray;
}
else if ( theDrawingStyleQString == "PalettedSingleBandPseudoColor" )//no need to tr() this its not shown in ui
{
mDrawingStyle = PalettedSingleBandPseudoColor;
drawingStyle = PalettedSingleBandPseudoColor;
}
else if ( theDrawingStyleQString == "PalettedMultiBandColor" )//no need to tr() this its not shown in ui
{
mDrawingStyle = PalettedMultiBandColor;
drawingStyle = PalettedMultiBandColor;
}
else if ( theDrawingStyleQString == "MultiBandSingleBandGray" )//no need to tr() this its not shown in ui
{
mDrawingStyle = MultiBandSingleBandGray;
drawingStyle = MultiBandSingleBandGray;
}
else if ( theDrawingStyleQString == "MultiBandSingleBandPseudoColor" )//no need to tr() this its not shown in ui
{
mDrawingStyle = MultiBandSingleBandPseudoColor;
drawingStyle = MultiBandSingleBandPseudoColor;
}
else if ( theDrawingStyleQString == "MultiBandColor" )//no need to tr() this its not shown in ui
{
mDrawingStyle = MultiBandColor;
drawingStyle = MultiBandColor;
}
else if ( theDrawingStyleQString == "SingleBandColorDataStyle" )//no need to tr() this its not shown in ui
{
QgsDebugMsg( "Setting mDrawingStyle to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
mDrawingStyle = SingleBandColorDataStyle;
QgsDebugMsg( "Setted mDrawingStyle to " + QString::number( mDrawingStyle ) );
QgsDebugMsg( "Setting drawingStyle to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
drawingStyle = SingleBandColorDataStyle;
QgsDebugMsg( "Setted drawingStyle to " + QString::number( drawingStyle ) );
}
else
{
mDrawingStyle = UndefinedDrawingStyle;
drawingStyle = UndefinedDrawingStyle;
}
setRendererForDrawingStyle( drawingStyle );
}

void QgsRasterLayer::setLayerOrder( QStringList const & layers )
@@ -1413,24 +1416,6 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
Raster layer project file XML of form:
\verbatim
<maplayer type="raster" visible="1" showInOverviewFlag="1">
<layername>Wynoochee_dem</layername>
<datasource>/home/mcoletti/mnt/MCOLETTIF8F9/c/Toolkit_Course/Answers/Training_Data/wynoochee_dem.img</datasource>
<zorder>0</zorder>
<transparencyLevelInt>255</transparencyLevelInt>
<rasterproperties>
<mDrawingStyle>SingleBandGray</mDrawingStyle>
<mInvertColor boolean="false"/>
<mStandardDeviations>0</mStandardDeviations>
<mRedBandName>Not Set</mRedBandName>
<mGreenBandName>Not Set</mGreenBandName>
<mBlueBandName>Not Set</mBlueBandName>
<mGrayBandName>Undefined</mGrayBandName>
</rasterproperties>
</maplayer>
\endverbatim
@note Called by QgsMapLayer::readXML().
*/
bool QgsRasterLayer::readXml( const QDomNode& layer_node )
@@ -1505,11 +1490,9 @@ bool QgsRasterLayer::readXml( const QDomNode& layer_node )
bool res = readSymbology( layer_node, theError );

// old wms settings we need to correct
if ( res &&
mProviderKey == "wms" &&
mDrawingStyle == MultiBandColor )
if ( res && mProviderKey == "wms" )
{
mDrawingStyle = SingleBandColorDataStyle;
setRendererForDrawingStyle( SingleBandColorDataStyle );
}

// Check timestamp
@@ -260,14 +260,14 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** [ data provider interface ] Set the data provider */
void setDataProvider( const QString & provider );

/** \brief Accessor for drawing style */
DrawingStyle drawingStyle() { return mDrawingStyle; }

/** \brief Accessor for raster layer type (which is a read only property) */
LayerType rasterType() { return mRasterType; }

/** \brief Accessor for drawing style */
//DrawingStyle drawingStyle() { return mDrawingStyle; }

/** \brief Mutator for drawing style */
void setDrawingStyle( const DrawingStyle & theDrawingStyle ) { mDrawingStyle = theDrawingStyle; setRendererForDrawingStyle( theDrawingStyle ); }
//void setDrawingStyle( const DrawingStyle & theDrawingStyle ) { mDrawingStyle = theDrawingStyle; setRendererForDrawingStyle( theDrawingStyle ); }

/**Set raster renderer. Takes ownership of the renderer object*/
void setRenderer( QgsRasterRenderer* theRenderer );
@@ -439,7 +439,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** Pointer to data provider */
QgsRasterDataProvider* mDataProvider;

DrawingStyle mDrawingStyle;
//DrawingStyle mDrawingStyle;

/** [ data provider interface ]The error message associated with the last error */
QString mError;
@@ -17,6 +17,7 @@

#include "qgsmslayerbuilder.h"
#include "qgsrasterlayer.h"
#include "qgsrasterrendererregistry.h"

#include <QDir>
#include <QFileInfo>
@@ -92,7 +93,8 @@ void QgsMSLayerBuilder::clearRasterSymbology( QgsRasterLayer* rl ) const
{
if ( rl->rasterType() == QgsRasterLayer::GrayOrUndefined )
{
rl->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
//rl->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRasterLayer::SingleBandPseudoColor, rl->dataProvider() ) );
}
}
}
@@ -31,6 +31,7 @@
#include "qgsmslayercache.h"
#include "qgsmsutils.h"
#include "qgsrasterlayer.h"
#include "qgsrasterrendererregistry.h"
#include "qgscolorrampshader.h"
#include "qgscoordinatereferencesystem.h"
#include "qgslabelattributes.h"
@@ -1496,7 +1497,8 @@ void QgsSLDParser::clearRasterSymbology( QgsRasterLayer* rl ) const
{
if ( rl->rasterType() == QgsRasterLayer::GrayOrUndefined )
{
rl->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
//rl->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRasterLayer::SingleBandPseudoColor, rl->dataProvider() ) );
}
}
}

0 comments on commit 378a55e

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