Skip to content
Permalink
Browse files

[Server] Use Project selection color in GetPrint for 3.4

Because selection was deactivated in layout, selection color was not transmitted from QgsProject to QgsLayoutRenderContext to QgsMapSettings.

forward porting of #7294
  • Loading branch information
rldhont committed Oct 25, 2018
1 parent 74f2785 commit a9e6950eee661b38cdbccd15179113be86437e59
@@ -104,6 +104,24 @@ Returns the ``dpi`` for outputting the layout.
.. seealso:: :py:func:`setDpi`
%End

void setSelectionColor( const QColor &color );
%Docstring
Sets color that is used for drawing of selected vector features

.. seealso:: :py:func:`selectionColor`

.. versionadded:: 3.4
%End

QColor selectionColor() const;
%Docstring
Gets color that is used for drawing of selected vector features

.. seealso:: :py:func:`setSelectionColor`

.. versionadded:: 3.4
%End


QgsLayoutMeasurementConverter &measurementConverter();
%Docstring
@@ -1104,6 +1104,7 @@ QgsMapSettings QgsLayoutItemMap::mapSettings( const QgsRectangle &extent, QSizeF
jobMapSettings.setFlag( QgsMapSettings::ForceVectorOutput, true ); // force vector output (no caching of marker images etc.)
jobMapSettings.setFlag( QgsMapSettings::Antialiasing, mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagAntialiasing );
jobMapSettings.setFlag( QgsMapSettings::DrawEditingInfo, false );
jobMapSettings.setSelectionColor( mLayout->renderContext().selectionColor() );
jobMapSettings.setFlag( QgsMapSettings::DrawSelection, mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagDrawSelection );
jobMapSettings.setFlag( QgsMapSettings::UseAdvancedEffects, mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagUseAdvancedEffects );
jobMapSettings.setTransformContext( mLayout->project()->transformContext() );
@@ -105,6 +105,20 @@ class CORE_EXPORT QgsLayoutRenderContext : public QObject
*/
double dpi() const;

/**
* Sets color that is used for drawing of selected vector features
* \see selectionColor()
* \since QGIS 3.4
*/
void setSelectionColor( const QColor &color ) { mSelectionColor = color; }

/**
* Gets color that is used for drawing of selected vector features
* \see setSelectionColor()
* \since QGIS 3.4
*/
QColor selectionColor() const { return mSelectionColor; }

/**
* Returns the layout measurement converter to be used in the layout. This converter is used
* for translating between other measurement units and the layout's native unit.
@@ -207,6 +221,8 @@ class CORE_EXPORT QgsLayoutRenderContext : public QObject

int mCurrentExportLayer = -1;

QColor mSelectionColor = Qt::yellow;

QgsLayoutMeasurementConverter mMeasurementConverter;

bool mIsPreviewRender = true;
@@ -450,6 +450,7 @@ namespace QgsWms

bool QgsRenderer::configurePrintLayout( QgsPrintLayout *c, const QgsMapSettings &mapSettings )
{
c->renderContext().setSelectionColor( mapSettings.selectionColor() );
c->renderContext().setFlag( QgsLayoutRenderContext::FlagDrawSelection, true );
// Maps are configured first
QList<QgsLayoutItemMap *> maps;
@@ -1141,6 +1142,13 @@ namespace QgsWms

// enable rendering optimization
mapSettings.setFlag( QgsMapSettings::UseRenderingOptimization );

// set selection color
int myRed = mProject->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );
int myGreen = mProject->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 );
int myBlue = mProject->readNumEntry( "Gui", "/SelectionColorBluePart", 0 );
int myAlpha = mProject->readNumEntry( "Gui", "/SelectionColorAlphaPart", 255 );
mapSettings.setSelectionColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
}

QDomDocument QgsRenderer::featureInfoDocument( QList<QgsMapLayer *> &layers, const QgsMapSettings &mapSettings,

0 comments on commit a9e6950

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