QGIS API Documentation 4.1.0-Master (60fea48833c)
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:
46 QgsProjectViewSettings( QgsProject *project = nullptr );
47
51 void reset();
52
66
79 void setDefaultViewExtent( const QgsReferencedRectangle &extent );
80
93
105 void setPresetFullExtent( const QgsReferencedRectangle &extent );
106
112 void setRestoreProjectExtentOnProjectLoad( bool state );
113
120
134
144 void setMapScales( const QVector<double> &scales );
145
155 QVector<double> mapScales() const;
156
166 void setUseProjectScales( bool enabled );
167
177 bool useProjectScales() const;
178
192 double defaultRotation() const;
193
207 void setDefaultRotation( double rotation );
208
213 bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
214
219 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
220
221 signals:
222
230
237
238 private:
239 QgsProject *mProject = nullptr;
240 QVector<double> mMapScales;
241 bool mUseProjectScales = false;
242 QgsReferencedRectangle mDefaultViewExtent;
243 QgsReferencedRectangle mPresetFullExtent;
244 bool mRestoreProjectExtentOnProjectLoad = false;
245 double mDefaultRotation = 0;
246};
247
248#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:113
A container for the context for various read/write operations on objects.
A QgsRectangle with associated coordinate reference system.