[QGIS Commit] r10738 - in trunk/qgis/src: core plugins/diagram_overlay

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue May 5 07:15:38 EDT 2009


Author: mhugent
Date: 2009-05-05 07:15:38 -0400 (Tue, 05 May 2009)
New Revision: 10738

Modified:
   trunk/qgis/src/core/qgsgeometry.cpp
   trunk/qgis/src/core/qgsgeometry.h
   trunk/qgis/src/core/qgsoverlayobject.h
   trunk/qgis/src/core/qgspalobjectpositionmanager.cpp
   trunk/qgis/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
Log:
Make pal diagrams work if on-the-fly reprojection is enabled. Added two consts in geometry methods

Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp	2009-05-05 11:08:21 UTC (rev 10737)
+++ trunk/qgis/src/core/qgsgeometry.cpp	2009-05-05 11:15:38 UTC (rev 10738)
@@ -3021,7 +3021,7 @@
   return 0;
 }
 
-int QgsGeometry::transform( QgsCoordinateTransform& ct )
+int QgsGeometry::transform( const QgsCoordinateTransform& ct )
 {
   if ( mDirtyWkb )
   {
@@ -4734,7 +4734,7 @@
   }
 }
 
-void QgsGeometry::transformVertex( int& wkbPosition, QgsCoordinateTransform& ct, bool hasZValue )
+void QgsGeometry::transformVertex( int& wkbPosition, const QgsCoordinateTransform& ct, bool hasZValue )
 {
   double x, y, z;
 

Modified: trunk/qgis/src/core/qgsgeometry.h
===================================================================
--- trunk/qgis/src/core/qgsgeometry.h	2009-05-05 11:08:21 UTC (rev 10737)
+++ trunk/qgis/src/core/qgsgeometry.h	2009-05-05 11:15:38 UTC (rev 10738)
@@ -238,7 +238,7 @@
 
     /**Transform this geometry as described by CoordinateTranasform ct
      @return 0 in case of success*/
-    int transform( QgsCoordinateTransform& ct );
+    int transform( const QgsCoordinateTransform& ct );
 
     /**Splits this geometry according to a given line. Note that the geometry is only splitted once. If there are several intersections
      between geometry and splitLine, only the first one is considered.
@@ -423,7 +423,7 @@
     @param wkbPosition position in wkb array. Is increased automatically by the function
     @param ct the QgsCoordinateTransform
     @param hasZValue 25D type?*/
-    void transformVertex( int& wkbPosition, QgsCoordinateTransform& ct, bool hasZValue );
+    void transformVertex( int& wkbPosition, const QgsCoordinateTransform& ct, bool hasZValue );
 
     //helper functions for geometry splitting
 

Modified: trunk/qgis/src/core/qgsoverlayobject.h
===================================================================
--- trunk/qgis/src/core/qgsoverlayobject.h	2009-05-05 11:08:21 UTC (rev 10737)
+++ trunk/qgis/src/core/qgsoverlayobject.h	2009-05-05 11:15:38 UTC (rev 10738)
@@ -41,7 +41,7 @@
 
 
     /**Returns the feature geometry in geos format. The calling function does _not_ take
-     ownership of the generated object*/
+     ownership of the generated object. The geometry is in map coordinates*/
     GEOSGeometry* getGeosGeometry();
     /**Feature geometry is released when object is destructed so this function is empty*/
     void releaseGeosGeometry( GEOSGeometry *the_geom ) {}
@@ -78,7 +78,7 @@
     /**Rotation of the object*/
     double mRotation;
     /**Copy of the feature geometry. A copy is necessary because in QGIS geometries are deleted
-    after drawing*/
+    after drawing. The geometry is in map coordinates*/
     QgsGeometry* mGeometry;
 
 };

Modified: trunk/qgis/src/core/qgspalobjectpositionmanager.cpp
===================================================================
--- trunk/qgis/src/core/qgspalobjectpositionmanager.cpp	2009-05-05 11:08:21 UTC (rev 10737)
+++ trunk/qgis/src/core/qgspalobjectpositionmanager.cpp	2009-05-05 11:15:38 UTC (rev 10738)
@@ -95,9 +95,15 @@
 {
   //trigger label placement
   QgsRectangle viewExtent = renderContext.extent();
+  //PAL needs projected view extent
+  if(renderContext.coordinateTransform())
+  {
+    viewExtent = renderContext.coordinateTransform()->transformBoundingBox(viewExtent);
+  }
   double bbox[4]; bbox[0] = viewExtent.xMinimum(); bbox[1] = viewExtent.yMinimum(); bbox[2] = viewExtent.xMaximum(); bbox[3] = viewExtent.yMaximum();
+
+
   pal::PalStat* stat = 0;
-
   //set map units
   pal::Units mapUnits;
   switch ( unitType )

Modified: trunk/qgis/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
===================================================================
--- trunk/qgis/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp	2009-05-05 11:08:21 UTC (rev 10737)
+++ trunk/qgis/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp	2009-05-05 11:15:38 UTC (rev 10738)
@@ -79,6 +79,8 @@
       theProvider->select( mAttributes, renderContext.extent() );
 
       QgsFeature currentFeature;
+      QgsGeometry* currentGeometry = 0;
+
       int width, height;
 
       std::list<unsigned char*> wkbBuffers;
@@ -95,7 +97,13 @@
           //error
         }
 
-        mOverlayObjects.insert( currentFeature.id(), new QgsOverlayObject( width, height, 0, currentFeature.geometryAndOwnership() ) );
+        currentGeometry = currentFeature.geometryAndOwnership();
+        //overlay objects needs the geometry in map coordinates
+        if(currentGeometry && renderContext.coordinateTransform())
+        {
+          currentGeometry->transform(*(renderContext.coordinateTransform()));
+        }
+        mOverlayObjects.insert( currentFeature.id(), new QgsOverlayObject( width, height, 0, currentGeometry ) );
       }
     }
   }
@@ -142,10 +150,6 @@
             for(; positionIt != positionList.constEnd(); ++positionIt)
             {
                 QgsPoint overlayPosition = *positionIt;
-                if ( ct )
-                {
-                    overlayPosition = ct->transform(overlayPosition);
-                }
                 context.mapToPixel().transform( &overlayPosition );
                 int shiftX = currentDiagramImage->width() / 2;
                 int shiftY = currentDiagramImage->height() / 2;



More information about the QGIS-commit mailing list