[QGIS Commit] r10260 - in branches/vector_overlay_branch: python/gui src/core src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Mar 3 16:27:27 EST 2009


Author: mhugent
Date: 2009-03-03 16:27:27 -0500 (Tue, 03 Mar 2009)
New Revision: 10260

Added:
   branches/vector_overlay_branch/python/gui/qgsmapcanvassnapper.sip
Modified:
   branches/vector_overlay_branch/src/core/qgssnapper.cpp
   branches/vector_overlay_branch/src/core/qgssnapper.h
   branches/vector_overlay_branch/src/gui/qgsmapcanvassnapper.cpp
Log:
Merged revisions 9656 to 9657 and 9670 to 9671 from trunk to fix compile errors with snapper bindings. Still some merges to be done for plugin installer

Copied: branches/vector_overlay_branch/python/gui/qgsmapcanvassnapper.sip (from rev 9657, trunk/qgis/python/gui/qgsmapcanvassnapper.sip)
===================================================================
--- branches/vector_overlay_branch/python/gui/qgsmapcanvassnapper.sip	                        (rev 0)
+++ branches/vector_overlay_branch/python/gui/qgsmapcanvassnapper.sip	2009-03-03 21:27:27 UTC (rev 10260)
@@ -0,0 +1,45 @@
+
+/** \ingroup gui
+ * This class reads the snapping properties from the current project and
+ * configures a QgsSnapper to perform the snapping.
+ * Snapping can be done to the active layer  (usefull for selecting a vertex to
+ * manipulate) or to background layers
+ */
+class QgsMapCanvasSnapper
+{
+%TypeHeaderCode
+#include <qgsmapcanvassnapper.h>
+%End
+  public:
+    /**Constructor
+     @param canvas the map canvas to snap to*/
+    QgsMapCanvasSnapper( QgsMapCanvas* canvas );
+
+    QgsMapCanvasSnapper();
+
+    ~QgsMapCanvasSnapper();
+
+    /**Does a snap to the current layer. Uses snap mode
+       QgsSnapper::SnapWithResultsForSamePosition if topological editing is enabled
+       and QgsSnapper::SnapWithOneResult_BY_SEGMENT if not. As this method is usually used to
+       find vertices/segments for editing operations, it uses the search radius for vertex
+       editing from the qgis options.
+       @param p start point of the snap (in pixel coordinates)
+       @param results list to which the results are appended
+       @param snap_to snap to vertex or to segment
+       @param snappingTol snapping tolerance. -1 means that the search radius for vertex edits is taken
+       @param excludePoints a list with (map coordinate) points that should be excluded in the snapping result. Useful e.g. for vertex moves where a vertex should not be snapped to its original position*/
+    int snapToCurrentLayer( const QPoint& p, QList<QgsSnappingResult>& results /Out/, QgsSnapper::SnappingType snap_to, double snappingTol = -1, const QList<QgsPoint>& excludePoints = QList<QgsPoint>() );
+    /**Snaps to the background layers. This method is usefull to align the features of the
+       edited layers to those of other layers (as described in the project properties).
+       Uses snap mode QgsSnapper::SnapWithOneResult. Therefore, only the
+       closest result is returned.
+       @param p start point of the snap (in pixel coordinates)
+       @param result snapped point
+       @param excludePoints a list with (map coordinate) points that should be excluded in the snapping result. Useful e.g. for vertex moves where a vertex should not be snapped to its original position
+       @return 0 in case of success*/
+    int snapToBackgroundLayers( const QPoint& p, QList<QgsSnappingResult>& results /Out/, const QList<QgsPoint>& excludePoints = QList<QgsPoint>() );
+
+    void setMapCanvas( QgsMapCanvas* canvas );
+
+};

Modified: branches/vector_overlay_branch/src/core/qgssnapper.cpp
===================================================================
--- branches/vector_overlay_branch/src/core/qgssnapper.cpp	2009-03-03 16:02:21 UTC (rev 10259)
+++ branches/vector_overlay_branch/src/core/qgssnapper.cpp	2009-03-03 21:27:27 UTC (rev 10260)
@@ -52,12 +52,12 @@
   QgsSnappingResult newResult;
 
   QList<QgsSnapper::SnapLayer>::iterator snapLayerIt;
-  for ( snapLayerIt = mSnapLayers.begin(); snapLayerIt != mSnapLayers.end(); ++snapLayerIt )
+  for (snapLayerIt = mSnapLayers.begin(); snapLayerIt != mSnapLayers.end(); ++snapLayerIt )
   {
     //transform point from map coordinates to layer coordinates
     layerCoordPoint = mMapRenderer->mapToLayerCoordinates( snapLayerIt->mLayer, mapCoordPoint );
     if ( snapLayerIt->mLayer->snapWithContext( layerCoordPoint, snapLayerIt->mTolerance,
-         currentResultList, snapLayerIt->mSnapTo ) != 0 )
+                                               currentResultList, snapLayerIt->mSnapTo ) != 0 )
     {
       //error
     }

Modified: branches/vector_overlay_branch/src/core/qgssnapper.h
===================================================================
--- branches/vector_overlay_branch/src/core/qgssnapper.h	2009-03-03 16:02:21 UTC (rev 10259)
+++ branches/vector_overlay_branch/src/core/qgssnapper.h	2009-03-03 21:27:27 UTC (rev 10260)
@@ -87,7 +87,7 @@
       /**What snapping type to use (snap to segment or to vertex)*/
       QgsSnapper::SnappingType mSnapTo;
     };
-
+    
     QgsSnapper( QgsMapRenderer* mapRender );
     ~QgsSnapper();
     /**Does the snapping operation

Modified: branches/vector_overlay_branch/src/gui/qgsmapcanvassnapper.cpp
===================================================================
--- branches/vector_overlay_branch/src/gui/qgsmapcanvassnapper.cpp	2009-03-03 16:02:21 UTC (rev 10259)
+++ branches/vector_overlay_branch/src/gui/qgsmapcanvassnapper.cpp	2009-03-03 21:27:27 UTC (rev 10260)
@@ -243,8 +243,8 @@
 
       //default snapping tolerance
       snapLayer.mTolerance = settings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
-
-      snapLayers.append( snapLayer );
+    
+      snapLayers.append(snapLayer);
     }
 
     mSnapper->setSnapLayers( snapLayers );



More information about the QGIS-commit mailing list