<div dir="ltr"><div><div><div><div><div><div>Hi QGIS !<br><br></div>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".<br><br></div>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.<br><br></div>I made a little python script as a proof of concept to illustrate it :<br><a href="http://paste.debian.net/167247/">http://paste.debian.net/167247/</a><br><br></div>In this script, I hard coded the scales, but oviously we should get them from the project properties.<br><br></div>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.<br><br></div><div>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 ?<br><br></div><div>Regards<br><br></div><div>MichaĆ«l<br></div><br></div>