QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsmaskingwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaskingwidget.h
3  ---------------------
4  begin : September 2019
5  copyright : (C) 2019 by Hugo Mercier
6  email : hugo dot mercier at oslandia dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSMASKINGWIDGET_H
16 #define QGSMASKINGWIDGET_H
17 
18 // We don't want to expose this in the public API
19 #define SIP_NO_FILE
20 
22 
23 #include <QPointer>
24 
25 #include "qgspanelwidget.h"
26 #include "ui_qgsmaskingwidgetbase.h"
27 #include "qgsstyleentityvisitor.h"
28 #include "qgis_sip.h"
29 #include "qgis_gui.h"
30 
31 class QgsMessageBarItem;
32 
40 class GUI_EXPORT QgsMaskingWidget: public QgsPanelWidget, private Ui::QgsMaskingWidgetBase
41 {
42  Q_OBJECT
43  public:
45  QgsMaskingWidget( QWidget *parent = nullptr );
46 
48  void setLayer( QgsVectorLayer *layer );
49 
51  void apply();
52 
54  bool hasBeenPopulated();
55 
56  protected:
57 
58  void showEvent( QShowEvent * ) override;
59 
60  private slots:
61 
65  void onSelectionChanged();
66 
67  private:
68  QgsVectorLayer *mLayer = nullptr;
70  void populate();
71 
72  QPointer<QgsMessageBarItem> mMessageBarItem;
73  bool mMustPopulate = false;
74 };
75 
76 
84 class SymbolLayerVisitor : public QgsStyleEntityVisitorInterface
85 {
86  public:
87  typedef std::function<void( const QgsSymbolLayer *, const QgsSymbolLayerId & )> SymbolLayerCallback;
88 
90  SymbolLayerVisitor( SymbolLayerCallback callback );
91 
92  bool visitEnter( const QgsStyleEntityVisitorInterface::Node &node ) override;
93 
95  void visitSymbol( const QgsSymbol *symbol, const QString &leafIdentifier, QVector<int> rootPath );
96 
97  bool visit( const QgsStyleEntityVisitorInterface::StyleLeaf &leaf ) override;
98 
99  private:
100  QString mSymbolKey;
101  QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> mMasks;
102  SymbolLayerCallback mCallback;
103 };
104 
106 
107 #endif
QgsStyleEntityVisitorInterface
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
Definition: qgsstyleentityvisitor.h:33
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:92
QgsStyleEntityVisitorInterface::StyleLeaf
Contains information relating to the style entity currently being visited.
Definition: qgsstyleentityvisitor.h:60
QgsSymbolLayer
Definition: qgssymbollayer.h:54
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsMessageBarItem
Represents an item shown within a QgsMessageBar widget.
Definition: qgsmessagebaritem.h:38
qgis_sip.h
QgsStyleEntityVisitorInterface::Node
Contains information relating to a node (i.e.
Definition: qgsstyleentityvisitor.h:110
QgsStyleEntityVisitorInterface::visitEnter
virtual bool visitEnter(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor starts visiting a node.
Definition: qgsstyleentityvisitor.h:169
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsStyleEntityVisitorInterface::visit
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
Definition: qgsstyleentityvisitor.h:153
QgsSymbolLayerId
We may need stable references to symbol layers, when pointers to symbol layers is not usable (when a ...
Definition: qgssymbollayerreference.h:53
qgspanelwidget.h
qgsstyleentityvisitor.h