Skip to content
Permalink
Browse files

Update Python bindings

  • Loading branch information
wonder-sk committed Sep 1, 2014
1 parent 514c49d commit ee3d67bcf3e1ef46195ddaa160884bdce5ff2637
@@ -223,6 +223,7 @@

%Include symbology-ng/qgscategorizedsymbolrendererv2.sip
%Include symbology-ng/qgsgraduatedsymbolrendererv2.sip
%Include symbology-ng/qgslegendsymbolitemv2.sip
%Include symbology-ng/qgssinglesymbolrendererv2.sip
%Include symbology-ng/qgspointdisplacementrenderer.sip
%Include symbology-ng/qgsrulebasedrendererv2.sip
@@ -20,7 +20,7 @@ class QgsMapLayerLegend : QObject
* Return list of legend nodes to be used for a particular layer tree layer node.
* Ownership is transferred to the caller.
*/
virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) = 0 /Factory/;
virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer, bool applyLayerNodeProperties = true ) = 0 /Factory/;

// TODO: support for layer tree view delegates

@@ -39,6 +39,31 @@ class QgsMapLayerLegend : QObject
};


/**
* Miscellaneous utility functions for handling of map layer legend
*
* @note added in 2.6
*/
class QgsMapLayerLegendUtils
{
%TypeHeaderCode
#include <qgsmaplayerlegend.h>
%End
public:
static void setLegendNodeOrder( QgsLayerTreeLayer* nodeLayer, const QList<int>& order );
static QList<int> legendNodeOrder( QgsLayerTreeLayer* nodeLayer );
static bool hasLegendNodeOrder( QgsLayerTreeLayer* nodeLayer );

static void setLegendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex, const QString& newLabel );
static QString legendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex );
static bool hasLegendNodeUserLabel( QgsLayerTreeLayer* nodeLayer, int originalIndex );

//! update according to layer node's custom properties (order of items, user labels for items)
static void applyLayerNodeProperties( QgsLayerTreeLayer* nodeLayer, QList<QgsLayerTreeModelLegendNode*>& nodes );
};



/** Default legend implementation for vector layers
* @note added in 2.6
*/
@@ -50,7 +75,7 @@ class QgsDefaultVectorLayerLegend : QgsMapLayerLegend
public:
explicit QgsDefaultVectorLayerLegend( QgsVectorLayer* vl );

virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) /Factory/;
virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer, bool applyLayerNodeProperties = true ) /Factory/;

};

@@ -66,7 +91,7 @@ class QgsDefaultRasterLayerLegend : QgsMapLayerLegend
public:
explicit QgsDefaultRasterLayerLegend( QgsRasterLayer* rl );

virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) /Factory/;
virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer, bool applyLayerNodeProperties = true ) /Factory/;

};

@@ -82,7 +107,7 @@ class QgsDefaultPluginLayerLegend : QgsMapLayerLegend
public:
explicit QgsDefaultPluginLayerLegend( QgsPluginLayer* pl );

virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer ) /Factory/;
virtual QList<QgsLayerTreeModelLegendNode*> createLayerTreeModelLegendNodes( QgsLayerTreeLayer* nodeLayer, bool applyLayerNodeProperties = true ) /Factory/;

};

@@ -0,0 +1,47 @@

/**
* The class stores information about one class/rule of a vector layer renderer in a unified way
* that can be used by legend model for rendering of legend.
*
* @see QgsSymbolV2LegendNode
* @note added in 2.6
*/
class QgsLegendSymbolItemV2
{
%TypeHeaderCode
#include <qgslegendsymbolitemv2.h>
%End

public:
QgsLegendSymbolItemV2();
//! Construct item. Does not take ownership of symbol (makes internal clone)
QgsLegendSymbolItemV2( QgsSymbolV2* symbol, const QString& label, const QString& ruleKey, bool checkable = false, int scaleMinDenom = -1, int scaleMaxDenom = -1 );
~QgsLegendSymbolItemV2();
QgsLegendSymbolItemV2( const QgsLegendSymbolItemV2& other );
//QgsLegendSymbolItemV2& operator=( const QgsLegendSymbolItemV2& other );

//! Return associated symbol. May be null.
QgsSymbolV2* symbol() const;
//! Return text label
QString label() const;
//! Return unique identifier of the rule for identification of the item within renderer
QString ruleKey() const;
//! Return whether the item is user-checkable - whether renderer supports enabling/disabling it
bool isCheckable() const;

//! Used for older code that identifies legend entries from symbol pointer within renderer
QgsSymbolV2* legacyRuleKey() const;

//! Determine whether given scale is within the scale range. Returns true if scale or scale range is invalid (value <= 0)
bool isScaleOK( double scale ) const;
//! Min scale denominator of the scale range. For range 1:1000 to 1:2000 this will return 1000.
//! Value <= 0 means the range is unbounded on this side
int scaleMinDenom() const;
//! Max scale denominator of the scale range. For range 1:1000 to 1:2000 this will return 2000.
//! Value <= 0 means the range is unbounded on this side
int scaleMaxDenom() const;

};


typedef QList< QgsLegendSymbolItemV2 > QgsLegendSymbolListV2;
@@ -144,6 +144,15 @@ class QgsFeatureRendererV2
//! @note not available in python bindings
// virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, QString rule = "" );

//! Return a list of symbology items for the legend. Better choice than legendSymbolItems().
//! Default fallback implementation just uses legendSymbolItems() implementation
//! @node added in 2.6
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const;

//! If supported by the renderer, return classification attribute for the use in legend
//! @note added in 2.6
virtual QString legendClassificationAttribute() const;

//! set type and size of editing vertex markers for subsequent rendering
void setVertexMarkerAppearance( int type, int size );

0 comments on commit ee3d67b

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