QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
29 #include "qgslayoutitemmapgrid.h"
30 
31 class QgsMapLayer;
32 class QgsLayoutItemMap;
37 
45 class 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;
55  void setDesignerInterface( QgsLayoutDesignerInterface *iface ) 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  protected:
114  bool setNewItem( QgsLayoutItem *item ) override;
115 
116  protected slots:
118  void populateDataDefinedButtons();
119 
120  private slots:
121 
123  void updateGuiElements();
124 
126  void atlasLayerChanged( QgsVectorLayer *layer );
127 
129  void compositionAtlasToggled( bool atlasEnabled );
130 
131  void aboutToShowKeepLayersVisibilityPresetsMenu();
132 
133  void followVisibilityPresetSelected( int currentIndex );
134  void keepLayersVisibilityPresetSelected();
135 
136  void onMapThemesChanged();
137 
138  void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
139  void overviewSymbolChanged();
140  void showLabelSettings();
141  void showClipSettings();
142  void switchToMoveContentTool();
143  void aboutToShowBookmarkMenu();
144 
145  private:
146  QPointer< QgsLayoutItemMap > mMapItem;
147  QgsMapCanvas *mMapCanvas = nullptr;
148  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
149  QgsLayoutDesignerInterface *mInterface = nullptr;
150  QPointer< QgsLayoutMapLabelingWidget > mLabelWidget;
151  QPointer< QgsLayoutMapClippingWidget > mClipWidget;
152  QMenu *mBookmarkMenu = nullptr;
153  QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
154  QString mReportTypeString;
155  int mBlockThemeComboChanges = 0;
156 
158  void updateComposerExtentFromGui();
159 
161  void blockAllSignals( bool b );
162 
163  void rotationChanged( double value );
164 
166  void toggleAtlasScalingOptionsByLayerType();
167 
169  void updateMapForAtlas();
170 
172  bool hasPredefinedScales() const;
173 
174  QListWidgetItem *addGridListItem( const QString &id, const QString &name );
175 
176  void loadGridEntries();
177 
178  QListWidgetItem *addOverviewListItem( const QString &id, const QString &name );
179 
180  void loadOverviewEntries();
181 
182  void storeCurrentLayerSet();
183 
188  QList<QgsMapLayer *> orderedPresetVisibleLayers( const QString &name ) const;
189 
190 };
191 
199 class GUI_EXPORT QgsLayoutMapItemBlocksLabelsModel : public QSortFilterProxyModel
200 {
201  Q_OBJECT
202 
203  public:
205  explicit QgsLayoutMapItemBlocksLabelsModel( QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
206 
207  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
208  QVariant data( const QModelIndex &index, int role ) const override;
209  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
210  Qt::ItemFlags flags( const QModelIndex &index ) const override;
211 
212  protected:
213 
214  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
215 
216  private:
217  QgsLayoutModel *mLayoutModel = nullptr;
218  QPointer< QgsLayoutItemMap > mMapItem;
219 
220 };
221 
229 class GUI_EXPORT QgsLayoutMapLabelingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapLabelingWidgetBase
230 {
231  Q_OBJECT
232 
233  public:
236 
237  protected:
238  bool setNewItem( QgsLayoutItem *item ) override;
239 
240  private slots:
241  void updateGuiElements();
242  void labelMarginChanged( double val );
243  void labelMarginUnitsChanged();
244  void showPartialsToggled( bool checked );
245  void showUnplacedToggled( bool checked );
246 
247  private:
248  QPointer< QgsLayoutItemMap > mMapItem;
249 };
250 
258 class GUI_EXPORT QgsLayoutMapClippingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapClippingWidgetBase
259 {
260  Q_OBJECT
261 
262  public:
265 
266  void setReportTypeString( const QString &string ) override;
267 
268  protected:
269  bool setNewItem( QgsLayoutItem *item ) override;
270 
271  private slots:
272  void updateGuiElements();
273  void atlasLayerChanged( QgsVectorLayer *layer );
274  void atlasToggled( bool atlasEnabled );
275 
276  private:
277  QPointer< QgsLayoutItemMap > mMapItem;
278  QgsMapLayerModel *mLayerModel = nullptr;
279 
280  bool mBlockUpdates = false;
281 };
282 
283 #endif
QgsLayoutItemMapGrid
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
Definition: qgslayoutitemmapgrid.h:140
qgslayoutitemmapgrid.h
QgsLayoutMapClippingWidget
Allows configuration of layout map clipping settings.
Definition: qgslayoutmapwidget.h:258
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsLayoutItemBaseWidget::setReportTypeString
virtual void setReportTypeString(const QString &string)
Sets the string to use to describe the current report type (e.g.
Definition: qgslayoutitemwidget.cpp:223
QgsLayoutMapItemBlocksLabelsModel
Model for label blocking items.
Definition: qgslayoutmapwidget.h:199
QgsLayoutItemPropertiesWidget
A widget for controlling the common properties of layout items (e.g. position and size,...
Definition: qgslayoutitemwidget.h:217
qgslayoutitemwidget.h
QgsLayoutModel
A model for items attached to a layout. The model also maintains the z-order for the layout,...
Definition: qgslayoutmodel.h:52
QgsLayoutItemBaseWidget::setDesignerInterface
virtual void setDesignerInterface(QgsLayoutDesignerInterface *iface)
Sets the the layout designer interface in which the widget is being shown.
Definition: qgslayoutitemwidget.cpp:227
QgsLayoutMapWidget
Input widget for the configuration of QgsLayoutItemMap.
Definition: qgslayoutmapwidget.h:45
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:112
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsLayoutItemBaseWidget
A base class for property widgets for layout items. All layout item widgets should inherit from this ...
Definition: qgslayoutitemwidget.h:122
QgsLayoutItemMapOverview
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
Definition: qgslayoutitemmapoverview.h:126
QgsLayoutItemBaseWidget::setNewItem
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
Definition: qgslayoutitemwidget.cpp:261
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:317
QgsLayoutItemBaseWidget::setMasterLayout
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
Definition: qgslayoutitemwidget.cpp:241
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsLayoutDesignerInterface
A common interface for layout designer dialogs and widgets.
Definition: qgslayoutdesignerinterface.h:55
QgsMasterLayoutInterface
Interface for master layout type objects, such as print layouts and reports.
Definition: qgsmasterlayoutinterface.h:42
QgsBookmarkManagerProxyModel
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
Definition: qgsbookmarkmodel.h:108
QgsLayoutMapLabelingWidget
Allows configuration of layout map labeling settings.
Definition: qgslayoutmapwidget.h:229
QgsMapLayerModel
The QgsMapLayerModel class is a model to display layers in widgets.
Definition: qgsmaplayermodel.h:37