Skip to content

Commit

Permalink
Server: set selection color prior to each render
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Feb 24, 2012
1 parent 67d432c commit d24c53c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/mapserver/qgsconfigparser.cpp
Expand Up @@ -33,6 +33,7 @@ QgsConfigParser::QgsConfigParser()
, mOutputUnits( QgsMapRenderer::Millimeters )
{
setDefaultLegendSettings();
mSelectionColor = QColor( 255, 255, 0 ); //yellow opaque is default selection color
}

QgsConfigParser::~QgsConfigParser()
Expand Down
6 changes: 6 additions & 0 deletions src/mapserver/qgsconfigparser.h
Expand Up @@ -19,6 +19,7 @@
#define QGSCONFIGPARSER_H

#include "qgsmaprenderer.h"
#include <QColor>
#include <QDomDocument>
#include <QFont>
#include <QList>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgsprojectparser.cpp
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/mapserver/qgsprojectparser.h
Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/mapserver/qgswmsserver.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit d24c53c

Please sign in to comment.