Skip to content
Permalink
Browse files
WriteXML method for multiband color renderer
  • Loading branch information
mhugent committed Mar 28, 2012
1 parent fbd944c commit 0bd0c06087400f0960a1cdd82caa8b6ce24ff9ff
@@ -25,6 +25,8 @@ class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
#include "qgslinearminmaxenhancement.h"
#include "qgslinearminmaxenhancementwithclip.h"
#include "qgscliptominmaxenhancement.h"
#include <QDomDocument>
#include <QDomElement>

QgsContrastEnhancement::QgsContrastEnhancement( QgsRasterDataType theDataType )
{
@@ -353,3 +355,24 @@ void QgsContrastEnhancement::setMinimumValue( double theValue, bool generateTabl
generateLookupTable();
}
}

void QgsContrastEnhancement::writeXML( QDomDocument& doc, QDomElement& parentElem ) const
{
//minimum value
QDomElement minElem = doc.createElement( "minValue" );
QDomText minText = doc.createTextNode( QString::number( mMinimumValue ) );
minElem.appendChild( minText );
parentElem.appendChild( minElem );

//maximum value
QDomElement maxElem = doc.createElement( "maxValue" );
QDomText maxText = doc.createTextNode( QString::number( mMaximumValue ) );
maxElem.appendChild( maxText );
parentElem.appendChild( maxElem );

//algorithm
QDomElement algorithmElem = doc.createElement( "algorithm" );
QDomText algorithmText = doc.createTextNode( QString::number( mContrastEnhancementAlgorithm ) );
algorithmElem.appendChild( algorithmText );
parentElem.appendChild( algorithmElem );
}
@@ -24,6 +24,8 @@ class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
#include <limits>

class QgsContrastEnhancementFunction;
class QDomDocument;
class QDomElement;

/** \ingroup core
* Manipulates raster pixel values so that they enhanceContrast or clip into a
@@ -119,6 +121,8 @@ class CORE_EXPORT QgsContrastEnhancement
/** \brief Return the minimum value for the contrast enhancement range. */
void setMinimumValue( double, bool generateTable = true );

void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;

private:
/** \brief Current contrast enhancement algorithm */
ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm;
@@ -278,14 +278,35 @@ void QgsMultiBandColorRenderer::draw( QPainter* p, QgsRasterViewPort* viewPort,

void QgsMultiBandColorRenderer::writeXML( QDomDocument& doc, QDomElement& parentElem ) const
{
if ( !parentElem.isNull() )
if ( parentElem.isNull() )
{
return;
}

QDomElement rasterRendererElem = doc.createElement( "rasterrenderer" );
_writeXML( doc, parentElem );
_writeXML( doc, rasterRendererElem );
rasterRendererElem.setAttribute( "redBand", mRedBand );
rasterRendererElem.setAttribute( "greenBand", mGreenBand );
rasterRendererElem.setAttribute( "blueBand", mBlueBand );

//contrast enhancement
if( mRedContrastEnhancement )
{
QDomElement redContrastElem = doc.createElement( "redContrastEnhancement" );
mRedContrastEnhancement->writeXML( doc, redContrastElem );
rasterRendererElem.appendChild( redContrastElem );
}
if( mGreenContrastEnhancement )
{
QDomElement greenContrastElem = doc.createElement( "greenContrastEnhancement" );
mGreenContrastEnhancement->writeXML( doc, greenContrastElem );
rasterRendererElem.appendChild( greenContrastElem );
}
if( mBlueContrastEnhancement )
{
QDomElement blueContrastElem = doc.createElement( "blueContrastEnhancement" );
mBlueContrastEnhancement->writeXML( doc, blueContrastElem );
rasterRendererElem.appendChild( blueContrastElem );
}
parentElem.appendChild( rasterRendererElem );
}

0 comments on commit 0bd0c06

Please sign in to comment.