[QGIS Commit] r11409 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Aug 17 08:38:23 EDT 2009


Author: homann
Date: 2009-08-17 08:38:22 -0400 (Mon, 17 Aug 2009)
New Revision: 11409

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgsclipboard.cpp
   trunk/qgis/src/app/qgsclipboard.h
Log:
Added OTFP to the clipboard contents (if OTFP is on). Fixes #1701

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2009-08-17 11:54:13 UTC (rev 11408)
+++ trunk/qgis/src/app/qgisapp.cpp	2009-08-17 12:38:22 UTC (rev 11409)
@@ -4437,6 +4437,7 @@
     {
       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 @@
     {
       QgsFeatureList features = selectionVectorLayer->selectedFeatures();
       clipboard()->replaceWithCopyOf( selectionVectorLayer->dataProvider()->fields(), features );
+      clipboard()->setCRS( selectionVectorLayer->srs() );
     }
   }
 }
@@ -4489,7 +4491,14 @@
     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();
     }

Modified: trunk/qgis/src/app/qgsclipboard.cpp
===================================================================
--- trunk/qgis/src/app/qgsclipboard.cpp	2009-08-17 11:54:13 UTC (rev 11408)
+++ trunk/qgis/src/app/qgsclipboard.cpp	2009-08-17 12:38:22 UTC (rev 11409)
@@ -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 @@
 {
   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;
+}

Modified: trunk/qgis/src/app/qgsclipboard.h
===================================================================
--- trunk/qgis/src/app/qgsclipboard.h	2009-08-17 11:54:13 UTC (rev 11408)
+++ trunk/qgis/src/app/qgsclipboard.h	2009-08-17 12:38:22 UTC (rev 11409)
@@ -25,6 +25,7 @@
 
 #include "qgsfield.h"
 #include "qgsfeature.h"
+#include "qgscoordinatereferencesystem.h"
 
 
 /**
@@ -68,7 +69,7 @@
 
     /*
      *  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 @@
      */
     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 @@
      */
     QgsFeatureList mFeatureClipboard;
 
+    QgsCoordinateReferenceSystem mCRS;
+
+
 };
 
 #endif



More information about the QGIS-commit mailing list