QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsmasksymbollayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmasksymbollayer.h
3  ---------------------
4  begin : July 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 
16 #ifndef QGSMASKSYMBOLLAYER_H
17 #define QGSMASKSYMBOLLAYER_H
18 
19 #include "qgis_core.h"
20 #include "qgis.h"
21 #include "qgssymbollayer.h"
23 
24 class QgsPaintEffect;
25 
34 {
35  public:
38 
46  static QgsSymbolLayer *create( const QgsStringMap &properties = QgsStringMap() ) SIP_FACTORY;
47 
48  QgsMaskMarkerSymbolLayer *clone() const override SIP_FACTORY;
49  QgsSymbol *subSymbol() override { return mSymbol.get(); }
50  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
51  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
52  bool hasDataDefinedProperties() const override;
53 
54  QgsStringMap properties() const override;
55 
56  QString layerType() const override;
57  void startRender( QgsSymbolRenderContext &context ) override;
58  void stopRender( QgsSymbolRenderContext &context ) override;
59  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
60  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
61 
62  virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
63 
65  bool enabled() const { return ! mMaskedSymbolLayers.isEmpty(); }
66 
72  QgsSymbolLayerReferenceList masks() const override { return mMaskedSymbolLayers; }
73 
79  void setMasks( QgsSymbolLayerReferenceList maskedLayers ) { mMaskedSymbolLayers = maskedLayers; }
80 
81  private:
82 #ifdef SIP_RUN
84 #endif
85 
87  std::unique_ptr<QgsMarkerSymbol> mSymbol;
88 
90  QgsSymbolLayerReferenceList mMaskedSymbolLayers;
91 
92  std::unique_ptr<QgsPaintEffect> mEffect;
93 };
94 
95 #endif
96 
97 
QgsSymbolLayer::setSubSymbol
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Definition: qgssymbollayer.h:356
QgsMaskMarkerSymbolLayer::enabled
bool enabled() const
Whether some masked symbol layers are defined.
Definition: qgsmasksymbollayer.h:65
QgsSymbolLayer::hasDataDefinedProperties
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Definition: qgssymbollayer.cpp:216
QgsMarkerSymbolLayer::startRender
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Definition: qgssymbollayer.cpp:447
qgis.h
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsMarkerSymbolLayer
Abstract base class for marker symbol layers.
Definition: qgssymbollayer.h:582
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:64
QgsMarkerSymbolLayer::drawPreviewIcon
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override
Definition: qgssymbollayer.cpp:457
QgsSymbolLayer::properties
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
qgssymbollayerreference.h
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSymbolRenderContext
Definition: qgssymbol.h:695
QgsSymbolLayer::clone
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolLayer
Definition: qgssymbollayer.h:53
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgssymbollayer.h
QgsSymbolLayer::usedAttributes
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Definition: qgssymbollayer.cpp:247
QgsMaskMarkerSymbolLayer::masks
QgsSymbolLayerReferenceList masks() const override
Returns a list of references to symbol layers that are masked by the sub symbol's shape.
Definition: qgsmasksymbollayer.h:72
QgsMaskMarkerSymbolLayer::subSymbol
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Definition: qgsmasksymbollayer.h:49
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
QgsSymbolLayerReferenceList
QList< QgsSymbolLayerReference > QgsSymbolLayerReferenceList
Definition: qgssymbollayerreference.h:160
QgsMaskMarkerSymbolLayer::setMasks
void setMasks(QgsSymbolLayerReferenceList maskedLayers)
Sets the symbol layers that will be masked by the sub symbol's shape.
Definition: qgsmasksymbollayer.h:79
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:54
QgsMarkerSymbolLayer::renderPoint
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QgsMarkerSymbolLayer::bounds
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QgsSymbolLayer::layerType
virtual QString layerType() const =0
Returns a string that represents this layer type.
QgsMaskMarkerSymbolLayer
Special symbol layer that uses its sub symbol as a selective mask.
Definition: qgsmasksymbollayer.h:34
QgsMarkerSymbolLayer::stopRender
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
Definition: qgssymbollayer.cpp:452