19 #include "qgsdxfexport.h" 
   29 #include <QSvgRenderer> 
   30 #include <QDomDocument> 
   31 #include <QDomElement> 
   34     : mBrushStyle( style ), mBorderColor( borderColor ), mBorderStyle( borderStyle ), mBorderWidth( borderWidth ), mBorderWidthUnit( 
QgsSymbolV2::MM ),
 
   59   if ( colorExpression )
 
   64   if ( colorBorderExpression )
 
   69   if ( widthBorderExpression )
 
   71     double width = widthBorderExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
   73     pen.setWidthF( width );
 
   74     selPen.setWidthF( width );
 
   88   if ( props.contains( 
"color" ) )
 
   90   if ( props.contains( 
"style" ) )
 
   92   if ( props.contains( 
"color_border" ) )
 
   94   if ( props.contains( 
"style_border" ) )
 
   96   if ( props.contains( 
"width_border" ) )
 
   97     borderWidth = props[
"width_border"].toDouble();
 
   98   if ( props.contains( 
"offset" ) )
 
  103   if ( props.contains( 
"border_width_unit" ) )
 
  105   if ( props.contains( 
"offset_unit" ) )
 
  108   if ( props.contains( 
"color_expression" ) )
 
  112   if ( props.contains( 
"color_border_expression" ) )
 
  116   if ( props.contains( 
"width_border_expression" ) )
 
  132   fillColor.setAlphaF( context.
alpha() * 
mColor.alphaF() );
 
  137   if ( rasterScaleFactor != 1.0 )
 
  139     mBrush.setMatrix( QMatrix().scale( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor ) );
 
  153   mPen = QPen( borderColor );
 
  183     p->translate( offset );
 
  190     p->translate( -offset );
 
  224   QDomElement symbolizerElem = doc.createElement( 
"se:PolygonSymbolizer" );
 
  225   if ( !props.value( 
"uom", 
"" ).isEmpty() )
 
  226     symbolizerElem.setAttribute( 
"uom", props.value( 
"uom", 
"" ) );
 
  227   element.appendChild( symbolizerElem );
 
  235     QDomElement fillElem = doc.createElement( 
"se:Fill" );
 
  236     symbolizerElem.appendChild( fillElem );
 
  243     QDomElement strokeElem = doc.createElement( 
"se:Stroke" );
 
  244     symbolizerElem.appendChild( strokeElem );
 
  257   symbolStyle.append( 
";" );
 
  268   Qt::BrushStyle fillStyle;
 
  272   QDomElement fillElem = element.firstChildElement( 
"Fill" );
 
  275   QDomElement strokeElem = element.firstChildElement( 
"Stroke" );
 
  290   return penBleed + offsetBleed;
 
  297   if ( widthBorderExpression )
 
  299     width = widthBorderExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
  301   return width * e.mapUnitScaleFactor( e.symbologyScaleDenominator(), 
mBorderWidthUnit, e.mapUnits() );
 
  309     if ( colorBorderExpression )
 
  318     if ( colorExpression )
 
  336     : mGradientColorType( colorType ),
 
  337     mGradientRamp( NULL ),
 
  338     mGradientType( gradientType ),
 
  339     mCoordinateMode( coordinateMode ),
 
  340     mGradientSpread( spread ),
 
  341     mReferencePoint1( QPointF( 0.5, 0 ) ),
 
  342     mReferencePoint1IsCentroid( false ),
 
  343     mReferencePoint2( QPointF( 0.5, 1 ) ),
 
  344     mReferencePoint2IsCentroid( false ),
 
  367   bool refPoint1IsCentroid = 
false;
 
  369   bool refPoint2IsCentroid = 
