19 #include "qgsdxfexport.h"
20 #include "qgsdxfpaintdevice.h"
27 #include <QSvgRenderer>
30 #include <QDomDocument>
31 #include <QDomElement>
51 : mOutlineStyle( Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit(
QgsSymbolV2::MM )
75 if ( props.contains(
"name" ) )
77 if ( props.contains(
"color" ) )
79 if ( props.contains(
"color_border" ) )
81 if ( props.contains(
"size" ) )
82 size = props[
"size"].toDouble();
83 if ( props.contains(
"angle" ) )
84 angle = props[
"angle"].toDouble();
85 if ( props.contains(
"scale_method" ) )
89 if ( props.contains(
"offset" ) )
91 if ( props.contains(
"offset_unit" ) )
93 if ( props.contains(
"offset_map_unit_scale" ) )
95 if ( props.contains(
"size_unit" ) )
97 if ( props.contains(
"size_map_unit_scale" ) )
100 if ( props.contains(
"outline_style" ) )
104 if ( props.contains(
"outline_width" ) )
108 if ( props.contains(
"outline_width_unit" ) )
112 if ( props.contains(
"outline_width_map_unit_scale" ) )
117 if ( props.contains(
"horizontal_anchor_point" ) )
121 if ( props.contains(
"vertical_anchor_point" ) )
127 if ( props.contains(
"name_expression" ) )
131 if ( props.contains(
"color_expression" ) )
135 if ( props.contains(
"color_border_expression" ) )
139 if ( props.contains(
"outline_width_expression" ) )
143 if ( props.contains(
"size_expression" ) )
147 if ( props.contains(
"angle_expression" ) )
151 if ( props.contains(
"offset_expression" ) )
155 if ( props.contains(
"horizontal_anchor_point_expression" ) )
159 if ( props.contains(
"vertical_anchor_point_expression" ) )
169 return "SimpleMarker";
174 QColor brushColor =
mColor;
177 brushColor.setAlphaF(
mColor.alphaF() * context.
alpha() );
180 mBrush = QBrush( brushColor );
181 mPen = QPen( penColor );
187 if ( context.
alpha() < 1 )
189 selBrushColor.setAlphaF( context.
alpha() );
190 selPenColor.setAlphaF( context.
alpha() );
216 if (
mName !=
"circle" )
217 mSelPen.setColor( selBrushColor );
229 if ( !hasDataDefinedSize )
234 double half = scaledSize / 2.0;
235 transform.scale( half, half );
239 if ( !hasDataDefinedRotation &&
mAngle != 0 )
241 transform.rotate(
mAngle );
275 double pw = ((
mPen.widthF() == 0 ? 1 :
mPen.widthF() ) + 1 ) / 2 * 2;
276 int imageSize = (( int ) scaledSize + pw ) / 2 * 2 + 1;
277 double center = imageSize / 2.0;
284 mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
289 p.setRenderHint( QPainter::Antialiasing );
292 p.translate( QPointF( center, center ) );
300 mSelCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
304 p.setRenderHint( QPainter::Antialiasing );
307 p.translate( QPointF( center, center ) );
318 p.setRenderHint( QPainter::Antialiasing );
319 p.fillRect( 0, 0, imageSize, imageSize, selColor );
322 p.translate( QPointF( center, center ) );
344 if ( name ==
"square" || name ==
"rectangle" )
346 mPolygon = QPolygonF( QRectF( QPointF( -1, -1 ), QPointF( 1, 1 ) ) );
349 else if ( name ==
"diamond" )
351 mPolygon << QPointF( -1, 0 ) << QPointF( 0, 1 )
352 << QPointF( 1, 0 ) << QPointF( 0, -1 );
355 else if ( name ==
"pentagon" )
364 else if ( name ==
"triangle" )
366 mPolygon << QPointF( -1, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 );
369 else if ( name ==
"equilateral_triangle" )
376 else if ( name ==
"star" )
378 double sixth = 1.0 / 3;
381 << QPointF( -sixth, -sixth )
382 << QPointF( -1, -sixth )
383 << QPointF( -sixth, 0 )
385 << QPointF( 0, + sixth )
387 << QPointF( + sixth, 0 )
388 << QPointF( 1, -sixth )
389 << QPointF( + sixth, -sixth );
392 else if ( name ==
"regular_star" )
398 << QPointF( inner_r * sin(
DEG2RAD( 252.0 ) ), - inner_r * cos(
DEG2RAD( 252.0 ) ) )
400 << QPointF( 0, inner_r )
402 << QPointF( inner_r * sin(
DEG2RAD( 108.0 ) ), - inner_r * cos(
DEG2RAD( 108.0 ) ) )
404 << QPointF( inner_r * sin(
DEG2RAD( 36.0 ) ), - inner_r * cos(
DEG2RAD( 36.0 ) ) )
408 else if ( name ==
"arrow" )
412 << QPointF( 0.5, -0.5 )
413 << QPointF( 0.25, -0.5 )
414 << QPointF( 0.25, 1 )
415 << QPointF( -0.25, 1 )
416 << QPointF( -0.25, -0.5 )
417 << QPointF( -0.5, -0.5 );
420 else if ( name ==
"filled_arrowhead" )
422 mPolygon << QPointF( 0, 0 ) << QPointF( -1, 1 ) << QPointF( -1, -1 );
431 mPath = QPainterPath();
437 if ( name ==
"circle" )
439 mPath.addEllipse( QRectF( -1, -1, 2, 2 ) );
442 else if ( name ==
"cross" )
444 mPath.moveTo( -1, 0 );
445 mPath.lineTo( 1, 0 );
446 mPath.moveTo( 0, -1 );
447 mPath.lineTo( 0, 1 );
450 else if ( name ==
"x" || name ==
"cross2" )
452 mPath.moveTo( -1, -1 );
453 mPath.lineTo( 1, 1 );
454 mPath.moveTo( 1, -1 );
455 mPath.lineTo( -1, 1 );
458 else if ( name ==
"line" )
460 mPath.moveTo( 0, -1 );
461 mPath.lineTo( 0, 1 );
464 else if ( name ==
"arrowhead" )
466 mPath.moveTo( 0, 0 );
467 mPath.lineTo( -1, -1 );
468 mPath.moveTo( 0, 0 );
469 mPath.lineTo( -1, 1 );
487 double scaledSize =
mSize;
488 if ( hasDataDefinedSize )
490 if ( sizeExpression )
492 scaledSize = sizeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
497 scaledSize = sqrt( scaledSize );
504 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
505 QPointF off( offsetX, offsetY );
531 p->drawImage( QRectF( point.x() - s / 2.0 + off.x(),
532 point.y() - s / 2.0 + off.y(),
540 transform.translate( point.x() + off.x(), point.y() + off.y() );
543 if ( hasDataDefinedSize )
548 double half = s / 2.0;
549 transform.scale( half, half );
553 if ( angle != 0 && hasDataDefinedRotation )
554 transform.rotate( angle );
559 if ( colorExpression )
563 if ( colorBorderExpression )
568 if ( outlineWidthExpression )
579 p->drawPolygon( transform.map(
mPolygon ) );
581 p->drawPath( transform.map(
mPath ) );
592 map[
"size"] = QString::number(
mSize );
595 map[
"angle"] = QString::number(
mAngle );
634 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
635 element.appendChild( graphicElem );
642 double angle = props.value(
"angle",
"0" ).toDouble( &ok );
645 angleFunc = QString(
"%1 + %2" ).arg( props.value(
"angle",
"0" ) ).arg(
mAngle );
647 else if ( angle +
mAngle != 0 )
649 angleFunc = QString::number( angle +
mAngle );
659 Q_UNUSED( mmScaleFactor );
660 Q_UNUSED( mapUnitScaleFactor );
662 QString ogrType =
"3";
663 if (
mName ==
"square" )
667 else if (
mName ==
"triangle" )
671 else if (
mName ==
"star" )
675 else if (
mName ==
"circle" )
679 else if (
mName ==
"cross" )
687 else if (
mName ==
"line" )
693 ogrString.append(
"SYMBOL(" );
694 ogrString.append(
"id:" );
695 ogrString.append(
"\"" );
696 ogrString.append(
"ogr-sym-" );
697 ogrString.append( ogrType );
698 ogrString.append(
"\"" );
699 ogrString.append(
",c:" );
700 ogrString.append(
mColor.name() );
701 ogrString.append(
",o:" );
703 ogrString.append( QString(
",s:%1mm" ).arg(
mSize ) );
704 ogrString.append(
")" );
709 ogrString.append(
"PEN(" );
710 ogrString.append(
"c:" );
711 ogrString.append(
mColor.name() );
712 ogrString.append(
",w:" );
713 ogrString.append( QString::number(
mSize ) );
714 ogrString.append(
"mm" );
715 ogrString.append(
")" );
723 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
724 if ( graphicElem.isNull() )
727 QString
name =
"square";
729 double borderWidth,
size;
730 Qt::PenStyle borderStyle;
740 double d = angleFunc.toDouble( &ok );
765 p->drawPath(
mPath );
775 bool hasDataDefinedSize =
false;
782 if ( hasDataDefinedSize )
784 if ( sizeExpression )
786 size = sizeExpression->
evaluate( const_cast<QgsFeature*>( context->
feature() ) ).toDouble();
802 size *= mmMapUnitScaleFactor;
804 double halfSize = size / 2.0;
809 if ( outlineWidthExpression )
811 outlineWidth = outlineWidthExpression->
evaluate( const_cast<QgsFeature*>( context->
feature() ) ).toDouble();
815 outlineWidth *= mmMapUnitScaleFactor;
819 QColor c =
mPen.color();
820 if (
mPen.style() == Qt::NoPen )
825 if ( colorExpression )
829 int colorIndex = QgsDxfExport::closestColorMatch( c.rgb() );
835 QPointF off( offsetX, offsetY );
840 if ( angleExpression )
842 angle = angleExpression->
evaluate( const_cast<QgsFeature*>( context->
feature() ) ).toDouble();
850 off *= mmMapUnitScaleFactor;
854 t.translate( shift.x() + offsetX, shift.y() + offsetY );
861 if (
mName ==
"circle" )
863 e.writeGroup( 0,
"CIRCLE" );
864 e.writeGroup( 8, layerName );
866 e.writeGroup( 62, colorIndex );
867 e.writeGroup( 10, shift.x() );
868 e.writeGroup( 20, shift.y() );
869 e.writeGroup( 30, 0.0 );
870 e.writeGroup( 40, halfSize );
872 else if (
mName ==
"square" ||
mName ==
"rectangle" )
874 QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
875 QPointF pt2 = t.map( QPointF( halfSize, -halfSize ) );
876 QPointF pt3 = t.map( QPointF( -halfSize, halfSize ) );
877 QPointF pt4 = t.map( QPointF( halfSize, halfSize ) );
878 e.writeSolid( layerName, colorIndex,
QgsPoint( pt1.x(), pt1.y() ),
QgsPoint( pt2.x(), pt2.y() ),
QgsPoint( pt3.x(), pt3.y() ),
QgsPoint( pt4.x(), pt4.y() ) );
880 else if (
mName ==
"diamond" )
882 QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
883 QPointF pt2 = t.map( QPointF( 0, -halfSize ) );
884 QPointF pt3 = t.map( QPointF( 0, halfSize ) );
885 QPointF pt4 = t.map( QPointF( halfSize, 0 ) );
886 e.writeSolid( layerName, colorIndex,
QgsPoint( pt1.x(), pt1.y() ),
QgsPoint( pt2.x(), pt2.y() ),
QgsPoint( pt3.x(), pt3.y() ),
QgsPoint( pt4.x(), pt4.y() ) );
888 else if (
mName ==
"triangle" )
890 QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
891 QPointF pt2 = t.map( QPointF( halfSize, -halfSize ) );
892 QPointF pt3 = t.map( QPointF( 0, halfSize ) );
893 e.writeSolid( layerName, colorIndex,
QgsPoint( pt1.x(), pt1.y() ),
QgsPoint( pt2.x(), pt2.y() ),
QgsPoint( pt3.x(), pt3.y() ),
QgsPoint( pt3.x(), pt3.y() ) );
899 else if (
mName ==
"line" )
901 QPointF pt1 = t.map( QPointF( 0, halfSize ) );
902 QPointF pt2 = t.map( QPointF( 0, -halfSize ) );
903 e.writeLine(
QgsPoint( pt1.x(), pt1.y() ),
QgsPoint( pt2.x(), pt2.y() ), layerName,
"CONTINUOUS", colorIndex, outlineWidth );
905 else if (
mName ==
"coss" )
907 QPointF pt1 = t.map( QPointF( -halfSize, 0 ) );
908 QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
909 QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
910 QPointF pt4 = t.map( QPointF( 0, halfSize ) );
911 e.writeLine(
QgsPoint( pt1.x(), pt1.y() ),
QgsPoint( pt2.x(), pt2.y() ), layerName,
"CONTINUOUS", colorIndex, outlineWidth );
912 e.writeLine(
QgsPoint( pt3.x(), pt3.y() ),
QgsPoint( pt4.x(), pt4.y() ), layerName,
"CONTINUOUS", colorIndex, outlineWidth );
916 QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
917 QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
918 QPointF pt3 = t.map( QPointF( -halfSize, halfSize ) );
919 QPointF pt4 = t.map( QPointF( halfSize, -halfSize ) );
920 e.writeLine(
QgsPoint( pt1.x(), pt1.y() ),
QgsPoint( pt2.x(), pt2.y() ), layerName,
"CONTINUOUS", colorIndex, outlineWidth );
921 e.writeLine(
QgsPoint( pt3.x(), pt3.y() ),
QgsPoint( pt4.x(), pt4.y() ), layerName,
"CONTINUOUS", colorIndex, outlineWidth );
923 else if (
mName ==
"arrowhead" )
925 QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
926 QPointF pt2 = t.map( QPointF( 0, 0 ) );
927 QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
928 e.writeLine(
QgsPoint( pt1.x(), pt1.y() ),
QgsPoint( pt2.x(), pt2.y() ), layerName,
"CONTINUOUS", colorIndex, outlineWidth );
929 e.writeLine(
QgsPoint( pt3.x(), pt3.y() ),
QgsPoint( pt2.x(), pt2.y() ), layerName,
"CONTINUOUS", colorIndex, outlineWidth );
931 else if (
mName ==
"filled_arrowhead" )
933 QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
934 QPointF pt2 = t.map( QPointF( 0, 0 ) );
935 QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
936 e.writeSolid( layerName, colorIndex,
QgsPoint( pt1.x(), pt1.y() ),
QgsPoint( pt2.x(), pt2.y() ),
QgsPoint( pt3.x(), pt3.y() ),
QgsPoint( pt3.x(), pt3.y() ) );
1000 if ( props.contains(
"name" ) )
1001 name = props[
"name"];
1002 if ( props.contains(
"size" ) )
1003 size = props[
"size"].toDouble();
1004 if ( props.contains(
"angle" ) )
1005 angle = props[
"angle"].toDouble();
1006 if ( props.contains(
"scale_method" ) )
1012 if ( !props.contains(
"fill" ) && !props.contains(
"outline" ) && !props.contains(
"outline-width" ) )
1016 bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1022 if ( hasOutlineParam )
1026 if ( hasOutlineWidthParam )
1032 if ( props.contains(
"size_unit" ) )
1034 if ( props.contains(
"size_map_unit_scale" ) )
1036 if ( props.contains(
"offset" ) )
1038 if ( props.contains(
"offset_unit" ) )
1040 if ( props.contains(
"offset_map_unit_scale" ) )
1042 if ( props.contains(
"fill" ) )
1044 if ( props.contains(
"outline" ) )
1046 if ( props.contains(
"outline-width" ) )
1048 if ( props.contains(
"outline_width_unit" ) )
1050 if ( props.contains(
"outline_width_map_unit_scale" ) )
1053 if ( props.contains(
"horizontal_anchor_point" ) )
1057 if ( props.contains(
"vertical_anchor_point" ) )
1063 if ( props.contains(
"size_expression" ) )
1067 if ( props.contains(
"outline-width_expression" ) )
1071 if ( props.contains(
"angle_expression" ) )
1075 if ( props.contains(
"offset_expression" ) )
1079 if ( props.contains(
"name_expression" ) )
1083 if ( props.contains(
"fill_expression" ) )
1087 if ( props.contains(
"outline_expression" ) )
1091 if ( props.contains(
"horizontal_anchor_point_expression" ) )
1095 if ( props.contains(
"vertical_anchor_point_expression" ) )
1107 bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
1113 if ( hasOutlineParam )
1117 if ( hasOutlineWidthParam )
1133 Q_UNUSED( context );
1139 Q_UNUSED( context );
1148 double scaledSize =
mSize;
1153 if ( sizeExpression )
1155 scaledSize = sizeExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
1158 if ( hasDataDefinedSize )
1163 scaledSize = sqrt( scaledSize );
1173 if ((
int )size < 1 || 10000.0 <
size )
1183 markerOffset( context, scaledSize, scaledSize, offsetX, offsetY );
1184 QPointF outputOffset( offsetX, offsetY );
1188 if ( angleExpression )
1190 angle = angleExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
1194 p->translate( point + outputOffset );
1202 if ( nameExpression )
1204 path = nameExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
1209 if ( outlineWidthExpression )
1211 outlineWidth = outlineWidthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
1216 if ( fillExpression )
1223 if ( outlineExpression )
1229 bool fitsInCache =
true;
1230 bool usePict =
true;
1231 double hwRatio = 1.0;
1237 if ( fitsInCache && img.width() > 1 )
1242 QImage transparentImage = img.copy();
1244 p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
1245 hwRatio = ( double )transparentImage.height() / ( double )transparentImage.width();
1249 p->drawImage( -img.width() / 2.0, -img.height() / 2.0, img );
1250 hwRatio = ( double )img.height() / ( double )img.width();
1255 if ( usePict || !fitsInCache )
1257 p->setOpacity( context.
alpha() );
1261 if ( pct.width() > 1 )
1265 p->drawPicture( 0, 0, pct );
1267 hwRatio = ( double )pct.height() / ( double )pct.width();
1275 if ( penWidth > size / 20 )
1278 penWidth = size / 20;
1280 double penOffset = penWidth / 2;
1281 pen.setWidth( penWidth );
1283 p->setBrush( Qt::NoBrush );
1284 double wSize = size + penOffset;
1285 double hSize = size * hwRatio + penOffset;
1286 p->drawRect( QRectF( -wSize / 2.0, -hSize / 2.0, wSize, hSize ) );
1297 map[
"size"] = QString::number(
mSize );
1300 map[
"angle"] = QString::number(
mAngle );
1370 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
1371 element.appendChild( graphicElem );
1378 double angle = props.value(
"angle",
"0" ).toDouble( &ok );
1381 angleFunc = QString(
"%1 + %2" ).arg( props.value(
"angle",
"0" ) ).arg(
mAngle );
1383 else if ( angle +
mAngle != 0 )
1385 angleFunc = QString::number( angle +
mAngle );
1398 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1399 if ( graphicElem.isNull() )
1402 QString
path, mimeType;
1409 if ( mimeType !=
"image/svg+xml" )
1417 double d = angleFunc.toDouble( &ok );
1435 const QPointF& shift )
const
1437 Q_UNUSED( layerName );
1440 QSvgRenderer r(
mPath );
1446 QgsDxfPaintDevice pd( &e );
1447 pd.setDrawingSize( QSizeF( r.defaultSize() ) );
1454 if ( sizeExpression )
1456 size = sizeExpression->
evaluate( *f ).toDouble();
1459 if ( hasDataDefinedSize )
1464 size = sqrt( size );
1473 size *= mmMapUnitScaleFactor;
1476 double halfSize = size / 2.0;
1481 if ( offsetExpression )
1483 QString offsetString = offsetExpression->
evaluate( *f ).toString();
1486 double offsetX = offset.x();
1487 double offsetY = offset.y();
1490 offsetX *= mmMapUnitScaleFactor;
1491 offsetY *= mmMapUnitScaleFactor;
1494 QPointF outputOffset( offsetX, offsetY );
1498 if ( angleExpression )
1500 angle = angleExpression->
evaluate( *f ).toDouble();
1510 p.translate( r.defaultSize().width() / 2.0, r.defaultSize().height() / 2.0 );
1512 p.translate( -r.defaultSize().width() / 2.0, -r.defaultSize().height() / 2.0 );
1514 pd.setShift( shift );
1515 pd.setOutputSize( QRectF( -halfSize, -halfSize, size, size ) );
1516 pd.setLayer( layerName );
1544 if ( props.contains(
"font" ) )
1545 fontFamily = props[
"font"];
1546 if ( props.contains(
"chr" ) && props[
"chr"].length() > 0 )
1547 chr = props[
"chr"].at( 0 );
1548 if ( props.contains(
"size" ) )
1549 pointSize = props[
"size"].toDouble();
1550 if ( props.contains(
"color" ) )
1552 if ( props.contains(
"angle" ) )
1553 angle = props[
"angle"].toDouble();
1556 if ( props.contains(
"offset" ) )
1558 if ( props.contains(
"offset_unit" ) )
1560 if ( props.contains(
"offset_map_unit_scale" ) )
1562 if ( props.contains(
"size_unit" ) )
1564 if ( props.contains(
"size_map_unit_scale" ) )
1566 if ( props.contains(
"horizontal_anchor_point" ) )
1570 if ( props.contains(
"vertical_anchor_point" ) )
1579 return "FontMarker";
1586 QFontMetrics fm(
mFont );
1594 Q_UNUSED( context );
1604 penColor.setAlphaF(
mColor.alphaF() * context.
alpha() );
1605 p->setPen( penColor );
1606 p->setFont(
mFont );
1613 QPointF outputOffset( offsetX, offsetY );
1616 p->translate( point + outputOffset );
1635 props[
"chr"] =
mChr;
1636 props[
"size"] = QString::number(
mSize );
1640 props[
"angle"] = QString::number(
mAngle );
1665 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
1666 element.appendChild( graphicElem );
1668 QString fontPath = QString(
"ttf://%1" ).arg(
mFontFamily );
1669 int markIndex =
mChr.unicode();
1675 double angle = props.value(
"angle",
"0" ).toDouble( &ok );
1678 angleFunc = QString(
"%1 + %2" ).arg( props.value(
"angle",
"0" ) ).arg(
mAngle );
1680 else if ( angle +
mAngle != 0 )
1682 angleFunc = QString::number( angle +
mAngle );
1694 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
1695 if ( graphicElem.isNull() )
1698 QString name, format;
1706 if ( !name.startsWith(
"ttf://" ) || format !=
"ttf" )
1716 double d = angleFunc.toDouble( &ok );
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
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)
QgsSymbolLayerV2 * clone() const
double outlineWidth() const
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
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()
QgsSymbolV2::OutputUnit outputUnit() const
static Q_DECL_DEPRECATED bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &borderColor, double &borderWidth, double &size)
void startRender(QgsSymbolV2RenderContext &context)
void setMapUnitScale(const QgsMapUnitScale &scale)
#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
Added in QGIS v2.0.
QgsSymbolV2::OutputUnit mOutlineWidthUnit
#define DEFAULT_SIMPLEMARKER_ANGLE
void startRender(QgsSymbolV2RenderContext &context)
void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)
QString layerType() const
void writeSldMarker(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
void setFillColor(const QColor &c)
Set fill color.
static void createRotationElement(QDomDocument &doc, QDomElement &element, QString rotationFunc)
double rendererScale() const
void stopRender(QgsSymbolV2RenderContext &context)
#define DEFAULT_FONTMARKER_CHR
void setMapUnitScale(const QgsMapUnitScale &scale)
void setOffset(QPointF offset)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
QgsMapUnitScale mapUnitScale() const
void setOutlineWidth(double w)
#define DEFAULT_SIMPLEMARKER_COLOR
static QPointF decodePoint(QString str)
void setVerticalAnchorPoint(VerticalAnchorPoint v)
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
static QColor decodeColor(QString str)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
void setOutlineWidth(double w)
double scaleFactor() const
void writeSldMarker(QDomDocument &doc, QDomElement &element, QgsStringMap props) 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 setOutputUnit(QgsSymbolV2::OutputUnit unit)
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
QMap< QString, QString > QgsStringMap
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
#define DEFAULT_SVGMARKER_ANGLE
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
void startRender(QgsSymbolV2RenderContext &context)
void setMapUnitScale(const QgsMapUnitScale &scale)
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)
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)
static QString symbolPathToName(QString path)
Get symbols's name from its path.
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit u)
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
const QgsFeature * feature() const
Current feature being rendered - may be null.
static QString encodePoint(QPointF point)
QColor fillColor() const
Get fill color.
static Qt::PenStyle decodePenStyle(QString str)
#define DEFAULT_SCALE_METHOD
Qt::PenStyle mOutlineStyle
QString fontFamily() const
double outlineWidth() const
QgsSymbolV2::ScaleMethod mScaleMethod
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
bool forceVectorOutput() const
void setSizeUnit(QgsSymbolV2::OutputUnit unit)
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
void startRender(QgsSymbolV2RenderContext &context)
void setPath(QString path)
double rasterScaleFactor() const
#define DEFAULT_FONTMARKER_ANGLE
QgsMapUnitScale mOutlineWidthMapUnitScale
virtual QColor color() const
QgsStringMap properties() const
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
virtual void prepareExpressions(const QgsFields *fields, double scale=-1.0)
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
A class to represent a point geometry.
QgsSymbolV2::ScaleMethod scaleMethod() const
QgsMapUnitScale mapUnitScale() 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)
QgsSymbolLayerV2 * clone() const
QString layerType() const
void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)
void writeSldMarker(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, const QgsSymbolV2RenderContext *context, const QgsFeature *f, const QPointF &shift=QPointF(0.0, 0.0)) const
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
QColor outlineColor() const
Get outline color.
#define DEFAULT_FONTMARKER_SIZE
#define DEFAULT_FONTMARKER_FONT
QString layerType() const
#define DEFAULT_SVGMARKER_NAME
QgsExpression * mAngleExpression
#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.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void stopRender(QgsSymbolV2RenderContext &context)
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 QString encodeScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QgsRenderContext & renderContext()
bool preparePath(QString name=QString())
QgsStringMap properties() const
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, QString path, QString mime, QColor color, double size=-1)
QgsMapUnitScale mapUnitScale() const
QgsSymbolV2::OutputUnit outputUnit() const
static Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, QString name, QColor color, QColor borderColor=QColor(), double borderWidth=-1, double size=-1)
QgsStringMap properties() const
const QgsFields * fields() const
Fields of the layer.
QgsSymbolV2::OutputUnit mOffsetUnit
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
QgsSymbolLayerV2 * clone() const
QgsSymbolV2::OutputUnit outputUnit() const
static QgsSymbolV2::ScaleMethod decodeScaleMethod(QString str)
VerticalAnchorPoint mVerticalAnchorPoint
bool prepareShape(QString name=QString())
QgsSymbolV2::OutputUnit mSizeUnit
QgsExpression * mNameExpression
QgsMapUnitScale mOffsetMapUnitScale
void setOutlineColor(const QColor &c)
Set outline color.
void stopRender(QgsSymbolV2RenderContext &context)
void markerOffset(const QgsSymbolV2RenderContext &context, double &offsetX, double &offsetY) const
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
void setAngle(double angle)
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, const QgsSymbolV2RenderContext *context, const QgsFeature *f, const QPointF &shift=QPointF(0.0, 0.0)) const
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void saveDataDefinedProperties(QgsStringMap &stringMap) const
Saves data defined properties to string map.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
bool prepareCache(QgsSymbolV2RenderContext &context)
Prepares cache image.
static QgsSymbolV2::OutputUnit decodeOutputUnit(QString str)
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 renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)
virtual void setDataDefinedProperty(const QString &property, const QString &expressionString)
static QPointF _rotatedOffset(const QPointF &offset, double angle)
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR