Skip to content
Permalink
Browse files

QgsFeatureRendererV2::Capabilities to flags

  • Loading branch information
m-kuhn committed Dec 20, 2015
1 parent 2cf9243 commit 8182f2970f1d768ef92c588a7415204e4773b0ce
@@ -241,6 +241,12 @@ None will need to be modified, as the method will return an empty geometry if th
<li>setFields( const QgsFields*, bool ) has been removed, use setFields( const QgsFields&, bool ) instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsFeatureRendererV2 QgsFeatureRendererV2

<ul>
<li>The method capabilities() returns QgsFeatureRendererV2::Capabilities flags instead of an integer. The two are binary compatible.
</ul>

\subsection qgis_api_break_3_0_QgsGeometry QgsGeometry

<ul>
@@ -68,7 +68,7 @@ class QgsCategorizedSymbolRendererV2 : QgsFeatureRendererV2
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities();
virtual QgsFeatureRendererV2::Capabilities capabilities();

virtual QString filter( const QgsFields& fields = QgsFields() );

@@ -111,7 +111,7 @@ class QgsGraduatedSymbolRendererV2 : QgsFeatureRendererV2
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities();
virtual QgsFeatureRendererV2::Capabilities capabilities();

//! @note symbol2 in python bindings
virtual QgsSymbolV2List symbols( QgsRenderContext& context ) /PyName=symbols2/;
@@ -41,7 +41,7 @@ class QgsInvertedPolygonRenderer : QgsFeatureRendererV2
/** Proxy that will call this method on the embedded renderer. */
virtual QList<QString> usedAttributes();
/** Proxy that will call this method on the embedded renderer. */
virtual int capabilities();
virtual QgsFeatureRendererV2::Capabilities capabilities();
/** Proxy that will call this method on the embedded renderer.
* @note available in python bindings as symbol2
*/
@@ -26,7 +26,7 @@ class QgsPointDisplacementRenderer : QgsFeatureRendererV2
/** Partial proxy that will call this method on the embedded renderer. */
virtual QList<QString> usedAttributes();
/** Proxy that will call this method on the embedded renderer. */
virtual int capabilities();
virtual QgsFeatureRendererV2::Capabilities capabilities();
/** Proxy that will call this method on the embedded renderer.
@note available in python as symbols2
*/
@@ -172,7 +172,7 @@ class QgsFeatureRendererV2
//! for debugging
virtual QString dump() const;

enum Capabilities
enum Capability
{
SymbolLevels, // rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
RotationField, // rotate symbols by attribute value
@@ -181,8 +181,10 @@ class QgsFeatureRendererV2
ScaleDependent // depends on scale if feature will be rendered (rule based )
};

typedef QFlags<QgsFeatureRendererV2::Capability> Capabilities;

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities();
virtual QgsFeatureRendererV2::Capabilities capabilities();

/** For symbol levels
* @deprecated use symbols( QgsRenderContext& context ) instead
@@ -418,7 +418,7 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
virtual QSet<QString> legendKeysForFeature( QgsFeature& feature, QgsRenderContext& context );

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities();
virtual QgsFeatureRendererV2::Capabilities capabilities();

/////

@@ -41,7 +41,7 @@ class QgsSingleSymbolRendererV2 : QgsFeatureRendererV2
static QgsFeatureRendererV2* createFromSld( QDomElement& element, Qgis::GeometryType geomType );

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities();
virtual QgsFeatureRendererV2::Capabilities capabilities();

//! @note available in python as symbol2
virtual QgsSymbolV2List symbols( QgsRenderContext& context ) /PyName=symbols2/;
@@ -102,7 +102,7 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2
virtual void toSld( QDomDocument& doc, QDomElement &element ) const override;

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities() override { return SymbolLevels | RotationField | Filter; }
virtual Capabilities capabilities() override { return SymbolLevels | RotationField | Filter; }

virtual QString filter( const QgsFields& fields = QgsFields() ) override;

@@ -155,7 +155,7 @@ class CORE_EXPORT QgsGraduatedSymbolRendererV2 : public QgsFeatureRendererV2
virtual void toSld( QDomDocument& doc, QDomElement &element ) const override;

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities() override { return SymbolLevels | RotationField | Filter; }
virtual Capabilities capabilities() override { return SymbolLevels | RotationField | Filter; }

//! @note symbol2 in python bindings
virtual QgsSymbolV2List symbols( QgsRenderContext &context ) override;
@@ -455,7 +455,7 @@ QgsSymbolV2List QgsInvertedPolygonRenderer::symbols( QgsRenderContext& context )
return mSubRenderer->symbols( context );
}

int QgsInvertedPolygonRenderer::capabilities()
QgsFeatureRendererV2::Capabilities QgsInvertedPolygonRenderer::capabilities()
{
if ( !mSubRenderer )
{
@@ -76,7 +76,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRendererV2
/** Proxy that will call this method on the embedded renderer. */
virtual QList<QString> usedAttributes() override;
/** Proxy that will call this method on the embedded renderer. */
virtual int capabilities() override;
virtual Capabilities capabilities() override;
/** Proxy that will call this method on the embedded renderer.
* @note available in python bindings as symbol2
*/
@@ -275,7 +275,7 @@ QList<QString> QgsPointDisplacementRenderer::usedAttributes()
return attributeList;
}

