Skip to content
Permalink
Browse files

Doxymentation

  • Loading branch information
m-kuhn committed Sep 11, 2015
1 parent bd86697 commit 72608b0a6f0e984bc31eb97b4533ba4bfa627971
@@ -112,13 +112,27 @@ class CORE_EXPORT QgsAttributes : public QVector<QVariant>
QgsAttributes()
: QVector<QVariant>()
{}
/**
* Create a new vector of attributes with the given size
*
* @param size Number of attributes
*/
QgsAttributes( int size )
: QVector<QVariant>( size )
{}
/**
* Constructs a vector with an initial size of size elements. Each element is initialized with value.
* @param size Number of elements
* @param v Initial value
*/
QgsAttributes( int size, const QVariant& v )
: QVector<QVariant>( size, v )
{}

/**
* Copies another vector of attributes
* @param v Attributes to copy
*/
QgsAttributes( const QVector<QVariant>& v )
: QVector<QVariant>( v )
{}
@@ -31,9 +31,13 @@ typedef QList<int> QgsAttributeList;
* The request may apply a filter to fetch only a particular subset of features. Currently supported filters:
* - no filter - all features are returned
* - feature id - only feature that matches given feature id is returned
* - rectangle - only features that intersect given rectangle should be fetched. For the sake of speed,
* the intersection is often done only using feature's bounding box. There is a flag
* ExactIntersect that makes sure that only intersecting features will be returned.
* - feature ids - only features that match any of the given feature ids are returned
* - filter expression - only features that match the given filter expression are returned
*
* Additionally a spatial rectangle can be set in combination:
* Only features that intersect given rectangle should be fetched. For the sake of speed,
* the intersection is often done only using feature's bounding box. There is a flag
* ExactIntersect that makes sure that only intersecting features will be returned.
*
* For efficiency, it is also possible to tell provider that some data is not required:
* - NoGeometry flag
@@ -68,6 +72,9 @@ class CORE_EXPORT QgsFeatureRequest
};
Q_DECLARE_FLAGS( Flags, Flag )

/**
* Types of filters.
*/
enum FilterType
{
FilterNone, //!< No filter is applied
@@ -77,6 +84,9 @@ class CORE_EXPORT QgsFeatureRequest
FilterFids //!< Filter using feature IDs
};

/**
* A special attribute that if set matches all attributes
*/
static const QString AllAttributes;

//! construct a default request: for all features get attributes and geometries
@@ -89,24 +99,36 @@ class CORE_EXPORT QgsFeatureRequest
explicit QgsFeatureRequest( const QgsExpression& expr, const QgsExpressionContext& context = QgsExpressionContext() );
//! copy constructor
QgsFeatureRequest( const QgsFeatureRequest& rh );

//! Assignment operator
QgsFeatureRequest& operator=( const QgsFeatureRequest& rh );

~QgsFeatureRequest();

/**
* Return the filter type which is currently set on this request
*
* @return Filter type
*/
FilterType filterType() const { if ( mFilter == FilterNone && !mFilterRect.isNull() ) return FilterRect; else return mFilter; }

//! Set rectangle from which features will be taken. Empty rectangle removes the filter.
//!
/**
* Set rectangle from which features will be taken. Empty rectangle removes the filter.
*/
QgsFeatureRequest& setFilterRect( const QgsRectangle& rect );

/**
* Get the rectangle from which features will be taken.
*/
const QgsRectangle& filterRect() const { return mFilterRect; }

//! Set feature ID that should be fetched.
QgsFeatureRequest& setFilterFid( QgsFeatureId fid );
//! Get the feature ID that should be fetched.
const QgsFeatureId& filterFid() const { return mFilterFid; }

//! Set feature ID that should be fetched.
//! Set feature IDs that should be fetched.
QgsFeatureRequest& setFilterFids( QgsFeatureIds fids );
//! Get feature IDs that should be fetched.
const QgsFeatureIds& filterFids() const { return mFilterFids; }

/** Set the filter expression. {@see QgsExpression}
@@ -153,6 +175,10 @@ class CORE_EXPORT QgsFeatureRequest
//! Set a subset of attributes that will be fetched. Empty list means that all attributes are used.
//! To disable fetching attributes, reset the FetchAttributes flag (which is set by default)
QgsFeatureRequest& setSubsetOfAttributes( const QgsAttributeList& attrs );
/**
* Return the subset of attributes which at least need to be fetched
* @return A list of attributes to be fetched
*/
const QgsAttributeList& subsetOfAttributes() const { return mAttrs; }

