QGIS API Documentation 3.99.0-Master (798f63fc3c0)
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;
38
46class GUI_EXPORT QgsLayoutMapWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapWidgetBase
47{
48 Q_OBJECT
49
50 public:
52 explicit QgsLayoutMapWidget( QgsLayoutItemMap *item, QgsMapCanvas *mapCanvas );
53 void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
54
55 void setReportTypeString( const QString &string ) override;
57
58 private slots:
59 void mScaleLineEdit_editingFinished();
60 void setToMapCanvasExtent();
61 void setToMapCanvasScale();
62 void viewExtentInCanvas();
63 void viewScaleInCanvas();
64 void updatePreview();
65 void mFollowVisibilityPresetCheckBox_stateChanged( int state );
66 void mKeepLayerListCheckBox_stateChanged( int state );
67 void mKeepLayerStylesCheckBox_stateChanged( int state );
68 void mDrawCanvasItemsCheckBox_stateChanged( int state );
69 void overviewMapChanged( QgsLayoutItem *item );
70 void mOverviewBlendModeComboBox_currentIndexChanged( int index );
71 void mOverviewInvertCheckbox_toggled( bool state );
72 void mOverviewCenterCheckbox_toggled( bool state );
73 void overviewStackingChanged( int value );
74 void overviewStackingLayerChanged( QgsMapLayer *layer );
75
76 void mXMinLineEdit_editingFinished();
77 void mXMaxLineEdit_editingFinished();
78 void mYMinLineEdit_editingFinished();
79 void mYMaxLineEdit_editingFinished();
80
81 void mAtlasMarginRadio_toggled( bool checked );
82
83 void mAtlasCheckBox_toggled( bool checked );
84 void mAtlasMarginSpinBox_valueChanged( int value );
85 void mAtlasFixedScaleRadio_toggled( bool checked );
86 void mAtlasPredefinedScaleRadio_toggled( bool checked );
87
88 void mAddGridPushButton_clicked();
89 void mRemoveGridPushButton_clicked();
90 void mCopyGridPushButton_clicked();
91 void mGridUpButton_clicked();
92 void mGridDownButton_clicked();
93
94 QgsLayoutItemMapGrid *currentGrid();
95 void mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
96 void mGridListWidget_itemChanged( QListWidgetItem *item );
97 void mGridPropertiesButton_clicked();
98
99 //overviews
100 void mAddOverviewPushButton_clicked();
101 void mRemoveOverviewPushButton_clicked();
102 void mOverviewUpButton_clicked();
103 void mOverviewDownButton_clicked();
104 QgsLayoutItemMapOverview *currentOverview();
105 void mOverviewCheckBox_toggled( bool state );
106 void mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
107 void mOverviewListWidget_itemChanged( QListWidgetItem *item );
108 void setOverviewItemsEnabled( bool enabled );
109 void setOverviewItems( QgsLayoutItemMapOverview *overview );
110 void blockOverviewItemsSignals( bool block );
111
112 void mTemporalCheckBox_toggled( bool checked );
113 void updateTemporalExtent();
114
115 void mElevationRangeCheckBox_toggled( bool checked );
116 void updateZRange();
117
118 protected:
119 bool setNewItem( QgsLayoutItem *item ) override;
120
121 protected slots:
123 void populateDataDefinedButtons();
124
125 private slots:
126
128 void updateGuiElements();
129
131 void atlasLayerChanged( QgsVectorLayer *layer );
132
134 void compositionAtlasToggled( bool atlasEnabled );
135
136 void aboutToShowKeepLayersVisibilityPresetsMenu();
137
138 void followVisibilityPresetSelected( int currentIndex );
139 void keepLayersVisibilityPresetSelected();
140
141 void onMapThemesChanged();
142
143 void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
144 void overviewSymbolChanged();
145 void showLabelSettings();
146 void showClipSettings();
147 void switchToMoveContentTool();
148 void aboutToShowLayersMenu();
149 void aboutToShowBookmarkMenu();
150
151 private:
152 QPointer<QgsLayoutItemMap> mMapItem;
153 QgsMapCanvas *mMapCanvas = nullptr;
154 QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
155 QgsLayoutDesignerInterface *mInterface = nullptr;
156 QPointer<QgsLayoutMapLabelingWidget> mLabelWidget;
157 QPointer<QgsLayoutMapClippingWidget> mClipWidget;
158 QMenu *mLayersMenu = nullptr;
159 QMenu *mBookmarkMenu = nullptr;
160 QgsMapLayerProxyModel *mMapLayerModel = nullptr;
161 QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
162 QString mReportTypeString;
163 int mBlockThemeComboChanges = 0;
164
166 void updateComposerExtentFromGui();
167
169 void blockAllSignals( bool b );
170
171 void rotationChanged( double value );
172
174 void toggleAtlasScalingOptionsByLayerType();
175
177 void updateMapForAtlas();
178
180 bool hasPredefinedScales() const;
181
182 QListWidgetItem *addGridListItem( const QString &id, const QString &name );
183
184 void loadGridEntries();
185
186 QListWidgetItem *addOverviewListItem( const QString &id, const QString &name );
187
188 void loadOverviewEntries();
189
190 void storeCurrentLayerSet();
191
196 QList<QgsMapLayer *> orderedPresetVisibleLayers( const QString &name ) const;
197
198 void setToCustomExtent( const QgsReferencedRectangle &extent );
199};
200
208class GUI_EXPORT QgsLayoutMapItemBlocksLabelsModel : public QSortFilterProxyModel
209{
210 Q_OBJECT
211
212 public:
214 explicit QgsLayoutMapItemBlocksLabelsModel( QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
215
216 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
217 QVariant data( const QModelIndex &index, int role ) const override;
218 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
219 Qt::ItemFlags flags( const QModelIndex &index ) const override;
220
221 protected:
222 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
223
224 private:
225 QgsLayoutModel *mLayoutModel = nullptr;
226 QPointer<QgsLayoutItemMap> mMapItem;
227};
228
236class GUI_EXPORT QgsLayoutMapLabelingWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapLabelingWidgetBase
237{
238 Q_OBJECT
239
240 public:
243
244 protected:
245 bool setNewItem( QgsLayoutItem *item ) final;
246
247 private slots:
248 void updateGuiElements();
249 void labelMarginChanged( double val );
250 void labelMarginUnitsChanged();
251 void showPartialsToggled( bool checked );
252 void showUnplacedToggled( bool checked );
253
254 private:
255 QPointer<QgsLayoutItemMap> mMapItem;
256};
257
265class GUI_EXPORT QgsLayoutMapClippingWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapClippingWidgetBase
266{
267 Q_OBJECT
268
269 public:
272
273 void setReportTypeString( const QString &string ) override;
274
275 protected:
276 bool setNewItem( QgsLayoutItem *item ) final;
277
278 private slots:
279 void updateGuiElements();
280 void atlasLayerChanged( QgsVectorLayer *layer );
281 void atlasToggled( bool atlasEnabled );
282 void selectAll();
283 void deselectAll();
284 void invertSelection();
285 void toggleLayersSelectionGui( bool toggled );
286
287 private:
288 QPointer<QgsLayoutItemMap> mMapItem;
289 QgsMapLayerModel *mLayerModel = nullptr;
290
291 bool mBlockUpdates = false;
292};
293
294#endif
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
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.
A model for display of map layers in widgets.
A proxy model which provides an easy to use model to display the list of layers in widgets.
Base class for all map layer types.
Definition qgsmaplayer.h:78
Interface for master layout type objects, such as print layouts and reports.
A QgsRectangle with associated coordinate reference system.
Represents a vector layer which manages a vector based dataset.
const QgsCoordinateReferenceSystem & crs