mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
Merge pull request #8320 from rldhont/server-reactivate-print-selection-3
[Server] Reactivate the capability to print selection with Server 3.4
This commit is contained in:
commit
6249b07f7c
@ -29,6 +29,7 @@ Stores information relating to the current rendering settings for a layout.
|
|||||||
FlagUseAdvancedEffects,
|
FlagUseAdvancedEffects,
|
||||||
FlagForceVectorOutput,
|
FlagForceVectorOutput,
|
||||||
FlagHideCoverageLayer,
|
FlagHideCoverageLayer,
|
||||||
|
FlagDrawSelection,
|
||||||
};
|
};
|
||||||
typedef QFlags<QgsLayoutRenderContext::Flag> Flags;
|
typedef QFlags<QgsLayoutRenderContext::Flag> Flags;
|
||||||
|
|
||||||
@ -103,6 +104,24 @@ Returns the ``dpi`` for outputting the layout.
|
|||||||
.. seealso:: :py:func:`setDpi`
|
.. seealso:: :py:func:`setDpi`
|
||||||
%End
|
%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();
|
QgsLayoutMeasurementConverter &measurementConverter();
|
||||||
%Docstring
|
%Docstring
|
||||||
|
@ -1104,7 +1104,8 @@ QgsMapSettings QgsLayoutItemMap::mapSettings( const QgsRectangle &extent, QSizeF
|
|||||||
jobMapSettings.setFlag( QgsMapSettings::ForceVectorOutput, true ); // force vector output (no caching of marker images etc.)
|
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::Antialiasing, mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagAntialiasing );
|
||||||
jobMapSettings.setFlag( QgsMapSettings::DrawEditingInfo, false );
|
jobMapSettings.setFlag( QgsMapSettings::DrawEditingInfo, false );
|
||||||
jobMapSettings.setFlag( QgsMapSettings::DrawSelection, 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.setFlag( QgsMapSettings::UseAdvancedEffects, mLayout->renderContext().flags() & QgsLayoutRenderContext::FlagUseAdvancedEffects );
|
||||||
jobMapSettings.setTransformContext( mLayout->project()->transformContext() );
|
jobMapSettings.setTransformContext( mLayout->project()->transformContext() );
|
||||||
jobMapSettings.setPathResolver( mLayout->project()->pathResolver() );
|
jobMapSettings.setPathResolver( mLayout->project()->pathResolver() );
|
||||||
|
@ -45,6 +45,7 @@ class CORE_EXPORT QgsLayoutRenderContext : public QObject
|
|||||||
FlagUseAdvancedEffects = 1 << 4, //!< Enable advanced effects such as blend modes.
|
FlagUseAdvancedEffects = 1 << 4, //!< Enable advanced effects such as blend modes.
|
||||||
FlagForceVectorOutput = 1 << 5, //!< Force output in vector format where possible, even if items require rasterization to keep their correct appearance.
|
FlagForceVectorOutput = 1 << 5, //!< Force output in vector format where possible, even if items require rasterization to keep their correct appearance.
|
||||||
FlagHideCoverageLayer = 1 << 6, //!< Hide coverage layer in outputs
|
FlagHideCoverageLayer = 1 << 6, //!< Hide coverage layer in outputs
|
||||||
|
FlagDrawSelection = 1 << 7, //!< Draw selection
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS( Flags, Flag )
|
Q_DECLARE_FLAGS( Flags, Flag )
|
||||||
|
|
||||||
@ -104,6 +105,20 @@ class CORE_EXPORT QgsLayoutRenderContext : public QObject
|
|||||||
*/
|
*/
|
||||||
double dpi() const;
|
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
|
* 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.
|
* for translating between other measurement units and the layout's native unit.
|
||||||
@ -206,6 +221,8 @@ class CORE_EXPORT QgsLayoutRenderContext : public QObject
|
|||||||
|
|
||||||
int mCurrentExportLayer = -1;
|
int mCurrentExportLayer = -1;
|
||||||
|
|
||||||
|
QColor mSelectionColor = Qt::yellow;
|
||||||
|
|
||||||
QgsLayoutMeasurementConverter mMeasurementConverter;
|
QgsLayoutMeasurementConverter mMeasurementConverter;
|
||||||
|
|
||||||
bool mIsPreviewRender = true;
|
bool mIsPreviewRender = true;
|
||||||
|
@ -66,7 +66,6 @@
|
|||||||
#include "qgslayerrestorer.h"
|
#include "qgslayerrestorer.h"
|
||||||
#include "qgsdxfexport.h"
|
#include "qgsdxfexport.h"
|
||||||
#include "qgssymbollayerutils.h"
|
#include "qgssymbollayerutils.h"
|
||||||
#include "qgslayoutitemlegend.h"
|
|
||||||
#include "qgsserverexception.h"
|
#include "qgsserverexception.h"
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
@ -80,6 +79,7 @@
|
|||||||
#include "qgslayoutmanager.h"
|
#include "qgslayoutmanager.h"
|
||||||
#include "qgslayoutexporter.h"
|
#include "qgslayoutexporter.h"
|
||||||
#include "qgslayoutsize.h"
|
#include "qgslayoutsize.h"
|
||||||
|
#include "qgslayoutrendercontext.h"
|
||||||
#include "qgslayoutmeasurement.h"
|
#include "qgslayoutmeasurement.h"
|
||||||
#include "qgsprintlayout.h"
|
#include "qgsprintlayout.h"
|
||||||
#include "qgslayoutpagecollection.h"
|
#include "qgslayoutpagecollection.h"
|
||||||
@ -396,6 +396,8 @@ namespace QgsWms
|
|||||||
if ( ok )
|
if ( ok )
|
||||||
exportSettings.dpi = dpi;
|
exportSettings.dpi = dpi;
|
||||||
}
|
}
|
||||||
|
// Draw selections
|
||||||
|
exportSettings.flags |= QgsLayoutRenderContext::FlagDrawSelection;
|
||||||
QgsLayoutExporter exporter( layout.get() );
|
QgsLayoutExporter exporter( layout.get() );
|
||||||
exporter.exportToSvg( tempOutputFile.fileName(), exportSettings );
|
exporter.exportToSvg( tempOutputFile.fileName(), exportSettings );
|
||||||
}
|
}
|
||||||
@ -413,6 +415,8 @@ namespace QgsWms
|
|||||||
dpi = _dpi;
|
dpi = _dpi;
|
||||||
}
|
}
|
||||||
exportSettings.dpi = dpi;
|
exportSettings.dpi = dpi;
|
||||||
|
// Draw selections
|
||||||
|
exportSettings.flags |= QgsLayoutRenderContext::FlagDrawSelection;
|
||||||
// Destination image size in px
|
// Destination image size in px
|
||||||
QgsLayoutSize layoutSize( layout->pageCollection()->page( 0 )->sizeWithUnits() );
|
QgsLayoutSize layoutSize( layout->pageCollection()->page( 0 )->sizeWithUnits() );
|
||||||
QgsLayoutMeasurement width( layout->convertFromLayoutUnits( layoutSize.width(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
|
QgsLayoutMeasurement width( layout->convertFromLayoutUnits( layoutSize.width(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
|
||||||
@ -435,6 +439,8 @@ namespace QgsWms
|
|||||||
if ( ok )
|
if ( ok )
|
||||||
exportSettings.dpi = dpi;
|
exportSettings.dpi = dpi;
|
||||||
}
|
}
|
||||||
|
// Draw selections
|
||||||
|
exportSettings.flags |= QgsLayoutRenderContext::FlagDrawSelection;
|
||||||
// Export all pages
|
// Export all pages
|
||||||
QgsLayoutExporter exporter( layout.get() );
|
QgsLayoutExporter exporter( layout.get() );
|
||||||
exporter.exportToPdf( tempOutputFile.fileName(), exportSettings );
|
exporter.exportToPdf( tempOutputFile.fileName(), exportSettings );
|
||||||
@ -450,7 +456,6 @@ namespace QgsWms
|
|||||||
|
|
||||||
bool QgsRenderer::configurePrintLayout( QgsPrintLayout *c, const QgsMapSettings &mapSettings )
|
bool QgsRenderer::configurePrintLayout( QgsPrintLayout *c, const QgsMapSettings &mapSettings )
|
||||||
{
|
{
|
||||||
|
|
||||||
// Maps are configured first
|
// Maps are configured first
|
||||||
QList<QgsLayoutItemMap *> maps;
|
QList<QgsLayoutItemMap *> maps;
|
||||||
c->layoutItems<QgsLayoutItemMap>( maps );
|
c->layoutItems<QgsLayoutItemMap>( maps );
|
||||||
@ -1141,6 +1146,13 @@ namespace QgsWms
|
|||||||
|
|
||||||
// enable rendering optimization
|
// enable rendering optimization
|
||||||
mapSettings.setFlag( QgsMapSettings::UseRenderingOptimization );
|
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,
|
QDomDocument QgsRenderer::featureInfoDocument( QList<QgsMapLayer *> &layers, const QgsMapSettings &mapSettings,
|
||||||
|
@ -286,6 +286,7 @@ class TestQgsServerWMSGetPrint(QgsServerTestBase):
|
|||||||
"REQUEST": "GetPrint",
|
"REQUEST": "GetPrint",
|
||||||
"TEMPLATE": "layoutA4",
|
"TEMPLATE": "layoutA4",
|
||||||
"FORMAT": "png",
|
"FORMAT": "png",
|
||||||
|
"LAYERS": "Country,Hello",
|
||||||
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031",
|
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031",
|
||||||
"map0:LAYERS": "Country,Hello",
|
"map0:LAYERS": "Country,Hello",
|
||||||
"CRS": "EPSG:3857",
|
"CRS": "EPSG:3857",
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 979 KiB After Width: | Height: | Size: 58 KiB |
Binary file not shown.
Before Width: | Height: | Size: 296 KiB After Width: | Height: | Size: 290 KiB |
Binary file not shown.
Before Width: | Height: | Size: 296 KiB After Width: | Height: | Size: 290 KiB |
Loading…
x
Reference in New Issue
Block a user