Skip to content
Permalink
Browse files

Merge pull request #476 from nyalldawson/blend_modes

Blend modes pt 2
  • Loading branch information
NathanW2 committed Mar 24, 2013
2 parents 176a08c + 08fba25 commit dac35e1063f9f53453069f31bb507fe7d9afe96f
@@ -192,9 +192,6 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mLayerAbstractTextEdit->setPlainText( layer->abstract() );
}

// Blend mode
mBlendModeComboBox->setBlendMode( layer->blendMode() );

QSettings settings;
restoreGeometry( settings.value( "/Windows/VectorLayerProperties/geometry" ).toByteArray() );
int tabIndex = settings.value( "/Windows/VectorLayerProperties/row", 0 ).toInt();
@@ -531,9 +528,6 @@ void QgsVectorLayerProperties::apply()
layer->setTitle( mLayerTitleLineEdit->text() );
layer->setAbstract( mLayerAbstractTextEdit->toPlainText() );

// set the blend mode for the layer
layer->setBlendMode(( QgsMapLayer::BlendMode ) mBlendModeComboBox->blendMode() );

// update symbology
emit refreshLegend( layer->id(), QgsLegendItem::DontChange );

@@ -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;
@@ -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 );
@@ -385,10 +385,10 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
.arg( ml->extent().toString() )
.arg( ml->blendMode() )
);

// Set the QPainter composition mode so that this layer is rendered using
// the desired blending mode
mypContextPainter->setCompositionMode(ml->getCompositionMode());
mypContextPainter->setCompositionMode( ml->getCompositionMode() );

if ( !ml->hasScaleBasedVisibility() || ( ml->minimumScale() <= mScale && mScale < ml->maximumScale() ) || mOverview )
{
@@ -559,6 +559,9 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )

QgsDebugMsg( "Done rendering map layers" );

// Reset the composition mode before rendering the labels
mRenderContext.painter()->setCompositionMode( QPainter::CompositionMode_SourceOver );

if ( !mOverview )
{
// render all labels for vector layers in the stack, starting at the base
@@ -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" );
@@ -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() );
@@ -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

@@ -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

@@ -87,6 +87,9 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog( QgsVectorLayer* la
// initialize registry's widget functions
_initRendererWidgetFunctions();

// Blend mode
mBlendModeComboBox->setBlendMode( mLayer->blendMode() );

QPixmap pix;
QgsRendererV2Registry* reg = QgsRendererV2Registry::instance();
QStringList renderers = reg->renderersList();
@@ -177,6 +180,9 @@ void QgsRendererV2PropertiesDialog::apply()
{
mLayer->setRendererV2( renderer->clone() );
}

// set the blend mode for the layer
mLayer->setBlendMode(( QgsMapLayer::BlendMode ) mBlendModeComboBox->blendMode() );
}

void QgsRendererV2PropertiesDialog::onOK()
@@ -145,6 +145,23 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="mBlendTypeLabel">
<property name="text">
<string>Blending mode</string>
</property>
</widget>
</item>
<item>
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -158,13 +175,19 @@
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mResamplingGroupBox"><property name="collapsed" stdset="0"><bool>false</bool></property><property name="saveCollapsedState" stdset="0"><bool>true</bool></property>
<widget class="QgsCollapsibleGroupBox" name="mResamplingGroupBox">
<property name="title">
<string>Resampling</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="mZoomedInResamplingLabel">
@@ -869,52 +892,6 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="mBlendTypeLabel">
<property name="text">
<string>Composition blending mode</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="grpSRS">
<property name="title">
@@ -1326,7 +1303,7 @@ p, li { white-space: pre-wrap; }
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QWidget</extends>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
</customwidgets>
@@ -32,6 +32,16 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Blending mode</string>
</property>
</widget>
</item>
<item>
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox"/>
</item>
<item>
<widget class="QPushButton" name="btnOldSymbology">
<property name="text">
@@ -77,6 +87,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cboRenderers</tabstop>
<tabstop>buttonBox</tabstop>
@@ -530,7 +530,7 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="3" column="0">
<widget class="QGroupBox" name="grpSubset">
<property name="title">
<string>Subset</string>
@@ -578,7 +578,7 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QGroupBox" name="grpProviderOptions">
<property name="title">
<string>Provider-specific options</string>
@@ -600,52 +600,6 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="leftMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="mBlendTypeLabel">
<property name="text">
<string>Composition blending mode</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
@@ -1054,11 +1008,6 @@ p, li { white-space: pre-wrap; }
<extends>QWidget</extends>
<header>qgsscalecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QWidget</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cbMinimumScale</tabstop>

0 comments on commit dac35e1

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