Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-04 Thread Tom Chadwin
I don't think I knew about show() either, so I have a couple of things to try. Many thanks! Tom -- View this message in context: http://osgeo-org.1560.x6.nabble.com/setting-QgsMapCanvas-size-for-testing-map-tools-tp5273987p5274573.html Sent from the Quantum GIS - Developer mailing list

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-01 Thread Sandro Santilli
On Fri, Jul 01, 2016 at 06:47:16PM +0200, Martin Dobias wrote: > I think what you are up to is not to find out scale(), but actually > mapUnitsPerPixel(). Scale in QGIS is calculated as ( extent_width / ( > canvas_width * dpi) ) with some extra conversions involved, see > QgsScaleCalculator

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-01 Thread Martin Dobias
Hi Tom On Fri, Jul 1, 2016 at 5:25 PM, Tom Chadwin wrote: > Hi Martin > > > Martin Dobias wrote > iface.mapCanvas().geometry() >> PyQt4.QtCore.QRect(0, 0, 879, 390) > iface.mapCanvas().viewport().geometry() >> PyQt4.QtCore.QRect(3, 3, 873, 384) > > Ah, OK! I

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-01 Thread Martin Dobias
Hi Sandro On Fri, Jul 1, 2016 at 6:07 PM, Sandro Santilli wrote: > On Fri, Jul 01, 2016 at 05:58:57PM +0200, Sandro Santilli wrote: >> On Thu, Jun 30, 2016 at 10:14:34PM +0100, Barry Rowlingson wrote: >> > Maybe I've missed something here, but doesn't the canvas resize method >> >

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-01 Thread Sandro Santilli
On Fri, Jul 01, 2016 at 05:58:57PM +0200, Sandro Santilli wrote: > On Thu, Jun 30, 2016 at 10:14:34PM +0100, Barry Rowlingson wrote: > > Maybe I've missed something here, but doesn't the canvas resize method > > set the canvas pixel size? This behaves as expected when run > > standalone from a

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-01 Thread Sandro Santilli
On Thu, Jun 30, 2016 at 10:14:34PM +0100, Barry Rowlingson wrote: > Maybe I've missed something here, but doesn't the canvas resize method > set the canvas pixel size? This behaves as expected when run > standalone from a python prompt. It does ! Thanks for the pointer. --strk;

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-01 Thread Tom Chadwin
Hi Martin Martin Dobias wrote iface.mapCanvas().geometry() > PyQt4.QtCore.QRect(0, 0, 879, 390) iface.mapCanvas().viewport().geometry() > PyQt4.QtCore.QRect(3, 3, 873, 384) Ah, OK! I didn't know anything about a canvas frame. So, without doing setFrameStyle(), does canvas.extent()

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-01 Thread Martin Dobias
Hi Tom! On Fri, Jul 1, 2016 at 1:08 PM, Tom Chadwin wrote: > Barry Rowlingson wrote >> Maybe I've missed something here, but doesn't the canvas resize method >> set the canvas pixel size? This behaves as expected when run >> standalone from a python prompt. >> >> from

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-07-01 Thread Tom Chadwin
Barry Rowlingson wrote > Maybe I've missed something here, but doesn't the canvas resize method > set the canvas pixel size? This behaves as expected when run > standalone from a python prompt. > > from qgis.core import * > from qgis.gui import * > app = QgsApplication([],True) > canvas =

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-06-30 Thread Barry Rowlingson
Maybe I've missed something here, but doesn't the canvas resize method set the canvas pixel size? This behaves as expected when run standalone from a python prompt. from qgis.core import * from qgis.gui import * app = QgsApplication([],True) canvas = QgsMapCanvas() canvas.show()

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-06-30 Thread Tom Chadwin
I asked about this a while back, as I could not get a defined canvas size in my tests. I never found an answer, but never understood why it didn't work: https://lists.osgeo.org/pipermail/qgis-developer/2015-November/040392.html Tom -- View this message in context:

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-06-29 Thread Sandro Santilli
On Wed, Jun 29, 2016 at 04:44:29PM +0200, Richard Duivenvoorde wrote: > https://github.com/rduivenvoorde/simplesvg/blob/master/src/simplesvg/mapsizer/MapSizerDialog.py#L93 > > the hard part (I think) is that the exact size of the mapcanvas was > defined relative to other (parent) widgets, and

Re: [Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-06-29 Thread Richard Duivenvoorde
On 29-06-16 16:37, Sandro Santilli wrote: > I'm writing a testcase for bug 13952 [1] and would need a > way to set the map canvas size so to be able to syntetize > clicks on pixels with predictable contents. How can it be > done ? > > Beside, I've found an QgsMapCanvas::updateMapSize() method >

[Qgis-developer] setting QgsMapCanvas size, for testing map tools

2016-06-29 Thread Sandro Santilli
I'm writing a testcase for bug 13952 [1] and would need a way to set the map canvas size so to be able to syntetize clicks on pixels with predictable contents. How can it be done ? Beside, I've found an QgsMapCanvas::updateMapSize() method which is declared in the header but never defined (git