QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgsselectivemaskingsource.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsselectivemaskingsource.h
3 ---------------------------
4 begin : January 2026
5 copyright : (C) 2026 by Nyall Dawson
6 email : nyall dot dawson at gmail 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
16#ifndef QGSSELECTIVEMASKINGSOURCE_H
17#define QGSSELECTIVEMASKINGSOURCE_H
18
19#include "qgis.h"
20#include "qgis_core.h"
21#include "qgis_sip.h"
22
23#include <QString>
24
25using namespace Qt::StringLiterals;
26
35class CORE_EXPORT QgsSelectiveMaskSource
36{
37 public:
42
50 QgsSelectiveMaskSource( const QString &layerId, Qgis::SelectiveMaskSourceType sourceType, const QString &sourceId = QString() );
51
55 bool isValid() const { return !mLayerId.isEmpty(); }
56
62 QString layerId() const { return mLayerId; }
63
69 void setLayerId( const QString &id ) { mLayerId = id; }
70
76 Qgis::SelectiveMaskSourceType sourceType() const { return mSourceType; }
77
83 void setSourceType( Qgis::SelectiveMaskSourceType type ) { mSourceType = type; }
84
90 QString sourceId() const { return mSourceId; }
91
97 void setSourceId( const QString &id ) { mSourceId = id; }
98
99#ifdef SIP_RUN
100 // clang-format off
101 SIP_PYOBJECT __repr__();
102 % MethodCode
103 if ( !sipCpp->isValid() )
104 {
105 sipRes = PyUnicode_FromString( "<QgsSelectiveMaskSource: invalid>" );
106 }
107 else if ( sipCpp->sourceId().isEmpty() )
108 {
109 const QString str = u"<QgsSelectiveMaskSource: %1 (%2)>"_s.arg(
110 sipCpp->layerId(),
111 qgsEnumValueToKey( sipCpp->sourceType() ) );
112 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
113 }
114 else
115 {
116 const QString str = u"<QgsSelectiveMaskSource: %1 - %2 (%3)>"_s.arg(
117 sipCpp->layerId(),
118 sipCpp->sourceId(),
119 qgsEnumValueToKey( sipCpp->sourceType() ) );
120 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
121 }
122 % End
123// clang-format on
124#endif
125
126 bool operator==( const QgsSelectiveMaskSource &other ) const
127 = default;
128 bool operator!=( const QgsSelectiveMaskSource &other ) const = default;
129
130 private:
131 QString mLayerId;
133 QString mSourceId;
134};
135
136#endif //QGSSELECTIVEMASKINGSOURCE_H
SelectiveMaskSourceType
Selective masking source types.
Definition qgis.h:3168
@ SymbolLayer
A mask generated from a symbol layer.
Definition qgis.h:3169
QString layerId() const
Returns the source layer id.
QgsSelectiveMaskSource()=default
Constructor for an invalid QgsSelectiveMaskSource.
void setSourceId(const QString &id)
Sets the symbol layer or label rule id.
void setLayerId(const QString &id)
Sets the source layer id.
bool isValid() const
Returns true if the source is valid (i.e.
bool operator!=(const QgsSelectiveMaskSource &other) const =default
Qgis::SelectiveMaskSourceType sourceType() const
Returns the type of masking source.
void setSourceType(Qgis::SelectiveMaskSourceType type)
Sets the source type.
QString sourceId() const
Returns the symbol layer or label rule ID.
bool operator==(const QgsSelectiveMaskSource &other) const =default
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:7157