Skip to content

Commit d24c53c

Browse files
committed
Server: set selection color prior to each render
1 parent 67d432c commit d24c53c

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

src/mapserver/qgsconfigparser.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ QgsConfigParser::QgsConfigParser()
3333
, mOutputUnits( QgsMapRenderer::Millimeters )
3434
{
3535
setDefaultLegendSettings();
36+
mSelectionColor = QColor( 255, 255, 0 ); //yellow opaque is default selection color
3637
}
3738

3839
QgsConfigParser::~QgsConfigParser()

src/mapserver/qgsconfigparser.h

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define QGSCONFIGPARSER_H
2020

2121
#include "qgsmaprenderer.h"
22+
#include <QColor>
2223
#include <QDomDocument>
2324
#include <QFont>
2425
#include <QList>
@@ -113,6 +114,9 @@ class QgsConfigParser
113114
/**Appends service metadata to the capabilities document*/
114115
virtual void serviceCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;
115116

117+
QColor selectionColor() const { return mSelectionColor; }
118+
void setSelectionColor( const QColor& c ) { mSelectionColor = c; }
119+
116120
protected:
117121
/**Parser to forward not resolved requests (e.g. SLD parser based on user request might have a fallback parser with admin configuration)*/
118122
QgsConfigParser* mFallbackParser;
@@ -150,6 +154,8 @@ class QgsConfigParser
150154
double mLegendSymbolWidth;
151155
double mLegendSymbolHeight;
152156

157+
QColor mSelectionColor;
158+
153159
/**Transforms layer extent to epsg 4326 and appends ExGeographicBoundingBox and BoundingBox elements to the layer element*/
154160
void appendLayerBoundingBoxes( QDomElement& layerElem, QDomDocument& doc, const QgsRectangle& layerExtent, const QgsCoordinateReferenceSystem& layerCRS ) const;
155161

src/mapserver/qgsprojectparser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ void QgsProjectParser::setSelectionColor()
14491449
}
14501450
}
14511451

1452-
QgsRenderer::setSelectionColor( QColor( red, green, blue, alpha ) );
1452+
mSelectionColor = QColor( red, green, blue, alpha );
14531453
}
14541454

14551455
const QgsCoordinateReferenceSystem& QgsProjectParser::projectCRS() const

src/mapserver/qgsprojectparser.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ class QgsProjectParser: public QgsConfigParser
154154
/**Converts a (possibly relative) path to absolute*/
155155
QString convertToAbsolutePath( const QString& file ) const;
156156

157-
/**Sets global selection color from the project or yellow if not defined in project*/
158-
void setSelectionColor();
159-
160157
/**Returns mapcanvas output CRS from project file*/
161158
const QgsCoordinateReferenceSystem& projectCRS() const;
162159

163160
/**Returns bbox of layer in project CRS (or empty rectangle in case of error)*/
164161
QgsRectangle layerBoundingBoxInProjectCRS( const QDomElement& layerElem ) const;
162+
163+
/**Reads selection color from project and sets it to QgsConfigParser::mSelectionColor*/
164+
void setSelectionColor();
165165
};
166166

167167
#endif // QGSPROJECTPARSER_H

src/mapserver/qgswmsserver.cpp

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

0 commit comments

Comments
 (0)