Module: safe_qgis.map_legend

InaSAFE Disaster risk assessment tool developed by AusAid -
InaSAFE map legend module.

Contact : ole.moller.nielsen@gmail.com

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

class safe_qgis.map_legend.MapLegend(theLayer)[source]

A class for creating a map legend.

addClassToLegend(theColour, theMin=None, theMax=None, theCategory=None, theLabel=None)[source]

Add a class to the current legend. If the legend is not defined, a new one will be created. A legend is just an image file with nicely rendered classes in it.

Args:

  • theColour - Required colour for the class as a QColor

  • theMin - Optional minimum value for the class

  • theMax - Optional maximum value for the class * theCategory - Optional category name (will be used in lieu of

    min/max)

  • theLabel - Optional text label for the class

Returns:
None
Raises:
Throws an exception if the class could not be added for some reason..
addSymbolToLegend(theSymbol, theMin=None, theMax=None, theCategory=None, theLabel=None)[source]

Add a class to the current legend. If the legend is not defined, a new one will be created. A legend is just an image file with nicely rendered classes in it.

Note

This method just extracts the colour from the symbol and then delegates to the addClassToLegend function.

Args:

  • theSymbol - Required symbol for the class as a QgsSymbol

  • theMin - Optional minimum value for the class

  • theMax - Optional maximum value for the class * theCategory - Optional category name (will be used in lieu of

    min/max)

  • theLabel - Optional text label for the class

Returns:
None
Raises:
Throws an exception if the class could not be added for some reason..
extendLegend()[source]

Grow the legend pixmap enough to accommodate one more legend entry.

Args:
None
Returns:
None
Raises:
Any exceptions raised by the InaSAFE library will be propogated.
getLegend()[source]

Examine the classes of the impact layer associated with this print job.

Args:
None
Returns:
None
Raises:
An InvalidLegendLayer will be raised if a legend cannot be created from the layer.
getRasterLegend()[source]

Get the legend for a raster layer as an image.

Args:
None
Returns:
An image representing the layer’s legend. self.legend is also populated
Raises:
An InvalidLegendLayer will be raised if a legend cannot be created from the layer.
getVectorLegend()[source]

Get the legend for this layer as a graphic.

Args:
None
Returns:
A QImage object. self.legend is also populated with the image.
Raises:
An InvalidLegendLayer will be raised if a legend cannot be created from the layer.
tr(theString)[source]

We implement this ourself since we do not inherit QObject.

Args:
theString - string for translation.
Returns:
Translated version of theString.
Raises:
no exceptions explicitly raised.

This module forms part of the InaSAFE tool.

Previous topic

Module: safe_qgis.impact_calculator

Next topic

Module: safe_qgis.help

This Page