Skip to content

Commit

Permalink
Added OTFP to the clipboard contents (if OTFP is on). Fixes #1701
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@11409 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Aug 17, 2009
1 parent f2320de commit e4f05aa
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -4437,6 +4437,7 @@ void QgisApp::editCut( QgsMapLayer * layerContainingSelection )
{
QgsFeatureList features = selectionVectorLayer->selectedFeatures();
clipboard()->replaceWithCopyOf( selectionVectorLayer->dataProvider()->fields(), features );
clipboard()->setCRS( selectionVectorLayer->srs() );
selectionVectorLayer->beginEditCommand( tr( "Features cut" ) );
selectionVectorLayer->deleteSelectedFeatures();
selectionVectorLayer->endEditCommand();
Expand Down Expand Up @@ -4465,6 +4466,7 @@ void QgisApp::editCopy( QgsMapLayer * layerContainingSelection )
{
QgsFeatureList features = selectionVectorLayer->selectedFeatures();
clipboard()->replaceWithCopyOf( selectionVectorLayer->dataProvider()->fields(), features );
clipboard()->setCRS( selectionVectorLayer->srs() );
}
}
}
Expand All @@ -4489,7 +4491,14 @@ void QgisApp::editPaste( QgsMapLayer * destinationLayer )
if ( pasteVectorLayer != 0 )
{
pasteVectorLayer->beginEditCommand( tr( "Features pasted" ) );
pasteVectorLayer->addFeatures( clipboard()->copyOf() );
if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
pasteVectorLayer->addFeatures( clipboard()->transformedCopyOf( pasteVectorLayer->srs() ) );
}
else
{
pasteVectorLayer->addFeatures( clipboard()->copyOf() );
}
pasteVectorLayer->endEditCommand();
mMapCanvas->refresh();
}
Expand Down
26 changes: 26 additions & 0 deletions src/app/qgsclipboard.cpp
Expand Up @@ -28,6 +28,7 @@
#include "qgsfeature.h"
#include "qgsfield.h"
#include "qgsgeometry.h"
#include "qgscoordinatereferencesystem.h"
#include "qgslogger.h"
#include "qgslogger.h"

Expand Down Expand Up @@ -139,3 +140,28 @@ bool QgsClipboard::empty()
{
return mFeatureClipboard.empty();
}

QgsFeatureList QgsClipboard::transformedCopyOf(QgsCoordinateReferenceSystem destCRS)
{

QgsFeatureList featureList = copyOf();
QgsCoordinateTransform ct( crs(), destCRS );

QgsDebugMsg( "transforming clipboard." );
for ( QgsFeatureList::iterator iter = featureList.begin(); iter != featureList.end(); ++iter )
{
iter->geometry()->transform(ct);
}

return featureList;
}

void QgsClipboard::setCRS( QgsCoordinateReferenceSystem crs )
{
mCRS = crs;
}

QgsCoordinateReferenceSystem QgsClipboard::crs()
{
return mCRS;
}
25 changes: 24 additions & 1 deletion src/app/qgsclipboard.h
Expand Up @@ -25,6 +25,7 @@

#include "qgsfield.h"
#include "qgsfeature.h"
#include "qgscoordinatereferencesystem.h"


/**
Expand Down Expand Up @@ -68,7 +69,7 @@ class QgsClipboard

/*
* Returns a copy of features on the internal clipboard,
* the caller assumes responsibility fot destroying the contents
* the caller assumes responsibility for destroying the contents
* when it's done with it.
*/
QgsFeatureList copyOf();
Expand All @@ -89,6 +90,25 @@ class QgsClipboard
*/
bool empty();

/*
* Returns a copy of features on the internal clipboard, transformed
* from the clipboard CRS to the destCRS.
* The caller assumes responsibility for destroying the contents
* when it's done with it.
*/
QgsFeatureList transformedCopyOf( QgsCoordinateReferenceSystem destCRS );

/*
* Set the clipboard CRS
*/
void setCRS( QgsCoordinateReferenceSystem crs );


/*
* Get the clipboard CRS
*/
QgsCoordinateReferenceSystem crs();

private:

/** QGIS-internal vector feature clipboard.
Expand All @@ -97,6 +117,9 @@ class QgsClipboard
*/
QgsFeatureList mFeatureClipboard;

QgsCoordinateReferenceSystem mCRS;


};

#endif

0 comments on commit e4f05aa

Please sign in to comment.