Skip to content
Permalink
Browse files

Merge pull request #6031 from elpaso/layouts-server

[layouts][server] Composition -> layout
  • Loading branch information
elpaso committed Jan 10, 2018
2 parents 880d853 + f61a5f2 commit 073275479bd7b39a7058ca49014d2fb2bc4ce6d7
Showing with 297 additions and 275 deletions.
  1. +0 −3 .ci/travis/linux/blacklist.txt
  2. +5 −0 python/core/layout/qgslayoutmanager.sip
  3. +1 −1 src/core/layout/qgscompositionconverter.cpp
  4. +13 −0 src/core/layout/qgslayoutmanager.cpp
  5. +6 −0 src/core/layout/qgslayoutmanager.h
  6. +40 −26 src/server/services/wms/qgswmsgetcapabilities.cpp
  7. +200 −230 src/server/services/wms/qgswmsrenderer.cpp
  8. +3 −3 src/server/services/wms/qgswmsrenderer.h
  9. +9 −1 tests/src/python/qgis_wrapped_server.py
  10. +16 −7 tests/src/python/test_qgsserver.py
  11. +2 −2 tests/src/python/test_qgsserver_wms_getprint.py
  12. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_Annotations/WMS_GetMap_Annotations.png
  13. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_Annotations/WMS_GetMap_Annotations_mask.png
  14. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_Mode_16bit/WMS_GetMap_Mode_16bit_mask.png
  15. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_Mode_1bit/WMS_GetMap_Mode_1bit.png
  16. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_Mode_1bit/WMS_GetMap_Mode_1bit_mask.png
  17. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_Mode_8bit/WMS_GetMap_Mode_8bit_mask.png
  18. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_StyleCustom/WMS_GetMap_StyleCustom.png
  19. BIN tests/testdata/control_images/qgis_server/WMS_GetMap_StyleCustom/WMS_GetMap_StyleCustom_mask.png
  20. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Basic/WMS_GetPrint_Basic.png
  21. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Grid/WMS_GetPrint_Grid.png
  22. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Highlight/WMS_GetPrint_Highlight.png
  23. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Highlight/WMS_GetPrint_Highlight_mask.png
  24. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_LabelRemoved/WMS_GetPrint_LabelRemoved.png
  25. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_LabelUpdated/WMS_GetPrint_LabelUpdated.png
  26. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Legend/WMS_GetPrint_Legend.png
  27. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Opacity/WMS_GetPrint_Opacity.png
  28. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Opacity/WMS_GetPrint_Opacity_mask.png
  29. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Rotation/WMS_GetPrint_Rotation.png
  30. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_SRS/WMS_GetPrint_SRS.png
  31. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Scale/WMS_GetPrint_Scale.png
  32. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_Selection/WMS_GetPrint_Selection.png
  33. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_StyleCustom/WMS_GetPrint_StyleCustom.png
  34. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_StyleCustom/WMS_GetPrint_StyleCustom_mask.png
  35. BIN tests/testdata/control_images/qgis_server/WMS_GetPrint_StyleDefault/WMS_GetPrint_StyleDefault.png
  36. +2 −2 tests/testdata/qgis_server/getprojectsettings.txt
@@ -38,6 +38,3 @@ PyQgsAuthManagerPKIPostgresTest
PyQgsAuthManagerPasswordPostgresTest
PyQgsAuthManagerOgrPostgresTest

# temporary disable for composition -> layout transition
PyQgsServerWMS
PyQgsServerWMSGetPrint
@@ -84,6 +84,11 @@ Removes and deletes all layouts from the manager.
Returns a list of all layouts contained in the manager.
%End

QList< QgsPrintLayout * > printLayouts() const;
%Docstring
Returns a list of all print layouts contained in the manager.
%End


QgsMasterLayoutInterface *layoutByName( const QString &name ) const;
%Docstring
@@ -782,7 +782,7 @@ bool QgsCompositionConverter::readMapXml( QgsLayoutItemMap *layoutItem, const QD
}
else
{
layoutItem->setKeepLayerSet( true );
layoutItem->setKeepLayerSet( false );
}

QString drawCanvasItemsFlag = itemElem.attribute( QStringLiteral( "drawCanvasItems" ), QStringLiteral( "true" ) );
@@ -140,6 +140,19 @@ QList<QgsMasterLayoutInterface *> QgsLayoutManager::layouts() const
return mLayouts;
}

QList<QgsPrintLayout *> QgsLayoutManager::printLayouts() const
{
QList<QgsPrintLayout *> result;
const QList<QgsMasterLayoutInterface *> _layouts( mLayouts );
for ( const auto &layout : _layouts )
{
QgsPrintLayout *_item( dynamic_cast<QgsPrintLayout *>( layout ) );
if ( _item )
result.push_back( _item );
}
return result;
}

