27 #include <QSvgRenderer> 30 #include <QDomDocument> 31 #include <QDomElement> 53 : mOutlineStyle( Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit(
QgsSymbolV2::MM )
64 mAngleExpression = NULL;
65 mNameExpression = NULL;
78 if ( props.contains(
"name" ) )
80 if ( props.contains(
"color" ) )
82 if ( props.contains(
"color_border" ) )
87 else if ( props.contains(
"outline_color" ) )
91 else if ( props.contains(
"line_color" ) )
95 if ( props.contains(
"size" ) )
96 size = props[
"size"].toDouble();
97 if ( props.contains(
"angle" ) )
98 angle = props[
"angle"].toDouble();
99 if ( props.contains(
"scale_method" ) )
103 if ( props.contains(
"offset" ) )
105 if ( props.contains(
"offset_unit" ) )
107 if ( props.contains(
"offset_map_unit_scale" ) )
109 if ( props.contains(
"size_unit" ) )
111 if ( props.contains(
"size_map_unit_scale" ) )
114 if ( props.contains(
"outline_style" ) )
118 else if ( props.contains(
"line_style" ) )
122 if ( props.contains(
"outline_width" ) )
126 else if ( props.contains(
"line_width" ) )
130 if ( props.contains(
"outline_width_unit" ) )
134 if ( props.contains(
"line_width_unit" ) )
138 if ( props.contains(
"outline_width_map_unit_scale" ) )
143 if ( props.contains(
"horizontal_anchor_point" ) )
147 if ( props.contains(
"vertical_anchor_point" ) )
153 if ( props.contains(
"name_expression" ) )
157 if ( props.contains(
"color_expression" ) )
161 if ( props.contains(
"color_border_expression" ) )
165 if ( props.contains(
"outline_style_expression" ) )
169 if ( props.contains(
"outline_width_expression" ) )
173 if ( props.contains(
"size_expression" ) )
177 if ( props.contains(
"angle_expression" ) )
181 if ( props.contains(
"offset_expression" ) )
185 if ( props.contains(
"horizontal_anchor_point_expression" ) )
189 if ( props.contains(
"vertical_anchor_point_expression" ) )
199 return "SimpleMarker";
204 QColor brushColor =
mColor;
207 brushColor.setAlphaF(
mColor.alphaF() * context.
alpha() );
210 mBrush = QBrush( brushColor );
211 mPen = QPen( penColor );
217 if ( context.
alpha() < 1 )
219 selBrushColor.setAlphaF( context.
alpha() );
220 selPenColor.setAlphaF( context.
alpha() );
247 if (
mName !=
"circle" )
248 mSelPen.setColor( selBrushColor );
260 if ( !hasDataDefinedSize )
265 double half = scaledSize / 2.0;
266 transform.scale( half, half );
270 if ( !hasDataDefinedRotation &&
mAngle != 0 )
272 transform.rotate(
mAngle );
306 double pw = ((
mPen.widthF() == 0 ? 1 :
mPen.widthF() ) + 1 ) / 2 * 2;
307 int imageSize = (( int ) scaledSize + pw ) / 2 * 2 + 1;
308 double center = imageSize / 2.0;
315 mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
320 p.setRenderHint( QPainter::Antialiasing );
323 p.translate( QPointF( center, center ) );
331 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
335 p.setRenderHint( QPainter::Antialiasing );
338 p.translate( QPointF( center, center ) );
349 p.setRenderHint( QPainter::Antialiasing );
350 p.fillRect( 0, 0, imageSize, imageSize, selColor );
353 p.translate( QPointF( center, center ) );
375 if ( name ==
"square" || name ==
"rectangle" )
377 polygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
380 else if ( name ==
"diamond" )
382 polygon << QPointF( -1, 0 ) << QPointF( 0, 1 )
383 << QPointF( 1, 0 ) << QPointF( 0, -1 );
386 else if ( name ==
"pentagon" )
388 polygon << QPointF( sin(
DEG2RAD( 288.0 ) ), - cos(
DEG2RAD( 288.0 ) ) )
395 else if ( name ==
"triangle" )
397 polygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 );
400 else if ( name ==
"equilateral_triangle" )
402 polygon << QPointF( sin(
DEG2RAD( 240.0 ) ), - cos(
DEG2RAD( 240.0 ) ) )
407 else if ( name ==
"star" )
409 double sixth = 1.0 / 3;
411 polygon << QPointF( 0, -1 )
412 << QPointF( -sixth, -sixth )
413 << QPointF( -1, -sixth )
414 << QPointF( -sixth, 0 )
416 << QPointF( 0, + sixth )
418 << QPointF( + sixth, 0 )
419 << QPointF( 1, -sixth )
420 << QPointF( + sixth, -sixth );
423 else if ( name ==
"regular_star" )
427 polygon << QPointF( inner_r * sin(
DEG2RAD( 324.0 ) ), - inner_r * cos(
DEG2RAD( 324.0 ) ) )
429 << QPointF( inner_r * sin(
DEG2RAD( 252.0 ) ), - inner_r * cos(
DEG2RAD( 252.0 ) ) )
431 << QPointF( 0, inner_r )
433 << QPointF( inner_r * sin(
DEG2RAD( 108.0 ) ), - inner_r * cos(
DEG2RAD( 108.0 ) ) )
435 << QPointF( inner_r * sin(
DEG2RAD( 36.0 ) ), - inner_r * cos(
DEG2RAD( 36.0 ) ) )
439 else if ( name ==
"arrow" )
441 polygon << QPointF( 0, -1 )
442 << QPointF( 0.5, -0.5 )
443 << QPointF( 0.25, -0.5 )
444 << QPointF( 0.25, 1 )
445 << QPointF( -0.25, 1 )
446 << QPointF( -0.25, -0.5 )
447 << QPointF( -0.5, -0.5 );
450 else if ( name ==
"filled_arrowhead" )
452 polygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 );
461 mPath = QPainterPath();
467 if ( name ==
"circle" )
469 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
472 else if ( name ==
"cross" )
474 mPath.moveTo( -1, 0 );
475 mPath.lineTo( 1, 0 );
476 mPath.moveTo( 0, -1 );
477 mPath.lineTo( 0, 1 );
480 else if ( name ==
"x" || name ==
"cross2" )
482 mPath.moveTo( -1, -1 );
483 mPath.lineTo( 1, 1 );
484 mPath.moveTo( 1, -1 );
485 mPath.lineTo( -1, 1 );
488 else if ( name ==
"line" )
490 mPath.moveTo( 0, -1 );
491 mPath.lineTo( 0, 1 );
494 else if ( name ==
"arrowhead" )
496 mPath.moveTo( 0, 0 );
497 mPath.lineTo( -1, -1 );
498 mPath.moveTo( 0, 0 );
499 mPath.lineTo( -1, 1 );
517 double scaledSize =
mSize;
518 if ( hasDataDefinedSize )
520 if ( sizeExpression )
522 scaledSize = sizeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
527 scaledSize = sqrt( scaledSize );
534 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
535 QPointF off( offsetX, offsetY );
539 if ( mAngleExpression )
541 angle = mAngleExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
545 if ( hasDataDefinedRotation )
568 bool createdNewPath =
false;
569 if ( mNameExpression )
571 QString
name = mNameExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
576 createdNewPath =
true;
585 p->drawImage( QRectF( point.x() - s / 2.0 + off.x(),
586 point.y() - s / 2.0 + off.y(),
594 transform.translate( point.x() + off.x(), point.y() + off.y() );
597 if ( hasDataDefinedSize || createdNewPath )
600 double half = s / 2.0;
601 transform.scale( half, half );
604 if ( angle != 0 && ( hasDataDefinedRotation || createdNewPath ) )
605 transform.rotate( angle );
611 if ( colorExpression )
615 if ( colorBorderExpression )
620 if ( outlineWidthExpression )
626 if ( outlineStyleExpression )
637 p->drawPolygon( transform.map(
mPolygon ) );
639 p->drawPath( transform.map(
mPath ) );
650 map[
"size"] = QString::number(
mSize );
653 map[
"angle"] = QString::number(
mAngle );
692 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
693 element.appendChild( graphicElem );
700 double angle = props.value(
"angle",
"0" ).toDouble( &ok );
703 angleFunc = QString(
"%1 + %2" ).arg( props.value(
"angle",
"0" ) ).arg(
mAngle );
705 else if ( angle +
mAngle != 0 )
707 angleFunc = QString::number( angle +
mAngle );
717 Q_UNUSED( mmScaleFactor );
718 Q_UNUSED( mapUnitScaleFactor );
720 QString ogrType =
"3";
721 if (
mName ==
"square" )
725 else if (
mName ==
"triangle" )
729 else if (
mName ==
"star" )
733 else if (
mName ==
"circle" )
737 else if (
mName ==
"cross" )
745 else if (
mName ==
"line" )
751 ogrString.append(
"SYMBOL(" );
752 ogrString.append(
"id:" );
753 ogrString.append(
"\"" );
754 ogrString.append(
"ogr-sym-" );
755 ogrString.append( ogrType );
756 ogrString.append(
"\"" );
757 ogrString.append(
",c:" );
758 ogrString.append(
mColor.name() );
759 ogrString.append(
",o:" );
761 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
762 ogrString.append(
")" );
767 ogrString.append(
"PEN(" );
768 ogrString.append(
"c:" );
769 ogrString.append(
mColor.name() );
770 ogrString.append(
",w:" );
771 ogrString.append( QString::number(
mSize ) );
772 ogrString.append(
"mm" );
773 ogrString.append(
")" );
781 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
782 if ( graphicElem.isNull() )
785 QString
name =
"square";
787 double borderWidth,
size;
788 Qt::PenStyle borderStyle;
798 double d = angleFunc.toDouble( &ok );
823 p->drawPath(
mPath );
833 bool hasDataDefinedSize =
false;
840 if ( hasDataDefinedSize )
842 if ( sizeExpression )
844 size = sizeExpression->
evaluate( *f ).toDouble();
860 size *= mmMapUnitScaleFactor;
862 double halfSize = size / 2.0;
867 if ( context && outlineWidthExpression )
869 outlineWidth = outlineWidthExpression->
evaluate( *f ).toDouble();
873 outlineWidth *= mmMapUnitScaleFactor;
877 QColor pc =
mPen.color();
878 QColor bc =
mBrush.color();
881 if ( colorExpression )
887 if ( outlinecolorExpression )
899 QPointF off( offsetX, offsetY );
904 if ( context && angleExpression )
906 angle = angleExpression->
evaluate( *f ).toDouble();
911 if ( context && nameExpression )
913 name = nameExpression->
evaluate( *f ).toString();
922 off *= mmMapUnitScaleFactor;
926 t.translate( shift.x() + offsetX, shift.y() + offsetY );
934 t.scale( halfSize, -halfSize );
936 polygon = t.map( polygon );
940 p[0].resize( polygon.size() + 1 );
942 for ( i = 0; i < polygon.size(); i++ )
943 p[0][i] = polygon[i];
946 if (
mBrush.style() != Qt::NoBrush )
948 if (
mPen.style() != Qt::NoPen )
949 e.
writePolyline( p[0], layerName,
"CONTINUOUS", pc, outlineWidth );
951 else if ( name ==
"circle" )
953 if (
mBrush.style() != Qt::NoBrush )
955 if (
mPen.style() != Qt::NoPen )
956 e.
writeCircle( layerName, pc, shift, halfSize,
"CONTINUOUS", outlineWidth );
958 else if ( name ==
"line" )
960 QPointF pt1 = t.map( QPointF( 0, -halfSize ) );
961 QPointF pt2 = t.map( QPointF( 0, halfSize ) );
963 if (
mPen.style() != Qt::NoPen )
964 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
966 else if ( name ==
"cross" )
968 if (
mPen.style() != Qt::NoPen )
970 QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
971 QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
972 QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
973 QPointF pt4 = t.map( QPointF( 0, halfSize ) );
975 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
976 e.
writeLine( pt3, pt4, layerName,
"CONTINUOUS", pc, outlineWidth );
979 else if ( name ==
"x" || name ==
"cross2" )
981 if (
mPen.style() != Qt::NoPen )
983 QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
984 QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
985 QPointF pt3 = t.map( QPointF( halfSize, -halfSize ) );
986 QPointF pt4 = t.map( QPointF( -halfSize, halfSize ) );
988 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
989 e.
writeLine( pt3, pt4, layerName,
"CONTINUOUS", pc, outlineWidth );
992 else if ( name ==
"arrowhead" )
994 if (
mPen.style() != Qt::NoPen )
996 QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
997 QPointF pt2 = t.map( QPointF( 0, 0 ) );
998 QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
1000 e.
writeLine( pt1, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
1001 e.
writeLine( pt3, pt2, layerName,
"CONTINUOUS", pc, outlineWidth );
1006 QgsDebugMsg( QString(
"Unsupported dxf marker name %1" ).arg( name ) );
1056 mColor = QColor( Qt::black );
1057 mOutlineColor = QColor( Qt::black );
1068 if ( props.contains(
"name" ) )
1069 name = props[
"name"];
1070 if ( props.contains(
"size" ) )
1071 size = props[
"size"].toDouble();
1072 if ( props.contains(
"angle" ) )
1073 angle = props[
"angle"].toDouble();
1074 if ( props.contains(
"scale_method" ) )
1080 if ( !props.contains(
"fill" ) && !props.contains(
"color" ) && !props.contains(
"outline" ) &&
1081 !props.contains(
"outline_color" ) && !props.contains(
"outline-width" ) && !props.contains(
"outline_width" ) )
1085 bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1091 if ( hasOutlineParam )
1095 if ( hasOutlineWidthParam )
1101 if ( props.contains(
"size_unit" ) )
1103 if ( props.contains(
"size_map_unit_scale" ) )
1105 if ( props.contains(
"offset" ) )
1107 if ( props.contains(
"offset_unit" ) )
1109 if ( props.contains(
"offset_map_unit_scale" ) )
1111 if ( props.contains(
"fill" ) )
1116 else if ( props.contains(
"color" ) )
1120 if ( props.contains(
"outline" ) )
1125 else if ( props.contains(
"outline_color" ) )
1129 else if ( props.contains(
"line_color" ) )
1134 if ( props.contains(
"outline-width" ) )
1139 else if ( props.contains(
"outline_width" ) )
1143 else if ( props.contains(
"line_width" ) )
1148 if ( props.contains(
"outline_width_unit" ) )
1152 else if ( props.contains(
"line_width_unit" ) )
1156 if ( props.contains(
"outline_width_map_unit_scale" ) )
1159 if ( props.contains(
"horizontal_anchor_point" ) )
1163 if ( props.contains(
"vertical_anchor_point" ) )
1169 if ( props.contains(
"size_expression" ) )
1173 if ( props.contains(
"outline-width_expression" ) )
1177 if ( props.contains(
"angle_expression" ) )
1181 if ( props.contains(
"offset_expression" ) )
1185 if ( props.contains(
"name_expression" ) )
1189 if ( props.contains(
"fill_expression" ) )
1193 if ( props.contains(
"outline_expression" ) )
1197 if ( props.contains(
"horizontal_anchor_point_expression" ) )
1201 if ( props.contains(
"vertical_anchor_point_expression" ) )
1213 bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1219 if ( hasOutlineParam )
1223 if ( hasOutlineWidthParam )
1238 Q_UNUSED( context );
1244 Q_UNUSED( context );
1253 double scaledSize =
mSize;
1258 if ( sizeExpression )
1260 scaledSize = sizeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
1263 if ( hasDataDefinedSize )
1268 scaledSize = sqrt( scaledSize );
1278 if ((
int )size < 1 || 10000.0 <
size )
1288 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
1289 QPointF outputOffset( offsetX, offsetY );
1293 if ( angleExpression )
1295 angle = angleExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
1299 if ( hasDataDefinedRotation )
1320 p->translate( point + outputOffset );
1326 QString path =
mPath;
1328 if ( nameExpression )
1330 path = nameExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
1335 if ( outlineWidthExpression )
1337 outlineWidth = outlineWidthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
1342 if ( fillExpression )
1349 if ( outlineExpression )
1355 bool fitsInCache =
true;
1356 bool usePict =
true;
1357 double hwRatio = 1.0;
1363 if ( fitsInCache && img.width() > 1 )
1368 QImage transparentImage = img.copy();
1370 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
1371 hwRatio = ( double )transparentImage.height() / ( double )transparentImage.width();
1375 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
1376 hwRatio = ( double )img.height() / ( double )img.width();
1381 if ( usePict || !fitsInCache )
1383 p->setOpacity( context.
alpha() );
1387 if ( pct.width() > 1 )
1391 p->drawPicture( 0, 0, pct );
1393 hwRatio = ( double )pct.height() / ( double )pct.width();
1401 if ( penWidth > size / 20 )
1404 penWidth = size / 20;
1406 double penOffset = penWidth / 2;
1407 pen.setWidth( penWidth );
1409 p->setBrush( Qt::NoBrush );
1410 double wSize = size + penOffset;
1411 double hSize = size * hwRatio + penOffset;
1412 p->drawRect( QRectF( -wSize / 2.0, -hSize / 2.0, wSize, hSize ) );
1423 map[
"size"] = QString::number(
mSize );
1426 map[
"angle"] = QString::number(
mAngle );
1431 map[
"color"] =
mColor.name();
1432 map[
"outline_color"] = mOutlineColor.name();
1496 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
1497 element.appendChild( graphicElem );
1504 double angle = props.value(
"angle",
"0" ).toDouble( &ok );
1507 angleFunc = QString(
"%1 + %2" ).arg( props.value(
"angle",
"0" ) ).arg(
mAngle );
1509 else if ( angle +
mAngle != 0 )
1511 angleFunc = QString::number( angle +
mAngle );
1524 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1525 if ( graphicElem.isNull() )
1528 QString path, mimeType;
1535 if ( mimeType !=
"image/svg+xml" )
1543 double d = angleFunc.toDouble( &ok );
1561 const QPointF& shift )
const 1563 Q_UNUSED( layerName );
1571 if ( sizeExpression )
1573 size = sizeExpression->
evaluate( *f ).toDouble();
1576 if ( hasDataDefinedSize )
1581 size = sqrt( size );
1590 size *= mmMapUnitScaleFactor;
1593 double halfSize = size / 2.0;
1598 if ( offsetExpression )
1600 QString offsetString = offsetExpression->
evaluate( *f ).toString();
1603 double offsetX = offset.x();
1604 double offsetY = offset.y();
1607 offsetX *= mmMapUnitScaleFactor;
1608 offsetY *= mmMapUnitScaleFactor;
1611 QPointF outputOffset( offsetX, offsetY );
1615 if ( angleExpression )
1617 angle = angleExpression->
evaluate( *f ).toDouble();
1623 QString path =
mPath;
1625 if ( nameExpression )
1627 path = nameExpression->
evaluate( *f ).toString();
1632 if ( outlineWidthExpression )
1634 outlineWidth = outlineWidthExpression->
evaluate( *f ).toDouble();
1639 if ( fillExpression )
1641 QString colorString = fillExpression->
evaluate( *f ).toString();
1648 if ( outlineExpression )
1650 QString colorString = outlineExpression->
evaluate( *f ).toString();
1662 QSvgRenderer r( svgContent );
1675 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
1677 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
1680 pd.
setOutputSize( QRectF( -halfSize, -halfSize, size, size ) );
1691 mFontFamily = fontFamily;
1696 mOrigSize = pointSize;
1710 if ( props.contains(
"font" ) )
1711 fontFamily = props[
"font"];
1712 if ( props.contains(
"chr" ) && props[
"chr"].length() > 0 )
1713 chr = props[
"chr"].at( 0 );
1714 if ( props.contains(
"size" ) )
1715 pointSize = props[
"size"].toDouble();
1716 if ( props.contains(
"color" ) )
1718 if ( props.contains(
"angle" ) )
1719 angle = props[
"angle"].toDouble();
1722 if ( props.contains(
"offset" ) )
1724 if ( props.contains(
"offset_unit" ) )
1726 if ( props.contains(
"offset_map_unit_scale" ) )
1728 if ( props.contains(
"size_unit" ) )
1730 if ( props.contains(
"size_map_unit_scale" ) )
1732 if ( props.contains(
"horizontal_anchor_point" ) )
1736 if ( props.contains(
"vertical_anchor_point" ) )
1745 return "FontMarker";
1750 mFont = QFont( mFontFamily );
1752 QFontMetrics fm( mFont );
1753 mChrOffset = QPointF( fm.width( mChr ) / 2, -fm.ascent() / 2 );
1760 Q_UNUSED( context );
1770 penColor.setAlphaF(
mColor.alphaF() * context.
alpha() );
1771 p->setPen( penColor );
1772 p->setFont( mFont );
1779 QPointF outputOffset( offsetX, offsetY );
1782 p->translate( point + outputOffset );
1786 double s =
mSize / mOrigSize;
1793 p->drawText( -mChrOffset, mChr );
1800 props[
"font"] = mFontFamily;
1801 props[
"chr"] = mChr;
1802 props[
"size"] = QString::number(
mSize );
1806 props[
"angle"] = QString::number(
mAngle );
1831 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
1832 element.appendChild( graphicElem );
1834 QString fontPath = QString(
"ttf://%1" ).arg( mFontFamily );
1835 int markIndex = mChr.unicode();
1841 double angle = props.value(
"angle",
"0" ).toDouble( &ok );
1844 angleFunc = QString(
"%1 + %2" ).arg( props.value(
"angle",
"0" ) ).arg(
mAngle );
1846 else if ( angle +
mAngle != 0 )
1848 angleFunc = QString::number( angle +
mAngle );
1860 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1861 if ( graphicElem.isNull() )
1864 QString
name, format;
1872 if ( !name.startsWith(
"ttf://" ) || format !=
"ttf" )
1875 QString fontFamily = name.mid( 6 );
1882 double d = angleFunc.toDouble( &ok );
QgsSymbolV2::OutputUnit outputUnit() const override
QColor borderColor() const
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
Q_GUI_EXPORT int qt_defaultDpiX()
Class for parsing and evaluation of expressions (formerly called "search strings").
void setOutlineStyle(Qt::PenStyle outlineStyle)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
void stopRender(QgsSymbolV2RenderContext &context) override
QgsSymbolV2::OutputUnit outputUnit() const override
static void multiplyImageOpacity(QImage *image, qreal alpha)
Multiplies opacity of image pixel values with a (global) transparency value.
QgsMapUnitScale mSizeMapUnitScale
QgsMapUnitScale mOutlineWidthMapUnitScale
Q_GUI_EXPORT int qt_defaultDpiY()
QString layerType() const override
QgsStringMap properties() const override
static Q_DECL_DEPRECATED bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &borderColor, double &borderWidth, double &size)
A paint device for drawing into dxf files.
QString layerType() const override
#define DEFAULT_FONTMARKER_COLOR
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.
QColor selectionColor() const
QgsSymbolLayerV2 * clone() const override
void setOutlineColor(const QColor &c) override
Set outline color.
QString layerType() const override
#define DEFAULT_SIMPLEMARKER_ANGLE
void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color)
Draw dxf polygon (HATCH)
static void createRotationElement(QDomDocument &doc, QDomElement &element, QString rotationFunc)
double rendererScale() const
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
#define DEFAULT_FONTMARKER_CHR
void setOffset(QPointF offset)
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
void setOutlineWidth(double w)
QGis::GeometryType type() const
Returns type of the vector.
#define DEFAULT_SIMPLEMARKER_COLOR
void writeSldMarker(QDomDocument &doc, QDomElement &element, QgsStringMap props) const override
QgsSymbolLayerV2 * clone() const override
static QPointF decodePoint(QString str)
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)
static QColor decodeColor(QString str)
void stopRender(QgsSymbolV2RenderContext &context) override
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
void setOutlineWidth(double w)
double scaleFactor() const
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)
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
void writeSldMarker(QDomDocument &doc, QDomElement &element, QgsStringMap props) const override
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
QMap< QString, QString > QgsStringMap
QgsSymbolLayerV2 * clone() const override
double mapRotation() const
Return current map rotation in degrees.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
void setMapUnitScale(const QgsMapUnitScale &scale) override
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void writeCircle(const QString &layer, QColor color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
#define DEFAULT_SVGMARKER_ANGLE
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
static QString encodeColor(QColor color)
#define DEFAULT_SIMPLEMARKER_NAME
virtual QgsExpression * expression(const QString &property) const
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.
void drawMarker(QPainter *p, QgsSymbolV2RenderContext &context)
static QgsSvgCache * instance()
static QString encodePenStyle(Qt::PenStyle style)
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, const QgsSymbolV2RenderContext *context, const QgsFeature *f, const QPointF &shift=QPointF(0.0, 0.0)) const override
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.
QgsFontMarkerSymbolLayerV2(QString fontFamily=DEFAULT_FONTMARKER_FONT, QChar chr=DEFAULT_FONTMARKER_CHR, double pointSize=DEFAULT_FONTMARKER_SIZE, QColor color=DEFAULT_FONTMARKER_COLOR, double angle=DEFAULT_FONTMARKER_ANGLE)
Perform transforms between map coordinates and device coordinates.
static QString symbolPathToName(QString path)
Get symbols's name from its path.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit u)
const QgsFeature * feature() const
Current feature being rendered - may be null.
static QString encodePoint(QPointF point)
QgsStringMap properties() const override
static Qt::PenStyle decodePenStyle(QString str)
void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context) override
#define DEFAULT_SCALE_METHOD
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
Qt::PenStyle mOutlineStyle
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setFillColor(const QColor &color) override
Set fill color.
double outlineWidth() const
QgsSymbolV2::ScaleMethod mScaleMethod
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
bool forceVectorOutput() const
void setLayer(const QString &layer)
void setSizeUnit(QgsSymbolV2::OutputUnit unit)
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
void setPath(QString path)
QgsMapUnitScale mapUnitScale() const override
QgsStringMap properties() const override
void stopRender(QgsSymbolV2RenderContext &context) override
double rasterScaleFactor() const
#define DEFAULT_FONTMARKER_ANGLE
QgsSymbolV2::OutputUnit outputUnit() const override
void writeLine(const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, QColor color, double width=-1)
Write line (as a polyline)
virtual QColor color() const
const QByteArray & svgContent(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor)
Get SVG content.
QgsSvgMarkerSymbolLayerV2(QString name=DEFAULT_SVGMARKER_NAME, double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, QgsSymbolV2::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
HorizontalAnchorPoint mHorizontalAnchorPoint
void writePolyline(const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color, double width=-1, bool unusedPolygonFlag=false)
draw dxf primitives
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
virtual void prepareExpressions(const QgsFields *fields, double scale=-1.0)
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::ScaleMethod scaleMethod() const
QgsSymbolV2::OutputUnit mOutlineWidthUnit
#define DEFAULT_SVGMARKER_SIZE
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 setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mapUnitScale() const override
void startRender(QgsSymbolV2RenderContext &context) override
#define DEFAULT_FONTMARKER_SIZE
void startRender(QgsSymbolV2RenderContext &context) override
#define DEFAULT_FONTMARKER_FONT
#define DEFAULT_SVGMARKER_NAME
#define DEFAULT_SIMPLEMARKER_SIZE
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.
void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context) override
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
Qt::PenStyle outlineStyle() const
void setShift(const QPointF &shift)
QgsSimpleMarkerSymbolLayerV2(QString name=DEFAULT_SIMPLEMARKER_NAME, QColor color=DEFAULT_SIMPLEMARKER_COLOR, QColor borderColor=DEFAULT_SIMPLEMARKER_BORDERCOLOR, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, QgsSymbolV2::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
virtual const QgsExpression * dataDefinedProperty(const QString &property) const
static const QString EXPR_SIZE
static QString encodeScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QgsRenderContext & renderContext()
bool preparePath(QString name=QString())
void writeFilledCircle(const QString &layer, QColor color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, QString path, QString mime, QColor color, double size=-1)
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, const QgsSymbolV2RenderContext *context, const QgsFeature *f, const QPointF &shift=QPointF(0.0, 0.0)) const override
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
QColor fillColor() const override
Get fill color.
const QgsFields * fields() const
Fields of the layer.
QgsSymbolV2::OutputUnit mOffsetUnit
void startRender(QgsSymbolV2RenderContext &context) override
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
static QgsSymbolV2::ScaleMethod decodeScaleMethod(QString str)
void startRender(QgsSymbolV2RenderContext &context) override
VerticalAnchorPoint mVerticalAnchorPoint
bool prepareShape(QString name=QString())
QgsSymbolV2::OutputUnit mSizeUnit
void setDrawingSize(const QSizeF &size)
QgsMapUnitScale mOffsetMapUnitScale
void markerOffset(const QgsSymbolV2RenderContext &context, double &offsetX, double &offsetY) const
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
void writeSldMarker(QDomDocument &doc, QDomElement &element, QgsStringMap props) const override
void setAngle(double angle)
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void saveDataDefinedProperties(QgsStringMap &stringMap) const
Saves data defined properties to string map.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QColor outlineColor() const override
Get outline color.
bool prepareCache(QgsSymbolV2RenderContext &context)
Prepares cache image.
static QgsSymbolV2::OutputUnit decodeOutputUnit(QString str)
void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context) override
static void externalMarkerToSld(QDomDocument &doc, QDomElement &element, QString path, QString format, int *markIndex=0, QColor color=QColor(), double size=-1)
static const int mMaximumCacheWidth
void copyDataDefinedProperties(QgsSymbolLayerV2 *destLayer) const
Copies data defined properties of this layer to another symbol layer.
void setOutputSize(const QRectF &r)
virtual void setDataDefinedProperty(const QString &property, const QString &expressionString)
static QPointF _rotatedOffset(const QPointF &offset, double angle)
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
void setOutlineColor(const QColor &color) override
Set outline color.