28 #include <QSvgRenderer> 31 #include <QDomDocument> 32 #include <QDomElement> 52 : mOutlineStyle(
Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit(
QgsSymbolV2::MM )
79 if ( props.
contains(
"color_border" ) )
84 else if ( props.
contains(
"outline_color" ) )
88 else if ( props.
contains(
"line_color" ) )
93 size = props[
"size"].toDouble();
95 angle = props[
"angle"].toDouble();
96 if ( props.
contains(
"scale_method" ) )
102 if ( props.
contains(
"offset_unit" ) )
104 if ( props.
contains(
"offset_map_unit_scale" ) )
106 if ( props.
contains(
"size_unit" ) )
108 if ( props.
contains(
"size_map_unit_scale" ) )
111 if ( props.
contains(
"outline_style" ) )
115 else if ( props.
contains(
"line_style" ) )
119 if ( props.
contains(
"outline_width" ) )
123 else if ( props.
contains(
"line_width" ) )
127 if ( props.
contains(
"outline_width_unit" ) )
131 if ( props.
contains(
"line_width_unit" ) )
135 if ( props.
contains(
"outline_width_map_unit_scale" ) )
140 if ( props.
contains(
"horizontal_anchor_point" ) )
144 if ( props.
contains(
"vertical_anchor_point" ) )
157 return "SimpleMarker";
175 if ( context.
alpha() < 1 )
205 if (
mName !=
"circle" )
218 if ( !hasDataDefinedSize )
223 double half = scaledSize / 2.0;
224 transform.
scale( half, half );
263 int imageSize = (
static_cast< int >( scaledSize ) + pw ) / 2 * 2 + 1;
264 double center = imageSize / 2.0;
271 mCache =
QImage(
QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
306 p.
fillRect( 0, 0, imageSize, imageSize, selColor );
331 if ( name ==
"square" || name ==
"rectangle" )
336 else if ( name ==
"diamond" )
342 else if ( name ==
"pentagon" )
351 else if ( name ==
"triangle" )
356 else if ( name ==
"equilateral_triangle" )
363 else if ( name ==
"star" )
365 double sixth = 1.0 / 3;
379 else if ( name ==
"regular_star" )
395 else if ( name ==
"arrow" )
406 else if ( name ==
"filled_arrowhead" )
423 if ( name ==
"circle" )
428 else if ( name ==
"cross" )
436 else if ( name ==
"x" || name ==
"cross2" )
444 else if ( name ==
"line" )
450 else if ( name ==
"arrowhead" )
473 bool hasDataDefinedSize =
false;
474 double scaledSize = calculateSize( context, hasDataDefinedSize );
476 bool hasDataDefinedRotation =
false;
479 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation, offset, angle );
482 bool createdNewPath =
false;
494 createdNewPath =
true;
505 point.
y() - s / 2.0 + offset.
y(),
513 transform.
translate( point.
x() + offset.
x(), point.
y() + offset.
y() );
516 if ( hasDataDefinedSize || createdNewPath )
519 double half = s / 2.0;
520 transform.
scale( half, half );
523 if ( !
qgsDoubleNear( angle, 0.0 ) && ( hasDataDefinedRotation || createdNewPath ) )
524 transform.
rotate( angle );
575 double QgsSimpleMarkerSymbolLayerV2::calculateSize(
QgsSymbolV2RenderContext& context,
bool& hasDataDefinedSize )
const 577 double scaledSize =
mSize;
587 if ( hasDataDefinedSize && ok )
592 scaledSize = sqrt( scaledSize );
604 bool& hasDataDefinedRotation,
606 double&
angle )
const 611 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
612 offset =
QPointF( offsetX, offsetY );
617 bool usingDataDefinedRotation =
false;
622 usingDataDefinedRotation = ok;
626 if ( hasDataDefinedRotation )
706 double angle = props.
value(
"angle",
"0" ).toDouble( &ok );
723 Q_UNUSED( mmScaleFactor );
724 Q_UNUSED( mapUnitScaleFactor );
727 if (
mName ==
"square" )
731 else if (
mName ==
"triangle" )
735 else if (
mName ==
"star" )
739 else if (
mName ==
"circle" )
743 else if (
mName ==
"cross" )
751 else if (
mName ==
"line" )
757 ogrString.
append(
"SYMBOL(" );
758 ogrString.
append(
"id:" );
760 ogrString.
append(
"ogr-sym-" );
761 ogrString.
append( ogrType );
763 ogrString.
append(
",c:" );
765 ogrString.
append(
",o:" );
773 ogrString.
append(
"PEN(" );
776 ogrString.
append(
",w:" );
788 if ( graphicElem.
isNull() )
793 double borderWidth,
size;
794 Qt::PenStyle borderStyle;
804 double d = angleFunc.
toDouble( &ok );
838 bool hasDataDefinedSize =
false;
846 if ( hasDataDefinedSize )
870 size *= mmMapUnitScaleFactor;
872 double halfSize = size / 2.0;
884 outlineWidth *= mmMapUnitScaleFactor;
912 QPointF off( offsetX, offsetY );
935 off *= mmMapUnitScaleFactor;
939 t.
translate( shift.
x() + offsetX, shift.
y() + offsetY );
947 t.
scale( halfSize, -halfSize );
949 polygon = t.
map( polygon );
955 for ( i = 0; i < polygon.
size(); i++ )
956 p[0][i] = polygon[i];
962 e.
writePolyline( p[0], layerName,
"CONTINUOUS", pc, outlineWidth );
964 else if ( name ==
"circle" )
969 e.
writeCircle( layerName, pc, shift, halfSize,
"CONTINUOUS", outlineWidth );
971 else if ( name ==
"line" )
977 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
979 else if ( name ==
"cross" )
988 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
989 e.
writeLine( pt3, pt4, layerName,
"CONTINUOUS", pc, outlineWidth );
992 else if ( name ==
"x" || name ==
"cross2" )
1001 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
1002 e.
writeLine( pt3, pt4, layerName,
"CONTINUOUS", pc, outlineWidth );
1005 else if ( name ==
"arrowhead" )
1013 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
1014 e.
writeLine( pt3, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
1059 bool hasDataDefinedSize =
false;
1060 double scaledSize = calculateSize( context, hasDataDefinedSize );
1062 bool hasDataDefinedRotation =
false;
1065 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation, offset, angle );
1073 transform.
translate( point.
x() + offset.
x(), point.
y() + offset.
y() );
1076 transform.
rotate( angle );
1078 double penWidth = 0.0;
1093 if ( ok && outlineStyle ==
"no" )
1099 penWidth += pixelSize;
1107 symbolBounds.
adjust( -penWidth / 2.0, -penWidth / 2.0,
1108 penWidth / 2.0, penWidth / 2.0 );
1110 return symbolBounds;
1126 mOutlineColor =
QColor( Qt::black );
1138 name = props[
"name"];
1140 size = props[
"size"].toDouble();
1142 angle = props[
"angle"].toDouble();
1143 if ( props.
contains(
"scale_method" ) )
1153 double fillOpacity = 1.0;
1154 double outlineOpacity = 1.0;
1156 bool hasFillParam =
false, hasFillOpacityParam =
false, hasOutlineParam =
false, hasOutlineWidthParam =
false, hasOutlineOpacityParam =
false;
1157 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultOutlineColor =
false, hasDefaultOutlineWidth =
false, hasDefaultOutlineOpacity =
false;
1159 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1160 hasOutlineParam, hasDefaultOutlineColor, outlineColor,
1161 hasOutlineWidthParam, hasDefaultOutlineWidth, outlineWidth,
1162 hasOutlineOpacityParam, hasDefaultOutlineOpacity, outlineOpacity );
1163 if ( hasDefaultFillColor )
1167 if ( hasDefaultFillOpacity )
1173 if ( hasDefaultOutlineColor )
1177 if ( hasDefaultOutlineWidth )
1181 if ( hasDefaultOutlineOpacity )
1189 if ( props.
contains(
"size_unit" ) )
1191 if ( props.
contains(
"size_map_unit_scale" ) )
1195 if ( props.
contains(
"offset_unit" ) )
1197 if ( props.
contains(
"offset_map_unit_scale" ) )
1204 else if ( props.
contains(
"color" ) )
1213 else if ( props.
contains(
"outline_color" ) )
1217 else if ( props.
contains(
"line_color" ) )
1222 if ( props.
contains(
"outline-width" ) )
1227 else if ( props.
contains(
"outline_width" ) )
1231 else if ( props.
contains(
"line_width" ) )
1236 if ( props.
contains(
"outline_width_unit" ) )
1240 else if ( props.
contains(
"line_width_unit" ) )
1244 if ( props.
contains(
"outline_width_map_unit_scale" ) )
1247 if ( props.
contains(
"horizontal_anchor_point" ) )
1251 if ( props.
contains(
"vertical_anchor_point" ) )
1264 QColor defaultFillColor, defaultOutlineColor;
1266 bool hasFillParam =
false, hasFillOpacityParam =
false, hasOutlineParam =
false, hasOutlineWidthParam =
false, hasOutlineOpacityParam =
false;
1267 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultOutlineColor =
false, hasDefaultOutlineWidth =
false, hasDefaultOutlineOpacity =
false;
1269 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1270 hasOutlineParam, hasDefaultOutlineColor, defaultOutlineColor,
1271 hasOutlineWidthParam, hasDefaultOutlineWidth, outlineWidth,
1272 hasOutlineOpacityParam, hasDefaultOutlineOpacity, outlineOpacity );
1274 double newFillOpacity = hasFillOpacityParam ?
fillColor().
alphaF() : 1.0;
1277 if ( hasDefaultFillColor )
1279 defaultFillColor.
setAlphaF( newFillOpacity );
1282 if ( hasDefaultFillOpacity )
1288 if ( hasDefaultOutlineColor )
1290 defaultOutlineColor.
setAlphaF( newOutlineOpacity );
1293 if ( hasDefaultOutlineWidth )
1297 if ( hasDefaultOutlineOpacity )
1314 Q_UNUSED( context );
1320 Q_UNUSED( context );
1329 bool hasDataDefinedSize =
false;
1330 double scaledSize = calculateSize( context, hasDataDefinedSize );
1334 if ( static_cast< int >( size ) < 1 || 10000.0 <
size )
1343 calculateOffsetAndRotation( context, scaledSize, outputOffset, angle );
1385 bool fitsInCache =
true;
1386 bool usePict =
true;
1387 double hwRatio = 1.0;
1393 if ( fitsInCache && img.
width() > 1 )
1400 p->
drawImage( -transparentImage.
width() / 2.0, -transparentImage.
height() / 2.0, transparentImage );
1401 hwRatio =
static_cast< double >( transparentImage.
height() ) / static_cast< double >( transparentImage.
width() );
1406 hwRatio =
static_cast< double >( img.
height() ) / static_cast< double >( img.
width() );
1411 if ( usePict || !fitsInCache )
1417 if ( pct.
width() > 1 )
1423 hwRatio =
static_cast< double >( pct.
height() ) / static_cast< double >( pct.
width() );
1431 if ( penWidth > size / 20 )
1434 penWidth = size / 20;
1436 double penOffset = penWidth / 2;
1437 pen.setWidth( penWidth );
1440 double wSize = size + penOffset;
1441 double hSize = size * hwRatio + penOffset;
1442 p->
drawRect(
QRectF( -wSize / 2.0, -hSize / 2.0, wSize, hSize ) );
1448 double QgsSvgMarkerSymbolLayerV2::calculateSize(
QgsSymbolV2RenderContext& context,
bool& hasDataDefinedSize )
const 1450 double scaledSize =
mSize;
1460 if ( hasDataDefinedSize && ok )
1465 scaledSize = sqrt( scaledSize );
1480 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
1481 offset =
QPointF( offsetX, offsetY );
1491 if ( hasDataDefinedRotation )
1601 double angle = props.
value(
"angle",
"0" ).toDouble( &ok );
1622 if ( graphicElem.
isNull() )
1632 if ( mimeType !=
"image/svg+xml" )
1640 double d = angleFunc.
toDouble( &ok );
1660 Q_UNUSED( layerName );
1675 if ( hasDataDefinedSize && ok )
1680 size = sqrt( size );
1689 size *= mmMapUnitScaleFactor;
1692 double halfSize = size / 2.0;
1704 double offsetX = offset.
x();
1705 double offsetY = offset.
y();
1708 offsetX *= mmMapUnitScaleFactor;
1709 offsetY *= mmMapUnitScaleFactor;
1712 QPointF outputOffset( offsetX, offsetY );
1791 bool hasDataDefinedSize =
false;
1792 double scaledSize = calculateSize( context, hasDataDefinedSize );
1796 if ( static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
1803 calculateOffsetAndRotation( context, scaledSize, outputOffset, angle );
1844 double scaledHeight = svgViewbox.
isValid() ? scaledSize * svgViewbox.
height() / svgViewbox.
width() : scaledSize;
1850 transform.
translate( point.
x() + outputOffset.
x(), point.
y() + outputOffset.
y() );
1853 transform.
rotate( angle );
1856 outlineWidth += pixelSize / 2.0;
1859 -scaledHeight / 2.0,
1864 symbolBounds.
adjust( -outlineWidth / 2.0, -outlineWidth / 2.0,
1865 outlineWidth / 2.0, outlineWidth / 2.0 );
1867 return symbolBounds;
1874 : mFontMetrics( nullptr )
1902 fontFamily = props[
"font"];
1903 if ( props.
contains(
"chr" ) && props[
"chr"].length() > 0 )
1904 chr = props[
"chr"].at( 0 );
1906 pointSize = props[
"size"].toDouble();
1910 angle = props[
"angle"].toDouble();
1915 if ( props.
contains(
"offset_unit" ) )
1917 if ( props.
contains(
"offset_map_unit_scale" ) )
1919 if ( props.
contains(
"size_unit" ) )
1921 if ( props.
contains(
"size_map_unit_scale" ) )
1923 if ( props.
contains(
"horizontal_anchor_point" ) )
1927 if ( props.
contains(
"vertical_anchor_point" ) )
1939 return "FontMarker";
1956 Q_UNUSED( context );
1967 if ( charToRender !=
mChr )
1973 return charToRender;
1978 bool& hasDataDefinedRotation,
1980 double&
angle )
const 1985 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
1986 offset =
QPointF( offsetX, offsetY );
1991 bool usingDataDefinedRotation =
false;
1996 usingDataDefinedRotation = ok;
2000 if ( hasDataDefinedRotation )
2025 double scaledSize =
mSize;
2035 if ( hasDataDefinedSize && ok )
2040 scaledSize = sqrt( scaledSize );
2073 QString charToRender = characterToRender( context, chrOffset, chrWidth );
2075 double sizeToRender = calculateSize( context );
2077 bool hasDataDefinedRotation =
false;
2080 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation, offset, angle );
2093 p->
drawText( -chrOffset, charToRender );
2101 props[
"chr"] =
mChr;
2147 double angle = props.
value(
"angle",
"0" ).toDouble( &ok );
2167 ( void )characterToRender( context, chrOffset, chrWidth );
2172 double scaledSize = calculateSize( context );
2178 bool hasDataDefinedRotation =
false;
2181 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation, offset, angle );
2187 transform.
translate( point.
x() + offset.
x(), point.
y() + offset.
y() );
2190 transform.
rotate( angle );
2192 QRectF symbolBounds = transform.mapRect(
QRectF( -chrWidth / 2.0,
2196 return symbolBounds;
2204 if ( graphicElem.
isNull() )
2215 if ( !name.
startsWith(
"ttf://" ) || format !=
"ttf" )
2225 double d = angleFunc.
toDouble( &ok );
void addEllipse(const QRectF &boundingRectangle)
QgsSymbolV2::OutputUnit outputUnit() const override
QColor borderColor() const
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
Q_GUI_EXPORT int qt_defaultDpiX()
static const QString EXPR_CHAR
void setOutlineStyle(Qt::PenStyle outlineStyle)
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
void setOpacity(qreal opacity)
Qt::PenStyle style() const
static void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
void stopRender(QgsSymbolV2RenderContext &context) override
QgsSymbolV2::OutputUnit outputUnit() const override
void setStyle(Qt::PenStyle style)
QString & append(QChar ch)
static QPointF _rotatedOffset(QPointF offset, double angle)
QgsSimpleMarkerSymbolLayerV2(const QString &name=DEFAULT_SIMPLEMARKER_NAME, const QColor &color=DEFAULT_SIMPLEMARKER_COLOR, const QColor &borderColor=DEFAULT_SIMPLEMARKER_BORDERCOLOR, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbolV2::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
static void multiplyImageOpacity(QImage *image, qreal alpha)
Multiplies opacity of image pixel values with a (global) transparency value.
OutputUnit
The unit of the output.
void writeLine(const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Write line (as a polyline)
QgsMapUnitScale mSizeMapUnitScale
QgsMapUnitScale mOutlineWidthMapUnitScale
Q_GUI_EXPORT int qt_defaultDpiY()
QString layerType() const override
Returns a string that represents this layer type.
bool contains(const Key &key) const
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
static Q_DECL_DEPRECATED bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &borderColor, double &borderWidth, double &size)
void fillRect(const QRectF &rectangle, const QBrush &brush)
QRectF bounds(QPointF point, QgsSymbolV2RenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
A paint device for drawing into dxf files.
void setRenderHint(RenderHint hint, bool on)
QString layerType() const override
Returns a string that represents this layer type.
QDomNode appendChild(const QDomNode &newChild)
#define DEFAULT_FONTMARKER_COLOR
void render(QPainter *painter)
const QPicture & svgAsPicture(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput=false)
Get SVG as QPicture&.
QSizeF svgViewboxSize(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor)
Calculates the viewbox size of a (possibly cached) SVG file.
Qt::BrushStyle style() const
QColor selectionColor() const
void setOutlineColor(const QColor &c) override
Set outline color.
QString layerType() const override
Returns a string that represents this layer type.
static QString encodeColor(const QColor &color)
#define DEFAULT_SIMPLEMARKER_ANGLE
void renderPoint(QPointF point, QgsSymbolV2RenderContext &context) override
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &mime, const QColor &color, double size=-1)
void scale(qreal sx, qreal sy)
void setDrawingSize(QSizeF size)
#define DEFAULT_FONTMARKER_CHR
static QgsSymbolV2::ScaleMethod decodeScaleMethod(const QString &str)
Calculate scale by the diameter.
void setOffset(QPointF offset)
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
void setOutlineWidth(double w)
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
#define DEFAULT_SIMPLEMARKER_COLOR
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)
void setVerticalAnchorPoint(VerticalAnchorPoint v)
void setFillColor(const QColor &color) override
Set fill color.
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
A geometry is the spatial representation of a feature.
void moveTo(const QPointF &point)
void renderPoint(QPointF point, QgsSymbolV2RenderContext &context) override
static QPointF decodePoint(const QString &str)
void copyPaintEffect(QgsSymbolLayerV2 *destLayer) const
Copies paint effect of this layer to another symbol layer.
void stopRender(QgsSymbolV2RenderContext &context) override
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
virtual bool hasDataDefinedProperty(const QString &property) const
Checks whether the layer has a matching data defined property and if that property is currently activ...
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
void setOutlineWidth(double w)
double scaleFactor() const
QColor fillColor() const override
Get fill color.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static void _fixQPictureDPI(QPainter *p)
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QImage copy(const QRect &rectangle) const
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
double toDouble(bool *ok) const
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
double mapRotation() const
Return current map rotation in degrees.
void adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
static const QString EXPR_OFFSET
void setMapUnitScale(const QgsMapUnitScale &scale) override
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
QSize defaultSize() const
#define DEFAULT_SVGMARKER_ANGLE
static const QString EXPR_SIZE
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
#define DEFAULT_SIMPLEMARKER_NAME
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasOutlineParam, QColor &defaultOutlineColor, bool &hasOutlineWidthParam, double &defaultOutlineWidth) const
Tests if an svg file contains parameters for fill, outline color, outline width.
static QgsSymbolV2::OutputUnit decodeOutputUnit(const QString &str)
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
void drawMarker(QPainter *p, QgsSymbolV2RenderContext &context)
const QColor & color() const
static QgsSvgCache * instance()
static QString encodePenStyle(Qt::PenStyle style)
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
const QImage & svgAsImage(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool &fitsInCache)
Get SVG as QImage.
void drawRect(const QRectF &rectangle)
Perform transforms between map coordinates and device coordinates.
void setPixelSize(int pixelSize)
static QString symbolPathToName(QString path)
Get symbols's name from its path.
Mixed units in symbol layers.
void setFont(const QFont &font)
The output shall be in millimeters.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QString number(int n, int base)
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit u)
void markerOffset(QgsSymbolV2RenderContext &context, double &offsetX, double &offsetY) const
const QgsFeature * feature() const
Current feature being rendered - may be null.
QRectF bounds(QPointF point, QgsSymbolV2RenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
void fill(uint pixelValue)
static QString encodePoint(QPointF point)
static double convertToPainterUnits(const QgsRenderContext &c, double size, QgsSymbolV2::OutputUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale())
Converts a size from the specied units to painter units.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void setPath(const QString &path)
void setPen(const QColor &color)
void lineTo(const QPointF &endPoint)
#define DEFAULT_SCALE_METHOD
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
Qt::PenStyle mOutlineStyle
QMatrix & translate(qreal dx, qreal dy)
void setMapUnitScale(const QgsMapUnitScale &scale) override
QString fontFamily() const
void setFillColor(const QColor &color) override
Set fill color.
QgsFontMarkerSymbolLayerV2(const QString &fontFamily=DEFAULT_FONTMARKER_FONT, QChar chr=DEFAULT_FONTMARKER_CHR, double pointSize=DEFAULT_FONTMARKER_SIZE, const QColor &color=DEFAULT_FONTMARKER_COLOR, double angle=DEFAULT_FONTMARKER_ANGLE)
double outlineWidth() const
bool prepareShape(const QString &name=QString())
QgsSymbolV2::ScaleMethod mScaleMethod
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
bool forceVectorOutput() const
void setLayer(const QString &layer)
void setSizeUnit(QgsSymbolV2::OutputUnit unit)
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
QPaintDevice * device() const
QgsMapUnitScale mapUnitScale() const override
void setWidthF(qreal width)
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void stopRender(QgsSymbolV2RenderContext &context) override
void setBrush(const QBrush &brush)
void drawText(const QPointF &position, const QString &text)
double rasterScaleFactor() const
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
#define DEFAULT_FONTMARKER_ANGLE
QgsSymbolV2::OutputUnit outputUnit() const override
static const QString EXPR_FILL
virtual QColor color() const
The fill color.
const QByteArray & svgContent(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor)
Get SVG content.
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
HorizontalAnchorPoint mHorizontalAnchorPoint
QgsSvgMarkerSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setColor(const QColor &color)
virtual Q_DECL_DEPRECATED void prepareExpressions(const QgsFields *fields, double scale=-1.0)
Prepares all data defined property expressions for evaluation.
void renderPoint(QPointF point, QgsSymbolV2RenderContext &context) override
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
static Qt::PenStyle decodePenStyle(const QString &str)
QgsSymbolV2::ScaleMethod scaleMethod() const
static const QString EXPR_OUTLINE_STYLE
void writePolyline(const QgsPolyline &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
QgsSymbolV2::OutputUnit mOutlineWidthUnit
#define DEFAULT_SVGMARKER_SIZE
~QgsFontMarkerSymbolLayerV2()
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
QFontMetrics * mFontMetrics
static const QString EXPR_COLOR
static const QString EXPR_ANGLE
QRect mapRect(const QRect &rectangle) const
int width(const QString &text, int len) const
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mapUnitScale() const override
void startRender(QgsSymbolV2RenderContext &context) override
#define DEFAULT_FONTMARKER_SIZE
void startRender(QgsSymbolV2RenderContext &context) override
static const QString EXPR_OUTLINE_WIDTH
#define DEFAULT_FONTMARKER_FONT
#define DEFAULT_SVGMARKER_NAME
QMatrix & rotate(qreal degrees)
#define DEFAULT_SIMPLEMARKER_SIZE
void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
void setShift(QPointF shift)
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
QString mid(int position, int n) const
void drawPath(const QPainterPath &path)
static double lineWidthScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns the line width scale factor depending on the unit and the paint device.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
Struct for storing maximum and minimum scales for measurements in map units.
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext *context, const QgsFeature *f, QPointF shift=QPointF(0.0, 0.0)) const override
QgsMapUnitScale mapUnitScale() const override
Qt::PenStyle outlineStyle() const
static const QString EXPR_NAME
QgsSvgMarkerSymbolLayerV2(const QString &name=DEFAULT_SVGMARKER_NAME, double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, QgsSymbolV2::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
static QString encodeScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QgsRenderContext & renderContext()
QDomElement firstChildElement(const QString &tagName) const
bool preparePath(QString name=QString())
int count(const T &value) const
static const QString EXPR_COLOR_BORDER
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
void translate(const QPointF &offset)
const QgsMapToPixel & mapToPixel() const
QColor fillColor() const override
Get fill color.
QgsSymbolV2::OutputUnit mOffsetUnit
void setAlphaF(qreal alpha)
virtual void setColor(const QColor &color)
The fill color.
void startRender(QgsSymbolV2RenderContext &context) override
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
double toDouble(bool *ok) const
static QColor decodeColor(const QString &str)
void startRender(QgsSymbolV2RenderContext &context) override
VerticalAnchorPoint mVerticalAnchorPoint
QgsSymbolV2::OutputUnit mSizeUnit
Calculate scale by the area.
QgsMapUnitScale mOffsetMapUnitScale
void drawPicture(const QPointF &point, const QPicture &picture)
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext *context, const QgsFeature *f, QPointF shift=QPointF(0.0, 0.0)) const override
static const QString EXPR_OUTLINE
QRectF bounds(QPointF point, QgsSymbolV2RenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
void restoreDataDefinedProperties(const QgsStringMap &stringMap)
Restores all data defined properties from string map.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QDomElement createElement(const QString &tagName)
void map(int x, int y, int *tx, int *ty) const
void setAngle(double angle)
bool begin(QPaintDevice *device)
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void setColor(const QColor &color)
QgsFontMarkerSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void saveDataDefinedProperties(QgsStringMap &stringMap) const
Saves all data defined properties to a string map.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
QColor outlineColor() const override
Get outline color.
QgsSimpleMarkerSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QColor outlineColor() const override
Get outline color.
bool prepareCache(QgsSymbolV2RenderContext &context)
Prepares cache image.
static const int mMaximumCacheWidth
void copyDataDefinedProperties(QgsSymbolLayerV2 *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
QMatrix & scale(qreal sx, qreal sy)
void setOutputSize(const QRectF &r)
const T value(const Key &key) const
static Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &borderColor=QColor(), double borderWidth=-1, double size=-1)
virtual Q_DECL_DEPRECATED QVariant evaluateDataDefinedProperty(const QString &property, const QgsFeature *feature, const QVariant &defaultVal=QVariant(), bool *ok=nullptr) const
Evaluates the matching data defined property and returns the calculated value.
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
void setOutlineColor(const QColor &color) override
Set outline color.