QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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"
21#include "qgslayoutpoint.h"
24#include <QPen>
25
26class QgsLayout;
28
35{
36
37 public:
38
40 enum Style
41 {
44 StyleCrosses
45 };
46
51
52 QString stringType() const override { return QStringLiteral( "LayoutGrid" ); }
53 QgsLayout *layout() override;
54
60 void setResolution( QgsLayoutMeasurement resolution );
61
67 QgsLayoutMeasurement resolution() const { return mGridResolution;}
68
74 void setOffset( const QgsLayoutPoint &offset );
75
81 QgsLayoutPoint offset() const { return mGridOffset; }
82
88 void setPen( const QPen &pen ) { mGridPen = pen; }
89
95 QPen pen() const { return mGridPen; }
96
102 void setStyle( const Style style ) { mGridStyle = style; }
103
109 Style style() const { return mGridStyle; }
110
114 void loadFromSettings();
115
120 bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
121
126 bool readXml( const QDomElement &gridElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
127
128 private:
129
130 // Used for 'collapsing' undo commands
131 enum UndoCommand
132 {
133 UndoGridResolution = 1,
134 UndoGridOffset,
135 };
136
137 QgsLayoutMeasurement mGridResolution;
138 QgsLayoutPoint mGridOffset;
139 QPen mGridPen;
140 Style mGridStyle = StyleLines;
141 QgsLayout *mLayout = nullptr;
142
143};
144
145#endif //QGSLAYOUTGRIDSETTINGS_H
Contains settings relating to the appearance, spacing and offset for layout grids.
QgsLayoutMeasurement resolution() const
Returns the page/snap grid resolution.
Style
Style for drawing the page/snapping grid.
QgsLayoutPoint offset() const
Returns the offset of the page/snap grid.
Style style() const
Returns the style used for drawing the page/snap grids.
void setPen(const QPen &pen)
Sets the pen used for drawing page/snap grids.
void setStyle(const Style style)
Sets the style used for drawing the page/snap grids.
QPen pen() const
Returns the pen used for drawing page/snap grids.
QString stringType() const override
Returns the object type as a string.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
This class provides a method of storing points, consisting of an x and y coordinate,...
An interface for layout objects which can be stored and read from DOM elements.
virtual bool writeXml(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const =0
Stores the objects's state in a DOM element.
virtual bool readXml(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)=0
Sets the objects's state from a DOM element.
virtual QgsLayout * layout()=0
Returns the layout the object belongs to.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:49
The class is used as a container of context for various read/write operations on other objects.