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 );
131 static QString encodeSize( QSizeF size );
139 static QSizeF decodeSize(
const QString &
string );
141 static QString encodeMapUnitScale(
const QgsMapUnitScale &mapUnitScale );
144 static QString encodeRealVector(
const QVector<qreal> &v );
145 static QVector<qreal> decodeRealVector(
const QString &s );
147 static QString encodeSldRealVector(
const QVector<qreal> &v );
148 static QVector<qreal> decodeSldRealVector(
const QString &s );
175 static double sizeInPixelsFromSldUom(
const QString &uom,
double size );
180 static QPainter::CompositionMode decodeBlendMode(
const QString &s );
189 static QIcon symbolPreviewIcon(
const QgsSymbol *symbol, QSize size,
int padding = 0 );
200 static QPixmap symbolPreviewPixmap(
const QgsSymbol *symbol, QSize size,
int padding = 0,
QgsRenderContext *customContext =
nullptr );
232 static QIcon colorRampPreviewIcon(
QgsColorRamp *ramp, QSize size,
int padding = 0 );
241 static QPixmap colorRampPreviewPixmap(
QgsColorRamp *ramp, QSize size,
int padding = 0 );
243 static void drawStippledBackground( QPainter *painter, QRect rect );
273 SymbolType *symbolCastToType =
dynamic_cast<SymbolType *
>( tmpSymbol );
275 if ( symbolCastToType )
277 return symbolCastToType;
297 static QString symbolProperties(
QgsSymbol *symbol );
305 static bool convertPolygonSymbolizerToPointMarker( QDomElement &element,
QgsSymbolLayerList &layerList );
306 static bool hasExternalGraphic( QDomElement &element );
307 static bool hasWellKnownMark( QDomElement &element );
309 static bool needFontMarker( QDomElement &element );
310 static bool needSvgMarker( QDomElement &element );
311 static bool needEllipseMarker( QDomElement &element );
312 static bool needMarkerLine( QDomElement &element );
313 static bool needLinePatternFill( QDomElement &element );
314 static bool needPointPatternFill( QDomElement &element );
315 static bool needSvgFill( QDomElement &element );
317 static void fillToSld( QDomDocument &doc, QDomElement &element,
318 Qt::BrushStyle brushStyle,
const QColor &color = QColor() );
319 static bool fillFromSld( QDomElement &element,
320 Qt::BrushStyle &brushStyle, QColor &color );
323 static void lineToSld( QDomDocument &doc, QDomElement &element,
324 Qt::PenStyle penStyle,
const QColor &color,
double width = -1,
325 const Qt::PenJoinStyle *penJoinStyle =
nullptr,
const Qt::PenCapStyle *penCapStyle =
nullptr,
326 const QVector<qreal> *customDashPattern =
nullptr,
double dashOffset = 0.0 )
SIP_SKIP;
327 static bool lineFromSld( QDomElement &element,
328 Qt::PenStyle &penStyle, QColor &color,
double &width,
329 Qt::PenJoinStyle *penJoinStyle =
nullptr, Qt::PenCapStyle *penCapStyle =
nullptr,
330 QVector<qreal> *customDashPattern =
nullptr,
double *dashOffset =
nullptr );
332 static void externalGraphicToSld( QDomDocument &doc, QDomElement &element,
333 const QString &path,
const QString &mime,
334 const QColor &color,
double size = -1 );
335 static bool externalGraphicFromSld( QDomElement &element,
336 QString &path, QString &mime,
337 QColor &color,
double &size );
339 static void wellKnownMarkerToSld( QDomDocument &doc, QDomElement &element,
340 const QString &name,
const QColor &color,
const QColor &strokeColor, Qt::PenStyle strokeStyle,
341 double strokeWidth = -1,
double size = -1 );
344 static bool wellKnownMarkerFromSld( QDomElement &element,
345 QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle,
346 double &strokeWidth,
double &size )
SIP_PYNAME( wellKnownMarkerFromSld2 );
348 static void externalMarkerToSld( QDomDocument &doc, QDomElement &element,
349 const QString &path,
const QString &format,
int *markIndex =
nullptr,
350 const QColor &color = QColor(),
double size = -1 );
351 static bool externalMarkerFromSld( QDomElement &element,
352 QString &path, QString &format,
int &markIndex,
353 QColor &color,
double &size );
356 static void labelTextToSld( QDomDocument &doc, QDomElement &element,
const QString &label,
357 const QFont &font,
const QColor &color = QColor(),
double size = -1 );
360 static QString ogrFeatureStylePen(
double width,
double mmScaleFactor,
double mapUnitsScaleFactor,
const QColor &
c,
361 Qt::PenJoinStyle joinStyle = Qt::MiterJoin,
362 Qt::PenCapStyle capStyle = Qt::FlatCap,
364 const QVector<qreal> *dashPattern =
nullptr );
369 static QString ogrFeatureStyleBrush(
const QColor &fillColr );
371 static void createRotationElement( QDomDocument &doc, QDomElement &element,
const QString &rotationFunc );
372 static bool rotationFromSldElement( QDomElement &element, QString &rotationFunc );
374 static void createOpacityElement( QDomDocument &doc, QDomElement &element,
const QString &alphaFunc );
375 static bool opacityFromSldElement( QDomElement &element, QString &alphaFunc );
377 static void createDisplacementElement( QDomDocument &doc, QDomElement &element, QPointF offset );
378 static bool displacementFromSldElement( QDomElement &element, QPointF &offset );
386 static void createAnchorPointElement( QDomDocument &doc, QDomElement &element, QPointF anchor );
388 static void createOnlineResourceElement( QDomDocument &doc, QDomElement &element,
const QString &path,
const QString &format );
389 static bool onlineResourceFromSldElement( QDomElement &element, QString &path, QString &format );
391 static void createGeometryElement( QDomDocument &doc, QDomElement &element,
const QString &geomFunc );
392 static bool geometryFromSldElement( QDomElement &element, QString &geomFunc );
400 static bool createExpressionElement( QDomDocument &doc, QDomElement &element,
const QString &
function );
401 static bool createFunctionElement( QDomDocument &doc, QDomElement &element,
const QString &
function );
402 static bool functionFromSldElement( QDomElement &element, QString &
function );
404 static QDomElement createSvgParameterElement( QDomDocument &doc,
const QString &name,
const QString &value );
405 static QgsStringMap getSvgParameterList( QDomElement &element );
407 static QDomElement createVendorOptionElement( QDomDocument &doc,
const QString &name,
const QString &value );
408 static QgsStringMap getVendorOptionList( QDomElement &element );
410 static QgsStringMap parseProperties( QDomElement &element );
411 static void saveProperties(
QgsStringMap props, QDomDocument &doc, QDomElement &element );
453 static QDomElement saveColorRamp(
const QString &name,
QgsColorRamp *ramp, QDomDocument &doc );
461 static QVariant colorRampToVariant(
const QString &name,
QgsColorRamp *ramp );
477 static QString colorToName(
const QColor &color );
486 static QList< QColor > parseColorList(
const QString &colorStr );
495 static QMimeData *colorToMimeData(
const QColor &color )
SIP_FACTORY;
506 static QColor colorFromMimeData(
const QMimeData *data,
bool &hasAlpha );
533 static bool saveColorsToGpl( QFile &file,
const QString &paletteName,
const QgsNamedColorList &colors );
543 static QgsNamedColorList importColorsFromGpl( QFile &file,
bool &ok, QString &name );
553 static QColor parseColor(
const QString &colorStr,
bool strictEval =
false );
564 static QColor parseColorWithAlpha(
const QString &colorStr,
bool &containsAlpha,
bool strictEval =
false );
569 static void multiplyImageOpacity( QImage *image, qreal opacity );
572 static void blurImageInPlace( QImage &image, QRect rect,
int radius,
bool alphaOnly );
578 static void premultiplyColor( QColor &rgb,
int alpha );
581 static void sortVariantList( QList<QVariant> &list, Qt::SortOrder order );
583 static QPointF pointOnLineWithDistance( QPointF startPoint, QPointF directionPoint,
double distance );
586 static QStringList listSvgFiles();
589 static QStringList listSvgFilesAt(
const QString &directory );
597 static QString svgSymbolNameToPath(
const QString &name,
const QgsPathResolver &pathResolver );
603 static QString svgSymbolPathToName(
const QString &path,
const QgsPathResolver &pathResolver );
606 static QPointF polygonCentroid(
const QPolygonF &points );
609 static QPointF polygonPointOnSurface(
const QPolygonF &points );
612 static bool pointInPolygon(
const QPolygonF &points, QPointF point );
630 static QString fieldOrExpressionFromExpression(
QgsExpression *expression );
638 static QList<double> prettyBreaks(
double minimum,
double maximum,
int classes );
665 static void applyScaleDependency( QDomDocument &doc, QDomElement &ruleElem,
QgsStringMap &props );
671 static void mergeScaleDependencies(
double mScaleMinDenom,
double mScaleMaxDenom,
QgsStringMap &props );
679 static void parametricSvgToSld( QDomDocument &doc, QDomElement &graphicElem,
681 const QColor &fillColor,
double size,
const QColor &strokeColor,
double strokeWidth );
687 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
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.