QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgslayoutmapwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutmapwidget.h
3  ----------------------
4  begin : October 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSLAYOUTMAPWIDGET_H
19 #define QGSLAYOUTMAPWIDGET_H
20 
21 // We don't want to expose this in the public API
22 #define SIP_NO_FILE
23 
24 #include "qgis_gui.h"
25 #include "ui_qgslayoutmapwidgetbase.h"
26 #include "ui_qgslayoutmaplabelingwidgetbase.h"
27 #include "ui_qgslayoutmapclippingwidgetbase.h"
28 #include "qgslayoutitemwidget.h"
29 #include "qgslayoutitemmapgrid.h"
30 
31 class QgsMapLayer;
32 class QgsLayoutItemMap;
37 
45 class GUI_EXPORT QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapWidgetBase
46 {
47  Q_OBJECT
48 
49  public:
51  explicit QgsLayoutMapWidget( QgsLayoutItemMap *item, QgsMapCanvas *mapCanvas );
52  void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
53 
54  void setReportTypeString( const QString &string ) override;
55  void setDesignerInterface( QgsLayoutDesignerInterface *iface ) override;
56 
57  private slots:
58  void mScaleLineEdit_editingFinished();
59  void setToMapCanvasExtent();
60  void setToMapCanvasScale();
61  void viewExtentInCanvas();
62  void viewScaleInCanvas();
63  void updatePreview();
64  void mFollowVisibilityPresetCheckBox_stateChanged( int state );
65  void mKeepLayerListCheckBox_stateChanged( int state );
66  void mKeepLayerStylesCheckBox_stateChanged( int state );
67  void mDrawCanvasItemsCheckBox_stateChanged( int state );
68  void overviewMapChanged( QgsLayoutItem *item );
69  void mOverviewBlendModeComboBox_currentIndexChanged( int index );
70  void mOverviewInvertCheckbox_toggled( bool state );
71  void mOverviewCenterCheckbox_toggled( bool state );
72  void overviewStackingChanged( int value );
73  void overviewStackingLayerChanged( QgsMapLayer *layer );
74 
75  void mXMinLineEdit_editingFinished();
76  void mXMaxLineEdit_editingFinished();
77  void mYMinLineEdit_editingFinished();
78  void mYMaxLineEdit_editingFinished();
79 
80  void mAtlasMarginRadio_toggled( bool checked );
81 
82  void mAtlasCheckBox_toggled( bool checked );
83  void mAtlasMarginSpinBox_valueChanged( int value );
84  void mAtlasFixedScaleRadio_toggled( bool checked );
85  void mAtlasPredefinedScaleRadio_toggled( bool checked );
86 
87  void mAddGridPushButton_clicked();
88  void mRemoveGridPushButton_clicked();
89  void mGridUpButton_clicked();
90  void mGridDownButton_clicked();
91 
92  QgsLayoutItemMapGrid *currentGrid();
93  void mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
94  void mGridListWidget_itemChanged( QListWidgetItem *item );
95  void mGridPropertiesButton_clicked();
96 
97  //overviews
98  void mAddOverviewPushButton_clicked();
99  void mRemoveOverviewPushButton_clicked();
100  void mOverviewUpButton_clicked();
101  void mOverviewDownButton_clicked();
102  QgsLayoutItemMapOverview *currentOverview();
103  void mOverviewCheckBox_toggled( bool state );
104  void mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
105  void mOverviewListWidget_itemChanged( QListWidgetItem *item );
106  void setOverviewItemsEnabled( bool enabled );
107  void setOverviewItems( QgsLayoutItemMapOverview *overview );
108  void blockOverviewItemsSignals( bool block );
109 
110  void mTemporalCheckBox_toggled( bool checked );
111  void updateTemporalExtent();
112 
113  protected:
114  bool setNewItem( QgsLayoutItem *item ) override;
115 
116  protected slots:
118  void populateDataDefinedButtons();
119 
120  private slots:
121 
123  void updateGuiElements();
124 
126  void atlasLayerChanged( QgsVectorLayer *layer );
127 
129  void compositionAtlasToggled( bool atlasEnabled );
130 
131  void aboutToShowKeepLayersVisibilityPresetsMenu();
132 
133  void followVisibilityPresetSelected( int currentIndex );
134  void keepLayersVisibilityPresetSelected();
135 
136  void onMapThemesChanged();
137 
138  void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
139  void overviewSymbolChanged();
140  void showLabelSettings();
141  void showClipSettings();
142  void switchToMoveContentTool();
143  void aboutToShowBookmarkMenu();
144 
145  private:
146  QPointer< QgsLayoutItemMap > mMapItem;
147  QgsMapCanvas *mMapCanvas = nullptr;
148  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
149  QgsLayoutDesignerInterface *mInterface = nullptr;
150  QPointer< QgsLayoutMapLabelingWidget > mLabelWidget;
151  QPointer< QgsLayoutMapClippingWidget > mClipWidget;
152  QMenu *mBookmarkMenu = nullptr;
153  QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
154  QString mReportTypeString;
155 
157  void updateComposerExtentFromGui();
158 
160  void blockAllSignals( bool b );
161 
162  void rotationChanged( double value );
163 
165  void toggleAtlasScalingOptionsByLayerType();
166 
168  void updateMapForAtlas();
169 
171  bool hasPredefinedScales() const;
172 
173  QListWidgetItem *addGridListItem( const QString &id, const QString &name );
174 
175  void loadGridEntries();
176 
177  QListWidgetItem *addOverviewListItem( const QString &id, const QString &name );
178 
179  void loadOverviewEntries();
180 
181  void storeCurrentLayerSet();
182 
187  QList<QgsMapLayer *> orderedPresetVisibleLayers( const QString &name ) const;
188 
189 };
190 
198 class GUI_EXPORT QgsLayoutMapItemBlocksLabelsModel : public QSortFilterProxyModel
199 {
200  Q_OBJECT
201 
202  public:
204  explicit QgsLayoutMapItemBlocksLabelsModel( QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
205 
206  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
207  QVariant data( const QModelIndex &index, int role ) const override;
208  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
209  Qt::ItemFlags flags( const QModelIndex &index ) const override;
210 
211  protected:
212 
213  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
214 
215  private:
216  QgsLayoutModel *mLayoutModel = nullptr;
217  QPointer< QgsLayoutItemMap > mMapItem;
218 
219 };
220 
228 class GUI_EXPORT QgsLayoutMapLabelingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapLabelingWidgetBase
229 {
230  Q_OBJECT
231 
232  public:
235 
236  protected:
237  bool setNewItem( QgsLayoutItem *item ) override;
238 
239  private slots:
240  void updateGuiElements();
241  void labelMarginChanged( double val );
242  void labelMarginUnitsChanged();
243  void showPartialsToggled( bool checked );
244  void showUnplacedToggled( bool checked );
245 
246  private:
247  QPointer< QgsLayoutItemMap > mMapItem;
248 };
249 
257 class GUI_EXPORT QgsLayoutMapClippingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapClippingWidgetBase
258 {
259  Q_OBJECT
260 
261  public:
264 
265  void setReportTypeString( const QString &string ) override;
266 
267  protected:
268  bool setNewItem( QgsLayoutItem *item ) override;
269 
270  private slots:
271  void updateGuiElements();
272  void atlasLayerChanged( QgsVectorLayer *layer );
273  void atlasToggled( bool atlasEnabled );
274 
275  private:
276  QPointer< QgsLayoutItemMap > mMapItem;
277  QgsMapLayerModel *mLayerModel = nullptr;
278 
279  bool mBlockUpdates = false;
280 };
281 
282 #endif
QgsLayoutItemMapGrid
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
Definition: qgslayoutitemmapgrid.h:141
qgslayoutitemmapgrid.h
QgsLayoutMapClippingWidget
Allows configuration of layout map clipping settings.
Definition: qgslayoutmapwidget.h:258
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
QgsLayoutItemBaseWidget::setReportTypeString
virtual void setReportTypeString(const QString &string)
Sets the string to use to describe the current report type (e.g.
Definition: qgslayoutitemwidget.cpp:184
QgsLayoutMapItemBlocksLabelsModel
Model for label blocking items.
Definition: qgslayoutmapwidget.h:199
QgsLayoutItemPropertiesWidget
A widget for controlling the common properties of layout items (e.g.
Definition: qgslayoutitemwidget.h:219
qgslayoutitemwidget.h
QgsLayoutModel
A model for items attached to a layout.
Definition: qgslayoutmodel.h:53
QgsLayoutItemBaseWidget::setDesignerInterface
virtual void setDesignerInterface(QgsLayoutDesignerInterface *iface)
Sets the the layout designer interface in which the widget is being shown.
Definition: qgslayoutitemwidget.cpp:188
QgsLayoutMapWidget
Input widget for the configuration of QgsLayoutItemMap.
Definition: qgslayoutmapwidget.h:46
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:113
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsLayoutItemBaseWidget
A base class for property widgets for layout items.
Definition: qgslayoutitemwidget.h:123
QgsLayoutItemMapOverview
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
Definition: qgslayoutitemmapoverview.h:127
QgsLayoutItemBaseWidget::setNewItem
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
Definition: qgslayoutitemwidget.cpp:222
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:318
QgsLayoutItemBaseWidget::setMasterLayout
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
Definition: qgslayoutitemwidget.cpp:202
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsLayoutDesignerInterface
A common interface for layout designer dialogs and widgets.
Definition: qgslayoutdesignerinterface.h:55
QgsMasterLayoutInterface
Interface for master layout type objects, such as print layouts and reports.
Definition: qgsmasterlayoutinterface.h:43
QgsBookmarkManagerProxyModel
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
Definition: qgsbookmarkmodel.h:109
QgsLayoutMapLabelingWidget
Allows configuration of layout map labeling settings.
Definition: qgslayoutmapwidget.h:229
QgsMapLayerModel
The QgsMapLayerModel class is a model to display layers in widgets.
Definition: qgsmaplayermodel.h:37