Server: set selection color prior to each render

This commit is contained in:
Marco Hugentobler 2012-02-24 17:17:56 +01:00
parent 67d432c7bd
commit d24c53c272
5 changed files with 14 additions and 4 deletions

View File

@ -33,6 +33,7 @@ QgsConfigParser::QgsConfigParser()
, mOutputUnits( QgsMapRenderer::Millimeters )
{
setDefaultLegendSettings();
mSelectionColor = QColor( 255, 255, 0 ); //yellow opaque is default selection color
}
QgsConfigParser::~QgsConfigParser()

View File

@ -19,6 +19,7 @@
#define QGSCONFIGPARSER_H
#include "qgsmaprenderer.h"
#include <QColor>
#include <QDomDocument>
#include <QFont>
#include <QList>
@ -113,6 +114,9 @@ class QgsConfigParser
/**Appends service metadata to the capabilities document*/
virtual void serviceCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;
QColor selectionColor() const { return mSelectionColor; }
void setSelectionColor( const QColor& c ) { mSelectionColor = c; }
protected:
/**Parser to forward not resolved requests (e.g. SLD parser based on user request might have a fallback parser with admin configuration)*/
QgsConfigParser* mFallbackParser;
@ -150,6 +154,8 @@ class QgsConfigParser
double mLegendSymbolWidth;
double mLegendSymbolHeight;
QColor mSelectionColor;
/**Transforms layer extent to epsg 4326 and appends ExGeographicBoundingBox and BoundingBox elements to the layer element*/
void appendLayerBoundingBoxes( QDomElement& layerElem, QDomDocument& doc, const QgsRectangle& layerExtent, const QgsCoordinateReferenceSystem& layerCRS ) const;

View File

@ -1449,7 +1449,7 @@ void QgsProjectParser::setSelectionColor()
}
}
QgsRenderer::setSelectionColor( QColor( red, green, blue, alpha ) );
mSelectionColor = QColor( red, green, blue, alpha );
}
const QgsCoordinateReferenceSystem& QgsProjectParser::projectCRS() const

View File

@ -154,14 +154,14 @@ class QgsProjectParser: public QgsConfigParser
/**Converts a (possibly relative) path to absolute*/
QString convertToAbsolutePath( const QString& file ) const;
/**Sets global selection color from the project or yellow if not defined in project*/
void setSelectionColor();
/**Returns mapcanvas output CRS from project file*/
const QgsCoordinateReferenceSystem& projectCRS() const;
/**Returns bbox of layer in project CRS (or empty rectangle in case of error)*/
QgsRectangle layerBoundingBoxInProjectCRS( const QDomElement& layerElem ) const;
/**Reads selection color from project and sets it to QgsConfigParser::mSelectionColor*/
void setSelectionColor();
};
#endif // QGSPROJECTPARSER_H

View File

@ -966,6 +966,9 @@ QImage* QgsWMSServer::initializeRendering( QStringList& layersList, QStringList&
QgsDebugMsg( QString( "Number of layers to be rendered. %1" ).arg( layerIdList.count() ) );
#endif
mMapRenderer->setLayerSet( layerIdList );
//set selection color prior to each render to avoid problems with caching (selection color is a global property of QgsRenderer)
QgsRenderer::setSelectionColor( mConfigParser->selectionColor() );
return theImage;
}