20 #include "qgsdxfexport.h"
30 #include <QSvgRenderer>
31 #include <QDomDocument>
32 #include <QDomElement>
35 Qt::PenJoinStyle penJoinStyle ) :
37 mBorderColor( borderColor ),
38 mBorderStyle( borderStyle ),
39 mBorderWidth( borderWidth ),
41 mPenJoinStyle( penJoinStyle ),
81 if ( colorExpression )
86 if ( colorBorderExpression )
91 if ( widthBorderExpression )
93 double width = widthBorderExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
95 pen.setWidthF( width );
96 selPen.setWidthF( width );
111 if ( props.contains(
"color" ) )
113 if ( props.contains(
"style" ) )
115 if ( props.contains(
"color_border" ) )
117 if ( props.contains(
"style_border" ) )
119 if ( props.contains(
"width_border" ) )
120 borderWidth = props[
"width_border"].toDouble();
121 if ( props.contains(
"offset" ) )
123 if ( props.contains(
"joinstyle" ) )
128 if ( props.contains(
"border_width_unit" ) )
130 if ( props.contains(
"offset_unit" ) )
133 if ( props.contains(
"border_width_map_unit_scale" ) )
135 if ( props.contains(
"offset_map_unit_scale" ) )
138 if ( props.contains(
"color_expression" ) )
142 if ( props.contains(
"color_border_expression" ) )
146 if ( props.contains(
"width_border_expression" ) )
162 fillColor.setAlphaF( context.
alpha() *
mColor.alphaF() );
167 if ( rasterScaleFactor != 1.0 )
169 mBrush.setMatrix( QMatrix().scale( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor ) );
183 mPen = QPen( borderColor );
214 p->translate( offset );
221 p->translate( -offset );
260 QDomElement symbolizerElem = doc.createElement(
"se:PolygonSymbolizer" );
261 if ( !props.value(
"uom",
"" ).isEmpty() )
262 symbolizerElem.setAttribute(
"uom", props.value(
"uom",
"" ) );
263 element.appendChild( symbolizerElem );
271 QDomElement fillElem = doc.createElement(
"se:Fill" );
272 symbolizerElem.appendChild( fillElem );
279 QDomElement strokeElem = doc.createElement(
"se:Stroke" );
280 symbolizerElem.appendChild( strokeElem );
293 symbolStyle.append(
";" );
304 Qt::BrushStyle fillStyle;
308 QDomElement fillElem = element.firstChildElement(
"Fill" );
311 QDomElement strokeElem = element.firstChildElement(
"Stroke" );
326 return penBleed + offsetBleed;
333 if ( widthBorderExpression )
335 width = widthBorderExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
337 return width * e.mapUnitScaleFactor( e.symbologyScaleDenominator(),
mBorderWidthUnit, e.mapUnits() );
343 if ( colorBorderExpression )
360 : mGradientColorType( colorType ),
361 mGradientRamp( NULL ),
362 mGradientType( gradientType ),
363 mCoordinateMode( coordinateMode ),
364 mGradientSpread( spread ),
365 mReferencePoint1( QPointF( 0.5, 0 ) ),
366 mReferencePoint1IsCentroid( false ),
367 mReferencePoint2( QPointF( 0.5, 1 ) ),
368 mReferencePoint2IsCentroid( false ),
391 bool refPoint1IsCentroid =
false;
393 bool refPoint2IsCentroid =
false;
398 if ( props.contains(
"type" ) )
400 if ( props.contains(
"coordinate_mode" ) )
402 if ( props.contains(
"spread" ) )
404 if ( props.contains(
"color_type" ) )
406 if ( props.contains(
"gradient_color" ) )
408 if ( props.contains(
"gradient_color2" ) )
410 if ( props.contains(
"reference_point1" ) )
412 if ( props.contains(
"reference_point1_iscentroid" ) )
413 refPoint1IsCentroid = props[
"reference_point1_iscentroid"].toInt();
414 if ( props.contains(
"reference_point2" ) )
416 if ( props.contains(
"reference_point2_iscentroid" ) )
417 refPoint2IsCentroid = props[
"reference_point2_iscentroid"].toInt();
418 if ( props.contains(
"angle" ) )
419 angle = props[
"angle"].toDouble();
420 if ( props.contains(
"offset" ) )
429 if ( props.contains(
"offset_unit" ) )
431 if ( props.contains(
"offset_map_unit_scale" ) )
442 if ( props.contains(
"color_expression" ) )
444 if ( props.contains(
"color2_expression" ) )
446 if ( props.contains(
"angle_expression" ) )
448 if ( props.contains(
"gradient_type_expression" ) )
450 if ( props.contains(
"coordinate_mode_expression" ) )
452 if ( props.contains(
"spread_expression" ) )
454 if ( props.contains(
"reference1_x_expression" ) )
456 if ( props.contains(
"reference1_y_expression" ) )
458 if ( props.contains(
"reference1_iscentroid_expression" ) )
460 if ( props.contains(
"reference2_x_expression" ) )
462 if ( props.contains(
"reference2_y_expression" ) )
464 if ( props.contains(
"reference2_iscentroid_expression" ) )
478 return "GradientFill";
486 if ( colorExpression )
492 if ( colorExpression2 )
498 if ( angleExpression )
499 angle = angleExpression->evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
504 if ( typeExpression )
506 QString currentType = typeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
515 else if ( currentType ==
QObject::tr(
"conical" ) )
529 if ( coordModeExpression )
531 QString currentCoordMode = coordModeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
532 if ( currentCoordMode ==
QObject::tr(
"feature" ) )
536 else if ( currentCoordMode ==
QObject::tr(
"viewport" ) )
550 if ( spreadExpression )
552 QString currentSpread = spreadExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
557 else if ( currentSpread ==
QObject::tr(
"repeat" ) )
561 else if ( currentSpread ==
QObject::tr(
"reflect" ) )
575 if ( ref1XExpression )
576 refPoint1X = ref1XExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
579 if ( ref1YExpression )
580 refPoint1Y = ref1YExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
583 if ( ref1IsCentroidExpression )
584 refPoint1IsCentroid = ref1IsCentroidExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toBool();
589 if ( ref2XExpression )
590 refPoint2X = ref2XExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
593 if ( ref2YExpression )
594 refPoint2Y = ref2YExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
597 if ( ref2IsCentroidExpression )
598 refPoint2IsCentroid = ref2IsCentroidExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toBool();
600 if ( refPoint1IsCentroid || refPoint2IsCentroid )
605 QRectF bbox = points.boundingRect();
606 double centroidX = ( centroid.x() - bbox.left() ) / bbox.width();
607 double centroidY = ( centroid.y() - bbox.top() ) / bbox.height();
609 if ( refPoint1IsCentroid )
611 refPoint1X = centroidX;
612 refPoint1Y = centroidY;
614 if ( refPoint2IsCentroid )
616 refPoint2X = centroidX;
617 refPoint2Y = centroidY;
623 spread, QPointF( refPoint1X, refPoint1Y ), QPointF( refPoint2X, refPoint2Y ), angle );
631 QLineF refLine = QLineF( QPointF( 0.5, 0.5 ), refPoint );
633 refLine.setAngle( refLine.angle() +
angle );
635 QPointF rotatedReferencePoint = refLine.p2();
637 if ( rotatedReferencePoint.x() > 1 )
638 rotatedReferencePoint.setX( 1 );
639 if ( rotatedReferencePoint.x() < 0 )
640 rotatedReferencePoint.setX( 0 );
641 if ( rotatedReferencePoint.y() > 1 )
642 rotatedReferencePoint.setY( 1 );
643 if ( rotatedReferencePoint.y() < 0 )
644 rotatedReferencePoint.setY( 0 );
646 return rotatedReferencePoint;
650 const QColor &color,
const QColor &color2,
const GradientColorType &gradientColorType,
653 const QPointF &referencePoint1,
const QPointF &referencePoint2,
const double angle )
657 fillColor.setAlphaF( context.
alpha() * fillColor.alphaF() );
658 QColor fillColor2 =
color2;
659 fillColor2.setAlphaF( context.
alpha() * fillColor2.alphaF() );
667 switch ( gradientType )
670 gradient = QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
673 gradient = QRadialGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
676 gradient = QConicalGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).
angle() );
679 switch ( coordinateMode )
682 gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
685 gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
688 switch ( gradientSpread )
691 gradient.setSpread( QGradient::PadSpread );
694 gradient.setSpread( QGradient::ReflectSpread );
697 gradient.setSpread( QGradient::RepeatSpread );
711 gradient.setColorAt( 0.0, fillColor );
712 gradient.setColorAt( 1.0, fillColor2 );
716 brush = QBrush( gradient );
746 p->setPen( QPen( Qt::NoPen ) );
753 p->translate( offset );
760 p->translate( -offset );
777 map[
"angle"] = QString::number(
mAngle );
835 int blurRadius,
bool useWholeShape,
double maxDistance ) :
837 mBlurRadius( blurRadius ),
838 mUseWholeShape( useWholeShape ),
839 mMaxDistance( maxDistance ),
841 mColorType( colorType ),
843 mGradientRamp( NULL ),
844 mTwoColorGradientRamp( 0 ),
845 mIgnoreRings( false ),
867 if ( props.contains(
"color_type" ) )
871 if ( props.contains(
"shapeburst_color" ) )
875 if ( props.contains(
"shapeburst_color2" ) )
879 if ( props.contains(
"blur_radius" ) )
881 blurRadius = props[
"blur_radius"].toInt();
883 if ( props.contains(
"use_whole_shape" ) )
885 useWholeShape = props[
"use_whole_shape"].toInt();
887 if ( props.contains(
"max_distance" ) )
889 maxDistance = props[
"max_distance"].toDouble();
891 if ( props.contains(
"offset" ) )
902 if ( props.contains(
"offset_unit" ) )
906 if ( props.contains(
"distance_unit" ) )
910 if ( props.contains(
"offset_map_unit_scale" ) )
914 if ( props.contains(
"distance_map_unit_scale" ) )
918 if ( props.contains(
"ignore_rings" ) )
927 if ( props.contains(
"color_expression" ) )
929 if ( props.contains(
"color2_expression" ) )
931 if ( props.contains(
"blur_radius_expression" ) )
933 if ( props.contains(
"use_whole_shape_expression" ) )
935 if ( props.contains(
"max_distance_expression" ) )
937 if ( props.contains(
"ignore_rings_expression" ) )
945 return "ShapeburstFill";
955 double& maxDistance,
bool& ignoreRings )
960 if ( colorExpression )
966 if ( colorExpression2 )
972 if ( blurRadiusExpression )
973 blurRadius = blurRadiusExpression->evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toInt();
978 if ( useWholeShapeExpression )
979 useWholeShape = useWholeShapeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toBool();
984 if ( maxDistanceExpression )
985 maxDistance = maxDistanceExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
990 if ( ignoreRingsExpression )
991 ignoreRings = ignoreRingsExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toBool();
1007 Q_UNUSED( context );
1027 p->translate( offset );
1032 p->translate( -offset );
1046 int outputPixelMaxDist = 0;
1047 if ( !useWholeShape && maxDistance != 0 )
1061 p->setPen( QPen( Qt::NoPen ) );
1064 int sideBuffer = 4 + ( blurRadius + 2 ) * 4 ;
1066 double imWidth = points.boundingRect().width() + ( sideBuffer * 2 );
1067 double imHeight = points.boundingRect().height() + ( sideBuffer * 2 );
1073 fillImage->fill( Qt::black );
1076 QImage * alphaImage =
new QImage( fillImage->width(), fillImage->height(), QImage::Format_ARGB32_Premultiplied );
1078 alphaImage->fill( Qt::transparent );
1081 QPainter imgPainter;
1082 imgPainter.begin( alphaImage );
1083 imgPainter.setRenderHint( QPainter::Antialiasing,
true );
1084 imgPainter.setBrush( QBrush( Qt::white ) );
1085 imgPainter.setPen( QPen( Qt::black ) );
1086 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1093 imgPainter.begin( fillImage );
1096 imgPainter.drawImage( 0, 0, *alphaImage );
1103 imgPainter.setBrush( QBrush( Qt::white ) );
1104 imgPainter.setPen( QPen( Qt::black ) );
1105 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1126 if ( blurRadius > 0 )
1132 imgPainter.begin( fillImage );
1133 imgPainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
1134 imgPainter.drawImage( 0, 0, *alphaImage );
1147 p->translate( offset );
1151 p->drawImage( points.boundingRect().left() - sideBuffer, points.boundingRect().top() - sideBuffer, *fillImage );
1157 p->translate( -offset );
1172 for (
int q = 1; q <= n - 1; q++ )
1174 double s = (( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1178 s = (( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1187 for (
int q = 0; q <= n - 1; q++ )
1189 while ( z[k+1] < q )
1191 d[q] = ( q - v[k] ) * ( q - v[k] ) + f[v[k]];
1198 double *f =
new double[ qMax( width,height )];
1199 int *v =
new int[ qMax( width,height )];
1200 double *z =
new double[ qMax( width,height ) + 1 ];
1201 double *d =
new double[ qMax( width,height )];
1204 for (
int x = 0; x < width; x++ )
1206 for (
int y = 0; y < height; y++ )
1208 f[y] = im[ x + y * width ];
1211 for (
int y = 0; y < height; y++ )
1213 im[ x + y * width ] = d[y];
1218 for (
int y = 0; y < height; y++ )
1220 for (
int x = 0; x < width; x++ )
1222 f[x] = im[ x + y*width ];
1225 for (
int x = 0; x < width; x++ )
1227 im[ x + y*width ] = d[x];
1240 int width = im->width();
1241 int height = im->height();
1243 double * dtArray =
new double[width * height];
1248 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1250 QRgb* scanLine = ( QRgb* )im->constScanLine( heightIndex );
1251 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1253 tmpRgb = scanLine[widthIndex];
1254 if ( qRed( tmpRgb ) == 0 )
1262 dtArray[ idx ] =
INF;
1277 double maxDistanceValue;
1279 if ( useWholeShape )
1282 double dtMaxValue = array[0];
1283 for (
int i = 1; i < ( im->width() * im->height() ); ++i )
1285 dtMaxValue = qMax( dtMaxValue, array[i] );
1289 maxDistanceValue = sqrt( dtMaxValue );
1294 maxDistanceValue = maxPixelDistance;
1299 double squaredVal = 0;
1303 for (
int heightIndex = 0; heightIndex < im->height(); ++heightIndex )
1305 QRgb* scanLine = ( QRgb* )im->scanLine( heightIndex );
1306 for (
int widthIndex = 0; widthIndex < im->width(); ++widthIndex )
1309 squaredVal = array[idx];
1312 pixVal = squaredVal > 0 ? qMin(( sqrt( squaredVal ) / maxDistanceValue ), 1.0 ) : 0;
1315 pixColor = ramp->
color( pixVal );
1318 double alpha = pixColor.alpha() * layerAlpha;
1322 scanLine[widthIndex] = pixColor.rgba();
1333 map[
"color_type"] = QString::number(
mColorType );
1334 map[
"blur_radius"] = QString::number(
mBlurRadius );
1430 p->setPen( QPen( Qt::NoPen ) );
1437 p->setBrush( QBrush( selColor ) );
1447 QTransform t =
mBrush.transform();
1449 QBrush rotatedBrush =
mBrush;
1450 rotatedBrush.setTransform( t );
1451 p->setBrush( rotatedBrush );
1459 QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
1460 for ( ; ringIt != rings->constEnd(); ++ringIt )
1520 return subLayerBleed;
1529 if ( widthExpression )
1531 width = widthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
1533 return width * e.mapUnitScaleFactor( e.symbologyScaleDenominator(),
mOutlineWidthUnit, e.mapUnits() );
1538 Q_UNUSED( context );
1541 return QColor( Qt::black );
1548 return Qt::SolidLine;
1552 return Qt::SolidLine;
1565 mPatternWidth( width ),
1577 mPatternWidth( width ),
1579 mSvgData( svgData ),
1648 if ( properties.contains(
"width" ) )
1650 width = properties[
"width"].toDouble();
1652 if ( properties.contains(
"svgFile" ) )
1654 QString svgName = properties[
"svgFile"];
1656 svgFilePath = ( savePath.isEmpty() ? svgName : savePath );
1658 if ( properties.contains(
"angle" ) )
1660 angle = properties[
"angle"].toDouble();
1664 if ( !svgFilePath.isEmpty() )
1670 if ( properties.contains(
"data" ) )
1672 data = QByteArray::fromHex( properties[
"data"].toLocal8Bit() );
1678 if ( properties.contains(
"svgFillColor" ) )
1682 if ( properties.contains(
"svgOutlineColor" ) )
1686 if ( properties.contains(
"svgOutlineWidth" ) )
1692 if ( properties.contains(
"pattern_width_unit" ) )
1696 if ( properties.contains(
"pattern_width_map_unit_scale" ) )
1700 if ( properties.contains(
"svg_outline_width_unit" ) )
1704 if ( properties.contains(
"svg_outline_width_map_unit_scale" ) )
1708 if ( properties.contains(
"outline_width_unit" ) )
1712 if ( properties.contains(
"outline_width_map_unit_scale" ) )
1717 if ( properties.contains(
"width_expression" ) )
1719 if ( properties.contains(
"svgFile_expression" ) )
1721 if ( properties.contains(
"angle_expression" ) )
1723 if ( properties.contains(
"svgFillColor_expression" ) )
1725 if ( properties.contains(
"svgOutlineColor_expression" ) )
1727 if ( properties.contains(
"svgOutlineWidth_expression" ) )
1739 const QColor& svgFillColor,
const QColor& svgOutlineColor,
double svgOutlineWidth,
1752 if ((
int )size < 1.0 || 10000.0 <
size )
1759 bool fitsInCache =
true;
1767 double hwRatio = 1.0;
1768 if ( patternPict.width() > 0 )
1770 hwRatio = ( double )patternPict.height() / ( double )patternPict.width();
1772 mSvgPattern =
new QImage((
int )size, (
int )( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
1776 p.drawPicture( QPointF( size / 2, size * hwRatio / 2 ), patternPict );
1779 QTransform brushTransform;
1783 QImage transparentImage = fitsInCache ? patternImage.copy() :
mSvgPattern->copy();
1785 brush.setTextureImage( transparentImage );
1789 brush.setTextureImage( fitsInCache ? patternImage : *
mSvgPattern );
1791 brush.setTransform( brushTransform );
1798 applyPattern(
mBrush,
mSvgFilePath,
mPatternWidth,
mPatternWidthUnit,
mSvgFillColor,
mSvgOutlineColor,
mSvgOutlineWidth,
mSvgOutlineWidthUnit, context,
mPatternWidthMapUnitScale,
mSvgOutlineWidthMapUnitScale );
1825 map.insert(
"data", QString(
mSvgData.toHex() ) );
1829 map.insert(
"angle", QString::number(
mAngle ) );
1880 QDomElement symbolizerElem = doc.createElement(
"se:PolygonSymbolizer" );
1881 if ( !props.value(
"uom",
"" ).isEmpty() )
1882 symbolizerElem.setAttribute(
"uom", props.value(
"uom",
"" ) );
1883 element.appendChild( symbolizerElem );
1887 QDomElement fillElem = doc.createElement(
"se:Fill" );
1888 symbolizerElem.appendChild( fillElem );
1890 QDomElement graphicFillElem = doc.createElement(
"se:GraphicFill" );
1891 fillElem.appendChild( graphicFillElem );
1893 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
1894 graphicFillElem.appendChild( graphicElem );
1904 symbolizerElem.appendChild( doc.createComment(
"SVG from data not implemented yet" ) );
1915 double angle = props.value(
"angle",
"0" ).toDouble( &ok );
1918 angleFunc = QString(
"%1 + %2" ).arg( props.value(
"angle",
"0" ) ).arg(
mAngle );
1920 else if ( angle +
mAngle != 0 )
1922 angleFunc = QString::number( angle +
mAngle );
1939 QString path, mimeType;
1941 Qt::PenStyle penStyle;
1942 double size, borderWidth;
1944 QDomElement fillElem = element.firstChildElement(
"Fill" );
1945 if ( fillElem.isNull() )
1948 QDomElement graphicFillElem = fillElem.firstChildElement(
"GraphicFill" );
1949 if ( graphicFillElem.isNull() )
1952 QDomElement graphicElem = graphicFillElem.firstChildElement(
"Graphic" );
1953 if ( graphicElem.isNull() )
1959 if ( mimeType !=
"image/svg+xml" )
1969 double d = angleFunc.toDouble( &ok );
1980 QDomElement strokeElem = element.firstChildElement(
"Stroke" );
1981 if ( !strokeElem.isNull() )
2003 if ( !widthExpression && !svgFileExpression && !fillColorExpression && !outlineColorExpression && !outlineWidthExpression && !angleExpression )
2008 if ( angleExpression )
2014 if ( widthExpression )
2016 width = widthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
2019 if ( svgFileExpression )
2021 svgFile = svgFileExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
2024 if ( fillColorExpression )
2029 if ( outlineColorExpression )
2034 if ( outlineWidthExpression )
2036 outlineWidth = outlineWidthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
2071 bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
2072 QColor defaultFillColor, defaultOutlineColor;
2073 double defaultOutlineWidth;
2075 defaultOutlineWidth );
2081 if ( hasOutlineParam )
2085 if ( hasOutlineWidthParam )
2093 mOffsetUnit(
QgsSymbolV2::MM ), mFillLineSymbol( 0 )
2193 QColor
color( Qt::black );
2196 if ( properties.contains(
"lineangle" ) )
2198 lineAngle = properties[
"lineangle"].toDouble();
2202 if ( properties.contains(
"distance" ) )
2204 distance = properties[
"distance"].toDouble();
2208 if ( properties.contains(
"linewidth" ) )
2210 lineWidth = properties[
"linewidth"].toDouble();
2214 if ( properties.contains(
"color" ) )
2220 if ( properties.contains(
"offset" ) )
2222 offset = properties[
"offset"].toDouble();
2227 if ( properties.contains(
"distance_unit" ) )
2231 if ( properties.contains(
"distance_map_unit_scale" ) )
2235 if ( properties.contains(
"line_width_unit" ) )
2239 if ( properties.contains(
"line_width_map_unit_scale" ) )
2243 if ( properties.contains(
"offset_unit" ) )
2247 if ( properties.contains(
"offset_map_unit_scale" ) )
2251 if ( properties.contains(
"outline_width_unit" ) )
2255 if ( properties.contains(
"outline_width_map_unit_scale" ) )
2262 if ( properties.contains(
"lineangle_expression" ) )
2266 if ( properties.contains(
"distance_expression" ) )
2270 if ( properties.contains(
"linewidth_expression" ) )
2274 if ( properties.contains(
"color_expression" ) )
2278 return patternLayer;
2283 return "LinePatternFill";
2287 double lineWidth,
const QColor& color )
2289 Q_UNUSED( lineWidth );
2292 mBrush.setTextureImage( QImage() );
2300 if ( !fillLineSymbol )
2312 double outputPixelBleed = 0;
2313 double outputPixelInterval = 0;
2325 outputPixelBleed = qMax( outputPixelBleed, outputPixelLayerBleed );
2328 if ( markerLineLayer )
2337 outputPixelInterval = qMax( outputPixelInterval, outputPixelLayerInterval );
2341 if ( outputPixelInterval > 0 )
2345 double intervalScale = qRound( outputPixelInterval ) / outputPixelInterval;
2346 outputPixelInterval = qRound( outputPixelInterval );
2353 if ( markerLineLayer )
2364 height = outputPixelDist;
2365 width = outputPixelInterval > 0 ? outputPixelInterval : height;
2369 width = outputPixelDist;
2370 height = outputPixelInterval > 0 ? outputPixelInterval : width;
2374 height = outputPixelDist / cos( lineAngle *
M_PI / 180 );
2375 width = outputPixelDist / sin( lineAngle *
M_PI / 180 );
2378 lineAngle = 180 * atan2((
double ) height, (
double ) width ) /
M_PI;
2379 if ( lineAngle < 0 )
2384 height = qAbs( height );
2385 width = qAbs( width );
2387 outputPixelDist = height * cos( lineAngle *
M_PI / 180 );
2391 int offsetHeight = qRound( qAbs( outputPixelOffset / cos( lineAngle *
M_PI / 180 ) ) );
2392 outputPixelOffset = offsetHeight * cos( lineAngle *
M_PI / 180 );
2401 int bufferMulti = qMax( qCeil( outputPixelBleed / width ), qCeil( outputPixelBleed / width ) );
2405 bufferMulti = qMax( bufferMulti, 1 );
2407 int xBuffer = width * bufferMulti;
2408 int yBuffer = height * bufferMulti;
2409 int innerWidth = width;
2410 int innerHeight = height;
2411 width += 2 * xBuffer;
2412 height += 2 * yBuffer;
2414 if ( width > 10000 || height > 10000 )
2419 QImage patternImage( width, height, QImage::Format_ARGB32 );
2420 patternImage.fill( 0 );
2422 QPointF p1, p2, p3, p4, p5, p6;
2425 p1 = QPointF( 0, yBuffer );
2426 p2 = QPointF( width, yBuffer );
2427 p3 = QPointF( 0, yBuffer + innerHeight );
2428 p4 = QPointF( width, yBuffer + innerHeight );
2432 p1 = QPointF( xBuffer, height );
2433 p2 = QPointF( xBuffer, 0 );
2434 p3 = QPointF( xBuffer + innerWidth, height );
2435 p4 = QPointF( xBuffer + innerWidth, 0 );
2437 else if ( lineAngle > 0 && lineAngle < 90 )
2439 dx = outputPixelDist * cos(( 90 - lineAngle ) *
M_PI / 180.0 );
2440 dy = outputPixelDist * sin(( 90 - lineAngle ) *
M_PI / 180.0 );
2441 p1 = QPointF( 0, height );
2442 p2 = QPointF( width, 0 );
2443 p3 = QPointF( -dx, height - dy );
2444 p4 = QPointF( width - dx, -dy );
2445 p5 = QPointF( dx, height + dy );
2446 p6 = QPointF( width + dx, dy );
2448 else if ( lineAngle > 180 && lineAngle < 270 )
2450 dx = outputPixelDist * cos(( 90 - lineAngle ) *
M_PI / 180.0 );
2451 dy = outputPixelDist * sin(( 90 - lineAngle ) *
M_PI / 180.0 );
2452 p1 = QPointF( width, 0 );
2453 p2 = QPointF( 0, height );
2454 p3 = QPointF( width - dx, -dy );
2455 p4 = QPointF( -dx, height - dy );
2456 p5 = QPointF( width + dx, dy );
2457 p6 = QPointF( dx, height + dy );
2459 else if ( lineAngle > 90 && lineAngle < 180 )
2461 dy = outputPixelDist * cos(( 180 - lineAngle ) *
M_PI / 180 );
2462 dx = outputPixelDist * sin(( 180 - lineAngle ) *
M_PI / 180 );
2463 p1 = QPointF( 0, 0 );
2464 p2 = QPointF( width, height );
2465 p5 = QPointF( dx, -dy );
2466 p6 = QPointF( width + dx, height - dy );
2467 p3 = QPointF( -dx, dy );
2468 p4 = QPointF( width - dx, height + dy );
2470 else if ( lineAngle > 270 && lineAngle < 360 )
2472 dy = outputPixelDist * cos(( 180 - lineAngle ) *
M_PI / 180 );
2473 dx = outputPixelDist * sin(( 180 - lineAngle ) *
M_PI / 180 );
2474 p1 = QPointF( width, height );
2475 p2 = QPointF( 0, 0 );
2476 p5 = QPointF( width + dx, height - dy );
2477 p6 = QPointF( dx, -dy );
2478 p3 = QPointF( width - dx, height + dy );
2479 p4 = QPointF( -dx, dy );
2486 p3 = QPointF( tempPt.x(), tempPt.y() );
2488 p4 = QPointF( tempPt.x(), tempPt.y() );
2490 p5 = QPointF( tempPt.x(), tempPt.y() );
2492 p6 = QPointF( tempPt.x(), tempPt.y() );
2496 p1 = QPointF( tempPt.x(), tempPt.y() );
2498 p2 = QPointF( tempPt.x(), tempPt.y() );;
2501 QPainter p( &patternImage );
2505 p.setRenderHint( QPainter::Antialiasing,
false );
2506 QPen pen( QColor( Qt::black ) );
2507 pen.setWidthF( 0.1 );
2508 pen.setCapStyle( Qt::FlatCap );
2513 QPolygon polygon = QPolygon() << QPoint( 0, 0 ) << QPoint( width - 1, 0 ) << QPoint( width - 1, height - 1 ) << QPoint( 0, height - 1 ) << QPoint( 0, 0 ) ;
2514 p.drawPolygon( polygon );
2516 polygon = QPolygon() << QPoint( xBuffer, yBuffer ) << QPoint( width - xBuffer - 1, yBuffer ) << QPoint( width - xBuffer - 1, height - yBuffer - 1 ) << QPoint( xBuffer, height - yBuffer - 1 ) << QPoint( xBuffer, yBuffer ) ;
2517 p.drawPolygon( polygon );
2523 p.setRenderHint( QPainter::Antialiasing,
true );
2536 QVector<QPolygonF> polygons;
2537 polygons.append( QPolygonF() << p1 << p2 );
2538 polygons.append( QPolygonF() << p3 << p4 );
2541 polygons.append( QPolygonF() << p5 << p6 );
2544 foreach ( QPolygonF polygon, polygons )
2549 fillLineSymbol->
stopRender( lineRenderContext );
2553 patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
2558 QImage transparentImage = patternImage.copy();
2560 brush.setTextureImage( transparentImage );
2564 brush.setTextureImage( patternImage );
2567 QTransform brushTransform;
2569 brush.setTransform( brushTransform );
2571 delete fillLineSymbol;
2593 map.insert(
"lineangle", QString::number(
mLineAngle ) );
2594 map.insert(
"distance", QString::number(
mDistance ) );
2595 map.insert(
"linewidth", QString::number(
mLineWidth ) );
2597 map.insert(
"offset", QString::number(
mOffset ) );
2622 QDomElement symbolizerElem = doc.createElement(
"se:PolygonSymbolizer" );
2623 if ( !props.value(
"uom",
"" ).isEmpty() )
2624 symbolizerElem.setAttribute(
"uom", props.value(
"uom",
"" ) );
2625 element.appendChild( symbolizerElem );
2630 QDomElement fillElem = doc.createElement(
"se:Fill" );
2631 symbolizerElem.appendChild( fillElem );
2633 QDomElement graphicFillElem = doc.createElement(
"se:GraphicFill" );
2634 fillElem.appendChild( graphicFillElem );
2636 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
2637 graphicFillElem.appendChild( graphicElem );
2647 double angle = props.value(
"angle",
"0" ).toDouble( &ok );
2650 angleFunc = QString(
"%1 + %2" ).arg( props.value(
"angle",
"0" ) ).arg(
mLineAngle );
2654 angleFunc = QString::number( angle +
mLineAngle );
2665 QString featureStyle;
2666 featureStyle.append(
"Brush(" );
2667 featureStyle.append( QString(
"fc:%1" ).arg(
mColor.name() ) );
2668 featureStyle.append( QString(
",bc:%1" ).arg(
"#00000000" ) );
2669 featureStyle.append(
",id:\"ogr-brush-2\"" );
2670 featureStyle.append( QString(
",a:%1" ).arg(
mLineAngle ) );
2671 featureStyle.append( QString(
",s:%1" ).arg(
mLineWidth * widthScaleFactor ) );
2672 featureStyle.append(
",dx:0mm" );
2673 featureStyle.append( QString(
",dy:%1mm" ).arg(
mDistance * widthScaleFactor ) );
2674 featureStyle.append(
")" );
2675 return featureStyle;
2684 if ( !lineAngleExpression && !distanceExpression && !lineWidthExpression && !colorExpression )
2690 if ( lineAngleExpression )
2692 lineAngle = lineAngleExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
2695 if ( distanceExpression )
2697 distance = distanceExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
2700 if ( lineWidthExpression )
2702 lineWidth = lineWidthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
2705 if ( colorExpression )
2719 Qt::PenStyle lineStyle;
2721 QDomElement fillElem = element.firstChildElement(
"Fill" );
2722 if ( fillElem.isNull() )
2725 QDomElement graphicFillElem = fillElem.firstChildElement(
"GraphicFill" );
2726 if ( graphicFillElem.isNull() )
2729 QDomElement graphicElem = graphicFillElem.firstChildElement(
"Graphic" );
2730 if ( graphicElem.isNull() )
2736 if ( name !=
"horline" )
2744 double d = angleFunc.toDouble( &ok );
2753 offset = sqrt( pow( vectOffset.x(), 2 ) + pow( vectOffset.y(), 2 ) );
2764 QDomElement strokeElem = element.firstChildElement(
"Stroke" );
2765 if ( !strokeElem.isNull() )
2784 mDisplacementY( 0 ), mDisplacementYUnit(
QgsSymbolV2::MM )
2841 if ( properties.contains(
"distance_x" ) )
2843 layer->
setDistanceX( properties[
"distance_x"].toDouble() );
2845 if ( properties.contains(
"distance_y" ) )
2847 layer->
setDistanceY( properties[
"distance_y"].toDouble() );
2849 if ( properties.contains(
"displacement_x" ) )
2853 if ( properties.contains(
"displacement_y" ) )
2858 if ( properties.contains(
"distance_x_unit" ) )
2862 if ( properties.contains(
"distance_x_map_unit_scale" ) )
2866 if ( properties.contains(
"distance_y_unit" ) )
2870 if ( properties.contains(
"distance_y_map_unit_scale" ) )
2874 if ( properties.contains(
"displacement_x_unit" ) )
2878 if ( properties.contains(
"displacement_x_map_unit_scale" ) )
2882 if ( properties.contains(
"displacement_y_unit" ) )
2886 if ( properties.contains(
"displacement_y_map_unit_scale" ) )
2890 if ( properties.contains(
"outline_width_unit" ) )
2894 if ( properties.contains(
"outline_width_map_unit_scale" ) )
2900 if ( properties.contains(
"distance_x_expression" ) )
2904 if ( properties.contains(
"distance_y_expression" ) )
2908 if ( properties.contains(
"displacement_x_expression" ) )
2912 if ( properties.contains(
"displacement_y_expression" ) )
2921 return "PointPatternFill";
2925 double displacementX,
double displacementY )
2932 if ( width > 10000 || height > 10000 )
2935 brush.setTextureImage( img );
2939 QImage patternImage( width, height, QImage::Format_ARGB32 );
2940 patternImage.fill( 0 );
2944 QPainter p( &patternImage );
2978 QImage transparentImage = patternImage.copy();
2980 brush.setTextureImage( transparentImage );
2984 brush.setTextureImage( patternImage );
2986 QTransform brushTransform;
2988 brush.setTransform( brushTransform );
3013 map.insert(
"distance_x", QString::number(
mDistanceX ) );
3014 map.insert(
"distance_y", QString::number(
mDistanceY ) );
3015 map.insert(
"displacement_x", QString::number(
mDisplacementX ) );
3016 map.insert(
"displacement_y", QString::number(
mDisplacementY ) );
3045 QDomElement symbolizerElem = doc.createElement(
"se:PolygonSymbolizer" );
3046 if ( !props.value(
"uom",
"" ).isEmpty() )
3047 symbolizerElem.setAttribute(
"uom", props.value(
"uom",
"" ) );
3048 element.appendChild( symbolizerElem );
3053 QDomElement fillElem = doc.createElement(
"se:Fill" );
3054 symbolizerElem.appendChild( fillElem );
3056 QDomElement graphicFillElem = doc.createElement(
"se:GraphicFill" );
3057 fillElem.appendChild( graphicFillElem );
3062 symbolizerElem.appendChild( distanceElem );
3068 QString errorMsg = QString(
"MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->
layerType() );
3069 graphicFillElem.appendChild( doc.createComment( errorMsg ) );
3080 Q_UNUSED( element );
3109 if ( !distanceXExpression && !distanceYExpression && !displacementXExpression && !displacementYExpression )
3116 if ( distanceXExpression )
3118 distanceX = distanceXExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
3121 if ( distanceYExpression )
3123 distanceY = distanceYExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
3126 if ( displacementXExpression )
3128 displacementX = displacementXExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
3131 if ( displacementYExpression )
3133 displacementY = displacementYExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
3170 if ( properties.contains(
"point_on_surface" ) )
3178 return "CentroidFill";
3270 QSet<QString> attributes;
virtual QSet< QString > usedAttributes() const
QgsMapUnitScale mSvgOutlineWidthMapUnitScale
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
void setBorderWidthMapUnitScale(const QgsMapUnitScale &scale)
Class for parsing and evaluation of expressions (formerly called "search strings").
ShapeburstColorType mColorType
static Qt::BrushStyle decodeBrushStyle(QString str)
void setForceVectorOutput(bool force)
Added in QGIS v1.5.
QgsSymbolV2::OutputUnit intervalUnit() const
QgsSymbolV2::OutputUnit patternWidthUnit() const
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
QgsImageFillSymbolLayer()
double borderWidth() const
const QgsMapUnitScale & patternWidthMapUnitScale() const
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
void setDistance(double d)
double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
QgsSymbolV2::OutputUnit mSvgOutlineWidthUnit
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
void setSvgOutlineWidth(double w)
static void multiplyImageOpacity(QImage *image, qreal alpha)
Multiplies opacity of image pixel values with a (global) transparency value.
QgsStringMap properties() const
void stopRender(QgsSymbolV2RenderContext &context)
void startRender(QgsSymbolV2RenderContext &context)
void setAngle(double angle)
Rotation angle for gradient fill.
QgsStringMap properties() const
QString ogrFeatureStyleWidth(double widthScaleFactor) const
void applyDataDefinedSettings(const QgsSymbolV2RenderContext &context)
double ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
void setMapUnitScale(const QgsMapUnitScale &scale)
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit mLineWidthUnit
virtual QString type() const =0
static Q_DECL_DEPRECATED bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &borderColor, double &borderWidth, double &size)
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
virtual Qt::PenStyle dxfPenStyle() const
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
QgsMapUnitScale mLineWidthMapUnitScale
void setSvgFillColor(const QColor &c)
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
bool mReferencePoint1IsCentroid
QgsSymbolV2::OutputUnit outputUnit() const
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setDistanceYUnit(QgsSymbolV2::OutputUnit unit)
QString svgFilePath() const
virtual void applyDataDefinedSettings(const QgsSymbolV2RenderContext &context)
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
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&.
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
QColor selectionColor() const
Added in QGIS v2.0.
QSet< QString > usedAttributes() const
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
QPointF referencePoint2() const
virtual QSet< QString > usedAttributes() const
QgsStringMap properties() const
double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const
QgsLinePatternFillSymbolLayer()
double displacementX() const
bool setSubSymbol(QgsSymbolV2 *symbol)
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
Base class for polygon renderers generating texture images.
QgsMapUnitScale mOffsetMapUnitScale
QgsSymbolV2 * subSymbol()
QgsMapUnitScale mPatternWidthMapUnitScale
GradientCoordinateMode mCoordinateMode
static void createRotationElement(QDomDocument &doc, QDomElement &element, QString rotationFunc)
double rendererScale() const
void setPointOnSurface(bool pointOnSurface)
QgsSymbolV2::OutputUnit outputUnit() const
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const
double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setRendererScale(double scale)
QString layerType() const
void setMapUnitScale(const QgsMapUnitScale &scale)
static QString ogrFeatureStyleBrush(const QColor &fillColr)
Create ogr feature style string for brush.
void applyDataDefinedSymbology(QgsSymbolV2RenderContext &context, QColor &color, QColor &color2, int &blurRadius, bool &useWholeShape, double &maxDistance, bool &ignoreRings)
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
static void fillToSld(QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, QColor color=QColor())
QgsSymbolLayerV2 * clone() const
QgsSymbolV2::OutputUnit outputUnit() const
const QgsMapUnitScale & intervalMapUnitScale() const
void distanceTransform1d(double *f, int n, int *v, double *z, double *d)
QgsMapUnitScale mapUnitScale() const
QgsMapUnitScale mOutlineWidthMapUnitScale
static QPointF decodePoint(QString str)
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
QgsSymbolV2::OutputUnit outputUnit() const
virtual QgsStringMap properties() const =0
static QDomElement createVendorOptionElement(QDomDocument &doc, QString name, QString value)
GradientType mGradientType
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient.
static QColor decodeColor(QString str)
QgsSymbolV2::OutputUnit mDisplacementXUnit
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
static const bool selectionIsOpaque
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
double useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
double scaleFactor() const
void stopRender(QgsSymbolV2RenderContext &context)
virtual QColor dxfColor(const QgsSymbolV2RenderContext &context) const
QgsMapUnitScale mapUnitScale() const
double mDistance
Distance (in mm or map units) between lines.
QColor fillColor() const
Get fill color.
QgsSymbolLayerV2 * clone() const
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setSvgOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsStringMap properties() const
QgsMapUnitScale mOffsetMapUnitScale
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
double mLineAngle
Vector line angle in degrees (0 = horizontal, counterclockwise)
GradientSpread mGradientSpread
virtual QColor fillColor() const
Get fill color.
QgsMapUnitScale mDistanceYMapUnitScale
void applyDataDefinedSymbology(QgsSymbolV2RenderContext &context, const QPolygonF &points)
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
QgsVectorColorRampV2 * mGradientRamp
QMap< QString, QString > QgsStringMap
void startRender(QgsSymbolV2RenderContext &context)
QgsSymbolLayerV2 * clone() const
void setColorRamp(QgsVectorColorRampV2 *ramp)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
QgsSymbolV2::OutputUnit outputUnit() const
static double pixelSizeScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns scale factor painter units -> pixel dimensions.
void setWidth(double width)
void setMapUnitScale(const QgsMapUnitScale &scale)
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setSvgOutlineColor(const QColor &c)
static QString encodeColor(QColor color)
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setInterval(double interval)
void applyPattern(const QgsSymbolV2RenderContext &context, QBrush &brush, double lineAngle, double distance, double lineWidth, const QColor &color)
Applies the svg pattern to the brush.
QgsSymbolV2::OutputUnit outputUnit() const
void setColor(const QColor &c)
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
virtual QgsExpression * expression(const QString &property) const
QgsMapUnitScale mDisplacementYMapUnitScale
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 bool displacementFromSldElement(QDomElement &element, QPointF &offset)
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
static QgsSvgCache * instance()
static QString encodePenStyle(Qt::PenStyle style)
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
bool setSubSymbol(QgsSymbolV2 *symbol)
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.
QgsSymbolV2::OutputUnit mDisplacementYUnit
Perform transforms between map coordinates and device coordinates.
QString layerType() const
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
void setColor(const QColor &color)
static QString symbolPathToName(QString path)
Get symbols's name from its path.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
void setLineAngle(double a)
void setMapUnitScale(const QgsMapUnitScale &scale)
static QgsSymbolLayerV2 * createMarkerLayerFromSld(QDomElement &element)
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
QgsStringMap properties() const
double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
bool mReferencePoint2IsCentroid
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
QByteArray mSvgData
SVG data.
Qt::PenStyle borderStyle() const
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsLineSymbolV2 * mOutline
Custom outline.
#define DEFAULT_SIMPLEFILL_STYLE
virtual ~QgsImageFillSymbolLayer()
QgsMapUnitScale mDistanceXMapUnitScale
static QString ogrFeatureStylePen(double width, double mmScaleFactor, double mapUnitsScaleFactor, const QColor &c, Qt::PenJoinStyle joinStyle=Qt::MiterJoin, Qt::PenCapStyle capStyle=Qt::FlatCap, double offset=0.0, const QVector< qreal > *dashPattern=0)
Create ogr feature style string for pen.
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
void setScaleFactor(double factor)
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
const QgsFeature * feature() const
Current feature being rendered - may be null.
QgsSymbolLayerV2 * clone() const
double mOffset
Offset perpendicular to line direction.
QgsMapUnitScale mDistanceMapUnitScale
static QString encodePoint(QPointF point)
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
QByteArray getImageData(const QString &path) const
Get image data.
QColor dxfColor(const QgsSymbolV2RenderContext &context) const
void startRender(QgsRenderContext &context, const QgsFields *fields=0)
double * distanceTransform(QImage *im)
QgsStringMap properties() const
static Qt::PenStyle decodePenStyle(QString str)
QgsVectorColorRampV2 * mTwoColorGradientRamp
void setLineWidthUnit(QgsSymbolV2::OutputUnit unit)
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
virtual QgsVectorColorRampV2 * clone() const =0
~QgsCentroidFillSymbolLayerV2()
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void applyPattern(QBrush &brush, const QString &svgFilePath, double patternWidth, QgsSymbolV2::OutputUnit patternWidthUnit, const QColor &svgFillColor, const QColor &svgOutlineColor, double svgOutlineWidth, QgsSymbolV2::OutputUnit svgOutlineWidthUnit, const QgsSymbolV2RenderContext &context, const QgsMapUnitScale &patternWidthMapUnitScale, const QgsMapUnitScale &svgOutlineWidthMapUnitScale)
Applies the svg pattern to the brush.
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
QgsMarkerSymbolV2 * mMarker
virtual QSet< QString > usedAttributes() const
QPointF offset() const
Returns the offset for the shapeburst fill.
void renderPolyline(const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mapUnitScale() const
void applyGradient(const QgsSymbolV2RenderContext &context, QBrush &brush, const QColor &color, const QColor &color2, const GradientColorType &gradientColorType, QgsVectorColorRampV2 *gradientRamp, const GradientType &gradientType, const GradientCoordinateMode &coordinateMode, const GradientSpread &gradientSpread, const QPointF &referencePoint1, const QPointF &referencePoint2, const double angle)
Applies the gradient to a brush.
void setMapUnitScale(const QgsMapUnitScale &scale)
void dtArrayToQImage(double *array, QImage *im, QgsVectorColorRampV2 *ramp, double layerAlpha=1, bool useWholeShape=true, int maxPixelDistance=0)
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
QgsMapUnitScale mapUnitScale() const
void setMapUnitScale(const QgsMapUnitScale &scale)
QgsSVGFillSymbolLayer(const QString &svgFilePath="", double width=20, double rotation=0.0)
~QgsLinePatternFillSymbolLayer()
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenStyle mBorderStyle
void stopRender(QgsSymbolV2RenderContext &context)
QColor svgFillColor() const
QgsMapUnitScale mOffsetMapUnitScale
QgsSymbolV2::OutputUnit mOffsetUnit
QgsCentroidFillSymbolLayerV2()
void setPainter(QPainter *p)
double rasterScaleFactor() const
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
static const bool selectFillStyle
double mapUnitsPerPixel() const
Return current map units per pixel.
virtual QColor color() const
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mapUnitScale() const
void setDisplacementXUnit(QgsSymbolV2::OutputUnit unit)
QgsMapUnitScale mOffsetMapUnitScale
QgsSymbolV2::OutputUnit mOffsetUnit
void renderPoint(const QPointF &point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
virtual void prepareExpressions(const QgsFields *fields, double scale=-1.0)
QgsSymbolLayerV2 * clone() const
void setMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mDisplacementXMapUnitScale
void setBorderWidthUnit(QgsSymbolV2::OutputUnit unit)
void startRender(QgsSymbolV2RenderContext &context)
void setLineWidthMapUnitScale(const QgsMapUnitScale &scale)
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit mOffsetUnit
QPointF referencePoint1() const
QString mSvgFilePath
Path to the svg file (or empty if constructed directly from data)
QgsSymbolV2::SymbolType type() const
virtual QColor color(double value) const =0
QgsSymbolV2::OutputUnit mOffsetUnit
QgsSymbolV2::OutputUnit mOutlineWidthUnit
double mOutlineWidth
Outline width.
QString layerType() const
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 setDistanceXUnit(QgsSymbolV2::OutputUnit unit)
double mLineWidth
Line width (in mm or map units)
QgsVectorColorRampV2 * mGradientRamp
QColor svgOutlineColor() const
void startRender(QgsSymbolV2RenderContext &context)
GradientSpread gradientSpread() const
Gradient spread mode.
static QgsSymbolLayerV2 * createLineLayerFromSld(QDomElement &element)
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
void setOffset(QPointF offset)
Offset for gradient fill.
virtual QString layerType() const =0
void stopRender(QgsSymbolV2RenderContext &context)
virtual ~QgsShapeburstFillSymbolLayerV2()
void setDisplacementY(double d)
double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Sets the units used for the offset for the shapeburst fill.
QgsSymbolV2::OutputUnit mDistanceYUnit
virtual QgsSymbolV2 * clone() const
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
void setOffset(QPointF offset)
void setLineWidth(double w)
Qt::PenJoinStyle mPenJoinStyle
void applyPattern(const QgsSymbolV2RenderContext &context, QBrush &brush, double distanceX, double distanceY, double displacementX, double displacementY)
A class for svg fill patterns.
void stopRender(QgsSymbolV2RenderContext &context)
bool setSubSymbol(QgsSymbolV2 *symbol)
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, QColor color, double width=-1, const Qt::PenJoinStyle *penJoinStyle=0, const Qt::PenCapStyle *penCapStyle=0, const QVector< qreal > *customDashPattern=0, double dashOffset=0.0)
static void createGeometryElement(QDomDocument &doc, QDomElement &element, QString geomFunc)
void setDefaultSvgParams()
Contains information about the context of a rendering operation.
Qt::BrushStyle mBrushStyle
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
QPointF rotateReferencePoint(const QPointF &refPoint, double angle)
rotates a reference point by a specified angle around the point (0.5, 0.5)
void stopRender(QgsRenderContext &context)
void setColor(const QColor &color)
void storeViewBox()
Helper function that gets the view box from the byte array.
QgsMapUnitScale mBorderWidthMapUnitScale
static QString encodeBrushStyle(Qt::BrushStyle style)
QgsMapUnitScale mapUnitScale() const
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.
GradientColorType mGradientColorType
QgsPointPatternFillSymbolLayer()
void startRender(QgsSymbolV2RenderContext &context)
QgsSymbolV2 * subSymbol()
QgsSymbolV2::OutputUnit mDistanceXUnit
QgsMapUnitScale mapUnitScale() const
QgsMapUnitScale mDistanceMapUnitScale
QgsStringMap properties() const
QgsGradientFillSymbolLayerV2(QColor color=DEFAULT_SIMPLEFILL_COLOR, QColor color2=Qt::white, GradientColorType gradientColorType=SimpleTwoColor, GradientType gradientType=Linear, GradientCoordinateMode coordinateMode=Feature, GradientSpread gradientSpread=Pad)
void setDisplacementYUnit(QgsSymbolV2::OutputUnit unit)
virtual QgsSymbolV2 * clone() const
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
QList< QgsSymbolLayerV2 * > QgsSymbolLayerV2List
void setSvgFilePath(const QString &svgPath)
QgsRenderContext & renderContext()
QgsSymbolV2::OutputUnit mBorderWidthUnit
Qt::PenJoinStyle penJoinStyle() const
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void applyDataDefinedSettings(const QgsSymbolV2RenderContext &context)
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
virtual ~QgsGradientFillSymbolLayerV2()
void setColorRamp(QgsVectorColorRampV2 *ramp)
Sets the color ramp used to draw the shapeburst fill.
void setMapToPixel(const QgsMapToPixel &mtp)
QgsSymbolV2::OutputUnit outputUnit() const
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, QString path, QString mime, QColor color, double size=-1)
QgsSymbolV2::OutputUnit mDistanceUnit
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
QString layerType() const
void setDistanceY(double d)
QgsMarkerSymbolV2 * mMarkerSymbol
QgsMapUnitScale mapUnitScale() const
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
static Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, QString name, QColor color, QColor borderColor=QColor(), double borderWidth=-1, double size=-1)
const QgsMapToPixel & mapToPixel() const
void startRender(QgsSymbolV2RenderContext &context)
void distanceTransform2d(double *im, int width, int height)
const QgsFields * fields() const
Fields of the layer.
QgsSimpleFillSymbolLayerV2(QColor color=DEFAULT_SIMPLEFILL_COLOR, Qt::BrushStyle style=DEFAULT_SIMPLEFILL_STYLE, QColor borderColor=DEFAULT_SIMPLEFILL_BORDERCOLOR, Qt::PenStyle borderStyle=DEFAULT_SIMPLEFILL_BORDERSTYLE, double borderWidth=DEFAULT_SIMPLEFILL_BORDERWIDTH, Qt::PenJoinStyle penJoinStyle=DEFAULT_SIMPLEFILL_JOINSTYLE)
static Qt::PenJoinStyle decodePenJoinStyle(QString str)
QgsMapUnitScale mapUnitScale() const
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
GradientType gradientType() const
Type of gradient, eg linear or radial.
QColor borderColor() const
QgsShapeburstFillSymbolLayerV2(QColor color=DEFAULT_SIMPLEFILL_COLOR, QColor color2=Qt::white, ShapeburstColorType colorType=SimpleTwoColor, int blurRadius=0, bool useWholeShape=true, double maxDistance=5)
void setDistanceX(double d)
static QPointF polygonCentroid(const QPolygonF &points)
Calculate the centroid point of a QPolygonF.
void stopRender(QgsSymbolV2RenderContext &context)
void setRasterScaleFactor(double factor)
QgsSymbolV2::OutputUnit mDistanceUnit
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsLineSymbolV2 * mFillLineSymbol
Fill line.
~QgsPointPatternFillSymbolLayer()
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void applyDataDefinedSettings(const QgsSymbolV2RenderContext &context)
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QgsSymbolLayerV2 * symbolLayer(int layer)
void setMapUnitScale(const QgsMapUnitScale &scale)
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
virtual double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const
void setOffset(double offset)
void setPatternWidthUnit(QgsSymbolV2::OutputUnit unit)
void stopRender(QgsSymbolV2RenderContext &context)
static bool lineFromSld(QDomElement &element, Qt::PenStyle &penStyle, QColor &color, double &width, Qt::PenJoinStyle *penJoinStyle=0, Qt::PenCapStyle *penCapStyle=0, QVector< qreal > *customDashPattern=0, double *dashOffset=0)
QgsSymbolV2::OutputUnit mPatternWidthUnit
static QPointF polygonPointOnSurface(const QPolygonF &points)
Calculate a point within of a QPolygonF.
QgsSymbolLayerV2 * clone() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QString layerType() const
void _renderPolygon(QPainter *p, const QPolygonF &points, const QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
Default method to render polygon.
void addStopsToGradient(QGradient *gradient, double alpha=1)
copy color ramp stops to a QGradient
static const bool selectFillBorder
QString layerType() const
QgsSymbolV2::OutputUnit outputUnit() const
static QPointF pointOnLineWithDistance(const QPointF &startPoint, const QPointF &directionPoint, double distance)
Returns a point on the line from startPoint to directionPoint that is a certain distance away from th...
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
QgsSymbolV2::OutputUnit outputUnit() const
QgsSymbolLayerV2 * clone() const
const QgsMapUnitScale & svgOutlineWidthMapUnitScale() const
#define DEFAULT_SIMPLEFILL_JOINSTYLE
void setDisplacementX(double d)
void saveDataDefinedProperties(QgsStringMap &stringMap) const
Saves data defined properties to string map.
void setOutputUnit(QgsSymbolV2::OutputUnit u)
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
double displacementY() const
static void blurImageInPlace(QImage &image, const QRect &rect, int radius, bool alphaOnly)
Blurs an image in place, e.g.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
static QgsSymbolV2::OutputUnit decodeOutputUnit(QString str)
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
#define DEFAULT_SIMPLEFILL_BORDERWIDTH
void copyDataDefinedProperties(QgsSymbolLayerV2 *destLayer) const
Copies data defined properties of this layer to another symbol layer.
static void premultiplyColor(QColor &rgb, int alpha)
Converts a QColor into a premultiplied ARGB QColor value using a specified alpha value.
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Units for gradient fill offset.
Qt::PenStyle dxfPenStyle() const
QRectF mSvgViewBox
SVG view box (to keep the aspect ratio.
void setIgnoreRings(double ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
QImage * mSvgPattern
SVG pattern image.
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
void setSvgOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
double mPatternWidth
Width of the pattern (in output units)
virtual void setDataDefinedProperty(const QString &property, const QString &expressionString)
QString layerType() const
void applyDataDefinedSymbology(QgsSymbolV2RenderContext &context, QBrush &brush, QPen &pen, QPen &selPen)
#define DEFAULT_SIMPLEFILL_COLOR
void startRender(QgsSymbolV2RenderContext &context)
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const