QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
39 void QgsMaskingWidget::onSelectionChanged()
42 bool printMessage = mMaskTargetsWidget->selection().empty() != mMaskSourcesWidget->selection().empty();
44 if ( mMessageBarItem && !printMessage )
46 mMessageBar->popWidget( mMessageBarItem );
47 delete mMessageBarItem;
49 else if ( !mMessageBarItem && printMessage )
51 mMessageBarItem =
new QgsMessageBarItem( tr(
"Select both sources and symbol layers or your configuration will be lost" ),
Qgis::Warning, 0,
this );
52 mMessageBar->pushItem( mMessageBarItem );
68 mMustPopulate =
false;
110 QVector<int> indexPath = rootPath;
111 indexPath.push_back( idx );
115 mCallback( sl,
QgsSymbolLayerId( mSymbolKey + leafIdentifier, indexPath ) );
120 visitSymbol( subSymbol, leafIdentifier, indexPath );
129 if ( symbolEntity->symbol() )
137 QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> mMasks;
155 QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> mMasks;
158 if ( ! sl->
masks().isEmpty() )
159 mMasks.push_back( qMakePair( lid, sl->
masks() ) );
167 if ( mLayer != layer )
170 mMustPopulate =
true;
174 void QgsMaskingWidget::populate()
176 mMaskSourcesWidget->update();
177 mMaskTargetsWidget->setLayer( mLayer );
180 QSet<QgsSymbolLayerId> maskedSymbolLayers;
181 QList<QgsMaskSourceSelectionWidget::MaskSource> maskSources;
185 for (
auto layerIt = layers.begin(); layerIt != layers.end(); layerIt++ )
187 QString layerId = layerIt.key();
188 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layerIt.value() );
193 QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> slMasks =
symbolLayerMasks( vl );
194 for (
auto p : slMasks )
207 maskSources.append( source );
214 for (
auto it = labelMasks.begin(); it != labelMasks.end(); it++ )
216 const QString &ruleKey = it.key();
217 for (
auto it2 = it.value().begin(); it2 != it.value().end(); it2++ )
219 if ( it2.key() == mLayer->
id() )
222 maskedSymbolLayers.unite( it2.value() );
227 maskSources.append( source );
233 mMaskSourcesWidget->setSelection( maskSources );
234 mMaskTargetsWidget->setSelection( maskedSymbolLayers );
239 QList<QgsMaskSourceSelectionWidget::MaskSource> maskSources = mMaskSourcesWidget->selection();
240 QSet<QgsSymbolLayerId> maskedSymbolLayers = mMaskTargetsWidget->selection();
242 QSet<QString> layersToRefresh;
245 for (
auto layerIt = layers.begin(); layerIt != layers.end(); layerIt++ )
247 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layerIt.value() );
257 QgsMaskMarkerSymbolLayer *maskSl = const_cast<QgsMaskMarkerSymbolLayer *>( static_cast<const QgsMaskMarkerSymbolLayer *>( sl ) );
259 QgsSymbolLayerReferenceList masks = maskSl->masks();
260 QgsSymbolLayerReferenceList newMasks;
261 for ( const QgsSymbolLayerReference &ref : masks )
264 if ( ref.layerId() != mLayer->id() )
265 newMasks.append( ref );
272 for ( const QgsSymbolLayerId &maskedId : maskedSymbolLayers )
274 newMasks.append( QgsSymbolLayerReference( mLayer->id(), maskedId ) );
277 layersToRefresh.insert( source.
layerId );
280 maskSl->setMasks( newMasks );
302 if ( ref.
layerId() != mLayer->id() )
303 newMasks.append( ref );
316 layersToRefresh.insert( source.
layerId );
327 mLayer->triggerRepaint();
329 for ( QString layerId : layersToRefresh )
338 return !mMustPopulate;
bool enabled() const
Returns whether the mask is enabled.
bool visitEnter(const QgsStyleEntityVisitorInterface::Node &node) override
Called when the visitor starts visiting a node.
A symbol entity for QgsStyle databases.
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
Type used to refer to a specific symbol layer in a symbol of a layer.
Generic visitor that collects symbol layers of a vector layer's renderer and call a callback function...
static QgsProject * instance()
Returns the QgsProject singleton instance.
An interface for classes which can visit style entity (e.g.
Abstract base class for all rendered symbols.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
void visitSymbol(const QgsSymbol *symbol, const QString &leafIdentifier, QVector< int > rootPath)
Process a symbol.
Contains information relating to the style entity currently being visited.
virtual void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString())=0
Set pal settings for a specific provider (takes ownership).
static QHash< QString, QHash< QString, QSet< QgsSymbolLayerId > > > labelMasks(const QgsVectorLayer *)
Returns masks defined in labeling options of a layer.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
Container for all settings relating to text rendering.
Represents an item shown within a QgsMessageBar widget.
virtual QStringList subProviders() const
Gets list of sub-providers within the layer's labeling.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
virtual QgsStyle::StyleEntity type() const =0
Returns the type of style entity.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
void setDirty(bool b=true)
Flag the project as dirty (modified).
@ SymbolRule
Rule based symbology or label child rule.
Contains information relating to a node (i.e.
QgsSymbolLayerId symbolLayerId() const
The symbol layer's id.
QgsSymbolLayerReferenceList maskedSymbolLayers() const
Returns a list of references to symbol layers that are masked by this buffer.
const QgsStyleEntityInterface * entity
Reference to style entity being visited.
QgsTextMaskSettings & mask()
Returns a reference to the masking settings.
virtual QgsSymbolLayerReferenceList masks() const
Returns masks defined by this symbol layer.
void setMaskedSymbolLayers(QgsSymbolLayerReferenceList maskedLayers)
Sets the symbol layers that will be masked by this buffer.
QString identifier
A string identifying the style entity.
QList< QgsSymbolLayerReference > QgsSymbolLayerReferenceList
Represents a vector layer which manages a vector based data sets.
Base class for all map layer types.
std::function< void(const QgsSymbolLayer *, const QgsSymbolLayerId &)> SymbolLayerCallback
SymbolLayerVisitor(SymbolLayerCallback callback)
constructor
We may need stable references to symbol layers, when pointers to symbol layers is not usable (when a ...
virtual QString layerType() const =0
Returns a string that represents this layer type.
QString symbolKey() const
Returns the key associated to the symbol.
bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &leaf) override
Called when the visitor will visit a style entity.
QString layerId() const
The referenced vector layer / feature renderer.
QString identifier
A string identifying the node.
virtual QgsPalLayerSettings settings(const QString &providerId=QString()) const =0
Gets associated label settings.
QgsStyleEntityVisitorInterface::NodeType type
Node type.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
QgsFeatureRenderer * renderer()
Returns renderer.