//! Set a subset of attributes by names that will be fetched
@@ -206,6 +232,11 @@ class CORE_EXPORT QgsAbstractFeatureSource
public:
virtual ~QgsAbstractFeatureSource();

/**
* Get an iterator for features matching the specified request
* @param request The request
* @return A feature iterator
*/
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request ) = 0;

protected:
@@ -143,10 +143,10 @@ void QgsRuleBasedRendererV2::Rule::updateElseRules()
}


QString QgsRuleBasedRendererV2::Rule::dump( int offset ) const
QString QgsRuleBasedRendererV2::Rule::dump( int indent ) const
{
QString off;
off.fill( QChar( ' ' ), offset );
off.fill( QChar( ' ' ), indent );
QString symbolDump = ( mSymbol ? mSymbol->dump() : QString( "[]" ) );
QString msg = off + QString( "RULE %1 - scale [%2,%3] - filter %4 - symbol %5\n" )
.arg( mLabel ).arg( mScaleMinDenom ).arg( mScaleMaxDenom )
@@ -155,7 +155,7 @@ QString QgsRuleBasedRendererV2::Rule::dump( int offset ) const
QStringList lst;
Q_FOREACH ( Rule* rule, mChildren )
{
lst.append( rule->dump( offset + 2 ) );
lst.append( rule->dump( indent + 2 ) );
}
msg += lst.join( "\n" );
return msg;
@@ -84,6 +84,7 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
class CORE_EXPORT Rule
{
public:
//! The result of rendering a rule
enum RenderResult
{
Filtered = 0, //!< The rule does not apply
@@ -95,24 +96,70 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
Rule( QgsSymbolV2* symbol, int scaleMinDenom = 0, int scaleMaxDenom = 0, QString filterExp = QString(),
QString label = QString(), QString description = QString(), bool elseRule = false );
~Rule();
QString dump( int offset = 0 ) const;

/**
* Dump for debug purpose
* @param indent How many characters to indent. Will increase by two with every of the recursive calls
* @return A string representing this rule
*/
QString dump( int indent = 0 ) const;

/**
* Return the attributes used to evaluate the expression of this rule
* @return A set of attribute names
*/
QSet<QString> usedAttributes();

QgsSymbolV2List symbols( const QgsRenderContext& context = QgsRenderContext() );

//! @note not available in python bindings
QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, QString rule = "" );

//! @note added in 2.6
QgsLegendSymbolListV2 legendSymbolItemsV2( int currentLevel = -1 ) const;

/**
* Check if a given feature shall be rendered by this rule
*
* @param f The feature to test
* @param context The context in which the rendering happens
* @return True if the feature shall be rendered
*/
bool isFilterOK( QgsFeature& f, QgsRenderContext *context = 0 ) const;

/**
* Check if this rule applies for a given scale
* @param scale The scale to check. If set to 0, it will always return true.
*
* @return If the rule will be evaluated at this scale
*/
bool isScaleOK( double scale ) const;

QgsSymbolV2* symbol() { return mSymbol; }
QString label() const { return mLabel; }
bool dependsOnScale() const { return mScaleMinDenom != 0 || mScaleMaxDenom != 0; }
int scaleMinDenom() const { return mScaleMinDenom; }
int scaleMaxDenom() const { return mScaleMaxDenom; }

/**
* A filter that will check if this rule applies
* @return An expression
*/
QgsExpression* filter() const { return mFilter; }

/**
* A filter that will check if this rule applies
* @return An expression
*/
QString filterExpression() const { return mFilterExp; }

/**
* A human readable description for this rule
*
* @return Description
*/
QString description() const { return mDescription; }

//! @note added in 2.6
//! @deprecated use active instead
bool checkState() const { return mIsActive; }
@@ -133,13 +180,41 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
//! set a new symbol (or NULL). Deletes old symbol.
void setSymbol( QgsSymbolV2* sym );
void setLabel( QString label ) { mLabel = label; }

/**
* Set the minimum denominator for which this rule shall apply.
* E.g. 1000 if it shall be evaluated between 1:1000 and 1:100'000
* Set to 0 to disable the minimum check
* @param scaleMinDenom The minimum scale denominator for this rule
*/
void setScaleMinDenom( int scaleMinDenom ) { mScaleMinDenom = scaleMinDenom; }

/**
* Set the maximum denominator for which this rule shall apply.
* E.g. 100'000 if it shall be evaluated between 1:1000 and 1:100'000
* Set to 0 to disable the maximum check
* @param scaleMaxDenom maximum scale denominator for this rule
*/
void setScaleMaxDenom( int scaleMaxDenom ) { mScaleMaxDenom = scaleMaxDenom; }

/**
* Set the expression used to check if a given feature shall be rendered with this rule
*
* @param filterExp An expression
*/
void setFilterExpression( QString filterExp ) { mFilterExp = filterExp; initFilter(); }

/**
* Set a human readable description for this rule
*
* @param description Description
*/
void setDescription( QString description ) { mDescription = description; }

//! @note added in 2.6
//! @deprecated use setActive instead
void setCheckState( bool state ) { mIsActive = state; }

/**
* Sets if this rule is active
* @param state Determines if the rule should be activated or deactivated
@@ -156,14 +231,26 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2

//! prepare the rule for rendering and its children (build active children array)
Q_DECL_DEPRECATED bool startRender( QgsRenderContext& context, const QgsFields& fields );

//! prepare the rule for rendering and its children (build active children array)
bool startRender( QgsRenderContext& context, const QgsFields& fields, QString& filter );

//! get all used z-levels from this rule and children
QSet<int> collectZLevels();

//! assign normalized z-levels [0..N-1] for this rule's symbol for quick access during rendering
//! @note not available in python bindings
void setNormZLevels( const QMap<int, int>& zLevelsToNormLevels );

/**
* Render a given feature, will recursively call subclasses and only render if the constraints apply.
*
* @param featToRender The feature to render
* @param context The rendering context
* @param renderQueue The rendering queue to which the feature should be added
* @return The result of the rendering. In explicit if the feature is added to the queue or
* the reason for not rendering the feature.
*/
RenderResult renderFeature( FeatureToRender& featToRender, QgsRenderContext& context, RenderQueue& renderQueue );

//! only tell whether a feature will be rendered without actually rendering it
@@ -175,34 +262,85 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
//! tell which rules will be used to render the feature
RuleList rulesForFeature( QgsFeature& feat, QgsRenderContext* context = 0 );

/**
* Stop a rendering process. Used to clean up the internal state of this rule
*
* @param context The rendering context
*/
void stopRender( QgsRenderContext& context );

/**
* Create a rule from an XML definition
*
* @param ruleElem The XML rule element
* @param symbolMap Symbol map
*
* @return A new rule
*/
static Rule* create( QDomElement& ruleElem, QgsSymbolV2Map& symbolMap );

/**
* Return all children rules of this rule
*
* @return A list of rules
*/
RuleList& children() { return mChildren; }

/**
* Returns all children, grand-children, grand-grand-children, grand-gra... you get it
*
* @return A list of descendant rules
*/
RuleList descendants() const { RuleList l; Q_FOREACH ( Rule *c, mChildren ) { l += c; l += c->descendants(); } return l; }

/**
* The parent rule
*
* @return Parent rule
*/
Rule* parent() { return mParent; }

//! add child rule, take ownership, sets this as parent
void appendChild( Rule* rule );

//! add child rule, take ownership, sets this as parent
void insertChild( int i, Rule* rule );

//! delete child rule
void removeChild( Rule* rule );

//! delete child rule
void removeChildAt( int i );

//! take child rule out, set parent as null
void takeChild( Rule* rule );

//! take child rule out, set parent as null
Rule* takeChildAt( int i );

//! Try to find a rule given its unique key
//! @note added in 2.6
Rule* findRuleByKey( 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
*
* @param iselse If true, this rule is an ELSE rule
*/
void setIsElse( bool iselse ) { mElseRule = iselse; }

/**
* Check if this rule is an ELSE rule
*
* @return True if this rule is an else rule
*/
bool isElse() { return mElseRule; }

protected:

0 comments on commit 72608b0

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