Skip to content
Permalink
Browse files

Merge pull request #3486 from nyalldawson/symbol

Symbology QGIS 3.0 todos
  • Loading branch information
nyalldawson committed Sep 14, 2016
2 parents aac7e9a + b711177 commit de7475ae726fa116159141a06136ea0d8d9ecf3f
@@ -875,6 +875,12 @@ be returned instead of a null pointer if no transformation is required.</li>
plugins calling this method will need to be updated.</li>
</ul>

\subsection qgis_api_break_3_0_QgsMarkerSymbolLayer QgsMarkerSymbolLayer

<ul>
<li>bounds() is now pure virtual and must be implemented in all subclasses.</li>
</ul>

\subsection qgis_api_break_3_0_QgsMimeDataUtils QgsMimeDataUtils

<ul>
@@ -1013,9 +1019,16 @@ be returned instead of a null pointer if no transformation is required.</li>

<ul>
<li>QgsRuleBasedRenderer.Rule checkState() and setCheckState() were removed. Use active() and setActive() instead.</li>
<li>QgsRuleBasedRenderer.Rule updateElseRules() was removed.</li>
<li>startRender( QgsRenderContext& context, const QgsFields& fields ) was removed. Use startRender( QgsRenderContext& context, const QgsFields& fields, QString& filter ) instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsRuleBasedRendererWidget QgsRuleBasedRendererWidget

<ul>
<li>refineRuleCategoriesGui() and refineRuleRangesGui() no longer take a QModelIndexList argument.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSimpleMarkerSymbolLayer QgsSimpleMarkerSymbolLayer

<ul>
@@ -1024,6 +1037,13 @@ be returned instead of a null pointer if no transformation is required.</li>
<li>prepareShape() and preparePath() were removed. Calling these methods manually should no longer be required.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSimpleMarkerSymbolLayerWidget QgsSimpleMarkerSymbolLayerWidget

<ul>
<li>setName() was removed.</li>
</ul>


\subsection qgis_api_break_3_0_QgsSingleSymbolRendererWidget QgsSingleSymbolRendererWidget
<ul>
<li>sizeScaleFieldChanged() and scaleMethodChanged() were removed. These settings are no longer exposed in the widget's GUI.</li>
@@ -1050,6 +1070,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)
@@ -1067,6 +1091,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>

@@ -295,13 +295,6 @@ class QgsRuleBasedRenderer : QgsFeatureRenderer
//! @note added in 2.6
QgsRuleBasedRenderer::Rule* findRuleByKey( const QString& key );

/**
* Check which child rules are else rules and update the internal list of else rules
*
* TODO QGIS 3: Does this need to be public?
*/
void updateElseRules();

/**
* Sets if this rule is an ELSE rule
*
@@ -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
@@ -516,10 +516,8 @@ class QgsMarkerSymbolLayer : QgsSymbolLayer
* any data defined overrides and offsets which are set for the marker layer.
* @returns approximate symbol bounds, in painter units
* @note added in QGIS 2.14
* @note this method will become pure virtual in QGIS 3.0
*/
//TODO QGIS 3.0 - make pure virtual
virtual QRectF bounds( QPointF point, QgsSymbolRenderContext& context );
virtual QRectF bounds( QPointF point, QgsSymbolRenderContext& context ) = 0;

protected:

@@ -83,4 +83,6 @@ class QgsVectorFieldSymbolLayer : QgsMarkerSymbolLayer

void setDistanceMapUnitScale( const QgsMapUnitScale& scale );
const QgsMapUnitScale& distanceMapUnitScale() const;

QRectF bounds( QPointF point, QgsSymbolRenderContext& context );
};
@@ -86,8 +86,10 @@ class QgsRuleBasedRendererWidget : QgsRendererWidget

protected:
void refineRule( int type );
void refineRuleCategoriesGui( const QModelIndexList& index );
void refineRuleRangesGui( const QModelIndexList& index );
//! Opens the dialog for refining a rule using categories
void refineRuleCategoriesGui();
//! Opens the dialog for refining a rule using ranges
void refineRuleRangesGui();
void refineRuleScalesGui( const QModelIndexList& index );

QgsRuleBasedRenderer::Rule* currentRule();
@@ -126,7 +126,6 @@ class QgsSimpleMarkerSymbolLayerWidget : QgsSymbolLayerWidget
virtual QgsSymbolLayer* symbolLayer();

public slots:
void setName();
void setColorBorder( const QColor& color );
void setColorFill( const QColor& color );
void setSize();
@@ -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
@@ -689,7 +689,6 @@ QgsSimpleMarkerSymbolLayer::QgsSimpleMarkerSymbolLayer( QgsSimpleMarkerSymbolLay
, mOutlineWidth( 0 )
, mOutlineWidthUnit( QgsUnitTypes::RenderMillimeters )
, mPenJoinStyle( penJoinStyle )
, mName( encodeShape( shape ) )
, mUsingCache( false )
{
mColor = color;
@@ -824,7 +823,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 +2091,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 +2622,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
@@ -366,9 +366,6 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayer : public QgsSimpleMarkerSymbolLayer
//! QBrush corresponding to marker's fill style
QBrush mBrush;

//TODO QGIS 3.0 - remove
QString mName;

//! Cached image of marker, if using cached version
QImage mCache;
//! QPen to use as outline of selected symbols
@@ -353,13 +353,6 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer
//! @note added in 2.6
Rule* findRuleByKey( const QString& key );

/**
* Check which child rules are else rules and update the internal list of else rules
*
* TODO QGIS 3: Does this need to be public?
*/
void updateElseRules();

/**
* Sets if this rule is an ELSE rule
*
@@ -398,6 +391,12 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer

Rule( const Rule& rh );
Rule& operator=( const Rule& rh );

/**
* Check which child rules are else rules and update the internal list of else rules
*
*/
void updateElseRules();
};

/////
@@ -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 )

0 comments on commit de7475a

Please sign in to comment.
You can’t perform that action at this time.