Skip to content
Permalink
Browse files

Store relation between layer and coordinate transform in maprenderer …

…class
  • Loading branch information
mhugent committed Oct 17, 2013
1 parent 39fd5b8 commit ba524fc2686947aa3820b953dfeb5436231c3452
Showing with 62 additions and 1 deletion.
  1. +48 −0 src/core/qgsmaprenderer.cpp
  2. +14 −1 src/core/qgsmaprenderer.h
@@ -1101,6 +1101,31 @@ bool QgsMapRenderer::readXML( QDomNode & theNode )
aoi.setYMaximum( ymax );

setExtent( aoi );

mLayerCoordinateTransformInfo.clear();
QDomElement layerCoordTransformInfoElem = theNode.firstChildElement( "layer_coordinate_transform_info" );
if ( !layerCoordTransformInfoElem.isNull() )
{
QDomNodeList layerCoordinateTransformList = layerCoordTransformInfoElem.elementsByTagName( "layer_coordinate_transform" );
QDomElement layerCoordTransformElem;
for ( int i = 0; i < layerCoordinateTransformList.size(); ++i )
{
layerCoordTransformElem = layerCoordinateTransformList.at( i ).toElement();
QString layerId = layerCoordTransformElem.attribute( "layerid" );
if ( layerId.isEmpty() )
{
continue;
}

QgsLayerCoordinateTransform lct;
lct.srcAuthId = layerCoordTransformElem.attribute( "srcAuthId" );
lct.destAuthId = layerCoordTransformElem.attribute( "destAuthId" );
lct.srcDatumTransform = layerCoordTransformElem.attribute( "srcDatumTransform", "-1" ).toInt();
lct.destDatumTransform = layerCoordTransformElem.attribute( "destDatumTransform", "-1" ).toInt();
mLayerCoordinateTransformInfo.insert( layerId, lct );
}
}

return true;
}

@@ -1170,6 +1195,20 @@ bool QgsMapRenderer::writeXML( QDomNode & theNode, QDomDocument & theDoc )
theNode.appendChild( srsNode );
destinationCrs().writeXML( srsNode, theDoc );

// layer coordinate transform infos
QDomElement layerCoordTransformInfo = theDoc.createElement( "layer_coordinate_transform_info" );
QHash< QString, QgsLayerCoordinateTransform >::const_iterator coordIt = mLayerCoordinateTransformInfo.constBegin();
for ( ; coordIt != mLayerCoordinateTransformInfo.constEnd(); ++coordIt )
{
QDomElement layerCoordTransformElem = theDoc.createElement( "layer_coordinate_transform" );
layerCoordTransformElem.setAttribute( "layerid", coordIt.key() );
layerCoordTransformElem.setAttribute( "srcAuthId", coordIt->srcAuthId );
layerCoordTransformElem.setAttribute( "destAuthId", coordIt->destAuthId );
layerCoordTransformElem.setAttribute( "srcDatumTransform", QString::number( coordIt->srcDatumTransform ) );
layerCoordTransformElem.setAttribute( "destDatumTransform", QString::number( coordIt->destDatumTransform ) );
layerCoordTransformInfo.appendChild( layerCoordTransformElem );
}
theNode.appendChild( layerCoordTransformInfo );
return true;
}

@@ -1264,4 +1303,13 @@ QgsMapRenderer::BlendMode QgsMapRenderer::getBlendModeEnum( const QPainter::Comp
}
}

const QgsCoordinateTransform* QgsMapRenderer::coordinateTransformFromCache( const QString& layerId )
{
//todo: lookup in mLayerCoordinateTransformInfo
//not present? Emit signal
//still not present? get coordinate transformation with -1/-1 datum transform

return 0;
}

bool QgsMapRenderer::mDrawing = false;
@@ -110,7 +110,13 @@ class CORE_EXPORT QgsLabelingEngineInterface
virtual QgsLabelingEngineInterface* clone() = 0;
};


struct CORE_EXPORT QgsLayerCoordinateTransform
{
QString srcAuthId;
QString destAuthId;
int srcDatumTransform; //-1 if unknown or not specified
int destDatumTransform;
};

/** \ingroup core
* A non GUI class for rendering a map layer set onto a QPainter.
@@ -289,6 +295,8 @@ class CORE_EXPORT QgsMapRenderer : public QObject
//! Added in 1.9
static QgsMapRenderer::BlendMode getBlendModeEnum( const QPainter::CompositionMode blendMode );

const QgsCoordinateTransform* coordinateTransformFromCache( const QString& layerId );

signals:

void drawingProgress( int current, int total );
@@ -304,6 +312,9 @@ class CORE_EXPORT QgsMapRenderer : public QObject
//! emitted when layer's draw() returned false
void drawError( QgsMapLayer* );

//! Notifies higher level components to show the datum transform dialog and add a QgsLayerCoordinateTransformInfo for that layer
void datumTransformInfoRequested( QgsMapLayer* ml, const QString& srcAuthId, const QString& destAuthId );

public slots:

//! called by signal from layer current being drawn
@@ -376,6 +387,8 @@ class CORE_EXPORT QgsMapRenderer : public QObject
//! Locks rendering loop for concurrent draws
QMutex mRenderMutex;

QHash< QString, QgsLayerCoordinateTransform > mLayerCoordinateTransformInfo;

private:
const QgsCoordinateTransform* tr( QgsMapLayer *layer );
};

0 comments on commit ba524fc

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