QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgssymbolrendercontext.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgssymbolrendercontext.cpp
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
17
18#include <memory>
19
20#include "qgslegendpatchshape.h"
21#include "qgsrendercontext.h"
22
24 : mRenderContext( c )
25 , mOutputUnit( u )
26 , mMapUnitScale( mapUnitScale )
27 , mOpacity( opacity )
28 , mSelected( selected )
29 , mRenderHints( renderHints )
30 , mFeature( f )
31 , mFields( fields )
32 , mGeometryPartCount( 0 )
33 , mGeometryPartNum( 0 )
34{
35}
36
38
40{
41 mRenderContext.expressionContext().setOriginalValueVariable( value );
42}
43
45{
46 return mRenderContext.rasterizedRenderingPolicy() != Qgis::RasterizedRenderingPolicy::Default
47 || mRenderHints.testFlag( Qgis::SymbolRenderHint::ForceVectorRendering );
48}
49
50double QgsSymbolRenderContext::outputLineWidth( double width ) const
51{
52 return mRenderContext.convertToPainterUnits( width, mOutputUnit, mMapUnitScale );
53}
54
55double QgsSymbolRenderContext::outputPixelSize( double size ) const
56{
57 return mRenderContext.convertToPainterUnits( size, mOutputUnit, mMapUnitScale );
58}
59
60// cppcheck-suppress operatorEqVarError
62{
63 // This is just a dummy implementation of assignment.
64 // sip 4.7 generates a piece of code that needs this function to exist.
65 // It's not generated automatically by the compiler because of
66 // mRenderContext member which is a reference (and thus can't be changed).
67 Q_ASSERT( false );
68 return *this;
69}
70
72{
73 return mExpressionContextScope.get();
74}
75
77{
78 mExpressionContextScope.reset( contextScope );
79}
80
82{
83 return mPatchShape.get();
84}
85
87{
88 mPatchShape = std::make_unique<QgsLegendPatchShape>( patchShape );
89}
@ Default
Allow raster-based rendering in situations where it is required for correct rendering or where it wil...
Definition qgis.h:2704
@ ForceVectorRendering
Symbol must be rendered using vector methods, and optimisations like pre-rendered images must be disa...
Definition qgis.h:772
RenderUnit
Rendering size units.
Definition qgis.h:5183
QFlags< SymbolRenderHint > SymbolRenderHints
Symbol render hints.
Definition qgis.h:777
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:58
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.
QgsFields fields() const
Fields of the layer.
void setExpressionContextScope(QgsExpressionContextScope *contextScope)
Set an expression scope for this symbol.
QgsSymbolRenderContext & operator=(const QgsSymbolRenderContext &)
Q_DECL_DEPRECATED double outputLineWidth(double width) const
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
Q_DECL_DEPRECATED double outputPixelSize(double size) const
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 setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
void setPatchShape(const QgsLegendPatchShape &shape)
Sets the symbol patch shape, to use if rendering symbol preview icons.
bool forceVectorRendering() const
Returns true if symbol must be rendered using vector methods, and optimisations like pre-rendered ima...
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered.
qreal opacity() const
Returns the opacity for the symbol.
const QgsLegendPatchShape * patchShape() const
Returns the symbol patch shape, to use if rendering symbol preview icons.
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