Skip to content

Commit

Permalink
[Server] Reactivate the capability to print selection with Server 2.18
Browse files Browse the repository at this point in the history
The capability to print selection has been removed by the commit aaa7003 to
prevent accidental selections showing in exports from composer.

It is reactivated only for QGIS Server.

fixes #13459 QGIS Server WMS GetPrint request don't respect SELECTION parameter
  • Loading branch information
rldhont authored and nyalldawson committed Jun 6, 2018
1 parent 61262a2 commit 268b9ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/composer/qgscomposermap.cpp
Expand Up @@ -59,6 +59,7 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w
, mUpdatesEnabled( true )
, mMapCanvas( nullptr )
, mDrawCanvasItems( true )
, mDrawSelection( false )
, mAtlasDriven( false )
, mAtlasScalingMode( Auto )
, mAtlasMargin( 0.10 )
Expand Down Expand Up @@ -229,7 +230,7 @@ QgsMapSettings QgsComposerMap::mapSettings( const QgsRectangle& extent, QSizeF s
jobMapSettings.setDestinationCrs( ms.destinationCrs() );
jobMapSettings.setCrsTransformEnabled( ms.hasCrsTransformEnabled() );
jobMapSettings.setFlags( ms.flags() );
jobMapSettings.setFlag( QgsMapSettings::DrawSelection, false );
jobMapSettings.setFlag( QgsMapSettings::DrawSelection, mDrawSelection );
jobMapSettings.setFlag( QgsMapSettings::RenderPartialOutput, false );

if ( mComposition->plotStyle() == QgsComposition::Print ||
Expand Down
14 changes: 14 additions & 0 deletions src/core/composer/qgscomposermap.h
Expand Up @@ -639,6 +639,17 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
void setDrawCanvasItems( bool b ) { mDrawCanvasItems = b; }
bool drawCanvasItems() const { return mDrawCanvasItems; }

/** Set the flag to draw selection in map
* @note this function was added in version 2.18.21
* @note not available in Python bindings
*/
void setDrawSelection( bool b ) { mDrawSelection = b; }
/** Get the flag to draw selection in map
* @note this function was added in version 2.18.21
* @note not available in Python bindings
*/
bool drawSelection() const { return mDrawSelection; }

/** Returns the conversion factor map units -> mm*/
double mapUnitsToMM() const;

Expand Down Expand Up @@ -939,6 +950,9 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
/** True if annotation items, rubber band, etc. from the main canvas should be displayed*/
bool mDrawCanvasItems;

/** True if selection has to be drawn. For server only! */
bool mDrawSelection;

/** Adjusts an extent rectangle to match the provided item width and height, so that extent
* center of extent remains the same */
void adjustExtentToItemShape( double itemWidth, double itemHeight, QgsRectangle& extent ) const;
Expand Down
3 changes: 3 additions & 0 deletions src/server/qgswmsconfigparser.cpp
Expand Up @@ -279,6 +279,9 @@ QgsComposition* QgsWMSConfigParser::createPrintComposition( const QString& compo
}
}

// Draw Selection
currentMap->setDrawSelection( true );

//grid space x / y
currentMap->grid()->setIntervalX( parameterMap.value( mapId + ":GRID_INTERVAL_X" ).toDouble() );
currentMap->grid()->setIntervalY( parameterMap.value( mapId + ":GRID_INTERVAL_Y" ).toDouble() );
Expand Down

0 comments on commit 268b9ac

Please sign in to comment.