34 #include <QDomDocument> 36 #include <QDomElement> 51 if ( lst.
count() < 3 )
55 int red, green, blue, alpha;
57 green = lst[1].toInt();
58 blue = lst[2].toInt();
60 if ( lst.
count() > 3 )
62 alpha = lst[3].toInt();
64 return QColor( red, green, blue, alpha );
76 if ( !ok || alpha > 1 )
87 case QFont::StyleNormal:
89 case QFont::StyleItalic:
91 case QFont::StyleOblique:
100 if ( str ==
"normal" )
return QFont::StyleNormal;
101 if ( str ==
"italic" )
return QFont::StyleItalic;
102 if ( str ==
"oblique" )
return QFont::StyleOblique;
103 return QFont::StyleNormal;
108 if ( weight == 50 )
return "normal";
109 if ( weight == 75 )
return "bold";
113 if ( weight < 0 )
return "100";
114 if ( weight > 99 )
return "900";
121 int weight = str.
toInt( &ok );
123 return static_cast< int >( QFont::Normal );
127 if ( weight > 900 )
return 99;
128 if ( weight < 100 )
return 0;
129 return ( weight - 100 ) * 99 / 800;
144 case Qt::DashDotLine:
146 case Qt::DashDotDotLine:
147 return "dash dot dot";
155 if ( str ==
"no" )
return Qt::NoPen;
156 if ( str ==
"solid" )
return Qt::SolidLine;
157 if ( str ==
"dash" )
return Qt::DashLine;
158 if ( str ==
"dot" )
return Qt::DotLine;
159 if ( str ==
"dash dot" )
return Qt::DashDotLine;
160 if ( str ==
"dash dot dot" )
return Qt::DashDotDotLine;
161 return Qt::SolidLine;
181 if ( str ==
"bevel" )
return Qt::BevelJoin;
182 if ( str ==
"miter" )
return Qt::MiterJoin;
183 if ( str ==
"round" )
return Qt::RoundJoin;
184 return Qt::BevelJoin;
204 if ( str ==
"bevel" )
return Qt::BevelJoin;
205 if ( str ==
"mitre" )
return Qt::MiterJoin;
206 if ( str ==
"round" )
return Qt::RoundJoin;
207 return Qt::BevelJoin;
227 if ( str ==
"square" )
return Qt::SquareCap;
228 if ( str ==
"flat" )
return Qt::FlatCap;
229 if ( str ==
"round" )
return Qt::RoundCap;
230 return Qt::SquareCap;
250 if ( str ==
"square" )
return Qt::SquareCap;
251 if ( str ==
"butt" )
return Qt::FlatCap;
252 if ( str ==
"round" )
return Qt::RoundCap;
253 return Qt::SquareCap;
260 case Qt::SolidPattern :
262 case Qt::HorPattern :
264 case Qt::VerPattern :
266 case Qt::CrossPattern :
268 case Qt::BDiagPattern :
270 case Qt::FDiagPattern :
272 case Qt::DiagCrossPattern :
274 case Qt::Dense1Pattern :
276 case Qt::Dense2Pattern :
278 case Qt::Dense3Pattern :
280 case Qt::Dense4Pattern :
282 case Qt::Dense5Pattern :
284 case Qt::Dense6Pattern :
286 case Qt::Dense7Pattern :
297 if ( str ==
"solid" )
return Qt::SolidPattern;
298 if ( str ==
"horizontal" )
return Qt::HorPattern;
299 if ( str ==
"vertical" )
return Qt::VerPattern;
300 if ( str ==
"cross" )
return Qt::CrossPattern;
301 if ( str ==
"b_diagonal" )
return Qt::BDiagPattern;
302 if ( str ==
"f_diagonal" )
return Qt::FDiagPattern;
303 if ( str ==
"diagonal_x" )
return Qt::DiagCrossPattern;
304 if ( str ==
"dense1" )
return Qt::Dense1Pattern;
305 if ( str ==
"dense2" )
return Qt::Dense2Pattern;
306 if ( str ==
"dense3" )
return Qt::Dense3Pattern;
307 if ( str ==
"dense4" )
return Qt::Dense4Pattern;
308 if ( str ==
"dense5" )
return Qt::Dense5Pattern;
309 if ( str ==
"dense6" )
return Qt::Dense6Pattern;
310 if ( str ==
"dense7" )
return Qt::Dense7Pattern;
311 if ( str ==
"no" )
return Qt::NoBrush;
312 return Qt::SolidPattern;
319 case Qt::CrossPattern:
321 case Qt::DiagCrossPattern:
332 case Qt::BDiagPattern:
334 case Qt::FDiagPattern:
338 case Qt::Dense1Pattern:
339 case Qt::Dense2Pattern:
340 case Qt::Dense3Pattern:
341 case Qt::Dense4Pattern:
342 case Qt::Dense5Pattern:
343 case Qt::Dense6Pattern:
344 case Qt::Dense7Pattern:
354 if ( str ==
"horline" )
return Qt::HorPattern;
355 if ( str ==
"line" )
return Qt::VerPattern;
356 if ( str ==
"cross" )
return Qt::CrossPattern;
357 if ( str ==
"slash" )
return Qt::BDiagPattern;
358 if ( str ==
"backshash" )
return Qt::FDiagPattern;
359 if ( str ==
"x" )
return Qt::DiagCrossPattern;
369 return QString(
"%1,%2" ).
arg( point.
x() ).arg( point.
y() );
375 if ( lst.
count() != 2 )
377 return QPointF( lst[0].toDouble(), lst[1].toDouble() );
392 if ( lst.
count() < 2 )
395 if ( lst.
count() < 6 )
449 *scaleFactor = 0.001;
450 return "http://www.opengeospatial.org/se/units/metre";
466 if ( str ==
"http://www.opengeospatial.org/se/units/metre" )
469 *scaleFactor = 1000.0;
472 else if ( str ==
"http://www.opengeospatial.org/se/units/foot" )
475 *scaleFactor = 304.8;
482 *scaleFactor = 1 / 0.00028;
494 vectorString.
append(
';' );
507 for ( ; it != realList.
constEnd(); ++it )
509 resultVector.
append( it->toDouble() );
523 vectorString.
append(
' ' );
536 for ( ; it != realList.
constEnd(); ++it )
538 resultVector.
append( it->toDouble() );
548 switch ( scaleMethod )
551 encodedValue =
"diameter";
554 encodedValue =
"area";
564 if ( str ==
"diameter" )
578 if ( s.
compare(
"Lighten", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Lighten;
579 if ( s.
compare(
"Screen", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Screen;
580 if ( s.
compare(
"Dodge", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorDodge;
581 if ( s.
compare(
"Addition", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Plus;
582 if ( s.
compare(
"Darken", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Darken;
583 if ( s.
compare(
"Multiply", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Multiply;
584 if ( s.
compare(
"Burn", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorBurn;
585 if ( s.
compare(
"Overlay", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Overlay;
586 if ( s.
compare(
"SoftLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_SoftLight;
587 if ( s.
compare(
"HardLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_HardLight;
588 if ( s.
compare(
"Difference", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Difference;
589 if ( s.
compare(
"Subtract", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Exclusion;
590 return QPainter::CompositionMode_SourceOver;
603 pixmap.
fill( Qt::transparent );
605 painter.
begin( &pixmap );
621 maxBleed = layerMaxBleed > maxBleed ? layerMaxBleed : maxBleed;
631 painter.
begin( &picture );
644 pixmap.
fill( Qt::transparent );
646 painter.
begin( &pixmap );
652 return QIcon( pixmap );
663 pixmap.
fill( Qt::transparent );
666 painter.
begin( &pixmap );
673 for (
int i = 0; i < size.
width(); i++ )
675 QPen pen( ramp->
color( static_cast< double >( i ) / size.
width() ) );
686 uchar pixDataRGB[] = { 255, 255, 255, 255,
691 QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
708 #if !defined(GEOS_VERSION_MAJOR) || !defined(GEOS_VERSION_MINOR) || \ 709 ((GEOS_VERSION_MAJOR<3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR<3))) 713 double x1 = p1.
x(), y1 = p1.
y(), x2 = p2.
x(), y2 = p2.
y();
715 if ( x1 == x2 && y1 == y2 )
719 t = ( x1 == x2 ? DBL_MAX : ( y2 - y1 ) / ( x2 - x1 ) );
723 angle = ( y2 > y1 ?
M_PI / 2 :
M_PI * 3 / 2 );
725 angle = ( x2 > x1 ? 0 :
M_PI );
727 angle = ( y2 > y1 ? atan( t ) :
M_PI + atan( t ) );
729 angle = ( y2 > y1 ?
M_PI + atan( t ) : atan( t ) );
737 return QPointF( pt.
x() + dist * cos( angle ), pt.
y() + dist * sin( angle ) );
744 if (( t1 == DBL_MAX && t2 == DBL_MAX ) || qAbs( atan( t1 ) - atan( t2 ) ) < 0.175 )
748 if ( t1 == DBL_MAX || t2 == DBL_MAX )
767 x = (( p1.
y() - p2.
y() ) + t2 * p2.
x() - t1 * p1.
x() ) / ( t2 - t1 );
770 y = p1.
y() + t1 * ( x - p1.
x() );
776 int i, pointCount = polyline.
count();
779 resultLine.
resize( pointCount );
783 for ( i = 0; i < pointCount; ++i, tempPtr++ )
784 resultLine[i] =
QPointF( tempPtr->
x(), tempPtr->
y() );
792 for (
int ring = 0; ring < polygon.
size(); ++ring )
793 resultGeom.
append( makeOffsetGeometry( polygon[ ring ] ) );
802 if ( polyline.
count() < 2 )
804 resultLine.
append( polyline );
811 #if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \ 812 ((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3))) 814 unsigned int i, pointCount = polyline.
count();
818 for ( i = 0; i < pointCount; ++i, tempPtr++ )
819 tempPolyline[i] =
QgsPoint( tempPtr->
rx(), tempPtr->
ry() );
824 int quadSegments = 0;
825 double mitreLimit = 2.0;
828 offsetGeom = tempGeometry->
buffer( -dist, quadSegments, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, mitreLimit );
830 offsetGeom = tempGeometry->
offsetCurve( dist, quadSegments, GEOSBUF_JOIN_MITRE, mitreLimit );
835 tempGeometry = offsetGeom;
842 if ( dist < 0 ) std::reverse( line.
begin(), line.
end() );
843 resultLine.
append( makeOffsetGeometry( line ) );
857 for (
int part = 0; part < tempMPolyline.
count(); ++part )
859 resultLine.
append( makeOffsetGeometry( tempMPolyline[ part ] ) );
868 for (
int part = 0; part < tempMPolygon.
count(); ++part )
870 resultLine.
append( makeOffsetGeometry( tempMPolygon[ part ] ) );
880 resultLine.
append( polyline );
885 double angle = 0.0, t_new, t_old = 0;
888 bool first_point =
true;
890 for (
int i = 1; i < polyline.
count(); i++ )
894 if ( !
lineInfo( p1, p2, angle, t_new ) )
920 resultLine.
append( newLine );
929 int pointCount = polyline.
count();
931 if ( pointCount > 3 &&
qgsDoubleNear( polyline[ 0 ].x(), polyline[ pointCount - 1 ].x() ) &&
qgsDoubleNear( polyline[ 0 ].y(), polyline[ pointCount - 1 ].y() ) )
935 else if ( pointCount > 1 )
939 return offsetLine( polyline, dist, geometryType );
950 while ( !layerNode.
isNull() )
992 if ( symbolType ==
"line" )
994 else if ( symbolType ==
"fill" )
996 else if ( symbolType ==
"marker" )
1000 QgsDebugMsg(
"unknown symbol type " + symbolType );
1039 if ( !effectElem.
isNull() )
1107 symbolElem.
save( stream, -1 );
1124 if ( symbolizerName ==
"PointSymbolizer" )
1128 if ( graphicElem.
isNull() )
1130 QgsDebugMsg(
"Graphic element not found in PointSymbolizer" );
1166 if ( symbolizerName ==
"LineSymbolizer" )
1170 if ( strokeElem.
isNull() )
1172 QgsDebugMsg(
"Stroke element not found in LineSymbolizer" );
1202 if ( symbolizerName ==
"PolygonSymbolizer" )
1209 QgsDebugMsg(
"neither Fill nor Stroke element not found in PolygonSymbolizer" );
1287 if ( strokeElem.
isNull() )
1306 if ( graphicElem.
isNull() )
1329 if ( graphicElem.
isNull() )
1333 if ( externalGraphicElem.
isNull() )
1338 if ( formatElem.
isNull() )
1342 if ( format !=
"image/svg+xml" )
1344 QgsDebugMsg(
"unsupported External Graphic format found: " + format );
1351 if ( !onlineResourceElem.
isNull() )
1356 else if ( !inlineContentElem.
isNull() )
1370 if ( graphicElem.
isNull() )
1378 if ( wellKnownNameElem.
isNull() )
1388 if ( graphicElem.
isNull() )
1397 if ( formatElem.
isNull() )
1401 if ( format !=
"ttf" )
1403 QgsDebugMsg(
"unsupported Graphic Mark format found: " + format );
1410 if ( !onlineResourceElem.
isNull() )
1414 if ( !markIndexElem.
isNull() )
1417 else if ( !inlineContentElem.
isNull() )
1433 if ( graphicElem.
isNull() )
1439 if ( it.key() ==
"widthHeightFactor" )
1451 if ( strokeElem.
isNull() )
1455 if ( graphicStrokeElem.
isNull() )
1468 if ( graphicFillElem.
isNull() )
1472 if ( graphicElem.
isNull() )
1478 QColor fillColor, borderColor;
1479 double size, borderWidth;
1480 Qt::PenStyle borderStyle;
1481 if ( !
wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderStyle, borderWidth, size ) )
1484 if ( name !=
"horline" )
1501 Q_UNUSED( element );
1512 if ( graphicFillElem.
isNull() )
1537 bool validFill =
false, validBorder =
false;
1542 Qt::BrushStyle fillStyle;
1544 if (
fillFromSld( fillElem, fillStyle, fillColor ) )
1550 Qt::PenStyle borderStyle;
1551 double borderWidth = 1.0, dashOffset = 0.0;
1554 if (
lineFromSld( strokeElem, borderStyle, borderColor, borderWidth,
1555 nullptr,
nullptr, &customDashPattern, &dashOffset ) )
1558 if ( validFill || validBorder )
1561 map[
"name"] =
"square";
1562 map[
"color"] =
encodeColor( validFill ? fillColor : Qt::transparent );
1563 map[
"color_border"] =
encodeColor( validBorder ? borderColor : Qt::transparent );
1573 bool validFill =
false, validBorder =
false;
1578 QColor fillColor, borderColor;
1579 double borderWidth = 1.0, size = 0.0,
angle = 0.0;
1584 if ( !graphicFillElem.
isNull() )
1588 if ( !graphicElem.
isNull() )
1595 while ( !graphicChildElem.
isNull() )
1597 if ( graphicChildElem.
localName() ==
"Mark" )
1601 if ( !wellKnownNameElem.
isNull() )
1609 if ( graphicChildElem.
localName() ==
"ExternalGraphic" || graphicChildElem.
localName() ==
"Mark" )
1613 if ( formatElem.
isNull() )
1620 if ( graphicChildElem.
localName() ==
"ExternalGraphic" && format !=
"image/svg+xml" )
1625 if ( graphicChildElem.
localName() ==
"Mark" && format !=
"ttf" )
1632 if ( !onlineResourceElem.
isNull() )
1634 name = onlineResourceElem.
attributeNS(
"http://www.w3.org/1999/xlink",
"href" );
1636 if ( graphicChildElem.
localName() ==
"Mark" && format ==
"ttf" )
1640 name = name.
mid( 6 );
1644 if ( markIndexElem.
isNull() )
1659 else if ( !inlineContentElem.
isNull() )
1669 if ( graphicChildElem.
localName() ==
"Mark" )
1678 if ( found && graphicChildElem.
localName() ==
"Mark" )
1685 Qt::BrushStyle markFillStyle;
1688 if (
fillFromSld( markFillElem, markFillStyle, fillColor ) )
1693 Qt::PenStyle borderStyle;
1694 double borderWidth = 1.0, dashOffset = 0.0;
1698 if (
lineFromSld( markStrokeElem, borderStyle, borderColor, borderWidth,
1699 nullptr,
nullptr, &customDashPattern, &dashOffset ) )
1707 if ( !opacityElem.
isNull() )
1711 if ( !sizeElem.
isNull() )
1723 double v = angleFunc.
toDouble( &ok );
1733 if ( validFill || validBorder )
1735 if ( format ==
"image/svg+xml" )
1739 map[
"fill"] = fillColor.
name();
1740 map[
"outline"] = borderColor.
name();
1750 else if ( format ==
"ttf" )
1754 map[
"chr"] = markIndex;
1755 map[
"color"] =
encodeColor( validFill ? fillColor : Qt::transparent );
1770 layerList << layers;
1778 switch ( brushStyle )
1783 case Qt::SolidPattern:
1787 if ( color.
alpha() < 255 )
1792 case Qt::CrossPattern:
1793 case Qt::DiagCrossPattern:
1794 case Qt::HorPattern:
1795 case Qt::VerPattern:
1796 case Qt::BDiagPattern:
1797 case Qt::FDiagPattern:
1798 case Qt::Dense1Pattern:
1799 case Qt::Dense2Pattern:
1800 case Qt::Dense3Pattern:
1801 case Qt::Dense4Pattern:
1802 case Qt::Dense5Pattern:
1803 case Qt::Dense6Pattern:
1804 case Qt::Dense7Pattern:
1823 wellKnownMarkerToSld( doc, graphicElem, patternName, fillColor, borderColor, Qt::SolidLine, -1, -1 );
1830 brushStyle = Qt::SolidPattern;
1831 color =
QColor(
"#808080" );
1835 brushStyle = Qt::NoBrush;
1842 if ( graphicFillElem.
isNull() )
1849 if ( it.key() ==
"fill" )
1850 color =
QColor( it.value() );
1851 else if ( it.key() ==
"fill-opacity" )
1858 if ( graphicElem.
isNull() )
1861 QString patternName =
"square";
1862 QColor fillColor, borderColor;
1863 double borderWidth, size;
1864 Qt::PenStyle borderStyle;
1865 if ( !
wellKnownMarkerFromSld( graphicElem, patternName, fillColor, borderColor, borderStyle, borderWidth, size ) )
1869 if ( brushStyle == Qt::NoBrush )
1881 Qt::PenStyle penStyle,
const QColor& color,
double width,
1882 const Qt::PenJoinStyle *penJoinStyle,
const Qt::PenCapStyle *penCapStyle,
1888 if ( penStyle == Qt::CustomDashLine && !customDashPattern )
1890 element.
appendChild( doc.
createComment(
"WARNING: Custom dash pattern required but not provided. Using default dash pattern." ) );
1891 penStyle = Qt::DashLine;
1910 case Qt::DashDotLine:
1916 case Qt::DashDotDotLine:
1925 case Qt::CustomDashLine:
1926 Q_ASSERT( customDashPattern );
1927 pattern = customDashPattern;
1938 if ( color.
alpha() < 255 )
1958 Qt::PenStyle &penStyle,
QColor &color,
double &width,
1959 Qt::PenJoinStyle *penJoinStyle, Qt::PenCapStyle *penCapStyle,
1964 penStyle = Qt::SolidLine;
1965 color =
QColor(
"#000000" );
1968 *penJoinStyle = Qt::BevelJoin;
1970 *penCapStyle = Qt::SquareCap;
1971 if ( customDashPattern )
1972 customDashPattern->
clear();
1978 penStyle = Qt::NoPen;
1988 if ( it.key() ==
"stroke" )
1990 color =
QColor( it.value() );
1992 else if ( it.key() ==
"stroke-opacity" )
1996 else if ( it.key() ==
"stroke-width" )
1999 double w = it.value().toDouble( &ok );
2003 else if ( it.key() ==
"stroke-linejoin" && penJoinStyle )
2007 else if ( it.key() ==
"stroke-linecap" && penCapStyle )
2011 else if ( it.key() ==
"stroke-dasharray" )
2018 bool dashPatternFound =
false;
2020 if ( dashPattern.
count() == 2 )
2022 if ( dashPattern.
at( 0 ) == 4.0 &&
2023 dashPattern.
at( 1 ) == 2.0 )
2025 penStyle = Qt::DashLine;
2026 dashPatternFound =
true;
2028 else if ( dashPattern.
at( 0 ) == 1.0 &&
2029 dashPattern.
at( 1 ) == 2.0 )
2031 penStyle = Qt::DotLine;
2032 dashPatternFound =
true;
2035 else if ( dashPattern.
count() == 4 )
2037 if ( dashPattern.
at( 0 ) == 4.0 &&
2038 dashPattern.
at( 1 ) == 2.0 &&
2039 dashPattern.
at( 2 ) == 1.0 &&
2040 dashPattern.
at( 3 ) == 2.0 )
2042 penStyle = Qt::DashDotLine;
2043 dashPatternFound =
true;
2046 else if ( dashPattern.
count() == 6 )
2048 if ( dashPattern.
at( 0 ) == 4.0 &&
2049 dashPattern.
at( 1 ) == 2.0 &&
2050 dashPattern.
at( 2 ) == 1.0 &&
2051 dashPattern.
at( 3 ) == 2.0 &&
2052 dashPattern.
at( 4 ) == 1.0 &&
2053 dashPattern.
at( 5 ) == 2.0 )
2055 penStyle = Qt::DashDotDotLine;
2056 dashPatternFound =
true;
2061 if ( !dashPatternFound )
2063 if ( customDashPattern )
2065 penStyle = Qt::CustomDashLine;
2066 *customDashPattern = dashPattern;
2070 QgsDebugMsg(
"custom dash pattern required but not provided. Using default dash pattern." );
2071 penStyle = Qt::DashLine;
2076 else if ( it.key() ==
"stroke-dashoffset" && dashOffset )
2079 double d = it.value().toDouble( &ok );
2090 const QColor& color,
double size )
2110 QColor &color,
double &size )
2116 if ( externalGraphicElem.
isNull() )
2122 if ( !sizeElem.
isNull() )
2135 const QColor& color,
double size )
2151 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2165 QColor &color,
double &size )
2180 if ( !markIndexElem.
isNull() )
2190 Qt::BrushStyle b = Qt::SolidPattern;
2196 if ( !sizeElem.
isNull() )
2209 double borderWidth,
double size )
2211 wellKnownMarkerToSld( doc, element, name, color, borderColor, Qt::SolidLine, borderWidth, size );
2215 const QString& name,
const QColor& color,
const QColor& borderColor, Qt::PenStyle borderStyle,
2216 double borderWidth,
double size )
2229 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2237 lineToSld( doc, strokeElem, borderStyle, borderColor, borderWidth );
2252 double &borderWidth,
double &size )
2254 Qt::PenStyle borderStyle;
2260 double &borderWidth,
double &size )
2266 borderColor =
QColor(
"#000000" );
2275 if ( !wellKnownNameElem.
isNull() )
2278 QgsDebugMsg(
"found Mark with well known name: " + name );
2283 Qt::BrushStyle b = Qt::SolidPattern;
2289 lineFromSld( strokeElem, borderStyle, borderColor, borderWidth );
2294 if ( !sizeElem.
isNull() )
2307 if ( !rotationFunc.
isEmpty() )
2318 if ( !rotationElem.
isNull() )
2339 if ( !opacityElem.
isNull() )
2369 if ( displacementElem.
isNull() )
2373 if ( !dispXElem.
isNull() )
2378 offset.
setX( offsetX );
2382 if ( !dispYElem.
isNull() )
2387 offset.
setY( offsetY );
2395 const QColor& color,
double size )
2415 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2421 Qt::PenJoinStyle joinStyle,
2422 Qt::PenCapStyle capStyle,
2427 penStyle.
append(
"PEN(" );
2430 penStyle.
append(
",w:" );
2436 if ( dashPattern && !dashPattern->
isEmpty() )
2438 penStyle.
append(
",p:\"" );
2440 for ( ; pIt != dashPattern->
constEnd(); ++pIt )
2453 penStyle.
append(
",cap:" );
2468 penStyle.
append(
",j:" );
2469 switch ( joinStyle )
2485 penStyle.
append(
",dp:" );
2497 brushStyle.
append(
"BRUSH(" );
2498 brushStyle.
append(
"fc:" );
2500 brushStyle.
append(
')' );
2541 if ( geometryElem.
isNull() )
2557 if ( !filterElem.
isNull() )
2565 if ( element.
tagName() !=
"Filter" )
2604 onlineResourceElem.
setAttribute(
"xlink:type",
"simple" );
2618 if ( onlineResourceElem.
isNull() )
2621 path = onlineResourceElem.
attributeNS(
"http://www.w3.org/1999/xlink",
"href" );
2624 if ( formatElem.
isNull() )
2645 while ( !paramElem.
isNull() )
2647 if ( paramElem.
localName() ==
"SvgParameter" || paramElem.
localName() ==
"CssParameter" )
2653 params[ name ] = value;
2675 while ( !paramElem.
isNull() )
2681 params[ name ] = value;
2704 props[propKey] = propValue;
2732 if ( e.
tagName() ==
"symbol" )
2753 if ( it.key()[0] !=
'@' )
2757 subsymbols.
append( it.key() );
2760 if ( parts.
count() < 3 )
2762 QgsDebugMsg(
"found subsymbol with invalid name: " + it.key() );
2767 int symlayer = parts[2].toInt();
2769 if ( !symbols.
contains( symname ) )
2771 QgsDebugMsg(
"subsymbol references invalid symbol: " + symname );
2788 QgsDebugMsg(
"symbol layer refused subsymbol: " + it.key() );
2795 for (
int i = 0; i < subsymbols.
count(); i++ )
2796 symbols.
take( subsymbols[i] );
2817 qDeleteAll( symbols );
2829 if ( rampType ==
"gradient" )
2831 else if ( rampType ==
"random" )
2833 else if ( rampType ==
"colorbrewer" )
2835 else if ( rampType ==
"cpt-city" )
2839 QgsDebugMsg(
"unknown colorramp type " + rampType );
2864 return color.
name();
2874 for ( ; it != components.
end(); ++it )
2882 if ( colors.
length() > 0 )
2889 it = components.
begin();
2890 for ( ; it != components.
end(); ++it )
2898 if ( colors.
length() > 0 )
2905 it = components.
begin();
2906 for ( ; it != components.
end(); ++it )
2914 if ( colors.
length() > 0 )
2920 components = colorStr.
split(
'\n' );
2921 it = components.
begin();
2922 for ( ; it != components.
end(); ++it )
2979 if ( dragDataElem.
tagName() ==
"ColorSchemeModelDragData" )
2982 int nChildNodes = nodeList.
size();
2985 for (
int i = 0; i < nChildNodes; ++i )
2988 if ( currentElem.
isNull() )
2995 namedColor.second = currentElem.
attribute(
"label",
"" );
2997 mimeColors << namedColor;
3002 if ( mimeColors.
length() == 0 && data->
hasFormat(
"application/x-colorobject-list" ) )
3005 QByteArray encodedData = data->
data(
"application/x-colorobject-list" );
3010 if ( colorsNodes.
length() > 0 )
3014 int nChildNodes = colorNodeList.
size();
3017 for (
int i = 0; i < nChildNodes; ++i )
3021 if ( currentElem.
isNull() )
3029 if ( colorNodes.
length() > 0 )
3034 if ( colorParts.
length() < 3 )
3039 int red = colorParts.
at( 0 ).toDouble() * 255;
3040 int green = colorParts.
at( 1 ).toDouble() * 255;
3041 int blue = colorParts.
at( 2 ).toDouble() * 255;
3043 namedColor.first =
QColor( red, green, blue );
3044 if ( nameNodes.
length() > 0 )
3047 namedColor.second = nameElem.
text();
3049 mimeColors << namedColor;
3060 for ( ; it != parsedColors.
end(); ++it )
3062 mimeColors << qMakePair( *it,
QString() );
3072 mimeColors << qMakePair( mimeColor,
QString() );
3088 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
3092 namedColor.
setAttribute(
"label", ( *colorIt ).second );
3105 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
3107 colorListString << ( *colorIt ).
first.name();
3109 mimeData->
setText( colorListString.
join(
"\n" ) );
3112 if ( colorList.
length() > 0 )
3122 if ( !file.
open( QIODevice::ReadWrite ) )
3128 stream <<
"GIMP Palette" << endl;
3131 stream <<
"Name: QGIS Palette" << endl;
3135 stream <<
"Name: " << paletteName << endl;
3137 stream <<
"Columns: 4" << endl;
3138 stream <<
'#' << endl;
3142 QColor color = ( *colorIt ).first;
3148 stream <<
"\t" << (( *colorIt ).second.isEmpty() ? color.
name() : ( *colorIt ).second ) << endl;
3159 if ( !file.
open( QIODevice::ReadOnly ) )
3162 return importedColors;
3171 return importedColors;
3181 QRegExp nameRx(
"Name:\\s*(\\S.*)$" );
3182 if ( nameRx.
indexIn( line ) != -1 )
3184 name = nameRx.
cap( 1 );
3196 return importedColors;
3200 QRegExp rx(
"^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)(\\s.*)?$" );
3201 while ( !in.
atEnd() )
3204 if ( rx.
indexIn( line ) == -1 )
3228 importedColors << qMakePair( color, label );
3233 return importedColors;
3253 containsAlpha =
false;
3259 QRegExp hexColorAlphaRx(
"^\\s*#?([0-9a-fA-F]{6})([0-9a-fA-F]{2})\\s*$" );
3260 if ( hexColorAlphaRx.
indexIn( colorStr ) != -1 )
3265 int alphaHex = hexColorAlphaRx.
cap( 2 ).
toInt( &alphaOk, 16 );
3267 if ( parsedColor.
isValid() && alphaOk )
3270 containsAlpha =
true;
3278 QRegExp hexColorRx2(
"^\\s*(?:[0-9a-fA-F]{3}){1,2}\\s*$" );
3279 if ( hexColorRx2.
indexIn( colorStr ) != -1 )
3285 containsAlpha =
false;
3292 QRegExp rgbFormatRx(
"^\\s*(?:rgb)?\\(?\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*\\)?\\s*;?\\s*$" );
3293 if ( rgbFormatRx.
indexIn( colorStr ) != -1 )
3295 int r = rgbFormatRx.
cap( 1 ).
toInt();
3296 int g = rgbFormatRx.
cap( 2 ).
toInt();
3297 int b = rgbFormatRx.
cap( 3 ).
toInt();
3298 parsedColor.
setRgb( r, g, b );
3301 containsAlpha =
false;
3307 QRegExp rgbPercentFormatRx(
"^\\s*(?:rgb)?\\(?\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(100|0*\\d{1,2})\\s*%\\s*\\)?\\s*;?\\s*$" );
3308 if ( rgbPercentFormatRx.
indexIn( colorStr ) != -1 )
3310 int r = qRound( rgbPercentFormatRx.
cap( 1 ).
toDouble() * 2.55 );
3311 int g = qRound( rgbPercentFormatRx.
cap( 2 ).
toDouble() * 2.55 );
3312 int b = qRound( rgbPercentFormatRx.
cap( 3 ).
toDouble() * 2.55 );
3313 parsedColor.
setRgb( r, g, b );
3316 containsAlpha =
false;
3322 QRegExp rgbaFormatRx(
"^\\s*(?:rgba)?\\(?\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\\s*,\\s*(0|0?\\.\\d*|1(?:\\.0*)?)\\s*\\)?\\s*;?\\s*$" );
3323 if ( rgbaFormatRx.
indexIn( colorStr ) != -1 )
3325 int r = rgbaFormatRx.
cap( 1 ).
toInt();
3326 int g = rgbaFormatRx.
cap( 2 ).
toInt();
3327 int b = rgbaFormatRx.
cap( 3 ).
toInt();
3328 int a = qRound( rgbaFormatRx.
cap( 4 ).
toDouble() * 255.0 );
3329 parsedColor.
setRgb( r, g, b, a );
3332 containsAlpha =
true;
3338 QRegExp rgbaPercentFormatRx(
"^\\s*(?:rgba)?\\(?\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(100|0*\\d{1,2})\\s*%\\s*,\\s*(0|0?\\.\\d*|1(?:\\.0*)?)\\s*\\)?\\s*;?\\s*$" );
3339 if ( rgbaPercentFormatRx.
indexIn( colorStr ) != -1 )
3341 int r = qRound( rgbaPercentFormatRx.
cap( 1 ).
toDouble() * 2.55 );
3342 int g = qRound( rgbaPercentFormatRx.
cap( 2 ).
toDouble() * 2.55 );
3343 int b = qRound( rgbaPercentFormatRx.
cap( 3 ).
toDouble() * 2.55 );
3344 int a = qRound( rgbaPercentFormatRx.
cap( 4 ).
toDouble() * 255.0 );
3345 parsedColor.
setRgb( r, g, b, a );
3348 containsAlpha =
true;
3388 double convertedSize = size * conversionFactor;
3399 return convertedSize;
3474 QImage::Format format = image->
format();
3475 if ( format != QImage::Format_ARGB32_Premultiplied && format != QImage::Format_ARGB32 )
3482 for (
int heightIndex = 0; heightIndex < image->
height(); ++heightIndex )
3484 QRgb* scanLine =
reinterpret_cast< QRgb*
>( image->
scanLine( heightIndex ) );
3485 for (
int widthIndex = 0; widthIndex < image->
width(); ++widthIndex )
3487 myRgb = scanLine[widthIndex];
3488 if ( format == QImage::Format_ARGB32_Premultiplied )
3489 scanLine[widthIndex] = qRgba( alpha * qRed( myRgb ), alpha * qGreen( myRgb ), alpha * qBlue( myRgb ), alpha * qAlpha( myRgb ) );
3491 scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), alpha * qAlpha( myRgb ) );
3499 int tab[] = { 14, 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
3500 int alpha = ( radius < 1 ) ? 16 : ( radius > 17 ) ? 1 : tab[radius-1];
3502 if ( image.
format() != QImage::Format_ARGB32_Premultiplied
3503 && image.
format() != QImage::Format_RGB32 )
3508 int r1 = rect.
top();
3510 int c1 = rect.
left();
3511 int c2 = rect.
right();
3521 i1 = i2 = ( QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3 );
3523 for (
int col = c1; col <= c2; col++ )
3525 p = image.
scanLine( r1 ) + col * 4;
3526 for (
int i = i1; i <= i2; i++ )
3527 rgba[i] = p[i] << 4;
3530 for (
int j = r1; j < r2; j++, p += bpl )
3531 for (
int i = i1; i <= i2; i++ )
3532 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3535 for (
int row = r1; row <= r2; row++ )
3537 p = image.
scanLine( row ) + c1 * 4;
3538 for (
int i = i1; i <= i2; i++ )
3539 rgba[i] = p[i] << 4;
3542 for (
int j = c1; j < c2; j++, p += 4 )
3543 for (
int i = i1; i <= i2; i++ )
3544 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3547 for (
int col = c1; col <= c2; col++ )
3549 p = image.
scanLine( r2 ) + col * 4;
3550 for (
int i = i1; i <= i2; i++ )
3551 rgba[i] = p[i] << 4;
3554 for (
int j = r1; j < r2; j++, p -= bpl )
3555 for (
int i = i1; i <= i2; i++ )
3556 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3559 for (
int row = r1; row <= r2; row++ )
3561 p = image.
scanLine( row ) + c2 * 4;
3562 for (
int i = i1; i <= i2; i++ )
3563 rgba[i] = p[i] << 4;
3566 for (
int j = c1; j < c2; j++, p -= 4 )
3567 for (
int i = i1; i <= i2; i++ )
3568 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3574 if ( alpha != 255 && alpha > 0 )
3578 double alphaFactor = alpha / 255.;
3579 int r = 0, g = 0, b = 0;
3580 rgb.
getRgb( &r, &g, &b );
3585 rgb.
setRgb( r, g, b, alpha );
3587 else if ( alpha == 0 )
3589 rgb.
setRgb( 0, 0, 0, 0 );
3596 switch ( lhs.
type() )
3600 case QVariant::UInt:
3602 case QVariant::LongLong:
3604 case QVariant::ULongLong:
3606 case QVariant::Double:
3608 case QVariant::Char:
3610 case QVariant::Date:
3612 case QVariant::Time:
3614 case QVariant::DateTime:
3621 static bool _QVariantGreaterThan(
const QVariant& lhs,
const QVariant& rhs )
3623 return ! _QVariantLessThan( lhs, rhs );
3629 if ( order == Qt::AscendingOrder )
3643 double dx = directionPoint.
x() - startPoint.
x();
3644 double dy = directionPoint.
y() - startPoint.
y();
3645 double length = sqrt( dx * dx + dy * dy );
3646 double scaleFactor = distance / length;
3647 return QPointF( startPoint.
x() + dx * scaleFactor, startPoint.
y() + dy * scaleFactor );
3657 for (
int i = 0; i < svgPaths.
size(); i++ )
3659 QDir dir( svgPaths[i] );
3660 Q_FOREACH (
const QString& item, dir.
entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3662 svgPaths.
insert( i + 1, dir.
path() +
'/' + item );
3681 svgPaths.
append( directory );
3683 for (
int i = 0; i < svgPaths.
size(); i++ )
3685 QDir dir( svgPaths[i] );
3686 Q_FOREACH (
const QString& item, dir.
entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3688 svgPaths.
insert( i + 1, dir.
path() +
'/' + item );
3705 if (
QFile( name ).exists() )
3714 if ( url.
scheme().
compare(
"file", Qt::CaseInsensitive ) == 0 )
3718 if (
QFile( name ).exists() )
3734 for (
int i = 0; i < svgPaths.
size(); i++ )
3736 QString svgPath = svgPaths[i];
3750 QgsDebugMsg(
"Alternative svg path: " + myLocalPath );
3751 if (
QFile( myLocalPath ).exists() )
3770 QgsDebugMsg(
"Computed alternate path but no svg there either" );
3787 bool isInSvgPathes =
false;
3788 for (
int i = 0; i < svgPaths.
size(); i++ )
3794 path = path.
mid( dir.
size() + 1 );
3795 isInSvgPathes =
true;
3800 if ( isInSvgPathes )
3809 double cx = 0, cy = 0;
3810 double area, sum = 0;
3811 for (
int i = points.
count() - 1, j = 0; j < points.
count(); i = j++ )
3813 const QPointF& p1 = points[i];
3814 const QPointF& p2 = points[j];
3815 area = p1.
x() * p2.
y() - p1.
y() * p2.
x();
3817 cx += ( p1.
x() + p2.
x() ) * area;
3818 cy += ( p1.
y() + p2.
y() ) * area;
3825 if ( points.
count() >= 2 )
3826 return QPointF(( points[0].x() + points[1].x() ) / 2, ( points[0].y() + points[1].y() ) / 2 );
3827 else if ( points.
count() == 1 )
3845 unsigned int i, pointCount = points.
count();
3848 for ( i = 0; i < pointCount; ++i ) polyline[i] =
QgsPoint( points[i].x(), points[i].y() );
3855 if ( pointOnSurfaceGeom )
3858 delete pointOnSurfaceGeom;
3871 bool inside =
false;
3873 double x = point.
x();
3874 double y = point.
y();
3876 for (
int i = 0, j = points.
count() - 1; i < points.
count(); i++ )
3878 const QPointF& p1 = points[i];
3879 const QPointF& p2 = points[j];
3884 if (( p1.
y() < y && p2.
y() >= y ) || ( p2.
y() < y && p1.
y() >= y ) )
3886 if ( p1.
x() + ( y - p1.
y() ) / ( p2.
y() - p1.
y() )*( p2.
x() - p1.
x() ) <= x )
3897 if ( fieldOrExpression.
isEmpty() )
3916 return static_cast<const QgsExpression::NodeColumnRef*>( n )->name();
3935 breaks.
append( maximum );
3939 int minimumCount =
static_cast< int >( classes ) / 3;
3940 double shrink = 0.75;
3941 double highBias = 1.5;
3942 double adjustBias = 0.5 + 1.5 * highBias;
3943 int divisions = classes;
3944 double h = highBias;
3948 double dx = maximum - minimum;
3958 cell = qMax( qAbs( minimum ), qAbs( maximum ) );
3959 if ( adjustBias >= 1.5 * h + 0.5 )
3961 U = 1 + ( 1.0 / ( 1 + h ) );
3965 U = 1 + ( 1.5 / ( 1 + adjustBias ) );
3967 small = dx < ( cell * U * qMax( 1, divisions ) * 1e-07 * 3.0 );
3974 cell = 9 + cell / 10;
3975 cell = cell * shrink;
3977 if ( minimumCount > 1 )
3979 cell = cell / minimumCount;
3985 if ( divisions > 1 )
3987 cell = cell / divisions;
3990 if ( cell < 20 * 1e-07 )
3995 double base = pow( 10.0, floor( log10( cell ) ) );
3997 if (( 2 * base ) - cell < h *( cell - unit ) )
4000 if (( 5 * base ) - cell < adjustBias *( cell - unit ) )
4003 if (( 10.0 * base ) - cell < h *( cell - unit ) )
4010 int start = floor( minimum / unit + 1e-07 );
4011 int end = ceil( maximum / unit - 1e-07 );
4014 while ( start * unit > minimum + ( 1e-07 * unit ) )
4018 while ( end * unit < maximum - ( 1e-07 * unit ) )
4026 int k = floor( 0.5 + end - start );
4027 if ( k < minimumCount )
4029 k = minimumCount - k;
4033 start = start - k / 2 + k % 2;
4037 start = start - k / 2;
4038 end = end + k / 2 + k % 2;
4041 double minimumBreak = start * unit;
4043 int count = end - start;
4046 for (
int i = 1; i < count + 1; i++ )
4048 breaks.
append( minimumBreak + i * unit );
4054 if ( breaks.
first() < minimum )
4056 breaks[0] = minimum;
4058 if ( breaks.
last() > maximum )
4060 breaks[breaks.
count()-1] = maximum;
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
static QDomElement saveSymbols(QgsSymbolV2Map &symbols, const QString &tagName, QDomDocument &doc)
static WkbType flatType(WkbType type)
Map 2d+ to 2d type.
static QString encodeSldLineJoinStyle(Qt::PenJoinStyle style)
static void sortVariantList(QList< QVariant > &list, Qt::SortOrder order)
Sorts the passed list in requested order.
Class for parsing and evaluation of expressions (formerly called "search strings").
qlonglong toLongLong(bool *ok) const
void setForceVectorOutput(bool force)
static QgsSymbolV2::OutputUnit decodeSldUom(const QString &str, double *scaleFactor)
void setLocked(bool locked)
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
QDomNodeList elementsByTagName(const QString &tagname) const
static QgsSymbolV2Map loadSymbols(QDomElement &element)
virtual NodeType nodeType() const =0
Abstract virtual that returns the type of this node.
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent...
static void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
QString cap(int nth) const
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
QString writePath(const QString &filename, const QString &relativeBasePath=QString::null) const
Prepare a filename to save it to the project file.
QString & append(QChar ch)
static void multiplyImageOpacity(QImage *image, qreal alpha)
Multiplies opacity of image pixel values with a (global) transparency value.
QByteArray data(const QString &mimeType) const
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
OutputUnit
The unit of the output.
static void drawStippledBackground(QPainter *painter, QRect rect)
static Qt::BrushStyle decodeBrushStyle(const QString &str)
static bool lineFromSld(QDomElement &element, Qt::PenStyle &penStyle, QColor &color, double &width, Qt::PenJoinStyle *penJoinStyle=nullptr, Qt::PenCapStyle *penCapStyle=nullptr, QVector< qreal > *customDashPattern=nullptr, double *dashOffset=nullptr)
static QIcon colorRampPreviewIcon(QgsVectorColorRampV2 *ramp, QSize size)
virtual QString type() const =0
static QIcon symbolLayerPreviewIcon(QgsSymbolLayerV2 *layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
static QPixmap colorRampPreviewPixmap(QgsVectorColorRampV2 *ramp, QSize size)
static QList< double > prettyBreaks(double minimum, double maximum, int classes)
Computes a sequence of about 'classes' equally spaced round values which cover the range of values fr...
bool contains(const Key &key) const
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
static Q_DECL_DEPRECATED bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &borderColor, double &borderWidth, double &size)
static QgsVectorColorRampV2 * loadColorRamp(QDomElement &element)
static QMimeData * colorToMimeData(const QColor &color)
Creates mime data from a color.
void fillRect(const QRectF &rectangle, const QBrush &brush)
int localeAwareCompare(const QString &other) const
void setRenderHint(RenderHint hint, bool on)
QDomNode appendChild(const QDomNode &newChild)
QString readLine(qint64 maxlen)
void append(const T &value)
void fill(const QColor &color)
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
QString attribute(const QString &name, const QString &defValue) const
static double mapUnitScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns scale factor painter units -> map units.
QString nodeValue() const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
static QString encodeColor(const QColor &color)
QDateTime toDateTime() const
static QDomElement saveColorRamp(const QString &name, QgsVectorColorRampV2 *ramp, QDomDocument &doc)
static QString encodeSldUom(QgsSymbolV2::OutputUnit unit, double *scaleFactor)
QString attributeNS(const QString nsURI, const QString &localName, const QString &defValue) const
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &mime, const QColor &color, double size=-1)
void setColorData(const QVariant &color)
static QgsStringMap getVendorOptionList(QDomElement &element)
static QgsSymbolV2::ScaleMethod decodeScaleMethod(const QString &str)
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Computes a map units per pixel scaling factor, respecting the minimum and maximum scales set for the ...
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
const_iterator constEnd() const
The output shall be in pixels.
Calculate scale by the diameter.
const T & at(int i) const
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
static QString ogrFeatureStyleBrush(const QColor &fillColr)
Create ogr feature style string for brush.
static QVector< qreal > decodeRealVector(const QString &s)
static QColor colorFromMimeData(const QMimeData *data, bool &hasAlpha)
Attempts to parse mime data as a color.
QString simplified() const
static bool functionFromSldElement(QDomElement &element, QString &function)
static QDomElement saveSymbol(const QString &symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
QDomElement nextSiblingElement(const QString &tagName) const
static QString encodeSldFontStyle(QFont::Style style)
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=nullptr)
Create ogr feature style string for pen.
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
QgsGeometry * pointOnSurface() const
Returns a point within a geometry.
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
A geometry is the spatial representation of a feature.
virtual QgsStringMap properties() const =0
static QPointF decodePoint(const QString &str)
static bool convertPolygonSymbolizerToPointMarker(QDomElement &element, QgsSymbolLayerV2List &layerList)
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static QgsSymbolLayerV2Registry * instance()
return the single instance of this class (instantiate it if not exists)
static QVector< qreal > decodeSldRealVector(const QString &s)
QDomElement documentElement() const
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static Qt::BrushStyle decodeSldBrushStyle(const QString &str)
double scaleFactor() const
QString join(const QString &separator) const
static void createOnlineResourceElement(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format)
static QString colorToName(const QColor &color)
Returns a friendly display name for a color.
void drawLine(const QLineF &line)
static QStringList listSvgFilesAt(const QString &directory)
Return a list of svg files at the specified directory.
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
void setRgb(int r, int g, int b, int a)
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
void setNamedColor(const QString &name)
double toDouble(bool *ok) const
bool isValidColor(const QString &name)
QDomNodeList childNodes() const
qulonglong toULongLong(bool *ok) const
static bool needMarkerLine(QDomElement &element)
const Node * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr)
Draw icon of the symbol that occupyies area given by size using the painter.
static bool needPointPatternFill(QDomElement &element)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
double maxScale
The maximum scale, or 0.0 if unset.
double x() const
Get the x value of the point.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
static QgsSymbolV2 * loadSymbol(const QDomElement &element)
Attempts to load a symbol from a DOM element.
static double pixelSizeScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns scale factor painter units -> pixel dimensions.
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
void setMapUnitScale(const QgsMapUnitScale &scale)
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
QDomNode nextSibling() const
static QgsSymbolV2::OutputUnit decodeOutputUnit(const QString &str)
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
QDomElement toElement() const
static QString encodePenStyle(Qt::PenStyle style)
static QPointF pointOnLineWithDistance(QPointF startPoint, QPointF directionPoint, double distance)
Returns a point on the line from startPoint to directionPoint that is a certain distance away from th...
static bool createSymbolLayerV2ListFromSld(QDomElement &element, QGis::GeometryType geomType, QgsSymbolLayerV2List &layers)
int indexIn(const QString &str, int offset, CaretMode caretMode) const
static QString symbolPathToName(QString path)
Get symbols's name from its path.
Mixed units in symbol layers.
QString canonicalFilePath() const
static QgsSymbolLayerV2 * createMarkerLayerFromSld(QDomElement &element)
static QgsRenderContext createRenderContext(QPainter *p)
Creates a render context for a pixel based device.
The output shall be in millimeters.
static QPainter::CompositionMode decodeBlendMode(const QString &s)
QString number(int n, int base)
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
int count(const T &value) const
void append(const T &value)
static QString encodeSldFontWeight(int weight)
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
void setScaleFactor(double factor)
QString localName() const
uint toUInt(bool *ok) const
QString canonicalPath() const
static bool pointInPolygon(const QPolygonF &points, QPointF point)
Calculate whether a point is within of a QPolygonF.
int toInt(bool *ok) const
static QgsSymbolLayerV2 * createFillLayerFromSld(QDomElement &element)
static QString encodePoint(QPointF point)
bool hasAttribute(const QString &name) const
static double convertToPainterUnits(const QgsRenderContext &c, double size, QgsSymbolV2::OutputUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale())
Converts a size from the specied units to painter units.
static QPointF offsetPoint(QPointF pt, double angle, double dist)
static QString encodeSldAlpha(int alpha)
static bool needLinePatternFill(QDomElement &element)
static QgsPaintEffectRegistry * instance()
Returns a reference to the singleton instance of the paint effect registry.
The ouput shall be a percentage of another measurement (eg canvas size, feature size) ...
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
static QgsNamedColorList importColorsFromGpl(QFile &file, bool &ok, QString &name)
Imports colors from a gpl GIMP palette file.
void setPen(const QColor &color)
void setRenderingPass(int renderingPass)
void setAttribute(const QString &name, const QString &value)
static QStringList listSvgFiles()
Return a list of all available svg files.
int toInt(bool *ok, int base) const
QDomNodeList elementsByTagName(const QString &tagname) const
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
The output shall be in map unitx.
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
QPaintDevice * device() const
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
static Qt::PenCapStyle decodePenCapStyle(const QString &str)
void setText(const QString &text)
void setPainter(QPainter *p)
static bool needFontMarker(QDomElement &element)
double rasterScaleFactor() const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
static void saveProperties(QgsStringMap props, QDomDocument &doc, QDomElement &element)
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QVector< QgsPolyline > QgsPolygon
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
static double estimateMaxSymbolBleed(QgsSymbolV2 *symbol)
Returns the maximum estimated bleed for the symbol.
static bool hasExternalGraphic(QDomElement &element)
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, const QColor &color, double width=-1, const Qt::PenJoinStyle *penJoinStyle=nullptr, const Qt::PenCapStyle *penCapStyle=nullptr, const QVector< qreal > *customDashPattern=nullptr, double dashOffset=0.0)
QVariant colorData() const
QgsGeometry * buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
A class to represent a point.
static Qt::PenStyle decodePenStyle(const QString &str)
QString toLocalFile() const
virtual QColor color(double value) const =0
QDomText createTextNode(const QString &value)
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)
static bool needSvgMarker(QDomElement &element)
static bool needSvgFill(QDomElement &element)
static bool geometryFromSldElement(QDomElement &element, QString &geomFunc)
static QgsSymbolLayerV2 * loadSymbolLayer(QDomElement &element)
bool contains(QChar ch, Qt::CaseSensitivity cs) const
static QgsSymbolLayerV2 * createLineLayerFromSld(QDomElement &element)
static QString encodeRealVector(const QVector< qreal > &v)
int renderingPass() const
virtual QString layerType() const =0
Returns a string that represents this layer type.
QgsSymbolLayerV2 * createSymbolLayerFromSld(const QString &name, QDomElement &element) const
create a new instance of symbol layer given symbol layer name and SLD
virtual QgsSymbolV2 * subSymbol()
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
SymbolType
Type of the symbol.
void setTexture(const QPixmap &pixmap)
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
const T & at(int i) const
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
const_iterator constBegin() const
Contains information about the context of a rendering operation.
void save(QTextStream &str, int indent) const
static QDomElement createSvgParameterElement(QDomDocument &doc, const QString &name, const QString &value)
QDomNode firstChild() const
QString mid(int position, int n) const
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
static QString encodeBrushStyle(Qt::BrushStyle style)
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
static void fillToSld(QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, const QColor &color=QColor())
static QColor parseColorWithAlpha(const QString &colorStr, bool &containsAlpha, bool strictEval=false)
Attempts to parse a string as a color using a variety of common formats, including hex codes...
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 QPointF linesIntersection(QPointF p1, double t1, QPointF p2, double t2)
static QgsExpression * fieldOrExpressionToExpression(const QString &fieldOrExpression)
Return a new valid expression instance for given field or expression string.
Struct for storing maximum and minimum scales for measurements in map units.
QList< QPolygonF > offsetLine(QPolygonF polyline, double dist, QGis::GeometryType geometryType)
calculate geometry shifted by a specified distance
static QList< QColor > parseColorList(const QString &colorStr)
Attempts to parse a string as a list of colors using a variety of common formats, including hex codes...
void insert(int i, const T &value)
static QPixmap symbolPreviewPixmap(QgsSymbolV2 *symbol, QSize size, QgsRenderContext *customContext=nullptr)
QgsGeometry * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit) const
Returns an offset line at a given distance and side from an input line.
static QDomElement expressionToOgcFilter(const QgsExpression &exp, QDomDocument &doc, QString *errorMessage=nullptr)
Creates OGC filter XML element.
QStringList entryList(QFlags< QDir::Filter > filters, QFlags< QDir::SortFlag > sort) const
static QMimeData * colorListToMimeData(const QgsNamedColorList &colorList, const bool allFormats=true)
Creates mime data from a list of named colors.
static bool lineInfo(QPointF p1, QPointF p2, double &angle, double &t)
static QString encodeScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
static QgsProject * instance()
access to canonical QgsProject instance
static QString symbolProperties(QgsSymbolV2 *symbol)
Returns a string representing the symbol.
QDomElement firstChildElement(const QString &tagName) const
static QString _nameForSymbolType(QgsSymbolV2::SymbolType type)
static QString fieldOrExpressionFromExpression(QgsExpression *expression)
Return a field name if the whole expression is just a name of the field .
static QString encodeSldRealVector(const QVector< qreal > &v)
void getRgb(int *r, int *g, int *b, int *a) const
static QgsExpression * expressionFromOgcFilter(const QDomElement &element)
Parse XML with OGC filter into QGIS expression.
static QString encodeSldBrushStyle(Qt::BrushStyle style)
int count(const T &value) const
QgsSymbolLayerV2 * createSymbolLayer(const QString &name, const QgsStringMap &properties=QgsStringMap()) const
create a new instance of symbol layer given symbol layer name and properties
static void labelTextToSld(QDomDocument &doc, QDomElement &element, const QString &label, const QFont &font, const QColor &color=QColor(), double size=-1)
QStringList split(const QString &sep, const QString &str, bool allowEmptyEntries)
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
static QPicture symbolLayerPreviewPicture(QgsSymbolLayerV2 *layer, QgsSymbolV2::OutputUnit units, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
Draws a symbol layer preview to a QPicture.
static QgsGeometry * fromPolyline(const QgsPolyline &polyline)
Creates a new geometry from a QgsPolyline object.
QString expression() const
Return the original, unmodified expression string.
void push_back(const T &value)
double y() const
Get the y value of the point.
static void clearSymbolMap(QgsSymbolV2Map &symbols)
static QStringList svgPaths()
Returns the pathes to svg directories.
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
static Qt::PenCapStyle decodeSldLineCapStyle(const QString &str)
double toDouble(bool *ok) const
static QColor decodeColor(const QString &str)
iterator insert(const Key &key, const T &value)
static QgsStringMap getSvgParameterList(QDomElement &element)
static QPointF polygonCentroid(const QPolygonF &points)
Calculate the centroid point of a QPolygonF.
void setRasterScaleFactor(double factor)
Calculate scale by the area.
static QgsGeometry * fromPolygon(const QgsPolygon &polygon)
Creates a new geometry from a QgsPolygon.
static int decodeSldFontWeight(const QString &str)
static int decodeSldAlpha(const QString &str)
static QColor parseColor(const QString &colorStr, bool strictEval=false)
Attempts to parse a string as a color using a variety of common formats, including hex codes...
void setData(const QString &mimeType, const QByteArray &data)
static bool onlineResourceFromSldElement(QDomElement &element, QString &path, QString &format)
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
static QgsStringMap parseProperties(QDomElement &element)
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
virtual void drawPreviewIcon(QgsSymbolV2RenderContext &context, QSize size)=0
const_iterator constBegin() const
static bool hasWellKnownMark(QDomElement &element)
static QPointF polygonPointOnSurface(const QPolygonF &points)
Calculate a point within of a QPolygonF.
static Qt::PenJoinStyle decodeSldLineJoinStyle(const QString &str)
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
static QFont::Style decodeSldFontStyle(const QString &str)
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
bool begin(QPaintDevice *device)
double minScale
The minimum scale, or 0.0 if unset.
int compare(const QString &other) const
static bool opacityFromSldElement(QDomElement &element, QString &alphaFunc)
QString parserErrorString() const
Returns parser error.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
set layer's subsymbol. takes ownership of the passed symbol
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
static void blurImageInPlace(QImage &image, QRect rect, int radius, bool alphaOnly)
Blurs an image in place, e.g.
static bool saveColorsToGpl(QFile &file, const QString &paletteName, const QgsNamedColorList &colors)
Exports colors to a gpl GIMP palette file.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the layer.
void setOutputUnit(QgsSymbolV2::OutputUnit u)
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
static QString encodeSldLineCapStyle(Qt::PenCapStyle style)
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the layer.
static void premultiplyColor(QColor &rgb, int alpha)
Converts a QColor into a premultiplied ARGB QColor value using a specified alpha value.
QByteArray toByteArray(int indent) const
static void createOpacityElement(QDomDocument &doc, QDomElement &element, const QString &alphaFunc)
static QgsNamedColorList colorListFromMimeData(const QMimeData *data)
Attempts to parse mime data as a list of named colors.
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
QDomNode at(int index) const
static bool needEllipseMarker(QDomElement &element)
static QString encodePenCapStyle(Qt::PenCapStyle style)
static Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &borderColor=QColor(), double borderWidth=-1, double size=-1)