Skip to content

Commit

Permalink
Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 17, 2023
1 parent 8e12541 commit 7fdc804
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/core/auto_generated/layout/qgslayoutitem.sip.in
Expand Up @@ -82,6 +82,8 @@ Base class for graphical items within a :py:class:`QgsLayout`.
#include "qgslayoutframe.h"
#include "qgslayoutitemshape.h"
#include "qgslayoutitempage.h"
#include "qgslayoutitemmarker.h"
#include "qgslayoutitemelevationprofile.h"
%End
%ConvertToSubClassCode

Expand Down Expand Up @@ -139,6 +141,14 @@ Base class for graphical items within a :py:class:`QgsLayout`.
sipType = sipType_QgsLayoutFrame;
*sipCppRet = static_cast<QgsLayoutFrame *>( sipCpp );
break;
case QGraphicsItem::UserType + 117:
sipType = sipType_QgsLayoutItemMarker;
*sipCppRet = static_cast<QgsLayoutItemMarker *>( sipCpp );
break;
case QGraphicsItem::UserType + 118:
sipType = sipType_QgsLayoutItemElevationProfile;
*sipCppRet = static_cast<QgsLayoutItemElevationProfile *>( sipCpp );
break;

// did you read that comment above? NO? Go read it now. You're about to break stuff.

Expand Down
@@ -0,0 +1,62 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutitemelevationprofile.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsLayoutItemElevationProfile: QgsLayoutItem
{
%Docstring(signature="appended")
A layout item subclass for elevation profile plots.

.. versionadded:: 3.30
%End

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

QgsLayoutItemElevationProfile( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutItemElevationProfile, with the specified parent ``layout``.
%End

static QgsLayoutItemElevationProfile *create( QgsLayout *layout ) /Factory/;
%Docstring
Returns a new elevation profile item for the specified ``layout``.

The caller takes responsibility for deleting the returned object.
%End

virtual int type() const;

virtual QIcon icon() const;


public slots:

virtual void refresh();


protected:
virtual void draw( QgsLayoutItemRenderContext &context );

virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;

virtual bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context );


};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutitemelevationprofile.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
Expand Up @@ -196,6 +196,11 @@ of layout items.
LayoutManualTable,
LayoutMarker,

LayoutElevationProfile,

// WARNING!!!! SIP CASTING OF QgsLayoutItem and QgsLayoutMultiFrame DEPENDS on these
// values, and must be updated if any additional types are added

// item types provided by plugins
PluginItem,
};
Expand Down
10 changes: 10 additions & 0 deletions python/core/auto_generated/layout/qgslayoutobject.sip.in
Expand Up @@ -31,6 +31,8 @@ A base class for objects which belong to a layout.
#include "qgslayoutframe.h"
#include "qgslayoutitemshape.h"
#include "qgslayoutitempage.h"
#include "qgslayoutitemmarker.h"
#include "qgslayoutitemelevationprofile.h"
%End
%ConvertToSubClassCode
if ( QgsLayoutItem *item = qobject_cast< QgsLayoutItem * >( sipCpp ) )
Expand Down Expand Up @@ -89,6 +91,14 @@ A base class for objects which belong to a layout.
sipType = sipType_QgsLayoutFrame;
*sipCppRet = static_cast<QgsLayoutFrame *>( sipCpp );
break;
case QGraphicsItem::UserType + 117:
sipType = sipType_QgsLayoutItemMarker;
*sipCppRet = static_cast<QgsLayoutItemMarker *>( sipCpp );
break;
case QGraphicsItem::UserType + 118:
sipType = sipType_QgsLayoutItemElevationProfile;
*sipCppRet = static_cast<QgsLayoutItemElevationProfile *>( sipCpp );
break;

// did you read that comment above? NO? Go read it now. You're about to break stuff.

