[QGIS Commit] r9357 - in trunk/qgis/src: app/composer core/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Sep 19 06:02:39 EDT 2008
Author: mhugent
Date: 2008-09-19 06:02:39 -0400 (Fri, 19 Sep 2008)
New Revision: 9357
Modified:
trunk/qgis/src/app/composer/qgscomposer.cpp
trunk/qgis/src/app/composer/qgscomposer.h
trunk/qgis/src/core/composer/qgscomposermap.cpp
trunk/qgis/src/core/composer/qgscomposermap.h
Log:
Show a warning before printing WMS layers. Some WMS servers have a limit for WIDTH and HEIGHT parameters
Modified: trunk/qgis/src/app/composer/qgscomposer.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.cpp 2008-09-19 09:58:51 UTC (rev 9356)
+++ trunk/qgis/src/app/composer/qgscomposer.cpp 2008-09-19 10:02:39 UTC (rev 9357)
@@ -435,6 +435,11 @@
return;
}
+ if(containsWMSLayer())
+ {
+ showWMSPrintingWarning();
+ }
+
QPrinter printer;
//try to set most of the print dialog settings based on composer properties
@@ -487,6 +492,11 @@
void QgsComposer::on_mActionExportAsImage_activated( void )
{
+ if(containsWMSLayer())
+ {
+ showWMSPrintingWarning();
+ }
+
// Image size
int width = ( int )( mComposition->printoutResolution() * mComposition->paperWidth() / 25.4 );
int height = ( int )( mComposition-> printoutResolution() * mComposition->paperHeight() / 25.4 );
@@ -608,6 +618,11 @@
void QgsComposer::on_mActionExportAsSVG_activated( void )
{
+ if(containsWMSLayer())
+ {
+ showWMSPrintingWarning();
+ }
+
QString myQSettingsLabel = "/UI/displaySVGWarning";
QSettings myQSettings;
@@ -1080,3 +1095,43 @@
mActionSelectMoveItem->setChecked( true );
on_mActionSelectMoveItem_activated();
}
+
+bool QgsComposer::containsWMSLayer() const
+{
+ QMap<QgsComposerItem*, QWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
+ QgsComposerItem* currentItem = 0;
+ QgsComposerMap* currentMap = 0;
+
+ for(; item_it != mItemWidgetMap.constEnd(); ++item_it)
+ {
+ currentItem = item_it.key();
+ currentMap = dynamic_cast<QgsComposerMap*>(currentItem);
+ if(currentMap)
+ {
+ if(currentMap->containsWMSLayer())
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+void QgsComposer::showWMSPrintingWarning()
+{
+ QString myQSettingsLabel = "/UI/displayComposerWMSWarning";
+ QSettings myQSettings;
+
+ bool displayWMSWarning = myQSettings.value( myQSettingsLabel, true ).toBool();
+ if(displayWMSWarning)
+ {
+ QgsMessageViewer* m = new QgsMessageViewer( this );
+ m->setWindowTitle( tr( "Project contains WMS layers" ) );
+ m->setMessage(tr("Some WMS servers (e.g. UMN mapserver) have a limit for the WIDTH and HEIGHT parameter. Printing layers from such servers may exceed this limit. If this is the case, the WMS layer will not be printed"), QgsMessageOutput::MessageText);
+ m->setCheckBoxText( tr( "Don't show this message again" ) );
+ m->setCheckBoxState( Qt::Unchecked );
+ m->setCheckBoxVisible( true );
+ m->setCheckBoxQSettingsLabel( myQSettingsLabel );
+ m->exec();
+ }
+}
Modified: trunk/qgis/src/app/composer/qgscomposer.h
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.h 2008-09-19 09:58:51 UTC (rev 9356)
+++ trunk/qgis/src/app/composer/qgscomposer.h 2008-09-19 10:02:39 UTC (rev 9357)
@@ -204,6 +204,12 @@
//! returns new world matrix for canvas view after zoom with factor scaleChange
QMatrix updateMatrix( double scaleChange );
+ //! True if a composer map contains a WMS layer
+ bool containsWMSLayer() const;
+
+ //! Displays a warning because of possible min/max size in WMS
+ void showWMSPrintingWarning();
+
//! Pointer to composer view
QgsComposerView *mView;
Modified: trunk/qgis/src/core/composer/qgscomposermap.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposermap.cpp 2008-09-19 09:58:51 UTC (rev 9356)
+++ trunk/qgis/src/core/composer/qgscomposermap.cpp 2008-09-19 10:02:39 UTC (rev 9357)
@@ -25,6 +25,7 @@
#include "qgsmaptopixel.h"
#include "qgsproject.h"
#include "qgsmaprenderer.h"
+#include "qgsrasterlayer.h"
#include "qgsrendercontext.h"
#include "qgsscalecalculator.h"
#include "qgsvectorlayer.h"
@@ -402,6 +403,40 @@
mYOffset = yOffset;
}
+bool QgsComposerMap::containsWMSLayer() const
+{
+ if(!mMapRenderer)
+ {
+ return false;
+ }
+
+ QStringList layers = mMapRenderer->layerSet();
+
+ QStringList::const_iterator layer_it = layers.constBegin();
+ QgsMapLayer* currentLayer = 0;
+
+ for(; layer_it != layers.constEnd(); ++layer_it)
+ {
+ currentLayer = QgsMapLayerRegistry::instance()->mapLayer(*layer_it);
+ if(currentLayer)
+ {
+ QgsRasterLayer* currentRasterLayer = dynamic_cast<QgsRasterLayer*>(currentLayer);
+ if(currentRasterLayer)
+ {
+ const QgsRasterDataProvider* rasterProvider = 0;
+ if(rasterProvider = currentRasterLayer->dataProvider())
+ {
+ if(rasterProvider->name() == "wms")
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
double QgsComposerMap::horizontalViewScaleFactor() const
{
double result = 1;
Modified: trunk/qgis/src/core/composer/qgscomposermap.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposermap.h 2008-09-19 09:58:51 UTC (rev 9356)
+++ trunk/qgis/src/core/composer/qgscomposermap.h 2008-09-19 10:02:39 UTC (rev 9357)
@@ -118,6 +118,9 @@
/**Sets offset values to shift image (useful for live updates when moving item content)*/
void setOffset( double xOffset, double yOffset );
+ /**True if composer map renders a WMS layer*/
+ bool containsWMSLayer() const;
+
/** stores state in Dom node
* @param elem is Dom element corresponding to 'Composer' tag
* @param temp write template file
More information about the QGIS-commit
mailing list