false;
 
  374   if ( props.contains( 
"type" ) )
 
  376   if ( props.contains( 
"coordinate_mode" ) )
 
  378   if ( props.contains( 
"spread" ) )
 
  380   if ( props.contains( 
"color_type" ) )
 
  382   if ( props.contains( 
"gradient_color" ) )
 
  384   if ( props.contains( 
"gradient_color2" ) )
 
  386   if ( props.contains( 
"reference_point1" ) )
 
  388   if ( props.contains( 
"reference_point1_iscentroid" ) )
 
  389     refPoint1IsCentroid = props[
"reference_point1_iscentroid"].toInt();
 
  390   if ( props.contains( 
"reference_point2" ) )
 
  392   if ( props.contains( 
"reference_point2_iscentroid" ) )
 
  393     refPoint2IsCentroid = props[
"reference_point2_iscentroid"].toInt();
 
  394   if ( props.contains( 
"angle" ) )
 
  395     angle = props[
"angle"].toDouble();
 
  396   if ( props.contains( 
"offset" ) )
 
  405   if ( props.contains( 
"offset_unit" ) )
 
  416   if ( props.contains( 
"color_expression" ) )
 
  418   if ( props.contains( 
"color2_expression" ) )
 
  420   if ( props.contains( 
"angle_expression" ) )
 
  422   if ( props.contains( 
"gradient_type_expression" ) )
 
  424   if ( props.contains( 
"coordinate_mode_expression" ) )
 
  426   if ( props.contains( 
"spread_expression" ) )
 
  428   if ( props.contains( 
"reference1_x_expression" ) )
 
  430   if ( props.contains( 
"reference1_y_expression" ) )
 
  432   if ( props.contains( 
"reference1_iscentroid_expression" ) )
 
  434   if ( props.contains( 
"reference2_x_expression" ) )
 
  436   if ( props.contains( 
"reference2_y_expression" ) )
 
  438   if ( props.contains( 
"reference2_iscentroid_expression" ) )
 
  452   return "GradientFill";
 
  460   if ( colorExpression )
 
  466   if ( colorExpression2 )
 
  472   if ( angleExpression )
 
  473     angle = angleExpression->evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
  478   if ( typeExpression )
 
  480     QString currentType = typeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
 
  489     else if ( currentType == 
QObject::tr( 
"conical" ) )
 
  503   if ( coordModeExpression )
 
  505     QString currentCoordMode = coordModeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
 
  506     if ( currentCoordMode == 
QObject::tr( 
"feature" ) )
 
  510     else if ( currentCoordMode == 
QObject::tr( 
"viewport" ) )
 
  524   if ( spreadExpression )
 
  526     QString currentSpread = spreadExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
 
  531     else if ( currentSpread == 
QObject::tr( 
"repeat" ) )
 
  535     else if ( currentSpread == 
QObject::tr( 
"reflect" ) )
 
  549   if ( ref1XExpression )
 
  550     refPoint1X = ref1XExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
  553   if ( ref1YExpression )
 
  554     refPoint1Y = ref1YExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
  557   if ( ref1IsCentroidExpression )
 
  558     refPoint1IsCentroid = ref1IsCentroidExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toBool();
 
  563   if ( ref2XExpression )
 
  564     refPoint2X = ref2XExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
  567   if ( ref2YExpression )
 
  568     refPoint2Y = ref2YExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
  571   if ( ref2IsCentroidExpression )
 
  572     refPoint2IsCentroid = ref2IsCentroidExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toBool();
 
  574   if ( refPoint1IsCentroid || refPoint2IsCentroid )
 
  579     QRectF bbox = points.boundingRect();
 
  580     double centroidX = ( centroid.x() - bbox.left() ) / bbox.width();
 
  581     double centroidY = ( centroid.y() - bbox.top() ) / bbox.height();
 
  583     if ( refPoint1IsCentroid )
 
  585       refPoint1X = centroidX;
 
  586       refPoint1Y = centroidY;
 
  588     if ( refPoint2IsCentroid )
 
  590       refPoint2X = centroidX;
 
  591       refPoint2Y = centroidY;
 
  597                  spread, QPointF( refPoint1X, refPoint1Y ), QPointF( refPoint2X, refPoint2Y ), angle );
 
  605   QLineF refLine = QLineF( QPointF( 0.5, 0.5 ), refPoint );
 
  607   refLine.setAngle( refLine.angle() + 
angle );
 
  609   QPointF rotatedReferencePoint = refLine.p2();
 
  611   if ( rotatedReferencePoint.x() > 1 )
 
  612     rotatedReferencePoint.setX( 1 );
 
  613   if ( rotatedReferencePoint.x() < 0 )
 
  614     rotatedReferencePoint.setX( 0 );
 
  615   if ( rotatedReferencePoint.y() > 1 )
 
  616     rotatedReferencePoint.setY( 1 );
 
  617   if ( rotatedReferencePoint.y() < 0 )
 
  618     rotatedReferencePoint.setY( 0 );
 
  620   return rotatedReferencePoint;
 
  624     const QColor &color, 