Expand Down
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -401,6 +401,7 @@
%Include auto_generated/layout/qgslayoutguidecollection.sip
%Include auto_generated/layout/qgslayoutitem.sip
%Include auto_generated/layout/qgslayoutitemattributetable.sip
%Include auto_generated/layout/qgslayoutitemelevationprofile.sip
%Include auto_generated/layout/qgslayoutitemgroup.sip
%Include auto_generated/layout/qgslayoutitemhtml.sip
%Include auto_generated/layout/qgslayoutitemlabel.sip
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -582,6 +582,7 @@ set(QGIS_CORE_SRCS
layout/qgslayoutgeopdfexporter.cpp
layout/qgslayoutitem.cpp
layout/qgslayoutitemattributetable.cpp
layout/qgslayoutitemelevationprofile.cpp
layout/qgslayoutitemgroup.cpp
layout/qgslayoutitemgroupundocommand.cpp
layout/qgslayoutitemhtml.cpp
Expand Down Expand Up @@ -1464,6 +1465,7 @@ set(QGIS_CORE_HDRS
layout/qgslayoutguidecollection.h
layout/qgslayoutitem.h
layout/qgslayoutitemattributetable.h
layout/qgslayoutitemelevationprofile.h
layout/qgslayoutitemgroup.h
layout/qgslayoutitemgroupundocommand.h
layout/qgslayoutitemhtml.h
Expand Down
10 changes: 10 additions & 0 deletions src/core/layout/qgslayoutitem.h
Expand Up @@ -123,6 +123,8 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
#include "qgslayoutframe.h"
#include "qgslayoutitemshape.h"
#include "qgslayoutitempage.h"
#include "qgslayoutitemmarker.h"
#include "qgslayoutitemelevationprofile.h"
#endif

#ifdef SIP_RUN
Expand Down Expand Up @@ -182,6 +184,14 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
sipType = sipType_QgsLayoutFrame;
*sipCppRet = static_cast<QgsLayoutFrame *>( sipCpp );
break;
case QGraphicsItem::UserType + 117:
sipType = sipType_QgsLayoutItemMarker;
*sipCppRet = static_cast<QgsLayoutItemMarker *>( sipCpp );
break;
case QGraphicsItem::UserType + 118:
sipType = sipType_QgsLayoutItemElevationProfile;
*sipCppRet = static_cast<QgsLayoutItemElevationProfile *>( sipCpp );
break;

// did you read that comment above? NO? Go read it now. You're about to break stuff.

Expand Down
75 changes: 75 additions & 0 deletions src/core/layout/qgslayoutitemelevationprofile.cpp
@@ -0,0 +1,75 @@
/***************************************************************************
qgslayoutitemelevationprofile.cpp
---------------------------------
begin : January 2023
copyright : (C) 2023 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 "qgslayoutitemelevationprofile.h"
#include "qgslayoutitemregistry.h"


QgsLayoutItemElevationProfile::QgsLayoutItemElevationProfile( QgsLayout *layout )
: QgsLayoutItem( layout )
{
//get default layout font from settings
const QgsSettings settings;
const QString defaultFontString = settings.value( QStringLiteral( "LayoutDesigner/defaultFont" ), QVariant(), QgsSettings::Gui ).toString();
if ( !defaultFontString.isEmpty() )
{
// QFont f = mFormat.font();
// f.setFamily( defaultFontString );
// mFormat.setFont( f );
}

//default to a 10 point font size
//mFormat.setSize( 10 );
//mFormat.setSizeUnit( QgsUnitTypes::RenderPoints );

//default to no background
setBackgroundEnabled( false );
}

QgsLayoutItemElevationProfile *QgsLayoutItemElevationProfile::create( QgsLayout *layout )
{
return new QgsLayoutItemElevationProfile( layout );
}

int QgsLayoutItemElevationProfile::type() const
{
return QgsLayoutItemRegistry::LayoutElevationProfile;
}

QIcon QgsLayoutItemElevationProfile::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemLabel.svg" ) );
}

void QgsLayoutItemElevationProfile::draw( QgsLayoutItemRenderContext &context )
{

}

bool QgsLayoutItemElevationProfile::writePropertiesToElement( QDomElement &layoutLabelElem, QDomDocument &doc, const QgsReadWriteContext &rwContext ) const
{


return true;
}

bool QgsLayoutItemElevationProfile::readPropertiesFromElement( const QDomElement &itemElem, const QDomDocument &, const QgsReadWriteContext &context )
{

return true;
}

62 changes: 62 additions & 0 deletions src/core/layout/qgslayoutitemelevationprofile.h
@@ -0,0 +1,62 @@
/***************************************************************************
qgslayoutitemelevationprofile.h
-------------------------------
begin : January 2023
copyright : (C) 2023 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 QGSLAYOUTITEMELEVATIONPROFILE_H
#define QGSLAYOUTITEMELEVATIONPROFILE_H

#include "qgis_core.h"
#include "qgslayoutitem.h"

/**
* \ingroup core
* \brief A layout item subclass for elevation profile plots.
* \since QGIS 3.30
*/
class CORE_EXPORT QgsLayoutItemElevationProfile: public QgsLayoutItem
{
Q_OBJECT

public:

/**
* Constructor for QgsLayoutItemElevationProfile, with the specified parent \a layout.
*/
QgsLayoutItemElevationProfile( QgsLayout *layout );

/**
* Returns a new elevation profile item for the specified \a layout.
*
* The caller takes responsibility for deleting the returned object.
*/
static QgsLayoutItemElevationProfile *create( QgsLayout *layout ) SIP_FACTORY;

int type() const override;
QIcon icon() const override;

public slots:

void refresh() override;

protected:
void draw( QgsLayoutItemRenderContext &context ) override;
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;

private:

};

#endif //QGSLAYOUTITEMELEVATIONPROFILE_H
5 changes: 5 additions & 0 deletions src/core/layout/qgslayoutitemregistry.h
Expand Up @@ -368,6 +368,11 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject
LayoutManualTable, //!< Manual (fixed) table
LayoutMarker, //!< Marker item

LayoutElevationProfile, //!< Elevation profile item (since QGIS 3.30)

// WARNING!!!! SIP CASTING OF QgsLayoutItem and QgsLayoutMultiFrame DEPENDS on these
// values, and must be updated if any additional types are added

// item types provided by plugins
PluginItem = LayoutTextTable + 10000, //!< Starting point for plugin item types
};
Expand Down
10 changes: 10 additions & 0 deletions src/core/layout/qgslayoutobject.h
Expand Up @@ -51,6 +51,8 @@ class CORE_EXPORT QgsLayoutObject: public QObject, public QgsExpressionContextGe
#include "qgslayoutframe.h"
#include "qgslayoutitemshape.h"
#include "qgslayoutitempage.h"
#include "qgslayoutitemmarker.h"
#include "qgslayoutitemelevationprofile.h"
#endif

#ifdef SIP_RUN
Expand Down Expand Up @@ -111,6 +113,14 @@ class CORE_EXPORT QgsLayoutObject: public QObject, public QgsExpressionContextGe
sipType = sipType_QgsLayoutFrame;
*sipCppRet = static_cast<QgsLayoutFrame *>( sipCpp );
break;
case QGraphicsItem::UserType + 117:
sipType = sipType_QgsLayoutItemMarker;
*sipCppRet = static_cast<QgsLayoutItemMarker *>( sipCpp );
break;
case QGraphicsItem::UserType + 118:
sipType = sipType_QgsLayoutItemElevationProfile;
*sipCppRet = static_cast<QgsLayoutItemElevationProfile *>( sipCpp );
break;

// did you read that comment above? NO? Go read it now. You're about to break stuff.

Expand Down

0 comments on commit 7fdc804

Please sign in to comment.