QGIS API Documentation  3.23.0-Master (dd0cd13a00)
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 
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 
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.
Q_DECL_DEPRECATED void setMapUnitScale(const QgsMapUnitScale &scale)
QgsFields fields() const
Fields of the layer.
void setSelected(bool selected)
Sets whether symbols should be rendered using the selected symbol coloring and style.
Q_DECL_DEPRECATED QgsUnitTypes::RenderUnit outputUnit() const
Returns the output unit for the context.
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.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Q_DECL_DEPRECATED QgsMapUnitScale mapUnitScale() const
int geometryPartCount() const
Part count of current geometry.
QgsWkbTypes::GeometryType originalGeometryType() const
Returns the geometry type for the original feature geometry being rendered.
const QgsFeature * feature() const
Returns the current feature being rendered.
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
void setRenderHints(Qgis::SymbolRenderHints hints)
Sets rendering hint flags for the symbol.
void setGeometryPartCount(int count)
Sets the part count of current geometry.
void setGeometryPartNum(int num)
Sets the part number of current geometry.
void setOriginalGeometryType(QgsWkbTypes::GeometryType type)
Sets the geometry type for the original feature geometry being rendered.
QgsSymbolRenderContext(const QgsSymbolRenderContext &rh)=delete
QgsSymbolRenderContext cannot be copied.
void setFeature(const QgsFeature *f)
qreal opacity() const
Returns the opacity for the symbol.
Q_DECL_DEPRECATED void setOutputUnit(QgsUnitTypes::RenderUnit u)
Sets the output unit for the context.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
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