Skip to content

Commit ceb305c

Browse files
author
mhugent
committed
Make pal diagrams work if on-the-fly reprojection is enabled. Added two consts in geometry methods
git-svn-id: http://svn.osgeo.org/qgis/trunk@10738 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 17e7861 commit ceb305c

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

src/core/qgsgeometry.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,7 @@ int QgsGeometry::translate( double dx, double dy )
30213021
return 0;
30223022
}
30233023

3024-
int QgsGeometry::transform( QgsCoordinateTransform& ct )
3024+
int QgsGeometry::transform( const QgsCoordinateTransform& ct )
30253025
{
30263026
if ( mDirtyWkb )
30273027
{
@@ -4734,7 +4734,7 @@ void QgsGeometry::translateVertex( int& wkbPosition, double dx, double dy, bool
47344734
}
47354735
}
47364736

4737-
void QgsGeometry::transformVertex( int& wkbPosition, QgsCoordinateTransform& ct, bool hasZValue )
4737+
void QgsGeometry::transformVertex( int& wkbPosition, const QgsCoordinateTransform& ct, bool hasZValue )
47384738
{
47394739
double x, y, z;
47404740

src/core/qgsgeometry.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class CORE_EXPORT QgsGeometry
238238

239239
/**Transform this geometry as described by CoordinateTranasform ct
240240
@return 0 in case of success*/
241-
int transform( QgsCoordinateTransform& ct );
241+
int transform( const QgsCoordinateTransform& ct );
242242

243243
/**Splits this geometry according to a given line. Note that the geometry is only splitted once. If there are several intersections
244244
between geometry and splitLine, only the first one is considered.
@@ -423,7 +423,7 @@ class CORE_EXPORT QgsGeometry
423423
@param wkbPosition position in wkb array. Is increased automatically by the function
424424
@param ct the QgsCoordinateTransform
425425
@param hasZValue 25D type?*/
426-
void transformVertex( int& wkbPosition, QgsCoordinateTransform& ct, bool hasZValue );
426+
void transformVertex( int& wkbPosition, const QgsCoordinateTransform& ct, bool hasZValue );
427427

428428
//helper functions for geometry splitting
429429

src/core/qgsoverlayobject.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CORE_EXPORT QgsOverlayObject: public pal::PalGeometry
4141

4242

4343
/**Returns the feature geometry in geos format. The calling function does _not_ take
44-
ownership of the generated object*/
44+
ownership of the generated object. The geometry is in map coordinates*/
4545
GEOSGeometry* getGeosGeometry();
4646
/**Feature geometry is released when object is destructed so this function is empty*/
4747
void releaseGeosGeometry( GEOSGeometry *the_geom ) {}
@@ -78,7 +78,7 @@ class CORE_EXPORT QgsOverlayObject: public pal::PalGeometry
7878
/**Rotation of the object*/
7979
double mRotation;
8080
/**Copy of the feature geometry. A copy is necessary because in QGIS geometries are deleted
81-
after drawing*/
81+
after drawing. The geometry is in map coordinates*/
8282
QgsGeometry* mGeometry;
8383

8484
};

src/core/qgspalobjectpositionmanager.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,15 @@ void QgsPALObjectPositionManager::findObjectPositions( const QgsRenderContext& r
9595
{
9696
//trigger label placement
9797
QgsRectangle viewExtent = renderContext.extent();
98+
//PAL needs projected view extent
99+
if(renderContext.coordinateTransform())
100+
{
101+
viewExtent = renderContext.coordinateTransform()->transformBoundingBox(viewExtent);
102+
}
98103
double bbox[4]; bbox[0] = viewExtent.xMinimum(); bbox[1] = viewExtent.yMinimum(); bbox[2] = viewExtent.xMaximum(); bbox[3] = viewExtent.yMaximum();
99-
pal::PalStat* stat = 0;
100104

105+
106+
pal::PalStat* stat = 0;
101107
//set map units
102108
pal::Units mapUnits;
103109
switch ( unitType )

src/plugins/diagram_overlay/qgsdiagramoverlay.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ void QgsDiagramOverlay::createOverlayObjects( const QgsRenderContext& renderCont
7979
theProvider->select( mAttributes, renderContext.extent() );
8080

8181
QgsFeature currentFeature;
82+
QgsGeometry* currentGeometry = 0;
83+
8284
int width, height;
8385

8486
std::list<unsigned char*> wkbBuffers;
@@ -95,7 +97,13 @@ void QgsDiagramOverlay::createOverlayObjects( const QgsRenderContext& renderCont
9597
//error
9698
}
9799

98-
mOverlayObjects.insert( currentFeature.id(), new QgsOverlayObject( width, height, 0, currentFeature.geometryAndOwnership() ) );
100+
currentGeometry = currentFeature.geometryAndOwnership();
101+
//overlay objects needs the geometry in map coordinates
102+
if(currentGeometry && renderContext.coordinateTransform())
103+
{
104+
currentGeometry->transform(*(renderContext.coordinateTransform()));
105+
}
106+
mOverlayObjects.insert( currentFeature.id(), new QgsOverlayObject( width, height, 0, currentGeometry ) );
99107
}
100108
}
101109
}
@@ -142,10 +150,6 @@ void QgsDiagramOverlay::drawOverlayObjects( QgsRenderContext& context ) const
142150
for(; positionIt != positionList.constEnd(); ++positionIt)
143151
{
144152
QgsPoint overlayPosition = *positionIt;
145-
if ( ct )
146-
{
147-
overlayPosition = ct->transform(overlayPosition);
148-
}
149153
context.mapToPixel().transform( &overlayPosition );
150154
int shiftX = currentDiagramImage->width() / 2;
151155
int shiftY = currentDiagramImage->height() / 2;

0 commit comments

Comments
 (0)