[Qgis-developer] python: which symbol for classified feature
Martin Dobias
wonder.sk at gmail.com
Wed Apr 29 05:40:18 EDT 2009
On Sat, Apr 25, 2009 at 10:47 PM, Richard Duivenvoorde
<rdmailings at duif.net> wrote:
> Hi devs,
>
> I'm trying to determine the symbol for a feature when a layers is classified
> in one way or another, using the python interface.
>
> If I'm correct, I can ask a renderer for it's symbols (via symbols()),
> returning me a List of symbols used, but I cannot myself determine, given a
> feature with which symbol it's (going to be) associated.
>
> Looking at some cpp code, I find a protected member symbolForFeature.
>
> Should I use that one? And if possible can this be made public via the
> python interface?
>
> Or am I on the wrong track anyway, and should I ask another class for the
> color and pen of a certain classified feature?
Hi Richard,
you might want to call renderer's renderFeature() method. This method
prepares painter for drawing of the feature based on the geometry
type:
- line - sets painter's pen
- polygon - sets painter's pen and brush
- point - modifies a QImage instance passed as an argument (will
contain the marker)
I'm not sure whether it will work with point symbols in python, the
interface is somehow messy. But for lines and polygons you should be
able to get the information you want from painter.
Bye
Martin
More information about the Qgis-developer
mailing list