QGIS API Documentation  2.99.0-Master (7d4f81d)
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 
30 class CORE_EXPORT QgsPaperGrid: public QGraphicsRectItem
31 {
32  public:
33  QgsPaperGrid( double x, double y, double width, double height, QgsComposition *composition );
34 
36  void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
37 
38  private:
39  QgsComposition *mComposition = nullptr;
40 };
41 
44 class CORE_EXPORT QgsPaperItem : public QgsComposerItem
45 {
46  Q_OBJECT
47 
48  public:
50  QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition *composition SIP_TRANSFERTHIS );
51  ~QgsPaperItem();
52 
54  virtual int type() const override { return ComposerPaper; }
55 
57  void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
58 
63  bool writeXml( QDomElement &elem, QDomDocument &doc ) const override;
64 
69  bool readXml( const QDomElement &itemElem, const QDomDocument &doc ) override;
70 
71  virtual void setSceneRect( const QRectF &rectangle ) override;
72 
73  private:
74  QgsPaperItem();
76  void initialize();
77 
78  void calculatePageMargin();
79 
80  QgsPaperGrid *mPageGrid = nullptr;
81  double mPageMargin;
82 };
83 
84 #endif
Item representing the paper.
Definition: qgspaperitem.h:44
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
virtual int type() const override
Return correct graphics item type.
Definition: qgspaperitem.h:54
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:30
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.