<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
Sorry to come again with this stuff, but I am really puzzled.<br>
<br>
I am wondering why I have a constant 9 pixels shift between<br>
QCursor.pos().x()<br>
and<br>
mouseEvent.pos().x() + self.canvas.pos().x() +
self.iface.mainWindow().pos().x()<br>
<br>
Can someone explain this to me?<br>
<br>
Also I am still looking for a smart way to perform a snap with the
QgsMapTool...<br>
Do you think it could be easily added as an option?<br>
<br>
Thanks a lot,<br>
<br>
Denis<br>
<br>
<br>
<br>
On 02/06/2012 04:28 PM, Denis Rouzaud wrote:
<blockquote cite="mid:4F2FF1B2.1050606@gmail.com" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Hi Nathan,<br>
<br>
Thanks for your reply.<br>
I am a little bit confused as I do not really know how to set the
mouse position. I have a solution, but it is not giving the same
experience as when you create a new feature in a layer:<br>
<br>
I use the canvasMoveEvent, I get the point in pixels in the canvas
using <br>
result,snappingResults =
QgsMapCanvasSnapper(self.canvas).snapToBackgroundLayers(pixPoint,[])<br>
<br>
The best I could do is calculating the difference in pixels:<br>
self.transform = self.canvas.getCoordinateTransform()<br>
snappedPoint = QgsPoint(snappingResults[0].snappedVertex) <br>
startPoint =
self.transform.toMapCoordinates(pixPoint.x(),pixPoint.y())<br>
dx =
(snappedPoint.x()-startPoint.x())/self.transform.mapUnitsPerPixel()<br>
dy =
(snappedPoint.y()-startPoint.y())/self.transform.mapUnitsPerPixel()<br>
<br>
And then setting the cursor by applying this difference:<br>
qcur = QCursor.pos()<br>
QCursor().setPos(qcur.x()+dx,qcur.y()-dy)<br>
<br>
I am quite sure there is a smarter way, but I cannot find it!<br>
Also the problem is that the mouse is oscillating using this
method. The only reason I can give is that canvasMoveEvent is sent
again before the previously called method has returning, could it
be true?<br>
<br>
I am a little bit lost in this. I would really appreciate your
help!<br>
<br>
Thanks again,<br>
<br>
Denis<br>
<br>
<br>
<br>
<br>
On 02/03/2012 07:37 AM, Nathan Woodrow wrote:
<blockquote
cite="mid:CAAi8Yg9zY_C_VWfBjWhTx=8ru3o6Z+J0WcF3FKG8YpFT1jyMGw@mail.gmail.com"
type="cite">Hey Denis,
<div><br>
</div>
<div><span class="Apple-style-span"
style="background-color:rgb(255,255,255)">The QCursor <span
class="Apple-style-span"
style="color:rgb(54,53,52);line-height:13px"><span
style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><a
moz-do-not-send="true"
href="http://developer.qt.nokia.com/doc/qt-4.8/qcursor.html#setPos"
style="font-size:11px;font-weight:bold;font-family:Verdana,'DejaVu
Sans',Geneva,sans-serif;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;color:rgb(0,115,47);text-decoration:none">setPos</a><font
class="Apple-style-span" face="arial, helvetica,
sans-serif"><span class="Apple-style-span"
style="font-size:11px"> </span>methods are static
so you shouldn't need to get access to the instance to
move the cursor position.</font></span></span></span></div>
<div><font class="Apple-style-span" face="Verdana, 'DejaVu
Sans', Geneva, sans-serif" color="#363534"><span
class="Apple-style-span"
style="font-size:11px;line-height:13px"><b><br>
</b></span></font></div>
<div><font class="Apple-style-span" face="Verdana, 'DejaVu
Sans', Geneva, sans-serif" color="#363534"><span
class="Apple-style-span"
style="font-size:11px;line-height:13px"><b>- Nathan<br>
</b></span></font><br>
<div class="gmail_quote">On Fri, Feb 3, 2012 at 4:07 PM, Denis
Rouzaud <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:denis.rouzaud@gmail.com">denis.rouzaud@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex"> Is
there anyway to access the QCursor within
QgsMapToolEmitPoint. I see there is a mCursor, but it's
protected.</blockquote>
</div>
<br>
</div>
</blockquote>
</blockquote>
</body>
</html>