On 10 November 2017 at 02:26, Tom Chadwin <[email protected]> wrote: > Hello all > > I've never implemented support of any unit other than pixels in my plugin. A > particular use case (vector tiles) could really use mapunits. Can someone > explain (or point me towards) the method for converting from mapunits to > pixels for on-screen rendering?
Have you got access to a QgsRenderContext? (If not, you can create one from a QgsMapSettings by QgsRenderContext::fromMapSettings) After you've got the render context you can use - QgsRenderContext::convertFromMapUnits to convert from map units to any other unit (including pixels, mm, etc) - QgsRenderContext::convertToMapUnits to convert from any unit (including pixels and mm) to map units (That's 3.0 API) Nyall _______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
