QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgslayoutitempolygon.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutitempolygon.h
3  begin : March 2016
4  copyright : (C) 2016 Paul Blottiere, Oslandia
5  email : paul dot blottiere at oslandia dot com
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSLAYOUTITEMPOLYGON_H
18 #define QGSLAYOUTITEMPOLYGON_H
19 
20 #include "qgis_core.h"
21 #include "qgslayoutitemnodeitem.h"
22 #include "qgssymbol.h"
23 
30 class CORE_EXPORT QgsLayoutItemPolygon: public QgsLayoutNodesItem
31 {
32  Q_OBJECT
33 
34  public:
35 
40 
45  QgsLayoutItemPolygon( const QPolygonF &polygon, QgsLayout *layout );
46 
52  static QgsLayoutItemPolygon *create( QgsLayout *layout ) SIP_FACTORY;
53 
54  int type() const override;
55  QIcon icon() const override;
56  QString displayName() const override;
57 
62  QgsFillSymbol *symbol() { return mPolygonStyleSymbol.get(); }
63 
69  void setSymbol( QgsFillSymbol *symbol );
70 
71  protected:
72  bool _addNode( int indexPoint, QPointF newPoint, double radius ) override;
73  bool _removeNode( int nodeIndex ) override;
74  void _draw( QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
75  void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) override;
76  void _writeXmlStyle( QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context ) const override;
77 
78  private:
79 
81  std::unique_ptr<QgsFillSymbol> mPolygonStyleSymbol;
83  void createDefaultPolygonStyleSymbol();
84 
89  void refreshSymbol();
90 };
91 
92 #endif // QGSLAYOUTITEMPOLYGON_H
virtual void _writeXmlStyle(QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context) const =0
Method called in writeXml.
The class is used as a container of context for various read/write operations on other objects...
virtual QIcon icon() const
Returns the item&#39;s icon.
int type() const override
Returns a unique graphics item type identifier.
virtual void _draw(QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle=nullptr)=0
Method called in paint.
QgsFillSymbol * symbol()
Returns the fill symbol used to draw the shape.
An abstract layout item that provides generic methods for node based shapes such as polygon or polyli...
virtual bool _removeNode(int nodeIndex)=0
Method called in removeNode.
Layout item for node based polygon shapes.
#define SIP_FACTORY
Definition: qgis_sip.h:69
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:43
virtual QString displayName() const
Gets item display name.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgssymbol.h:1003
virtual void _readXmlStyle(const QDomElement &elmt, const QgsReadWriteContext &context)=0
Method called in readXml.
virtual bool _addNode(int nodeIndex, QPointF newNode, double radius)=0
Method called in addNode.