Skip to content
Permalink
Browse files

Add rotation widget to the georeferencer canvas

  • Loading branch information
uclaros authored and nyalldawson committed Oct 25, 2020
1 parent 1d9c0e7 commit fe2faaacf17b0f6cf2aaac1ef4e10cf3d5ef45f8
Showing with 35 additions and 0 deletions.
  1. +31 −0 src/app/georeferencer/qgsgeorefmainwindow.cpp
  2. +4 −0 src/app/georeferencer/qgsgeorefmainwindow.h
@@ -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 )
{
@@ -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" ) );
@@ -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()
@@ -1111,6 +1141,7 @@ void QgsGeoreferencerMainWindow::removeOldLayer()
}
mCanvas->setLayers( QList<QgsMapLayer *>() );
mCanvas->clearCache();
mRotationEdit->clear();
mCanvas->refresh();
}

@@ -28,6 +28,7 @@ class QPlainTextEdit;
class QLabel;

class QgisInterface;
class QgsDoubleSpinBox;
class QgsGeorefDataPoint;
class QgsGCPListWidget;
class QgsMapTool;
@@ -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 );
@@ -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;

0 comments on commit fe2faaa

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