QGIS API Documentation 4.1.0-Master (376402f9aeb)
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
25#include <QPen>
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
30class QgsLayout;
35
42{
43 public:
51
56
57 QString stringType() const override { return u"LayoutGrid"_s; }
58 QgsLayout *layout() override;
59
65 void setResolution( QgsLayoutMeasurement resolution );
66
72 QgsLayoutMeasurement resolution() const { return mGridResolution; }
73
79 void setOffset( const QgsLayoutPoint &offset );
80
86 QgsLayoutPoint offset() const { return mGridOffset; }
87
93 void setPen( const QPen &pen ) { mGridPen = pen; }
94
100 QPen pen() const { return mGridPen; }
101
107 void setStyle( const Style style ) { mGridStyle = style; }
108
114 Style style() const { return mGridStyle; }
115
119 void loadFromSettings();
120
125 bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
126
131 bool readXml( const QDomElement &gridElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
132
133 private:
134 // Used for 'collapsing' undo commands
135 enum UndoCommand
136 {
137 UndoGridResolution = 1,
138 UndoGridOffset,
139 };
140
141 QgsLayoutMeasurement mGridResolution;
142 QgsLayoutPoint mGridOffset;
143 QPen mGridPen;
144 Style mGridStyle = StyleLines;
145 QgsLayout *mLayout = nullptr;
146
147 public:
148#ifndef SIP_RUN
154#endif
155};
156
157#endif //QGSLAYOUTGRIDSETTINGS_H
Contains settings relating to the appearance, spacing and offset for layout grids.
QgsLayoutMeasurement resolution() const
Returns the page/snap grid resolution.
static const QgsSettingsEntryDouble * settingsGridOffsetX
Style
Style for drawing the page/snapping grid.
static const QgsSettingsEntryColor * settingsGridColor
QgsLayoutGridSettings(QgsLayout *layout)
Constructor for QgsLayoutGridSettings.
QgsLayoutPoint offset() const
Returns the offset of the page/snap grid.
static const QgsSettingsEntryDouble * settingsGridResolution
Style style() const
Returns the style used for drawing the page/snap grids.
static const QgsSettingsEntryDouble * settingsGridOffsetY
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.
static const QgsSettingsEntryString * settingsGridStyle
QPen pen() const
Returns the pen used for drawing page/snap grids.
QString stringType() const override
Returns the object type as a string.
Provides a method of storing measurements for use in QGIS layouts using a variety of different measur...
Provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
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:51
A container for the context for various read/write operations on objects.
A color settings entry.
A double settings entry.
A string settings entry.
#define SIP_SKIP
Definition qgis_sip.h:133