QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgslayoutgridsettings.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutgridsettings.h
3  -----------------------
4  begin : July 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
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 #ifndef QGSLAYOUTGRIDSETTINGS_H
17 #define QGSLAYOUTGRIDSETTINGS_H
18 
19 #include "qgis_core.h"
20 #include "qgslayoutmeasurement.h"
21 #include "qgslayoutpoint.h"
22 #include "qgslayoutundocommand.h"
24 #include <QPen>
25 
26 class QgsLayout;
28 
36 {
37 
38  public:
39 
41  enum Style
42  {
45  StyleCrosses
46  };
47 
52 
53  QString stringType() const override { return QStringLiteral( "LayoutGrid" ); }
54  QgsLayout *layout() override;
55 
61  void setResolution( QgsLayoutMeasurement resolution );
62 
68  QgsLayoutMeasurement resolution() const { return mGridResolution;}
69 
75  void setOffset( const QgsLayoutPoint &offset );
76 
82  QgsLayoutPoint offset() const { return mGridOffset; }
83 
89  void setPen( const QPen &pen ) { mGridPen = pen; }
90 
96  QPen pen() const { return mGridPen; }
97 
103  void setStyle( const Style style ) { mGridStyle = style; }
104 
110  Style style() const { return mGridStyle; }
111 
115  void loadFromSettings();
116 
121  bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
122 
127  bool readXml( const QDomElement &gridElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
128 
129  private:
130 
131  // Used for 'collapsing' undo commands
132  enum UndoCommand
133  {
134  UndoGridResolution = 1,
135  UndoGridOffset,
136  };
137 
138  QgsLayoutMeasurement mGridResolution;
139  QgsLayoutPoint mGridOffset;
140  QPen mGridPen;
141  Style mGridStyle = StyleLines;
142  QgsLayout *mLayout = nullptr;
143 
144 };
145 
146 #endif //QGSLAYOUTGRIDSETTINGS_H
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsLayoutGridSettings::pen
QPen pen() const
Returns the pen used for drawing page/snap grids.
Definition: qgslayoutgridsettings.h:96
QgsLayoutGridSettings::StyleLines
@ StyleLines
Solid lines.
Definition: qgslayoutgridsettings.h:43
QgsLayoutGridSettings::style
Style style() const
Returns the style used for drawing the page/snap grids.
Definition: qgslayoutgridsettings.h:110
QgsLayoutGridSettings::Style
Style
Style for drawing the page/snapping grid.
Definition: qgslayoutgridsettings.h:42
qgslayoutpoint.h
qgslayoutserializableobject.h
QgsLayoutGridSettings::setStyle
void setStyle(const Style style)
Sets the style used for drawing the page/snap grids.
Definition: qgslayoutgridsettings.h:103
QgsLayoutSerializableObject::layout
virtual QgsLayout * layout()=0
Returns the layout the object belongs to.
QgsLayoutGridSettings::stringType
QString stringType() const override
Returns the object type as a string.
Definition: qgslayoutgridsettings.h:53
QgsLayoutSerializableObject::writeXml
virtual bool writeXml(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const =0
Stores the objects's state in a DOM element.
qgslayoutmeasurement.h
qgslayoutundocommand.h
QgsLayoutSerializableObject::readXml
virtual bool readXml(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)=0
Sets the objects's state from a DOM element.
QgsLayoutGridSettings::offset
QgsLayoutPoint offset() const
Returns the offset of the page/snap grid.
Definition: qgslayoutgridsettings.h:82
QgsLayoutSerializableObject
An interface for layout objects which can be stored and read from DOM elements.
Definition: qgslayoutserializableobject.h:36
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
QgsLayoutGridSettings
Contains settings relating to the appearance, spacing and offset for layout grids.
Definition: qgslayoutgridsettings.h:36
QgsLayoutGridSettings::setPen
void setPen(const QPen &pen)
Sets the pen used for drawing page/snap grids.
Definition: qgslayoutgridsettings.h:89
QgsLayoutPoint
This class provides a method of storing points, consisting of an x and y coordinate,...
Definition: qgslayoutpoint.h:40
QgsLayoutGridSettings::StyleDots
@ StyleDots
Dots.
Definition: qgslayoutgridsettings.h:44
QgsLayoutMeasurement
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
Definition: qgslayoutmeasurement.h:34
QgsLayoutGridSettings::resolution
QgsLayoutMeasurement resolution() const
Returns the page/snap grid resolution.
Definition: qgslayoutgridsettings.h:68