Skip to content

Commit

Permalink
Added QgsMapToolEmitPoint which emits a signal when a point on map ca…
Browse files Browse the repository at this point in the history
…nvas is clicked.

git-svn-id: http://svn.osgeo.org/qgis/trunk@6989 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jun 9, 2007
1 parent a6be9c4 commit 9289a37
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/gui/gui.sip
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
%Include qgsmapcanvasitem.sip
%Include qgsmapcanvasmap.sip
%Include qgsmaptool.sip
%Include qgsmaptoolemitpoint.sip
%Include qgsmaptoolpan.sip
%Include qgsmaptoolzoom.sip
%Include qgsmapoverviewcanvas.sip
Expand Down
2 changes: 2 additions & 0 deletions python/gui/qgsmaptool.sip
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class QgsMapTool : QObject
sipClass = sipClass_QgsMapToolZoom;
else if (dynamic_cast<QgsMapToolPan*>(sipCpp) != NULL)
sipClass = sipClass_QgsMapToolPan;
else if (dynamic_cast<QgsMapToolEmitPoint*>(sipCpp) != NULL)
sipClass = sipClass_QgsMapToolEmitPoint;
else
sipClass = NULL;
%End
Expand Down
25 changes: 25 additions & 0 deletions python/gui/qgsmaptoolemitpoint.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

class QgsMapToolEmitPoint : QgsMapTool
{
%TypeHeaderCode
#include <qgsmaptoolemitpoint.h>
%End

public:
//! constructor
QgsMapToolEmitPoint(QgsMapCanvas* canvas);

//! Overridden mouse move event
virtual void canvasMoveEvent(QMouseEvent * e);

//! Overridden mouse press event - emits the signal
virtual void canvasPressEvent(QMouseEvent * e);

//! Overridden mouse release event
virtual void canvasReleaseEvent(QMouseEvent * e);

signals:

//! signal emitted on canvas click
void gotPoint(QgsPoint& point, Qt::MouseButton button);
};
3 changes: 3 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ qgsmapcanvasitem.cpp
qgsmapcanvasmap.cpp
qgsmapoverviewcanvas.cpp
qgsmaptool.cpp
qgsmaptoolemitpoint.cpp
qgsmaptoolpan.cpp
qgsmaptoolzoom.cpp
qgsmessageviewer.cpp
Expand All @@ -26,6 +27,7 @@ qgsencodingfiledialog.h
qgslayerprojectionselector.h
qgsmapcanvas.h
qgsmapoverviewcanvas.h
qgsmaptoolemitpoint.h
qgsprojectionselector.h
)

Expand Down Expand Up @@ -81,6 +83,7 @@ qgsmapcanvasitem.h
qgsmapcanvasmap.h
qgsmapoverviewcanvas.h
qgsmaptool.h
qgsmaptoolemitpoint.h
qgsmaptoolpan.h
qgsmaptoolzoom.h
qgsmessageviewer.h
Expand Down
39 changes: 39 additions & 0 deletions src/gui/qgsmaptoolemitpoint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/***************************************************************************
qgsmaptoolemitpoint.cpp - map tool that emits a signal on click
---------------------
begin : June 2007
copyright : (C) 2007 by Martin Dobias
email : wonder.sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */


#include "qgsmaptoolemitpoint.h"
#include "qgsmapcanvas.h"


QgsMapToolEmitPoint::QgsMapToolEmitPoint(QgsMapCanvas* canvas)
: QgsMapTool(canvas)
{
}

void QgsMapToolEmitPoint::canvasMoveEvent(QMouseEvent * e)
{
}

void QgsMapToolEmitPoint::canvasPressEvent(QMouseEvent * e)
{
QgsPoint pnt = toMapCoords(e->pos());
emit gotPoint(pnt, e->button());
}

void QgsMapToolEmitPoint::canvasReleaseEvent(QMouseEvent * e)
{
}
48 changes: 48 additions & 0 deletions src/gui/qgsmaptoolemitpoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/***************************************************************************
qgsmaptoolemitpoint.h - map tool that emits a signal on click
---------------------
begin : June 2007
copyright : (C) 2007 by Martin Dobias
email : wonder.sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */

#ifndef QGSMAPTOOLEMITPOINT_H
#define QGSMAPTOOLEMITPOINT_H

#include "qgspoint.h"
#include "qgsmaptool.h"
class QgsMapCanvas;


class GUI_EXPORT QgsMapToolEmitPoint : public QgsMapTool
{
Q_OBJECT

public:
//! constructor
QgsMapToolEmitPoint(QgsMapCanvas* canvas);

//! Overridden mouse move event
virtual void canvasMoveEvent(QMouseEvent * e);

//! Overridden mouse press event - emits the signal
virtual void canvasPressEvent(QMouseEvent * e);

//! Overridden mouse release event
virtual void canvasReleaseEvent(QMouseEvent * e);

signals:

//! signal emitted on canvas click
void gotPoint(QgsPoint& point, Qt::MouseButton button);
};

#endif

0 comments on commit 9289a37

Please sign in to comment.