Skip to content

Commit

Permalink
Add rotation widget to the georeferencer canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and nyalldawson committed Oct 25, 2020
1 parent 1d9c0e7 commit fe2faaa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/app/georeferencer/qgsgeorefmainwindow.cpp
Expand Up @@ -771,6 +771,13 @@ void QgsGeoreferencerMainWindow::extentsChangedQGisCanvas()
}
}

void QgsGeoreferencerMainWindow::updateCanvasRotation()
{
double degrees = mRotationEdit->value();
mCanvas->setRotation( degrees );
mCanvas->refresh();
}

// Canvas info slots (copy/pasted from QGIS :) )
void QgsGeoreferencerMainWindow::showMouseCoords( const QgsPointXY &p )
{
Expand Down Expand Up @@ -1069,6 +1076,26 @@ QLabel *QgsGeoreferencerMainWindow::createBaseLabelStatus()

void QgsGeoreferencerMainWindow::createStatusBar()
{
// add a widget to show/set current rotation
mRotationLabel = createBaseLabelStatus();
mRotationLabel->setObjectName( QStringLiteral( "mRotationLabel" ) );
mRotationLabel->setText( tr( "Rotation" ) );
mRotationLabel->setToolTip( tr( "Current clockwise map rotation in degrees" ) );
statusBar()->addPermanentWidget( mRotationLabel, 0 );

mRotationEdit = new QgsDoubleSpinBox( statusBar() );
mRotationEdit->setObjectName( QStringLiteral( "mRotationEdit" ) );
mRotationEdit->setClearValue( 0.0 );
mRotationEdit->setKeyboardTracking( false );
mRotationEdit->setMaximumWidth( 120 );
mRotationEdit->setDecimals( 1 );
mRotationEdit->setRange( -360.0, 360.0 );
mRotationEdit->setWrapping( true );
mRotationEdit->setSingleStep( 5.0 );
mRotationEdit->setSuffix( tr( " °" ) );
mRotationEdit->setToolTip( tr( "Current clockwise map rotation in degrees" ) );
statusBar()->addPermanentWidget( mRotationEdit, 0 );

mTransformParamLabel = createBaseLabelStatus();
mTransformParamLabel->setText( tr( "Transform: " ) + convertTransformEnumToString( mTransformParam ) );
mTransformParamLabel->setToolTip( tr( "Current transform parametrisation" ) );
Expand Down Expand Up @@ -1098,6 +1125,9 @@ void QgsGeoreferencerMainWindow::setupConnections()

// Connect extents changed - Use for need add again Raster
connect( mCanvas, &QgsMapCanvas::extentsChanged, this, &QgsGeoreferencerMainWindow::extentsChanged );

// Connect mapCanvas rotation widget
connect( mRotationEdit, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsGeoreferencerMainWindow::updateCanvasRotation );
}

void QgsGeoreferencerMainWindow::removeOldLayer()
Expand All @@ -1111,6 +1141,7 @@ void QgsGeoreferencerMainWindow::removeOldLayer()
}
mCanvas->setLayers( QList<QgsMapLayer *>() );
mCanvas->clearCache();
mRotationEdit->clear();
mCanvas->refresh();
}

Expand Down
4 changes: 4 additions & 0 deletions src/app/georeferencer/qgsgeorefmainwindow.h
Expand Up @@ -28,6 +28,7 @@ class QPlainTextEdit;
class QLabel;

class QgisInterface;
class QgsDoubleSpinBox;
class QgsGeorefDataPoint;
class QgsGCPListWidget;
class QgsMapTool;
Expand Down Expand Up @@ -105,6 +106,7 @@ class QgsGeoreferencerMainWindow : public QMainWindow, private Ui::QgsGeorefPlug
void jumpToGCP( uint theGCPIndex );
void extentsChangedGeorefCanvas();
void extentsChangedQGisCanvas();
void updateCanvasRotation();

// canvas info
void showMouseCoords( const QgsPointXY &pt );
Expand Down Expand Up @@ -211,6 +213,8 @@ class QgsGeoreferencerMainWindow : public QMainWindow, private Ui::QgsGeorefPlug
QLabel *mCoordsLabel = nullptr;
QLabel *mTransformParamLabel = nullptr;
QLabel *mEPSG = nullptr;
QLabel *mRotationLabel = nullptr;
QgsDoubleSpinBox *mRotationEdit = nullptr;
unsigned int mMousePrecisionDecimalPlaces;

QString mRasterFileName;
Expand Down

0 comments on commit fe2faaa

Please sign in to comment.