Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
407 additions
and 0 deletions.
@@ -0,0 +1,138 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layertree/qgscolorramplegendnodesettings.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsColorRampLegendNodeSettings | ||
{ | ||
%Docstring | ||
Settings for a color ramp legend node. | ||
|
||
.. versionadded:: 3.18 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgscolorramplegendnodesettings.h" | ||
%End | ||
public: | ||
|
||
enum Direction | ||
{ | ||
MinimumToMaximum, | ||
MaximumToMinimum, | ||
}; | ||
|
||
QgsColorRampLegendNodeSettings(); | ||
|
||
~QgsColorRampLegendNodeSettings(); | ||
|
||
QgsColorRampLegendNodeSettings( const QgsColorRampLegendNodeSettings &other ); | ||
%Docstring | ||
Copy constructor | ||
%End | ||
|
||
|
||
QgsColorRampLegendNodeSettings::Direction direction() const; | ||
%Docstring | ||
Returns the direction of the ramp. | ||
|
||
.. seealso:: :py:func:`setDirection` | ||
%End | ||
|
||
void setDirection( QgsColorRampLegendNodeSettings::Direction direction ); | ||
%Docstring | ||
Sets the ``direction`` of the ramp. | ||
|
||
.. seealso:: :py:func:`direction` | ||
%End | ||
|
||
QString minimumLabel() const; | ||
%Docstring | ||
Returns the label for the minimum value on the ramp. | ||
|
||
If the returned string is empty than a default value will be generated based on the associated minimum value. | ||
|
||
.. seealso:: :py:func:`maximumLabel` | ||
|
||
.. seealso:: :py:func:`setMinimumLabel` | ||
%End | ||
|
||
void setMinimumLabel( const QString &label ); | ||
%Docstring | ||
Sets the ``label`` for the minimum value on the ramp. | ||
|
||
If the ``label`` is empty than a default value will be generated based on the associated minimum value. | ||
|
||
.. seealso:: :py:func:`setMaximumLabel` | ||
|
||
.. seealso:: :py:func:`minimumLabel` | ||
%End | ||
|
||
QString maximumLabel() const; | ||
%Docstring | ||
Returns the label for the maximum value on the ramp. | ||
|
||
If the returned string is empty than a default value will be generated based on the associated maximum value. | ||
|
||
.. seealso:: :py:func:`minimumLabel` | ||
|
||
.. seealso:: :py:func:`setMaximumLabel` | ||
%End | ||
|
||
void setMaximumLabel( const QString &label ); | ||
%Docstring | ||
Sets the ``label`` for the maximum value on the ramp. | ||
|
||
If the ``label`` is empty than a default value will be generated based on the associated maximum value. | ||
|
||
.. seealso:: :py:func:`setMinimumLabel` | ||
|
||
.. seealso:: :py:func:`maximumLabel` | ||
%End | ||
|
||
const QgsNumericFormat *numericFormat() const; | ||
%Docstring | ||
Returns the numeric format used for numbers in the scalebar. | ||
|
||
.. seealso:: :py:func:`setNumericFormat` | ||
|
||
.. versionadded:: 3.12 | ||
%End | ||
|
||
void setNumericFormat( QgsNumericFormat *format /Transfer/ ); | ||
%Docstring | ||
Sets the numeric ``format`` used for numbers in the scalebar. | ||
|
||
Ownership of ``format`` is transferred to the scalebar. | ||
|
||
.. seealso:: :py:func:`numericFormat` | ||
|
||
.. versionadded:: 3.12 | ||
%End | ||
|
||
void writeXml( QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context ) const; | ||
%Docstring | ||
Writes settings to an XML ``element``. | ||
%End | ||
|
||
void readXml( const QDomElement &element, const QgsReadWriteContext &context ); | ||
%Docstring | ||
Reads settings from an XML ``element``. | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layertree/qgscolorramplegendnodesettings.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
@@ -0,0 +1,119 @@ | ||
/*************************************************************************** | ||
qgscolorramplegendnode.h | ||
-------------------------------------- | ||
Date : December 2020 | ||
Copyright : (C) 2020 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgscolorramplegendnodesettings.h" | ||
#include "qgsnumericformat.h" | ||
#include "qgsbasicnumericformat.h" | ||
#include "qgsapplication.h" | ||
#include "qgsnumericformatregistry.h" | ||
#include "qgis.h" | ||
|
||
QgsColorRampLegendNodeSettings::QgsColorRampLegendNodeSettings() | ||
: mNumericFormat( qgis::make_unique< QgsBasicNumericFormat >() ) | ||
{ | ||
} | ||
|
||
QgsColorRampLegendNodeSettings::QgsColorRampLegendNodeSettings( const QgsColorRampLegendNodeSettings &other ) | ||
: mMinimumLabel( other.mMinimumLabel ) | ||
, mMaximumLabel( other.mMaximumLabel ) | ||
, mDirection( other.mDirection ) | ||
, mNumericFormat( other.numericFormat()->clone() ) | ||
{ | ||
|
||
} | ||
|
||
QgsColorRampLegendNodeSettings &QgsColorRampLegendNodeSettings::operator=( const QgsColorRampLegendNodeSettings &other ) | ||
{ | ||
mMinimumLabel = other.mMinimumLabel; | ||
mMaximumLabel = other.mMaximumLabel; | ||
mDirection = other.mDirection; | ||
mNumericFormat.reset( other.numericFormat()->clone() ); | ||
return *this; | ||
} | ||
|
||
QgsColorRampLegendNodeSettings::~QgsColorRampLegendNodeSettings() = default; | ||
|
||
QgsColorRampLegendNodeSettings::Direction QgsColorRampLegendNodeSettings::direction() const | ||
{ | ||
return mDirection; | ||
} | ||
|
||
void QgsColorRampLegendNodeSettings::setDirection( QgsColorRampLegendNodeSettings::Direction direction ) | ||
{ | ||
mDirection = direction; | ||
} | ||
|
||
QString QgsColorRampLegendNodeSettings::minimumLabel() const | ||
{ | ||
return mMinimumLabel; | ||
} | ||
|
||
void QgsColorRampLegendNodeSettings::setMinimumLabel( const QString &label ) | ||
{ | ||
mMinimumLabel = label; | ||
} | ||
|
||
QString QgsColorRampLegendNodeSettings::maximumLabel() const | ||
{ | ||
return mMaximumLabel; | ||
} | ||
|
||
void QgsColorRampLegendNodeSettings::setMaximumLabel( const QString &label ) | ||
{ | ||
mMaximumLabel = label; | ||
} | ||
|
||
const QgsNumericFormat *QgsColorRampLegendNodeSettings::numericFormat() const | ||
{ | ||
return mNumericFormat.get(); | ||
} | ||
|
||
void QgsColorRampLegendNodeSettings::setNumericFormat( QgsNumericFormat *format ) | ||
{ | ||
mNumericFormat.reset( format ); | ||
} | ||
|
||
void QgsColorRampLegendNodeSettings::writeXml( QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context ) const | ||
{ | ||
QDomElement settingsElement = doc.createElement( QStringLiteral( "rampLegendSettings" ) ); | ||
|
||
settingsElement.setAttribute( QStringLiteral( "minimumLabel" ), mMinimumLabel ); | ||
settingsElement.setAttribute( QStringLiteral( "maximumLabel" ), mMaximumLabel ); | ||
settingsElement.setAttribute( QStringLiteral( "direction" ), static_cast< int >( mDirection ) ); | ||
|
||
QDomElement numericFormatElem = doc.createElement( QStringLiteral( "numericFormat" ) ); | ||
mNumericFormat->writeXml( numericFormatElem, doc, context ); | ||
settingsElement.appendChild( numericFormatElem ); | ||
|
||
element.appendChild( settingsElement ); | ||
} | ||
|
||
void QgsColorRampLegendNodeSettings::readXml( const QDomElement &element, const QgsReadWriteContext &context ) | ||
{ | ||
const QDomElement settingsElement = element.firstChildElement( QStringLiteral( "rampLegendSettings" ) ); | ||
if ( !settingsElement.isNull() ) | ||
{ | ||
mMinimumLabel = settingsElement.attribute( QStringLiteral( "minimumLabel" ) ); | ||
mMaximumLabel = settingsElement.attribute( QStringLiteral( "maximumLabel" ) ); | ||
mDirection = static_cast< QgsColorRampLegendNodeSettings::Direction >( settingsElement.attribute( QStringLiteral( "direction" ) ).toInt() ); | ||
|
||
QDomNodeList numericFormatNodeList = settingsElement.elementsByTagName( QStringLiteral( "numericFormat" ) ); | ||
if ( !numericFormatNodeList.isEmpty() ) | ||
{ | ||
QDomElement numericFormatElem = numericFormatNodeList.at( 0 ).toElement(); | ||
mNumericFormat.reset( QgsApplication::numericFormatRegistry()->createFromXml( numericFormatElem, context ) ); | ||
} | ||
} | ||
} |
Oops, something went wrong.