Skip to content
Permalink
Browse files
applied Martins patch to backport georeference plugin fix to 0.8
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@7133 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Aug 13, 2007
1 parent 48447b7 commit 5880887
Show file tree
Hide file tree
Showing 11 changed files with 454 additions and 186 deletions.

Large diffs are not rendered by default.

@@ -41,6 +41,7 @@ SET(QGIS_GUI_SRCS
../gui/qgsmaprender.cpp
../gui/qgsmaptoolcapture.cpp
../gui/qgsmaptool.cpp
../gui/qgsmaptoolemitpoint.cpp
../gui/qgsmaptoolidentify.cpp
../gui/qgsmaptoolpan.cpp
../gui/qgsmaptoolselect.cpp
@@ -142,6 +143,7 @@ SET(QGIS_GUI_MOC_HDRS
../gui/qgsmapoverviewcanvas.h
../gui/qgsmaplayer.h
../gui/qgsmaplayerregistry.h
../gui/qgsmaptoolemitpoint.h
../gui/qgsmaptoolidentify.h
../gui/qgspointstylewidget.h
../widgets/projectionselector/qgsprojectionselector.h
@@ -403,6 +405,7 @@ SET(QGIS_GUI_HDRS
../gui/qgsmaprender.h
../gui/qgsmaptoolcapture.h
../gui/qgsmaptool.h
../gui/qgsmaptoolemitpoint.h
../gui/qgsmaptoolidentify.h
../gui/qgsmaptoolpan.h
../gui/qgsmaptoolselect.h
@@ -109,6 +109,7 @@ libqgis_guiHEADERS = \
qgsmapserverexport.h \
qgsmaptool.h \
qgsmaptoolcapture.h \
qgsmaptoolemitpoint.h \
qgsmaptoolidentify.h \
qgsmaptoolpan.h \
qgsmaptoolselect.h \
@@ -178,6 +179,7 @@ libqgis_gui_la_MOC = \
qgsmapoverviewcanvas.moc.cpp \
qgsmaprender.moc.cpp \
qgsmapserverexport.moc.cpp \
qgsmaptoolemitpoint.moc.cpp \
qgsmaptoolidentify.moc.cpp \
qgsmarkerdialog.moc.cpp \
qgsmeasure.moc.cpp \
@@ -240,6 +242,7 @@ libqgis_gui_la_SOURCES = \
qgsmapserverexport.cpp \
qgsmaptool.cpp \
qgsmaptoolcapture.cpp \
qgsmaptoolemitpoint.cpp \
qgsmaptoolidentify.cpp \
qgsmaptoolpan.cpp \
qgsmaptoolselect.cpp \
@@ -1,5 +1,5 @@
/***************************************************************************
qgsmaptool.h - base class for map canvas tools
qgsmaptool.cpp - base class for map canvas tools
----------------------
begin : January 2006
copyright : (C) 2006 by Martin Dobias
@@ -21,9 +21,10 @@
#include "qgsmaptopixel.h"
#include "qgsproject.h"
#include <QAction>
#include <QAbstractButton>

QgsMapTool::QgsMapTool(QgsMapCanvas* canvas)
: mCanvas(canvas), mCursor(Qt::CrossCursor), mAction(NULL)
: mCanvas(canvas), mCursor(Qt::CrossCursor), mAction(NULL), mButton(NULL)
{
}

@@ -74,9 +75,11 @@ QPoint QgsMapTool::toCanvasCoords(const QgsPoint& point)

void QgsMapTool::activate()
{
// make action active
// make action and/or button active
if (mAction)
mAction->setChecked(true);
if (mButton)
mButton->setChecked(true);

// set cursor (map tools usually set it in constructor)
mCanvas->setCursor(mCursor);
@@ -88,4 +91,17 @@ void QgsMapTool::deactivate()
{
if (mAction)
mAction->setChecked(false);
if (mButton)
mButton->setChecked(false);
}

void QgsMapTool::setButton(QAbstractButton* button)
{
mButton = button;
}

QAbstractButton* QgsMapTool::button()
{
return mButton;
}

@@ -26,7 +26,7 @@ class QMouseEvent;
class QgsPoint;
class QPoint;
class QAction;

class QAbstractButton;

class QgsMapTool
{
@@ -47,15 +47,24 @@ class QgsMapTool
//! Called when rendering has finished
virtual void renderComplete() {}

/** Use this to associate a button, toolbutton, menu entry etc
* that inherits qaction to this maptool. Then when the setMapTool

/** Use this to associate a QAction to this maptool. Then when the setMapTool
* method of mapcanvas is called the action state will be set to on.
* Usually this will cause e.g. a toolbutton to appear pressed in and
* the previously used toolbutton to pop out. */
void setAction(QAction* action) { mAction = action; }

/** Return associated action with map tool or NULL if no action is associated */
QAction* action() { return mAction; }

/** Use this to associate a button to this maptool. It has the same meaning
* as setAction() function except it works with a button instead of an QAction. */
void setButton(QAbstractButton* button);

/** Return associated button with map tool or NULL if no button is associated */
QAbstractButton* button();


/** Check whether this MapTool performs a zoom or pan operation.
* If it does, we will be able to perform the zoom and then
* resume operations with the original / previously used tool.*/
@@ -91,6 +100,10 @@ class QgsMapTool
//! which will be used to set that action as active
QAction* mAction;

//! optionally map tool can have pointer to a button
//! which will be used to set that action as active
QAbstractButton* mButton;

};

#endif
@@ -1,6 +1,7 @@
<RCC>
<qresource prefix="/" >
<file>icon.png</file>
<file>georef.png</file>
<file>icon.png</file>
<file>pencil.png</file>
</qresource>
</RCC>
@@ -1,26 +1,45 @@

#include <QValidator>
#include <mapcoordsdialog.h>

#include <qgsmapcanvas.h>
#include <qgsmaptoolemitpoint.h>

MapCoordsDialog::MapCoordsDialog() {

}


MapCoordsDialog::MapCoordsDialog(const QgsPoint& pixelCoords,
MapCoordsDialog::MapCoordsDialog(const QgsPoint& pixelCoords, QgsMapCanvas* qgisCanvas,
QWidget* parent, Qt::WFlags fl)
: QDialog(parent, fl) {
setupUi(this);
mPixelCoords = pixelCoords;
mQgisCanvas = qgisCanvas;
leXCoord->setValidator(new QDoubleValidator(this));
leYCoord->setValidator(new QDoubleValidator(this));

mToolEmitPoint = new QgsMapToolEmitPoint(qgisCanvas);
mToolEmitPoint->setButton(btnPointFromCanvas);
connect((QgsMapToolEmitPoint*)mToolEmitPoint, SIGNAL(gotPoint(QgsPoint&,Qt::MouseButton)),
this, SLOT(setXY(QgsPoint&)));

connect(leXCoord, SIGNAL(textChanged(const QString&)), this, SLOT(updateOK()));
connect(leYCoord, SIGNAL(textChanged(const QString&)), this, SLOT(updateOK()));
updateOK();
}


MapCoordsDialog::~MapCoordsDialog() {

delete mToolEmitPoint;
}

void MapCoordsDialog::updateOK()
{
bool enable = (leXCoord->text().size() != 0 && leYCoord->text().size() != 0);
buttonOk->setEnabled(enable);
}

void MapCoordsDialog::on_buttonOk_clicked() {
QgsPoint mapCoords(leXCoord->text().toDouble(), leYCoord->text().toDouble());
@@ -32,3 +51,20 @@ void MapCoordsDialog::on_buttonCancel_clicked()
{
reject();
}

void MapCoordsDialog::setXY(QgsPoint & xy)
{
leXCoord->clear();
leYCoord->clear();
leXCoord->insert(QString::number(xy.x(),'f',7));
leYCoord->insert(QString::number(xy.y(),'f',7));

mQgisCanvas->setMapTool(mPrevMapTool);
}

void MapCoordsDialog::on_btnPointFromCanvas_clicked()
{
mPrevMapTool = mQgisCanvas->mapTool();
mQgisCanvas->setMapTool(mToolEmitPoint);
}

@@ -14,14 +14,17 @@

#include <qgspoint.h>

class QgsMapCanvas;
class QgsMapTool;

#include <ui_mapcoordsdialogbase.h>
#include <QDialog>
class MapCoordsDialog : public QDialog, private Ui::MapCoordsDialogBase
{
Q_OBJECT
public:
MapCoordsDialog();
MapCoordsDialog(const QgsPoint& pixelCoords,
MapCoordsDialog(const QgsPoint& pixelCoords, QgsMapCanvas* qgisCanvas,
QWidget* parent = 0, Qt::WFlags fl = 0);
~MapCoordsDialog();

@@ -30,9 +33,19 @@ public slots:
void on_buttonOk_clicked();
void on_buttonCancel_clicked();

void on_btnPointFromCanvas_clicked();

void setXY(QgsPoint &);
void updateOK();

private:

QgsPoint mPixelCoords;

QgsMapTool* mToolEmitPoint;
QgsMapTool* mPrevMapTool;

QgsMapCanvas* mQgisCanvas;

signals:

0 comments on commit 5880887

Please sign in to comment.