QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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 "qgsmapunitscale.h"
22#include "qgsfields.h"
23#include "qgswkbtypes.h"
24
26class QgsFeature;
29
34class CORE_EXPORT QgsSymbolRenderContext
35{
36 public:
37
38 //TODO QGIS 4.0 - remove mapUnitScale and renderunit
39
51 QgsSymbolRenderContext( QgsRenderContext &c, Qgis::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() );
52
54
57
61 QgsRenderContext &renderContext() { return mRenderContext; }
62
67 const QgsRenderContext &renderContext() const { return mRenderContext; } SIP_SKIP
68
75 void setOriginalValueVariable( const QVariant &value );
76
81 Q_DECL_DEPRECATED Qgis::RenderUnit outputUnit() const SIP_DEPRECATED { return mOutputUnit; }
82
87 Q_DECL_DEPRECATED void setOutputUnit( Qgis::RenderUnit u ) SIP_DEPRECATED { mOutputUnit = u; }
88
92 Q_DECL_DEPRECATED QgsMapUnitScale mapUnitScale() const SIP_DEPRECATED { return mMapUnitScale; }
93
97 Q_DECL_DEPRECATED void setMapUnitScale( const QgsMapUnitScale &scale ) SIP_DEPRECATED { mMapUnitScale = scale; }
98
104 qreal opacity() const { return mOpacity; }
105
111 void setOpacity( qreal opacity ) { mOpacity = opacity; }
112
117 bool selected() const { return mSelected; }
118
123 void setSelected( bool selected ) { mSelected = selected; }
124
129 Qgis::SymbolRenderHints renderHints() const { return mRenderHints; }
130
135 void setRenderHints( Qgis::SymbolRenderHints hints ) { mRenderHints = hints; }
136
137 void setFeature( const QgsFeature *f ) { mFeature = f; }
138
142 const QgsFeature *feature() const { return mFeature; }
143
149 void setOriginalGeometryType( Qgis::GeometryType type ) { mOriginalGeometryType = type; }
150
159 Qgis::GeometryType originalGeometryType() const { return mOriginalGeometryType; }
160
167 QgsFields fields() const { return mFields; }
168
173 int geometryPartCount() const { return mGeometryPartCount; }
174
179 void setGeometryPartCount( int count ) { mGeometryPartCount = count; }
180
185 int geometryPartNum() const { return mGeometryPartNum; }
186
191 void setGeometryPartNum( int num ) { mGeometryPartNum = num; }
192
196 Q_DECL_DEPRECATED double outputLineWidth( double width ) const SIP_DEPRECATED;
197
201 Q_DECL_DEPRECATED double outputPixelSize( double size ) const SIP_DEPRECATED;
202
203 // workaround for sip 4.7. Don't use assignment - will fail with assertion error
205
211 QgsExpressionContextScope *expressionContextScope();
212
220 void setExpressionContextScope( QgsExpressionContextScope *contextScope SIP_TRANSFER );
221
228 const QgsLegendPatchShape *patchShape() const;
229
236 void setPatchShape( const QgsLegendPatchShape &shape );
237
238 private:
239
240#ifdef SIP_RUN
242#endif
243
244 QgsRenderContext &mRenderContext;
245 std::unique_ptr< QgsExpressionContextScope > mExpressionContextScope;
246 Qgis::RenderUnit mOutputUnit;
247 QgsMapUnitScale mMapUnitScale;
248 qreal mOpacity = 1.0;
249 bool mSelected;
250 Qgis::SymbolRenderHints mRenderHints;
251 const QgsFeature *mFeature; //current feature
252 QgsFields mFields;
253 int mGeometryPartCount;
254 int mGeometryPartNum;
255 Qgis::GeometryType mOriginalGeometryType = Qgis::GeometryType::Unknown;
256 std::unique_ptr< QgsLegendPatchShape > mPatchShape;
257};
258
259
260#endif // QGSSYMBOLRENDERCONTEXT_H
261
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition: qgis.h:228
RenderUnit
Rendering size units.
Definition: qgis.h:3176
Single scope for storing variables and functions for use within a QgsExpressionContext.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Container of fields for a vector layer.
Definition: qgsfields.h:45
Represents a patch shape for use in map legends.
Struct for storing maximum and minimum scales for measurements in map units.
Contains information about the context of a rendering operation.
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
const QgsFeature * feature() const
Returns the current feature being rendered.
Q_DECL_DEPRECATED void setMapUnitScale(const QgsMapUnitScale &scale)
Qgis::GeometryType originalGeometryType() const
Returns the geometry type for the original feature geometry being rendered.
QgsFields fields() const
Fields of the layer.
void setSelected(bool selected)
Sets whether symbols should be rendered using the selected symbol coloring and style.
void setOriginalGeometryType(Qgis::GeometryType type)
Sets the geometry type for the original feature geometry being rendered.
int geometryPartNum() const
Part number of current geometry.
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
Qgis::SymbolRenderHints renderHints() const
Returns the rendering hint flags for the symbol.
Q_DECL_DEPRECATED QgsMapUnitScale mapUnitScale() const
int geometryPartCount() const
Part count of current geometry.
void setRenderHints(Qgis::SymbolRenderHints hints)
Sets rendering hint flags for the symbol.
void setGeometryPartCount(int count)
Sets the part count of current geometry.
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
void setGeometryPartNum(int num)
Sets the part number of current geometry.
Q_DECL_DEPRECATED Qgis::RenderUnit outputUnit() const
Returns the output unit for the context.
QgsSymbolRenderContext(const QgsSymbolRenderContext &rh)=delete
QgsSymbolRenderContext cannot be copied.
Q_DECL_DEPRECATED void setOutputUnit(Qgis::RenderUnit u)
Sets the output unit for the context.
void setFeature(const QgsFeature *f)
qreal opacity() const
Returns the opacity for the symbol.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
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
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_FORCE
Definition: qgis_sip.h:131
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36