QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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#include "qgsrendercontext.h"
18#include "qgslegendpatchshape.h"
19
20QgsSymbolRenderContext::QgsSymbolRenderContext( QgsRenderContext &c, Qgis::RenderUnit u, qreal opacity, bool selected, Qgis::SymbolRenderHints renderHints, const QgsFeature *f, const QgsFields &fields, const QgsMapUnitScale &mapUnitScale )
21 : mRenderContext( c )
22 , mOutputUnit( u )
23 , mMapUnitScale( mapUnitScale )
24 , mOpacity( opacity )
25 , mSelected( selected )
26 , mRenderHints( renderHints )
27 , mFeature( f )
28 , mFields( fields )
29 , mGeometryPartCount( 0 )
30 , mGeometryPartNum( 0 )
31{
32}
33
35
37{
38 mRenderContext.expressionContext().setOriginalValueVariable( value );
39}
40
46
47double QgsSymbolRenderContext::outputLineWidth( double width ) const
48{
49 return mRenderContext.convertToPainterUnits( width, mOutputUnit, mMapUnitScale );
50}
51
52double QgsSymbolRenderContext::outputPixelSize( double size ) const
53{
54 return mRenderContext.convertToPainterUnits( size, mOutputUnit, mMapUnitScale );
55}
56
57// cppcheck-suppress operatorEqVarError
59{
60 // This is just a dummy implementation of assignment.
61 // sip 4.7 generates a piece of code that needs this function to exist.
62 // It's not generated automatically by the compiler because of
63 // mRenderContext member which is a reference (and thus can't be changed).
64 Q_ASSERT( false );
65 return *this;
66}
67
69{
70 return mExpressionContextScope.get();
71}
72
74{
75 mExpressionContextScope.reset( contextScope );
76}
77
79{
80 return mPatchShape.get();
81}
82
84{
85 mPatchShape.reset( new QgsLegendPatchShape( patchShape ) );
86}
@ ForceVectorRendering
Symbol must be rendered using vector methods, and optimisations like pre-rendered images must be disa...
RenderUnit
Rendering size units.
Definition qgis.h:4839
@ ForceVectorOutput
Vector graphics should not be cached and drawn as raster images.
QFlags< SymbolRenderHint > SymbolRenderHints
Symbol render hints.
Definition qgis.h:741
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
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.
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
QgsExpressionContext & expressionContext()
Gets the expression context.
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
void setExpressionContextScope(QgsExpressionContextScope *contextScope)
Set an expression scope for this symbol.
QgsSymbolRenderContext & operator=(const QgsSymbolRenderContext &)
Q_DECL_DEPRECATED double outputLineWidth(double width) 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.
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