QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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  protected:
109  bool setNewItem( QgsLayoutItem *item ) override;
110 
111  protected slots:
113  void populateDataDefinedButtons();
114 
115  private slots:
116 
118  void updateGuiElements();
119 
121  void atlasLayerChanged( QgsVectorLayer *layer );
122 
124  void compositionAtlasToggled( bool atlasEnabled );
125 
126  void aboutToShowKeepLayersVisibilityPresetsMenu();
127 
128  void followVisibilityPresetSelected( int currentIndex );
129  void keepLayersVisibilityPresetSelected();
130 
131  void onMapThemesChanged();
132 
133  void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
134  void overviewSymbolChanged();
135  void showLabelSettings();
136  void switchToMoveContentTool();
137  void aboutToShowBookmarkMenu();
138 
139  private:
140  QPointer< QgsLayoutItemMap > mMapItem;
141  QgsMapCanvas *mMapCanvas = nullptr;
142  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
143  QgsLayoutDesignerInterface *mInterface = nullptr;
144  QPointer< QgsLayoutMapLabelingWidget > mLabelWidget;
145  QMenu *mBookmarkMenu = nullptr;
146  QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
147 
149  void updateComposerExtentFromGui();
150 
152  void blockAllSignals( bool b );
153 
154  void rotationChanged( double value );
155 
157  void toggleAtlasScalingOptionsByLayerType();
158 
160  void updateMapForAtlas();
161 
163  bool hasPredefinedScales() const;
164 
165  QListWidgetItem *addGridListItem( const QString &id, const QString &name );
166 
167  void loadGridEntries();
168 
169  QListWidgetItem *addOverviewListItem( const QString &id, const QString &name );
170 
171  void loadOverviewEntries();
172 
173  void storeCurrentLayerSet();
174 
179  QList<QgsMapLayer *> orderedPresetVisibleLayers( const QString &name ) const;
180 
181 };
182 
190 class GUI_EXPORT QgsLayoutMapItemBlocksLabelsModel : public QSortFilterProxyModel
191 {
192  Q_OBJECT
193 
194  public:
196  explicit QgsLayoutMapItemBlocksLabelsModel( QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
197 
198  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
199  QVariant data( const QModelIndex &index, int role ) const override;
200  bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
201  Qt::ItemFlags flags( const QModelIndex &index ) const override;
202 
203  protected:
204 
205  bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
206 
207  private:
208  QgsLayoutModel *mLayoutModel = nullptr;
209  QPointer< QgsLayoutItemMap > mMapItem;
210 
211 };
212 
220 class GUI_EXPORT QgsLayoutMapLabelingWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapLabelingWidgetBase
221 {
222  Q_OBJECT
223 
224  public:
227 
228  protected:
229  bool setNewItem( QgsLayoutItem *item ) override;
230 
231  private slots:
232  void updateGuiElements();
233  void labelMarginChanged( double val );
234  void labelMarginUnitsChanged();
235  void showPartialsToggled( bool checked );
236  void showUnplacedToggled( bool checked );
237 
238  private:
239  QPointer< QgsLayoutItemMap > mMapItem;
240 };
241 
242 #endif
Base class for all map layer types.
Definition: qgsmaplayer.h:79
virtual void setDesignerInterface(QgsLayoutDesignerInterface *iface)
Sets the the layout designer interface in which the widget is being shown.
Base class for graphical items within a QgsLayout.
An individual overview which is drawn above the map content in a QgsLayoutItemMap, and shows the extent of another QgsLayoutItemMap.
Input widget for the configuration of QgsLayoutItemMap.
A widget for controlling the common properties of layout items (e.g.
A common interface for layout designer dialogs and widgets.
const QgsCoordinateReferenceSystem & crs
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:75
Layout graphical items for displaying a map.
Allows configuration of layout map labeling settings.
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.
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
A base class for property widgets for layout items.
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
This class represents a coordinate reference system (CRS).
A model for items attached to a layout.
Model for label blocking items.
Interface for master layout type objects, such as print layouts and reports.
Represents a vector layer which manages a vector based data sets.