File tree 3 files changed +60
-2
lines changed
3 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -4437,6 +4437,7 @@ void QgisApp::editCut( QgsMapLayer * layerContainingSelection )
4437
4437
{
4438
4438
QgsFeatureList features = selectionVectorLayer->selectedFeatures ();
4439
4439
clipboard ()->replaceWithCopyOf ( selectionVectorLayer->dataProvider ()->fields (), features );
4440
+ clipboard ()->setCRS ( selectionVectorLayer->srs () );
4440
4441
selectionVectorLayer->beginEditCommand ( tr ( " Features cut" ) );
4441
4442
selectionVectorLayer->deleteSelectedFeatures ();
4442
4443
selectionVectorLayer->endEditCommand ();
@@ -4465,6 +4466,7 @@ void QgisApp::editCopy( QgsMapLayer * layerContainingSelection )
4465
4466
{
4466
4467
QgsFeatureList features = selectionVectorLayer->selectedFeatures ();
4467
4468
clipboard ()->replaceWithCopyOf ( selectionVectorLayer->dataProvider ()->fields (), features );
4469
+ clipboard ()->setCRS ( selectionVectorLayer->srs () );
4468
4470
}
4469
4471
}
4470
4472
}
@@ -4489,7 +4491,14 @@ void QgisApp::editPaste( QgsMapLayer * destinationLayer )
4489
4491
if ( pasteVectorLayer != 0 )
4490
4492
{
4491
4493
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
+ }
4493
4502
pasteVectorLayer->endEditCommand ();
4494
4503
mMapCanvas ->refresh ();
4495
4504
}
Original file line number Diff line number Diff line change 28
28
#include " qgsfeature.h"
29
29
#include " qgsfield.h"
30
30
#include " qgsgeometry.h"
31
+ #include " qgscoordinatereferencesystem.h"
31
32
#include " qgslogger.h"
32
33
#include " qgslogger.h"
33
34
@@ -139,3 +140,28 @@ bool QgsClipboard::empty()
139
140
{
140
141
return mFeatureClipboard .empty ();
141
142
}
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
+ }
Original file line number Diff line number Diff line change 25
25
26
26
#include " qgsfield.h"
27
27
#include " qgsfeature.h"
28
+ #include " qgscoordinatereferencesystem.h"
28
29
29
30
30
31
/* *
@@ -68,7 +69,7 @@ class QgsClipboard
68
69
69
70
/*
70
71
* 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
72
73
* when it's done with it.
73
74
*/
74
75
QgsFeatureList copyOf ();
@@ -89,6 +90,25 @@ class QgsClipboard
89
90
*/
90
91
bool empty ();
91
92
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
+
92
112
private:
93
113
94
114
/* * QGIS-internal vector feature clipboard.
@@ -97,6 +117,9 @@ class QgsClipboard
97
117
*/
98
118
QgsFeatureList mFeatureClipboard ;
99
119
120
+ QgsCoordinateReferenceSystem mCRS ;
121
+
122
+
100
123
};
101
124
102
125
#endif
You can’t perform that action at this time.
0 commit comments