Skip to content
Permalink
Browse files

Don't needed anymore

Without this the marker symbol is centered on the symbol place.
  • Loading branch information
Stéphane Brunner
Stéphane Brunner committed Oct 19, 2013
1 parent b1c26bf commit 593026fbde106d7bf79d3033f326c02872cfb6f2
Showing with 11 additions and 21 deletions.
  1. +8 −18 src/mapserver/qgswmsserver.cpp
  2. +3 −3 src/mapserver/qgswmsserver.h
@@ -404,7 +404,7 @@ QImage* QgsWMSServer::getLegendGraphics()
switch ( type )
{
case QgsComposerLegendItem::SymbologyV2Item:
drawLegendSymbolV2( currentComposerItem, &p, 0., 0., symbolWidth, symbolHeight, theImage->dotsPerMeterX() * 0.0254, 0. );
drawLegendSymbolV2( currentComposerItem, &p, 0., 0., symbolWidth, symbolHeight, 0. );
break;
case QgsComposerLegendItem::RasterSymbolItem:
drawRasterSymbol( currentComposerItem, &p, 0., 0., symbolWidth, symbolHeight, 0. );
@@ -428,7 +428,7 @@ QImage* QgsWMSServer::getLegendGraphics()

double currentY = drawLegendGraphics( 0, fontOversamplingFactor, rootItem, boxSpace, layerSpace, layerTitleSpace, symbolSpace,
iconLabelSpace, symbolWidth, symbolHeight, layerFont, itemFont, layerFontColor, itemFontColor, maxTextWidth,
maxSymbolWidth, theImage->dotsPerMeterX() * 0.0254 );
maxSymbolWidth );

//create second image with the right dimensions
QImage* paintImage = createImage( maxTextWidth + maxSymbolWidth, ceil( currentY ) );
@@ -439,7 +439,7 @@ QImage* QgsWMSServer::getLegendGraphics()

drawLegendGraphics( &p, fontOversamplingFactor, rootItem, boxSpace, layerSpace, layerTitleSpace, symbolSpace,
iconLabelSpace, symbolWidth, symbolHeight, layerFont, itemFont, layerFontColor, itemFontColor, maxTextWidth,
maxSymbolWidth, theImage->dotsPerMeterX() * 0.0254 );
maxSymbolWidth );

