mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Move some useful utility methods to QgsSymbolLayerUtils
This commit is contained in:
parent
60360f9b97
commit
8f4893d8b2
@ -22,6 +22,8 @@ try:
|
||||
QgsSymbolLayerUtils.decodeBrushStyle = staticmethod(QgsSymbolLayerUtils.decodeBrushStyle)
|
||||
QgsSymbolLayerUtils.encodeSldBrushStyle = staticmethod(QgsSymbolLayerUtils.encodeSldBrushStyle)
|
||||
QgsSymbolLayerUtils.decodeSldBrushStyle = staticmethod(QgsSymbolLayerUtils.decodeSldBrushStyle)
|
||||
QgsSymbolLayerUtils.penCapStyleToEndCapStyle = staticmethod(QgsSymbolLayerUtils.penCapStyleToEndCapStyle)
|
||||
QgsSymbolLayerUtils.penJoinStyleToJoinStyle = staticmethod(QgsSymbolLayerUtils.penJoinStyleToJoinStyle)
|
||||
QgsSymbolLayerUtils.hasSldSymbolizer = staticmethod(QgsSymbolLayerUtils.hasSldSymbolizer)
|
||||
QgsSymbolLayerUtils.decodeCoordinateReference = staticmethod(QgsSymbolLayerUtils.decodeCoordinateReference)
|
||||
QgsSymbolLayerUtils.encodeCoordinateReference = staticmethod(QgsSymbolLayerUtils.encodeCoordinateReference)
|
||||
|
@ -60,6 +60,20 @@ Contains utility functions for working with symbols and symbol layers.
|
||||
static QString encodeSldBrushStyle( Qt::BrushStyle style );
|
||||
static Qt::BrushStyle decodeSldBrushStyle( const QString &str );
|
||||
|
||||
static Qgis::EndCapStyle penCapStyleToEndCapStyle( Qt::PenCapStyle style );
|
||||
%Docstring
|
||||
Converts a Qt pen cap style to a QGIS end cap style.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
static Qgis::JoinStyle penJoinStyleToJoinStyle( Qt::PenJoinStyle style );
|
||||
%Docstring
|
||||
Converts a Qt pen joinstyle to a QGIS join style.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
static bool hasSldSymbolizer( const QDomElement &element );
|
||||
%Docstring
|
||||
Returns ``True`` if a DOM ``element`` contains an SLD Symbolizer element.
|
||||
|
@ -22,6 +22,8 @@ try:
|
||||
QgsSymbolLayerUtils.decodeBrushStyle = staticmethod(QgsSymbolLayerUtils.decodeBrushStyle)
|
||||
QgsSymbolLayerUtils.encodeSldBrushStyle = staticmethod(QgsSymbolLayerUtils.encodeSldBrushStyle)
|
||||
QgsSymbolLayerUtils.decodeSldBrushStyle = staticmethod(QgsSymbolLayerUtils.decodeSldBrushStyle)
|
||||
QgsSymbolLayerUtils.penCapStyleToEndCapStyle = staticmethod(QgsSymbolLayerUtils.penCapStyleToEndCapStyle)
|
||||
QgsSymbolLayerUtils.penJoinStyleToJoinStyle = staticmethod(QgsSymbolLayerUtils.penJoinStyleToJoinStyle)
|
||||
QgsSymbolLayerUtils.hasSldSymbolizer = staticmethod(QgsSymbolLayerUtils.hasSldSymbolizer)
|
||||
QgsSymbolLayerUtils.decodeCoordinateReference = staticmethod(QgsSymbolLayerUtils.decodeCoordinateReference)
|
||||
QgsSymbolLayerUtils.encodeCoordinateReference = staticmethod(QgsSymbolLayerUtils.encodeCoordinateReference)
|
||||
|
@ -60,6 +60,20 @@ Contains utility functions for working with symbols and symbol layers.
|
||||
static QString encodeSldBrushStyle( Qt::BrushStyle style );
|
||||
static Qt::BrushStyle decodeSldBrushStyle( const QString &str );
|
||||
|
||||
static Qgis::EndCapStyle penCapStyleToEndCapStyle( Qt::PenCapStyle style );
|
||||
%Docstring
|
||||
Converts a Qt pen cap style to a QGIS end cap style.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
static Qgis::JoinStyle penJoinStyleToJoinStyle( Qt::PenJoinStyle style );
|
||||
%Docstring
|
||||
Converts a Qt pen joinstyle to a QGIS join style.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
static bool hasSldSymbolizer( const QDomElement &element );
|
||||
%Docstring
|
||||
Returns ``True`` if a DOM ``element`` contains an SLD Symbolizer element.
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "qgsmultipolygon.h"
|
||||
#include "qgsmultilinestring.h"
|
||||
#include "qgspainting.h"
|
||||
#include "qgssymbollayerutils.h"
|
||||
|
||||
//
|
||||
// QgsGeometryPaintEngine
|
||||
@ -395,42 +396,6 @@ void QgsGeometryPaintEngine::addStrokedLine( const QgsLineString *line, double p
|
||||
}
|
||||
}
|
||||
|
||||
Qgis::EndCapStyle QgsGeometryPaintEngine::penStyleToCapStyle( Qt::PenCapStyle style )
|
||||
{
|
||||
switch ( style )
|
||||
{
|
||||
case Qt::FlatCap:
|
||||
return Qgis::EndCapStyle::Flat;
|
||||
case Qt::SquareCap:
|
||||
return Qgis::EndCapStyle::Square;
|
||||
case Qt::RoundCap:
|
||||
return Qgis::EndCapStyle::Round;
|
||||
case Qt::MPenCapStyle:
|
||||
// undocumented?
|
||||
break;
|
||||
}
|
||||
|
||||
return Qgis::EndCapStyle::Round;
|
||||
}
|
||||
|
||||
Qgis::JoinStyle QgsGeometryPaintEngine::penStyleToJoinStyle( Qt::PenJoinStyle style )
|
||||
{
|
||||
switch ( style )
|
||||
{
|
||||
case Qt::MiterJoin:
|
||||
case Qt::SvgMiterJoin:
|
||||
return Qgis::JoinStyle::Miter;
|
||||
case Qt::BevelJoin:
|
||||
return Qgis::JoinStyle::Bevel;
|
||||
case Qt::RoundJoin:
|
||||
return Qgis::JoinStyle::Round;
|
||||
case Qt::MPenJoinStyle:
|
||||
// undocumented?
|
||||
break;
|
||||
}
|
||||
return Qgis::JoinStyle::Round;
|
||||
}
|
||||
|
||||
// based on QPainterPath::toSubpathPolygons()
|
||||
void QgsGeometryPaintEngine::addSubpathGeometries( const QPainterPath &path, const QTransform &matrix )
|
||||
{
|
||||
@ -439,8 +404,8 @@ void QgsGeometryPaintEngine::addSubpathGeometries( const QPainterPath &path, con
|
||||
|
||||
const bool transformIsIdentity = matrix.isIdentity();
|
||||
|
||||
const Qgis::EndCapStyle endCapStyle = penStyleToCapStyle( mPen.capStyle() );
|
||||
const Qgis::JoinStyle joinStyle = penStyleToJoinStyle( mPen.joinStyle() );
|
||||
const Qgis::EndCapStyle endCapStyle = QgsSymbolLayerUtils::penCapStyleToEndCapStyle( mPen.capStyle() );
|
||||
const Qgis::JoinStyle joinStyle = QgsSymbolLayerUtils::penJoinStyleToJoinStyle( mPen.joinStyle() );
|
||||
const double penWidth = mPen.widthF() <= 0 ? 1 : mPen.widthF();
|
||||
const double miterLimit = mPen.miterLimit();
|
||||
|
||||
|
@ -103,8 +103,6 @@ class QgsGeometryPaintEngine: public QPaintEngine
|
||||
|
||||
void addSubpathGeometries( const QPainterPath &path, const QTransform &matrix );
|
||||
void addStrokedLine( const QgsLineString *line, double penWidth, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit, const QTransform *matrix );
|
||||
static Qgis::EndCapStyle penStyleToCapStyle( Qt::PenCapStyle style );
|
||||
static Qgis::JoinStyle penStyleToJoinStyle( Qt::PenJoinStyle style );
|
||||
|
||||
bool mUsePathStroker = false;
|
||||
QPen mPen;
|
||||
|
@ -392,6 +392,42 @@ Qt::BrushStyle QgsSymbolLayerUtils::decodeSldBrushStyle( const QString &str )
|
||||
return Qt::NoBrush;
|
||||
}
|
||||
|
||||
Qgis::EndCapStyle QgsSymbolLayerUtils::penCapStyleToEndCapStyle( Qt::PenCapStyle style )
|
||||
{
|
||||
switch ( style )
|
||||
{
|
||||
case Qt::FlatCap:
|
||||
return Qgis::EndCapStyle::Flat;
|
||||
case Qt::SquareCap:
|
||||
return Qgis::EndCapStyle::Square;
|
||||
case Qt::RoundCap:
|
||||
return Qgis::EndCapStyle::Round;
|
||||
case Qt::MPenCapStyle:
|
||||
// undocumented?
|
||||
break;
|
||||
}
|
||||
|
||||
return Qgis::EndCapStyle::Round;
|
||||
}
|
||||
|
||||
Qgis::JoinStyle QgsSymbolLayerUtils::penJoinStyleToJoinStyle( Qt::PenJoinStyle style )
|
||||
{
|
||||
switch ( style )
|
||||
{
|
||||
case Qt::MiterJoin:
|
||||
case Qt::SvgMiterJoin:
|
||||
return Qgis::JoinStyle::Miter;
|
||||
case Qt::BevelJoin:
|
||||
return Qgis::JoinStyle::Bevel;
|
||||
case Qt::RoundJoin:
|
||||
return Qgis::JoinStyle::Round;
|
||||
case Qt::MPenJoinStyle:
|
||||
// undocumented?
|
||||
break;
|
||||
}
|
||||
return Qgis::JoinStyle::Round;
|
||||
}
|
||||
|
||||
bool QgsSymbolLayerUtils::hasSldSymbolizer( const QDomElement &element )
|
||||
{
|
||||
const QDomNodeList children = element.childNodes();
|
||||
|
@ -94,6 +94,20 @@ class CORE_EXPORT QgsSymbolLayerUtils
|
||||
static QString encodeSldBrushStyle( Qt::BrushStyle style );
|
||||
static Qt::BrushStyle decodeSldBrushStyle( const QString &str );
|
||||
|
||||
/**
|
||||
* Converts a Qt pen cap style to a QGIS end cap style.
|
||||
*
|
||||
* \since QGIS 3.42
|
||||
*/
|
||||
static Qgis::EndCapStyle penCapStyleToEndCapStyle( Qt::PenCapStyle style );
|
||||
|
||||
/**
|
||||
* Converts a Qt pen joinstyle to a QGIS join style.
|
||||
*
|
||||
* \since QGIS 3.42
|
||||
*/
|
||||
static Qgis::JoinStyle penJoinStyleToJoinStyle( Qt::PenJoinStyle style );
|
||||
|
||||
/**
|
||||
* Returns TRUE if a DOM \a element contains an SLD Symbolizer element.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user