[Qgis-developer] show grid on map canvas (similiar to grid used in composer) - strategy?

Martin Dobias wonder.sk at gmail.com
Thu May 10 23:14:15 PDT 2012

On Fri, May 11, 2012 at 12:40 AM, Etienne Tourigny
<etourigny.dev at gmail.com> wrote:
>> For me a grid is a good candidate to be implemented as another type of
>> decoration (currently there is north arrow, scale bar and copyright
>> label). A decoration is drawn on top of the map when map rendering has
>> finished. And symbology can still be applied when drawing grid as a
>> decoration.
> Hmm... symbology applied to what?
> Nathan's suggestion to make it a layer to be able to style it makes
> sense. Any way we can use the symbology interface on a map decoration?
> Can we re-use existing widgets for this, or just a waste or time
> instead of designing a new widget?

It is fairly easy to provide a GUI where users would select/modify the
symbol for drawing grid lines (all necessary widgets are in qgis_gui
library - QgsSymbolV2SelectorDialog, QgsSymbolV2PropertiesDialog). For
drawing itself you only have to construct a QgsRenderContext instance
and issue calls to QgsLineSymbolV2::renderPolyline(...). Before first
render call make sure to initialize the symbol with startRender() and
at the end stopRender(). To get screen coordinates from map
coordinates there is QgsMapToPixel utility class.


More information about the Qgis-developer mailing list