17 #ifndef QGSSYMBOLLAYERUTILS_H 18 #define QGSSYMBOLLAYERUTILS_H 20 #include "qgis_core.h" 58 static QString encodeColor(
const QColor &color );
59 static QColor decodeColor(
const QString &str );
61 static QString encodeSldAlpha(
int alpha );
62 static int decodeSldAlpha(
const QString &str );
64 static QString encodeSldFontStyle( QFont::Style style );
65 static QFont::Style decodeSldFontStyle(
const QString &str );
67 static QString encodeSldFontWeight(
int weight );
68 static int decodeSldFontWeight(
const QString &str );
70 static QString encodePenStyle( Qt::PenStyle style );
71 static Qt::PenStyle decodePenStyle(
const QString &str );
73 static QString encodePenJoinStyle( Qt::PenJoinStyle style );
74 static Qt::PenJoinStyle decodePenJoinStyle(
const QString &str );
76 static QString encodePenCapStyle( Qt::PenCapStyle style );
77 static Qt::PenCapStyle decodePenCapStyle(
const QString &str );
79 static QString encodeSldLineJoinStyle( Qt::PenJoinStyle style );
80 static Qt::PenJoinStyle decodeSldLineJoinStyle(
const QString &str );
82 static QString encodeSldLineCapStyle( Qt::PenCapStyle style );
83 static Qt::PenCapStyle decodeSldLineCapStyle(
const QString &str );
85 static QString encodeBrushStyle( Qt::BrushStyle style );
86 static Qt::BrushStyle decodeBrushStyle(
const QString &str );
88 static QString encodeSldBrushStyle( Qt::BrushStyle style );
89 static Qt::BrushStyle decodeSldBrushStyle(
const QString &str );
108 static QString encodePoint( QPointF point );
115 static QPointF decodePoint(
const QString &
string );
123 static QString encodeSize( QSizeF size );
131 static QSizeF decodeSize(
const QString &
string );
133 static QString encodeMapUnitScale(
const QgsMapUnitScale &mapUnitScale );
136 static QString encodeRealVector(
const QVector<qreal> &v );
137 static QVector<qreal> decodeRealVector(
const QString &s );
139 static QString encodeSldRealVector(
const QVector<qreal> &v );
140 static QVector<qreal> decodeSldRealVector(
const QString &s );
167 static double sizeInPixelsFromSldUom(
const QString &uom,
double size );
172 static QPainter::CompositionMode decodeBlendMode(
const QString &s );
181 static QIcon symbolPreviewIcon(
QgsSymbol *symbol, QSize size,
int padding = 0 );
192 static QPixmap symbolPreviewPixmap(
QgsSymbol *symbol, QSize size,
int padding = 0,
QgsRenderContext *customContext =
nullptr );
224 static QIcon colorRampPreviewIcon(
QgsColorRamp *ramp, QSize size,
int padding = 0 );
233 static QPixmap colorRampPreviewPixmap(
QgsColorRamp *ramp, QSize size,
int padding = 0 );
235 static void drawStippledBackground( QPainter *painter, QRect rect );
259 SymbolType *symbolCastToType =
dynamic_cast<SymbolType *
>( tmpSymbol );
261 if ( symbolCastToType )
263 return symbolCastToType;
283 static QString symbolProperties(
QgsSymbol *symbol );
291 static bool convertPolygonSymbolizerToPointMarker( QDomElement &element,
QgsSymbolLayerList &layerList );
292 static bool hasExternalGraphic( QDomElement &element );
293 static bool hasWellKnownMark( QDomElement &element );
295 static bool needFontMarker( QDomElement &element );
296 static bool needSvgMarker( QDomElement &element );
297 static bool needEllipseMarker( QDomElement &element );
298 static bool needMarkerLine( QDomElement &element );
299 static bool needLinePatternFill( QDomElement &element );
300 static bool needPointPatternFill( QDomElement &element );
301 static bool needSvgFill( QDomElement &element );
303 static void fillToSld( QDomDocument &doc, QDomElement &element,
304 Qt::BrushStyle brushStyle,
const QColor &color = QColor() );
305 static bool fillFromSld( QDomElement &element,
306 Qt::BrushStyle &brushStyle, QColor &color );
309 static void lineToSld( QDomDocument &doc, QDomElement &element,
310 Qt::PenStyle penStyle,
const QColor &color,
double width = -1,
311 const Qt::PenJoinStyle *penJoinStyle =
nullptr,
const Qt::PenCapStyle *penCapStyle =
nullptr,
312 const QVector<qreal> *customDashPattern =
nullptr,
double dashOffset = 0.0 )
SIP_SKIP;
313 static bool lineFromSld( QDomElement &element,
314 Qt::PenStyle &penStyle, QColor &color,
double &width,
315 Qt::PenJoinStyle *penJoinStyle =
nullptr, Qt::PenCapStyle *penCapStyle =
nullptr,
316 QVector<qreal> *customDashPattern =
nullptr,
double *dashOffset =
nullptr );
318 static void externalGraphicToSld( QDomDocument &doc, QDomElement &element,
319 const QString &path,
const QString &mime,
320 const QColor &color,
double size = -1 );
321 static bool externalGraphicFromSld( QDomElement &element,
322 QString &path, QString &mime,
323 QColor &color,
double &size );
325 static void wellKnownMarkerToSld( QDomDocument &doc, QDomElement &element,
326 const QString &name,
const QColor &color,
const QColor &strokeColor, Qt::PenStyle strokeStyle,
327 double strokeWidth = -1,
double size = -1 );
330 static bool wellKnownMarkerFromSld( QDomElement &element,
331 QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle,
332 double &strokeWidth,
double &size )
SIP_PYNAME( wellKnownMarkerFromSld2 );
334 static void externalMarkerToSld( QDomDocument &doc, QDomElement &element,
335 const QString &path,
const QString &format,
int *markIndex =
nullptr,
336 const QColor &color = QColor(),
double size = -1 );
337 static bool externalMarkerFromSld( QDomElement &element,
338 QString &path, QString &format,
int &markIndex,
339 QColor &color,
double &size );
342 static void labelTextToSld( QDomDocument &doc, QDomElement &element,
const QString &label,
343 const QFont &font,
const QColor &color = QColor(),
double size = -1 );
346 static QString ogrFeatureStylePen(
double width,
double mmScaleFactor,
double mapUnitsScaleFactor,
const QColor &
c,
347 Qt::PenJoinStyle joinStyle = Qt::MiterJoin,
348 Qt::PenCapStyle capStyle = Qt::FlatCap,
350 const QVector<qreal> *dashPattern =
nullptr );
355 static QString ogrFeatureStyleBrush(
const QColor &fillColr );
357 static void createRotationElement( QDomDocument &doc, QDomElement &element,
const QString &rotationFunc );
358 static bool rotationFromSldElement( QDomElement &element, QString &rotationFunc );
360 static void createOpacityElement( QDomDocument &doc, QDomElement &element,
const QString &alphaFunc );
361 static bool opacityFromSldElement( QDomElement &element, QString &alphaFunc );
363 static void createDisplacementElement( QDomDocument &doc, QDomElement &element, QPointF offset );
364 static bool displacementFromSldElement( QDomElement &element, QPointF &offset );
372 static void createAnchorPointElement( QDomDocument &doc, QDomElement &element, QPointF anchor );
374 static void createOnlineResourceElement( QDomDocument &doc, QDomElement &element,
const QString &path,
const QString &format );
375 static bool onlineResourceFromSldElement( QDomElement &element, QString &path, QString &format );
377 static void createGeometryElement( QDomDocument &doc, QDomElement &element,
const QString &geomFunc );
378 static bool geometryFromSldElement( QDomElement &element, QString &geomFunc );
386 static bool createExpressionElement( QDomDocument &doc, QDomElement &element,
const QString &
function );
387 static bool createFunctionElement( QDomDocument &doc, QDomElement &element,
const QString &
function );
388 static bool functionFromSldElement( QDomElement &element, QString &
function );
390 static QDomElement createSvgParameterElement( QDomDocument &doc,
const QString &name,
const QString &value );
391 static QgsStringMap getSvgParameterList( QDomElement &element );
393 static QDomElement createVendorOptionElement( QDomDocument &doc,
const QString &name,
const QString &value );
394 static QgsStringMap getVendorOptionList( QDomElement &element );
396 static QgsStringMap parseProperties( QDomElement &element );
397 static void saveProperties(
QgsStringMap props, QDomDocument &doc, QDomElement &element );
439 static QDomElement saveColorRamp(
const QString &name,
QgsColorRamp *ramp, QDomDocument &doc );
447 static QVariant colorRampToVariant(
const QString &name,
QgsColorRamp *ramp );
463 static QString colorToName(
const QColor &color );
472 static QList< QColor > parseColorList(
const QString &colorStr );
481 static QMimeData *colorToMimeData(
const QColor &color )
SIP_FACTORY;
492 static QColor colorFromMimeData(
const QMimeData *data,
bool &hasAlpha );
519 static bool saveColorsToGpl( QFile &file,
const QString &paletteName,
const QgsNamedColorList &colors );
529 static QgsNamedColorList importColorsFromGpl( QFile &file,
bool &ok, QString &name );
539 static QColor parseColor(
const QString &colorStr,
bool strictEval =
false );
550 static QColor parseColorWithAlpha(
const QString &colorStr,
bool &containsAlpha,
bool strictEval =
false );
555 static void multiplyImageOpacity( QImage *image, qreal opacity );
558 static void blurImageInPlace( QImage &image, QRect rect,
int radius,
bool alphaOnly );
564 static void premultiplyColor( QColor &rgb,
int alpha );
567 static void sortVariantList( QList<QVariant> &list, Qt::SortOrder order );
569 static QPointF pointOnLineWithDistance( QPointF startPoint, QPointF directionPoint,
double distance );
572 static QStringList listSvgFiles();
575 static QStringList listSvgFilesAt(
const QString &directory );
583 static QString svgSymbolNameToPath(
const QString &name,
const QgsPathResolver &pathResolver );
589 static QString svgSymbolPathToName(
const QString &path,
const QgsPathResolver &pathResolver );
592 static QPointF polygonCentroid(
const QPolygonF &points );
595 static QPointF polygonPointOnSurface(
const QPolygonF &points );
598 static bool pointInPolygon(
const QPolygonF &points, QPointF point );
616 static QString fieldOrExpressionFromExpression(
QgsExpression *expression );
624 static QList<double> prettyBreaks(
double minimum,
double maximum,
int classes );
651 static void applyScaleDependency( QDomDocument &doc, QDomElement &ruleElem,
QgsStringMap &props );
657 static void mergeScaleDependencies(
int mScaleMinDenom,
int mScaleMaxDenom,
QgsStringMap &props );
665 static void parametricSvgToSld( QDomDocument &doc, QDomElement &graphicElem,
667 const QColor &fillColor,
double size,
const QColor &strokeColor,
double strokeWidth );
673 static QString getSvgParametricPath(
const QString &basePath,
const QColor &fillColor,
const QColor &strokeColor,
double strokeWidth );
Class for parsing and evaluation of expressions (formerly called "search strings").
The class is used as a container of context for various read/write operations on other objects...
Abstract base class for color ramps.
QList< QPolygonF > offsetLine(QPolygonF polyline, double dist, QgsWkbTypes::GeometryType geometryType)
calculate geometry shifted by a specified distance
static QgsSymbol * loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element.
QMap< QString, QString > QgsStringMap
QMap< QString, QString > QgsStringMap
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.
ArrowType
Possible arrow types.
QList< QgsSymbolLayer * > QgsSymbolLayerList
static SymbolType * loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element and cast it to a particular symbol type.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Contains information about the context of a rendering operation.
Struct for storing maximum and minimum scales for measurements in map units.
QMap< QString, QgsSymbol *> QgsSymbolMap
QMap< QString, QgsSymbol *> QgsSymbolMap
Resolves relative paths into absolute paths and vice versa.
HeadType
Possible head types.
RenderUnit
Rendering size units.