QGIS API Documentation  2.99.0-Master (b698612)
qgspaperitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspaperitem.h
3  -------------------
4  begin : September 2008
5  copyright : (C) 2008 by Marco Hugentobler
6  email : marco dot hugentobler at karto dot baug dot ethz dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSPAPERITEM_H
19 #define QGSPAPERITEM_H
20 
21 #include "qgis_core.h"
22 #include "qgis.h"
23 #include "qgscomposeritem.h"
24 #include <QGraphicsRectItem>
25 
29 class CORE_EXPORT QgsPaperGrid: public QGraphicsRectItem
30 {
31  public:
32  QgsPaperGrid( double x, double y, double width, double height, QgsComposition *composition );
33 
35  void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
36 
37  private:
38  QgsComposition *mComposition = nullptr;
39 };
40 
43 class CORE_EXPORT QgsPaperItem : public QgsComposerItem
44 {
45  Q_OBJECT
46 
47  public:
49  QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition *composition SIP_TRANSFERTHIS );
50  ~QgsPaperItem();
51 
53  virtual int type() const override { return ComposerPaper; }
54 
56  void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
57 
62  bool writeXml( QDomElement &elem, QDomDocument &doc ) const override;
63 
68  bool readXml( const QDomElement &itemElem, const QDomDocument &doc ) override;
69 
70  virtual void setSceneRect( const QRectF &rectangle ) override;
71 
72  private:
73  QgsPaperItem();
75  void initialize();
76 
77  void calculatePageMargin();
78 
79  QgsPaperGrid *mPageGrid = nullptr;
80  double mPageMargin;
81 };
82 
83 #endif
Item representing the paper.
Definition: qgspaperitem.h:43
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:34
virtual int type() const override
Return correct graphics item type.
Definition: qgspaperitem.h:53
A item that forms part of a map composition.
virtual bool readXml(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
Item representing a grid.
Definition: qgspaperitem.h:29
Graphics scene for map printing.
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
virtual bool writeXml(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.