[Qgis-developer] line renderer and composition mode

Jürgen E. Fischer jef at norbit.de
Wed Aug 27 05:53:14 PDT 2014


Hi,

any objections to have the line symbol layer render in composition mode
"source"?

I have a layer with multiple levels of administrative boundaries, where higher
level boundaries (eg. state) lie over lower level boundaries (county). Lower
level boundaries should not be visible if there is a higher level boundary on
top of them.  The styles are dash-dotted - so the lines don't fully cover the
lines below.

I could solve that by putting a white line on the bottom of the symbol, but
that would also mean that layers below are covered, that I still would like
see.

Rendering the line in "source" composition would allow to have a fully
transparent line symbol layers on the bottom of the symbol that would overwrite
the already rendered lines on that layer with transparency.

Is that already possible in a different way (without resorting to multiple
vector layers) to achieve the same?   Or does it introduce some problem that I
didn't think of?   It could still be optional...


Jürgen


diff --git a/src/core/symbology-ng/qgslinesymbollayerv2.cpp b/src/core/symbology-ng/qgslinesymbollayerv2.cpp
index 5a06f23..e21474a 100644
--- a/src/core/symbology-ng/qgslinesymbollayerv2.cpp
+++ b/src/core/symbology-ng/qgslinesymbollayerv2.cpp
@@ -207,10 +207,12 @@ void QgsSimpleLineSymbolLayerV2::renderPolygonOutline( const QPolygonF& points,
     return;
   }

+  p->save();
+  p->setCompositionMode( QPainter::CompositionMode_Source );
+
   if ( mDrawInsidePolygon )
   {
     //only drawing the line on the interior of the polygon, so set clip path for painter
-    p->save();
     QPainterPath clipPath;
     clipPath.addPolygon( points );

@@ -236,11 +238,8 @@ void QgsSimpleLineSymbolLayerV2::renderPolygonOutline( const QPolygonF& points,
       renderPolyline( ring, context );
   }

-  if ( mDrawInsidePolygon )
-  {
-    //restore painter to reset clip path
-    p->restore();
-  }
+  //restore painter's composition mode and reset clip path
+  p->restore();

 }

@@ -252,6 +251,9 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
     return;
   }

+  p->save();
+  p->setCompositionMode( QPainter::CompositionMode_Source );
+
   double offset = 0.0;
   applyDataDefinedSymbology( context, mPen, mSelPen, offset );

@@ -280,6 +282,8 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
     for ( int part = 0; part < mline.count(); ++part )
       p->drawPolyline( mline[ part ] );
   }
+
+  p->restore();
 }

 QgsStringMap QgsSimpleLineSymbolLayerV2::properties() const



-- 
Jürgen E. Fischer         norBIT GmbH               Tel. +49-4931-918175-31
Dipl.-Inf. (FH)           Rheinstraße 13            Fax. +49-4931-918175-50
Software Engineer         D-26506 Norden               http://www.norbit.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140827/581679c2/attachment-0001.pgp>


More information about the Qgis-developer mailing list