QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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"
30
31class QgsMapLayer;
37
45class 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;
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 void mElevationRangeCheckBox_toggled( bool checked );
114 void updateZRange();
115
116 protected:
117 bool setNewItem( QgsLayoutItem *item ) override;
118
119 protected slots:
121 void populateDataDefinedButtons();
122
123 private slots:
124
126 void updateGuiElements();
127
129 void atlasLayerChanged( QgsVectorLayer *layer );
130
132 void compositionAtlasToggled( bool atlasEnabled );
133
134 void aboutToShowKeepLayersVisibilityPresetsMenu();
135
136 void followVisibilityPresetSelected( int currentIndex );
137 void keepLayersVisibilityPresetSelected();
138
139 void onMapThemesChanged();
140
141 void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
142 void overviewSymbolChanged();
143 void showLabelSettings();
144 void showClipSettings();
145 void switchToMoveContentTool();
146 void aboutToShowBookmarkMenu();
147
148 private:
149 QPointer< QgsLayoutItemMap > mMapItem;
150 QgsMapCanvas *mMapCanvas = nullptr;
151 QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
152 QgsLayoutDesignerInterface *mInterface = nullptr;
153 QPointer< QgsLayoutMapLabelingWidget > mLabelWidget;
154 QPointer< QgsLayoutMapClippingWidget > mClipWidget;
155 QMenu *mBookmarkMenu = nullptr;
156 QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
157 QString mReportTypeString;
158 int mBlockThemeComboChanges = 0;
159
161 void updateComposerExtentFromGui();
162
164 void blockAllSignals( bool b );
165
166 void rotationChanged( double value );
167
169 void toggleAtlasScalingOptionsByLayerType();
170
172 void updateMapForAtlas();
173
175 bool hasPredefinedScales() const;
176
177 QListWidgetItem *addGridListItem( const QString &id, const QString &name );
178
179 void loadGridEntries();
180
181 QListWidgetItem *addOverviewListItem( const QString &id, const QString &name );
182
183 void loadOverviewEntries();
184
185 void storeCurrentLayerSet();
186
191 QList<QgsMapLayer *> orderedPresetVisibleLayers( const QString &name ) const;
192
193};
194
202class GUI_EXPORT QgsLayoutMapItemBlocksLabelsModel : public QSortFilterProxyModel
203{
204 Q_OBJECT
205
206 public:
208 explicit QgsLayoutMapItemBlocksLabelsModel( QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
209
210 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
211 QVariant data( const QModelIndex &index, int role ) const override;
212 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
213 Qt::ItemFlags flags( const QModelIndex &index ) const override;
214
215 protected:
216
217 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
218
219 private:
220 QgsLayoutModel *mLayoutModel = nullptr;
221 QPointer< QgsLayoutItemMap > mMapItem;
222
223};
224
232class GUI_EXPORT QgsLayoutMapLabelingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapLabelingWidgetBase
233{
234 Q_OBJECT
235
236 public:
239
240 protected:
241 bool setNewItem( QgsLayoutItem *item ) final;
242
243 private slots:
244 void updateGuiElements();
245 void labelMarginChanged( double val );
246 void labelMarginUnitsChanged();
247 void showPartialsToggled( bool checked );
248 void showUnplacedToggled( bool checked );
249
250 private:
251 QPointer< QgsLayoutItemMap > mMapItem;
252};
253
261class GUI_EXPORT QgsLayoutMapClippingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapClippingWidgetBase
262{
263 Q_OBJECT
264
265 public:
268
269 void setReportTypeString( const QString &string ) override;
270
271 protected:
272 bool setNewItem( QgsLayoutItem *item ) final;
273
274 private slots:
275 void updateGuiElements();
276 void atlasLayerChanged( QgsVectorLayer *layer );
277 void atlasToggled( bool atlasEnabled );
278 void selectAll();
279 void deselectAll();
280 void invertSelection();
281 void toggleLayersSelectionGui( bool toggled );
282
283 private:
284 QPointer< QgsLayoutItemMap > mMapItem;
285 QgsMapLayerModel *mLayerModel = nullptr;
286
287 bool mBlockUpdates = false;
288};
289
290#endif
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
This class represents a coordinate reference system (CRS).
A common interface for layout designer dialogs and widgets.
A base class for property widgets for layout items.
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
virtual void setDesignerInterface(QgsLayoutDesignerInterface *iface)
Sets the the layout designer interface in which the widget is being shown.
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
virtual void setReportTypeString(const QString &string)
Sets the string to use to describe the current report type (e.g.
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
Layout graphical items for displaying a map.
A widget for controlling the common properties of layout items (e.g.
Base class for graphical items within a QgsLayout.
Allows configuration of layout map clipping settings.
Model for label blocking items.
Allows configuration of layout map labeling settings.
Input widget for the configuration of QgsLayoutItemMap.
A model for items attached to a layout.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:93
The QgsMapLayerModel class is a model to display layers in widgets.
Base class for all map layer types.
Definition: qgsmaplayer.h:75
Interface for master layout type objects, such as print layouts and reports.
Represents a vector layer which manages a vector based data sets.
const QgsCoordinateReferenceSystem & crs