Skip to content
Permalink
Browse files

Merge pull request #4877 from nyalldawson/layout_next

Layouts, chapter II
  • Loading branch information
nyalldawson committed Jul 23, 2017
2 parents d570b43 + 54bf013 commit faa4a09ed0fb26e0032dd72a82d7adcb1a5d46f2
Showing with 6,034 additions and 58 deletions.
  1. +5 −1 python/core/core_auto.sip
  2. +166 −2 python/core/layout/qgslayout.sip
  3. +133 −0 python/core/layout/qgslayoutcontext.sip
  4. +185 −3 python/core/layout/qgslayoutitem.sip
  5. +40 −0 python/core/layout/qgslayoutitemmap.sip
  6. +3 −0 python/core/layout/qgslayoutitemregistry.sip
  7. +165 −0 python/core/layout/qgslayoutitemshape.sip
  8. +132 −2 python/core/layout/qgslayoutobject.sip
  9. +5 −0 python/core/layout/qgslayoutpoint.sip
  10. +5 −0 python/core/layout/qgslayoutsize.sip
  11. +59 −0 python/core/layout/qgslayoututils.sip
  12. +31 −0 python/core/qgsexpressioncontext.sip
  13. +2 −0 python/gui/gui_auto.sip
  14. +70 −1 python/gui/layout/qgslayoutitemguiregistry.sip
  15. +80 −0 python/gui/layout/qgslayoutnewitempropertiesdialog.sip
  16. +56 −0 python/gui/layout/qgslayoutunitscombobox.sip
  17. +30 −0 python/gui/layout/qgslayoutviewrubberband.sip
  18. +52 −2 src/app/layout/qgslayoutdesignerdialog.cpp
  19. +4 −0 src/app/layout/qgslayoutdesignerdialog.h
  20. +8 −1 src/core/CMakeLists.txt
  21. +83 −1 src/core/layout/qgslayout.cpp
  22. +184 −2 src/core/layout/qgslayout.h
  23. +66 −0 src/core/layout/qgslayoutcontext.cpp
  24. +151 −0 src/core/layout/qgslayoutcontext.h
  25. +384 −5 src/core/layout/qgslayoutitem.cpp
  26. +207 −3 src/core/layout/qgslayoutitem.h
  27. +30 −0 src/core/layout/qgslayoutitemmap.cpp
  28. +46 −0 src/core/layout/qgslayoutitemmap.h
  29. +38 −3 src/core/layout/qgslayoutitemregistry.cpp
  30. +7 −1 src/core/layout/qgslayoutitemregistry.h
  31. +173 −0 src/core/layout/qgslayoutitemshape.cpp
  32. +173 −0 src/core/layout/qgslayoutitemshape.h
  33. +97 −0 src/core/layout/qgslayoutobject.cpp
  34. +144 −2 src/core/layout/qgslayoutobject.h
  35. +8 −0 src/core/layout/qgslayoutpoint.cpp
  36. +5 −0 src/core/layout/qgslayoutpoint.h
  37. +7 −0 src/core/layout/qgslayoutsize.cpp
  38. +5 −0 src/core/layout/qgslayoutsize.h
  39. +85 −0 src/core/layout/qgslayoututils.cpp
  40. +62 −0 src/core/layout/qgslayoututils.h
  41. +2 −0 src/core/qgsapplication.cpp
  42. +75 −0 src/core/qgsexpressioncontext.cpp
  43. +33 −1 src/core/qgsexpressioncontext.h
  44. +4 −0 src/gui/CMakeLists.txt
  45. +28 −1 src/gui/layout/qgslayoutitemguiregistry.cpp
  46. +77 −3 src/gui/layout/qgslayoutitemguiregistry.h
  47. +149 −0 src/gui/layout/qgslayoutnewitempropertiesdialog.cpp
  48. +85 −0 src/gui/layout/qgslayoutnewitempropertiesdialog.h
  49. +53 −0 src/gui/layout/qgslayoutunitscombobox.cpp
  50. +62 −0 src/gui/layout/qgslayoutunitscombobox.h
  51. +76 −0 src/gui/layout/qgslayoutviewrubberband.cpp
  52. +32 −0 src/gui/layout/qgslayoutviewrubberband.h
  53. +31 −3 src/gui/layout/qgslayoutviewtooladditem.cpp
  54. +414 −0 src/ui/layout/qgslayoutnewitemproperties.ui
  55. +2 −0 tests/src/core/CMakeLists.txt
  56. +179 −1 tests/src/core/testqgslayout.cpp
  57. +139 −0 tests/src/core/testqgslayoutcontext.cpp
  58. +987 −9 tests/src/core/testqgslayoutitem.cpp
  59. +65 −7 tests/src/core/testqgslayoutobject.cpp
  60. +12 −0 tests/src/core/testqgslayoutunits.cpp
  61. +232 −0 tests/src/core/testqgslayoututils.cpp
  62. +12 −3 tests/src/gui/testqgslayoutview.cpp
  63. +3 −1 tests/src/python/CMakeLists.txt
  64. +49 −0 tests/src/python/test_qgslayoutitempropertiesdialog.py
  65. +47 −0 tests/src/python/test_qgslayoutunitscombobox.py
  66. BIN tests/testdata/control_images/expected_layoutitem_draw/expected_layoutitem_draw.png
  67. BIN ...tdata/control_images/{ → layouts}/expected_layoutitem_debugrect/expected_layoutitem_debugrect.png
  68. BIN tests/testdata/control_images/layouts/expected_layoutitem_draw/expected_layoutitem_draw.png
  69. BIN tests/testdata/control_images/layouts/expected_layoutitem_draw/expected_layoutitem_draw_mask.png
  70. BIN tests/testdata/control_images/layouts/expected_layoutitem_rotation/expected_layoutitem_rotation.png
