Skip to content
Permalink
Browse files
Remove old GCPs in georeferencer; clear image on close. Fixes #4310
  • Loading branch information
NathanW2 authored and jef-n committed May 8, 2012
1 parent 169e412 commit d11603e7ecd12450cb1f52aab2f5df559405cc1e
Showing with 31 additions and 28 deletions.
  1. +0 −1 src/plugins/georeferencer/qgsgeorefplugin.cpp
  2. +23 −19 src/plugins/georeferencer/qgsgeorefplugingui.cpp
  3. +8 −8 src/plugins/georeferencer/qgsgeorefplugingui.h
@@ -109,7 +109,6 @@ void QgsGeorefPlugin::initGui()
mQGisIface->addPluginToRasterMenu( tr( "&Georeferencer" ), mActionRunGeoref );
}

// Slot called when the buffer menu item is triggered
void QgsGeorefPlugin::run()
{
if ( !mPluginGui )
@@ -70,16 +70,6 @@ QgsGeorefDockWidget::QgsGeorefDockWidget( const QString & title, QWidget * paren
setObjectName( "GeorefDockWidget" ); // set object name so the position can be saved
}

void QgsGeorefDockWidget::closeEvent( QCloseEvent * ev )
{
if ( widget() && !widget()->close() )
{
ev->ignore();
return;
}
deleteLater();
}

QgsGeorefPluginGui::QgsGeorefPluginGui( QgisInterface* theQgisInterface, QWidget* parent, Qt::WFlags fl )
: QMainWindow( parent, fl )
, mTransformParam( QgsGeorefTransform::InvalidTransform )
@@ -145,12 +135,7 @@ QgsGeorefPluginGui::~QgsGeorefPluginGui()
{
clearGCPData();

// delete layer (and don't signal it as it's our private layer)
if ( mLayer )
{
QgsMapLayerRegistry::instance()->removeMapLayers(
( QStringList() << mLayer->id() ), false );
}
removeOldLayer();

delete mToolZoomIn;
delete mToolZoomOut;
@@ -173,14 +158,23 @@ void QgsGeorefPluginGui::closeEvent( QCloseEvent *e )
else
saveGCPs();
writeSettings();
clearGCPData();
removeOldLayer();
mRasterFileName = "";
e->accept();
return;
case QgsGeorefPluginGui::GCPSILENTSAVE:
if ( !mGCPpointsFileName.isEmpty() )
saveGCPs();
clearGCPData();
removeOldLayer();
mRasterFileName = "";
return;
case QgsGeorefPluginGui::GCPDISCARD:
writeSettings();
clearGCPData();
removeOldLayer();
mRasterFileName = "";
e->accept();
return;
case QgsGeorefPluginGui::GCPCANCEL:
@@ -253,9 +247,7 @@ void QgsGeorefPluginGui::openRaster()
clearGCPData();

//delete any old rasterlayers
if ( mLayer )
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << mLayer->id(), false );
removeOldLayer();

// Add raster
addRaster( mRasterFileName );
@@ -1036,6 +1028,18 @@ void QgsGeorefPluginGui::setupConnections()
connect( mCanvas, SIGNAL( extentsChanged() ), this, SLOT( extentsChanged() ) );
}

void QgsGeorefPluginGui::removeOldLayer()
{
// delete layer (and don't signal it as it's our private layer)
if ( mLayer )
{
QgsMapLayerRegistry::instance()->removeMapLayers(
( QStringList() << mLayer->id() ), false );
mLayer = NULL;
}
mCanvas->refresh();
}

void QgsGeorefPluginGui::updateIconTheme( QString theme )
{
// File actions
@@ -38,6 +38,13 @@ class QgsPoint;
class QgsRasterLayer;
class QgsRectangle;

class QgsGeorefDockWidget : public QDockWidget
{
Q_OBJECT
public:
QgsGeorefDockWidget( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
};

class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBase
{
Q_OBJECT
@@ -126,6 +133,7 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
void createDockWidgets();
void createStatusBar();
void setupConnections();
void removeOldLayer();

// Mapcanvas Plugin
void addRaster( QString file );
@@ -239,12 +247,4 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
QDockWidget* mDock;
};

class QgsGeorefDockWidget : public QDockWidget
{
Q_OBJECT
public:
QgsGeorefDockWidget( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
virtual void closeEvent( QCloseEvent * ev );
};

#endif

0 comments on commit d11603e

Please sign in to comment.