[Qgis-developer] Symbology NG - rendering of selected symbols

Martin Dobias wonder.sk at gmail.com
Sun Apr 4 05:49:17 EDT 2010

On Sat, Apr 3, 2010 at 8:40 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Hi
> I'm wondering if we could improve the way that Qgis renders selected symbols.
> Currently it seems that the rendering loop uses a standard renderer (defined in QgsVectorLayer::drawRendererV2Levels)  for this independent of the renderer used for the layer.  Where the actual renderer generates a very distinctive symbology (in my case an oriented arrow), selected symbols don't look anything like the orginal symbology, and don't carry any of the information of the original symbology.

Hi Chris,

right, the rendering of selected features is somehow suboptimal. Old
symbology simply changes color of the symbol which should be drawn as
selected. This is a problem e.g. with svg symbol where the color can't
be easily changed. New symbology indeed could do it better...

> I'm wanting to add the flexibility for the renderer to customise this.  I was thinking that perhaps the way to do this is to add a "renderSelectedFeature" virtual function to the QgsFeatureRendererV2 interface, and implement the default functions in the QgsFeatureRenderer (maybe by instantiating the standard renderer and passing the renderSelectedFeature onto its renderFeature function, and of course handling the start and stop render functions there too)

I think the support for selection should have two levels:
- symbols: it should be possible to tell the symbol (resp. symbol
layer) to be drawn in "selected" mode - maybe by passing a flag in
QgsSymbolV2RenderContext. Default implementation would only change
color of the symbol to the selected color. Custom implementation
should be possible (e.g. to allow svg symbol to draw a
circle/rectangle around the symbol)
- renderers: they should be aware whether the symbol should be
rendererd in normal or selected mode. Again, default implementation
would handle that automatically, special renderers that do additional
drawing should be able to customize what should be done.

The passing of selected/not selected flag could done either by adding
a new function as you propose, or by adding a new parameter to
existing renderFeature function...


More information about the Qgis-developer mailing list