@@ -153,12 +153,13 @@
%Include composer/qgscomposermultiframecommand.sip
%Include composer/qgscomposertexttable.sip
%Include composer/qgspaperitem.sip
%Include layout/qgslayout.sip
%Include layout/qgslayoutcontext.sip
%Include layout/qgslayoutmeasurement.sip
%Include layout/qgslayoutmeasurementconverter.sip
%Include layout/qgspagesizeregistry.sip
%Include layout/qgslayoutpoint.sip
%Include layout/qgslayoutsize.sip
%Include layout/qgslayoututils.sip
%Include metadata/qgslayermetadata.sip
%Include metadata/qgslayermetadatavalidator.sip
%Include processing/qgsprocessing.sip
@@ -378,8 +379,11 @@
%Include gps/qgsgpsdetector.sip
%Include gps/qgsnmeaconnection.sip
%Include gps/qgsgpsdconnection.sip
%Include layout/qgslayout.sip
%Include layout/qgslayoutitem.sip
%Include layout/qgslayoutitemmap.sip
%Include layout/qgslayoutitemregistry.sip
%Include layout/qgslayoutitemshape.sip
%Include layout/qgslayoutobject.sip
%Include symbology-ng/qgscptcityarchive.sip
%Include symbology-ng/qgssvgcache.sip
@@ -7,7 +7,8 @@
************************************************************************/


class QgsLayout : QGraphicsScene

class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator
{
%Docstring
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
@@ -24,7 +25,170 @@ class QgsLayout : QGraphicsScene
ZMapTool,
};

QgsLayout();
QgsLayout( QgsProject *project );
%Docstring
Construct a new layout linked to the specified ``project``.
%End

QgsProject *project() const;
%Docstring
The project associated with the layout. Used to get access to layers, map themes,
relations and various other bits. It is never null.
:rtype: QgsProject
%End

QString name() const;
%Docstring
Returns the layout's name.
.. seealso:: setName()
:rtype: str
%End

void setName( const QString &name );
%Docstring
Sets the layout's name.
.. seealso:: name()
%End

void setUnits( QgsUnitTypes::LayoutUnit units );
%Docstring
Sets the native measurement ``units`` for the layout. These also form the default unit
for measurements for the layout.
.. seealso:: units()
.. seealso:: convertToLayoutUnits()
%End

QgsUnitTypes::LayoutUnit units() const;
%Docstring
Returns the native units for the layout.
.. seealso:: setUnits()
.. seealso:: convertToLayoutUnits()
:rtype: QgsUnitTypes.LayoutUnit
%End

double convertToLayoutUnits( const QgsLayoutMeasurement &measurement ) const;
%Docstring
Converts a measurement into the layout's native units.
:return: length of measurement in layout units
.. seealso:: convertFromLayoutUnits()
.. seealso:: units()
:rtype: float
%End

QSizeF convertToLayoutUnits( const QgsLayoutSize &size ) const;
%Docstring
Converts a size into the layout's native units.
:return: size of measurement in layout units
.. seealso:: convertFromLayoutUnits()
.. seealso:: units()
:rtype: QSizeF
%End

QPointF convertToLayoutUnits( const QgsLayoutPoint &point ) const;
%Docstring
Converts a ``point`` into the layout's native units.
:return: point in layout units
.. seealso:: convertFromLayoutUnits()
.. seealso:: units()
:rtype: QPointF
%End

QgsLayoutMeasurement convertFromLayoutUnits( const double length, const QgsUnitTypes::LayoutUnit unit ) const;
%Docstring
Converts a ``length`` measurement from the layout's native units to a specified target ``unit``.
:return: length of measurement in specified units
.. seealso:: convertToLayoutUnits()
.. seealso:: units()
:rtype: QgsLayoutMeasurement
%End

QgsLayoutSize convertFromLayoutUnits( const QSizeF &size, const QgsUnitTypes::LayoutUnit unit ) const;
%Docstring
Converts a ``size`` from the layout's native units to a specified target ``unit``.
:return: size of measurement in specified units
.. seealso:: convertToLayoutUnits()
.. seealso:: units()
:rtype: QgsLayoutSize
%End

