QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgssymbolrendercontext.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolrendercontext.h
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk 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 QGSSYMBOLRENDERCONTEXT_H
17 #define QGSSYMBOLRENDERCONTEXT_H
18 
19 #include "qgis_core.h"
20 #include "qgis.h"
21 #include "qgsunittypes.h"
22 #include "qgsmapunitscale.h"
23 #include "qgsfields.h"
24 #include "qgswkbtypes.h"
25 
26 class QgsRenderContext;
27 class QgsFeature;
30 
35 class CORE_EXPORT QgsSymbolRenderContext
36 {
37  public:
38 
39  //TODO QGIS 4.0 - remove mapUnitScale and renderunit
40 
52  QgsSymbolRenderContext( QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal opacity = 1.0, bool selected = false, Qgis::SymbolRenderHints renderHints = Qgis::SymbolRenderHints(), const QgsFeature *f = nullptr, const QgsFields &fields = QgsFields(), const QgsMapUnitScale &mapUnitScale = QgsMapUnitScale() );
53 
55 
57  QgsSymbolRenderContext( const QgsSymbolRenderContext &rh ) = delete;
58 
62  QgsRenderContext &renderContext() { return mRenderContext; }
63 
68  const QgsRenderContext &renderContext() const { return mRenderContext; } SIP_SKIP
69 
76  void setOriginalValueVariable( const QVariant &value );
77 
82  Q_DECL_DEPRECATED QgsUnitTypes::RenderUnit outputUnit() const SIP_DEPRECATED { return mOutputUnit; }
83 
88  Q_DECL_DEPRECATED void setOutputUnit( QgsUnitTypes::RenderUnit u ) SIP_DEPRECATED { mOutputUnit = u; }
89 
93  Q_DECL_DEPRECATED QgsMapUnitScale mapUnitScale() const SIP_DEPRECATED { return mMapUnitScale; }
94 
98  Q_DECL_DEPRECATED void setMapUnitScale( const QgsMapUnitScale &scale ) SIP_DEPRECATED { mMapUnitScale = scale; }
99 
105  qreal opacity() const { return mOpacity; }
106 
112  void setOpacity( qreal opacity ) { mOpacity = opacity; }
113 
118  bool selected() const { return mSelected; }
119 
124  void setSelected( bool selected ) { mSelected = selected; }
125 
130  Qgis::SymbolRenderHints renderHints() const { return mRenderHints; }
131 
136  void setRenderHints( Qgis::SymbolRenderHints hints ) { mRenderHints = hints; }
137 
138  void setFeature( const QgsFeature *f ) { mFeature = f; }
139 
143  const QgsFeature *feature() const { return mFeature; }
144 
150  void setOriginalGeometryType( QgsWkbTypes::GeometryType type ) { mOriginalGeometryType = type; }
151 
160  QgsWkbTypes::GeometryType originalGeometryType() const { return mOriginalGeometryType; }
161 
168  QgsFields fields() const { return mFields; }
169 
174  int geometryPartCount() const { return mGeometryPartCount; }
175 
180  void setGeometryPartCount( int count ) { mGeometryPartCount = count; }
181 
186  int geometryPartNum() const { return mGeometryPartNum; }
187 
192  void setGeometryPartNum( int num ) { mGeometryPartNum = num; }
193 
197  Q_DECL_DEPRECATED double outputLineWidth( double width ) const SIP_DEPRECATED;
198 
202  Q_DECL_DEPRECATED double outputPixelSize( double size ) const SIP_DEPRECATED;
203 
204  // workaround for sip 4.7. Don't use assignment - will fail with assertion error
205  QgsSymbolRenderContext &operator=( const QgsSymbolRenderContext & );
206 
212  QgsExpressionContextScope *expressionContextScope();
213 
221  void setExpressionContextScope( QgsExpressionContextScope *contextScope SIP_TRANSFER );
222 
229  const QgsLegendPatchShape *patchShape() const;
230 
237  void setPatchShape( const QgsLegendPatchShape &shape );
238 
239  private:
240 
241 #ifdef SIP_RUN
243 #endif
244 
245  QgsRenderContext &mRenderContext;
246  std::unique_ptr< QgsExpressionContextScope > mExpressionContextScope;
247  QgsUnitTypes::RenderUnit mOutputUnit;
248  QgsMapUnitScale mMapUnitScale;
249  qreal mOpacity = 1.0;
250  bool mSelected;
251  Qgis::SymbolRenderHints mRenderHints;
252  const QgsFeature *mFeature; //current feature
253  QgsFields mFields;
254  int mGeometryPartCount;
255  int mGeometryPartNum;
257  std::unique_ptr< QgsLegendPatchShape > mPatchShape;
258 };
259 
260 
261 #endif // QGSSYMBOLRENDERCONTEXT_H
262 
qgsfields.h
QgsSymbolRenderContext::setOpacity
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
Definition: qgssymbolrendercontext.h:112
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsSymbolRenderContext::outputUnit
Q_DECL_DEPRECATED QgsUnitTypes::RenderUnit outputUnit() const
Returns the output unit for the context.
Definition: qgssymbolrendercontext.h:82
QgsSymbolRenderContext::feature
const QgsFeature * feature() const
Returns the current feature being rendered.
Definition: qgssymbolrendercontext.h:143
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsSymbolRenderContext::setSelected
void setSelected(bool selected)
Sets whether symbols should be rendered using the selected symbol coloring and style.
Definition: qgssymbolrendercontext.h:124
QgsSymbolRenderContext::setGeometryPartNum
void setGeometryPartNum(int num)
Sets the part number of current geometry.
Definition: qgssymbolrendercontext.h:192
QgsSymbolRenderContext::opacity
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbolrendercontext.h:105
qgis.h
QgsSymbolRenderContext::geometryPartCount
int geometryPartCount() const
Part count of current geometry.
Definition: qgssymbolrendercontext.h:174
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsSymbolRenderContext::setOutputUnit
Q_DECL_DEPRECATED void setOutputUnit(QgsUnitTypes::RenderUnit u)
Sets the output unit for the context.
Definition: qgssymbolrendercontext.h:88
qgsunittypes.h
QgsSymbolRenderContext::setFeature
void setFeature(const QgsFeature *f)
Definition: qgssymbolrendercontext.h:138
QgsLegendPatchShape
Represents a patch shape for use in map legends.
Definition: qgslegendpatchshape.h:33
QgsSymbolRenderContext::selected
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
Definition: qgssymbolrendercontext.h:118
QgsSymbolRenderContext
Definition: qgssymbolrendercontext.h:35
QgsSymbolRenderContext::originalGeometryType
QgsWkbTypes::GeometryType originalGeometryType() const
Returns the geometry type for the original feature geometry being rendered.
Definition: qgssymbolrendercontext.h:160
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsSymbolRenderContext::renderContext
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
Definition: qgssymbolrendercontext.h:68
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsSymbolRenderContext::fields
QgsFields fields() const
Fields of the layer.
Definition: qgssymbolrendercontext.h:168
QgsSymbolRenderContext::setRenderHints
void setRenderHints(Qgis::SymbolRenderHints hints)
Sets rendering hint flags for the symbol.
Definition: qgssymbolrendercontext.h:136
QgsSymbolRenderContext::setGeometryPartCount
void setGeometryPartCount(int count)
Sets the part count of current geometry.
Definition: qgssymbolrendercontext.h:180
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext....
Definition: qgsexpressioncontext.h:113
QgsSymbolRenderContext::setOriginalGeometryType
void setOriginalGeometryType(QgsWkbTypes::GeometryType type)
Sets the geometry type for the original feature geometry being rendered.
Definition: qgssymbolrendercontext.h:150
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
SIP_FORCE
#define SIP_FORCE
Definition: qgis_sip.h:131
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1
QgsSymbolRenderContext::setMapUnitScale
Q_DECL_DEPRECATED void setMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgssymbolrendercontext.h:98
QgsWkbTypes::UnknownGeometry
@ UnknownGeometry
Definition: qgswkbtypes.h:145
qgsmapunitscale.h
QgsSymbolRenderContext::renderHints
Qgis::SymbolRenderHints renderHints() const
Returns the rendering hint flags for the symbol.
Definition: qgssymbolrendercontext.h:130
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsSymbolRenderContext::renderContext
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Definition: qgssymbolrendercontext.h:62
qgswkbtypes.h
QgsSymbolRenderContext::geometryPartNum
int geometryPartNum() const
Part number of current geometry.
Definition: qgssymbolrendercontext.h:186
QgsSymbolRenderContext::mapUnitScale
Q_DECL_DEPRECATED QgsMapUnitScale mapUnitScale() const
Definition: qgssymbolrendercontext.h:93