[Qgis-developer] API functions

Mathieu Ouimet noryoku at gmail.com
Tue Jul 4 11:30:27 EDT 2006


Hi,

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??

/***************** plugin.h

[...]
#include <qgsmaptool.h>
[...]
class plugin : public QObject, public QgisPlugin, public QgsMapTool {
    Q_OBJECT;
    public:
        virtual ~plugin();
        plugin(QgisApp * theApplication, QgisIface * theInterface);
        virtual void canvasPressEvent(QMouseEvent * e);
    public slots:
        [...]
    private:
        [...]

/***************** plugin.cpp

[...]
#include "plugin.h"
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface
* theQgisInterfacePointer) {
    return new plugin(theQGisAppPointer, theQgisInterfacePointer);
}
[...]
plugin::plugin(QgisApp * theQGisApp, QgisIface * theQgisInterface) :
    QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
    mQGisApp(theQGisApp),
    mQGisIface(theQgisInterface),
    QgsMapTool(theQgisInterface->getMapCanvas())
<---------------------------
{
    /* do nothing */
}
[...]
void plugin::canvasPressEvent(QMouseEvent * e) {
    QMessageBox::critical(0, QString("SEARCH"), QString("Cannot create
Search Window."), QMessageBox::Ok, QMessageBox::NoButton,
QMessageBox::NoButton);
}
[...]

Thx a lot

Mathieu Ouimet

On 6/29/06, Martin Dobias <wonder.sk at gmail.com> wrote:
>
> On 6/28/06, Mathieu Ouimet <noryoku at gmail.com> wrote:
> > Hi,
> >
> > Is it possible to obtain a position on the map ( well-known text (wkt)
> or
> > well-known binary (wkb) ) by the click of the mouse in the map
> canvas???  Is
> > there a fonction in the Qgis API who does that??
>
> Hi Mathieu,
>
> yes this is possible in current development version (which will be
> version 0.8). You can create a plugin with your custom class derived
> from QgsMapCanvasTool which will handle clicks on map canvas and use
> the position for any use you might want.
>
> >
> > Also, with a position in the wkt or wkb format, is it possible to zoom
> to
> > the position.  Is there a fonction in the Api like
> > "zoomToPosition(position)" where the position is a wkt or wkb.
>
> You can use function QgsMapCanvas::setExtent to change extent of the
> map canvas. For conversion from/to wkt/wkb use class QgsGeometry.
>
>
> Martin
>
> >
> > Thx a lot :)
> >
> > --
> > Mathieu Ouimet
> > _______________________________________________
> > Qgis-developer mailing list
> > Qgis-developer at lists.qgis.org
> > http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20060704/4839a4f3/attachment.html


More information about the Qgis-developer mailing list