Skip to content
Permalink
Browse files

Added a resolution parameter in option->Canvas&Legend to instruct WMS…

… getLegendGraphic

to get WMS legend with a good resolution for printing.
Set value to 0 to get default pixmap resolution.

Drawback in case of big resolution of the legend, it becames too big to be
correctly shown as PopUp in the QgsLegend interface.

Developed with funding from Regione Toscana-SITA
  • Loading branch information
luipir committed Oct 18, 2013
1 parent 48002db commit 32da13b20c6a408a975d0e93415a73d20a3c4b59
Showing with 65 additions and 0 deletions.
  1. +4 −0 src/app/qgsoptions.cpp
  2. +18 −0 src/providers/wms/qgswmsprovider.cpp
  3. +43 −0 src/ui/qgsoptionsbase.ui
@@ -541,6 +541,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :

cmbLegendDoubleClickAction->setCurrentIndex( settings.value( "/qgis/legendDoubleClickAction", 0 ).toInt() );

// WMS getLegendGraphic setting
mLegendGraphicResolutionSpinBox->setValue( settings.value("/qgis/defaultLegendGraphicResolution", 0).toInt() );

//
// Raster properties
//
@@ -961,6 +964,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
settings.setValue( "/qgis/addOracleDC", cbxAddOracleDC->isChecked() );
settings.setValue( "/qgis/addNewLayersToCurrentGroup", cbxAddNewLayersToCurrentGroup->isChecked() );
settings.setValue( "/qgis/defaultLegendGraphicResolution", mLegendGraphicResolutionSpinBox->value() );
bool createRasterLegendIcons = settings.value( "/qgis/createRasterLegendIcons", false ).toBool();
settings.setValue( "/qgis/createRasterLegendIcons", cbxCreateRasterLegendIcons->isChecked() );
settings.setValue( "/qgis/copyGeometryAsWKT", cbxCopyWKTGeomFromTable->isChecked() );
@@ -4663,6 +4663,24 @@ QImage QgsWmsProvider::getLegendGraphic( double scale, bool forceRefresh )
setQueryItem( url, "SCALE", QString::number( scale, 'f') );
setQueryItem( url, "FORMAT", mImageMimeType );

// add config parameter related to resolution
QSettings s;
int defaultLegendGraphicResolution = s.value( "/qgis/defaultLegendGraphicResolution", 0 ).toInt();
QgsDebugMsg( QString( "defaultLegendGraphicResolution: %1" ).arg( defaultLegendGraphicResolution ) );
if ( defaultLegendGraphicResolution ) {
if (url.queryItemValue("map_resolution") != "")
{
setQueryItem( url, "map_resolution", QString::number(defaultLegendGraphicResolution) );
}
else if (url.queryItemValue("dpi") != "")
{
setQueryItem( url, "dpi", QString::number(defaultLegendGraphicResolution) );
}
else{
QgsLogger::warning(tr("getLegendGraphic: Can not determine resolution uri parameter [map_resolution | dpi]. No resolution parameter will be used"));
}
}

mError = "";

QNetworkRequest request( url );
@@ -2345,6 +2345,49 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_34">
<item>
<widget class="QLabel" name="label_58">
<property name="text">
<string>WMS getLegendGraphic Resolution</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_39">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="mLegendGraphicResolutionSpinBox">
<property name="toolTip">
<string extracomment="MAP_RESOLUTION or DPI value overloading getMap default value (set 0 to use default)"/>
</property>
<property name="whatsThis">
<string extracomment="MAP_RESOLUTION or DPI value overloading getMap default value (set 0 to use default)"/>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

0 comments on commit 32da13b

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