QgsMapLayerRegistry::instance()->removeAllMapLayers();
delete theImage;
@@ -449,7 +449,7 @@ QImage* QgsWMSServer::getLegendGraphics()
double QgsWMSServer::drawLegendGraphics( QPainter* p, double fontOversamplingFactor, QStandardItem* rootItem, double boxSpace,
double layerSpace, double layerTitleSpace, double symbolSpace, double iconLabelSpace,
double symbolWidth, double symbolHeight, const QFont& layerFont, const QFont& itemFont,
const QColor& layerFontColor, const QColor& itemFontColor, double& maxTextWidth, double& maxSymbolWidth, double dpi )
const QColor& layerFontColor, const QColor& itemFontColor, double& maxTextWidth, double& maxSymbolWidth )
{
if ( !rootItem )
{
@@ -473,8 +473,7 @@ double QgsWMSServer::drawLegendGraphics( QPainter* p, double fontOversamplingFac
currentY += layerSpace;
}
drawLegendLayerItem( layerItem, p, maxTextWidth, maxSymbolWidth, currentY, layerFont, layerFontColor, itemFont, itemFontColor,
boxSpace, layerSpace, layerTitleSpace, symbolSpace, iconLabelSpace, symbolWidth, symbolHeight, fontOversamplingFactor,
dpi );
boxSpace, layerSpace, layerTitleSpace, symbolSpace, iconLabelSpace, symbolWidth, symbolHeight, fontOversamplingFactor );
}
}
currentY += boxSpace;
@@ -1681,8 +1680,7 @@ QStringList QgsWMSServer::layerSet( const QStringList &layersList,

void QgsWMSServer::drawLegendLayerItem( QgsComposerLayerItem* item, QPainter* p, double& maxTextWidth, double& maxSymbolWidth, double& currentY, const QFont& layerFont,
const QColor& layerFontColor, const QFont& itemFont, const QColor& itemFontColor, double boxSpace, double layerSpace,
double layerTitleSpace, double symbolSpace, double iconLabelSpace, double symbolWidth, double symbolHeight, double fontOversamplingFactor,
double dpi ) const
double layerTitleSpace, double symbolSpace, double iconLabelSpace, double symbolWidth, double symbolHeight, double fontOversamplingFactor ) const
{
Q_UNUSED( layerSpace );
if ( !item )
@@ -1743,7 +1741,7 @@ void QgsWMSServer::drawLegendLayerItem( QgsComposerLayerItem* item, QPainter* p,
switch ( type )
{
case QgsComposerLegendItem::SymbologyV2Item:
drawLegendSymbolV2( currentComposerItem, p, boxSpace, currentY, currentSymbolWidth, currentSymbolHeight, dpi, symbolDownShift );
drawLegendSymbolV2( currentComposerItem, p, boxSpace, currentY, currentSymbolWidth, currentSymbolHeight, symbolDownShift );
break;
case QgsComposerLegendItem::RasterSymbolItem:
drawRasterSymbol( currentComposerItem, p, boxSpace, currentY, currentSymbolWidth, currentSymbolHeight, symbolDownShift );
@@ -1796,7 +1794,7 @@ void QgsWMSServer::drawLegendLayerItem( QgsComposerLayerItem* item, QPainter* p,


void QgsWMSServer::drawLegendSymbolV2( QgsComposerLegendItem* item, QPainter* p, double boxSpace, double currentY, double& symbolWidth,
double& symbolHeight, double dpi, double yDownShift ) const
double& symbolHeight, double yDownShift ) const
{
QgsComposerSymbolV2Item* symbolItem = dynamic_cast< QgsComposerSymbolV2Item* >( item );
if ( !symbolItem )
@@ -1809,14 +1807,6 @@ void QgsWMSServer::drawLegendSymbolV2( QgsComposerLegendItem* item, QPainter* p,
return;
}

//markers might have a different size
QgsMarkerSymbolV2* markerSymbol = dynamic_cast< QgsMarkerSymbolV2* >( symbol );
if ( markerSymbol )
{
symbolWidth = markerSymbol->size() * dpi / 25.4;
symbolHeight = markerSymbol->size() * dpi / 25.4;
}

if ( p )
{
p->save();
@@ -149,7 +149,7 @@ class QgsWMSServer
double drawLegendGraphics( QPainter* p, double fontOversamplingFactor, QStandardItem* rootItem, double boxSpace, double layerSpace, double layerTitleSpace,
double symbolSpace, double iconLabelSpace, double symbolWidth, double symbolHeight,
const QFont& layerFont, const QFont& itemFont, const QColor& layerFontColor, const QColor& itemFontColor,
double& maxTextWidth, double& maxSymbolWidth, double dpi );
double& maxTextWidth, double& maxSymbolWidth );

//helper functions for GetLegendGraphics
/**Draws layer item and subitems
@@ -159,9 +159,9 @@ class QgsWMSServer
*/
void drawLegendLayerItem( QgsComposerLayerItem* item, QPainter* p, double& maxTextWidth, double& maxSymbolWidth, double& currentY, const QFont& layerFont,
const QColor& layerFontColor, const QFont& itemFont, const QColor& itemFontColor, double boxSpace, double layerSpace,
double layerTitleSpace, double symbolSpace, double iconLabelSpace, double symbolWidth, double symbolHeight, double fontOversamplingFactor, double dpi ) const;
double layerTitleSpace, double symbolSpace, double iconLabelSpace, double symbolWidth, double symbolHeight, double fontOversamplingFactor ) const;
/**Draws a symbol. Optionally, maxHeight is adapted (e.g. for large point markers) */
void drawLegendSymbolV2( QgsComposerLegendItem* item, QPainter* p, double boxSpace, double currentY, double& symbolWidth, double& symbolHeight, double dpi, double yDownShift ) const;
void drawLegendSymbolV2( QgsComposerLegendItem* item, QPainter* p, double boxSpace, double currentY, double& symbolWidth, double& symbolHeight, double yDownShift ) const;
void drawRasterSymbol( QgsComposerLegendItem* item, QPainter* p, double boxSpace, double currentY, double symbolWidth, double symbolHeight, double yDownShift ) const;

/**Read legend parameter from the request or from the first print composer in the project*/

0 comments on commit 593026f

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