QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 "qgslayoutitemwidget.h"
28 #include "qgslayoutitemmapgrid.h"
29 
30 class QgsMapLayer;
31 class QgsLayoutItemMap;
35 
43 class GUI_EXPORT QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapWidgetBase
44 {
45  Q_OBJECT
46 
47  public:
49  explicit QgsLayoutMapWidget( QgsLayoutItemMap *item, QgsMapCanvas *mapCanvas );
50  void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
51 
52  void setReportTypeString( const QString &string ) override;
53  void setDesignerInterface( QgsLayoutDesignerInterface *iface ) override;
54 
55  private slots:
56  void mScaleLineEdit_editingFinished();
57  void setToMapCanvasExtent();
58  void setToMapCanvasScale();
59  void viewExtentInCanvas();
60  void viewScaleInCanvas();
61  void updatePreview();
62  void mFollowVisibilityPresetCheckBox_stateChanged( int state );
63  void mKeepLayerListCheckBox_stateChanged( int state );
64  void mKeepLayerStylesCheckBox_stateChanged( int state );
65  void mDrawCanvasItemsCheckBox_stateChanged( int state );
66  void overviewMapChanged( QgsLayoutItem *item );
67  void mOverviewBlendModeComboBox_currentIndexChanged( int index );
68  void mOverviewInvertCheckbox_toggled( bool state );
69  void mOverviewCenterCheckbox_toggled( bool state );
70  void overviewStackingChanged( int value );
71  void overviewStackingLayerChanged( QgsMapLayer *layer );
72 
73  void mXMinLineEdit_editingFinished();
74  void mXMaxLineEdit_editingFinished();
75  void mYMinLineEdit_editingFinished();
76  void mYMaxLineEdit_editingFinished();
77 
78  void mAtlasMarginRadio_toggled( bool checked );
79 
80  void mAtlasCheckBox_toggled( bool checked );
81  void mAtlasMarginSpinBox_valueChanged( int value );
82  void mAtlasFixedScaleRadio_toggled( bool checked );
83  void mAtlasPredefinedScaleRadio_toggled( bool checked );
84 
85  void mAddGridPushButton_clicked();
86  void mRemoveGridPushButton_clicked();
87  void mGridUpButton_clicked();
88  void mGridDownButton_clicked();
89 
90  QgsLayoutItemMapGrid *currentGrid();
91  void mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
92  void mGridListWidget_itemChanged( QListWidgetItem *item );
93  void mGridPropertiesButton_clicked();
94 
95  //overviews
96  void mAddOverviewPushButton_clicked();
97  void mRemoveOverviewPushButton_clicked();
98  void mOverviewUpButton_clicked();
99  void mOverviewDownButton_clicked();
100  QgsLayoutItemMapOverview *currentOverview();
101  void mOverviewCheckBox_toggled( bool state );
102  void mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
103  void mOverviewListWidget_itemChanged( QListWidgetItem *item );
104  void setOverviewItemsEnabled( bool enabled );
105  void setOverviewItems( QgsLayoutItemMapOverview *overview );
106  void blockOverviewItemsSignals( bool block );
107 
108  void mTemporalCheckBox_toggled( bool checked );
109  void updateTemporalExtent();
110 
111  protected:
112  bool setNewItem( QgsLayoutItem *item ) override;
113 
114  protected slots:
116  void populateDataDefinedButtons();
117 
118  private slots:
119 
121  void updateGuiElements();
122 
124  void atlasLayerChanged( QgsVectorLayer *layer );
125 
127  void compositionAtlasToggled( bool atlasEnabled );
128 
129  void aboutToShowKeepLayersVisibilityPresetsMenu();
130 
131  void followVisibilityPresetSelected( int currentIndex );
132  void keepLayersVisibilityPresetSelected();
133 
134  void onMapThemesChanged();
135 
136  void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
137  void overviewSymbolChanged();
138  void showLabelSettings();
139  void switchToMoveContentTool();
140  void aboutToShowBookmarkMenu();
141 
142  private:
143  QPointer< QgsLayoutItemMap > mMapItem;
144  QgsMapCanvas *mMapCanvas = nullptr;
145  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
146  QgsLayoutDesignerInterface *mInterface = nullptr;
147  QPointer< QgsLayoutMapLabelingWidget > mLabelWidget;
148  QMenu *mBookmarkMenu = nullptr;
149  QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
150 
152  void updateComposerExtentFromGui();
153 
155  void blockAllSignals( bool b );
156 
157  void rotationChanged( double value );
158 
160  void toggleAtlasScalingOptionsByLayerType();
161 
163  void updateMapForAtlas();
164 
166  bool hasPredefinedScales() const;
167 
168  QListWidgetItem *addGridListItem( const QString &id, const QString &name );
169 
170  void loadGridEntries();
171 
172  QListWidgetItem *addOverviewListItem( const QString &id, const QString &name );
173 
174  void loadOverviewEntries();
175 
176  void storeCurrentLayerSet();
177 
182  QList<QgsMapLayer *> orderedPresetVisibleLayers( const QString &name ) const;
183 
184 };
185 
193 class GUI_EXPORT QgsLayoutMapItemBlocksLabelsModel : public QSortFilterProxyModel
194 {
195  Q_OBJECT
196 
197  public:
199  explicit QgsLayoutMapItemBlocksLabelsModel( QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
200 
201  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
202  QVariant data( const QModelIndex &index, int role ) const override;
203  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
204  Qt::ItemFlags flags( const QModelIndex &index ) const override;
205 
206  protected:
207 
208  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
209 
210  private:
211  QgsLayoutModel *mLayoutModel = nullptr;
212  QPointer< QgsLayoutItemMap > mMapItem;
213 
214 };
215 
223 class GUI_EXPORT QgsLayoutMapLabelingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapLabelingWidgetBase
224 {
225  Q_OBJECT
226 
227  public:
230 
231  protected:
232  bool setNewItem( QgsLayoutItem *item ) override;
233 
234  private slots:
235  void updateGuiElements();
236  void labelMarginChanged( double val );
237  void labelMarginUnitsChanged();
238  void showPartialsToggled( bool checked );
239  void showUnplacedToggled( bool checked );
240 
241  private:
242  QPointer< QgsLayoutItemMap > mMapItem;
243 };
244 
245 #endif
QgsLayoutItemMapGrid
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
Definition: qgslayoutitemmapgrid.h:138
qgslayoutitemmapgrid.h
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsLayoutItemBaseWidget::setReportTypeString
virtual void setReportTypeString(const QString &string)
Sets the string to use to describe the current report type (e.g.
Definition: qgslayoutitemwidget.cpp:184
QgsLayoutMapItemBlocksLabelsModel
Definition: qgslayoutmapwidget.h:193
QgsLayoutItemPropertiesWidget
Definition: qgslayoutitemwidget.h:218
qgslayoutitemwidget.h
QgsLayoutModel
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:188
QgsLayoutMapWidget
Definition: qgslayoutmapwidget.h:43
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:112
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsLayoutItemBaseWidget
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:222
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:39
QgsLayoutItemBaseWidget::setMasterLayout
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
Definition: qgslayoutitemwidget.cpp:202
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsLayoutDesignerInterface
Definition: qgslayoutdesignerinterface.h:54
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
Definition: qgslayoutmapwidget.h:223