Skip to content
Permalink
Browse files

Make pal diagrams work if on-the-fly reprojection is enabled. Added t…

…wo consts in geometry methods

git-svn-id: http://svn.osgeo.org/qgis/trunk@10738 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed May 5, 2009
1 parent 17e7861 commit ceb305cee67f2ccb99b20c186c044168277af743
@@ -3021,7 +3021,7 @@ int QgsGeometry::translate( double dx, double dy )
return 0;
}

int QgsGeometry::transform( QgsCoordinateTransform& ct )
int QgsGeometry::transform( const QgsCoordinateTransform& ct )
{
if ( mDirtyWkb )
{
@@ -4734,7 +4734,7 @@ void QgsGeometry::translateVertex( int& wkbPosition, double dx, double dy, bool
}
}

void QgsGeometry::transformVertex( int& wkbPosition, QgsCoordinateTransform& ct, bool hasZValue )
void QgsGeometry::transformVertex( int& wkbPosition, const QgsCoordinateTransform& ct, bool hasZValue )
{
double x, y, z;

@@ -238,7 +238,7 @@ class CORE_EXPORT QgsGeometry

/**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 @@ class CORE_EXPORT QgsGeometry
@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

@@ -41,7 +41,7 @@ class CORE_EXPORT QgsOverlayObject: public pal::PalGeometry


/**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 @@ class CORE_EXPORT QgsOverlayObject: public pal::PalGeometry
/**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;

};
@@ -95,9 +95,15 @@ void QgsPALObjectPositionManager::findObjectPositions( const QgsRenderContext& r
{
//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;


pal::PalStat* stat = 0;
//set map units
pal::Units mapUnits;
switch ( unitType )
@@ -79,6 +79,8 @@ void QgsDiagramOverlay::createOverlayObjects( const QgsRenderContext& renderCont
theProvider->select( mAttributes, renderContext.extent() );

QgsFeature currentFeature;
QgsGeometry* currentGeometry = 0;

int width, height;

std::list<unsigned char*> wkbBuffers;
@@ -95,7 +97,13 @@ void QgsDiagramOverlay::createOverlayObjects( const QgsRenderContext& renderCont
//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 @@ void QgsDiagramOverlay::drawOverlayObjects( QgsRenderContext& context ) const
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;

0 comments on commit ceb305c

Please sign in to comment.
You can’t perform that action at this time.