26using namespace Qt::StringLiterals;
35 mUuid = !
uuid.isEmpty() ?
uuid : QUuid::createUuid().toString();
45 mUuid = !
uuid.isEmpty() ?
uuid : QUuid::createUuid().toString();
143 toSld( doc, element, props.value( u
"attribute"_s, QString() ).toString(), context, firstRange );
148 if ( !
mSymbol || classAttribute.isEmpty() )
151 QString attrName = classAttribute;
153 QDomElement ruleElem = doc.createElement( u
"se:Rule"_s );
155 QDomElement nameElem = doc.createElement( u
"se:Name"_s );
156 nameElem.appendChild( doc.createTextNode(
mLabel ) );
157 ruleElem.appendChild( nameElem );
159 QDomElement descrElem = doc.createElement( u
"se:Description"_s );
160 QDomElement titleElem = doc.createElement( u
"se:Title"_s );
162 titleElem.appendChild( doc.createTextNode( !
mLabel.isEmpty() ?
mLabel : descrStr ) );
163 descrElem.appendChild( titleElem );
164 ruleElem.appendChild( descrElem );
170 mSymbol->toSld( doc, ruleElem, context );
178 element.appendChild( ruleElem );
211 return !( *
this == other );
238 QString valueStr = QLocale().toString( value,
'f',
mPrecision );
242 valueStr = valueStr.mid( 1 );
247 QString valueStr = QLocale().toString( value *
mNumberScale,
'f', 0 );
248 if ( valueStr ==
"-0"_L1 )
250 if ( valueStr !=
"0"_L1 )
262 return legend.replace(
"%1"_L1, lowerStr ).replace(
"%2"_L1, upperStr );
267 mFormat = element.attribute( u
"format"_s, element.attribute( u
"prefix"_s, u
" "_s ) +
"%1" + element.attribute( u
"separator"_s, u
" - "_s ) +
"%2" + element.attribute( u
"suffix"_s, u
" "_s ) );
268 setPrecision( element.attribute( u
"decimalplaces"_s, u
"4"_s ).toInt() );
269 mTrimTrailingZeroes = element.attribute( u
"trimtrailingzeroes"_s, u
"false"_s ) ==
"true"_L1;
274 element.setAttribute( u
"format"_s,
mFormat );
275 element.setAttribute( u
"decimalplaces"_s,
mPrecision );
276 element.setAttribute( u
"trimtrailingzeroes"_s,
mTrimTrailingZeroes ? u
"true"_s : u
"false"_s );
Contains the information about a classification range.
Represents a value range for a QgsGraduatedSymbolRenderer.
void setUpperValue(double upperValue)
Sets the upper bound of the range.
QgsRendererRange()=default
QString label() const
Returns the label used for the range.
void setSymbol(QgsSymbol *s)
Sets the symbol used for the range.
std::unique_ptr< QgsSymbol > mSymbol
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, QVariantMap props, bool firstRange=false) const
Creates a DOM element representing the range in SLD format.
QgsRendererRange & operator=(QgsRendererRange range)
QgsSymbol * symbol() const
Returns the symbol used for the range.
void setLabel(const QString &label)
Sets the label used for the range.
bool renderState() const
Returns true if the range should be rendered.
void setRenderState(bool render)
Sets whether the range should be rendered.
QString dump() const
Dumps a string representation of the range.
double upperValue() const
Returns the upper bound of the range.
void setLowerValue(double lowerValue)
Sets the lower bound of the range.
QString uuid() const
Returns the unique identifier for this range.
double lowerValue() const
Returns the lower bound of the range.
bool operator<(const QgsRendererRange &other) const
Holds SLD export options and other information related to SLD export of a QGIS layer style.
void setExtraProperties(const QVariantMap &properties)
Sets the open ended set of properties that can drive/inform the SLD encoding.
static Q_DECL_DEPRECATED bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
Creates an OGC function element.
static bool hasSldSymbolizer(const QDomElement &element)
Returns true if a DOM element contains an SLD Symbolizer element.
Abstract base class for all rendered symbols.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).