[Qgis-developer] PyQGIS - How to create "Outline: Simple Line" layer?
Gilbert, Daniel R.
DANIEL.R.GILBERT at saic.com
Thu Nov 29 10:34:15 PST 2012
Hello All,
First off I'm quite the newbie when it comes to developing PyQGIS
plugins so hopefully this post makes sense...
I'm creating a vector layer using the memory provider. Layer consists
of polygons and everything is working great.
I'm now attempting to tailor the appearance of the symbols. Following
the advice in this post
(http://lists.osgeo.org/pipermail/qgis-developer/2011-April/013772.html)
I successfully created just an outline (i.e. no fill):
props = { 'color_border' : '255,0,0,255', 'style' : 'no',
'style_border' : 'solid' }
s = QgsFillSymbolV2.createSimple(props)
vl.setRendererV2( QgsSingleSymbolRendererV2( s ) )
This is close to what I'd like but I notice that when selecting features
the selected features become filled which is not what I'd like.
Manually adjusting the properties via the "Symbol properties" dialog I
discovered that by selecting "Outline: Simple line" from the "Symbol
layer type" pulldown provides the functionality I desire. When
selecting features the color of the outline changes while remaining
un-filled. Looking at the resulting entry in symbology-ng-style.xml
shows the following:
<symbol outputUnit="MM" alpha="1" type="fill" name="Dash Foo">
<layer pass="0" class="SimpleLine" locked="0">
<prop k="capstyle" v="square"/>
<prop k="color" v="0,85,0,255"/>
<prop k="customdash" v="5;2"/>
<prop k="joinstyle" v="bevel"/>
<prop k="offset" v="0"/>
<prop k="penstyle" v="dash"/>
<prop k="use_custom_dash" v="0"/>
<prop k="width" v="0.37"/>
</layer>
</symbol>
I haven't had any luck in figuring out how to get the proper combination
of type="fill" while using "SimpleLine". I also noticed that if I
follow the example in the PyQGIS Cookbook to display the complete list
of types for a QgsSymbolV2.Fill none of the "Outline: <foo>" types from
the dialog pulldown are listed:
myRegistry = QgsSymbolLayerV2Registry.instance()
for item in myRegistry.symbolLayersForType(QgsSymbolV2.Fill):
... print item
CentroidFill
LinePatternFill
PointPatternFill
SVGFill
SimpleFill
Any advice on how to replicate the "Outline: Simple line" symbology will
be greatly appreciated!
Thanks,
-- Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20121129/350adc21/attachment.html>
More information about the Qgis-developer
mailing list