QgsComposition *QgsLayoutManager::compositionByName( const QString &name ) const
{
Q_FOREACH ( QgsComposition *c, mCompositions )
@@ -23,6 +23,7 @@
#include <QObject>

class QgsProject;
class QgsPrintLayout;

/**
* \ingroup core
@@ -110,6 +111,11 @@ class CORE_EXPORT QgsLayoutManager : public QObject
*/
QList< QgsMasterLayoutInterface * > layouts() const;

/**
* Returns a list of all print layouts contained in the manager.
*/
QList< QgsPrintLayout * > printLayouts() const;

/**
* Returns the composition with a matching name, or nullptr if no matching compositions
* were found.
@@ -23,11 +23,12 @@
#include "qgsserverprojectutils.h"

#include "qgslayoutmanager.h"
#include "qgscomposition.h"
#include "qgscomposermap.h"
#include "qgscomposerlabel.h"
#include "qgscomposerhtml.h"
#include "qgscomposerframe.h"
#include "qgsprintlayout.h"
#include "qgslayoutitemmap.h"
#include "qgslayoutitemlabel.h"
#include "qgslayoutitemhtml.h"
#include "qgslayoutframe.h"
#include "qgslayoutpagecollection.h"

#include "qgslayertreenode.h"
#include "qgslayertreegroup.h"
@@ -624,48 +625,61 @@ namespace QgsWms

QDomElement getComposerTemplatesElement( QDomDocument &doc, const QgsProject *project )
{
QList<QgsComposition *> projectComposers = project->layoutManager()->compositions();
QList< QgsPrintLayout * > projectComposers = project->layoutManager()->printLayouts();
if ( projectComposers.size() == 0 )
return QDomElement();

QStringList restrictedComposers = QgsServerProjectUtils::wmsRestrictedComposers( *project );

QDomElement composerTemplatesElem = doc.createElement( QStringLiteral( "ComposerTemplates" ) );
QList<QgsComposition *>::const_iterator cIt = projectComposers.constBegin();
QList<QgsPrintLayout *>::const_iterator cIt = projectComposers.constBegin();
for ( ; cIt != projectComposers.constEnd(); ++cIt )
{
QgsComposition *composer = *cIt;
if ( restrictedComposers.contains( composer->name() ) )
QgsPrintLayout *layout = *cIt;
if ( restrictedComposers.contains( layout->name() ) )
continue;

// Check that we have at least one page
if ( layout->pageCollection()->pageCount() < 1 )
continue;

// Get width and height from first page of the collection
QgsLayoutSize layoutSize( layout->pageCollection()->page( 0 )->sizeWithUnits() );
QgsLayoutMeasurement width( layout->convertFromLayoutUnits( layoutSize.width(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
QgsLayoutMeasurement height( layout->convertFromLayoutUnits( layoutSize.height(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );

QDomElement composerTemplateElem = doc.createElement( QStringLiteral( "ComposerTemplate" ) );
composerTemplateElem.setAttribute( QStringLiteral( "name" ), composer->name() );
composerTemplateElem.setAttribute( QStringLiteral( "name" ), layout->name() );

//get paper width and hight in mm from composition
composerTemplateElem.setAttribute( QStringLiteral( "width" ), composer->paperWidth() );
composerTemplateElem.setAttribute( QStringLiteral( "height" ), composer->paperHeight() );
//get paper width and height in mm from composition
composerTemplateElem.setAttribute( QStringLiteral( "width" ), width.length() );
composerTemplateElem.setAttribute( QStringLiteral( "height" ), height.length() );

//add available composer maps and their size in mm
QList<const QgsComposerMap *> composerMapList = composer->composerMapItems();
QList<const QgsComposerMap *>::const_iterator cmIt = composerMapList.constBegin();
for ( ; cmIt != composerMapList.constEnd(); ++cmIt )
QList<QgsLayoutItemMap *> layoutMapList;
layout->layoutItems<QgsLayoutItemMap>( layoutMapList );
QList<QgsLayoutItemMap *>::const_iterator cmIt = layoutMapList.constBegin();
// Add map id
int mapId = 0;
for ( ; cmIt != layoutMapList.constEnd(); ++cmIt )
{
const QgsComposerMap *composerMap = *cmIt;
const QgsLayoutItemMap *composerMap = *cmIt;

QDomElement composerMapElem = doc.createElement( QStringLiteral( "ComposerMap" ) );
composerMapElem.setAttribute( QStringLiteral( "name" ), QStringLiteral( "map%1" ).arg( composerMap->id() ) );
composerMapElem.setAttribute( QStringLiteral( "name" ), QStringLiteral( "map%1" ).arg( mapId ) );
mapId++;
composerMapElem.setAttribute( QStringLiteral( "width" ), composerMap->rect().width() );
composerMapElem.setAttribute( QStringLiteral( "height" ), composerMap->rect().height() );
composerTemplateElem.appendChild( composerMapElem );
}

//add available composer labels
QList<QgsComposerLabel *> composerLabelList;
composer->composerItems( composerLabelList );
QList<QgsComposerLabel *>::const_iterator clIt = composerLabelList.constBegin();
QList<QgsLayoutItemLabel *> composerLabelList;
layout->layoutItems<QgsLayoutItemLabel>( composerLabelList );
QList<QgsLayoutItemLabel *>::const_iterator clIt = composerLabelList.constBegin();
for ( ; clIt != composerLabelList.constEnd(); ++clIt )
{
QgsComposerLabel *composerLabel = *clIt;
QgsLayoutItemLabel *composerLabel = *clIt;
QString id = composerLabel->id();
if ( id.isEmpty() )
continue;
@@ -676,12 +690,12 @@ namespace QgsWms
}

//add available composer HTML
QList<QgsComposerHtml *> composerHtmlList;
composer->composerItems( composerHtmlList );
QList<QgsComposerHtml *>::const_iterator chIt = composerHtmlList.constBegin();
QList<QgsLayoutItemHtml *> composerHtmlList;
layout->layoutObjects<QgsLayoutItemHtml>( composerHtmlList );
QList<QgsLayoutItemHtml *>::const_iterator chIt = composerHtmlList.constBegin();
for ( ; chIt != composerHtmlList.constEnd(); ++chIt )
{
QgsComposerHtml *composerHtml = *chIt;
QgsLayoutItemHtml *composerHtml = *chIt;
if ( composerHtml->frameCount() == 0 )
continue;

0 comments on commit 0732754

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