const QColor &color2, 
const GradientColorType &gradientColorType,
 
  627     const QPointF &referencePoint1, 
const QPointF &referencePoint2, 
const double angle )
 
  631   fillColor.setAlphaF( context.
alpha() * fillColor.alphaF() );
 
  632   QColor fillColor2 = 
color2;
 
  633   fillColor2.setAlphaF( context.
alpha() * fillColor2.alphaF() );
 
  641   switch ( gradientType )
 
  644       gradient = QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
 
  647       gradient = QRadialGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
 
  650       gradient = QConicalGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).
angle() );
 
  653   switch ( coordinateMode )
 
  656       gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
 
  659       gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
 
  662   switch ( gradientSpread )
 
  665       gradient.setSpread( QGradient::PadSpread );
 
  668       gradient.setSpread( QGradient::ReflectSpread );
 
  671       gradient.setSpread( QGradient::RepeatSpread );
 
  685     gradient.setColorAt( 0.0, fillColor );
 
  686     gradient.setColorAt( 1.0, fillColor2 );
 
  690   brush = QBrush( gradient );
 
  720   p->setPen( QPen( Qt::NoPen ) );
 
  727     p->translate( offset );
 
  734     p->translate( -offset );
 
  751   map[
"angle"] = QString::number( 
mAngle );
 
  806   p->setPen( QPen( Qt::NoPen ) );
 
  813     p->setBrush( QBrush( selColor ) );
 
  823     QTransform t = 
mBrush.transform();
 
  825     QBrush rotatedBrush = 
mBrush;
 
  826     rotatedBrush.setTransform( t );
 
  827     p->setBrush( rotatedBrush );
 
  835       QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
 
  836       for ( ; ringIt != rings->constEnd(); ++ringIt )
 
  877     return subLayerBleed;
 
  886   if ( widthExpression )
 
  888     width = widthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
  890   return width * e.mapUnitScaleFactor( e.symbologyScaleDenominator(), 
mOutlineWidthUnit, e.mapUnits() );
 
  898     return QColor( Qt::black );
 
  905   return Qt::SolidLine;
 
  909     return Qt::SolidLine;
 
  980   if ( properties.contains( 
"width" ) )
 
  982     width = properties[
"width"].toDouble();
 
  984   if ( properties.contains( 
"svgFile" ) )
 
  986     QString svgName = properties[
"svgFile"];
 
  988     svgFilePath = ( savePath.isEmpty() ? svgName : savePath );
 
  990   if ( properties.contains( 
"angle" ) )
 
  992     angle = properties[
"angle"].toDouble();
 
  996   if ( !svgFilePath.isEmpty() )
 
 1002     if ( properties.contains( 
"data" ) )
 
 1004       data = QByteArray::fromHex( properties[
"data"].toLocal8Bit() );
 
 1010   if ( properties.contains( 
"svgFillColor" ) )
 
 1014   if ( properties.contains( 
"svgOutlineColor" ) )
 
 1018   if ( properties.contains( 
"svgOutlineWidth" ) )
 
 1024   if ( properties.contains( 
"pattern_width_unit" ) )
 
 1028   if ( properties.contains( 
"svg_outline_width_unit" ) )
 
 1032   if ( properties.contains( 
"outline_width_unit" ) )
 
 1037   if ( properties.contains( 
"width_expression" ) )
 
 1039   if ( properties.contains( 
"svgFile_expression" ) )
 
 1041   if ( properties.contains( 
"angle_expression" ) )
 
 1043   if ( properties.contains( 
"svgFillColor_expression" ) )
 
 1045   if ( properties.contains( 
"svgOutlineColor_expression" ) )
 
 1047   if ( properties.contains( 
"svgOutlineWidth" ) )
 
 1059     const QColor& svgFillColor, 
