Skip to content
Permalink
Browse files

fix capture coordinate plugin: refs pull request #803

  • Loading branch information
slarosa committed Aug 27, 2013
1 parent c2310fd commit d51ea41ff79cb397eb6202f6879f1d587d1e13c8
@@ -92,13 +92,22 @@ void CoordinateCapture::initGui()
mTransform.setDestCRS( mCrs ); // set the CRS in the transform
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 5 : 3; // precision depends on CRS units

//create the dock widget
mpDockWidget = new QDockWidget( tr( "Coordinate Capture" ), mQGisIface->mainWindow() );
mpDockWidget->setObjectName( "CoordinateCapture" );
mpDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mQGisIface->addDockWidget( Qt::LeftDockWidgetArea, mpDockWidget );

// Create the action for tool
mQActionPointer = new QAction( QIcon(), tr( "Coordinate Capture" ), this );
mQActionPointer->setCheckable( true );
mQActionPointer->setChecked( mpDockWidget->isVisible() );
// 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() ) );
connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( showOrHide() ) );
mQGisIface->addPluginToVectorMenu( tr( "&Coordinate Capture" ), mQActionPointer );
mQGisIface->addVectorToolBarIcon( mQActionPointer );

// create our map tool
mpMapTool = new CoordinateCaptureMapTool( mQGisIface->mapCanvas() );
@@ -155,16 +164,9 @@ void CoordinateCapture::initGui()
mypLayout->addWidget( mypCopyButton, 2, 1 );
mypLayout->addWidget( mpCaptureButton, 3, 1 );


//create the dock widget
mpDockWidget = new QDockWidget( tr( "Coordinate Capture" ), mQGisIface->mainWindow() );
mpDockWidget->setObjectName( "CoordinateCapture" );
mpDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mQGisIface->addDockWidget( Qt::LeftDockWidgetArea, mpDockWidget );

// now add our custom widget to the dock - ownership of the widget is passed to the dock
mpDockWidget->setWidget( mypWidget );

connect( mpDockWidget, SIGNAL( visibilityChanged( bool ) ), mQActionPointer, SLOT( setChecked( bool ) ) );
}

//method defined in interface
@@ -243,12 +245,23 @@ void CoordinateCapture::run()
//myPluginGui->show();
}

void CoordinateCapture::showOrHide()
{
if ( !mpDockWidget )
run();
else
if ( mQActionPointer->isChecked() )
mpDockWidget->show();
else
mpDockWidget->hide();
}

// Unload the plugin by cleaning up the GUI
void CoordinateCapture::unload()
{
// remove the GUI
mQGisIface->removePluginMenu( "&Coordinate Capture", mQActionPointer );
//mQGisIface->removeToolBarIcon( mQActionPointer );
mQGisIface->removePluginVectorMenu( "&Coordinate Capture", mQActionPointer );
mQGisIface->removeVectorToolBarIcon( mQActionPointer );
mpMapTool->deactivate();
delete mpMapTool;
delete mpDockWidget;
@@ -90,6 +90,8 @@ class CoordinateCapture: public QObject, public QgisPlugin
void run();
//! unload the plugin
void unload();
//! Show/hide the dockwidget
void showOrHide();
//! show the help document
void help();
//! Set the Coordinate Reference System used for displaying non canvas CRS coord

0 comments on commit d51ea41

Please sign in to comment.
You can’t perform that action at this time.