QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsprojectviewsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojectviewsettings.h
3 ---------------------------
4 begin : October 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSPROJECTVIEWSETTINGS_H
16#define QGSPROJECTVIEWSETTINGS_H
17
18#include "qgis_core.h"
20
21#include <QObject>
22#include <QVector>
23
24class QDomElement;
26class QDomDocument;
27class QgsProject;
28
36class CORE_EXPORT QgsProjectViewSettings : public QObject
37{
38 Q_OBJECT
39
40 public:
41
47 QgsProjectViewSettings( QgsProject *project = nullptr );
48
52 void reset();
53
67
80 void setDefaultViewExtent( const QgsReferencedRectangle &extent );
81
94
106 void setPresetFullExtent( const QgsReferencedRectangle &extent );
107
113 void setRestoreProjectExtentOnProjectLoad( bool state );
114
121
135
145 void setMapScales( const QVector<double> &scales );
146
156 QVector<double> mapScales() const;
157
167 void setUseProjectScales( bool enabled );
168
178 bool useProjectScales() const;
179
193 double defaultRotation() const;
194
208 void setDefaultRotation( double rotation );
209
214 bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
215
220 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
221
222 signals:
223
231
238
239 private:
240
241 QgsProject *mProject = nullptr;
242 QVector<double> mMapScales;
243 bool mUseProjectScales = false;
244 QgsReferencedRectangle mDefaultViewExtent;
245 QgsReferencedRectangle mPresetFullExtent;
246 bool mRestoreProjectExtentOnProjectLoad;
247 double mDefaultRotation = 0;
248};
249
250#endif // QGSPROJECTVIEWSETTINGS_H
double defaultRotation() const
Returns the default map rotation (in clockwise degrees) for maps in the project.
QgsReferencedRectangle defaultViewExtent() const
Returns the default view extent, which should be used as the initial map extent when this project is ...
bool useProjectScales() const
Returns true if project mapScales() are enabled.
QgsReferencedRectangle presetFullExtent() const
Returns the project's preset full extent.
void setPresetFullExtent(const QgsReferencedRectangle &extent)
Sets the project's preset full extent.
void reset()
Resets the settings to a default state.
void presetFullExtentChanged()
Emitted whenever the presetFullExtent() is changed.
void setDefaultViewExtent(const QgsReferencedRectangle &extent)
Sets the default view extent, which should be used as the initial map extent when this project is ope...
bool restoreProjectExtentOnProjectLoad()
Returns whether the project's preset full extent should be restored when the project is loaded.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads the settings's state from a DOM element.
void setDefaultRotation(double rotation)
Set the default rotation of maps in the project, in clockwise degrees.
void setMapScales(const QVector< double > &scales)
Sets the list of custom project map scales.
void setUseProjectScales(bool enabled)
Sets whether project mapScales() are enabled.
QVector< double > mapScales() const
Returns the list of custom project map scales.
QgsProjectViewSettings(QgsProject *project=nullptr)
Constructor for QgsProjectViewSettings for the specified project.
void mapScalesChanged()
Emitted when the list of custom project map scales changes.
QgsReferencedRectangle fullExtent() const
Returns the full extent of the project, which represents the maximal limits of the project.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Returns a DOM element representing the settings.
void setRestoreProjectExtentOnProjectLoad(bool state)
Sets whether the project's preset full extent should be restored when the project is loaded.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
A container for the context for various read/write operations on objects.
A QgsRectangle with associated coordinate reference system.