QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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  signals:
58  void widgetChanged();
59 
60  protected:
61 
62  void showEvent( QShowEvent * ) override;
63 
64  private slots:
65 
69  void onSelectionChanged();
70 
71  private:
72  QgsVectorLayer *mLayer = nullptr;
74  void populate();
75 
76  QPointer<QgsMessageBarItem> mMessageBarItem;
77  bool mMustPopulate = false;
78 };
79 
80 
88 class SymbolLayerVisitor : public QgsStyleEntityVisitorInterface
89 {
90  public:
91  typedef std::function<void( const QgsSymbolLayer *, const QgsSymbolLayerId & )> SymbolLayerCallback;
92 
94  SymbolLayerVisitor( SymbolLayerCallback callback );
95 
96  bool visitEnter( const QgsStyleEntityVisitorInterface::Node &node ) override;
97 
99  void visitSymbol( const QgsSymbol *symbol, const QString &leafIdentifier, QVector<int> rootPath );
100 
101  bool visit( const QgsStyleEntityVisitorInterface::StyleLeaf &leaf ) override;
102 
103  private:
104  QString mSymbolKey;
105  QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> mMasks;
106  SymbolLayerCallback mCallback;
107 };
108 
110 
111 #endif
Represents an item shown within a QgsMessageBar widget.
Base class for any widget that can be shown as a inline panel.
void widgetChanged()
Emitted when the widget state changes.
An interface for classes which can visit style entity (e.g.
virtual bool visitEnter(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor starts visiting a node.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
We may need stable references to symbol layers, when pointers to symbol layers is not usable (when a ...
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
Represents a vector layer which manages a vector based data sets.
Contains information relating to a node (i.e.
Contains information relating to the style entity currently being visited.