Hookup georeferencer from app

This commit is contained in:
Nyall Dawson 2020-05-24 18:53:17 +10:00
parent 54c5e3a5c6
commit 4057790cc8
10 changed files with 230 additions and 518 deletions

View File

@ -639,6 +639,7 @@ ADD_DEFINITIONS(-DQT_DISABLE_DEPRECATED_BEFORE=0x050800)
IF (WITH_GEOREFERENCER) IF (WITH_GEOREFERENCER)
FIND_PACKAGE(GSL REQUIRED) FIND_PACKAGE(GSL REQUIRED)
SET(HAVE_GEOREFERENCER TRUE)
ENDIF (WITH_GEOREFERENCER) ENDIF (WITH_GEOREFERENCER)
IF(ENABLE_COVERAGE) IF(ENABLE_COVERAGE)

View File

@ -64,6 +64,8 @@
#cmakedefine HAVE_3D #cmakedefine HAVE_3D
#cmakedefine HAVE_GEOREFERENCER
#cmakedefine USE_THREAD_LOCAL #cmakedefine USE_THREAD_LOCAL
#cmakedefine QGISDEBUG #cmakedefine QGISDEBUG

View File

@ -175,27 +175,6 @@ SET(QGIS_APP_SRCS
devtools/profiler/qgsprofilerpanelwidget.cpp devtools/profiler/qgsprofilerpanelwidget.cpp
devtools/profiler/qgsprofilerwidgetfactory.cpp devtools/profiler/qgsprofilerwidgetfactory.cpp
georeferencer/qgsgcpcanvasitem.cpp
georeferencer/qgsgeorefconfigdialog.cpp
georeferencer/qgsgeorefdatapoint.cpp
georeferencer/qgsgeorefdelegates.cpp
georeferencer/qgsgeorefdescriptiondialog.cpp
georeferencer/qgsgeorefplugin.cpp
georeferencer/qgsgeorefplugingui.cpp
georeferencer/qgsgeoreftooladdpoint.cpp
georeferencer/qgsgeoreftooldeletepoint.cpp
georeferencer/qgsgeoreftoolmovepoint.cpp
georeferencer/qgsgeorefvalidators.cpp
georeferencer/qgsleastsquares.cpp
georeferencer/qgsmapcoordsdialog.cpp
georeferencer/qgsresidualplotitem.cpp
georeferencer/qgstransformsettingsdialog.cpp
georeferencer/qgsgcplist.cpp
georeferencer/qgsgcplistmodel.cpp
georeferencer/qgsimagewarper.cpp
georeferencer/qgsgeoreftransform.cpp
georeferencer/qgsgcplistwidget.cpp
georeferencer/qgsrasterchangecoords.cpp
georeferencer/qgsvalidateddoublespinbox.cpp georeferencer/qgsvalidateddoublespinbox.cpp
labeling/qgslabelpropertydialog.cpp labeling/qgslabelpropertydialog.cpp
@ -252,6 +231,32 @@ SET(QGIS_APP_SRCS
mesh/qgsmeshvariablestrokewidthwidget.cpp mesh/qgsmeshvariablestrokewidthwidget.cpp
) )
IF (WITH_GEOREFERENCER)
SET(QGIS_APP_SRCS
${QGIS_APP_SRCS}
georeferencer/qgsgcpcanvasitem.cpp
georeferencer/qgsgeorefconfigdialog.cpp
georeferencer/qgsgeorefdatapoint.cpp
georeferencer/qgsgeorefdelegates.cpp
georeferencer/qgsgeorefdescriptiondialog.cpp
georeferencer/qgsgeorefplugingui.cpp
georeferencer/qgsgeoreftooladdpoint.cpp
georeferencer/qgsgeoreftooldeletepoint.cpp
georeferencer/qgsgeoreftoolmovepoint.cpp
georeferencer/qgsgeorefvalidators.cpp
georeferencer/qgsleastsquares.cpp
georeferencer/qgsmapcoordsdialog.cpp
georeferencer/qgsresidualplotitem.cpp
georeferencer/qgstransformsettingsdialog.cpp
georeferencer/qgsgcplist.cpp
georeferencer/qgsgcplistmodel.cpp
georeferencer/qgsimagewarper.cpp
georeferencer/qgsgeoreftransform.cpp
georeferencer/qgsgcplistwidget.cpp
georeferencer/qgsrasterchangecoords.cpp
)
ENDIF (WITH_GEOREFERENCER)
IF (WITH_3D) IF (WITH_3D)
SET(QGIS_APP_SRCS SET(QGIS_APP_SRCS
${QGIS_APP_SRCS} ${QGIS_APP_SRCS}

View File

@ -1,217 +0,0 @@
/***************************************************************************
* File Name: plugin.cpp
*
* The georeferencer plugin is a tool for adding projection info to rasters
*
*--------------------------------------------------------------------------
* begin : Jan 21, 2004
* copyright : (C) 2004 by Tim Sutton
* email : tim@linfiniti.com
*
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/***************************************************************************
* QGIS Programming conventions:
*
* mVariableName - a class level member variable
* sVariableName - a static class level member variable
* variableName() - accessor for a class member (no 'get' in front of name)
* setVariableName() - mutator for a class member (prefix with 'set')
*
* Additional useful conventions:
*
* variableName - a method parameter (prefix with 'the')
* myVariableName - a locally declared variable within a method ('my' prefix)
*
* DO: Use mixed case variable names - myVariableName
* DON'T: separate variable names using underscores: my_variable_name (NO!)
*
* **************************************************************************/
/****************************************************************************
* "Some work on Georeferencer is funded by Rosleszaschita, Russia" *
* **************************************************************************/
//
// Required qgis includes
//
#include "qgisinterface.h"
#include "qgsapplication.h"
#include "qgsmaplayer.h"
#include "qgsrasterlayer.h"
#include "qgsgeorefplugin.h"
#include <QFile>
#include <QMessageBox>
//
//the gui subclass
//
#include "qgsgeorefplugingui.h"
static const QString sName = QObject::tr( "Georeferencer GDAL" );
static const QString sDescription = QObject::tr( "Georeferencing rasters using GDAL" );
static const QString sCategory = QObject::tr( "Raster" );
static const QString sPluginVersion = QObject::tr( "Version 3.1.9" );
static const QgisPlugin::PluginType sPluginType = QgisPlugin::UI;
static const QString sPluginIcon = QStringLiteral( ":/icons/default/mGeorefRun.png" );
//////////////////////////////////////////////////////////////////////
//
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
//
//////////////////////////////////////////////////////////////////////
QgsGeorefPlugin::QgsGeorefPlugin( QgisInterface *qgisInterface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
, mQGisIface( qgisInterface )
{
}
/*
* Initialize the GUI interface for the plugin
*/
void QgsGeorefPlugin::initGui()
{
delete mActionRunGeoref;
// Create the action for tool
mActionRunGeoref = new QAction( QIcon(), tr( "&Georeferencer…" ), this );
mActionRunGeoref->setObjectName( QStringLiteral( "mActionRunGeoref" ) );
// Connect the action to the run
connect( mActionRunGeoref, &QAction::triggered, this, &QgsGeorefPlugin::run );
setCurrentTheme( QString() );
// this is called when the icon theme is changed
connect( mQGisIface, &QgisInterface::currentThemeChanged, this, &QgsGeorefPlugin::setCurrentTheme );
// Add to the toolbar & menu
mQGisIface->addRasterToolBarIcon( mActionRunGeoref );
mQGisIface->addPluginToRasterMenu( QString(), mActionRunGeoref );
}
void QgsGeorefPlugin::run()
{
if ( !mPluginGui )
mPluginGui = new QgsGeorefPluginGui( mQGisIface, mQGisIface->mainWindow() );
mPluginGui->show();
mPluginGui->setFocus();
}
// Unload the plugin by cleaning up the GUI
void QgsGeorefPlugin::unload()
{
// remove the GUI
mQGisIface->rasterMenu()->removeAction( mActionRunGeoref );
mQGisIface->removeRasterToolBarIcon( mActionRunGeoref );
delete mActionRunGeoref;
mActionRunGeoref = nullptr;
delete mPluginGui;
mPluginGui = nullptr;
}
//! Sets icons to the current theme
void QgsGeorefPlugin::setCurrentTheme( const QString & )
{
if ( mActionRunGeoref )
mActionRunGeoref->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mGeorefRun.png" ) ) );
}
QIcon QgsGeorefPlugin::getThemeIcon( const QString &name )
{
if ( QFile::exists( QgsApplication::activeThemePath() + "/plugins" + name ) )
{
return QIcon( QgsApplication::activeThemePath() + "/plugins" + name );
}
else if ( QFile::exists( QgsApplication::defaultThemePath() + "/plugins" + name ) )
{
return QIcon( QgsApplication::defaultThemePath() + "/plugins" + name );
}
else
{
return QIcon( ":/icons/default" + name );
}
}
//////////////////////////////////////////////////////////////////////
//
// END OF MANDATORY PLUGIN METHODS
//
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
//
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
//
//
//////////////////////////////////////////////////////////////////////////
/**
* Required extern functions needed for every plugin
* These functions can be called prior to creating an instance
* of the plugin class
*/
// Class factory to return a new instance of the plugin class
QGISEXTERN QgisPlugin *classFactory( QgisInterface *qgisInterfacePointer )
{
return new QgsGeorefPlugin( qgisInterfacePointer );
}
// Return the name of the plugin - note that we do not user class members as
// the class may not yet be insantiated when this method is called.
QGISEXTERN QString name()
{
return sName;
}
// Return the description
QGISEXTERN QString description()
{
return sDescription;
}
// Return the category
QGISEXTERN QString category()
{
return sCategory;
}
// Return the type (either UI or MapLayer plugin)
QGISEXTERN int type()
{
return sPluginType;
}
// Return the version number for the plugin
QGISEXTERN QString version()
{
return sPluginVersion;
}
QGISEXTERN QString icon()
{
return sPluginIcon;
}
// Delete ourself
QGISEXTERN void unload( QgisPlugin *pluginPointer )
{
delete pluginPointer;
}

View File

@ -1,115 +0,0 @@
/***************************************************************************
* File Name: plugin.h
*
* The georeferencer plugin is a tool for adding projection info to rasters
*
*--------------------------------------------------------------------------
* begin : Jan 21, 2004
* copyright : (C) 2004 by Tim Sutton
* email : tim@linfiniti.com
*
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/***************************************************************************
* QGIS Programming conventions:
*
* mVariableName - a class level member variable
* sVariableName - a static class level member variable
* variableName() - accessor for a class member (no 'get' in front of name)
* setVariableName() - mutator for a class member (prefix with 'set')
*
* Additional useful conventions:
*
* variableName - a method parameter (prefix with 'the')
* myVariableName - a locally declared variable within a method ('my' prefix)
*
* DO: Use mixed case variable names - myVariableName
* DON'T: separate variable names using underscores: my_variable_name (NO!)
*
* **************************************************************************/
#ifndef QGSGEOREFPLUGIN
#define QGSGEOREFPLUGIN
//
//QGIS Includes
//
#include "qgisplugin.h"
class QgisInterface;
class QgsGeorefPluginGui;
//
//QT Includes
//
#include <QWidget>
#include <QIcon>
/**
* \class Plugin
* \brief [name] plugin for QGIS
* [description]
*/
class QgsGeorefPlugin: public QObject, public QgisPlugin
{
Q_OBJECT public:
//////////////////////////////////////////////////////////////////////
//
// MANDATORY PLUGIN METHODS FOLLOW
//
//////////////////////////////////////////////////////////////////////
/**
* Constructor for a plugin. The QgisApp and QgisIface pointers are passed by
* QGIS when it attempts to instantiate the plugin.
* \param interface pointer to the QgisIface object.
*/
explicit QgsGeorefPlugin( QgisInterface *interface );
public slots:
//! init the gui
void initGui() override;
//! Show the dialog box
void run();
//! unload the plugin
void unload() override;
//! update the plugins theme when the app tells us its theme is changed
void setCurrentTheme( const QString &themeName );
QIcon getThemeIcon( const QString &themeName );
//////////////////////////////////////////////////////////////////////
//
// END OF MANDATORY PLUGIN METHODS
//
//////////////////////////////////////////////////////////////////////
private:
////////////////////////////////////////////////////////////////////
//
// MANDATORY PLUGIN MEMBER DECLARATIONS .....
//
////////////////////////////////////////////////////////////////////
//! Pointer to the QGIS interface object
QgisInterface *mQGisIface = nullptr;
//!pointer to the qaction for this plugin
QAction *mActionRunGeoref = nullptr;
////////////////////////////////////////////////////////////////////
//
// ADD YOUR OWN MEMBER DECLARATIONS AFTER THIS POINT.....
//
////////////////////////////////////////////////////////////////////
QgsGeorefPluginGui *mPluginGui = nullptr;
};
#endif

View File

@ -34,6 +34,7 @@
#include "qgisinterface.h" #include "qgisinterface.h"
#include "qgsapplication.h" #include "qgsapplication.h"
#include "qgsgui.h" #include "qgsgui.h"
#include "qgisapp.h"
#include "qgslayout.h" #include "qgslayout.h"
#include "qgslayoutitemlabel.h" #include "qgslayoutitemlabel.h"
@ -74,11 +75,10 @@ QgsGeorefDockWidget::QgsGeorefDockWidget( const QString &title, QWidget *parent,
setObjectName( QStringLiteral( "GeorefDockWidget" ) ); // set object name so the position can be saved setObjectName( QStringLiteral( "GeorefDockWidget" ) ); // set object name so the position can be saved
} }
QgsGeorefPluginGui::QgsGeorefPluginGui( QgisInterface *qgisInterface, QWidget *parent, Qt::WindowFlags fl ) QgsGeoreferencerMainWindow::QgsGeoreferencerMainWindow( QWidget *parent, Qt::WindowFlags fl )
: QMainWindow( parent, fl ) : QMainWindow( parent, fl )
, mMousePrecisionDecimalPlaces( 0 ) , mMousePrecisionDecimalPlaces( 0 )
, mTransformParam( QgsGeorefTransform::InvalidTransform ) , mTransformParam( QgsGeorefTransform::InvalidTransform )
, mIface( qgisInterface )
, mAgainAddRaster( false ) , mAgainAddRaster( false )
, mMapCoordsDialog( nullptr ) , mMapCoordsDialog( nullptr )
, mUseZeroForTrans( false ) , mUseZeroForTrans( false )
@ -120,14 +120,14 @@ QgsGeorefPluginGui::QgsGeorefPluginGui( QgisInterface *qgisInterface, QWidget *p
} }
} }
void QgsGeorefPluginGui::dockThisWindow( bool dock ) void QgsGeoreferencerMainWindow::dockThisWindow( bool dock )
{ {
if ( mDock ) if ( mDock )
{ {
setParent( mIface->mainWindow(), Qt::Window ); setParent( QgisApp::instance(), Qt::Window );
show(); show();
mIface->removeDockWidget( mDock ); QgisApp::instance()->removeDockWidget( mDock );
mDock->setWidget( nullptr ); mDock->setWidget( nullptr );
delete mDock; delete mDock;
mDock = nullptr; mDock = nullptr;
@ -135,13 +135,13 @@ void QgsGeorefPluginGui::dockThisWindow( bool dock )
if ( dock ) if ( dock )
{ {
mDock = new QgsGeorefDockWidget( tr( "Georeferencer" ), mIface->mainWindow() ); mDock = new QgsGeorefDockWidget( tr( "Georeferencer" ), QgisApp::instance() );
mDock->setWidget( this ); mDock->setWidget( this );
mIface->addDockWidget( Qt::BottomDockWidgetArea, mDock ); QgisApp::instance()->addDockWidget( Qt::BottomDockWidgetArea, mDock );
} }
} }
QgsGeorefPluginGui::~QgsGeorefPluginGui() QgsGeoreferencerMainWindow::~QgsGeoreferencerMainWindow()
{ {
clearGCPData(); clearGCPData();
@ -157,11 +157,11 @@ QgsGeorefPluginGui::~QgsGeorefPluginGui()
} }
// ----------------------------- protected --------------------------------- // // ----------------------------- protected --------------------------------- //
void QgsGeorefPluginGui::closeEvent( QCloseEvent *e ) void QgsGeoreferencerMainWindow::closeEvent( QCloseEvent *e )
{ {
switch ( checkNeedGCPSave() ) switch ( checkNeedGCPSave() )
{ {
case QgsGeorefPluginGui::GCPSAVE: case QgsGeoreferencerMainWindow::GCPSAVE:
if ( mGCPpointsFileName.isEmpty() ) if ( mGCPpointsFileName.isEmpty() )
saveGCPsDialog(); saveGCPsDialog();
else else
@ -172,27 +172,27 @@ void QgsGeorefPluginGui::closeEvent( QCloseEvent *e )
mRasterFileName.clear(); mRasterFileName.clear();
e->accept(); e->accept();
return; return;
case QgsGeorefPluginGui::GCPSILENTSAVE: case QgsGeoreferencerMainWindow::GCPSILENTSAVE:
if ( !mGCPpointsFileName.isEmpty() ) if ( !mGCPpointsFileName.isEmpty() )
saveGCPs(); saveGCPs();
clearGCPData(); clearGCPData();
removeOldLayer(); removeOldLayer();
mRasterFileName.clear(); mRasterFileName.clear();
return; return;
case QgsGeorefPluginGui::GCPDISCARD: case QgsGeoreferencerMainWindow::GCPDISCARD:
writeSettings(); writeSettings();
clearGCPData(); clearGCPData();
removeOldLayer(); removeOldLayer();
mRasterFileName.clear(); mRasterFileName.clear();
e->accept(); e->accept();
return; return;
case QgsGeorefPluginGui::GCPCANCEL: case QgsGeoreferencerMainWindow::GCPCANCEL:
e->ignore(); e->ignore();
return; return;
} }
} }
void QgsGeorefPluginGui::reset() void QgsGeoreferencerMainWindow::reset()
{ {
if ( QMessageBox::question( this, if ( QMessageBox::question( this,
tr( "Reset Georeferencer" ), tr( "Reset Georeferencer" ),
@ -213,21 +213,21 @@ void QgsGeorefPluginGui::reset()
// -------------------------- private slots -------------------------------- // // -------------------------- private slots -------------------------------- //
// File slots // File slots
void QgsGeorefPluginGui::openRaster() void QgsGeoreferencerMainWindow::openRaster()
{ {
// clearLog(); // clearLog();
switch ( checkNeedGCPSave() ) switch ( checkNeedGCPSave() )
{ {
case QgsGeorefPluginGui::GCPSAVE: case QgsGeoreferencerMainWindow::GCPSAVE:
saveGCPsDialog(); saveGCPsDialog();
break; break;
case QgsGeorefPluginGui::GCPSILENTSAVE: case QgsGeoreferencerMainWindow::GCPSILENTSAVE:
if ( !mGCPpointsFileName.isEmpty() ) if ( !mGCPpointsFileName.isEmpty() )
saveGCPs(); saveGCPs();
break; break;
case QgsGeorefPluginGui::GCPDISCARD: case QgsGeoreferencerMainWindow::GCPDISCARD:
break; break;
case QgsGeorefPluginGui::GCPCANCEL: case QgsGeoreferencerMainWindow::GCPCANCEL:
return; return;
} }
@ -286,7 +286,7 @@ void QgsGeorefPluginGui::openRaster()
mCanvas->setExtent( mLayer->extent() ); mCanvas->setExtent( mLayer->extent() );
mCanvas->refresh(); mCanvas->refresh();
mIface->mapCanvas()->refresh(); QgisApp::instance()->mapCanvas()->refresh();
mActionLinkGeorefToQGis->setChecked( false ); mActionLinkGeorefToQGis->setChecked( false );
mActionLinkQGisToGeoref->setChecked( false ); mActionLinkQGisToGeoref->setChecked( false );
@ -297,7 +297,7 @@ void QgsGeorefPluginGui::openRaster()
mWorldFileName = guessWorldFileName( mRasterFileName ); mWorldFileName = guessWorldFileName( mRasterFileName );
} }
void QgsGeorefPluginGui::doGeoreference() void QgsGeoreferencerMainWindow::doGeoreference()
{ {
if ( georeference() ) if ( georeference() )
{ {
@ -306,11 +306,11 @@ void QgsGeorefPluginGui::doGeoreference()
{ {
if ( mModifiedRasterFileName.isEmpty() ) if ( mModifiedRasterFileName.isEmpty() )
{ {
mIface->addRasterLayer( mRasterFileName ); QgisApp::instance()->addRasterLayer( mRasterFileName, QFileInfo( mRasterFileName ).completeBaseName() );
} }
else else
{ {
mIface->addRasterLayer( mModifiedRasterFileName ); QgisApp::instance()->addRasterLayer( mModifiedRasterFileName, QFileInfo( mModifiedRasterFileName ).completeBaseName() );
} }
// showMessageInLog(tr("Modified raster saved in"), mModifiedRasterFileName); // showMessageInLog(tr("Modified raster saved in"), mModifiedRasterFileName);
@ -327,7 +327,7 @@ void QgsGeorefPluginGui::doGeoreference()
} }
} }
bool QgsGeorefPluginGui::getTransformSettings() bool QgsGeoreferencerMainWindow::getTransformSettings()
{ {
QgsTransformSettingsDialog d( mRasterFileName, mModifiedRasterFileName, mPoints.size() ); QgsTransformSettingsDialog d( mRasterFileName, mModifiedRasterFileName, mPoints.size() );
if ( !d.exec() ) if ( !d.exec() )
@ -362,7 +362,7 @@ bool QgsGeorefPluginGui::getTransformSettings()
return true; return true;
} }
void QgsGeorefPluginGui::generateGDALScript() void QgsGeoreferencerMainWindow::generateGDALScript()
{ {
if ( !checkReadyGeoref() ) if ( !checkReadyGeoref() )
return; return;
@ -399,39 +399,39 @@ void QgsGeorefPluginGui::generateGDALScript()
} }
// Edit slots // Edit slots
void QgsGeorefPluginGui::setAddPointTool() void QgsGeoreferencerMainWindow::setAddPointTool()
{ {
mCanvas->setMapTool( mToolAddPoint ); mCanvas->setMapTool( mToolAddPoint );
} }
void QgsGeorefPluginGui::setDeletePointTool() void QgsGeoreferencerMainWindow::setDeletePointTool()
{ {
mCanvas->setMapTool( mToolDeletePoint ); mCanvas->setMapTool( mToolDeletePoint );
} }
void QgsGeorefPluginGui::setMovePointTool() void QgsGeoreferencerMainWindow::setMovePointTool()
{ {
mCanvas->setMapTool( mToolMovePoint ); mCanvas->setMapTool( mToolMovePoint );
mIface->mapCanvas()->setMapTool( mToolMovePointQgis ); QgisApp::instance()->mapCanvas()->setMapTool( mToolMovePointQgis );
} }
// View slots // View slots
void QgsGeorefPluginGui::setPanTool() void QgsGeoreferencerMainWindow::setPanTool()
{ {
mCanvas->setMapTool( mToolPan ); mCanvas->setMapTool( mToolPan );
} }
void QgsGeorefPluginGui::setZoomInTool() void QgsGeoreferencerMainWindow::setZoomInTool()
{ {
mCanvas->setMapTool( mToolZoomIn ); mCanvas->setMapTool( mToolZoomIn );
} }
void QgsGeorefPluginGui::setZoomOutTool() void QgsGeoreferencerMainWindow::setZoomOutTool()
{ {
mCanvas->setMapTool( mToolZoomOut ); mCanvas->setMapTool( mToolZoomOut );
} }
void QgsGeorefPluginGui::zoomToLayerTool() void QgsGeoreferencerMainWindow::zoomToLayerTool()
{ {
if ( mLayer ) if ( mLayer )
{ {
@ -440,17 +440,17 @@ void QgsGeorefPluginGui::zoomToLayerTool()
} }
} }
void QgsGeorefPluginGui::zoomToLast() void QgsGeoreferencerMainWindow::zoomToLast()
{ {
mCanvas->zoomToPreviousExtent(); mCanvas->zoomToPreviousExtent();
} }
void QgsGeorefPluginGui::zoomToNext() void QgsGeoreferencerMainWindow::zoomToNext()
{ {
mCanvas->zoomToNextExtent(); mCanvas->zoomToNextExtent();
} }
void QgsGeorefPluginGui::linkQGisToGeoref( bool link ) void QgsGeoreferencerMainWindow::linkQGisToGeoref( bool link )
{ {
if ( link ) if ( link )
{ {
@ -466,7 +466,7 @@ void QgsGeorefPluginGui::linkQGisToGeoref( bool link )
} }
} }
void QgsGeorefPluginGui::linkGeorefToQGis( bool link ) void QgsGeoreferencerMainWindow::linkGeorefToQGis( bool link )
{ {
if ( link ) if ( link )
{ {
@ -483,10 +483,10 @@ void QgsGeorefPluginGui::linkGeorefToQGis( bool link )
} }
// GCPs slots // GCPs slots
void QgsGeorefPluginGui::addPoint( const QgsPointXY &pixelCoords, const QgsPointXY &mapCoords, void QgsGeoreferencerMainWindow::addPoint( const QgsPointXY &pixelCoords, const QgsPointXY &mapCoords,
bool enable, bool finalize ) bool enable, bool finalize )
{ {
QgsGeorefDataPoint *pnt = new QgsGeorefDataPoint( mCanvas, mIface->mapCanvas(), QgsGeorefDataPoint *pnt = new QgsGeorefDataPoint( mCanvas, QgisApp::instance()->mapCanvas(),
pixelCoords, mapCoords, enable ); pixelCoords, mapCoords, enable );
mPoints.append( pnt ); mPoints.append( pnt );
mGCPsDirty = true; mGCPsDirty = true;
@ -494,7 +494,7 @@ void QgsGeorefPluginGui::addPoint( const QgsPointXY &pixelCoords, const QgsPoint
{ {
mGCPListWidget->setGCPList( &mPoints ); mGCPListWidget->setGCPList( &mPoints );
mCanvas->refresh(); mCanvas->refresh();
mIface->mapCanvas()->refresh(); QgisApp::instance()->mapCanvas()->refresh();
} }
connect( mCanvas, &QgsMapCanvas::extentsChanged, pnt, &QgsGeorefDataPoint::updateCoords ); connect( mCanvas, &QgsMapCanvas::extentsChanged, pnt, &QgsGeorefDataPoint::updateCoords );
@ -504,7 +504,7 @@ void QgsGeorefPluginGui::addPoint( const QgsPointXY &pixelCoords, const QgsPoint
} }
} }
void QgsGeorefPluginGui::deleteDataPoint( QPoint coords ) void QgsGeoreferencerMainWindow::deleteDataPoint( QPoint coords )
{ {
for ( QgsGCPList::iterator it = mPoints.begin(); it != mPoints.end(); ++it ) for ( QgsGCPList::iterator it = mPoints.begin(); it != mPoints.end(); ++it )
{ {
@ -522,7 +522,7 @@ void QgsGeorefPluginGui::deleteDataPoint( QPoint coords )
updateGeorefTransform(); updateGeorefTransform();
} }
void QgsGeorefPluginGui::deleteDataPoint( int theGCPIndex ) void QgsGeoreferencerMainWindow::deleteDataPoint( int theGCPIndex )
{ {
Q_ASSERT( theGCPIndex >= 0 ); Q_ASSERT( theGCPIndex >= 0 );
delete mPoints.takeAt( theGCPIndex ); delete mPoints.takeAt( theGCPIndex );
@ -530,7 +530,7 @@ void QgsGeorefPluginGui::deleteDataPoint( int theGCPIndex )
updateGeorefTransform(); updateGeorefTransform();
} }
void QgsGeorefPluginGui::selectPoint( QPoint p ) void QgsGeoreferencerMainWindow::selectPoint( QPoint p )
{ {
// Get Map Sender // Get Map Sender
bool isMapPlugin = sender() == mToolMovePoint; bool isMapPlugin = sender() == mToolMovePoint;
@ -546,7 +546,7 @@ void QgsGeorefPluginGui::selectPoint( QPoint p )
} }
} }
void QgsGeorefPluginGui::movePoint( QPoint p ) void QgsGeoreferencerMainWindow::movePoint( QPoint p )
{ {
// Get Map Sender // Get Map Sender
bool isMapPlugin = sender() == mToolMovePoint; bool isMapPlugin = sender() == mToolMovePoint;
@ -560,7 +560,7 @@ void QgsGeorefPluginGui::movePoint( QPoint p )
} }
void QgsGeorefPluginGui::releasePoint( QPoint p ) void QgsGeoreferencerMainWindow::releasePoint( QPoint p )
{ {
Q_UNUSED( p ) Q_UNUSED( p )
// Get Map Sender // Get Map Sender
@ -574,11 +574,11 @@ void QgsGeorefPluginGui::releasePoint( QPoint p )
} }
} }
void QgsGeorefPluginGui::showCoordDialog( const QgsPointXY &pixelCoords ) void QgsGeoreferencerMainWindow::showCoordDialog( const QgsPointXY &pixelCoords )
{ {
if ( mLayer && !mMapCoordsDialog ) if ( mLayer && !mMapCoordsDialog )
{ {
mMapCoordsDialog = new QgsMapCoordsDialog( mIface->mapCanvas(), pixelCoords, this ); mMapCoordsDialog = new QgsMapCoordsDialog( QgisApp::instance()->mapCanvas(), pixelCoords, this );
connect( mMapCoordsDialog, &QgsMapCoordsDialog::pointAdded, this, connect( mMapCoordsDialog, &QgsMapCoordsDialog::pointAdded, this,
[this]( const QgsPointXY & a, const QgsPointXY & b ) { this->addPoint( a, b ); } [this]( const QgsPointXY & a, const QgsPointXY & b ) { this->addPoint( a, b ); }
); );
@ -586,7 +586,7 @@ void QgsGeorefPluginGui::showCoordDialog( const QgsPointXY &pixelCoords )
} }
} }
void QgsGeorefPluginGui::loadGCPsDialog() void QgsGeoreferencerMainWindow::loadGCPsDialog()
{ {
QString selectedFile = mRasterFileName.isEmpty() ? QString() : mRasterFileName + ".points"; QString selectedFile = mRasterFileName.isEmpty() ? QString() : mRasterFileName + ".points";
mGCPpointsFileName = QFileDialog::getOpenFileName( this, tr( "Load GCP Points" ), mGCPpointsFileName = QFileDialog::getOpenFileName( this, tr( "Load GCP Points" ),
@ -604,7 +604,7 @@ void QgsGeorefPluginGui::loadGCPsDialog()
} }
} }
void QgsGeorefPluginGui::saveGCPsDialog() void QgsGeoreferencerMainWindow::saveGCPsDialog()
{ {
if ( mPoints.isEmpty() ) if ( mPoints.isEmpty() )
{ {
@ -627,11 +627,11 @@ void QgsGeorefPluginGui::saveGCPsDialog()
} }
// Settings slots // Settings slots
void QgsGeorefPluginGui::showRasterPropertiesDialog() void QgsGeoreferencerMainWindow::showRasterPropertiesDialog()
{ {
if ( mLayer ) if ( mLayer )
{ {
mIface->showLayerProperties( mLayer ); QgisApp::instance()->showLayerProperties( mLayer );
} }
else else
{ {
@ -639,13 +639,13 @@ void QgsGeorefPluginGui::showRasterPropertiesDialog()
} }
} }
void QgsGeorefPluginGui::showGeorefConfigDialog() void QgsGeoreferencerMainWindow::showGeorefConfigDialog()
{ {
QgsGeorefConfigDialog config; QgsGeorefConfigDialog config;
if ( config.exec() == QDialog::Accepted ) if ( config.exec() == QDialog::Accepted )
{ {
mCanvas->refresh(); mCanvas->refresh();
mIface->mapCanvas()->refresh(); QgisApp::instance()->mapCanvas()->refresh();
QgsSettings s; QgsSettings s;
//update dock state //update dock state
bool dock = s.value( QStringLiteral( "/Plugin-GeoReferencer/Config/ShowDocked" ) ).toBool(); bool dock = s.value( QStringLiteral( "/Plugin-GeoReferencer/Config/ShowDocked" ) ).toBool();
@ -668,28 +668,28 @@ void QgsGeorefPluginGui::showGeorefConfigDialog()
} }
// Histogram stretch slots // Histogram stretch slots
void QgsGeorefPluginGui::fullHistogramStretch() void QgsGeoreferencerMainWindow::fullHistogramStretch()
{ {
mLayer->setContrastEnhancement( QgsContrastEnhancement::StretchToMinimumMaximum ); mLayer->setContrastEnhancement( QgsContrastEnhancement::StretchToMinimumMaximum );
mCanvas->refresh(); mCanvas->refresh();
} }
void QgsGeorefPluginGui::localHistogramStretch() void QgsGeoreferencerMainWindow::localHistogramStretch()
{ {
QgsRectangle rectangle = mIface->mapCanvas()->mapSettings().outputExtentToLayerExtent( mLayer, mIface->mapCanvas()->extent() ); QgsRectangle rectangle = QgisApp::instance()->mapCanvas()->mapSettings().outputExtentToLayerExtent( mLayer, QgisApp::instance()->mapCanvas()->extent() );
mLayer->setContrastEnhancement( QgsContrastEnhancement::StretchToMinimumMaximum, QgsRasterMinMaxOrigin::MinMax, rectangle ); mLayer->setContrastEnhancement( QgsContrastEnhancement::StretchToMinimumMaximum, QgsRasterMinMaxOrigin::MinMax, rectangle );
mCanvas->refresh(); mCanvas->refresh();
} }
// Info slots // Info slots
void QgsGeorefPluginGui::showHelp() void QgsGeoreferencerMainWindow::showHelp()
{ {
QgsHelp::openHelp( QStringLiteral( "plugins/core_plugins/plugins_georeferencer.html#defining-the-transformation-settings" ) ); QgsHelp::openHelp( QStringLiteral( "plugins/core_plugins/plugins_georeferencer.html#defining-the-transformation-settings" ) );
} }
// Comfort slots // Comfort slots
void QgsGeorefPluginGui::jumpToGCP( uint theGCPIndex ) void QgsGeoreferencerMainWindow::jumpToGCP( uint theGCPIndex )
{ {
if ( static_cast<int>( theGCPIndex ) >= mPoints.size() ) if ( static_cast<int>( theGCPIndex ) >= mPoints.size() )
{ {
@ -710,7 +710,7 @@ void QgsGeorefPluginGui::jumpToGCP( uint theGCPIndex )
} }
// This slot is called whenever the georeference canvas changes the displayed extent // This slot is called whenever the georeference canvas changes the displayed extent
void QgsGeorefPluginGui::extentsChangedGeorefCanvas() void QgsGeoreferencerMainWindow::extentsChangedGeorefCanvas()
{ {
// Guard against endless recursion by ping-pong updates // Guard against endless recursion by ping-pong updates
if ( mExtentsChangedRecursionGuard ) if ( mExtentsChangedRecursionGuard )
@ -732,14 +732,14 @@ void QgsGeorefPluginGui::extentsChangedGeorefCanvas()
mExtentsChangedRecursionGuard = true; mExtentsChangedRecursionGuard = true;
// Just set the whole extent for now // Just set the whole extent for now
// TODO: better fitting function which accounts for differing aspect ratios etc. // TODO: better fitting function which accounts for differing aspect ratios etc.
mIface->mapCanvas()->setExtent( boundingBox ); QgisApp::instance()->mapCanvas()->setExtent( boundingBox );
mIface->mapCanvas()->refresh(); QgisApp::instance()->mapCanvas()->refresh();
mExtentsChangedRecursionGuard = false; mExtentsChangedRecursionGuard = false;
} }
} }
// This slot is called whenever the qgis main canvas changes the displayed extent // This slot is called whenever the qgis main canvas changes the displayed extent
void QgsGeorefPluginGui::extentsChangedQGisCanvas() void QgsGeoreferencerMainWindow::extentsChangedQGisCanvas()
{ {
// Guard against endless recursion by ping-pong updates // Guard against endless recursion by ping-pong updates
if ( mExtentsChangedRecursionGuard ) if ( mExtentsChangedRecursionGuard )
@ -756,7 +756,7 @@ void QgsGeorefPluginGui::extentsChangedQGisCanvas()
} }
// Reproject the canvas into raster coordinates and fit axis aligned bounding box // Reproject the canvas into raster coordinates and fit axis aligned bounding box
QgsRectangle boundingBox = transformViewportBoundingBox( mIface->mapCanvas()->extent(), mGeorefTransform, false ); QgsRectangle boundingBox = transformViewportBoundingBox( QgisApp::instance()->mapCanvas()->extent(), mGeorefTransform, false );
QgsRectangle rectMap = mGeorefTransform.hasCrs() ? mGeorefTransform.getBoundingBox( boundingBox, false ) : boundingBox; QgsRectangle rectMap = mGeorefTransform.hasCrs() ? mGeorefTransform.getBoundingBox( boundingBox, false ) : boundingBox;
mExtentsChangedRecursionGuard = true; mExtentsChangedRecursionGuard = true;
@ -769,7 +769,7 @@ void QgsGeorefPluginGui::extentsChangedQGisCanvas()
} }
// Canvas info slots (copy/pasted from QGIS :) ) // Canvas info slots (copy/pasted from QGIS :) )
void QgsGeorefPluginGui::showMouseCoords( const QgsPointXY &p ) void QgsGeoreferencerMainWindow::showMouseCoords( const QgsPointXY &p )
{ {
mCoordsLabel->setText( p.toString( mMousePrecisionDecimalPlaces ) ); mCoordsLabel->setText( p.toString( mMousePrecisionDecimalPlaces ) );
// Set minimum necessary width // Set minimum necessary width
@ -779,7 +779,7 @@ void QgsGeorefPluginGui::showMouseCoords( const QgsPointXY &p )
} }
} }
void QgsGeorefPluginGui::updateMouseCoordinatePrecision() void QgsGeoreferencerMainWindow::updateMouseCoordinatePrecision()
{ {
// Work out what mouse display precision to use. This only needs to // Work out what mouse display precision to use. This only needs to
// be when the s change or the zoom level changes. This // be when the s change or the zoom level changes. This
@ -808,7 +808,7 @@ void QgsGeorefPluginGui::updateMouseCoordinatePrecision()
mMousePrecisionDecimalPlaces = dp; mMousePrecisionDecimalPlaces = dp;
} }
void QgsGeorefPluginGui::extentsChanged() void QgsGeoreferencerMainWindow::extentsChanged()
{ {
if ( mAgainAddRaster ) if ( mAgainAddRaster )
{ {
@ -825,90 +825,90 @@ void QgsGeorefPluginGui::extentsChanged()
} }
// Registry layer QGis // Registry layer QGis
void QgsGeorefPluginGui::layerWillBeRemoved( const QString &layerId ) void QgsGeoreferencerMainWindow::layerWillBeRemoved( const QString &layerId )
{ {
mAgainAddRaster = mLayer && mLayer->id().compare( layerId ) == 0; mAgainAddRaster = mLayer && mLayer->id().compare( layerId ) == 0;
} }
// ------------------------------ private ---------------------------------- // // ------------------------------ private ---------------------------------- //
// Gui // Gui
void QgsGeorefPluginGui::createActions() void QgsGeoreferencerMainWindow::createActions()
{ {
// File actions // File actions
connect( mActionReset, &QAction::triggered, this, &QgsGeorefPluginGui::reset ); connect( mActionReset, &QAction::triggered, this, &QgsGeoreferencerMainWindow::reset );
mActionOpenRaster->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddRasterLayer.svg" ) ) ); mActionOpenRaster->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddRasterLayer.svg" ) ) );
connect( mActionOpenRaster, &QAction::triggered, this, &QgsGeorefPluginGui::openRaster ); connect( mActionOpenRaster, &QAction::triggered, this, &QgsGeoreferencerMainWindow::openRaster );
mActionStartGeoref->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionStartGeoref.png" ) ) ); mActionStartGeoref->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionStartGeoref.png" ) ) );
connect( mActionStartGeoref, &QAction::triggered, this, &QgsGeorefPluginGui::doGeoreference ); connect( mActionStartGeoref, &QAction::triggered, this, &QgsGeoreferencerMainWindow::doGeoreference );
mActionGDALScript->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionGDALScript.png" ) ) ); mActionGDALScript->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionGDALScript.png" ) ) );
connect( mActionGDALScript, &QAction::triggered, this, &QgsGeorefPluginGui::generateGDALScript ); connect( mActionGDALScript, &QAction::triggered, this, &QgsGeoreferencerMainWindow::generateGDALScript );
mActionLoadGCPpoints->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionLoadGCPpoints.png" ) ) ); mActionLoadGCPpoints->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionLoadGCPpoints.png" ) ) );
connect( mActionLoadGCPpoints, &QAction::triggered, this, &QgsGeorefPluginGui::loadGCPsDialog ); connect( mActionLoadGCPpoints, &QAction::triggered, this, &QgsGeoreferencerMainWindow::loadGCPsDialog );
mActionSaveGCPpoints->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionSaveGCPpointsAs.png" ) ) ); mActionSaveGCPpoints->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionSaveGCPpointsAs.png" ) ) );
connect( mActionSaveGCPpoints, &QAction::triggered, this, &QgsGeorefPluginGui::saveGCPsDialog ); connect( mActionSaveGCPpoints, &QAction::triggered, this, &QgsGeoreferencerMainWindow::saveGCPsDialog );
mActionTransformSettings->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/settings.svg" ) ) ); mActionTransformSettings->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/settings.svg" ) ) );
connect( mActionTransformSettings, &QAction::triggered, this, &QgsGeorefPluginGui::getTransformSettings ); connect( mActionTransformSettings, &QAction::triggered, this, &QgsGeoreferencerMainWindow::getTransformSettings );
// Edit actions // Edit actions
mActionAddPoint->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionAddGCPPoint.png" ) ) ); mActionAddPoint->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionAddGCPPoint.png" ) ) );
connect( mActionAddPoint, &QAction::triggered, this, &QgsGeorefPluginGui::setAddPointTool ); connect( mActionAddPoint, &QAction::triggered, this, &QgsGeoreferencerMainWindow::setAddPointTool );
mActionDeletePoint->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionDeleteGCPPoint.png" ) ) ); mActionDeletePoint->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionDeleteGCPPoint.png" ) ) );
connect( mActionDeletePoint, &QAction::triggered, this, &QgsGeorefPluginGui::setDeletePointTool ); connect( mActionDeletePoint, &QAction::triggered, this, &QgsGeoreferencerMainWindow::setDeletePointTool );
mActionMoveGCPPoint->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionMoveGCPPoint.png" ) ) ); mActionMoveGCPPoint->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionMoveGCPPoint.png" ) ) );
connect( mActionMoveGCPPoint, &QAction::triggered, this, &QgsGeorefPluginGui::setMovePointTool ); connect( mActionMoveGCPPoint, &QAction::triggered, this, &QgsGeoreferencerMainWindow::setMovePointTool );
// View actions // View actions
mActionPan->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPan.svg" ) ) ); mActionPan->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPan.svg" ) ) );
connect( mActionPan, &QAction::triggered, this, &QgsGeorefPluginGui::setPanTool ); connect( mActionPan, &QAction::triggered, this, &QgsGeoreferencerMainWindow::setPanTool );
mActionZoomIn->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomIn.svg" ) ) ); mActionZoomIn->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomIn.svg" ) ) );
connect( mActionZoomIn, &QAction::triggered, this, &QgsGeorefPluginGui::setZoomInTool ); connect( mActionZoomIn, &QAction::triggered, this, &QgsGeoreferencerMainWindow::setZoomInTool );
mActionZoomOut->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomOut.svg" ) ) ); mActionZoomOut->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomOut.svg" ) ) );
connect( mActionZoomOut, &QAction::triggered, this, &QgsGeorefPluginGui::setZoomOutTool ); connect( mActionZoomOut, &QAction::triggered, this, &QgsGeoreferencerMainWindow::setZoomOutTool );
mActionZoomToLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToLayer.svg" ) ) ); mActionZoomToLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToLayer.svg" ) ) );
connect( mActionZoomToLayer, &QAction::triggered, this, &QgsGeorefPluginGui::zoomToLayerTool ); connect( mActionZoomToLayer, &QAction::triggered, this, &QgsGeoreferencerMainWindow::zoomToLayerTool );
mActionZoomLast->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomLast.svg" ) ) ); mActionZoomLast->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomLast.svg" ) ) );
connect( mActionZoomLast, &QAction::triggered, this, &QgsGeorefPluginGui::zoomToLast ); connect( mActionZoomLast, &QAction::triggered, this, &QgsGeoreferencerMainWindow::zoomToLast );
mActionZoomNext->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomNext.svg" ) ) ); mActionZoomNext->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomNext.svg" ) ) );
connect( mActionZoomNext, &QAction::triggered, this, &QgsGeorefPluginGui::zoomToNext ); connect( mActionZoomNext, &QAction::triggered, this, &QgsGeoreferencerMainWindow::zoomToNext );
mActionLinkGeorefToQGis->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionLinkGeorefToQGis.png" ) ) ); mActionLinkGeorefToQGis->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionLinkGeorefToQGis.png" ) ) );
connect( mActionLinkGeorefToQGis, &QAction::triggered, this, &QgsGeorefPluginGui::linkGeorefToQGis ); connect( mActionLinkGeorefToQGis, &QAction::triggered, this, &QgsGeoreferencerMainWindow::linkGeorefToQGis );
mActionLinkQGisToGeoref->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionLinkQGisToGeoref.png" ) ) ); mActionLinkQGisToGeoref->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionLinkQGisToGeoref.png" ) ) );
connect( mActionLinkQGisToGeoref, &QAction::triggered, this, &QgsGeorefPluginGui::linkQGisToGeoref ); connect( mActionLinkQGisToGeoref, &QAction::triggered, this, &QgsGeoreferencerMainWindow::linkQGisToGeoref );
// Settings actions // Settings actions
mActionRasterProperties->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionRasterProperties.png" ) ) ); mActionRasterProperties->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionRasterProperties.png" ) ) );
connect( mActionRasterProperties, &QAction::triggered, this, &QgsGeorefPluginGui::showRasterPropertiesDialog ); connect( mActionRasterProperties, &QAction::triggered, this, &QgsGeoreferencerMainWindow::showRasterPropertiesDialog );
mActionGeorefConfig->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionGeorefConfig.png" ) ) ); mActionGeorefConfig->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionGeorefConfig.png" ) ) );
connect( mActionGeorefConfig, &QAction::triggered, this, &QgsGeorefPluginGui::showGeorefConfigDialog ); connect( mActionGeorefConfig, &QAction::triggered, this, &QgsGeoreferencerMainWindow::showGeorefConfigDialog );
// Histogram stretch // Histogram stretch
mActionLocalHistogramStretch->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionLocalHistogramStretch.svg" ) ) ); mActionLocalHistogramStretch->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionLocalHistogramStretch.svg" ) ) );
connect( mActionLocalHistogramStretch, &QAction::triggered, this, &QgsGeorefPluginGui::localHistogramStretch ); connect( mActionLocalHistogramStretch, &QAction::triggered, this, &QgsGeoreferencerMainWindow::localHistogramStretch );
mActionLocalHistogramStretch->setEnabled( false ); mActionLocalHistogramStretch->setEnabled( false );
mActionFullHistogramStretch->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionFullHistogramStretch.svg" ) ) ); mActionFullHistogramStretch->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionFullHistogramStretch.svg" ) ) );
connect( mActionFullHistogramStretch, &QAction::triggered, this, &QgsGeorefPluginGui::fullHistogramStretch ); connect( mActionFullHistogramStretch, &QAction::triggered, this, &QgsGeoreferencerMainWindow::fullHistogramStretch );
mActionFullHistogramStretch->setEnabled( false ); mActionFullHistogramStretch->setEnabled( false );
// Help actions // Help actions
mActionHelp = new QAction( tr( "Help" ), this ); mActionHelp = new QAction( tr( "Help" ), this );
connect( mActionHelp, &QAction::triggered, this, &QgsGeorefPluginGui::showHelp ); connect( mActionHelp, &QAction::triggered, this, &QgsGeoreferencerMainWindow::showHelp );
mActionQuit->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionQuit.png" ) ) ); mActionQuit->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionQuit.png" ) ) );
mActionQuit->setShortcuts( QList<QKeySequence>() << QKeySequence( Qt::CTRL + Qt::Key_Q ) mActionQuit->setShortcuts( QList<QKeySequence>() << QKeySequence( Qt::CTRL + Qt::Key_Q )
@ -916,7 +916,7 @@ void QgsGeorefPluginGui::createActions()
connect( mActionQuit, &QAction::triggered, this, &QWidget::close ); connect( mActionQuit, &QAction::triggered, this, &QWidget::close );
} }
void QgsGeorefPluginGui::createActionGroups() void QgsGeoreferencerMainWindow::createActionGroups()
{ {
QActionGroup *mapToolGroup = new QActionGroup( this ); QActionGroup *mapToolGroup = new QActionGroup( this );
mActionPan->setCheckable( true ); mActionPan->setCheckable( true );
@ -934,7 +934,7 @@ void QgsGeorefPluginGui::createActionGroups()
mapToolGroup->addAction( mActionMoveGCPPoint ); mapToolGroup->addAction( mActionMoveGCPPoint );
} }
void QgsGeorefPluginGui::createMapCanvas() void QgsGeoreferencerMainWindow::createMapCanvas()
{ {
// set up the canvas // set up the canvas
mCanvas = new QgsMapCanvas( this->centralWidget() ); mCanvas = new QgsMapCanvas( this->centralWidget() );
@ -957,31 +957,31 @@ void QgsGeorefPluginGui::createMapCanvas()
mToolAddPoint = new QgsGeorefToolAddPoint( mCanvas ); mToolAddPoint = new QgsGeorefToolAddPoint( mCanvas );
mToolAddPoint->setAction( mActionAddPoint ); mToolAddPoint->setAction( mActionAddPoint );
connect( mToolAddPoint, &QgsGeorefToolAddPoint::showCoordDialog, connect( mToolAddPoint, &QgsGeorefToolAddPoint::showCoordDialog,
this, &QgsGeorefPluginGui::showCoordDialog ); this, &QgsGeoreferencerMainWindow::showCoordDialog );
mToolDeletePoint = new QgsGeorefToolDeletePoint( mCanvas ); mToolDeletePoint = new QgsGeorefToolDeletePoint( mCanvas );
mToolDeletePoint->setAction( mActionDeletePoint ); mToolDeletePoint->setAction( mActionDeletePoint );
connect( mToolDeletePoint, &QgsGeorefToolDeletePoint::deleteDataPoint, connect( mToolDeletePoint, &QgsGeorefToolDeletePoint::deleteDataPoint,
this, static_cast<void ( QgsGeorefPluginGui::* )( QPoint )>( &QgsGeorefPluginGui::deleteDataPoint ) ); this, static_cast<void ( QgsGeoreferencerMainWindow::* )( QPoint )>( &QgsGeoreferencerMainWindow::deleteDataPoint ) );
mToolMovePoint = new QgsGeorefToolMovePoint( mCanvas ); mToolMovePoint = new QgsGeorefToolMovePoint( mCanvas );
mToolMovePoint->setAction( mActionMoveGCPPoint ); mToolMovePoint->setAction( mActionMoveGCPPoint );
connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointPressed, connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointPressed,
this, &QgsGeorefPluginGui::selectPoint ); this, &QgsGeoreferencerMainWindow::selectPoint );
connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointMoved, connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointMoved,
this, &QgsGeorefPluginGui::movePoint ); this, &QgsGeoreferencerMainWindow::movePoint );
connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointReleased, connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointReleased,
this, &QgsGeorefPluginGui::releasePoint ); this, &QgsGeoreferencerMainWindow::releasePoint );
// Point in Qgis Map // Point in Qgis Map
mToolMovePointQgis = new QgsGeorefToolMovePoint( mIface->mapCanvas() ); mToolMovePointQgis = new QgsGeorefToolMovePoint( QgisApp::instance()->mapCanvas() );
mToolMovePointQgis->setAction( mActionMoveGCPPoint ); mToolMovePointQgis->setAction( mActionMoveGCPPoint );
connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointPressed, connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointPressed,
this, &QgsGeorefPluginGui::selectPoint ); this, &QgsGeoreferencerMainWindow::selectPoint );
connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointMoved, connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointMoved,
this, &QgsGeorefPluginGui::movePoint ); this, &QgsGeoreferencerMainWindow::movePoint );
connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointReleased, connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointReleased,
this, &QgsGeorefPluginGui::releasePoint ); this, &QgsGeoreferencerMainWindow::releasePoint );
QgsSettings s; QgsSettings s;
double zoomFactor = s.value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toDouble(); double zoomFactor = s.value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toDouble();
@ -994,11 +994,11 @@ void QgsGeorefPluginGui::createMapCanvas()
// Connect main canvas and georef canvas signals so we are aware if any of the viewports change // Connect main canvas and georef canvas signals so we are aware if any of the viewports change
// (used by the map follow mode) // (used by the map follow mode)
connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsGeorefPluginGui::extentsChangedGeorefCanvas ); connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsGeoreferencerMainWindow::extentsChangedGeorefCanvas );
connect( mIface->mapCanvas(), &QgsMapCanvas::extentsChanged, this, &QgsGeorefPluginGui::extentsChangedQGisCanvas ); connect( QgisApp::instance()->mapCanvas(), &QgsMapCanvas::extentsChanged, this, &QgsGeoreferencerMainWindow::extentsChangedQGisCanvas );
} }
void QgsGeorefPluginGui::createMenus() void QgsGeoreferencerMainWindow::createMenus()
{ {
// Get platform for menu layout customization (Gnome, Kde, Mac, Win) // Get platform for menu layout customization (Gnome, Kde, Mac, Win)
QDialogButtonBox::ButtonLayout layout = QDialogButtonBox::ButtonLayout layout =
@ -1015,10 +1015,10 @@ void QgsGeorefPluginGui::createMenus()
mToolbarMenu->addAction( toolBarEdit->toggleViewAction() ); mToolbarMenu->addAction( toolBarEdit->toggleViewAction() );
mToolbarMenu->addAction( toolBarView->toggleViewAction() ); mToolbarMenu->addAction( toolBarView->toggleViewAction() );
toolBarFile->setIconSize( mIface->iconSize() ); toolBarFile->setIconSize( QgisApp::instance()->iconSize() );
toolBarEdit->setIconSize( mIface->iconSize() ); toolBarEdit->setIconSize( QgisApp::instance()->iconSize() );
toolBarView->setIconSize( mIface->iconSize() ); toolBarView->setIconSize( QgisApp::instance()->iconSize() );
toolBarHistogramStretch->setIconSize( mIface->iconSize() ); toolBarHistogramStretch->setIconSize( QgisApp::instance()->iconSize() );
// View menu // View menu
if ( layout != QDialogButtonBox::KdeLayout ) if ( layout != QDialogButtonBox::KdeLayout )
@ -1035,7 +1035,7 @@ void QgsGeorefPluginGui::createMenus()
} }
} }
void QgsGeorefPluginGui::createDockWidgets() void QgsGeoreferencerMainWindow::createDockWidgets()
{ {
// mLogViewer = new QPlainTextEdit; // mLogViewer = new QPlainTextEdit;
// mLogViewer->setReadOnly(true); // mLogViewer->setReadOnly(true);
@ -1046,17 +1046,17 @@ void QgsGeorefPluginGui::createDockWidgets()
mGCPListWidget->setGeorefTransform( &mGeorefTransform ); mGCPListWidget->setGeorefTransform( &mGeorefTransform );
dockWidgetGCPpoints->setWidget( mGCPListWidget ); dockWidgetGCPpoints->setWidget( mGCPListWidget );
connect( mGCPListWidget, &QgsGCPListWidget::jumpToGCP, this, &QgsGeorefPluginGui::jumpToGCP ); connect( mGCPListWidget, &QgsGCPListWidget::jumpToGCP, this, &QgsGeoreferencerMainWindow::jumpToGCP );
#if 0 #if 0
connect( mGCPListWidget, SIGNAL( replaceDataPoint( QgsGeorefDataPoint *, int ) ), connect( mGCPListWidget, SIGNAL( replaceDataPoint( QgsGeorefDataPoint *, int ) ),
this, SLOT( replaceDataPoint( QgsGeorefDataPoint *, int ) ) ); this, SLOT( replaceDataPoint( QgsGeorefDataPoint *, int ) ) );
#endif #endif
connect( mGCPListWidget, static_cast<void ( QgsGCPListWidget::* )( int )>( &QgsGCPListWidget::deleteDataPoint ), connect( mGCPListWidget, static_cast<void ( QgsGCPListWidget::* )( int )>( &QgsGCPListWidget::deleteDataPoint ),
this, static_cast<void ( QgsGeorefPluginGui::* )( int )>( &QgsGeorefPluginGui::deleteDataPoint ) ); this, static_cast<void ( QgsGeoreferencerMainWindow::* )( int )>( &QgsGeoreferencerMainWindow::deleteDataPoint ) );
connect( mGCPListWidget, &QgsGCPListWidget::pointEnabled, this, &QgsGeorefPluginGui::updateGeorefTransform ); connect( mGCPListWidget, &QgsGCPListWidget::pointEnabled, this, &QgsGeoreferencerMainWindow::updateGeorefTransform );
} }
QLabel *QgsGeorefPluginGui::createBaseLabelStatus() QLabel *QgsGeoreferencerMainWindow::createBaseLabelStatus()
{ {
QFont myFont( QStringLiteral( "Arial" ), 9 ); QFont myFont( QStringLiteral( "Arial" ), 9 );
QLabel *label = new QLabel( statusBar() ); QLabel *label = new QLabel( statusBar() );
@ -1069,7 +1069,7 @@ QLabel *QgsGeorefPluginGui::createBaseLabelStatus()
return label; return label;
} }
void QgsGeorefPluginGui::createStatusBar() void QgsGeoreferencerMainWindow::createStatusBar()
{ {
mTransformParamLabel = createBaseLabelStatus(); mTransformParamLabel = createBaseLabelStatus();
mTransformParamLabel->setText( tr( "Transform: " ) + convertTransformEnumToString( mTransformParam ) ); mTransformParamLabel->setText( tr( "Transform: " ) + convertTransformEnumToString( mTransformParam ) );
@ -1087,22 +1087,22 @@ void QgsGeorefPluginGui::createStatusBar()
statusBar()->addPermanentWidget( mEPSG, 0 ); statusBar()->addPermanentWidget( mEPSG, 0 );
} }
void QgsGeorefPluginGui::setupConnections() void QgsGeoreferencerMainWindow::setupConnections()
{ {
connect( mCanvas, &QgsMapCanvas::xyCoordinates, this, &QgsGeorefPluginGui::showMouseCoords ); connect( mCanvas, &QgsMapCanvas::xyCoordinates, this, &QgsGeoreferencerMainWindow::showMouseCoords );
connect( mCanvas, &QgsMapCanvas::scaleChanged, this, &QgsGeorefPluginGui::updateMouseCoordinatePrecision ); connect( mCanvas, &QgsMapCanvas::scaleChanged, this, &QgsGeoreferencerMainWindow::updateMouseCoordinatePrecision );
// Connect status from ZoomLast/ZoomNext to corresponding action // Connect status from ZoomLast/ZoomNext to corresponding action
connect( mCanvas, &QgsMapCanvas::zoomLastStatusChanged, mActionZoomLast, &QAction::setEnabled ); connect( mCanvas, &QgsMapCanvas::zoomLastStatusChanged, mActionZoomLast, &QAction::setEnabled );
connect( mCanvas, &QgsMapCanvas::zoomNextStatusChanged, mActionZoomNext, &QAction::setEnabled ); connect( mCanvas, &QgsMapCanvas::zoomNextStatusChanged, mActionZoomNext, &QAction::setEnabled );
// Connect when one Layer is removed - Case where change the Projetct in QGIS // Connect when one Layer is removed - Case where change the Projetct in QGIS
connect( QgsProject::instance(), static_cast<void ( QgsProject::* )( const QString & )>( &QgsProject::layerWillBeRemoved ), this, &QgsGeorefPluginGui::layerWillBeRemoved ); connect( QgsProject::instance(), static_cast<void ( QgsProject::* )( const QString & )>( &QgsProject::layerWillBeRemoved ), this, &QgsGeoreferencerMainWindow::layerWillBeRemoved );
// Connect extents changed - Use for need add again Raster // Connect extents changed - Use for need add again Raster
connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsGeorefPluginGui::extentsChanged ); connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsGeoreferencerMainWindow::extentsChanged );
} }
void QgsGeorefPluginGui::removeOldLayer() void QgsGeoreferencerMainWindow::removeOldLayer()
{ {
// delete layer (and don't signal it as it's our private layer) // delete layer (and don't signal it as it's our private layer)
if ( mLayer ) if ( mLayer )
@ -1117,7 +1117,7 @@ void QgsGeorefPluginGui::removeOldLayer()
} }
// Mapcanvas Plugin // Mapcanvas Plugin
void QgsGeorefPluginGui::addRaster( const QString &file ) void QgsGeoreferencerMainWindow::addRaster( const QString &file )
{ {
mLayer = new QgsRasterLayer( file, QStringLiteral( "Raster" ) ); mLayer = new QgsRasterLayer( file, QStringLiteral( "Raster" ) );
@ -1148,12 +1148,12 @@ void QgsGeorefPluginGui::addRaster( const QString &file )
} }
// Settings // Settings
void QgsGeorefPluginGui::readSettings() void QgsGeoreferencerMainWindow::readSettings()
{ {
QgsSettings s; QgsSettings s;
QRect georefRect = QApplication::desktop()->screenGeometry( mIface->mainWindow() ); QRect georefRect = QApplication::desktop()->screenGeometry( QgisApp::instance() );
resize( s.value( QStringLiteral( "/Plugin-GeoReferencer/size" ), QSize( georefRect.width() / 2 + georefRect.width() / 5, resize( s.value( QStringLiteral( "/Plugin-GeoReferencer/size" ), QSize( georefRect.width() / 2 + georefRect.width() / 5,
mIface->mainWindow()->height() ) ).toSize() ); QgisApp::instance()->height() ) ).toSize() );
move( s.value( QStringLiteral( "/Plugin-GeoReferencer/pos" ), QPoint( parentWidget()->width() / 2 - width() / 2, 0 ) ).toPoint() ); move( s.value( QStringLiteral( "/Plugin-GeoReferencer/pos" ), QPoint( parentWidget()->width() / 2 - width() / 2, 0 ) ).toPoint() );
restoreState( s.value( QStringLiteral( "/Plugin-GeoReferencer/uistate" ) ).toByteArray() ); restoreState( s.value( QStringLiteral( "/Plugin-GeoReferencer/uistate" ) ).toByteArray() );
@ -1164,7 +1164,7 @@ void QgsGeorefPluginGui::readSettings()
mUseZeroForTrans = s.value( QStringLiteral( "/Plugin-GeoReferencer/usezerofortrans" ), false ).toBool(); mUseZeroForTrans = s.value( QStringLiteral( "/Plugin-GeoReferencer/usezerofortrans" ), false ).toBool();
} }
void QgsGeorefPluginGui::writeSettings() void QgsGeoreferencerMainWindow::writeSettings()
{ {
QgsSettings s; QgsSettings s;
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/pos" ), pos() ); s.setValue( QStringLiteral( "/Plugin-GeoReferencer/pos" ), pos() );
@ -1179,7 +1179,7 @@ void QgsGeorefPluginGui::writeSettings()
} }
// GCP points // GCP points
bool QgsGeorefPluginGui::loadGCPs( /*bool verbose*/ ) bool QgsGeoreferencerMainWindow::loadGCPs( /*bool verbose*/ )
{ {
QFile pointFile( mGCPpointsFileName ); QFile pointFile( mGCPpointsFileName );
if ( !pointFile.open( QIODevice::ReadOnly ) ) if ( !pointFile.open( QIODevice::ReadOnly ) )
@ -1232,13 +1232,13 @@ bool QgsGeorefPluginGui::loadGCPs( /*bool verbose*/ )
mGCPListWidget->setGCPList( &mPoints ); mGCPListWidget->setGCPList( &mPoints );
updateGeorefTransform(); updateGeorefTransform();
mCanvas->refresh(); mCanvas->refresh();
mIface->mapCanvas()->refresh(); QgisApp::instance()->mapCanvas()->refresh();
} }
return true; return true;
} }
void QgsGeorefPluginGui::saveGCPs() void QgsGeoreferencerMainWindow::saveGCPs()
{ {
QFile pointFile( mGCPpointsFileName ); QFile pointFile( mGCPpointsFileName );
if ( pointFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) if ( pointFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
@ -1270,10 +1270,10 @@ void QgsGeorefPluginGui::saveGCPs()
// showMessageInLog(tr("GCP points saved in"), mGCPpointsFileName); // showMessageInLog(tr("GCP points saved in"), mGCPpointsFileName);
} }
QgsGeorefPluginGui::SaveGCPs QgsGeorefPluginGui::checkNeedGCPSave() QgsGeoreferencerMainWindow::SaveGCPs QgsGeoreferencerMainWindow::checkNeedGCPSave()
{ {
if ( 0 == mPoints.count() ) if ( 0 == mPoints.count() )
return QgsGeorefPluginGui::GCPDISCARD; return QgsGeoreferencerMainWindow::GCPDISCARD;
if ( !equalGCPlists( mInitialPoints, mPoints ) ) if ( !equalGCPlists( mInitialPoints, mPoints ) )
{ {
@ -1283,23 +1283,23 @@ QgsGeorefPluginGui::SaveGCPs QgsGeorefPluginGui::checkNeedGCPSave()
| QMessageBox::Cancel ); | QMessageBox::Cancel );
if ( a == QMessageBox::Save ) if ( a == QMessageBox::Save )
{ {
return QgsGeorefPluginGui::GCPSAVE; return QgsGeoreferencerMainWindow::GCPSAVE;
} }
else if ( a == QMessageBox::Cancel ) else if ( a == QMessageBox::Cancel )
{ {
return QgsGeorefPluginGui::GCPCANCEL; return QgsGeoreferencerMainWindow::GCPCANCEL;
} }
else if ( a == QMessageBox::Discard ) else if ( a == QMessageBox::Discard )
{ {
return QgsGeorefPluginGui::GCPDISCARD; return QgsGeoreferencerMainWindow::GCPDISCARD;
} }
} }
return QgsGeorefPluginGui::GCPSILENTSAVE; return QgsGeoreferencerMainWindow::GCPSILENTSAVE;
} }
// Georeference // Georeference
bool QgsGeorefPluginGui::georeference() bool QgsGeoreferencerMainWindow::georeference()
{ {
if ( !checkReadyGeoref() ) if ( !checkReadyGeoref() )
return false; return false;
@ -1388,7 +1388,7 @@ bool QgsGeorefPluginGui::georeference()
} }
} }
bool QgsGeorefPluginGui::writeWorldFile( const QgsPointXY &origin, double pixelXSize, double pixelYSize, double rotation ) bool QgsGeoreferencerMainWindow::writeWorldFile( const QgsPointXY &origin, double pixelXSize, double pixelYSize, double rotation )
{ {
// write the world file // write the world file
QFile file( mWorldFileName ); QFile file( mWorldFileName );
@ -1419,7 +1419,7 @@ bool QgsGeorefPluginGui::writeWorldFile( const QgsPointXY &origin, double pixelX
return true; return true;
} }
bool QgsGeorefPluginGui::calculateMeanError( double &error ) const bool QgsGeoreferencerMainWindow::calculateMeanError( double &error ) const
{ {
if ( mGeorefTransform.transformParametrisation() == QgsGeorefTransform::InvalidTransform ) if ( mGeorefTransform.transformParametrisation() == QgsGeorefTransform::InvalidTransform )
{ {
@ -1465,7 +1465,7 @@ bool QgsGeorefPluginGui::calculateMeanError( double &error ) const
return true; return true;
} }
bool QgsGeorefPluginGui::writePDFMapFile( const QString &fileName, const QgsGeorefTransform &transform ) bool QgsGeoreferencerMainWindow::writePDFMapFile( const QString &fileName, const QgsGeorefTransform &transform )
{ {
Q_UNUSED( transform ) Q_UNUSED( transform )
if ( !mCanvas ) if ( !mCanvas )
@ -1543,7 +1543,7 @@ bool QgsGeorefPluginGui::writePDFMapFile( const QString &fileName, const QgsGeor
return true; return true;
} }
bool QgsGeorefPluginGui::writePDFReportFile( const QString &fileName, const QgsGeorefTransform &transform ) bool QgsGeoreferencerMainWindow::writePDFReportFile( const QString &fileName, const QgsGeorefTransform &transform )
{ {
if ( !mCanvas ) if ( !mCanvas )
{ {
@ -1754,7 +1754,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString &fileName, const QgsG
return true; return true;
} }
void QgsGeorefPluginGui::updateTransformParamLabel() void QgsGeoreferencerMainWindow::updateTransformParamLabel()
{ {
if ( !mTransformParamLabel ) if ( !mTransformParamLabel )
{ {
@ -1786,7 +1786,7 @@ void QgsGeorefPluginGui::updateTransformParamLabel()
} }
// Gdal script // Gdal script
void QgsGeorefPluginGui::showGDALScript( const QStringList &commands ) void QgsGeoreferencerMainWindow::showGDALScript( const QStringList &commands )
{ {
QString script = commands.join( QStringLiteral( "\n" ) ) + '\n'; QString script = commands.join( QStringLiteral( "\n" ) ) + '\n';
@ -1818,7 +1818,7 @@ void QgsGeorefPluginGui::showGDALScript( const QStringList &commands )
} }
} }
QString QgsGeorefPluginGui::generateGDALtranslateCommand( bool generateTFW ) QString QgsGeoreferencerMainWindow::generateGDALtranslateCommand( bool generateTFW )
{ {
QStringList gdalCommand; QStringList gdalCommand;
gdalCommand << QStringLiteral( "gdal_translate" ) << QStringLiteral( "-of GTiff" ); gdalCommand << QStringLiteral( "gdal_translate" ) << QStringLiteral( "-of GTiff" );
@ -1841,7 +1841,7 @@ QString QgsGeorefPluginGui::generateGDALtranslateCommand( bool generateTFW )
return gdalCommand.join( QStringLiteral( " " ) ); return gdalCommand.join( QStringLiteral( " " ) );
} }
QString QgsGeorefPluginGui::generateGDALwarpCommand( const QString &resampling, const QString &compress, QString QgsGeoreferencerMainWindow::generateGDALwarpCommand( const QString &resampling, const QString &compress,
bool useZeroForTrans, int order, double targetResX, double targetResY ) bool useZeroForTrans, int order, double targetResX, double targetResY )
{ {
QStringList gdalCommand; QStringList gdalCommand;
@ -1892,7 +1892,7 @@ QString QgsGeorefPluginGui::generateGDALwarpCommand( const QString &resampling,
//} //}
// Helpers // Helpers
bool QgsGeorefPluginGui::checkReadyGeoref() bool QgsGeoreferencerMainWindow::checkReadyGeoref()
{ {
if ( mRasterFileName.isEmpty() ) if ( mRasterFileName.isEmpty() )
{ {
@ -1934,7 +1934,7 @@ bool QgsGeorefPluginGui::checkReadyGeoref()
return true; return true;
} }
bool QgsGeorefPluginGui::updateGeorefTransform() bool QgsGeoreferencerMainWindow::updateGeorefTransform()
{ {
QVector<QgsPointXY> mapCoords, pixelCoords; QVector<QgsPointXY> mapCoords, pixelCoords;
if ( mGCPListWidget->gcpList() ) if ( mGCPListWidget->gcpList() )
@ -1955,7 +1955,7 @@ bool QgsGeorefPluginGui::updateGeorefTransform()
// Samples the given rectangle at numSamples per edge. // Samples the given rectangle at numSamples per edge.
// Returns an axis aligned bounding box which contains the transformed samples. // Returns an axis aligned bounding box which contains the transformed samples.
QgsRectangle QgsGeorefPluginGui::transformViewportBoundingBox( const QgsRectangle &canvasExtent, QgsRectangle QgsGeoreferencerMainWindow::transformViewportBoundingBox( const QgsRectangle &canvasExtent,
QgsGeorefTransform &t, QgsGeorefTransform &t,
bool rasterToWorld, uint numSamples ) bool rasterToWorld, uint numSamples )
{ {
@ -2000,7 +2000,7 @@ QgsRectangle QgsGeorefPluginGui::transformViewportBoundingBox( const QgsRectangl
return QgsRectangle( minX, minY, maxX, maxY ); return QgsRectangle( minX, minY, maxX, maxY );
} }
QString QgsGeorefPluginGui::convertTransformEnumToString( QgsGeorefTransform::TransformParametrisation transform ) QString QgsGeoreferencerMainWindow::convertTransformEnumToString( QgsGeorefTransform::TransformParametrisation transform )
{ {
switch ( transform ) switch ( transform )
{ {
@ -2023,7 +2023,7 @@ QString QgsGeorefPluginGui::convertTransformEnumToString( QgsGeorefTransform::Tr
} }
} }
QString QgsGeorefPluginGui::convertResamplingEnumToString( QgsImageWarper::ResamplingMethod resampling ) QString QgsGeoreferencerMainWindow::convertResamplingEnumToString( QgsImageWarper::ResamplingMethod resampling )
{ {
switch ( resampling ) switch ( resampling )
{ {
@ -2041,7 +2041,7 @@ QString QgsGeorefPluginGui::convertResamplingEnumToString( QgsImageWarper::Resam
return QString(); return QString();
} }
int QgsGeorefPluginGui::polynomialOrder( QgsGeorefTransform::TransformParametrisation transform ) int QgsGeoreferencerMainWindow::polynomialOrder( QgsGeorefTransform::TransformParametrisation transform )
{ {
switch ( transform ) switch ( transform )
{ {
@ -2059,7 +2059,7 @@ int QgsGeorefPluginGui::polynomialOrder( QgsGeorefTransform::TransformParametris
} }
} }
QString QgsGeorefPluginGui::guessWorldFileName( const QString &rasterFileName ) QString QgsGeoreferencerMainWindow::guessWorldFileName( const QString &rasterFileName )
{ {
QString worldFileName; QString worldFileName;
int point = rasterFileName.lastIndexOf( '.' ); int point = rasterFileName.lastIndexOf( '.' );
@ -2069,7 +2069,7 @@ QString QgsGeorefPluginGui::guessWorldFileName( const QString &rasterFileName )
return worldFileName; return worldFileName;
} }
bool QgsGeorefPluginGui::checkFileExisting( const QString &fileName, const QString &title, const QString &question ) bool QgsGeoreferencerMainWindow::checkFileExisting( const QString &fileName, const QString &title, const QString &question )
{ {
if ( !fileName.isEmpty() ) if ( !fileName.isEmpty() )
{ {
@ -2088,7 +2088,7 @@ bool QgsGeorefPluginGui::checkFileExisting( const QString &fileName, const QStri
return true; return true;
} }
bool QgsGeorefPluginGui::equalGCPlists( const QgsGCPList &list1, const QgsGCPList &list2 ) bool QgsGeoreferencerMainWindow::equalGCPlists( const QgsGCPList &list1, const QgsGCPList &list2 )
{ {
if ( list1.count() != list2.count() ) if ( list1.count() != list2.count() )
return false; return false;
@ -2129,7 +2129,7 @@ bool QgsGeorefPluginGui::equalGCPlists( const QgsGCPList &list1, const QgsGCPLis
// } // }
//} //}
void QgsGeorefPluginGui::clearGCPData() void QgsGeoreferencerMainWindow::clearGCPData()
{ {
//force all list widget editors to close before removing data points //force all list widget editors to close before removing data points
//otherwise the editors try to update deleted data points when they close //otherwise the editors try to update deleted data points when they close
@ -2139,10 +2139,10 @@ void QgsGeorefPluginGui::clearGCPData()
mPoints.clear(); mPoints.clear();
mGCPListWidget->updateGCPList(); mGCPListWidget->updateGCPList();
mIface->mapCanvas()->refresh(); QgisApp::instance()->mapCanvas()->refresh();
} }
int QgsGeorefPluginGui::messageTimeout() int QgsGeoreferencerMainWindow::messageTimeout()
{ {
QgsSettings settings; QgsSettings settings;
return settings.value( QStringLiteral( "qgis/messageTimeout" ), 5 ).toInt(); return settings.value( QStringLiteral( "qgis/messageTimeout" ), 5 ).toInt();

View File

@ -51,13 +51,13 @@ class QgsGeorefDockWidget : public QgsDockWidget
QgsGeorefDockWidget( const QString &title, QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr ); QgsGeorefDockWidget( const QString &title, QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr );
}; };
class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBase class QgsGeoreferencerMainWindow : public QMainWindow, private Ui::QgsGeorefPluginGuiBase
{ {
Q_OBJECT Q_OBJECT
public: public:
QgsGeorefPluginGui( QgisInterface *qgisInterface, QWidget *parent = nullptr, Qt::WindowFlags fl = nullptr ); QgsGeoreferencerMainWindow( QWidget *parent = nullptr, Qt::WindowFlags fl = nullptr );
~QgsGeorefPluginGui() override; ~QgsGeoreferencerMainWindow() override;
protected: protected:
void closeEvent( QCloseEvent * ) override; void closeEvent( QCloseEvent * ) override;
@ -156,7 +156,7 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
// gcp points // gcp points
bool loadGCPs( /*bool verbose = true*/ ); bool loadGCPs( /*bool verbose = true*/ );
void saveGCPs(); void saveGCPs();
QgsGeorefPluginGui::SaveGCPs checkNeedGCPSave(); QgsGeoreferencerMainWindow::SaveGCPs checkNeedGCPSave();
// georeference // georeference
bool georeference(); bool georeference();
@ -233,8 +233,6 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
QgsGeorefTransform mGeorefTransform; QgsGeorefTransform mGeorefTransform;
QString mCompressionMethod; QString mCompressionMethod;
QgisInterface *mIface = nullptr;
QgsGCPList mPoints; QgsGCPList mPoints;
QgsGCPList mInitialPoints; QgsGCPList mInitialPoints;
QgsMapCanvas *mCanvas = nullptr; QgsMapCanvas *mCanvas = nullptr;

View File

@ -117,6 +117,10 @@
#include "qgsvectorlayer3drendererwidget.h" #include "qgsvectorlayer3drendererwidget.h"
#endif #endif
#ifdef HAVE_GEOREFERENCER
#include "georeferencer/qgsgeorefplugingui.h"
#endif
#include "qgsgui.h" #include "qgsgui.h"
#include "qgsnative.h" #include "qgsnative.h"
#include "qgsdatasourceselectdialog.h" #include "qgsdatasourceselectdialog.h"
@ -740,6 +744,16 @@ void QgisApp::toggleEventTracing()
} }
} }
#ifdef HAVE_GEOREFERENCER
void QgisApp::showGeoreferencer()
{
if ( !mGeoreferencer )
mGeoreferencer = new QgsGeoreferencerMainWindow( this );
mGeoreferencer->show();
mGeoreferencer->setFocus();
}
#endif
/* /*
* This function contains forced validation of CRS used in QGIS. * This function contains forced validation of CRS used in QGIS.
* There are 4 options depending on the settings: * There are 4 options depending on the settings:
@ -2753,6 +2767,13 @@ void QgisApp::createActions()
connect( mActionIncreaseContrast, &QAction::triggered, this, &QgisApp::increaseContrast ); connect( mActionIncreaseContrast, &QAction::triggered, this, &QgisApp::increaseContrast );
connect( mActionDecreaseContrast, &QAction::triggered, this, &QgisApp::decreaseContrast ); connect( mActionDecreaseContrast, &QAction::triggered, this, &QgisApp::decreaseContrast );
#ifdef HAVE_GEOREFERENCER
connect( mActionShowGeoreferencer, &QAction::triggered, this, &QgisApp::showGeoreferencer );
#else
delete mActionShowGeoreferencer;
mActionShowGeoreferencer = nullptr;
#endif
// Help Menu Items // Help Menu Items
#ifdef Q_OS_MAC #ifdef Q_OS_MAC

View File

@ -146,7 +146,6 @@ class QgsDevToolsPanelWidget;
class QgsDevToolWidgetFactory; class QgsDevToolWidgetFactory;
class QgsNetworkLogger; class QgsNetworkLogger;
class QgsNetworkLoggerWidgetFactory; class QgsNetworkLoggerWidgetFactory;
#include <QMainWindow> #include <QMainWindow>
#include <QToolBar> #include <QToolBar>
#include <QAbstractSocket> #include <QAbstractSocket>
@ -183,6 +182,10 @@ class QgsNetworkLoggerWidgetFactory;
class QgsLegendFilterButton; class QgsLegendFilterButton;
#ifdef HAVE_GEOREFERENCER
class QgsGeoreferencerMainWindow;
#endif
/** /**
* \class QgisApp * \class QgisApp
* \brief Main window for the Qgis application * \brief Main window for the Qgis application
@ -1835,6 +1838,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Enable or disable event tracing (for debugging) //! Enable or disable event tracing (for debugging)
void toggleEventTracing(); void toggleEventTracing();
#ifdef HAVE_GEOREFERENCER
void showGeoreferencer();
#endif
signals: signals:
/** /**
@ -2470,6 +2477,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsSnappingUtils *mSnappingUtils = nullptr; QgsSnappingUtils *mSnappingUtils = nullptr;
#ifdef HAVE_GEOREFERENCER
QgsGeoreferencerMainWindow *mGeoreferencer = nullptr;
#endif
QList<QgsMapLayerConfigWidgetFactory *> mMapLayerPanelFactories; QList<QgsMapLayerConfigWidgetFactory *> mMapLayerPanelFactories;
QList<QPointer<QgsOptionsWidgetFactory>> mOptionsWidgetFactories; QList<QPointer<QgsOptionsWidgetFactory>> mOptionsWidgetFactories;

View File

@ -17,7 +17,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>847</width> <width>847</width>
<height>20</height> <height>24</height>
</rect> </rect>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -275,6 +275,7 @@
</property> </property>
<addaction name="mActionShowRasterCalculator"/> <addaction name="mActionShowRasterCalculator"/>
<addaction name="mActionShowAlignRasterTool"/> <addaction name="mActionShowAlignRasterTool"/>
<addaction name="mActionShowGeoreferencer"/>
</widget> </widget>
<widget class="QMenu" name="mVectorMenu"> <widget class="QMenu" name="mVectorMenu">
<property name="title"> <property name="title">
@ -3339,6 +3340,11 @@ Shows placeholders for labels which could not be placed, e.g. due to overlaps wi
<string>Add Vector Tile Layer…</string> <string>Add Vector Tile Layer…</string>
</property> </property>
</action> </action>
<action name="mActionShowGeoreferencer">
<property name="text">
<string>Georeferencer…</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../../images/images.qrc"/> <include location="../../images/images.qrc"/>