Hi,<br><br>I'm currently trying to overload the canvasPressEvent from QgsMapTool in my plugin but it doesn't work, did i forgot anything in my code?? I put a message box when the mouse is clicked on the canvas but I never get the message. Is it the constructor and i don't initialize the QgsMapTool correctly??
<br><br>/***************** plugin.h<br><br>[...]<br>#include <qgsmaptool.h><br>[...]<br>class plugin : public QObject, public QgisPlugin, public QgsMapTool {<br> Q_OBJECT;<br> public:<br> virtual ~plugin();
<br> plugin(QgisApp * theApplication, QgisIface * theInterface);<br> virtual void canvasPressEvent(QMouseEvent * e);<br> public slots:<br> [...]<br> private:<br> [...]<br><br>/*****************
plugin.cpp<br><br>[...]<br>#include "plugin.h"<br>QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer) {<br> return new plugin(theQGisAppPointer, theQgisInterfacePointer);
<br>}<br>[...]<br>plugin::plugin(QgisApp * theQGisApp, QgisIface * theQgisInterface) : <br> QgisPlugin(sName,sDescription,sPluginVersion,sPluginType), <br> mQGisApp(theQGisApp), <br> mQGisIface(theQgisInterface),
<br> QgsMapTool(theQgisInterface->getMapCanvas()) <--------------------------- <br>{<br> /* do nothing */<br>}<br>[...]<br>void plugin::canvasPressEvent(QMouseEvent * e) {<br> QMessageBox::critical(0, QString("SEARCH"), QString("Cannot create Search Window."), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
<br>}<br>[...]<br><br>Thx a lot<br><br>Mathieu Ouimet<br><br><div><span class="gmail_quote">On 6/29/06, <b class="gmail_sendername">Martin Dobias</b> <<a href="mailto:wonder.sk@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
wonder.sk@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 6/28/06, Mathieu Ouimet <<a href="mailto:noryoku@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">noryoku@gmail.com</a>> wrote:<br>> Hi,<br>><br>> Is it possible to obtain a position on the map ( well-known text (wkt) or
<br>> well-known binary (wkb) ) by the click of the mouse in the map canvas??? Is
<br>> there a fonction in the Qgis API who does that??<br><br>Hi Mathieu,<br><br>yes this is possible in current development version (which will be<br>version 0.8). You can create a plugin with your custom class derived
<br>from QgsMapCanvasTool which will handle clicks on map canvas and use<br>the position for any use you might want.<br><br>><br>> Also, with a position in the wkt or wkb format, is it possible to zoom to<br>> the position. Is there a fonction in the Api like
<br>> "zoomToPosition(position)" where the position is a wkt or wkb.<br><br>You can use function QgsMapCanvas::setExtent to change extent of the<br>map canvas. For conversion from/to wkt/wkb use class QgsGeometry.
<br><br><br>Martin<br><br>><br>> Thx a lot :)<br>><br>> --<br>> Mathieu Ouimet<br>> _______________________________________________<br>> Qgis-developer mailing list<br>> <a href="mailto:Qgis-developer@lists.qgis.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
Qgis-developer@lists.qgis.org</a><br>> <a href="http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
</a><br>><br>><br>><br></blockquote></div>
<br>