Skip to content

Commit

Permalink
Add QgsLayout subclass, QgsPrintLayout
Browse files Browse the repository at this point in the history
A print layout is a layout with an atlas
  • Loading branch information
nyalldawson committed Jan 5, 2018
1 parent bd7784c commit e6a6db8
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 3 deletions.
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -437,6 +437,7 @@
%Include layout/qgslayouttable.sip
%Include layout/qgslayouttablecolumn.sip
%Include layout/qgslayoutundostack.sip
%Include layout/qgsprintlayout.sip
%Include symbology/qgscptcityarchive.sip
%Include symbology/qgssvgcache.sip
%Include symbology/qgsstyle.sip
Expand Down
2 changes: 1 addition & 1 deletion python/core/layout/qgslayoutatlas.sip
Expand Up @@ -29,7 +29,7 @@ QgsLayoutAtlas which is automatically created and attached to the composition.
%End
public:

QgsLayoutAtlas( QgsLayout *layout );
QgsLayoutAtlas( QgsLayout *layout /TransferThis/ );
%Docstring
Constructor for new QgsLayoutAtlas.
%End
Expand Down
42 changes: 42 additions & 0 deletions python/core/layout/qgsprintlayout.sip
@@ -0,0 +1,42 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgsprintlayout.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsPrintLayout : QgsLayout
{
%Docstring
Print layout, a QgsLayout subclass for static or atlas-based layouts.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsprintlayout.h"
%End
public:

QgsPrintLayout( QgsProject *project );
%Docstring
Constructor for QgsPrintLayout.
%End

QgsLayoutAtlas *atlas();
%Docstring
Returns the print layout's atlas.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgsprintlayout.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -412,6 +412,7 @@ SET(QGIS_CORE_SRCS
layout/qgslayoutpoint.cpp
layout/qgslayoutserializableobject.cpp
layout/qgslayoutsize.cpp
layout/qgsprintlayout.cpp

pal/costcalculator.cpp
pal/feature.cpp
Expand Down Expand Up @@ -770,6 +771,7 @@ SET(QGIS_CORE_MOC_HDRS
layout/qgslayouttable.h
layout/qgslayouttablecolumn.h
layout/qgslayoutundostack.h
layout/qgsprintlayout.h

symbology/qgscptcityarchive.h
symbology/qgssvgcache.h
Expand Down
3 changes: 2 additions & 1 deletion src/core/layout/qgslayoutatlas.cpp
Expand Up @@ -22,7 +22,8 @@
#include "qgslayout.h"

QgsLayoutAtlas::QgsLayoutAtlas( QgsLayout *layout )
: mLayout( layout )
: QObject( layout )
, mLayout( layout )
, mFilenameExpressionString( QStringLiteral( "'output_'||@atlas_featurenumber" ) )
{

Expand Down
2 changes: 1 addition & 1 deletion src/core/layout/qgslayoutatlas.h
Expand Up @@ -40,7 +40,7 @@ class CORE_EXPORT QgsLayoutAtlas : public QObject
/**
* Constructor for new QgsLayoutAtlas.
*/
QgsLayoutAtlas( QgsLayout *layout );
QgsLayoutAtlas( QgsLayout *layout SIP_TRANSFERTHIS );

/**
* Returns whether the atlas generation is enabled
Expand Down
24 changes: 24 additions & 0 deletions src/core/layout/qgsprintlayout.cpp
@@ -0,0 +1,24 @@
/***************************************************************************
qgsprintlayout.cpp
-------------------
begin : December 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsprintlayout.h"
#include "qgslayoutatlas.h"

QgsPrintLayout::QgsPrintLayout( QgsProject *project )
: QgsLayout( project )
, mAtlas( new QgsLayoutAtlas( this ) )
{
}
52 changes: 52 additions & 0 deletions src/core/layout/qgsprintlayout.h
@@ -0,0 +1,52 @@
/***************************************************************************
qgsprintlayout.h
-------------------
begin : December 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSPRINTLAYOUT_H
#define QGSPRINTLAYOUT_H

#include "qgis_core.h"
#include "qgslayout.h"

class QgsLayoutAtlas;

/**
* \ingroup core
* \class QgsPrintLayout
* \brief Print layout, a QgsLayout subclass for static or atlas-based layouts.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsPrintLayout : public QgsLayout
{
Q_OBJECT

public:

/**
* Constructor for QgsPrintLayout.
*/
QgsPrintLayout( QgsProject *project );

/**
* Returns the print layout's atlas.
*/
QgsLayoutAtlas *atlas();

private:

QgsLayoutAtlas *mAtlas = nullptr;

};

#endif //QGSPRINTLAYOUT_H

0 comments on commit e6a6db8

Please sign in to comment.