@@ -792,6 +792,7 @@ void QgisApp::createActions()
792
792
connect ( mActionLayerSelectionSaveAs , SIGNAL ( triggered () ), this , SLOT ( saveSelectionAsVectorFile () ) );
793
793
connect ( mActionRemoveLayer , SIGNAL ( triggered () ), this , SLOT ( removeLayer () ) );
794
794
connect ( mActionSetLayerCRS , SIGNAL ( triggered () ), this , SLOT ( setLayerCRS () ) );
795
+ connect ( mActionSetProjectCRSFromLayer , SIGNAL ( triggered () ), this , SLOT ( setProjectCRSFromLayer () ) );
795
796
connect ( mActionTileScale , SIGNAL ( triggered () ), this , SLOT ( showTileScale () ) );
796
797
connect ( mActionGpsTool , SIGNAL ( triggered () ), this , SLOT ( showGpsTool () ) );
797
798
connect ( mActionLayerProperties , SIGNAL ( triggered () ), this , SLOT ( layerProperties () ) );
@@ -1339,6 +1340,7 @@ void QgisApp::setTheme( QString theThemeName )
1339
1340
#endif
1340
1341
mActionRemoveLayer ->setIcon ( getThemeIcon ( " /mActionRemoveLayer.png" ) );
1341
1342
mActionSetLayerCRS ->setIcon ( getThemeIcon ( " /mActionSetLayerCRS.png" ) );
1343
+ mActionSetProjectCRSFromLayer ->setIcon ( getThemeIcon ( " /mActionSetProjectCRSFromLayer.png" ) );
1342
1344
mActionNewVectorLayer ->setIcon ( getThemeIcon ( " /mActionNewVectorLayer.png" ) );
1343
1345
mActionAddAllToOverview ->setIcon ( getThemeIcon ( " /mActionAddAllToOverview.png" ) );
1344
1346
mActionHideAllLayers ->setIcon ( getThemeIcon ( " /mActionHideAllLayers.png" ) );
@@ -4492,7 +4494,7 @@ void QgisApp::setLayerCRS()
4492
4494
return ;
4493
4495
}
4494
4496
4495
- if ( !mMapLegend )
4497
+ if ( !( mMapLegend && mMapLegend -> currentLayer () ) )
4496
4498
{
4497
4499
return ;
4498
4500
}
@@ -4513,6 +4515,28 @@ void QgisApp::setLayerCRS()
4513
4515
delete mySelector;
4514
4516
}
4515
4517
4518
+ void QgisApp::setProjectCRSFromLayer ()
4519
+ {
4520
+ if ( mMapCanvas && mMapCanvas ->isDrawing () )
4521
+ {
4522
+ return ;
4523
+ }
4524
+
4525
+ if ( !( mMapLegend && mMapLegend ->currentLayer () ) )
4526
+ {
4527
+ return ;
4528
+ }
4529
+
4530
+ QgsCoordinateReferenceSystem crs = mMapLegend ->currentLayer ()->crs ();
4531
+ QgsMapRenderer* myRenderer = mMapCanvas ->mapRenderer ();
4532
+ myRenderer->setDestinationSrs ( crs );
4533
+ if ( crs.mapUnits () != QGis::UnknownUnit )
4534
+ {
4535
+ myRenderer->setMapUnits ( crs.mapUnits () );
4536
+ }
4537
+ mMapCanvas ->refresh ();
4538
+ }
4539
+
4516
4540
void QgisApp::showGpsTool ()
4517
4541
{
4518
4542
if ( !mpGpsWidget )
@@ -5567,6 +5591,7 @@ void QgisApp::legendLayerSelectionChanged( void )
5567
5591
{
5568
5592
mActionRemoveLayer ->setEnabled ( mMapLegend && mMapLegend ->selectedLayers ().size () > 0 );
5569
5593
mActionSetLayerCRS ->setEnabled ( mMapLegend && mMapLegend ->selectedLayers ().size () > 0 );
5594
+ mActionSetProjectCRSFromLayer ->setEnabled ( mMapLegend && mMapLegend ->selectedLayers ().size () == 1 );
5570
5595
}
5571
5596
5572
5597
void QgisApp::activateDeactivateLayerRelatedActions ( QgsMapLayer* layer )
0 commit comments