const QColor& svgOutlineColor, 
double svgOutlineWidth,
 
 1071   if (( 
int )size < 1.0 || 10000.0 < 
size )
 
 1078     bool fitsInCache = 
true;
 
 1086       double hwRatio = 1.0;
 
 1087       if ( patternPict.width() > 0 )
 
 1089         hwRatio = ( double )patternPict.height() / ( double )patternPict.width();
 
 1091       mSvgPattern = 
new QImage(( 
int )size, ( 
int )( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
 
 1095       p.drawPicture( QPointF( size / 2, size * hwRatio / 2 ), patternPict );
 
 1098     QTransform brushTransform;
 
 1102       QImage transparentImage = fitsInCache ? patternImage.copy() : 
mSvgPattern->copy();
 
 1104       brush.setTextureImage( transparentImage );
 
 1108       brush.setTextureImage( fitsInCache ? patternImage : *
mSvgPattern );
 
 1110     brush.setTransform( brushTransform );
 
 1144     map.insert( 
"data", QString( 
mSvgData.toHex() ) );
 
 1148   map.insert( 
"angle", QString::number( 
mAngle ) );
 
 1193   QDomElement symbolizerElem = doc.createElement( 
"se:PolygonSymbolizer" );
 
 1194   if ( !props.value( 
"uom", 
"" ).isEmpty() )
 
 1195     symbolizerElem.setAttribute( 
"uom", props.value( 
"uom", 
"" ) );
 
 1196   element.appendChild( symbolizerElem );
 
 1200   QDomElement fillElem = doc.createElement( 
"se:Fill" );
 
 1201   symbolizerElem.appendChild( fillElem );
 
 1203   QDomElement graphicFillElem = doc.createElement( 
"se:GraphicFill" );
 
 1204   fillElem.appendChild( graphicFillElem );
 
 1206   QDomElement graphicElem = doc.createElement( 
"se:Graphic" );
 
 1207   graphicFillElem.appendChild( graphicElem );
 
 1217     symbolizerElem.appendChild( doc.createComment( 
"SVG from data not implemented yet" ) );
 
 1228   double angle = props.value( 
"angle", 
"0" ).toDouble( &ok );
 
 1231     angleFunc = QString( 
"%1 + %2" ).arg( props.value( 
"angle", 
"0" ) ).arg( 
mAngle );
 
 1233   else if ( angle + 
mAngle != 0 )
 
 1235     angleFunc = QString::number( angle + 
mAngle );
 
 1252   QString path, mimeType;
 
 1254   Qt::PenStyle penStyle;
 
 1255   double size, borderWidth;
 
 1257   QDomElement fillElem = element.firstChildElement( 
"Fill" );
 
 1258   if ( fillElem.isNull() )
 
 1261   QDomElement graphicFillElem = fillElem.firstChildElement( 
"GraphicFill" );
 
 1262   if ( graphicFillElem.isNull() )
 
 1265   QDomElement graphicElem = graphicFillElem.firstChildElement( 
"Graphic" );
 
 1266   if ( graphicElem.isNull() )
 
 1272   if ( mimeType != 
"image/svg+xml" )
 
 1282     double d = angleFunc.toDouble( &ok );
 
 1293   QDomElement strokeElem = element.firstChildElement( 
"Stroke" );
 
 1294   if ( !strokeElem.isNull() )
 
 1316   if ( !widthExpression && !svgFileExpression && !fillColorExpression && !outlineColorExpression && !outlineWidthExpression && !angleExpression )
 
 1321   if ( angleExpression )
 
 1327   if ( widthExpression )
 
 1329     width = widthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 1332   if ( svgFileExpression )
 
 1334     svgFile = svgFileExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
 
 1337   if ( fillColorExpression )
 
 1342   if ( outlineColorExpression )
 
 1347   if ( outlineWidthExpression )
 
 1349     outlineWidth = outlineWidthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 1384   bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
 
 1385   QColor defaultFillColor, defaultOutlineColor;
 
 1386   double defaultOutlineWidth;
 
 1388       defaultOutlineWidth );
 
 1394   if ( hasOutlineParam )
 
 1398   if ( hasOutlineWidthParam )
 
 1406     mOffsetUnit( 
QgsSymbolV2::MM ), mFillLineSymbol( 0 )
 
 1486   QColor 
color( Qt::black );
 
 1489   if ( properties.contains( 
"lineangle" ) )
 
 1491     lineAngle = properties[
"lineangle"].toDouble();
 
 1495   if ( properties.contains( 
"distance" ) )
 
 1497     distance = properties[
"distance"].toDouble();
 
 1501   if ( properties.contains( 
"linewidth" ) )
 
 1503     lineWidth = properties[
"linewidth"].toDouble();
 
 1507   if ( properties.contains( 
"color" ) )
 
 1513   if ( properties.contains( 
"offset" ) )
 
 1515     offset = properties[
"offset"].toDouble();
 
 1520   if ( properties.contains( 
"distance_unit" ) )
 
 1524   if ( properties.contains( 
"line_width_unit" ) )
 
 1528   if ( properties.contains( 
"offset_unit" ) )
 
 1534   if ( properties.contains( 
"lineangle_expression" ) )
 
 1538   if ( properties.contains( 
"distance_expression" ) )
 
 1542   if ( properties.contains( 
"linewidth_expression" ) )
 
 1546   if ( properties.contains( 
"color_expression" ) )
 
 1550   return patternLayer;
 
 1555   return "LinePatternFill";
 
 1559     double lineWidth, 
const QColor& color )
 
 1561   Q_UNUSED( lineWidth );
 
 1564   mBrush.setTextureImage( QImage() ); 
 
 1572   if ( !fillLineSymbol )
 
 1580   double outputPixelOffset = 
