QGIS/python/core/symbology/qgsgraduatedsymbolrenderer.sip.in

466 lines
13 KiB
Plaintext
Raw Normal View History

2017-06-06 11:03:05 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
2017-08-06 13:39:03 +02:00
* src/core/symbology/qgsgraduatedsymbolrenderer.h *
2017-06-06 11:03:05 +02:00
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2017-09-12 00:48:40 +02:00
2016-08-06 11:01:42 +02:00
class QgsRendererRange
{
2017-06-06 11:03:05 +02:00
%TypeHeaderCode
2017-06-06 11:03:05 +02:00
#include "qgsgraduatedsymbolrenderer.h"
%End
public:
2016-08-06 11:01:42 +02:00
QgsRendererRange();
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsRendererRange.
%End
QgsRendererRange( double lowerValue, double upperValue, QgsSymbol *symbol /Transfer/, const QString &label, bool render = true );
QgsRendererRange( const QgsRendererRange &range );
2017-06-06 11:03:05 +02:00
bool operator<( const QgsRendererRange &other ) const;
double lowerValue() const;
double upperValue() const;
QgsSymbol *symbol() const;
QString label() const;
void setSymbol( QgsSymbol *s /Transfer/ );
void setLabel( const QString &label );
void setLowerValue( double lowerValue );
void setUpperValue( double upperValue );
bool renderState() const;
void setRenderState( bool render );
QString dump() const;
2017-06-06 11:03:05 +02:00
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props, bool firstRange = false ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Creates a DOM element representing the range in SLD format.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param doc: DOM document
:param element: destination DOM element
:param props: graduated renderer properties
:param firstRange: set to true if the range is the first range, where the lower value uses a <= test
rather than a < test.
2017-06-06 11:03:05 +02:00
%End
2014-05-27 23:22:50 +02:00
protected:
2017-06-06 11:03:05 +02:00
void swap( QgsRendererRange &other );
};
2016-08-06 11:01:42 +02:00
typedef QList<QgsRendererRange> QgsRangeList;
2016-08-06 11:01:42 +02:00
class QgsRendererRangeLabelFormat
{
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.6
%End
%TypeHeaderCode
2017-06-06 11:03:05 +02:00
#include "qgsgraduatedsymbolrenderer.h"
%End
public:
2016-08-06 11:01:42 +02:00
QgsRendererRangeLabelFormat();
QgsRendererRangeLabelFormat( const QString &format, int precision = 4, bool trimTrailingZeroes = false );
bool operator==( const QgsRendererRangeLabelFormat &other ) const;
bool operator!=( const QgsRendererRangeLabelFormat &other ) const;
QString format() const;
void setFormat( const QString &format );
2017-06-06 11:03:05 +02:00
int precision() const;
void setPrecision( int precision );
bool trimTrailingZeroes() const;
void setTrimTrailingZeroes( bool trimTrailingZeroes );
2014-10-09 09:37:19 +13:00
QString labelForRange( double lower, double upper ) const /PyName=labelForLowerUpper/;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
2017-06-06 11:03:05 +02:00
.. note::
labelForLowerUpper in Python bindings
%End
2016-08-06 11:01:42 +02:00
QString labelForRange( const QgsRendererRange &range ) const;
QString formatNumber( double value ) const;
void setFromDomElement( QDomElement &element );
void saveToDomElement( QDomElement &element );
2014-10-03 06:14:38 +13:00
static const int MAX_PRECISION;
static const int MIN_PRECISION;
2014-10-03 06:14:38 +13:00
2017-06-06 11:03:05 +02:00
protected:
};
2016-08-06 11:01:42 +02:00
class QgsGraduatedSymbolRenderer : QgsFeatureRenderer
{
2017-06-06 11:03:05 +02:00
%TypeHeaderCode
2017-06-06 11:03:05 +02:00
#include "qgsgraduatedsymbolrenderer.h"
%End
public:
2015-05-03 17:10:32 +02:00
QgsGraduatedSymbolRenderer( const QString &attrName = QString(), const QgsRangeList &ranges = QgsRangeList() );
~QgsGraduatedSymbolRenderer();
2018-04-18 12:51:48 +02:00
virtual QgsSymbol *symbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;
2018-04-18 12:51:48 +02:00
virtual QgsSymbol *originalSymbolForFeature( QgsFeature &feature, QgsRenderContext &context ) const;
virtual void startRender( QgsRenderContext &context, const QgsFields &fields );
virtual void stopRender( QgsRenderContext &context );
virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
virtual QString dump() const;
virtual QgsGraduatedSymbolRenderer *clone() const /Factory/;
2017-06-06 11:03:05 +02:00
virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const;
2016-08-06 11:01:42 +02:00
virtual QgsFeatureRenderer::Capabilities capabilities();
2018-04-18 12:51:48 +02:00
virtual QgsSymbolList symbols( QgsRenderContext &context ) const;
QString classAttribute() const;
void setClassAttribute( const QString &attr );
2017-06-06 11:03:05 +02:00
const QgsRangeList &ranges() const;
bool updateRangeSymbol( int rangeIndex, QgsSymbol *symbol /Transfer/ );
bool updateRangeLabel( int rangeIndex, const QString &label );
bool updateRangeUpperValue( int rangeIndex, double value );
bool updateRangeLowerValue( int rangeIndex, double value );
bool updateRangeRenderState( int rangeIndex, bool render );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.5
%End
void addClass( QgsSymbol *symbol );
void addClass( const QgsRendererRange &range ) /PyName=addClassRange/;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
2017-06-06 11:03:05 +02:00
.. note::
available in Python bindings as addClassRange
%End
void addClass( double lower, double upper ) /PyName=addClassLowerUpper/;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
2017-06-06 11:03:05 +02:00
.. note::
available in Python bindings as addClassLowerUpper
%End
void addBreak( double breakValue, bool updateSymbols = true );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Add a breakpoint by splitting existing classes so that the specified
value becomes a break between two classes.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param breakValue: position to insert break
:param updateSymbols: set to true to reapply ramp colors to the new
symbol ranges
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.9
%End
void deleteClass( int idx );
2013-06-23 16:00:16 +02:00
void deleteAllClasses();
void moveClass( int from, int to );
2017-06-06 11:03:05 +02:00
%Docstring
Moves the category at index position from to index position to.
%End
2013-06-23 16:00:16 +02:00
bool rangesOverlap() const;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Tests whether classes assigned to the renderer have ranges which overlap.
:return: true if ranges overlap
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.10
%End
bool rangesHaveGaps() const;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Tests whether classes assigned to the renderer have gaps between the ranges.
:return: true if ranges have gaps
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.10
%End
2013-06-23 16:00:16 +02:00
void sortByValue( Qt::SortOrder order = Qt::AscendingOrder );
void sortByLabel( Qt::SortOrder order = Qt::AscendingOrder );
enum Mode
{
EqualInterval,
Quantile,
Jenks,
StdDev,
Pretty,
Custom
};
Mode mode() const;
void setMode( Mode mode );
void updateClasses( QgsVectorLayer *vlayer, Mode mode, int nclasses );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Recalculate classes for a layer
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param vlayer: The layer being rendered (from which data values are calculated)
:param mode: The calculation mode
:param nclasses: The number of classes to calculate (approximate for some modes)
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.6
%End
2015-05-03 17:10:32 +02:00
2016-08-06 11:01:42 +02:00
const QgsRendererRangeLabelFormat &labelFormat() const;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Return the label format used to generate default classification labels
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.6
%End
2016-08-06 11:01:42 +02:00
void setLabelFormat( const QgsRendererRangeLabelFormat &labelFormat, bool updateRanges = false );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Set the label format used to generate default classification labels
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param labelFormat: The string appended to classification labels
:param updateRanges: If true then ranges ending with the old unit string are updated to the new.
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.6
%End
void calculateLabelPrecision( bool updateRanges = true );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Reset the label decimal places to a numberbased on the minimum class interval
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param updateRanges: if true then ranges currently using the default label will be updated
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.6
%End
2017-06-06 11:03:05 +02:00
static QgsGraduatedSymbolRenderer *createRenderer( QgsVectorLayer *vlayer,
const QString &attrName,
int classes,
Mode mode,
QgsSymbol *symbol /Transfer/,
QgsColorRamp *ramp /Transfer/,
const QgsRendererRangeLabelFormat &legendFormat = QgsRendererRangeLabelFormat() );
%Docstring
2017-12-15 10:36:55 -04:00
Creates a new graduated renderer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param vlayer: vector layer
:param attrName: attribute to classify
:param classes: number of classes
:param mode: classification mode
:param symbol: base symbol
:param ramp: color ramp for classes
:param legendFormat:
:return: new QgsGraduatedSymbolRenderer object
2017-06-06 11:03:05 +02:00
%End
2017-06-06 11:03:05 +02:00
static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) /Factory/;
%Docstring
create renderer from XML element
%End
2017-06-06 11:03:05 +02:00
virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context );
virtual QgsLegendSymbolList legendSymbolItems() const;
2018-04-18 12:51:48 +02:00
virtual QSet< QString > legendKeysForFeature( QgsFeature &feature, QgsRenderContext &context ) const;
QgsSymbol *sourceSymbol();
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the renderer's source symbol, which is the base symbol used for the each classes' symbol before applying
the classes' color.
.. seealso:: :py:func:`setSourceSymbol`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`sourceColorRamp`
2017-06-06 11:03:05 +02:00
%End
void setSourceSymbol( QgsSymbol *sym /Transfer/ );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the source symbol for the renderer, which is the base symbol used for the each classes' symbol before applying
the classes' color.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param sym: source symbol, ownership is transferred to the renderer
.. seealso:: :py:func:`sourceSymbol`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`setSourceColorRamp`
2017-06-06 11:03:05 +02:00
%End
QgsColorRamp *sourceColorRamp();
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the source color ramp, from which each classes' color is derived.
.. seealso:: :py:func:`setSourceColorRamp`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`sourceSymbol`
2017-06-06 11:03:05 +02:00
%End
2015-09-01 16:06:35 +10:00
void setSourceColorRamp( QgsColorRamp *ramp /Transfer/ );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the source color ramp.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param ramp: color ramp. Ownership is transferred to the renderer
2017-06-06 11:03:05 +02:00
%End
2015-09-01 16:06:35 +10:00
void updateColorRamp( QgsColorRamp *ramp /Transfer/ = 0 );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Update the color ramp used. Also updates all symbols colors.
Doesn't alter current breaks.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param ramp: color ramp. Ownership is transferred to the renderer
2017-06-06 11:03:05 +02:00
%End
void updateSymbols( QgsSymbol *sym );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Update all the symbols but leave breaks and colors. This method also sets the source
symbol for the renderer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param sym: source symbol to use for classes. Ownership is not transferred.
.. seealso:: :py:func:`setSourceSymbol`
2017-06-06 11:03:05 +02:00
%End
void setSymbolSizes( double minSize, double maxSize );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
set varying symbol size for classes
.. note::
the classes must already be set so that symbols exist
2017-12-15 10:36:55 -04:00
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.10
%End
double minSymbolSize() const;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
return the min symbol size when graduated by size
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.10
%End
double maxSymbolSize() const;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
return the max symbol size when graduated by size
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.10
%End
2017-06-06 11:03:05 +02:00
enum GraduatedMethod
{
GraduatedColor,
GraduatedSize
};
GraduatedMethod graduatedMethod() const;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
return the method used for graduation (either size or color)
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.10
%End
void setGraduatedMethod( GraduatedMethod method );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
set the method used for graduation (either size or color)
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.10
%End
virtual bool legendSymbolItemsCheckable() const;
virtual bool legendSymbolItemChecked( const QString &key );
virtual void checkLegendSymbolItem( const QString &key, bool state = true );
virtual void setLegendSymbolItem( const QString &key, QgsSymbol *symbol /Transfer/ );
2017-06-06 11:03:05 +02:00
virtual QString legendClassificationAttribute() const;
static QgsGraduatedSymbolRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) /Factory/;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
creates a QgsGraduatedSymbolRenderer from an existing renderer.
:return: a new renderer if the conversion was possible, otherwise 0.
2017-12-16 10:38:54 -04:00
.. versionadded:: 2.6
2017-06-06 11:03:05 +02:00
%End
void setDataDefinedSizeLegend( QgsDataDefinedSizeLegend *settings /Transfer/ );
%Docstring
2017-12-15 10:36:55 -04:00
Configures appearance of legend when renderer is configured to use data-defined size for marker symbols.
This allows configuring for which values (symbol sizes) should be shown in the legend, whether to display
different symbol sizes collapsed in one legend node or separated across multiple legend nodes etc.
When renderer does not use data-defined size or does not use marker symbols, these settings will be ignored.
Takes ownership of the passed settings objects. Null pointer is a valid input that disables data-defined
size legend.
.. versionadded:: 3.0
%End
QgsDataDefinedSizeLegend *dataDefinedSizeLegend() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns configuration of appearance of legend when using data-defined size for marker symbols.
Will return null if the functionality is disabled.
.. versionadded:: 3.0
%End
protected:
2017-06-06 11:03:05 +02:00
2018-04-18 12:51:48 +02:00
QgsSymbol *symbolForValue( double value ) const;
2017-06-06 11:03:05 +02:00
%Docstring
attribute index (derived from attribute name in startRender)
%End
QString legendKeyForValue( double value ) const;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the matching legend key for a value.
2017-06-06 11:03:05 +02:00
%End
private:
2016-08-06 11:01:42 +02:00
QgsGraduatedSymbolRenderer( const QgsGraduatedSymbolRenderer & );
QgsGraduatedSymbolRenderer &operator=( const QgsGraduatedSymbolRenderer & );
};
2017-06-06 11:03:05 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
2017-08-06 13:39:03 +02:00
* src/core/symbology/qgsgraduatedsymbolrenderer.h *
2017-06-06 11:03:05 +02:00
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/