Skip to content
Permalink
Browse files
Updated georeferencer plugin to use emit tool for acquiring coordinat…
…es of a point from map canvas.

Removed sendXY signal from QgsMapCanvas.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7036 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jun 17, 2007
1 parent 4b801ce commit c316571b8ea981e0476eab23e05d3831544fdc72
@@ -645,13 +645,6 @@ void QgsMapCanvas::mousePressEvent(QMouseEvent * e)
mCanvasProperties->mouseButtonDown = true;
mCanvasProperties->rubberStartPoint = e->pos();

if (e->button() == Qt::RightButton )
{
QPoint xy = e->pos();
QgsPoint coord = getCoordinateTransform()->toMapCoordinates(xy);
emit sendXY(coord);
}

} // mousePressEvent


@@ -274,8 +274,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
void setProgress(int,int);
/** emits current mouse position */
void xyCoordinates(QgsPoint & p);
/** emits current mouse position on right mouse click */
void sendXY(QgsPoint & p);

//! Emitted when the scale of the map changes
void scaleChanged(double);
@@ -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,24 +1,33 @@

#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(mToolEmitPoint, SIGNAL(gotPoint(QgsPoint&,Qt::MouseButton)), this, SLOT(setXY(QgsPoint&)));
}


MapCoordsDialog::~MapCoordsDialog() {

delete mToolEmitPoint;
}


@@ -35,6 +44,16 @@ void MapCoordsDialog::on_buttonCancel_clicked()

void MapCoordsDialog::setXY(QgsPoint & xy)
{
leXCoord->insert(QString::number(xy.x(),'f',7));
leYCoord->insert(QString::number(xy.y(),'f',7));
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,11 +33,18 @@ public slots:
void on_buttonOk_clicked();
void on_buttonCancel_clicked();

void on_btnPointFromCanvas_clicked();

void setXY(QgsPoint &);

private:

QgsPoint mPixelCoords;

QgsMapTool* mToolEmitPoint;
QgsMapTool* mPrevMapTool;

QgsMapCanvas* mQgisCanvas;

signals:

@@ -1,15 +1,12 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>MapCoordsDialogBase</class>
<widget class="QDialog" name="MapCoordsDialogBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>290</width>
<height>110</height>
<width>389</width>
<height>203</height>
</rect>
</property>
<property name="windowTitle" >
@@ -18,77 +15,187 @@
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>10</number>
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>X:</string>
<string>Enter X and Y coordinates which correspond with the selected point on the image. Alternatively, click the button with icon of a pencil and then click a corresponding point on map canvas of QGIS to fill in coordinates of that point.</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>Y:</string>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3" >
<widget class="QLineEdit" name="leYCoord" />
</item>
<item row="0" column="1" colspan="3" >
<widget class="QLineEdit" name="leXCoord" />
</item>
<item row="2" column="0" colspan="2" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>90</width>
<height>20</height>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="3" >
<widget class="QPushButton" name="buttonOk" >
<property name="text" >
<string>&amp;OK</string>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="shortcut" >
<string/>
<property name="spacing" >
<number>6</number>
</property>
<property name="autoDefault" >
<bool>true</bool>
<item row="0" column="1" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>X:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>Y:</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLineEdit" name="leXCoord" />
</item>
<item row="1" column="2" >
<widget class="QLineEdit" name="leYCoord" />
</item>
<item rowspan="2" row="0" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item rowspan="2" row="0" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="default" >
<bool>true</bool>
<property name="sizeHint" >
<size>
<width>20</width>
<height>21</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="buttonCancel" >
<property name="text" >
<string>&amp;Cancel</string>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="shortcut" >
<string/>
<property name="spacing" >
<number>6</number>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
</widget>
<item>
<widget class="QPushButton" name="btnPointFromCanvas" >
<property name="text" >
<string> from map canvas</string>
</property>
<property name="icon" >
<iconset resource="georeferencer.qrc" >:/pencil.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>21</width>
<height>27</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonCancel" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
<property name="shortcut" >
<string/>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonOk" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="shortcut" >
<string/>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@@ -100,6 +207,8 @@
<tabstop>buttonCancel</tabstop>
<tabstop>buttonOk</tabstop>
</tabstops>
<resources/>
<resources>
<include location="georeferencer.qrc" />
</resources>
<connections/>
</ui>
Binary file not shown.
Loading

0 comments on commit c316571

Please sign in to comment.