mOffset * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( ctx,  
mOffsetUnit );
 
 1584   double outputPixelBleed = 0;
 
 1585   double outputPixelInterval = 0; 
 
 1596     double outputPixelLayerBleed = layerBleed * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( ctx, 
QgsSymbolV2::MM );
 
 1597     outputPixelBleed = qMax( outputPixelBleed, outputPixelLayerBleed );
 
 1600     if ( markerLineLayer )
 
 1602       double outputPixelLayerInterval = markerLineLayer->
interval() * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( ctx, markerLineLayer->
intervalUnit() );
 
 1609       outputPixelInterval = qMax( outputPixelInterval, outputPixelLayerInterval );
 
 1613   if ( outputPixelInterval > 0 )
 
 1617     double intervalScale = qRound( outputPixelInterval ) / outputPixelInterval;
 
 1618     outputPixelInterval = qRound( outputPixelInterval );
 
 1625       if ( markerLineLayer )
 
 1636     height = outputPixelDist;
 
 1637     width = outputPixelInterval > 0 ? outputPixelInterval : height;
 
 1641     width = outputPixelDist;
 
 1642     height = outputPixelInterval > 0 ? outputPixelInterval : width;
 
 1646     height = qAbs( outputPixelDist / cos( lineAngle * 
M_PI / 180 ) ); 
 
 1647     width = qAbs( height / tan( lineAngle * 
M_PI / 180 ) );
 
 1650     lineAngle = 180 * qAbs( atan2(( 
double ) height, ( 
double ) width ) ) / 
M_PI;
 
 1651     outputPixelDist = height * cos( lineAngle * 
M_PI / 180 );
 
 1655     int offsetHeight = qRound( qAbs( outputPixelOffset / cos( lineAngle * 
M_PI / 180 ) ) );
 
 1656     outputPixelOffset = offsetHeight * cos( lineAngle * 
M_PI / 180 );
 
 1665   int bufferMulti = qMax( qCeil( outputPixelBleed / width ), qCeil( outputPixelBleed / width ) );
 
 1669   bufferMulti = qMax( bufferMulti, 1 );
 
 1671   int xBuffer = width * bufferMulti;
 
 1672   int yBuffer = height * bufferMulti;
 
 1673   int innerWidth = width;
 
 1674   int innerHeight = height;
 
 1675   width += 2 * xBuffer;
 
 1676   height += 2 * yBuffer;
 
 1678   if ( width > 10000 || height > 10000 ) 
 
 1683   QImage patternImage( width, height, QImage::Format_ARGB32 );
 
 1684   patternImage.fill( 0 );
 
 1686   QPointF p1, p2, p3, p4, p5, p6;
 
 1689     p1 = QPointF( 0, yBuffer );
 
 1690     p2 = QPointF( width, yBuffer );
 
 1691     p3 = QPointF( 0, yBuffer + innerHeight );
 
 1692     p4 = QPointF( width, yBuffer + innerHeight );
 
 1696     p1 = QPointF( xBuffer, height );
 
 1697     p2 = QPointF( xBuffer, 0 );
 
 1698     p3 = QPointF( xBuffer + innerWidth, height );
 
 1699     p4 = QPointF( xBuffer + innerWidth, 0 );
 
 1701   else if (( lineAngle > 0 && lineAngle < 90 ) || ( lineAngle > 180 && lineAngle < 270 ) )
 
 1703     dx = outputPixelDist * cos(( 90 - lineAngle ) * 
M_PI / 180.0 );
 
 1704     dy = outputPixelDist * sin(( 90 - lineAngle ) * 
M_PI / 180.0 );
 
 1705     p1 = QPointF( 0, height );
 
 1706     p2 = QPointF( width, 0 );
 
 1707     p3 = QPointF( -dx, height - dy );
 
 1708     p4 = QPointF( width - dx, -dy ); 
 
 1709     p5 = QPointF( dx, height + dy );
 
 1710     p6 = QPointF( width + dx, dy ); 
 
 1712   else if (( lineAngle < 180 ) || ( lineAngle > 270 && lineAngle < 360 ) )
 
 1714     dy = outputPixelDist * cos(( 180 - lineAngle ) * 
M_PI / 180 );
 
 1715     dx = outputPixelDist * sin(( 180 - lineAngle ) * 
M_PI / 180 );
 
 1716     p1 = QPointF( width, height );
 
 1717     p2 = QPointF( 0, 0 );
 
 1718     p5 = QPointF( width + dx, height - dy );
 
 1719     p6 = QPointF( p5.x() - width, p5.y() - height ); 
 
 1720     p3 = QPointF( width - dx, height + dy );
 
 1721     p4 = QPointF( p3.x() - width, p3.y() - height ); 
 
 1728     p3 = QPointF( tempPt.x(), tempPt.y() );
 
 1730     p4 = QPointF( tempPt.x(), tempPt.y() );
 
 1732     p5 = QPointF( tempPt.x(), tempPt.y() );
 
 1734     p6 = QPointF( tempPt.x(), tempPt.y() );
 
 1738     p1 = QPointF( tempPt.x(), tempPt.y() );
 
 1740     p2 = QPointF( tempPt.x(), tempPt.y() );;
 
 1743   QPainter p( &patternImage );
 
 1747   p.setRenderHint( QPainter::Antialiasing, 
false ); 
 
 1748   QPen pen( QColor( Qt::black ) );
 
 1749   pen.setWidthF( 0.1 );
 
 1750   pen.setCapStyle( Qt::FlatCap );
 
 1755   QPolygon polygon = QPolygon() << QPoint( 0, 0 ) << QPoint( width - 1, 0 ) << QPoint( width - 1, height - 1 ) << QPoint( 0, height - 1 ) << QPoint( 0, 0 ) ;
 
 1756   p.drawPolygon( polygon );
 
 1758   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 ) ;
 
 1759   p.drawPolygon( polygon );
 
 1765   p.setRenderHint( QPainter::Antialiasing, 
true );
 
 1778   QVector<QPolygonF> polygons;
 
 1779   polygons.append( QPolygonF() << p1 << p2 );
 
 1780   polygons.append( QPolygonF() << p3 << p4 );
 
 1783     polygons.append( QPolygonF() << p5 << p6 );
 
 1786   foreach ( QPolygonF polygon, polygons )
 
 1791   fillLineSymbol->