int QgsPointDisplacementRenderer::capabilities()
QgsFeatureRendererV2::Capabilities QgsPointDisplacementRenderer::capabilities()
{
if ( !mRenderer )
{
@@ -54,7 +54,7 @@ class CORE_EXPORT QgsPointDisplacementRenderer: public QgsFeatureRendererV2
/** Partial proxy that will call this method on the embedded renderer. */
virtual QList<QString> usedAttributes() override;
/** Proxy that will call this method on the embedded renderer. */
virtual int capabilities() override;
virtual Capabilities capabilities() override;
/** Proxy that will call this method on the embedded renderer.
@note available in python as symbols2
*/
@@ -169,10 +169,12 @@ class CORE_EXPORT QgsFeatureRendererV2
virtual QString filter( const QgsFields& fields = QgsFields() ) { Q_UNUSED( fields ); return QString::null; }

/**
* Returns a set of attributes required for this renderer.
* Return a list of attributes required by this renderer. Attributes not listed in here may
* not have been requested from the provider at rendering time.
*
* TODO QGIS3: Change QList to QSet
* @return A set of attributes
*/
// TODO QGIS3: Change QList to QSet
virtual QList<QString> usedAttributes() = 0;

/**
@@ -182,6 +184,12 @@ class CORE_EXPORT QgsFeatureRendererV2

virtual ~QgsFeatureRendererV2();

/**
* Create a deep copy of this renderer. Should be implemented by all subclasses
* and generate a proper subclass.
*
* @return A copy of this renderer
*/
virtual QgsFeatureRendererV2* clone() const = 0;

/**
@@ -196,20 +204,37 @@ class CORE_EXPORT QgsFeatureRendererV2
*/
virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );

//! for debugging
//! Returns debug information about this renderer
virtual QString dump() const;

enum Capabilities
/**
* Used to specify details about a renderer.
* Is returned from the capabilities() method.
*/
enum Capability
{
SymbolLevels = 1, //!< rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
RotationField = 1 << 1, //!< rotate symbols by attribute value
SymbolLevels = 1, //!< rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
RotationField = 1 << 1, //!< rotate symbols by attribute value
MoreSymbolsPerFeature = 1 << 2, //!< may use more than one symbol to render a feature: symbolsForFeature() will return them
Filter = 1 << 3, //!< features may be filtered, i.e. some features may not be rendered (categorized, rule based ...)
ScaleDependent = 1 << 4 //!< depends on scale if feature will be rendered (rule based )
Filter = 1 << 3, //!< features may be filtered, i.e. some features may not be rendered (categorized, rule based ...)
ScaleDependent = 1 << 4 //!< depends on scale if feature will be rendered (rule based )
};

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities() { return 0; }
Q_DECLARE_FLAGS( Capabilities, Capability )

/**
* Returns details about internals of this renderer.
*
* E.g. if you only want to deal with visible features:
*
* ~~~{.py}
* if not renderer.capabilities().testFlag(QgsFeatureRendererV2.Filter) or renderer.willRenderFeature(feature, context):
* deal_with_my_feature()
* else:
* skip_the_curren_feature()
* ~~~
*/
virtual Capabilities capabilities() { return 0; }

/** For symbol levels
* @deprecated use symbols( QgsRenderContext& context ) instead
@@ -517,6 +542,8 @@ class CORE_EXPORT QgsFeatureRendererV2
Q_DISABLE_COPY( QgsFeatureRendererV2 )
};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFeatureRendererV2::Capabilities )

// for some reason SIP compilation fails if these lines are not included:
class QgsRendererV2Widget;
class QgsPaintEffectWidget;
@@ -489,7 +489,7 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
virtual QSet<QString> legendKeysForFeature( QgsFeature& feature, QgsRenderContext& context ) override;

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities() override { return MoreSymbolsPerFeature | Filter | ScaleDependent; }
virtual Capabilities capabilities() override { return MoreSymbolsPerFeature | Filter | ScaleDependent; }

/////

@@ -65,7 +65,7 @@ class CORE_EXPORT QgsSingleSymbolRendererV2 : public QgsFeatureRendererV2
static QgsFeatureRendererV2* createFromSld( QDomElement& element, Qgis::GeometryType geomType );

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities() override { return SymbolLevels | RotationField; }
virtual Capabilities capabilities() override { return SymbolLevels | RotationField; }

//! @note available in python as symbol2
virtual QgsSymbolV2List symbols( QgsRenderContext& context ) override;

0 comments on commit 8182f29

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