QgsLayoutPoint convertFromLayoutUnits( const QPointF &point, const QgsUnitTypes::LayoutUnit unit ) const;
%Docstring
Converts a ``point`` from the layout's native units to a specified target ``unit``.
:return: point in specified units
.. seealso:: convertToLayoutUnits()
.. seealso:: units()
:rtype: QgsLayoutPoint
%End

QgsLayoutContext &context();
%Docstring
Returns a reference to the layout's context, which stores information relating to the
current context and rendering settings for the layout.
:rtype: QgsLayoutContext
%End


virtual QgsExpressionContext createExpressionContext() const;

%Docstring
Creates an expression context relating to the layout's current state. The context includes
scopes for global, project, layout and layout context properties.
:rtype: QgsExpressionContext
%End

void setCustomProperty( const QString &key, const QVariant &value );
%Docstring
Set a custom property for the layout.
\param key property key. If a property with the same key already exists it will be overwritten.
\param value property value
.. seealso:: customProperty()
.. seealso:: removeCustomProperty()
.. seealso:: customProperties()
%End

QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
%Docstring
Read a custom property from the layout.
\param key property key
\param defaultValue default value to return if property with matching key does not exist
:return: value of matching property
.. seealso:: setCustomProperty()
.. seealso:: removeCustomProperty()
.. seealso:: customProperties()
:rtype: QVariant
%End

void removeCustomProperty( const QString &key );
%Docstring
Remove a custom property from the layout.
\param key property key
.. seealso:: setCustomProperty()
.. seealso:: customProperty()
.. seealso:: customProperties()
%End

QStringList customProperties() const;
%Docstring
Return list of keys stored in custom properties for the layout.
.. seealso:: setCustomProperty()
.. seealso:: customProperty()
.. seealso:: removeCustomProperty()
:rtype: list of str
%End

QgsLayoutItemMap *referenceMap() const;
%Docstring
:rtype: QgsLayoutItemMap
%End

void setReferenceMap( QgsLayoutItemMap *map );

signals:

void variablesChanged();
%Docstring
Emitted whenever the expression variables stored in the layout have been changed.
%End

};

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



class QgsLayoutContext
{
%Docstring
Stores information relating to the current context and rendering settings for a layout.
.. versionadded:: 3.0
%End

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

enum Flag
{
FlagDebug,
FlagOutlineOnly,
FlagAntialiasing,
FlagUseAdvancedEffects,
};
typedef QFlags<QgsLayoutContext::Flag> Flags;


QgsLayoutContext();

void setFlags( const QgsLayoutContext::Flags flags );
%Docstring
Sets the combination of ``flags`` that will be used for rendering the layout.
.. seealso:: setFlag()
.. seealso:: flags()
.. seealso:: testFlag()
%End

void setFlag( const QgsLayoutContext::Flag flag, const bool on = true );
%Docstring
Enables or disables a particular rendering ``flag`` for the layout. Other existing
flags are not affected.
.. seealso:: setFlags()
.. seealso:: flags()
.. seealso:: testFlag()
%End

QgsLayoutContext::Flags flags() const;
%Docstring
Returns the current combination of flags used for rendering the layout.
.. seealso:: setFlags()
.. seealso:: setFlag()
.. seealso:: testFlag()
:rtype: QgsLayoutContext.Flags
%End

bool testFlag( const Flag flag ) const;
%Docstring
Check whether a particular rendering ``flag`` is enabled for the layout.
.. seealso:: setFlags()
.. seealso:: setFlag()
.. seealso:: flags()
:rtype: bool
%End

void setFeature( const QgsFeature &feature );
%Docstring
Sets the current ``feature`` for evaluating the layout. This feature may
be used for altering an item's content and appearance for a report
or atlas layout.
.. seealso:: feature()
%End

QgsFeature feature() const;
%Docstring
Returns the current feature for evaluating the layout. This feature may
be used for altering an item's content and appearance for a report
or atlas layout.
.. seealso:: setFeature()
:rtype: QgsFeature
%End

QgsVectorLayer *layer() const;
%Docstring
Returns the vector layer associated with the layout's context.
.. seealso:: setLayer()
:rtype: QgsVectorLayer
%End

void setLayer( QgsVectorLayer *layer );
%Docstring
Sets the vector ``layer`` associated with the layout's context.
.. seealso:: layer()
%End

void setDpi( double dpi );
%Docstring
Sets the ``dpi`` for outputting the layout. This also sets the
corresponding DPI for the context's measurementConverter().
.. seealso:: dpi()
%End

double dpi() const;
%Docstring
Returns the ``dpi`` for outputting the layout.
.. seealso:: setDpi()
:rtype: float
%End


QgsLayoutMeasurementConverter &measurementConverter();
%Docstring
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.
:rtype: QgsLayoutMeasurementConverter
%End

};




/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutcontext.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

0 comments on commit faa4a09

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