Skip to content
Permalink
Browse files

Added OTFP to the clipboard contents (if OTFP is on). Fixes #1701

git-svn-id: http://svn.osgeo.org/qgis/trunk@11409 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann
homann committed Aug 17, 2009
1 parent f2320de commit e4f05aa8b9301afbe2672072cf128f0c72c65bca
Showing with 60 additions and 2 deletions.
  1. +10 −1 src/app/qgisapp.cpp
  2. +26 −0 src/app/qgsclipboard.cpp
  3. +24 −1 src/app/qgsclipboard.h
@@ -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();
@@ -4465,6 +4466,7 @@ void QgisApp::editCopy( QgsMapLayer * layerContainingSelection )
{
QgsFeatureList features = selectionVectorLayer->selectedFeatures();
clipboard()->replaceWithCopyOf( selectionVectorLayer->dataProvider()->fields(), features );
clipboard()->setCRS( selectionVectorLayer->srs() );
}
}
}
@@ -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();
}
@@ -28,6 +28,7 @@
#include "qgsfeature.h"
#include "qgsfield.h"
#include "qgsgeometry.h"
#include "qgscoordinatereferencesystem.h"
#include "qgslogger.h"
#include "qgslogger.h"

@@ -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,6 +25,7 @@

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


/**
@@ -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();
@@ -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.
@@ -97,6 +117,9 @@ class QgsClipboard
*/
QgsFeatureList mFeatureClipboard;

QgsCoordinateReferenceSystem mCRS;


};

#endif

0 comments on commit e4f05aa

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