Skip to content
Permalink
Browse files

[mesh] make layer blend mode option visible in UI

  • Loading branch information
nirvn committed Oct 4, 2018
1 parent 64e561c commit 9d2c3af7ade1edfcb573104d6e46948e66d0c1c0
@@ -44,6 +44,10 @@ QgsRendererMeshPropertiesWidget::QgsRendererMeshPropertiesWidget( QgsMeshLayer *
mMeshRendererVectorSettingsWidget->setLayer( mMeshLayer );
syncToLayer();

//blend mode
mBlendModeComboBox->setBlendMode( mMeshLayer->blendMode() );
connect( mBlendModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsPanelWidget::widgetChanged );

connect( mMeshRendererActiveDatasetWidget, &QgsMeshRendererActiveDatasetWidget::activeScalarGroupChanged,
this, &QgsRendererMeshPropertiesWidget::onActiveScalarGroupChanged );
connect( mMeshRendererActiveDatasetWidget, &QgsMeshRendererActiveDatasetWidget::activeVectorGroupChanged,
@@ -53,7 +57,6 @@ QgsRendererMeshPropertiesWidget::QgsRendererMeshPropertiesWidget( QgsMeshLayer *
connect( mTriangularMeshGroup, &QGroupBox::toggled, this, &QgsPanelWidget::widgetChanged );
connect( mContoursGroupBox, &QGroupBox::toggled, this, &QgsPanelWidget::widgetChanged );
connect( mVectorsGroupBox, &QGroupBox::toggled, this, &QgsPanelWidget::widgetChanged );

connect( mMeshRendererActiveDatasetWidget, &QgsMeshRendererActiveDatasetWidget::widgetChanged, this, &QgsPanelWidget::widgetChanged );
connect( mMeshRendererScalarSettingsWidget, &QgsMeshRendererScalarSettingsWidget::widgetChanged, this, &QgsPanelWidget::widgetChanged );
connect( mMeshRendererVectorSettingsWidget, &QgsMeshRendererVectorSettingsWidget::widgetChanged, this, &QgsPanelWidget::widgetChanged );
@@ -100,6 +103,9 @@ void QgsRendererMeshPropertiesWidget::apply()
if ( activeVectorDatasetIndex.isValid() )
settings.setVectorSettings( activeVectorDatasetIndex.group(), mMeshRendererVectorSettingsWidget->settings() );

//set the blend mode for the layer
mMeshLayer->setBlendMode( mBlendModeComboBox->blendMode() );

mMeshLayer->setRendererSettings( settings );
mMeshLayer->triggerRepaint();
}
@@ -27,6 +27,7 @@
#include "qgsmeshlayer.h"
#include "qgsmeshlayerrenderer.h"
#include "qgsmeshlayerutils.h"
#include "qgspainting.h"
#include "qgsproviderregistry.h"
#include "qgsreadwritecontext.h"
#include "qgsstyle.h"
@@ -271,6 +272,14 @@ bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
if ( !elemRendererSettings.isNull() )
mRendererSettings.readXml( elemRendererSettings );

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

return true;
}

@@ -287,6 +296,12 @@ bool QgsMeshLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &e
QDomElement elemRendererSettings = mRendererSettings.writeXml( doc );
elem.appendChild( elemRendererSettings );

// add blend mode node
QDomElement blendModeElement = doc.createElement( QStringLiteral( "blendMode" ) );
QDomText blendModeText = doc.createTextNode( QString::number( QgsPainting::getBlendModeEnum( blendMode() ) ) );
blendModeElement.appendChild( blendModeText );
node.appendChild( blendModeElement );

return true;
}

@@ -68,6 +68,32 @@
</property>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mActiveDatasetBlendingMode">
<property name="title">
<string>Layer Rendering</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="">
<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>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
@@ -299,6 +325,17 @@
<header>mesh/qgsmeshrenderervectorsettingswidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../images/images.qrc"/>

0 comments on commit 9d2c3af

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