QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
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.h"
20#include "qgis_core.h"
21#include "qgsfields.h"
22#include "qgsmapunitscale.h"
23
25class QgsFeature;
28
34class CORE_EXPORT QgsSymbolRenderContext
35{
36 public:
37 //TODO QGIS 5.0 - remove mapUnitScale and renderunit
38
53 qreal opacity = 1.0,
54 bool selected = false,
56 const QgsFeature *f = nullptr,
57 const QgsFields &fields = QgsFields(),
59 );
60
62
64
68 QgsRenderContext &renderContext() { return mRenderContext; }
69
74 const QgsRenderContext &renderContext() const SIP_SKIP { return mRenderContext; }
75
81 void setOriginalValueVariable( const QVariant &value );
82
87 Q_DECL_DEPRECATED Qgis::RenderUnit outputUnit() const SIP_DEPRECATED { return mOutputUnit; }
88
93 Q_DECL_DEPRECATED void setOutputUnit( Qgis::RenderUnit u ) SIP_DEPRECATED { mOutputUnit = u; }
94
98 Q_DECL_DEPRECATED QgsMapUnitScale mapUnitScale() const SIP_DEPRECATED { return mMapUnitScale; }
99
103 Q_DECL_DEPRECATED void setMapUnitScale( const QgsMapUnitScale &scale ) SIP_DEPRECATED { mMapUnitScale = scale; }
104
110 qreal opacity() const { return mOpacity; }
111
117 void setOpacity( qreal opacity ) { mOpacity = opacity; }
118
123 bool selected() const { return mSelected; }
124
129 void setSelected( bool selected ) { mSelected = selected; }
130
135 Qgis::SymbolRenderHints renderHints() const { return mRenderHints; }
136
143 bool forceVectorRendering() const;
144
149 void setRenderHints( Qgis::SymbolRenderHints hints ) { mRenderHints = hints; }
150
157 void setRenderHint( Qgis::SymbolRenderHint hint, bool enabled = true ) { mRenderHints.setFlag( hint, enabled ); }
158
159 void setFeature( const QgsFeature *f ) { mFeature = f; }
160
164 const QgsFeature *feature() const { return mFeature; }
165
170 void setOriginalGeometryType( Qgis::GeometryType type ) { mOriginalGeometryType = type; }
171
179 Qgis::GeometryType originalGeometryType() const { return mOriginalGeometryType; }
180
186 QgsFields fields() const { return mFields; }
187
191 int geometryPartCount() const { return mGeometryPartCount; }
192
196 void setGeometryPartCount( int count ) { mGeometryPartCount = count; }
197
201 int geometryPartNum() const { return mGeometryPartNum; }
202
206 void setGeometryPartNum( int num ) { mGeometryPartNum = num; }
207
211 Q_DECL_DEPRECATED double outputLineWidth( double width ) const SIP_DEPRECATED;
212
216 Q_DECL_DEPRECATED double outputPixelSize( double size ) const SIP_DEPRECATED;
217
218 // workaround for sip 4.7. Don't use assignment - will fail with assertion error
220
226 QgsExpressionContextScope *expressionContextScope();
227
235 void setExpressionContextScope( QgsExpressionContextScope *contextScope SIP_TRANSFER );
236
243 const QgsLegendPatchShape *patchShape() const;
244
251 void setPatchShape( const QgsLegendPatchShape &shape );
252
253 private:
254#ifdef SIP_RUN
256#endif
257
258 QgsRenderContext &mRenderContext;
259 std::unique_ptr< QgsExpressionContextScope > mExpressionContextScope;
260 Qgis::RenderUnit mOutputUnit;
261 QgsMapUnitScale mMapUnitScale;
262 qreal mOpacity = 1.0;
263 bool mSelected;
264 Qgis::SymbolRenderHints mRenderHints;
265 const QgsFeature *mFeature; //current feature
266 QgsFields mFields;
267 int mGeometryPartCount = 0;
268 int mGeometryPartNum = 0;
269 Qgis::GeometryType mOriginalGeometryType = Qgis::GeometryType::Unknown;
270 std::unique_ptr< QgsLegendPatchShape > mPatchShape;
271};
272
273
274#endif // QGSSYMBOLRENDERCONTEXT_H
SymbolRenderHint
Flags controlling behavior of symbols during rendering.
Definition qgis.h:795
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:379
@ Unknown
Unknown types.
Definition qgis.h:383
RenderUnit
Rendering size units.
Definition qgis.h:5340
QFlags< SymbolRenderHint > SymbolRenderHints
Symbol render hints.
Definition qgis.h:803
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:60
Container of fields for a vector layer.
Definition qgsfields.h:46
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.
Encapsulates the context in which a symbol is being rendered.
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
void setRenderHint(Qgis::SymbolRenderHint hint, bool enabled=true)
Sets a rendering hint flag 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.
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())
Constructor for QgsSymbolRenderContext.
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
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:113
#define SIP_FORCE
Definition qgis_sip.h:138
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35