Skip to content

Commit

Permalink
Make pal diagrams work if on-the-fly reprojection is enabled. Added t…
Browse files Browse the repository at this point in the history
…wo consts in geometry methods

git-svn-id: http://svn.osgeo.org/qgis/trunk@10738 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 5, 2009
1 parent 17e7861 commit ceb305c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/core/qgsgeometry.cpp
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsgeometry.h
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsoverlayobject.h
Expand Up @@ -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 ) {}
Expand Down Expand Up @@ -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;

};
Expand Down
8 changes: 7 additions & 1 deletion src/core/qgspalobjectpositionmanager.cpp
Expand Up @@ -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 )
Expand Down
14 changes: 9 additions & 5 deletions src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
Expand Up @@ -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;
Expand All @@ -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 ) );
}
}
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ceb305c

Please sign in to comment.