QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "ui_qgslayoutmapclippingwidgetbase.h"
25#include "ui_qgslayoutmaplabelingwidgetbase.h"
26#include "ui_qgslayoutmapwidgetbase.h"
27
28#include "qgis_gui.h"
30#include "qgslayoutitemwidget.h"
31
32class QgsMapLayer;
39
47class GUI_EXPORT QgsLayoutMapWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapWidgetBase
48{
49 Q_OBJECT
50
51 public:
53 explicit QgsLayoutMapWidget( QgsLayoutItemMap *item, QgsMapCanvas *mapCanvas );
54 void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
55
56 void setReportTypeString( const QString &string ) override;
58
59 private slots:
60 void mScaleLineEdit_editingFinished();
61 void setToMapCanvasExtent();
62 void setToMapCanvasScale();
63 void viewExtentInCanvas();
64 void viewScaleInCanvas();
65 void updatePreview();
66 void mFollowVisibilityPresetCheckBox_stateChanged( int state );
67 void mKeepLayerListCheckBox_stateChanged( int state );
68 void mKeepLayerStylesCheckBox_stateChanged( int state );
69 void mDrawCanvasItemsCheckBox_stateChanged( int state );
70 void overviewMapChanged( QgsLayoutItem *item );
71 void mOverviewBlendModeComboBox_currentIndexChanged( int index );
72 void mOverviewInvertCheckbox_toggled( bool state );
73 void mOverviewCenterCheckbox_toggled( bool state );
74 void overviewStackingChanged( int value );
75 void overviewStackingLayerChanged( QgsMapLayer *layer );
76
77 void mXMinLineEdit_editingFinished();
78 void mXMaxLineEdit_editingFinished();
79 void mYMinLineEdit_editingFinished();
80 void mYMaxLineEdit_editingFinished();
81
82 void mAtlasMarginRadio_toggled( bool checked );
83
84 void mAtlasCheckBox_toggled( bool checked );
85 void mAtlasMarginSpinBox_valueChanged( int value );
86 void mAtlasFixedScaleRadio_toggled( bool checked );
87 void mAtlasPredefinedScaleRadio_toggled( bool checked );
88
89 void mAddGridPushButton_clicked();
90 void mRemoveGridPushButton_clicked();
91 void mCopyGridPushButton_clicked();
92 void mGridUpButton_clicked();
93 void mGridDownButton_clicked();
94
95 QgsLayoutItemMapGrid *currentGrid();
96 void mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
97 void mGridListWidget_itemChanged( QListWidgetItem *item );
98 void mGridPropertiesButton_clicked();
99
100 //overviews
101 void mAddOverviewPushButton_clicked();
102 void mRemoveOverviewPushButton_clicked();
103 void mOverviewUpButton_clicked();
104 void mOverviewDownButton_clicked();
105 QgsLayoutItemMapOverview *currentOverview();
106 void mOverviewCheckBox_toggled( bool state );
107 void mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
108 void mOverviewListWidget_itemChanged( QListWidgetItem *item );
109 void setOverviewItemsEnabled( bool enabled );
110 void setOverviewItems( QgsLayoutItemMapOverview *overview );
111 void blockOverviewItemsSignals( bool block );
112
113 void mTemporalCheckBox_toggled( bool checked );
114 void updateTemporalExtent();
115
116 void mElevationRangeCheckBox_toggled( bool checked );
117 void updateZRange();
118
119 protected:
120 bool setNewItem( QgsLayoutItem *item ) override;
121
122 protected slots:
125
126 private slots:
127
129 void updateGuiElements();
130
132 void atlasLayerChanged( QgsVectorLayer *layer );
133
135 void compositionAtlasToggled( bool atlasEnabled );
136
137 void aboutToShowKeepLayersVisibilityPresetsMenu();
138
139 void followVisibilityPresetSelected( int currentIndex );
140 void keepLayersVisibilityPresetSelected();
141
142 void onMapThemesChanged();
143
144 void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
145 void overviewSymbolChanged();
146 void showLabelSettings();
147 void showClipSettings();
148 void switchToMoveContentTool();
149 void aboutToShowLayersMenu();
150 void aboutToShowBookmarkMenu();
151
152 private:
153 QPointer<QgsLayoutItemMap> mMapItem;
154 QgsMapCanvas *mMapCanvas = nullptr;
155 QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
156 QgsLayoutDesignerInterface *mInterface = nullptr;
157 QPointer<QgsLayoutMapLabelingWidget> mLabelWidget;
158 QPointer<QgsLayoutMapClippingWidget> mClipWidget;
159 QMenu *mLayersMenu = nullptr;
160 QMenu *mBookmarkMenu = nullptr;
161 QgsMapLayerProxyModel *mMapLayerModel = nullptr;
162 QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
163 QString mReportTypeString;
164 int mBlockThemeComboChanges = 0;
165
167 void updateComposerExtentFromGui();
168
170 void blockAllSignals( bool b );
171
172 void rotationChanged( double value );
173
175 void toggleAtlasScalingOptionsByLayerType();
176
178 void updateMapForAtlas();
179
181 bool hasPredefinedScales() const;
182
183 QListWidgetItem *addGridListItem( const QString &id, const QString &name );
184
185 void loadGridEntries();
186
187 QListWidgetItem *addOverviewListItem( const QString &id, const QString &name );
188
189 void loadOverviewEntries();
190
191 void storeCurrentLayerSet();
192
197 QList<QgsMapLayer *> orderedPresetVisibleLayers( const QString &name ) const;
198
199 void setToCustomExtent( const QgsReferencedRectangle &extent );
200};
201
209class GUI_EXPORT QgsLayoutMapItemBlocksLabelsModel : public QSortFilterProxyModel
210{
211 Q_OBJECT
212
213 public:
215 explicit QgsLayoutMapItemBlocksLabelsModel( QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
216
217 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
218 QVariant data( const QModelIndex &index, int role ) const override;
219 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
220 Qt::ItemFlags flags( const QModelIndex &index ) const override;
221
222 protected:
223 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
224
225 private:
226 QgsLayoutModel *mLayoutModel = nullptr;
227 QPointer<QgsLayoutItemMap> mMapItem;
228};
229
237class GUI_EXPORT QgsLayoutMapLabelingWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapLabelingWidgetBase
238{
239 Q_OBJECT
240
241 public:
244
245 protected:
246 bool setNewItem( QgsLayoutItem *item ) final;
247
248 private slots:
249 void updateGuiElements();
250 void labelMarginChanged( double val );
251 void labelMarginUnitsChanged();
252 void showPartialsToggled( bool checked );
253 void showUnplacedToggled( bool checked );
254
255 private:
256 QPointer<QgsLayoutItemMap> mMapItem;
257};
258
266class GUI_EXPORT QgsLayoutMapClippingWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapClippingWidgetBase
267{
268 Q_OBJECT
269
270 public:
273
274 void setReportTypeString( const QString &string ) override;
275
276 protected:
277 bool setNewItem( QgsLayoutItem *item ) final;
278
279 private slots:
280 void updateGuiElements();
281 void atlasLayerChanged( QgsVectorLayer *layer );
282 void atlasToggled( bool atlasEnabled );
283 void selectAll();
284 void deselectAll();
285 void invertSelection();
286 void toggleLayersSelectionGui( bool toggled );
287
288 private:
289 QPointer<QgsLayoutItemMap> mMapItem;
290 QgsMapLayerModel *mLayerModel = nullptr;
291
292 bool mBlockUpdates = false;
293};
294
295#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.
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.
QgsLayoutItemBaseWidget(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutItemBaseWidget, linked with the specified layoutObject.
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.
QgsLayoutMapClippingWidget(QgsLayoutItemMap *map)
constructor
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
QgsLayoutMapItemBlocksLabelsModel(QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent=nullptr)
constructor
Qt::ItemFlags flags(const QModelIndex &index) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QVariant data(const QModelIndex &index, int role) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Allows configuration of layout map labeling settings.
QgsLayoutMapLabelingWidget(QgsLayoutItemMap *map)
constructor
void populateDataDefinedButtons()
Initializes data defined buttons to current atlas coverage layer.
QgsLayoutMapWidget(QgsLayoutItemMap *item, QgsMapCanvas *mapCanvas)
constructor
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:80
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.