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