mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Change QgsSymbol and QgsSymbolRenderContext render hint to use a
QgsSymbol::RenderHints QFlags value instead of a raw int Also rename DataDefinedRotation to DynamicRotation since it is no longer used for data defined rotation
This commit is contained in:
parent
5617dbc612
commit
e122546546
@ -951,6 +951,10 @@ parameters or QgsSymbol::OutputUnitList parameters now take QgsUnitTypes::Render
|
||||
<li>startRender() now accepts a QgsFields reference, not a pointer.</li>
|
||||
<li>isSymbolLayerCompatible() was removed. Use QgsSymbolLayer::isCompatibleWithSymbol() instead.</li>
|
||||
<li>The DataDefinedSizeScale flag has been removed. This is no longer used and data defined scaling on a symbol layer level should be used instead.</li>
|
||||
<li>The DataDefinedRotation RenderHint was renamed to DynamicRotation, as it is no longer used for
|
||||
data defined rotation.</li>
|
||||
<li>setRenderHints() and renderHints() now accept and return a QgsSymbol::RenderHints flag rather
|
||||
than an integer value</li>
|
||||
</ul>
|
||||
|
||||
\subsection qgis_api_break_3_0_QgsSymbolLayer QgsSymbolLayer (renamed from QgsSymbolLayerV2)
|
||||
@ -968,6 +972,8 @@ the variant which takes QgsSymbolRenderContext instead.</li>
|
||||
|
||||
<ul>
|
||||
<li>The constructor now accepts a QgsFields reference, not a pointer.</li>
|
||||
<li>The constructor, setRenderHints() and renderHints() now accept and return a QgsSymbol::RenderHints flag rather
|
||||
than an integer value</li>
|
||||
<li>fields() now returns a QgsFields value, not a pointer.</li>
|
||||
</ul>
|
||||
|
||||
|
@ -39,10 +39,12 @@ class QgsSymbol
|
||||
ScaleDiameter //!< Calculate scale by the diameter
|
||||
};
|
||||
|
||||
//! Flags controlling behaviour of symbols during rendering
|
||||
enum RenderHint
|
||||
{
|
||||
DataDefinedRotation
|
||||
DynamicRotation, //!< Rotation of symbol may be changed during rendering and symbol should not be cached
|
||||
};
|
||||
typedef QFlags<QgsSymbol::RenderHint> RenderHints;
|
||||
|
||||
virtual ~QgsSymbol();
|
||||
|
||||
@ -178,8 +180,15 @@ class QgsSymbol
|
||||
//! Set alpha transparency 1 for opaque, 0 for invisible
|
||||
void setAlpha( qreal alpha );
|
||||
|
||||
void setRenderHints( int hints );
|
||||
int renderHints() const;
|
||||
/** Sets rendering hint flags for the symbol.
|
||||
* @see renderHints()
|
||||
*/
|
||||
void setRenderHints( RenderHints hints );
|
||||
|
||||
/** Returns the rendering hint flags for the symbol.
|
||||
* @see setRenderHints()
|
||||
*/
|
||||
RenderHints renderHints() const;
|
||||
|
||||
/** Sets whether features drawn by the symbol should be clipped to the render context's
|
||||
* extent. If this option is enabled then features which are partially outside the extent
|
||||
@ -281,6 +290,9 @@ class QgsSymbol
|
||||
QgsSymbol( const QgsSymbol& );
|
||||
};
|
||||
|
||||
QFlags<QgsSymbol::RenderHint> operator|(QgsSymbol::RenderHint f1, QFlags<QgsSymbol::RenderHint> f2);
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
||||
class QgsSymbolRenderContext
|
||||
@ -296,12 +308,12 @@ class QgsSymbolRenderContext
|
||||
* @param u
|
||||
* @param alpha
|
||||
* @param selected set to true if symbol should be drawn in a "selected" state
|
||||
* @param renderHints
|
||||
* @param renderHints flags controlling rendering behaviour
|
||||
* @param f
|
||||
* @param fields
|
||||
* @param mapUnitScale
|
||||
*/
|
||||
QgsSymbolRenderContext( QgsRenderContext& c, QgsUnitTypes::RenderUnit u, qreal alpha = 1.0, bool selected = false, int renderHints = 0, const QgsFeature* f = 0, const QgsFields& fields = QgsFields(), const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
|
||||
QgsSymbolRenderContext( QgsRenderContext& c, QgsUnitTypes::RenderUnit u, qreal alpha = 1.0, bool selected = false, QgsSymbol::RenderHints renderHints = 0, const QgsFeature* f = 0, const QgsFields& fields = QgsFields(), const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
|
||||
~QgsSymbolRenderContext();
|
||||
|
||||
QgsRenderContext& renderContext();
|
||||
@ -331,8 +343,15 @@ class QgsSymbolRenderContext
|
||||
bool selected() const;
|
||||
void setSelected( bool selected );
|
||||
|
||||
int renderHints() const;
|
||||
void setRenderHints( int hints );
|
||||
/** Returns the rendering hint flags for the symbol.
|
||||
* @see setRenderHints()
|
||||
*/
|
||||
QgsSymbol::RenderHints renderHints() const;
|
||||
|
||||
/** Sets rendering hint flags for the symbol.
|
||||
* @see renderHints()
|
||||
*/
|
||||
void setRenderHints( QgsSymbol::RenderHints hints );
|
||||
|
||||
void setFeature( const QgsFeature* f );
|
||||
//! Current feature being rendered - may be null
|
||||
|
@ -4168,7 +4168,7 @@ bool QgsDxfExport::hasDataDefinedProperties( const QgsSymbolLayer* sl, const Qgs
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( symbol->renderHints() & QgsSymbol::DataDefinedRotation )
|
||||
if ( symbol->renderHints() & QgsSymbol::DynamicRotation )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ void QgsEllipseSymbolLayer::calculateOffsetAndRotation( QgsSymbolRenderContext&
|
||||
usingDataDefinedRotation = ok;
|
||||
}
|
||||
|
||||
hasDataDefinedRotation = context.renderHints() & QgsSymbol::DataDefinedRotation || usingDataDefinedRotation;
|
||||
hasDataDefinedRotation = context.renderHints() & QgsSymbol::DynamicRotation || usingDataDefinedRotation;
|
||||
if ( hasDataDefinedRotation )
|
||||
{
|
||||
// For non-point markers, "dataDefinedRotation" means following the
|
||||
|
@ -809,9 +809,9 @@ void QgsMarkerLineSymbolLayer::startRender( QgsSymbolRenderContext& context )
|
||||
mMarker->setAlpha( context.alpha() );
|
||||
|
||||
// if being rotated, it gets initialized with every line segment
|
||||
int hints = 0;
|
||||
QgsSymbol::RenderHints hints = 0;
|
||||
if ( mRotateMarker )
|
||||
hints |= QgsSymbol::DataDefinedRotation;
|
||||
hints |= QgsSymbol::DynamicRotation;
|
||||
mMarker->setRenderHints( hints );
|
||||
|
||||
mMarker->startRender( context.renderContext(), context.fields() );
|
||||
|
@ -130,7 +130,7 @@ bool QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( QgsSimpleMarkerSymbolLayerBa
|
||||
|
||||
void QgsSimpleMarkerSymbolLayerBase::startRender( QgsSymbolRenderContext &context )
|
||||
{
|
||||
bool hasDataDefinedRotation = context.renderHints() & QgsSymbol::DataDefinedRotation || hasDataDefinedProperty( QgsSymbolLayer::EXPR_ANGLE );
|
||||
bool hasDataDefinedRotation = context.renderHints() & QgsSymbol::DynamicRotation || hasDataDefinedProperty( QgsSymbolLayer::EXPR_ANGLE );
|
||||
bool hasDataDefinedSize = hasDataDefinedProperty( QgsSymbolLayer::EXPR_SIZE );
|
||||
|
||||
// use either QPolygonF or QPainterPath for drawing
|
||||
@ -654,7 +654,7 @@ void QgsSimpleMarkerSymbolLayerBase::calculateOffsetAndRotation( QgsSymbolRender
|
||||
usingDataDefinedRotation = ok;
|
||||
}
|
||||
|
||||
hasDataDefinedRotation = context.renderHints() & QgsSymbol::DataDefinedRotation || usingDataDefinedRotation;
|
||||
hasDataDefinedRotation = context.renderHints() & QgsSymbol::DynamicRotation || usingDataDefinedRotation;
|
||||
if ( hasDataDefinedRotation )
|
||||
{
|
||||
// For non-point markers, "dataDefinedRotation" means following the
|
||||
@ -824,7 +824,7 @@ void QgsSimpleMarkerSymbolLayer::startRender( QgsSymbolRenderContext& context )
|
||||
mSelPen.setStyle( mOutlineStyle );
|
||||
mSelPen.setWidthF( QgsSymbolLayerUtils::convertToPainterUnits( context.renderContext(), mOutlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale ) );
|
||||
|
||||
bool hasDataDefinedRotation = context.renderHints() & QgsSymbol::DataDefinedRotation || hasDataDefinedProperty( QgsSymbolLayer::EXPR_ANGLE );
|
||||
bool hasDataDefinedRotation = context.renderHints() & QgsSymbol::DynamicRotation || hasDataDefinedProperty( QgsSymbolLayer::EXPR_ANGLE );
|
||||
bool hasDataDefinedSize = hasDataDefinedProperty( QgsSymbolLayer::EXPR_SIZE );
|
||||
|
||||
// use caching only when:
|
||||
@ -2092,7 +2092,7 @@ void QgsSvgMarkerSymbolLayer::calculateOffsetAndRotation( QgsSymbolRenderContext
|
||||
angle = evaluateDataDefinedProperty( QgsSymbolLayer::EXPR_ANGLE, context, mAngle ).toDouble() + mLineAngle;
|
||||
}
|
||||
|
||||
bool hasDataDefinedRotation = context.renderHints() & QgsSymbol::DataDefinedRotation || hasDataDefinedProperty( QgsSymbolLayer::EXPR_ANGLE );
|
||||
bool hasDataDefinedRotation = context.renderHints() & QgsSymbol::DynamicRotation || hasDataDefinedProperty( QgsSymbolLayer::EXPR_ANGLE );
|
||||
if ( hasDataDefinedRotation )
|
||||
{
|
||||
// For non-point markers, "dataDefinedRotation" means following the
|
||||
@ -2623,7 +2623,7 @@ void QgsFontMarkerSymbolLayer::calculateOffsetAndRotation( QgsSymbolRenderContex
|
||||
usingDataDefinedRotation = ok;
|
||||
}
|
||||
|
||||
hasDataDefinedRotation = context.renderHints() & QgsSymbol::DataDefinedRotation || usingDataDefinedRotation;
|
||||
hasDataDefinedRotation = context.renderHints() & QgsSymbol::DynamicRotation || usingDataDefinedRotation;
|
||||
if ( hasDataDefinedRotation )
|
||||
{
|
||||
// For non-point markers, "dataDefinedRotation" means following the
|
||||
|
@ -942,7 +942,7 @@ void QgsSymbol::renderVertexMarker( QPointF pt, QgsRenderContext& context, int c
|
||||
////////////////////
|
||||
|
||||
|
||||
QgsSymbolRenderContext::QgsSymbolRenderContext( QgsRenderContext& c, QgsUnitTypes::RenderUnit u, qreal alpha, bool selected, int renderHints, const QgsFeature* f, const QgsFields& fields, const QgsMapUnitScale& mapUnitScale )
|
||||
QgsSymbolRenderContext::QgsSymbolRenderContext( QgsRenderContext& c, QgsUnitTypes::RenderUnit u, qreal alpha, bool selected, QgsSymbol::RenderHints renderHints, const QgsFeature* f, const QgsFields& fields, const QgsMapUnitScale& mapUnitScale )
|
||||
: mRenderContext( c )
|
||||
, mExpressionContextScope( nullptr )
|
||||
, mOutputUnit( u )
|
||||
|
@ -80,10 +80,13 @@ class CORE_EXPORT QgsSymbol
|
||||
ScaleDiameter //!< Calculate scale by the diameter
|
||||
};
|
||||
|
||||
|
||||
//! Flags controlling behaviour of symbols during rendering
|
||||
enum RenderHint
|
||||
{
|
||||
DataDefinedRotation = 2
|
||||
DynamicRotation = 2, //!< Rotation of symbol may be changed during rendering and symbol should not be cached
|
||||
};
|
||||
Q_DECLARE_FLAGS( RenderHints, RenderHint )
|
||||
|
||||
virtual ~QgsSymbol();
|
||||
|
||||
@ -224,8 +227,15 @@ class CORE_EXPORT QgsSymbol
|
||||
//! Set alpha transparency 1 for opaque, 0 for invisible
|
||||
void setAlpha( qreal alpha ) { mAlpha = alpha; }
|
||||
|
||||
void setRenderHints( int hints ) { mRenderHints = hints; }
|
||||
int renderHints() const { return mRenderHints; }
|
||||
/** Sets rendering hint flags for the symbol.
|
||||
* @see renderHints()
|
||||
*/
|
||||
void setRenderHints( RenderHints hints ) { mRenderHints = hints; }
|
||||
|
||||
/** Returns the rendering hint flags for the symbol.
|
||||
* @see setRenderHints()
|
||||
*/
|
||||
RenderHints renderHints() const { return mRenderHints; }
|
||||
|
||||
/** Sets whether features drawn by the symbol should be clipped to the render context's
|
||||
* extent. If this option is enabled then features which are partially outside the extent
|
||||
@ -343,7 +353,7 @@ class CORE_EXPORT QgsSymbol
|
||||
/** Symbol opacity (in the range 0 - 1)*/
|
||||
qreal mAlpha;
|
||||
|
||||
int mRenderHints;
|
||||
RenderHints mRenderHints;
|
||||
bool mClipFeaturesToExtent;
|
||||
|
||||
const QgsVectorLayer* mLayer; //current vectorlayer
|
||||
@ -356,6 +366,8 @@ class CORE_EXPORT QgsSymbol
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsSymbol::RenderHints )
|
||||
|
||||
///////////////////////
|
||||
|
||||
/** \ingroup core
|
||||
@ -370,12 +382,12 @@ class CORE_EXPORT QgsSymbolRenderContext
|
||||
* @param u
|
||||
* @param alpha
|
||||
* @param selected set to true if symbol should be drawn in a "selected" state
|
||||
* @param renderHints
|
||||
* @param renderHints flags controlling rendering behaviour
|
||||
* @param f
|
||||
* @param fields
|
||||
* @param mapUnitScale
|
||||
*/
|
||||
QgsSymbolRenderContext( QgsRenderContext& c, QgsUnitTypes::RenderUnit u, qreal alpha = 1.0, bool selected = false, int renderHints = 0, const QgsFeature* f = nullptr, const QgsFields& fields = QgsFields(), const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
|
||||
QgsSymbolRenderContext( QgsRenderContext& c, QgsUnitTypes::RenderUnit u, qreal alpha = 1.0, bool selected = false, QgsSymbol::RenderHints renderHints = 0, const QgsFeature* f = nullptr, const QgsFields& fields = QgsFields(), const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
|
||||
~QgsSymbolRenderContext();
|
||||
|
||||
QgsRenderContext& renderContext() { return mRenderContext; }
|
||||
@ -405,8 +417,15 @@ class CORE_EXPORT QgsSymbolRenderContext
|
||||
bool selected() const { return mSelected; }
|
||||
void setSelected( bool selected ) { mSelected = selected; }
|
||||
|
||||
int renderHints() const { return mRenderHints; }
|
||||
void setRenderHints( int hints ) { mRenderHints = hints; }
|
||||
/** Returns the rendering hint flags for the symbol.
|
||||
* @see setRenderHints()
|
||||
*/
|
||||
QgsSymbol::RenderHints renderHints() const { return mRenderHints; }
|
||||
|
||||
/** Sets rendering hint flags for the symbol.
|
||||
* @see renderHints()
|
||||
*/
|
||||
void setRenderHints( QgsSymbol::RenderHints hints ) { mRenderHints = hints; }
|
||||
|
||||
void setFeature( const QgsFeature* f ) { mFeature = f; }
|
||||
//! Current feature being rendered - may be null
|
||||
@ -464,7 +483,7 @@ class CORE_EXPORT QgsSymbolRenderContext
|
||||
QgsMapUnitScale mMapUnitScale;
|
||||
qreal mAlpha;
|
||||
bool mSelected;
|
||||
int mRenderHints;
|
||||
QgsSymbol::RenderHints mRenderHints;
|
||||
const QgsFeature* mFeature; //current feature
|
||||
QgsFields mFields;
|
||||
int mGeometryPartCount;
|
||||
|
Loading…
x
Reference in New Issue
Block a user