Skip to content

Commit

Permalink
Fix logic determining when link georef to qgis canvas actions are
Browse files Browse the repository at this point in the history
enabled

And partially fix this functionality when using an already
georeferenced image (not fully)
  • Loading branch information
nyalldawson committed Feb 9, 2022
1 parent baf0534 commit b20a05a
Showing 1 changed file with 21 additions and 35 deletions.
56 changes: 21 additions & 35 deletions src/app/georeferencer/qgsgeorefmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,14 @@ void QgsGeoreferencerMainWindow::openRaster( const QString &fileName )
mCanvas->refresh();
QgisApp::instance()->mapCanvas()->refresh();

mActionLinkGeorefToQgis->setChecked( false );
mActionLinkQGisToGeoref->setChecked( false );
mActionLinkGeorefToQgis->setEnabled( false );
mActionLinkQGisToGeoref->setEnabled( false );
const bool hasExistingReference = mLayer->crs().isValid();
mActionLinkGeorefToQgis->setEnabled( hasExistingReference );
mActionLinkQGisToGeoref->setEnabled( hasExistingReference );
if ( !hasExistingReference )
{
mActionLinkGeorefToQgis->setChecked( false );
mActionLinkQGisToGeoref->setChecked( false );
}

mCanvas->clearExtentHistory(); // reset zoomnext/zoomlast
mWorldFileName = guessWorldFileName( mRasterFileName );
Expand Down Expand Up @@ -362,9 +366,6 @@ void QgsGeoreferencerMainWindow::doGeoreference()
// mGeorefTransform.selectTransformParametrisation(mTransformParam);
// mGCPListWidget->setGeorefTransform(&mGeorefTransform);
// mTransformParamLabel->setText(tr("Transform: ") + convertTransformEnumToString(mTransformParam));

mActionLinkGeorefToQgis->setEnabled( false );
mActionLinkQGisToGeoref->setEnabled( false );
}
}
}
Expand All @@ -389,15 +390,14 @@ bool QgsGeoreferencerMainWindow::getTransformSettings()
// logTransformOptions();
// logRequaredGCPs();

if ( QgsGcpTransformerInterface::TransformMethod::InvalidTransform != mTransformParam )
const bool hasReferencing = QgsGcpTransformerInterface::TransformMethod::InvalidTransform != mTransformParam
|| mLayer->crs().isValid();
mActionLinkGeorefToQgis->setEnabled( hasReferencing );
mActionLinkQGisToGeoref->setEnabled( hasReferencing );
if ( !hasReferencing )
{
mActionLinkGeorefToQgis->setEnabled( true );
mActionLinkQGisToGeoref->setEnabled( true );
}
else
{
mActionLinkGeorefToQgis->setEnabled( false );
mActionLinkQGisToGeoref->setEnabled( false );
mActionLinkGeorefToQgis->setChecked( false );
mActionLinkQGisToGeoref->setChecked( false );
}

updateTransformParamLabel();
Expand Down Expand Up @@ -506,31 +506,17 @@ void QgsGeoreferencerMainWindow::linkQGisToGeoref( bool link )
{
if ( link )
{
if ( QgsGcpTransformerInterface::TransformMethod::InvalidTransform != mTransformParam )
{
// Indicate that georeferencer canvas extent has changed
extentsChangedGeorefCanvas();
}
else
{
mActionLinkGeorefToQgis->setEnabled( false );
}
// Indicate that georeferencer canvas extent has changed
extentsChangedGeorefCanvas();
}
}

void QgsGeoreferencerMainWindow::linkGeorefToQgis( bool link )
{
if ( link )
{
if ( QgsGcpTransformerInterface::TransformMethod::InvalidTransform != mTransformParam )
{
// Indicate that qgis main canvas extent has changed
extentsChangedQGisCanvas();
}
else
{
mActionLinkQGisToGeoref->setEnabled( false );
}
// Indicate that qgis main canvas extent has changed
extentsChangedQGisCanvas();
}
}

Expand Down Expand Up @@ -920,10 +906,10 @@ void QgsGeoreferencerMainWindow::createActions()
connect( mActionZoomNext, &QAction::triggered, this, &QgsGeoreferencerMainWindow::zoomToNext );

mActionLinkGeorefToQgis->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionLinkGeorefToQgis.png" ) ) );
connect( mActionLinkGeorefToQgis, &QAction::triggered, this, &QgsGeoreferencerMainWindow::linkGeorefToQgis );
connect( mActionLinkGeorefToQgis, &QAction::toggled, this, &QgsGeoreferencerMainWindow::linkGeorefToQgis );

mActionLinkQGisToGeoref->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/georeferencer/mActionLinkQGisToGeoref.png" ) ) );
connect( mActionLinkQGisToGeoref, &QAction::triggered, this, &QgsGeoreferencerMainWindow::linkQGisToGeoref );
connect( mActionLinkQGisToGeoref, &QAction::toggled, this, &QgsGeoreferencerMainWindow::linkQGisToGeoref );

// Settings actions
mActionRasterProperties->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionRasterProperties.png" ) ) );
Expand Down

0 comments on commit b20a05a

Please sign in to comment.