Skip to content

Commit 2779129

Browse files
author
homann
committed
Added OTFP to the clipboard contents (if OTFP is on). Fixes #1701
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11409 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent c2e5f4c commit 2779129

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

src/app/qgisapp.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -4437,6 +4437,7 @@ void QgisApp::editCut( QgsMapLayer * layerContainingSelection )
44374437
{
44384438
QgsFeatureList features = selectionVectorLayer->selectedFeatures();
44394439
clipboard()->replaceWithCopyOf( selectionVectorLayer->dataProvider()->fields(), features );
4440+
clipboard()->setCRS( selectionVectorLayer->srs() );
44404441
selectionVectorLayer->beginEditCommand( tr( "Features cut" ) );
44414442
selectionVectorLayer->deleteSelectedFeatures();
44424443
selectionVectorLayer->endEditCommand();
@@ -4465,6 +4466,7 @@ void QgisApp::editCopy( QgsMapLayer * layerContainingSelection )
44654466
{
44664467
QgsFeatureList features = selectionVectorLayer->selectedFeatures();
44674468
clipboard()->replaceWithCopyOf( selectionVectorLayer->dataProvider()->fields(), features );
4469+
clipboard()->setCRS( selectionVectorLayer->srs() );
44684470
}
44694471
}
44704472
}
@@ -4489,7 +4491,14 @@ void QgisApp::editPaste( QgsMapLayer * destinationLayer )
44894491
if ( pasteVectorLayer != 0 )
44904492
{
44914493
pasteVectorLayer->beginEditCommand( tr( "Features pasted" ) );
4492-
pasteVectorLayer->addFeatures( clipboard()->copyOf() );
4494+
if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
4495+
{
4496+
pasteVectorLayer->addFeatures( clipboard()->transformedCopyOf( pasteVectorLayer->srs() ) );
4497+
}
4498+
else
4499+
{
4500+
pasteVectorLayer->addFeatures( clipboard()->copyOf() );
4501+
}
44934502
pasteVectorLayer->endEditCommand();
44944503
mMapCanvas->refresh();
44954504
}

src/app/qgsclipboard.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "qgsfeature.h"
2929
#include "qgsfield.h"
3030
#include "qgsgeometry.h"
31+
#include "qgscoordinatereferencesystem.h"
3132
#include "qgslogger.h"
3233
#include "qgslogger.h"
3334

@@ -139,3 +140,28 @@ bool QgsClipboard::empty()
139140
{
140141
return mFeatureClipboard.empty();
141142
}
143+
144+
QgsFeatureList QgsClipboard::transformedCopyOf(QgsCoordinateReferenceSystem destCRS)
145+
{
146+
147+
QgsFeatureList featureList = copyOf();
148+
QgsCoordinateTransform ct( crs(), destCRS );
149+
150+
QgsDebugMsg( "transforming clipboard." );
151+
for ( QgsFeatureList::iterator iter = featureList.begin(); iter != featureList.end(); ++iter )
152+
{
153+
iter->geometry()->transform(ct);
154+
}
155+
156+
return featureList;
157+
}
158+
159+
void QgsClipboard::setCRS( QgsCoordinateReferenceSystem crs )
160+
{
161+
mCRS = crs;
162+
}
163+
164+
QgsCoordinateReferenceSystem QgsClipboard::crs()
165+
{
166+
return mCRS;
167+
}

src/app/qgsclipboard.h

+24-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "qgsfield.h"
2727
#include "qgsfeature.h"
28+
#include "qgscoordinatereferencesystem.h"
2829

2930

3031
/**
@@ -68,7 +69,7 @@ class QgsClipboard
6869

6970
/*
7071
* Returns a copy of features on the internal clipboard,
71-
* the caller assumes responsibility fot destroying the contents
72+
* the caller assumes responsibility for destroying the contents
7273
* when it's done with it.
7374
*/
7475
QgsFeatureList copyOf();
@@ -89,6 +90,25 @@ class QgsClipboard
8990
*/
9091
bool empty();
9192

93+
/*
94+
* Returns a copy of features on the internal clipboard, transformed
95+
* from the clipboard CRS to the destCRS.
96+
* The caller assumes responsibility for destroying the contents
97+
* when it's done with it.
98+
*/
99+
QgsFeatureList transformedCopyOf( QgsCoordinateReferenceSystem destCRS );
100+
101+
/*
102+
* Set the clipboard CRS
103+
*/
104+
void setCRS( QgsCoordinateReferenceSystem crs );
105+
106+
107+
/*
108+
* Get the clipboard CRS
109+
*/
110+
QgsCoordinateReferenceSystem crs();
111+
92112
private:
93113

94114
/** QGIS-internal vector feature clipboard.
@@ -97,6 +117,9 @@ class QgsClipboard
97117
*/
98118
QgsFeatureList mFeatureClipboard;
99119

120+
QgsCoordinateReferenceSystem mCRS;
121+
122+
100123
};
101124

102125
#endif

0 commit comments

Comments
 (0)