Skip to content

Commit 1f872ce

Browse files
committedApr 19, 2013
raster filters moved to pipe node in project file to allow custom filters in future
1 parent d4d2625 commit 1f872ce

8 files changed

+39
-14
lines changed
 

‎python/core/raster/qgsrasterresamplefilter.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class QgsRasterResampleFilter : QgsRasterInterface
3232
void setMaxOversampling( double os );
3333
double maxOversampling() const;
3434

35-
void writeXML( QDomDocument& doc, QDomElement& parentElem );
35+
void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
3636

3737
/**Sets base class members from xml. Usually called from create() methods of subclasses*/
3838
void readXML( const QDomElement& resamplefilterElem );

‎src/core/raster/qgsbrightnesscontrastfilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ int QgsBrightnessContrastFilter::adjustColorComponent( int colorComponent, int a
191191
}
192192
}
193193

194-
void QgsBrightnessContrastFilter::writeXML( QDomDocument& doc, QDomElement& parentElem )
194+
void QgsBrightnessContrastFilter::writeXML( QDomDocument& doc, QDomElement& parentElem ) const
195195
{
196196
if ( parentElem.isNull() )
197197
{

‎src/core/raster/qgsbrightnesscontrastfilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CORE_EXPORT QgsBrightnessContrastFilter : public QgsRasterInterface
4848
void setContrast( int contrast ) { mContrast = qBound( -100, contrast, 100 ); }
4949
int contrast() const { return mContrast; }
5050

51-
void writeXML( QDomDocument& doc, QDomElement& parentElem );
51+
void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
5252

5353
/**Sets base class members from xml. Usually called from create() methods of subclasses*/
5454
void readXML( const QDomElement& filterElem );

‎src/core/raster/qgshuesaturationfilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ void QgsHueSaturationFilter::setColorizeColor( QColor colorizeColor )
333333
mColorizeS = mColorizeColor.saturation();
334334
}
335335

336-
void QgsHueSaturationFilter::writeXML( QDomDocument& doc, QDomElement& parentElem )
336+
void QgsHueSaturationFilter::writeXML( QDomDocument& doc, QDomElement& parentElem ) const
337337
{
338338
if ( parentElem.isNull() )
339339
{

‎src/core/raster/qgshuesaturationfilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class CORE_EXPORT QgsHueSaturationFilter : public QgsRasterInterface
6565
void setColorizeStrength( int colorizeStrength ) { mColorizeStrength = colorizeStrength; }
6666
int colorizeStrength() const { return mColorizeStrength; }
6767

68-
void writeXML( QDomDocument& doc, QDomElement& parentElem );
68+
void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
6969

7070
/**Sets base class members from xml. Usually called from create() methods of subclasses*/
7171
void readXML( const QDomElement& filterElem );

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,11 +2237,21 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
22372237
Q_UNUSED( errorMessage );
22382238
QDomElement rasterRendererElem;
22392239

2240-
//rasterlayerproperties element there -> old format
2241-
if ( !layer_node.firstChildElement( "rasterproperties" ).isNull() )
2240+
// pipe element was introduced in the end of 1.9 development when there were
2241+
// already many project files in use so we support 1.9 backward compatibility
2242+
// even it was never officialy released -> use pipe element if present, otherwise
2243+
// use layer node
2244+
QDomNode pipeNode = layer_node.firstChildElement( "pipe" );
2245+
if ( pipeNode.isNull() ) // old project
2246+
{
2247+
pipeNode = layer_node;
2248+
}
2249+
2250+
//rasterlayerproperties element there -> old format (1.8 and early 1.9)
2251+
if ( !pipeNode.firstChildElement( "rasterproperties" ).isNull() )
22422252
{
22432253
//copy node because layer_node is const
2244-
QDomNode layerNodeCopy = layer_node.cloneNode();
2254+
QDomNode layerNodeCopy = pipeNode.cloneNode();
22452255
QDomDocument doc = layerNodeCopy.ownerDocument();
22462256
QDomElement rasterPropertiesElem = layerNodeCopy.firstChildElement( "rasterproperties" );
22472257
QgsProjectFileTransform::convertRasterProperties( doc, layerNodeCopy, rasterPropertiesElem,
@@ -2251,7 +2261,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
22512261
}
22522262
else
22532263
{
2254-
rasterRendererElem = layer_node.firstChildElement( "rasterrenderer" );
2264+
rasterRendererElem = pipeNode.firstChildElement( "rasterrenderer" );
22552265
}
22562266

22572267
if ( !rasterRendererElem.isNull() )
@@ -2270,7 +2280,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
22702280
mPipe.set( brightnessFilter );
22712281

22722282
//brightness coefficient
2273-
QDomElement brightnessElem = layer_node.firstChildElement( "brightnesscontrast" );
2283+
QDomElement brightnessElem = pipeNode.firstChildElement( "brightnesscontrast" );
22742284
if ( !brightnessElem.isNull() )
22752285
{
22762286
brightnessFilter->readXML( brightnessElem );
@@ -2281,7 +2291,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
22812291
mPipe.set( hueSaturationFilter );
22822292

22832293
//saturation coefficient
2284-
QDomElement hueSaturationElem = layer_node.firstChildElement( "huesaturation" );
2294+
QDomElement hueSaturationElem = pipeNode.firstChildElement( "huesaturation" );
22852295
if ( !hueSaturationElem.isNull() )
22862296
{
22872297
hueSaturationFilter->readXML( hueSaturationElem );
@@ -2292,7 +2302,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
22922302
mPipe.set( resampleFilter );
22932303

22942304
//max oversampling
2295-
QDomElement resampleElem = layer_node.firstChildElement( "rasterresampler" );
2305+
QDomElement resampleElem = pipeNode.firstChildElement( "rasterresampler" );
22962306
if ( !resampleElem.isNull() )
22972307
{
22982308
resampleFilter->readXML( resampleElem );
@@ -2472,6 +2482,20 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum
24722482
Q_UNUSED( errorMessage );
24732483
QDomElement layerElem = layer_node.toElement();
24742484

2485+
// Store pipe members (except provider) into pipe element, in future, it will be
2486+
// possible to add custom filters into the pipe
2487+
QDomElement pipeElement = document.createElement( "pipe" );
2488+
2489+
for ( int i = 1; i < mPipe.size(); i++ )
2490+
{
2491+
QgsRasterInterface * interface = mPipe.at( i );
2492+
if ( !interface ) continue;
2493+
interface->writeXML( document, pipeElement );
2494+
}
2495+
2496+
layer_node.appendChild( pipeElement );
2497+
2498+
#if 0
24752499
QgsRasterRenderer *renderer = mPipe.renderer();
24762500
if ( renderer )
24772501
{
@@ -2498,6 +2522,7 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum
24982522
QDomElement layerElem = layer_node.toElement();
24992523
resampleFilter->writeXML( document, layerElem );
25002524
}
2525+
#endif
25012526

25022527
// add blend mode node
25032528
QDomElement blendModeElement = document.createElement( "blendMode" );

‎src/core/raster/qgsrasterresamplefilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ QgsRasterBlock * QgsRasterResampleFilter::block( int bandNo, QgsRectangle const
220220
return outputBlock; // No resampling
221221
}
222222

223-
void QgsRasterResampleFilter::writeXML( QDomDocument& doc, QDomElement& parentElem )
223+
void QgsRasterResampleFilter::writeXML( QDomDocument& doc, QDomElement& parentElem ) const
224224
{
225225
if ( parentElem.isNull() )
226226
{

‎src/core/raster/qgsrasterresamplefilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CORE_EXPORT QgsRasterResampleFilter : public QgsRasterInterface
5555
void setMaxOversampling( double os ) { mMaxOversampling = os; }
5656
double maxOversampling() const { return mMaxOversampling; }
5757

58-
void writeXML( QDomDocument& doc, QDomElement& parentElem );
58+
void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
5959

6060
/**Sets base class members from xml. Usually called from create() methods of subclasses*/
6161
void readXML( const QDomElement& filterElem );

0 commit comments

Comments
 (0)
Please sign in to comment.