Skip to content

Commit

Permalink
[composer] Don't show vector selections in composer map items (fix #7610
Browse files Browse the repository at this point in the history
)
  • Loading branch information
nyalldawson committed Jun 2, 2014
1 parent 1c0ccb7 commit aaa7003
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 2 deletions.
16 changes: 16 additions & 0 deletions python/core/qgsmapsettings.sip
Expand Up @@ -38,6 +38,22 @@ class QgsMapSettings

void setSelectionColor( const QColor& color );
QColor selectionColor() const;

/**Sets whether vector selections should be shown in the rendered map
* @param showSelection set to true if selections should be shown
* @see showSelection
* @see setSelectionColor
* @note Added in QGIS v2.4
*/
void setShowSelection( const bool showSelection );

/**Returns true if vector selections should be shown in the rendered map
* @returns true if selections should be shown
* @see setShowSelection
* @see selectionColor
* @note Added in QGIS v2.4
*/
bool showSelection() const;

enum Flag
{
Expand Down
16 changes: 16 additions & 0 deletions python/core/qgsrendercontext.sip
Expand Up @@ -49,6 +49,14 @@ class QgsRenderContext

//! Added in QGIS v2.0
QColor selectionColor() const;

/**Returns true if vector selections should be shown in the rendered map
* @returns true if selections should be shown
* @see setShowSelection
* @see selectionColor
* @note Added in QGIS v2.4
*/
bool showSelection() const;

//setters

Expand All @@ -68,6 +76,14 @@ class QgsRenderContext
void setLabelingEngine( QgsLabelingEngineInterface* iface );
//! Added in QGIS v2.0
void setSelectionColor( const QColor& color );

/**Sets whether vector selections should be shown in the rendered map
* @param showSelection set to true if selections should be shown
* @see showSelection
* @see setSelectionColor
* @note Added in QGIS v2.4
*/
void setShowSelection( const bool showSelection );

/**Returns true if the rendering optimization (geometry simplification) can be executed*/
bool useRenderingOptimization() const;
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -185,6 +185,7 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const
jobMapSettings.setOutputDpi( dpi );
jobMapSettings.setMapUnits( ms.mapUnits() );
jobMapSettings.setBackgroundColor( Qt::transparent );
jobMapSettings.setShowSelection( false );

//set layers to render
QStringList theLayerSet = layersToRender();
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsmapsettings.cpp
Expand Up @@ -24,6 +24,7 @@ QgsMapSettings::QgsMapSettings()
, mDestCRS( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId ) // WGS 84
, mBackgroundColor( Qt::white )
, mSelectionColor( Qt::yellow )
, mShowSelection( true )
, mFlags( Antialiasing | UseAdvancedEffects | DrawLabeling )
{
updateDerived();
Expand Down
18 changes: 18 additions & 0 deletions src/core/qgsmapsettings.h
Expand Up @@ -54,6 +54,22 @@ class CORE_EXPORT QgsMapSettings
void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
QColor selectionColor() const { return mSelectionColor; }

/**Sets whether vector selections should be shown in the rendered map
* @param showSelection set to true if selections should be shown
* @see showSelection
* @see setSelectionColor
* @note Added in QGIS v2.4
*/
void setShowSelection( const bool showSelection ) { mShowSelection = showSelection; }

/**Returns true if vector selections should be shown in the rendered map
* @returns true if selections should be shown
* @see setShowSelection
* @see selectionColor
* @note Added in QGIS v2.4
*/
bool showSelection() const { return mShowSelection; }

enum Flag
{
Antialiasing = 0x01,
Expand Down Expand Up @@ -146,6 +162,8 @@ class CORE_EXPORT QgsMapSettings

QColor mBackgroundColor;
QColor mSelectionColor;
/**Whether selection should be shown in the map*/
bool mShowSelection;

Flags mFlags;

Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsrendercontext.cpp
Expand Up @@ -31,6 +31,7 @@ QgsRenderContext::QgsRenderContext()
mRasterScaleFactor( 1.0 ),
mRendererScale( 1.0 ),
mLabelingEngine( NULL ),
mShowSelection( true ),
mUseRenderingOptimization( true )
{
mVectorSimplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
Expand All @@ -51,6 +52,7 @@ QgsRenderContext QgsRenderContext::fromMapSettings( const QgsMapSettings& mapSet
ctx.setUseRenderingOptimization( mapSettings.testFlag( QgsMapSettings::UseRenderingOptimization ) );
ctx.setCoordinateTransform( 0 );
ctx.setSelectionColor( mapSettings.selectionColor() );
ctx.setShowSelection( mapSettings.showSelection() );
ctx.setRasterScaleFactor( 1.0 );
ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
ctx.setRendererScale( mapSettings.scale() );
Expand Down
21 changes: 20 additions & 1 deletion src/core/qgsrendercontext.h
Expand Up @@ -82,6 +82,14 @@ class CORE_EXPORT QgsRenderContext
//! Added in QGIS v2.0
QColor selectionColor() const { return mSelectionColor; }

/**Returns true if vector selections should be shown in the rendered map
* @returns true if selections should be shown
* @see setShowSelection
* @see selectionColor
* @note Added in QGIS v2.4
*/
bool showSelection() const { return mShowSelection; }

//setters

/**Sets coordinate transformation. QgsRenderContext does not take ownership*/
Expand All @@ -101,6 +109,14 @@ class CORE_EXPORT QgsRenderContext
//! Added in QGIS v2.0
void setSelectionColor( const QColor& color ) { mSelectionColor = color; }

/**Sets whether vector selections should be shown in the rendered map
* @param showSelection set to true if selections should be shown
* @see showSelection
* @see setSelectionColor
* @note Added in QGIS v2.4
*/
void setShowSelection( const bool showSelection ) { mShowSelection = showSelection; }

/**Returns true if the rendering optimization (geometry simplification) can be executed*/
bool useRenderingOptimization() const { return mUseRenderingOptimization; }
void setUseRenderingOptimization( bool enabled ) { mUseRenderingOptimization = enabled; }
Expand Down Expand Up @@ -145,7 +161,10 @@ class CORE_EXPORT QgsRenderContext
/**Labeling engine (can be NULL)*/
QgsLabelingEngineInterface* mLabelingEngine;

/** Color used for features that are marked as selected */
/**Whether selection should be shown*/
bool mShowSelection;

/**Color used for features that are marked as selected */
QColor mSelectionColor;

/**True if the rendering optimization (geometry simplification) can be executed*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerrenderer.cpp
Expand Up @@ -231,7 +231,7 @@ void QgsVectorLayerRenderer::drawRendererV2( QgsFeatureIterator& fit )
break;
}

bool sel = mSelectedFeatureIds.contains( fet.id() );
bool sel = mContext.showSelection() && mSelectedFeatureIds.contains( fet.id() );
bool drawMarker = ( mDrawVertexMarkers && mContext.drawEditingInformation() && ( !mVertexMarkerOnlyForSelection || sel ) );

// render feature
Expand Down

0 comments on commit aaa7003

Please sign in to comment.