[Qgis-developer] Force canvas to predefined scales : help needed to improve a script
kimaidou
kimaidou at gmail.com
Fri Apr 17 01:46:12 PDT 2015
Hi QGIS !
I would like to be able in QGIS to force the canvas scales to some
predefined ones. Since we now have project scales (and QGIS pre-defined
scales) in the scale selector, we could use them, and add a simple checkbox
near the combobox "Stick to predefined scales".
The aim is to force the canvas to render only at these scales. For example,
if I use the rectangle zoom tool, and I should go toe 1/56003, I would
instead land on 1/50000 , the closest pre-defined scale.
I made a little python script as a proof of concept to illustrate it :
http://paste.debian.net/167247/
In this script, I hard coded the scales, but oviously we should get them
from the project properties.
I have a question regarding my script. Since I use the
QgsMapCanvas::scaleChanged signal, I assume the rendering is done twice ?
Once the "normal" way, and once again after I use the
QgsMapCanvas::zoomScale method after calculating the new target scale.
Any idea for improving it ? I assume I would have to disconnect one (not
found yet) signal/slot, then set the scale and reconnect this signal/slot
afterwards ?
Regards
Michaël
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150417/e6c87e6e/attachment.html>
More information about the Qgis-developer
mailing list