On Fri, May 11, 2012 at 3:14 AM, Martin Dobias <[email protected]> wrote: > On Fri, May 11, 2012 at 12:40 AM, Etienne Tourigny > <[email protected]> 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. >
Thanks Martin, this is great to know. Existing code (composer grid) does not seem use this infrastructure. Would it make sense to create a new qgisgui element (or other class) to deal with grids, and re-use this code in the composer? Or perhaps just draw in the composer whatever grid(s) have been defined by the user in the main canvas? Are there any documentation/examples on using qgisgui elements, other than the api? Regards, Etienne > Regards > Martin _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