stopRender( lineRenderContext );
 
 1795   patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
 
 1800     QImage transparentImage = patternImage.copy();
 
 1802     brush.setTextureImage( transparentImage );
 
 1806     brush.setTextureImage( patternImage );
 
 1809   QTransform brushTransform;
 
 1811   brush.setTransform( brushTransform );
 
 1813   delete fillLineSymbol;
 
 1835   map.insert( 
"lineangle", QString::number( 
mLineAngle ) );
 
 1836   map.insert( 
"distance", QString::number( 
mDistance ) );
 
 1837   map.insert( 
"linewidth", QString::number( 
mLineWidth ) );
 
 1839   map.insert( 
"offset", QString::number( 
mOffset ) );
 
 1863   QDomElement symbolizerElem = doc.createElement( 
"se:PolygonSymbolizer" );
 
 1864   if ( !props.value( 
"uom", 
"" ).isEmpty() )
 
 1865     symbolizerElem.setAttribute( 
"uom", props.value( 
"uom", 
"" ) );
 
 1866   element.appendChild( symbolizerElem );
 
 1871   QDomElement fillElem = doc.createElement( 
"se:Fill" );
 
 1872   symbolizerElem.appendChild( fillElem );
 
 1874   QDomElement graphicFillElem = doc.createElement( 
"se:GraphicFill" );
 
 1875   fillElem.appendChild( graphicFillElem );
 
 1877   QDomElement graphicElem = doc.createElement( 
"se:Graphic" );
 
 1878   graphicFillElem.appendChild( graphicElem );
 
 1885   double angle = props.value( 
"angle", 
"0" ).toDouble( &ok );
 
 1888     angleFunc = QString( 
"%1 + %2" ).arg( props.value( 
"angle", 
"0" ) ).arg( 
mLineAngle );
 
 1892     angleFunc = QString::number( angle + 
mLineAngle );
 
 1908   QString featureStyle;
 
 1909   featureStyle.append( 
"Brush(" );
 
 1910   featureStyle.append( QString( 
"fc:%1" ).arg( 
mColor.name() ) );
 
 1911   featureStyle.append( QString( 
",bc:%1" ).arg( 
"#00000000" ) ); 
 
 1912   featureStyle.append( 
",id:\"ogr-brush-2\"" );
 
 1913   featureStyle.append( QString( 
",a:%1" ).arg( 
mLineAngle ) );
 
 1914   featureStyle.append( QString( 
",s:%1" ).arg( 
mLineWidth * widthScaleFactor ) );
 
 1915   featureStyle.append( 
",dx:0mm" );
 
 1916   featureStyle.append( QString( 
",dy:%1mm" ).arg( 
mDistance * widthScaleFactor ) );
 
 1917   featureStyle.append( 
")" );
 
 1918   return featureStyle;
 
 1927   if ( !lineAngleExpression && !distanceExpression && !lineWidthExpression && !colorExpression )
 
 1933   if ( lineAngleExpression )
 
 1935     lineAngle = lineAngleExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 1938   if ( distanceExpression )
 
 1940     distance = distanceExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 1943   if ( lineWidthExpression )
 
 1945     lineWidth = lineWidthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 1948   if ( colorExpression )
 
 1962   Qt::PenStyle lineStyle;
 
 1964   QDomElement fillElem = element.firstChildElement( 
"Fill" );
 
 1965   if ( fillElem.isNull() )
 
 1968   QDomElement graphicFillElem = fillElem.firstChildElement( 
"GraphicFill" );
 
 1969   if ( graphicFillElem.isNull() )
 
 1972   QDomElement graphicElem = graphicFillElem.firstChildElement( 
"Graphic" );
 
 1973   if ( graphicElem.isNull() )
 
 1979   if ( name != 
"horline" )
 
 1987     double d = angleFunc.toDouble( &ok );
 
 1996     offset = sqrt( pow( vectOffset.x(), 2 ) + pow( vectOffset.y(), 2 ) );
 
 2007   QDomElement strokeElem = element.firstChildElement( 
"Stroke" );
 
 2008   if ( !strokeElem.isNull() )
 
 2027     mDisplacementY( 0 ), mDisplacementYUnit( 
QgsSymbolV2::MM )
 
 2062   if ( properties.contains( 
"distance_x" ) )
 
 2064     layer->
