Skip to content

Commit 7c37279

Browse files
author
timlinux
committed
Gui cleanups for coordinate capture - dont use a toolbar icon, rather use a button in the dock.
Also use less precision for dd maps. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10395 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b3c54da commit 7c37279

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/plugins/coordinate_capture/coordinatecapture.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,14 @@ void CoordinateCapture::initGui()
8787

8888
setSourceCrs(); //set up the source CRS
8989
mTransform.setDestCRS( mCrs ); // set the CRS in the transform
90-
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 8 : 3; // precision depends on CRS units
90+
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 3 : 5; // precision depends on CRS units
9191

9292
// Create the action for tool
9393
mQActionPointer = new QAction( QIcon( ":/coordinatecapture/coordinate_capture.png" ), tr( "Coordinate Capture" ), this );
9494
// Set the what's this text
9595
mQActionPointer->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) );
9696
// Connect the action to the run
9797
connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) );
98-
// Add the icon to the toolbar
99-
mQGisIface->addToolBarIcon( mQActionPointer );
10098
mQGisIface->addPluginToMenu( tr( "&Coordinate Capture" ), mQActionPointer );
10199

102100
// create our map tool
@@ -138,12 +136,21 @@ void CoordinateCapture::initGui()
138136
mpTrackMouseButton->setChecked( false );
139137
mpTrackMouseButton->setIcon( QIcon( ":/coordinatecapture/tracking.png" ) );
140138

139+
// Create the action for tool
140+
mpCaptureButton = new QPushButton( mypWidget );
141+
mpCaptureButton->setText( tr( "Start capture" ) );
142+
mpCaptureButton->setToolTip( tr( "Click to enable coordinate capture" ) );
143+
mpCaptureButton->setIcon( QIcon( ":/coordinatecapture/coordinatecapture/coordinate_capture.png" ));
144+
mpCaptureButton->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) );
145+
connect( mpCaptureButton, SIGNAL( clicked() ), this, SLOT( run() ) );
146+
141147
mypLayout->addWidget( mypUserCrsToolButton, 0, 0 );
142148
mypLayout->addWidget( mpUserCrsEdit, 0, 1 );
143149
mypLayout->addWidget( mypCRSLabel, 1, 0 );
144150
mypLayout->addWidget( mpCanvasEdit, 1, 1 );
145151
mypLayout->addWidget( mpTrackMouseButton, 2, 0 );
146152
mypLayout->addWidget( mypCopyButton, 2, 1 );
153+
mypLayout->addWidget( mpCaptureButton, 3, 1 );
147154

148155

149156
//create the dock widget
@@ -171,14 +178,14 @@ void CoordinateCapture::setCRS()
171178
{
172179
mCrs.createFromSrsId( mySelector.selectedCrsId() );
173180
mTransform.setDestCRS( mCrs );
174-
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 8 : 3; //precision depends on CRS units
181+
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 3 : 5; //precision depends on CRS units
175182
}
176183
}
177184

178185
void CoordinateCapture::setSourceCrs()
179186
{
180187
mTransform.setSourceCrs( mQGisIface->mapCanvas()->mapRenderer()->destinationSrs() );
181-
mCanvasDisplayPrecision = ( mQGisIface->mapCanvas()->mapRenderer()->destinationSrs().mapUnits() == QGis::Degrees ) ? 8 : 3; // for the map canvas coordinate display
188+
mCanvasDisplayPrecision = ( mQGisIface->mapCanvas()->mapRenderer()->destinationSrs().mapUnits() == QGis::Degrees ) ? 3 : 5; // for the map canvas coordinate display
182189
}
183190

184191
void CoordinateCapture::mouseClicked( QgsPoint thePoint )
@@ -245,7 +252,7 @@ void CoordinateCapture::unload()
245252
{
246253
// remove the GUI
247254
mQGisIface->removePluginMenu( "&Coordinate Capture", mQActionPointer );
248-
mQGisIface->removeToolBarIcon( mQActionPointer );
255+
//mQGisIface->removeToolBarIcon( mQActionPointer );
249256
mpMapTool->deactivate();
250257
delete mpMapTool;
251258
delete mpDockWidget;

src/plugins/coordinate_capture/coordinatecapture.h

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
class QAction;
5151
class QToolBar;
5252
class QToolButton;
53+
class QPushButton;
5354
class QDockWidget;
5455
class QLineEdit;
5556

@@ -121,6 +122,7 @@ class CoordinateCapture: public QObject, public QgisPlugin
121122

122123
//!A toolbutton to keep track whether mouse tracking is enabled
123124
QToolButton * mpTrackMouseButton;
125+
QPushButton * mpCaptureButton;
124126

125127
//! transform object
126128
QgsCoordinateTransform mTransform;

0 commit comments

Comments
 (0)