Skip to content

Commit

Permalink
Gui cleanups for coordinate capture - dont use a toolbar icon, rather…
Browse files Browse the repository at this point in the history
… use a button in the dock.

Also use less precision for dd maps.


git-svn-id: http://svn.osgeo.org/qgis/trunk@10395 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Mar 21, 2009
1 parent 82c5709 commit f3a641e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/plugins/coordinate_capture/coordinatecapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,14 @@ void CoordinateCapture::initGui()

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

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

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

// Create the action for tool
mpCaptureButton = new QPushButton( mypWidget );
mpCaptureButton->setText( tr( "Start capture" ) );
mpCaptureButton->setToolTip( tr( "Click to enable coordinate capture" ) );
mpCaptureButton->setIcon( QIcon( ":/coordinatecapture/coordinatecapture/coordinate_capture.png" ));
mpCaptureButton->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) );
connect( mpCaptureButton, SIGNAL( clicked() ), this, SLOT( run() ) );

mypLayout->addWidget( mypUserCrsToolButton, 0, 0 );
mypLayout->addWidget( mpUserCrsEdit, 0, 1 );
mypLayout->addWidget( mypCRSLabel, 1, 0 );
mypLayout->addWidget( mpCanvasEdit, 1, 1 );
mypLayout->addWidget( mpTrackMouseButton, 2, 0 );
mypLayout->addWidget( mypCopyButton, 2, 1 );
mypLayout->addWidget( mpCaptureButton, 3, 1 );


//create the dock widget
Expand Down Expand Up @@ -171,14 +178,14 @@ void CoordinateCapture::setCRS()
{
mCrs.createFromSrsId( mySelector.selectedCrsId() );
mTransform.setDestCRS( mCrs );
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 8 : 3; //precision depends on CRS units
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 3 : 5; //precision depends on CRS units
}
}

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

void CoordinateCapture::mouseClicked( QgsPoint thePoint )
Expand Down Expand Up @@ -245,7 +252,7 @@ void CoordinateCapture::unload()
{
// remove the GUI
mQGisIface->removePluginMenu( "&Coordinate Capture", mQActionPointer );
mQGisIface->removeToolBarIcon( mQActionPointer );
//mQGisIface->removeToolBarIcon( mQActionPointer );
mpMapTool->deactivate();
delete mpMapTool;
delete mpDockWidget;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/coordinate_capture/coordinatecapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
class QAction;
class QToolBar;
class QToolButton;
class QPushButton;
class QDockWidget;
class QLineEdit;

Expand Down Expand Up @@ -121,6 +122,7 @@ class CoordinateCapture: public QObject, public QgisPlugin

//!A toolbutton to keep track whether mouse tracking is enabled
QToolButton * mpTrackMouseButton;
QPushButton * mpCaptureButton;

//! transform object
QgsCoordinateTransform mTransform;
Expand Down

0 comments on commit f3a641e

Please sign in to comment.