QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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 mCopyGridPushButton_clicked();
90 void mGridUpButton_clicked();
91 void mGridDownButton_clicked();
92
93 QgsLayoutItemMapGrid *currentGrid();
94 void mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
95 void mGridListWidget_itemChanged( QListWidgetItem *item );
96 void mGridPropertiesButton_clicked();
97
98 //overviews
99 void mAddOverviewPushButton_clicked();
100 void mRemoveOverviewPushButton_clicked();
101 void mOverviewUpButton_clicked();
102 void mOverviewDownButton_clicked();
103 QgsLayoutItemMapOverview *currentOverview();
104 void mOverviewCheckBox_toggled( bool state );
105 void mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
106 void mOverviewListWidget_itemChanged( QListWidgetItem *item );
107 void setOverviewItemsEnabled( bool enabled );
108 void setOverviewItems( QgsLayoutItemMapOverview *overview );
109 void blockOverviewItemsSignals( bool block );
110
111 void mTemporalCheckBox_toggled( bool checked );
112 void updateTemporalExtent();
113
114 void mElevationRangeCheckBox_toggled( bool checked );
115 void updateZRange();
116
117 protected:
118 bool setNewItem( QgsLayoutItem *item ) override;
119
120 protected slots:
122 void populateDataDefinedButtons();
123
124 private slots:
125
127 void updateGuiElements();
128
130 void atlasLayerChanged( QgsVectorLayer *layer );
131
133 void compositionAtlasToggled( bool atlasEnabled );
134
135 void aboutToShowKeepLayersVisibilityPresetsMenu();
136
137 void followVisibilityPresetSelected( int currentIndex );
138 void keepLayersVisibilityPresetSelected();
139
140 void onMapThemesChanged();
141
142 void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
143 void overviewSymbolChanged();
144 void showLabelSettings();
145 void showClipSettings();
146 void switchToMoveContentTool();
147 void aboutToShowBookmarkMenu();
148
149 private:
150 QPointer< QgsLayoutItemMap > mMapItem;
151 QgsMapCanvas *mMapCanvas = nullptr;
152 QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
153 QgsLayoutDesignerInterface *mInterface = nullptr;
154 QPointer< QgsLayoutMapLabelingWidget > mLabelWidget;
155 QPointer< QgsLayoutMapClippingWidget > mClipWidget;
156 QMenu *mBookmarkMenu = nullptr;
157 QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
158 QString mReportTypeString;
159 int mBlockThemeComboChanges = 0;
160
162 void updateComposerExtentFromGui();
163
165 void blockAllSignals( bool b );
166
167 void rotationChanged( double value );
168
170 void toggleAtlasScalingOptionsByLayerType();
171
173 void updateMapForAtlas();
174
176 bool hasPredefinedScales() const;
177
178 QListWidgetItem *addGridListItem( const QString &id, const QString &name );
179
180 void loadGridEntries();
181
182 QListWidgetItem *addOverviewListItem( const QString &id, const QString &name );
183
184 void loadOverviewEntries();
185
186 void storeCurrentLayerSet();
187
192 QList<QgsMapLayer *> orderedPresetVisibleLayers( const QString &name ) const;
193
194};
195
203class GUI_EXPORT QgsLayoutMapItemBlocksLabelsModel : public QSortFilterProxyModel
204{
205 Q_OBJECT
206
207 public:
209 explicit QgsLayoutMapItemBlocksLabelsModel( QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
210
211 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
212 QVariant data( const QModelIndex &index, int role ) const override;
213 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
214 Qt::ItemFlags flags( const QModelIndex &index ) const override;
215
216 protected:
217
218 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
219
220 private:
221 QgsLayoutModel *mLayoutModel = nullptr;
222 QPointer< QgsLayoutItemMap > mMapItem;
223
224};
225
233class GUI_EXPORT QgsLayoutMapLabelingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapLabelingWidgetBase
234{
235 Q_OBJECT
236
237 public:
240
241 protected:
242 bool setNewItem( QgsLayoutItem *item ) final;
243
244 private slots:
245 void updateGuiElements();
246 void labelMarginChanged( double val );
247 void labelMarginUnitsChanged();
248 void showPartialsToggled( bool checked );
249 void showUnplacedToggled( bool checked );
250
251 private:
252 QPointer< QgsLayoutItemMap > mMapItem;
253};
254
262class GUI_EXPORT QgsLayoutMapClippingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapClippingWidgetBase
263{
264 Q_OBJECT
265
266 public:
269
270 void setReportTypeString( const QString &string ) override;
271
272 protected:
273 bool setNewItem( QgsLayoutItem *item ) final;
274
275 private slots:
276 void updateGuiElements();
277 void atlasLayerChanged( QgsVectorLayer *layer );
278 void atlasToggled( bool atlasEnabled );
279 void selectAll();
280 void deselectAll();
281 void invertSelection();
282 void toggleLayersSelectionGui( bool toggled );
283
284 private:
285 QPointer< QgsLayoutItemMap > mMapItem;
286 QgsMapLayerModel *mLayerModel = nullptr;
287
288 bool mBlockUpdates = false;
289};
290
291#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.
The QgsMapLayerModel class is a model to display layers in widgets.
Base class for all map layer types.
Definition qgsmaplayer.h:76
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