Skip to content

Commit

Permalink
Add some base classes for layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 30, 2017
1 parent cd979d8 commit 18b2b52
Show file tree
Hide file tree
Showing 24 changed files with 977 additions and 2 deletions.
4 changes: 4 additions & 0 deletions python/core/core_auto.sip
Expand Up @@ -153,6 +153,7 @@
%Include composer/qgscomposermultiframecommand.sip
%Include composer/qgscomposertexttable.sip
%Include composer/qgspaperitem.sip
%Include layout/qgslayout.sip
%Include layout/qgslayoutmeasurement.sip
%Include layout/qgslayoutmeasurementconverter.sip
%Include layout/qgspagesizeregistry.sip
Expand Down Expand Up @@ -371,6 +372,9 @@
%Include gps/qgsgpsdetector.sip
%Include gps/qgsnmeaconnection.sip
%Include gps/qgsgpsdconnection.sip
%Include layout/qgslayoutitem.sip
%Include layout/qgslayoutitemregistry.sip
%Include layout/qgslayoutobject.sip
%Include symbology-ng/qgscptcityarchive.sip
%Include symbology-ng/qgssvgcache.sip
%Include symbology-ng/qgsstyle.sip
Expand Down
35 changes: 35 additions & 0 deletions python/core/layout/qgslayout.sip
@@ -0,0 +1,35 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayout.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/


class QgsLayout : QGraphicsScene
{
%Docstring
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
.. versionadded:: 3.0
%End

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

QgsLayout();

};




/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayout.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
60 changes: 60 additions & 0 deletions python/core/layout/qgslayoutitem.sip
@@ -0,0 +1,60 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem
{
%Docstring
Base class for graphical items within a QgsLayout.
.. versionadded:: 3.0
%End

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

QgsLayoutItem( QgsLayout *layout );

virtual int type() const = 0;
%Docstring
Return correct graphics item type.
:rtype: int
%End

virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget );

%Docstring
Handles preparing a paint surface for the layout item and painting the item's
content. Derived classes must not override this method, but instead implement
the pure virtual method QgsLayoutItem.draw.
%End

protected:

virtual void drawDebugRect( QPainter *painter );
%Docstring
Draws a debugging rectangle of the item's current bounds within the specified
painter.
@param painter destination QPainter
%End

};




/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
58 changes: 58 additions & 0 deletions python/core/layout/qgslayoutitemregistry.sip
@@ -0,0 +1,58 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutitemregistry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsLayoutItemRegistry : QObject
{
%Docstring
Registry of available layout item types.

QgsLayoutItemRegistry is not usually directly created, but rather accessed through
QgsApplication.layoutItemRegistry().

.. versionadded:: 3.0
%End

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

enum ItemType
{
LayoutItem,

// known
LayoutPage,

// item
PluginItem,
};

QgsLayoutItemRegistry( QObject *parent = 0 );
%Docstring
Creates a registry and populates it with standard item types.

QgsLayoutItemRegistry is not usually directly created, but rather accessed through
QgsApplication.layoutItemRegistry().
%End


};




/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutitemregistry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
52 changes: 52 additions & 0 deletions python/core/layout/qgslayoutobject.sip
@@ -0,0 +1,52 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutobject.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsLayoutObject: QObject
{
%Docstring
A base class for objects which belong to a layout.
.. versionadded:: 3.0
%End

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

QgsLayoutObject( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutObject, with the specified parent ``layout``.
.. note::

While ownership of a QgsLayoutObject is not passed to the layout,
classes which are derived from QgsLayoutObject (such as QgsLayoutItem)
may transfer their ownership to a layout upon construction.
%End


QgsLayout *layout();
%Docstring
Returns the layout the object is attached to.
:rtype: QgsLayout
%End

protected:


};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutobject.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
8 changes: 7 additions & 1 deletion python/core/qgsapplication.sip
Expand Up @@ -10,7 +10,6 @@




class QgsApplication : QApplication
{
%Docstring
Expand Down Expand Up @@ -646,6 +645,13 @@ Returns path to the build output directory. Valid only when running from build d
:rtype: QgsSymbolLayerRegistry
%End

static QgsLayoutItemRegistry *layoutItemRegistry();
%Docstring
Returns the application's layout item registry, used for layout item types.
.. versionadded:: 3.0
:rtype: QgsLayoutItemRegistry
%End

static QgsGPSConnectionRegistry *gpsConnectionRegistry();
%Docstring
Returns the application's GPS connection registry, used for managing GPS connections.
Expand Down
10 changes: 10 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -343,8 +343,12 @@ SET(QGIS_CORE_SRCS
dxf/qgsdxfpaintengine.cpp
dxf/qgsdxfpallabeling.cpp

layout/qgslayout.cpp
layout/qgslayoutitem.cpp
layout/qgslayoutitemregistry.cpp
layout/qgslayoutmeasurement.cpp
layout/qgslayoutmeasurementconverter.cpp
layout/qgslayoutobject.cpp
layout/qgspagesizeregistry.cpp
layout/qgslayoutpoint.cpp
layout/qgslayoutsize.cpp
Expand Down Expand Up @@ -660,6 +664,11 @@ SET(QGIS_CORE_MOC_HDRS
gps/qgsnmeaconnection.h
gps/qgsgpsdconnection.h

layout/qgslayout.h
layout/qgslayoutitem.h
layout/qgslayoutitemregistry.h
layout/qgslayoutobject.h

symbology-ng/qgscptcityarchive.h
symbology-ng/qgssvgcache.h
symbology-ng/qgsstyle.h
Expand Down Expand Up @@ -901,6 +910,7 @@ SET(QGIS_CORE_HDRS
composer/qgscomposertexttable.h
composer/qgspaperitem.h

layout/qgslayout.h
layout/qgslayoutmeasurement.h
layout/qgslayoutmeasurementconverter.h
layout/qgspagesizeregistry.h
Expand Down
23 changes: 23 additions & 0 deletions src/core/layout/qgslayout.cpp
@@ -0,0 +1,23 @@
/***************************************************************************
qgslayout.cpp
-------------------
begin : June 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 "qgslayout.h"

QgsLayout::QgsLayout()
: QGraphicsScene()
{

}
41 changes: 41 additions & 0 deletions src/core/layout/qgslayout.h
@@ -0,0 +1,41 @@
/***************************************************************************
qgslayout.h
-------------------
begin : June 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 QGSLAYOUT_H
#define QGSLAYOUT_H

#include "qgis_core.h"
#include <QGraphicsScene>

/**
* \ingroup core
* \class QgsLayout
* \brief Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsLayout : public QGraphicsScene
{
Q_OBJECT

public:

QgsLayout();

};

#endif //QGSLAYOUT_H



0 comments on commit 18b2b52

Please sign in to comment.