17 #ifndef QGSSYMBOLLAYERUTILS_H 18 #define QGSSYMBOLLAYERUTILS_H 20 #include "qgis_core.h" 66 static QString encodeColor(
const QColor &color );
67 static QColor decodeColor(
const QString &str );
69 static QString encodeSldAlpha(
int alpha );
70 static int decodeSldAlpha(
const QString &str );
72 static QString encodeSldFontStyle( QFont::Style style );
73 static QFont::Style decodeSldFontStyle(
const QString &str );
75 static QString encodeSldFontWeight(
int weight );
76 static int decodeSldFontWeight(
const QString &str );
78 static QString encodePenStyle( Qt::PenStyle style );
79 static Qt::PenStyle decodePenStyle(
const QString &str );
81 static QString encodePenJoinStyle( Qt::PenJoinStyle style );
82 static Qt::PenJoinStyle decodePenJoinStyle(
const QString &str );
84 static QString encodePenCapStyle( Qt::PenCapStyle style );
85 static Qt::PenCapStyle decodePenCapStyle(
const QString &str );
87 static QString encodeSldLineJoinStyle( Qt::PenJoinStyle style );
88 static Qt::PenJoinStyle decodeSldLineJoinStyle(
const QString &str );
90 static QString encodeSldLineCapStyle( Qt::PenCapStyle style );
91 static Qt::PenCapStyle decodeSldLineCapStyle(
const QString &str );
93 static QString encodeBrushStyle( Qt::BrushStyle style );
94 static Qt::BrushStyle decodeBrushStyle(
const QString &str );
96 static QString encodeSldBrushStyle( Qt::BrushStyle style );
97 static Qt::BrushStyle decodeSldBrushStyle(
const QString &str );
116 static QString encodePoint( QPointF point );
123 static QPointF decodePoint(
const QString &
string );
137 static QPointF toPoint(
const QVariant &value,
bool *ok
SIP_OUT =
nullptr );
145 static QString encodeSize( QSizeF size );
153 static QSizeF decodeSize(
const QString &
string );
167 static QSizeF toSize(
const QVariant &value,
bool *ok
SIP_OUT =
nullptr );
169 static QString encodeMapUnitScale(
const QgsMapUnitScale &mapUnitScale );
172 static QString encodeRealVector(
const QVector<qreal> &v );
173 static QVector<qreal> decodeRealVector(
const QString &s );
175 static QString encodeSldRealVector(
const QVector<qreal> &v );
176 static QVector<qreal> decodeSldRealVector(
const QString &s );
203 static double sizeInPixelsFromSldUom(
const QString &uom,
double size );
208 static QPainter::CompositionMode decodeBlendMode(
const QString &s );
217 static QIcon symbolPreviewIcon(
const QgsSymbol *symbol, QSize size,
int padding = 0 );
232 static QPixmap symbolPreviewPixmap(
const QgsSymbol *symbol, QSize size,
int padding = 0,
QgsRenderContext *customContext =
nullptr,
bool selected =
false,
265 static QIcon colorRampPreviewIcon(
QgsColorRamp *ramp, QSize size,
int padding = 0 );
274 static QPixmap colorRampPreviewPixmap(
QgsColorRamp *ramp, QSize size,
int padding = 0 );
276 static void drawStippledBackground( QPainter *painter, QRect rect );
306 SymbolType *symbolCastToType =
dynamic_cast<SymbolType *
>( tmpSymbol );
308 if ( symbolCastToType )
310 return symbolCastToType;
323 static QDomElement saveSymbol(
const QString &symbolName,
const QgsSymbol *symbol, QDomDocument &doc,
const QgsReadWriteContext &context );
330 static QString symbolProperties(
QgsSymbol *symbol );
338 static bool convertPolygonSymbolizerToPointMarker( QDomElement &element,
QgsSymbolLayerList &layerList );
339 static bool hasExternalGraphic( QDomElement &element );
340 static bool hasWellKnownMark( QDomElement &element );
342 static bool needFontMarker( QDomElement &element );
343 static bool needSvgMarker( QDomElement &element );
344 static bool needEllipseMarker( QDomElement &element );
345 static bool needMarkerLine( QDomElement &element );
346 static bool needLinePatternFill( QDomElement &element );
347 static bool needPointPatternFill( QDomElement &element );
348 static bool needSvgFill( QDomElement &element );
350 static void fillToSld( QDomDocument &doc, QDomElement &element,
351 Qt::BrushStyle brushStyle,
const QColor &color = QColor() );
352 static bool fillFromSld( QDomElement &element,
353 Qt::BrushStyle &brushStyle, QColor &color );
356 static void lineToSld( QDomDocument &doc, QDomElement &element,
357 Qt::PenStyle penStyle,
const QColor &color,
double width = -1,
358 const Qt::PenJoinStyle *penJoinStyle =
nullptr,
const Qt::PenCapStyle *penCapStyle =
nullptr,
359 const QVector<qreal> *customDashPattern =
nullptr,
double dashOffset = 0.0 )
SIP_SKIP;
360 static bool lineFromSld( QDomElement &element,
361 Qt::PenStyle &penStyle, QColor &color,
double &width,
362 Qt::PenJoinStyle *penJoinStyle =
nullptr, Qt::PenCapStyle *penCapStyle =
nullptr,
363 QVector<qreal> *customDashPattern =
nullptr,
double *dashOffset =
nullptr );
365 static void externalGraphicToSld( QDomDocument &doc, QDomElement &element,
366 const QString &path,
const QString &mime,
367 const QColor &color,
double size = -1 );
368 static bool externalGraphicFromSld( QDomElement &element,
369 QString &path, QString &mime,
370 QColor &color,
double &size );
372 static void wellKnownMarkerToSld( QDomDocument &doc, QDomElement &element,
373 const QString &name,
const QColor &color,
const QColor &strokeColor, Qt::PenStyle strokeStyle,
374 double strokeWidth = -1,
double size = -1 );
377 static bool wellKnownMarkerFromSld( QDomElement &element,
378 QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle,
379 double &strokeWidth,
double &size )
SIP_PYNAME( wellKnownMarkerFromSld2 );
381 static void externalMarkerToSld( QDomDocument &doc, QDomElement &element,
382 const QString &path,
const QString &format,
int *markIndex =
nullptr,
383 const QColor &color = QColor(),
double size = -1 );
384 static bool externalMarkerFromSld( QDomElement &element,
385 QString &path, QString &format,
int &markIndex,
386 QColor &color,
double &size );
389 static void labelTextToSld( QDomDocument &doc, QDomElement &element,
const QString &label,
390 const QFont &font,
const QColor &color = QColor(),
double size = -1 );
393 static QString ogrFeatureStylePen(
double width,
double mmScaleFactor,
double mapUnitsScaleFactor,
const QColor &
c,
394 Qt::PenJoinStyle joinStyle = Qt::MiterJoin,
395 Qt::PenCapStyle capStyle = Qt::FlatCap,
397 const QVector<qreal> *dashPattern =
nullptr );
402 static QString ogrFeatureStyleBrush(
const QColor &fillColr );
404 static void createRotationElement( QDomDocument &doc, QDomElement &element,
const QString &rotationFunc );
405 static bool rotationFromSldElement( QDomElement &element, QString &rotationFunc );
407 static void createOpacityElement( QDomDocument &doc, QDomElement &element,
const QString &alphaFunc );
408 static bool opacityFromSldElement( QDomElement &element, QString &alphaFunc );
410 static void createDisplacementElement( QDomDocument &doc, QDomElement &element, QPointF offset );
411 static bool displacementFromSldElement( QDomElement &element, QPointF &offset );
419 static void createAnchorPointElement( QDomDocument &doc, QDomElement &element, QPointF anchor );
421 static void createOnlineResourceElement( QDomDocument &doc, QDomElement &element,
const QString &path,
const QString &format );
422 static bool onlineResourceFromSldElement( QDomElement &element, QString &path, QString &format );
424 static void createGeometryElement( QDomDocument &doc, QDomElement &element,
const QString &geomFunc );
425 static bool geometryFromSldElement( QDomElement &element, QString &geomFunc );
433 static bool createExpressionElement( QDomDocument &doc, QDomElement &element,
const QString &
function );
434 static bool createFunctionElement( QDomDocument &doc, QDomElement &element,
const QString &
function );
435 static bool functionFromSldElement( QDomElement &element, QString &
function );
437 static QDomElement createSvgParameterElement( QDomDocument &doc,
const QString &name,
const QString &value );
438 static QgsStringMap getSvgParameterList( QDomElement &element );
440 static QDomElement createVendorOptionElement( QDomDocument &doc,
const QString &name,
const QString &value );
441 static QgsStringMap getVendorOptionList( QDomElement &element );
443 static QgsStringMap parseProperties( QDomElement &element );
444 static void saveProperties(
QgsStringMap props, QDomDocument &doc, QDomElement &element );
486 static QDomElement saveColorRamp(
const QString &name,
QgsColorRamp *ramp, QDomDocument &doc );
494 static QVariant colorRampToVariant(
const QString &name,
QgsColorRamp *ramp );
510 static QString colorToName(
const QColor &color );
519 static QList< QColor > parseColorList(
const QString &colorStr );
528 static QMimeData *colorToMimeData(
const QColor &color )
SIP_FACTORY;
539 static QColor colorFromMimeData(
const QMimeData *data,
bool &hasAlpha );
566 static bool saveColorsToGpl( QFile &file,
const QString &paletteName,
const QgsNamedColorList &colors );
576 static QgsNamedColorList importColorsFromGpl( QFile &file,
bool &ok, QString &name );
586 static QColor parseColor(
const QString &colorStr,
bool strictEval =
false );
597 static QColor parseColorWithAlpha(
const QString &colorStr,
bool &containsAlpha,
bool strictEval =
false );
602 static void multiplyImageOpacity( QImage *image, qreal opacity );
605 static void blurImageInPlace( QImage &image, QRect rect,
int radius,
bool alphaOnly );
611 static void premultiplyColor( QColor &rgb,
int alpha );
614 static void sortVariantList( QList<QVariant> &list, Qt::SortOrder order );
616 static QPointF pointOnLineWithDistance( QPointF startPoint, QPointF directionPoint,
double distance );
619 static QStringList listSvgFiles();
622 static QStringList listSvgFilesAt(
const QString &directory );
630 static QString svgSymbolNameToPath(
const QString &name,
const QgsPathResolver &pathResolver );
636 static QString svgSymbolPathToName(
const QString &path,
const QgsPathResolver &pathResolver );
639 static QPointF polygonCentroid(
const QPolygonF &points );
642 static QPointF polygonPointOnSurface(
const QPolygonF &points, QList<QPolygonF> *rings =
nullptr );
645 static bool pointInPolygon(
const QPolygonF &points, QPointF point );
663 static QString fieldOrExpressionFromExpression(
QgsExpression *expression );
671 static QList<double> prettyBreaks(
double minimum,
double maximum,
int classes );
698 static void applyScaleDependency( QDomDocument &doc, QDomElement &ruleElem,
QgsStringMap &props );
704 static void mergeScaleDependencies(
double mScaleMinDenom,
double mScaleMaxDenom,
QgsStringMap &props );
712 static void parametricSvgToSld( QDomDocument &doc, QDomElement &graphicElem,
714 const QColor &fillColor,
double size,
const QColor &strokeColor,
double strokeWidth );
720 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 all rendered symbols.
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
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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.
VertexMarkerType
Editing vertex markers.
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.