Skip to content

Commit 59be558

Browse files
author
timlinux
committedAug 7, 2008
Final fixes for ticket #1024
- you can now set the display CRS to any CRS you like by selecting one from the projection selector using the button provided - other small cleanups to the coordinate capture plugin git-svn-id: http://svn.osgeo.org/qgis/trunk@9012 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent aa896df commit 59be558

File tree

3 files changed

+45
-23
lines changed

3 files changed

+45
-23
lines changed
 

‎src/plugins/coordinate_capture/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ ADD_LIBRARY (coordinatecaptureplugin MODULE ${coordinatecapture_SRCS} ${coordina
3131

3232
INCLUDE_DIRECTORIES(
3333
${CMAKE_CURRENT_BINARY_DIR}
34-
../../core ../../core/raster ../../core/renderer ../../core/symbology
34+
${CMAKE_CURRENT_BINARY_DIR}/../../ui/
35+
../../core
36+
../../core/raster
37+
../../core/renderer
38+
../../core/symbology
3539
../../gui
3640
..
3741
)

‎src/plugins/coordinate_capture/coordinatecapture.cpp

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <qgis.h>
2929
#include <qgsspatialrefsys.h>
3030
#include <qgscoordinatetransform.h>
31+
#include <qgsgenericprojectionselector.h>
3132

3233
#include "coordinatecapture.h"
3334
#include "coordinatecapturegui.h"
@@ -79,7 +80,7 @@ CoordinateCapture::~CoordinateCapture()
7980
*/
8081
void CoordinateCapture::initGui()
8182
{
82-
83+
mEpsgId = GEOEPSG_ID;
8384
// Create the action for tool
8485
mQActionPointer = new QAction(QIcon(":/coordinatecapture/coordinate_capture.png"),tr("Coordinate Capture"), this);
8586
// Set the what's this text
@@ -102,19 +103,20 @@ void CoordinateCapture::initGui()
102103
mypLayout->setColumnMinimumWidth( 0, 36 );
103104
mypWidget->setLayout(mypLayout);
104105

105-
QLabel * mypGeoLabel = new QLabel(mypWidget);
106-
mypGeoLabel->setPixmap(QPixmap(":/coordinatecapture/geographic.png"));
106+
QToolButton * mypUserCrsToolButton = new QToolButton(mypWidget);
107+
mypUserCrsToolButton->setIcon(QIcon(":/coordinatecapture/geographic.png"));
108+
connect(mypUserCrsToolButton , SIGNAL(clicked()), this, SLOT(setCRS()));
107109

108110
QLabel * mypCRSLabel = new QLabel(mypWidget);
109111
mypCRSLabel->setPixmap(QPixmap(":/coordinatecapture/transformed.png"));
110112

111-
mpGeoEdit = new QLineEdit(mypWidget);
112-
mpGeoEdit->setReadOnly(true);
113-
mpGeoEdit->setToolTip(tr("Coordinate in lat/long WGS84"));
113+
mpUserCrsEdit = new QLineEdit(mypWidget);
114+
mpUserCrsEdit->setReadOnly(true);
115+
mpUserCrsEdit->setToolTip(tr("Coordinate in your selected CRS"));
114116

115-
mpTransformedEdit = new QLineEdit(mypWidget);
116-
mpTransformedEdit->setReadOnly(true);
117-
mpTransformedEdit->setToolTip(tr("Coordinate in map canvas coordinate reference system"));
117+
mpCanvasEdit = new QLineEdit(mypWidget);
118+
mpCanvasEdit->setReadOnly(true);
119+
mpCanvasEdit->setToolTip(tr("Coordinate in map canvas coordinate reference system"));
118120

119121
QPushButton * mypCopyButton = new QPushButton(mypWidget);
120122
mypCopyButton->setText(tr("Copy to clipboard"));
@@ -126,10 +128,10 @@ void CoordinateCapture::initGui()
126128
mpTrackMouseButton->setChecked(false);
127129
mpTrackMouseButton->setIcon(QIcon(":/coordinatecapture/tracking.png"));
128130

129-
mypLayout->addWidget(mypGeoLabel, 0,0);
130-
mypLayout->addWidget(mpGeoEdit, 0,1);
131+
mypLayout->addWidget(mypUserCrsToolButton, 0,0);
132+
mypLayout->addWidget(mpUserCrsEdit, 0,1);
131133
mypLayout->addWidget(mypCRSLabel, 1,0);
132-
mypLayout->addWidget(mpTransformedEdit, 1,1);
134+
mypLayout->addWidget(mpCanvasEdit, 1,1);
133135
mypLayout->addWidget(mpTrackMouseButton, 2,0);
134136
mypLayout->addWidget(mypCopyButton, 2,1);
135137

@@ -150,6 +152,17 @@ void CoordinateCapture::help()
150152
{
151153
//implement me!
152154
}
155+
156+
void CoordinateCapture::setCRS()
157+
{
158+
QgsGenericProjectionSelector mySelector(mQGisIface->getMainWindow());
159+
mySelector.setSelectedEpsg(mEpsgId);
160+
if (mySelector.exec())
161+
{
162+
mEpsgId = mySelector.getSelectedEpsg();
163+
}
164+
}
165+
153166
void CoordinateCapture::mouseClicked(QgsPoint thePoint)
154167
{
155168
//clicking on the canvas will update the widgets and then disable
@@ -170,13 +183,13 @@ void CoordinateCapture::update(QgsPoint thePoint)
170183
{
171184
//this is the coordinate resolved back to lat / lon
172185
QgsSpatialRefSys mySrs;
173-
mySrs.createFromEpsg(GEOEPSG_ID); //geo lat lon
186+
mySrs.createFromEpsg(mEpsgId); //geo lat lon
174187
QgsCoordinateTransform myTransform(mQGisIface->getMapCanvas()->mapRenderer()->destinationSrs(),mySrs);
175-
QgsPoint myGeoPoint = myTransform.transform(thePoint);
176-
mpGeoEdit->setText(QString::number( myGeoPoint.x(),'f',3) + "," +
177-
QString::number( myGeoPoint.y(),'f',3));
188+
QgsPoint myUserCrsPoint = myTransform.transform(thePoint);
189+
mpUserCrsEdit->setText(QString::number( myUserCrsPoint.x(),'f',3) + "," +
190+
QString::number( myUserCrsPoint.y(),'f',3));
178191
// This is the coordinate space of the map canvas
179-
mpTransformedEdit->setText(QString::number( thePoint.x(),'f',3) + "," +
192+
mpCanvasEdit->setText(QString::number( thePoint.x(),'f',3) + "," +
180193
QString::number( thePoint.y(),'f',3));
181194
}
182195
void CoordinateCapture::copy()
@@ -185,14 +198,14 @@ void CoordinateCapture::copy()
185198
//if we are on x11 system put text into selection ready for middle button pasting
186199
if (myClipboard->supportsSelection())
187200
{
188-
myClipboard->setText(mpGeoEdit->text() + "," + mpTransformedEdit->text(),QClipboard::Selection);
201+
myClipboard->setText(mpUserCrsEdit->text() + "," + mpCanvasEdit->text(),QClipboard::Selection);
189202
//QString myMessage = tr("Clipboard contents set to: ");
190203
//statusBar()->showMessage(myMessage + myClipboard->text(QClipboard::Selection));
191204
}
192205
else
193206
{
194207
//user has an inferior operating system....
195-
myClipboard->setText(mpGeoEdit->text() + "," + mpTransformedEdit->text(),QClipboard::Clipboard );
208+
myClipboard->setText(mpUserCrsEdit->text() + "," + mpCanvasEdit->text(),QClipboard::Clipboard );
196209
//QString myMessage = tr("Clipboard contents set to: ");
197210
//statusBar()->showMessage(myMessage + myClipboard->text(QClipboard::Clipboard));
198211
}

‎src/plugins/coordinate_capture/coordinatecapture.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public slots:
8888
void unload();
8989
//! show the help document
9090
void help();
91+
//! Set the Coordinate Reference System used for displaying non canvas CRS coord
92+
void setCRS();
9193
//! Called when mouse clicks on the canvas. Will populate text box with coords.
9294
void mouseClicked(QgsPoint thePoint);
9395
/** Called when mouse moved over the canvas. If the tracking button is toggled,
@@ -103,18 +105,21 @@ public slots:
103105
//! Container for the coordinate info
104106
QPointer<QDockWidget> mpDockWidget;
105107

106-
//!output display for geographic lat/long coords
107-
QPointer<QLineEdit> mpGeoEdit;
108+
//!output display for user defined Coordinate Reference System
109+
QPointer<QLineEdit> mpUserCrsEdit;
108110

109111
//!output display for CRS coord
110-
QPointer<QLineEdit> mpTransformedEdit;
112+
QPointer<QLineEdit> mpCanvasEdit;
111113

112114
//!Our custom map tool to capture clicks
113115
CoordinateCaptureMapTool * mpMapTool;
114116

115117
//!A toolbutton to keep track whether mouse tracking is enabled
116118
QToolButton * mpTrackMouseButton;
117119

120+
//!epsg id for showin in geoedit box
121+
long mEpsgId;
122+
118123
////////////////////////////////////////////////////////////////////
119124
//
120125
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....

0 commit comments

Comments
 (0)
Please sign in to comment.