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 )
708 double angle = props.
value(
"angle",
"0" ).toDouble( &ok );
726 Q_UNUSED( mmScaleFactor );
727 Q_UNUSED( mapUnitScaleFactor );
730 if (
mName ==
"square" )
734 else if (
mName ==
"triangle" )
738 else if (
mName ==
"star" )
742 else if (
mName ==
"circle" )
746 else if (
mName ==
"cross" )
754 else if (
mName ==
"line" )
760 ogrString.
append(
"SYMBOL(" );
761 ogrString.
append(
"id:" );
763 ogrString.
append(
"ogr-sym-" );
764 ogrString.
append( ogrType );
766 ogrString.
append(
",c:" );
768 ogrString.
append(
",o:" );
776 ogrString.
append(
"PEN(" );
779 ogrString.
append(
",w:" );
791 if ( graphicElem.
isNull() )
796 double borderWidth,
size;
797 Qt::PenStyle borderStyle;
807 double d = angleFunc.
toDouble( &ok );
845 if ( hasDataDefinedSize )
869 size *= mmMapUnitScaleFactor;
871 double halfSize = size / 2.0;
883 outlineWidth *= mmMapUnitScaleFactor;
909 QPointF off( offsetX, offsetY );
932 off *= mmMapUnitScaleFactor;
936 t.
translate( shift.
x() + offsetX, shift.
y() + offsetY );
944 t.
scale( halfSize, -halfSize );
946 polygon = t.
map( polygon );
952 for ( i = 0; i < polygon.
size(); i++ )
953 p[0][i] = polygon[i];
959 e.
writePolyline( p[0], layerName,
"CONTINUOUS", pc, outlineWidth );
961 else if ( name ==
"circle" )
966 e.
writeCircle( layerName, pc, shift, halfSize,
"CONTINUOUS", outlineWidth );
968 else if ( name ==
"line" )
974 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
976 else if ( name ==
"cross" )
985 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
986 e.
writeLine( pt3, pt4, layerName,
"CONTINUOUS", pc, outlineWidth );
989 else if ( name ==
"x" || name ==
"cross2" )
998 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
999 e.
writeLine( pt3, pt4, layerName,
"CONTINUOUS", pc, outlineWidth );
1002 else if ( name ==
"arrowhead" )
1010 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
1011 e.
writeLine( pt3, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
1056 bool hasDataDefinedSize =
false;
1057 double scaledSize = calculateSize( context, hasDataDefinedSize );
1059 bool hasDataDefinedRotation =
false;
1062 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation, offset, angle );
1070 transform.
translate( point.
x() + offset.
x(), point.
y() + offset.
y() );
1073 transform.
rotate( angle );
1075 double penWidth = 0.0;
1090 if ( ok && outlineStyle ==
"no" )
1096 penWidth += pixelSize;
1104 symbolBounds.
adjust( -penWidth / 2.0, -penWidth / 2.0,
1105 penWidth / 2.0, penWidth / 2.0 );
1107 return symbolBounds;
1123 mOutlineColor =
QColor( Qt::black );
1135 name = props[
"name"];
1137 size = props[
"size"].toDouble();
1139 angle = props[
"angle"].toDouble();
1140 if ( props.
contains(
"scale_method" ) )
1150 double fillOpacity = 1.0;
1151 double outlineOpacity = 1.0;
1153 bool hasFillParam =
false, hasFillOpacityParam =
false, hasOutlineParam =
false, hasOutlineWidthParam =
false, hasOutlineOpacityParam =
false;
1154 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultOutlineColor =
false, hasDefaultOutlineWidth =
false, hasDefaultOutlineOpacity =
false;
1156 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1157 hasOutlineParam, hasDefaultOutlineColor, outlineColor,
1158 hasOutlineWidthParam, hasDefaultOutlineWidth, outlineWidth,
1159 hasOutlineOpacityParam, hasDefaultOutlineOpacity, outlineOpacity );
1160 if ( hasDefaultFillColor )
1164 if ( hasDefaultFillOpacity )
1170 if ( hasDefaultOutlineColor )
1174 if ( hasDefaultOutlineWidth )
1178 if ( hasDefaultOutlineOpacity )
1186 if ( props.
contains(
"size_unit" ) )
1188 if ( props.
contains(
"size_map_unit_scale" ) )
1192 if ( props.
contains(
"offset_unit" ) )
1194 if ( props.
contains(
"offset_map_unit_scale" ) )
1201 else if ( props.
contains(
"color" ) )
1210 else if ( props.
contains(
"outline_color" ) )
1214 else if ( props.
contains(
"line_color" ) )
1219 if ( props.
contains(
"outline-width" ) )
1224 else if ( props.
contains(
"outline_width" ) )
1228 else if ( props.
contains(
"line_width" ) )
1233 if ( props.
contains(
"outline_width_unit" ) )
1237 else if ( props.
contains(
"line_width_unit" ) )
1241 if ( props.
contains(
"outline_width_map_unit_scale" ) )
1244 if ( props.
contains(
"horizontal_anchor_point" ) )
1248 if ( props.
contains(
"vertical_anchor_point" ) )
1261 QColor defaultFillColor, defaultOutlineColor;
1263 bool hasFillParam =
false, hasFillOpacityParam =
false, hasOutlineParam =
false, hasOutlineWidthParam =
false, hasOutlineOpacityParam =
false;
1264 bool hasDefaultFillColor =
false, hasDefaultFillOpacity =
false, hasDefaultOutlineColor =
false, hasDefaultOutlineWidth =
false, hasDefaultOutlineOpacity =
false;
1266 hasFillOpacityParam, hasDefaultFillOpacity, fillOpacity,
1267 hasOutlineParam, hasDefaultOutlineColor, defaultOutlineColor,
1268 hasOutlineWidthParam, hasDefaultOutlineWidth, outlineWidth,
1269 hasOutlineOpacityParam, hasDefaultOutlineOpacity, outlineOpacity );
1271 double newFillOpacity = hasFillOpacityParam ?
fillColor().
alphaF() : 1.0;
1274 if ( hasDefaultFillColor )
1276 defaultFillColor.
setAlphaF( newFillOpacity );
1279 if ( hasDefaultFillOpacity )
1285 if ( hasDefaultOutlineColor )
1287 defaultOutlineColor.
setAlphaF( newOutlineOpacity );
1290 if ( hasDefaultOutlineWidth )
1294 if ( hasDefaultOutlineOpacity )
1311 Q_UNUSED( context );
1317 Q_UNUSED( context );
1326 bool hasDataDefinedSize =
false;
1327 double scaledSize = calculateSize( context, hasDataDefinedSize );
1331 if ( static_cast< int >( size ) < 1 || 10000.0 <
size )
1340 calculateOffsetAndRotation( context, scaledSize, outputOffset, angle );
1382 bool fitsInCache =
true;
1383 bool usePict =
true;
1384 double hwRatio = 1.0;
1390 if ( fitsInCache && img.
width() > 1 )
1397 p->
drawImage( -transparentImage.
width() / 2.0, -transparentImage.
height() / 2.0, transparentImage );
1398 hwRatio =
static_cast< double >( transparentImage.
height() ) / static_cast< double >( transparentImage.
width() );
1403 hwRatio =
static_cast< double >( img.
height() ) / static_cast< double >( img.
width() );
1408 if ( usePict || !fitsInCache )
1414 if ( pct.
width() > 1 )
1420 hwRatio =
static_cast< double >( pct.
height() ) / static_cast< double >( pct.
width() );
1428 if ( penWidth > size / 20 )
1431 penWidth = size / 20;
1433 double penOffset = penWidth / 2;
1434 pen.setWidth( penWidth );
1437 double wSize = size + penOffset;
1438 double hSize = size * hwRatio + penOffset;
1439 p->
drawRect(
QRectF( -wSize / 2.0, -hSize / 2.0, wSize, hSize ) );
1452 double QgsSvgMarkerSymbolLayerV2::calculateSize(
QgsSymbolV2RenderContext& context,
bool& hasDataDefinedSize )
const 1454 double scaledSize =
mSize;
1464 if ( hasDataDefinedSize && ok )
1469 scaledSize = sqrt( scaledSize );
1484 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
1485 offset =
QPointF( offsetX, offsetY );
1495 if ( hasDataDefinedRotation )
1606 double angle = props.
value(
"angle",
"0" ).toDouble( &ok );
1628 if ( graphicElem.
isNull() )
1638 if ( mimeType !=
"image/svg+xml" )
1646 double d = angleFunc.
toDouble( &ok );
1665 Q_UNUSED( layerName );
1680 if ( hasDataDefinedSize && ok )
1685 size = sqrt( size );
1694 size *= mmMapUnitScaleFactor;
1697 double halfSize = size / 2.0;
1709 double offsetX = offset.
x();
1710 double offsetY = offset.
y();
1713 offsetX *= mmMapUnitScaleFactor;
1714 offsetY *= mmMapUnitScaleFactor;
1717 QPointF outputOffset( offsetX, offsetY );
1796 bool hasDataDefinedSize =
false;
1797 double scaledSize = calculateSize( context, hasDataDefinedSize );
1801 if ( static_cast< int >( scaledSize ) < 1 || 10000.0 < scaledSize )
1808 calculateOffsetAndRotation( context, scaledSize, outputOffset, angle );
1849 double scaledHeight = svgViewbox.
isValid() ? scaledSize * svgViewbox.
height() / svgViewbox.
width() : scaledSize;
1855 transform.
translate( point.
x() + outputOffset.
x(), point.
y() + outputOffset.
y() );
1858 transform.
rotate( angle );
1861 outlineWidth += pixelSize / 2.0;
1864 -scaledHeight / 2.0,
1869 symbolBounds.
adjust( -outlineWidth / 2.0, -outlineWidth / 2.0,
1870 outlineWidth / 2.0, outlineWidth / 2.0 );
1872 return symbolBounds;
1879 : mFontMetrics( nullptr )
1907 fontFamily = props[
"font"];
1908 if ( props.
contains(
"chr" ) && props[
"chr"].length() > 0 )
1909 chr = props[
"chr"].at( 0 );
1911 pointSize = props[
"size"].toDouble();
1915 angle = props[
"angle"].toDouble();
1920 if ( props.
contains(
"offset_unit" ) )
1922 if ( props.
contains(
"offset_map_unit_scale" ) )
1924 if ( props.
contains(
"size_unit" ) )
1926 if ( props.
contains(
"size_map_unit_scale" ) )
1928 if ( props.
contains(
"horizontal_anchor_point" ) )
1932 if ( props.
contains(
"vertical_anchor_point" ) )
1944 return "FontMarker";
1961 Q_UNUSED( context );
1972 if ( charToRender !=
mChr )
1978 return charToRender;
1983 bool& hasDataDefinedRotation,
1985 double&
angle )
const 1990 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
1991 offset =
QPointF( offsetX, offsetY );
1996 bool usingDataDefinedRotation =
false;
2001 usingDataDefinedRotation = ok;
2005 if ( hasDataDefinedRotation )
2030 double scaledSize =
mSize;
2040 if ( hasDataDefinedSize && ok )
2045 scaledSize = sqrt( scaledSize );
2078 QString charToRender = characterToRender( context, chrOffset, chrWidth );
2080 double sizeToRender = calculateSize( context );
2082 bool hasDataDefinedRotation =
false;
2085 calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation, offset, angle );
2098 p->
drawText( -chrOffset, charToRender );
2106 props[
"chr"] =
mChr;
2153 double angle = props.
value(
"angle",
"0" ).toDouble( &ok );
2174 ( void )characterToRender( context, chrOffset, chrWidth );
2179 double scaledSize = calculateSize( context );
2185 bool hasDataDefinedRotation =
false;
2188 calculateOffsetAndRotation( context, scaledSize, hasDataDefinedRotation, offset, angle );
2194 transform.
translate( point.
x() + offset.
x(), point.
y() + offset.
y() );
2197 transform.
rotate( angle );
2199 QRectF symbolBounds = transform.mapRect(
QRectF( -chrWidth / 2.0,
2203 return symbolBounds;
2211 if ( graphicElem.
isNull() )
2222 if ( !name.
startsWith(
"ttf://" ) || format !=
"ttf" )
2232 double d = angleFunc.
toDouble( &ok );
void addEllipse(const QRectF &boundingRectangle)
QgsSymbolV2::OutputUnit outputUnit() const override
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 markerOffset(QgsSymbolV2RenderContext &context, double &offsetX, double &offsetY) const
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()
Qt::PenStyle outlineStyle() const
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)
static double rescaleUom(double size, QgsSymbolV2::OutputUnit unit, const QgsStringMap &props)
Rescales the given size based on the uomScale found in the props, if any is found, otherwise returns the value un-modified.
Use antialiasing while drawing.
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
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)
QString fontFamily() const
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)
#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
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
static QPointF decodePoint(const QString &str)
Flags flags() const
Return combination of flags used for rendering.
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.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
void stopRender(QgsSymbolV2RenderContext &context) override
const QgsFeature * feature() const
Current feature being rendered - may be null.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
void setOutlineWidth(double w)
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
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())
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
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_SVGMARKER_ANGLE
static const QString EXPR_SIZE
double mapRotation() const
Return current map rotation in degrees.
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
#define DEFAULT_SIMPLEMARKER_NAME
static QgsSymbolV2::OutputUnit decodeOutputUnit(const QString &str)
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
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)
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)
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
#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
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)
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
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
QColor selectionColor() 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)
QColor borderColor() 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
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.
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
void renderPoint(QPointF point, QgsSymbolV2RenderContext &context) override
virtual QColor color() const
The fill color.
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
static Qt::PenStyle decodePenStyle(const QString &str)
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()
void copyDataDefinedProperties(QgsSymbolLayerV2 *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
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)
void saveDataDefinedProperties(QgsStringMap &stringMap) const
Saves all data defined properties to a string map.
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
bool forceVectorOutput() const
void startRender(QgsSymbolV2RenderContext &context) override
static const QString EXPR_OUTLINE_WIDTH
#define DEFAULT_FONTMARKER_FONT
void copyPaintEffect(QgsSymbolLayerV2 *destLayer) const
Copies paint effect of this layer to another symbol layer.
#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)
QgsSymbolV2::ScaleMethod scaleMethod() const
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
const QgsMapToPixel & mapToPixel() const
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.
QgsMapUnitScale mapUnitScale() const override
virtual bool hasDataDefinedProperty(const QString &property) const
Checks whether the layer has a matching data defined property and if that property is currently activ...
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
double outlineWidth() const
void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
void translate(const QPointF &offset)
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)
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)
double rasterScaleFactor() const
QDomElement createElement(const QString &tagName)
void map(int x, int y, int *tx, int *ty) const
void setAngle(double angle)
double scaleFactor() const
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 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
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)
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
void setOutlineColor(const QColor &color) override
Set outline color.