Skip to content
Permalink
Browse files

[FEATURE] Assign layer CRS to project (legend context menu)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15424 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty
borysiasty committed Mar 10, 2011
1 parent 4bd9f3a commit b46a5757a2fe0bc416065a0299621139593a678e
Showing with 39 additions and 2 deletions.
  1. +4 −1 src/app/legend/qgslegendlayer.cpp
  2. +26 −1 src/app/qgisapp.cpp
  3. +3 −0 src/app/qgisapp.h
  4. +6 −0 src/ui/qgisapp.ui
@@ -431,8 +431,11 @@ void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
// remove from canvas
theMenu.addAction( QgisApp::getThemeIcon( "/mActionRemoveLayer.png" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) );

// remove from canvas
// set layer crs
theMenu.addAction( QgisApp::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) );

// assign layer crs to project
theMenu.addAction( QgisApp::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Assign layer CRS to &project" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) );

theMenu.addSeparator();

@@ -792,6 +792,7 @@ void QgisApp::createActions()
connect( mActionLayerSelectionSaveAs, SIGNAL( triggered() ), this, SLOT( saveSelectionAsVectorFile() ) );
connect( mActionRemoveLayer, SIGNAL( triggered() ), this, SLOT( removeLayer() ) );
connect( mActionSetLayerCRS, SIGNAL( triggered() ), this, SLOT( setLayerCRS() ) );
connect( mActionSetProjectCRSFromLayer, SIGNAL( triggered() ), this, SLOT( setProjectCRSFromLayer() ) );
connect( mActionTileScale, SIGNAL( triggered() ), this, SLOT( showTileScale() ) );
connect( mActionGpsTool, SIGNAL( triggered() ), this, SLOT( showGpsTool() ) );
connect( mActionLayerProperties, SIGNAL( triggered() ), this, SLOT( layerProperties() ) );
@@ -1339,6 +1340,7 @@ void QgisApp::setTheme( QString theThemeName )
#endif
mActionRemoveLayer->setIcon( getThemeIcon( "/mActionRemoveLayer.png" ) );
mActionSetLayerCRS->setIcon( getThemeIcon( "/mActionSetLayerCRS.png" ) );
mActionSetProjectCRSFromLayer->setIcon( getThemeIcon( "/mActionSetProjectCRSFromLayer.png" ) );
mActionNewVectorLayer->setIcon( getThemeIcon( "/mActionNewVectorLayer.png" ) );
mActionAddAllToOverview->setIcon( getThemeIcon( "/mActionAddAllToOverview.png" ) );
mActionHideAllLayers->setIcon( getThemeIcon( "/mActionHideAllLayers.png" ) );
@@ -4492,7 +4494,7 @@ void QgisApp::setLayerCRS()
return;
}

if ( !mMapLegend )
if ( !( mMapLegend && mMapLegend->currentLayer() ) )
{
return;
}
@@ -4513,6 +4515,28 @@ void QgisApp::setLayerCRS()
delete mySelector;
}

void QgisApp::setProjectCRSFromLayer()
{
if ( mMapCanvas && mMapCanvas->isDrawing() )
{
return;
}

if ( !( mMapLegend && mMapLegend->currentLayer() ) )
{
return;
}

QgsCoordinateReferenceSystem crs = mMapLegend->currentLayer()->crs();
QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
myRenderer->setDestinationSrs( crs );
if ( crs.mapUnits() != QGis::UnknownUnit )
{
myRenderer->setMapUnits( crs.mapUnits() );
}
mMapCanvas->refresh();
}

void QgisApp::showGpsTool()
{
if ( !mpGpsWidget )
@@ -5567,6 +5591,7 @@ void QgisApp::legendLayerSelectionChanged( void )
{
mActionRemoveLayer->setEnabled( mMapLegend && mMapLegend->selectedLayers().size() > 0 );
mActionSetLayerCRS->setEnabled( mMapLegend && mMapLegend->selectedLayers().size() > 0 );
mActionSetProjectCRSFromLayer->setEnabled( mMapLegend && mMapLegend->selectedLayers().size() == 1 );
}

void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
@@ -276,6 +276,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionLayerSelectionSaveAs() { return mActionLayerSelectionSaveAs; }
QAction *actionRemoveLayer() { return mActionRemoveLayer; }
QAction *actionSetLayerCRS() { return mActionSetLayerCRS; }
QAction *actionSetProjectCRSFromLayer() { return mActionSetProjectCRSFromLayer; }
QAction *actionTileScale() { return mActionTileScale; }
QAction *actionGpsTool() { return mActionGpsTool; }
QAction *actionLayerProperties() { return mActionLayerProperties; }
@@ -482,6 +483,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void removeLayer();
//! Set CRS of a layer
void setLayerCRS();
//! Assign layer CRS to project
void setProjectCRSFromLayer();
//! Show GPS tool
void showGpsTool();
//! Show tile scale slider
@@ -147,6 +147,7 @@
<addaction name="mActionLayerSelectionSaveAs"/>
<addaction name="mActionRemoveLayer"/>
<addaction name="mActionSetLayerCRS"/>
<addaction name="mActionSetProjectCRSFromLayer"/>
<addaction name="mActionLayerProperties"/>
<addaction name="mActionLayerSubsetString"/>
<addaction name="mActionLabeling"/>
@@ -1198,6 +1199,11 @@
<string>Ctrl+Shift+C</string>
</property>
</action>
<action name="mActionSetProjectCRSFromLayer">
<property name="text">
<string>Assign layer CRS to project</string>
</property>
</action>
<action name="mActionTileScale">
<property name="text">
<string>Tile scale slider</string>

0 comments on commit b46a575

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