Skip to content
Permalink
Browse files

Make a correct copy of QgsCoordinateTransform for labeling (hope it f…

…ixes #9600)
  • Loading branch information
mhugent committed Feb 19, 2014
1 parent 42a4e75 commit 34f79cf1fff11bd3ac23548d0929a7e90e6d142d
Showing with 27 additions and 6 deletions.
  1. +9 −0 src/core/qgscoordinatetransform.cpp
  2. +2 −0 src/core/qgscoordinatetransform.h
  3. +16 −6 src/core/qgspallabeling.cpp
@@ -127,6 +127,15 @@ QgsCoordinateTransform::~QgsCoordinateTransform()
}
}

QgsCoordinateTransform* QgsCoordinateTransform::clone() const
{
QgsCoordinateTransform* tr = new QgsCoordinateTransform( sourceCrs(), destCRS() );
tr->setSourceDatumTransform( sourceDatumTransform() );
tr->setDestinationDatumTransform( destinationDatumTransform() );
tr->initialise();
return tr;
}

void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem& theCRS )
{
mSourceCRS = theCRS;
@@ -88,6 +88,8 @@ class CORE_EXPORT QgsCoordinateTransform : public QObject
//! destructor
~QgsCoordinateTransform();

QgsCoordinateTransform* clone() const;

//! Enum used to indicate the direction (forward or inverse) of the transform
enum TransformDirection
{
@@ -3297,10 +3297,15 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,
lyr.fieldIndex = fldIndex;

lyr.xform = mMapRenderer->coordinateTransform();
lyr.ct = 0;
if ( mMapRenderer->hasCrsTransformEnabled() )
lyr.ct = new QgsCoordinateTransform( layer->crs(), mMapRenderer->destinationCrs() );
else
lyr.ct = NULL;
{
const QgsCoordinateTransform* tr = mMapRenderer->transformation( layer );
if ( tr )
{
lyr.ct = tr->clone();
}
}
lyr.ptZero = lyr.xform->toMapCoordinates( 0, 0 );
lyr.ptOne = lyr.xform->toMapCoordinates( 1, 0 );

@@ -3318,10 +3323,15 @@ int QgsPalLabeling::addDiagramLayer( QgsVectorLayer* layer, QgsDiagramLayerSetti
l->setArrangementFlags( s->placementFlags );

s->palLayer = l;
s->ct = 0;
if ( mMapRenderer->hasCrsTransformEnabled() )
s->ct = new QgsCoordinateTransform( layer->crs(), mMapRenderer->destinationCrs() );
else
s->ct = NULL;
{
const QgsCoordinateTransform* tr = mMapRenderer->transformation( layer );
if ( tr )
{
s->ct = tr->clone();
}
}
s->xform = mMapRenderer->coordinateTransform();
mActiveDiagramLayers.insert( layer, *s );
return 1;

0 comments on commit 34f79cf

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