setDistanceX( properties[
"distance_x"].toDouble() );
 
 2066   if ( properties.contains( 
"distance_y" ) )
 
 2068     layer->
setDistanceY( properties[
"distance_y"].toDouble() );
 
 2070   if ( properties.contains( 
"displacement_x" ) )
 
 2074   if ( properties.contains( 
"displacement_y" ) )
 
 2079   if ( properties.contains( 
"distance_x_unit" ) )
 
 2083   if ( properties.contains( 
"distance_y_unit" ) )
 
 2087   if ( properties.contains( 
"displacement_x_unit" ) )
 
 2091   if ( properties.contains( 
"displacement_y_unit" ) )
 
 2097   if ( properties.contains( 
"distance_x_expression" ) )
 
 2101   if ( properties.contains( 
"distance_y_expression" ) )
 
 2105   if ( properties.contains( 
"displacement_x_expression" ) )
 
 2109   if ( properties.contains( 
"displacement_y_expression" ) )
 
 2118   return "PointPatternFill";
 
 2122     double displacementX, 
double displacementY )
 
 2129   if ( width > 10000 || height > 10000 ) 
 
 2132     brush.setTextureImage( img );
 
 2136   QImage patternImage( width, height, QImage::Format_ARGB32 );
 
 2137   patternImage.fill( 0 );
 
 2141     QPainter p( &patternImage );
 
 2162     double displacementPixelY = displacementY * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( ctx, 
mDisplacementYUnit );
 
 2174     QImage transparentImage = patternImage.copy();
 
 2176     brush.setTextureImage( transparentImage );
 
 2180     brush.setTextureImage( patternImage );
 
 2182   QTransform brushTransform;
 
 2184   brush.setTransform( brushTransform );
 
 2209   propertyMap[
"distance_x"] = QString::number( 
mDistanceX );
 
 2210   propertyMap[
"distance_y"] = QString::number( 
mDistanceY );
 
 2211   propertyMap[
"displacement_x"] = QString::number( 
mDisplacementX );
 
 2212   propertyMap[
"displacement_y"] = QString::number( 
mDisplacementY );
 
 2236     QDomElement symbolizerElem = doc.createElement( 
"se:PolygonSymbolizer" );
 
 2237     if ( !props.value( 
"uom", 
"" ).isEmpty() )
 
 2238       symbolizerElem.setAttribute( 
"uom", props.value( 
"uom", 
"" ) );
 
 2239     element.appendChild( symbolizerElem );
 
 2244     QDomElement fillElem = doc.createElement( 
"se:Fill" );
 
 2245     symbolizerElem.appendChild( fillElem );
 
 2247     QDomElement graphicFillElem = doc.createElement( 
"se:GraphicFill" );
 
 2248     fillElem.appendChild( graphicFillElem );
 
 2253     symbolizerElem.appendChild( distanceElem );
 
 2259       QString errorMsg = QString( 
"MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->
layerType() );
 
 2260       graphicFillElem.appendChild( doc.createComment( errorMsg ) );
 
 2271   Q_UNUSED( element );
 
 2300   if ( !distanceXExpression && !distanceYExpression && !displacementXExpression && !displacementYExpression )
 
 2307   if ( distanceXExpression )
 
 2309     distanceX = distanceXExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 2312   if ( distanceYExpression )
 
 2314     distanceY = distanceYExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 2317   if ( displacementXExpression )
 
 2319     displacementX = displacementXExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 2322   if ( displacementYExpression )
 
 2324     displacementY = displacementYExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
 
 2359   Q_UNUSED( properties );
 
 2365   return "CentroidFill";
 
 2452   QSet<QString> attributes;