Skip to content

Commit

Permalink
Add support for copy/pasting blend modes for layers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 23, 2013
1 parent 3bb405f commit 4ba3690
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -411,15 +411,6 @@ bool QgsMapLayer::readXML( const QDomNode& layer_node )
setTransparency( myElement.text().toInt() );
}

//read blend mode
QDomNode blendModeNode = layer_node.namedItem( "blendMode" );
if ( ! blendModeNode.isNull() )
{
// set blend mode if it's specified in project
QDomElement myElement = blendModeNode.toElement();
setBlendMode(( QgsMapLayer::BlendMode )myElement.text().toInt() );
}

readCustomProperties( layer_node );

return true;
Expand Down Expand Up @@ -536,12 +527,6 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )
transparencyLevelIntElement.appendChild( transparencyLevelIntText );
maplayer.appendChild( transparencyLevelIntElement );

// <blendMode>
QDomElement blendModeElement = document.createElement( "blendMode" );
QDomText blendModeText = document.createTextNode( QString::number( blendMode() ) );
blendModeElement.appendChild( blendModeText );
maplayer.appendChild( blendModeElement );

// now append layer node to map layer node

layer_node.appendChild( maplayer );
Expand Down
14 changes: 14 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2260,6 +2260,14 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
setDisplayField( e.text() );
}

// get and set the blend mode if it exists
QDomNode blendModeNode = node.namedItem( "blendMode" );
if ( !blendModeNode.isNull() )
{
QDomElement e = blendModeNode.toElement();
setBlendMode(( QgsMapLayer::BlendMode ) e.text().toInt() );
}

// use scale dependent visibility flag
QDomElement e = node.toElement();
mLabel->setScaleBasedVisibility( e.attribute( "scaleBasedLabelVisibilityFlag", "0" ) == "1" );
Expand Down Expand Up @@ -2605,6 +2613,12 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
//save customproperties (for labeling ng)
writeCustomProperties( node, doc );

// add the blend mode field
QDomElement blendModeElem = doc.createElement( "blendMode" );
QDomText blendModeText = doc.createTextNode( QString::number( blendMode() ) );
blendModeElem.appendChild( blendModeText );
node.appendChild( blendModeElem );

// add the display field
QDomElement dField = doc.createElement( "displayfield" );
QDomText dFieldText = doc.createTextNode( displayField() );
Expand Down
14 changes: 14 additions & 0 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -2312,6 +2312,14 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
resampleFilter->readXML( resampleElem );
}

// get and set the blend mode if it exists
QDomNode blendModeNode = layer_node.namedItem( "blendMode" );
if ( !blendModeNode.isNull() )
{
QDomElement e = blendModeNode.toElement();
setBlendMode(( QgsMapLayer::BlendMode ) e.text().toInt() );
}

return true;
} //readSymbology

Expand Down Expand Up @@ -2499,6 +2507,12 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum
resampleFilter->writeXML( document, layerElem );
}

// add blend mode node
QDomElement blendModeElement = document.createElement( "blendMode" );
QDomText blendModeText = document.createTextNode( QString::number( blendMode() ) );
blendModeElement.appendChild( blendModeText );
layer_node.appendChild( blendModeElement );

return true;
} // bool QgsRasterLayer::writeSymbology

Expand Down

0 comments on commit 4ba3690

Please sign in to comment.