On Fri, Apr 1, 2011 at 9:14 AM, <[email protected]> wrote:
>
> Hi,
>
> I've searched across documentation and mailing list, but I didn't found a
> page explaining how to set a symbol.
>
> For example:
>
> - point layer: I want to use a circle with width 0.5 and gray colour with
> black border;
> - line layer: width 1 and continous green line
>
> any hint?
Hi Luca
using the new symbology you can do it as follows:
- gray circle with black border:
props = { 'color' : '128,128,128' }
sl =
QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("SimpleMarker").createSymbolLayer(props)
s = QgsMarkerSymbolV2([sl])
- green line with 1mm width:
props = { 'width' : '1', 'color' : '0,0,255' }
sl =
QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("SimpleLine").createSymbolLayer(props)
s = QgsLineSymbolV2([sl])
Then you will just use the symbol in a renderer and assign the
renderer to a layer:
layer.setRendererV2( QgsSingleSymbolRendererV2( s ) )
The syntax of properties is dependent on the symbol layer you use, I
guess there is no documentation for the accepted keys and values,
though you can save some symbols into qgis style and then inspect the
~/.qgis/symbology-ng-style.xml.
In order to make creation of simple symbols a bit easier, I have added
just now (r15663) some convenience methods:
s = QgsMarkerSymbolV2.createSimple( { ... } )
s = QgsLineSymbolV2.createSimple( { ... } )
s = QgsFillSymbolV2.createSimple( { ... } )
Regards
Martin
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer