33 #include <QDomDocument>
35 #include <QDomElement>
50 if ( lst.
count() < 3 )
54 int red, green, blue, alpha;
56 green = lst[1].toInt();
57 blue = lst[2].toInt();
59 if ( lst.
count() > 3 )
61 alpha = lst[3].toInt();
63 return QColor( red, green, blue, alpha );
75 if ( !ok || alpha > 1 )
86 case QFont::StyleNormal:
return "normal";
87 case QFont::StyleItalic:
return "italic";
88 case QFont::StyleOblique:
return "oblique";
95 if ( str ==
"normal" )
return QFont::StyleNormal;
96 if ( str ==
"italic" )
return QFont::StyleItalic;
97 if ( str ==
"oblique" )
return QFont::StyleOblique;
98 return QFont::StyleNormal;
103 if ( weight == 50 )
return "normal";
104 if ( weight == 75 )
return "bold";
108 if ( weight < 0 )
return "100";
109 if ( weight > 99 )
return "900";
116 int weight = str.
toInt( &ok );
117 if ( !ok )
return (
int ) QFont::Normal;
121 if ( weight > 900 )
return 99;
122 if ( weight < 100 )
return 0;
123 return ( weight - 100 ) * 99 / 800;
130 case Qt::NoPen:
return "no";
131 case Qt::SolidLine:
return "solid";
132 case Qt::DashLine:
return "dash";
133 case Qt::DotLine:
return "dot";
134 case Qt::DashDotLine:
return "dash dot";
135 case Qt::DashDotDotLine:
return "dash dot dot";
136 default:
return "???";
142 if ( str ==
"no" )
return Qt::NoPen;
143 if ( str ==
"solid" )
return Qt::SolidLine;
144 if ( str ==
"dash" )
return Qt::DashLine;
145 if ( str ==
"dot" )
return Qt::DotLine;
146 if ( str ==
"dash dot" )
return Qt::DashDotLine;
147 if ( str ==
"dash dot dot" )
return Qt::DashDotDotLine;
148 return Qt::SolidLine;
155 case Qt::BevelJoin:
return "bevel";
156 case Qt::MiterJoin:
return "miter";
157 case Qt::RoundJoin:
return "round";
158 default:
return "???";
164 if ( str ==
"bevel" )
return Qt::BevelJoin;
165 if ( str ==
"miter" )
return Qt::MiterJoin;
166 if ( str ==
"round" )
return Qt::RoundJoin;
167 return Qt::BevelJoin;
174 case Qt::BevelJoin:
return "bevel";
175 case Qt::MiterJoin:
return "mitre";
176 case Qt::RoundJoin:
return "round";
183 if ( str ==
"bevel" )
return Qt::BevelJoin;
184 if ( str ==
"mitre" )
return Qt::MiterJoin;
185 if ( str ==
"round" )
return Qt::RoundJoin;
186 return Qt::BevelJoin;
193 case Qt::SquareCap:
return "square";
194 case Qt::FlatCap:
return "flat";
195 case Qt::RoundCap:
return "round";
196 default:
return "???";
202 if ( str ==
"square" )
return Qt::SquareCap;
203 if ( str ==
"flat" )
return Qt::FlatCap;
204 if ( str ==
"round" )
return Qt::RoundCap;
205 return Qt::SquareCap;
212 case Qt::SquareCap:
return "square";
213 case Qt::FlatCap:
return "butt";
214 case Qt::RoundCap:
return "round";
221 if ( str ==
"square" )
return Qt::SquareCap;
222 if ( str ==
"butt" )
return Qt::FlatCap;
223 if ( str ==
"round" )
return Qt::RoundCap;
224 return Qt::SquareCap;
231 case Qt::SolidPattern :
return "solid";
232 case Qt::HorPattern :
return "horizontal";
233 case Qt::VerPattern :
return "vertical";
234 case Qt::CrossPattern :
return "cross";
235 case Qt::BDiagPattern :
return "b_diagonal";
236 case Qt::FDiagPattern :
return "f_diagonal";
237 case Qt::DiagCrossPattern :
return "diagonal_x";
238 case Qt::Dense1Pattern :
return "dense1";
239 case Qt::Dense2Pattern :
return "dense2";
240 case Qt::Dense3Pattern :
return "dense3";
241 case Qt::Dense4Pattern :
return "dense4";
242 case Qt::Dense5Pattern :
return "dense5";
243 case Qt::Dense6Pattern :
return "dense6";
244 case Qt::Dense7Pattern :
return "dense7";
245 case Qt::NoBrush :
return "no";
246 default:
return "???";
252 if ( str ==
"solid" )
return Qt::SolidPattern;
253 if ( str ==
"horizontal" )
return Qt::HorPattern;
254 if ( str ==
"vertical" )
return Qt::VerPattern;
255 if ( str ==
"cross" )
return Qt::CrossPattern;
256 if ( str ==
"b_diagonal" )
return Qt::BDiagPattern;
257 if ( str ==
"f_diagonal" )
return Qt::FDiagPattern;
258 if ( str ==
"diagonal_x" )
return Qt::DiagCrossPattern;
259 if ( str ==
"dense1" )
return Qt::Dense1Pattern;
260 if ( str ==
"dense2" )
return Qt::Dense2Pattern;
261 if ( str ==
"dense3" )
return Qt::Dense3Pattern;
262 if ( str ==
"dense4" )
return Qt::Dense4Pattern;
263 if ( str ==
"dense5" )
return Qt::Dense5Pattern;
264 if ( str ==
"dense6" )
return Qt::Dense6Pattern;
265 if ( str ==
"dense7" )
return Qt::Dense7Pattern;
266 if ( str ==
"no" )
return Qt::NoBrush;
267 return Qt::SolidPattern;
274 case Qt::CrossPattern:
return "cross";
275 case Qt::DiagCrossPattern:
return "x";
281 case Qt::HorPattern:
return "horline";
282 case Qt::VerPattern:
return "line";
283 case Qt::BDiagPattern:
return "slash";
284 case Qt::FDiagPattern:
return "backslash";
287 case Qt::Dense1Pattern:
288 case Qt::Dense2Pattern:
289 case Qt::Dense3Pattern:
290 case Qt::Dense4Pattern:
291 case Qt::Dense5Pattern:
292 case Qt::Dense6Pattern:
293 case Qt::Dense7Pattern:
303 if ( str ==
"horline" )
return Qt::HorPattern;
304 if ( str ==
"line" )
return Qt::VerPattern;
305 if ( str ==
"cross" )
return Qt::CrossPattern;
306 if ( str ==
"slash" )
return Qt::BDiagPattern;
307 if ( str ==
"backshash" )
return Qt::FDiagPattern;
308 if ( str ==
"x" )
return Qt::DiagCrossPattern;
318 return QString(
"%1,%2" ).
arg( point.
x() ).arg( point.
y() );
324 if ( lst.
count() != 2 )
326 return QPointF( lst[0].toDouble(), lst[1].toDouble() );
337 if ( lst.
count() != 2 )
363 else if ( str ==
"MapUnit" )
367 else if ( str ==
"Pixel" )
382 *scaleFactor = 0.001;
383 return "http://www.opengeospatial.org/se/units/metre";
399 if ( str ==
"http://www.opengeospatial.org/se/units/metre" )
402 *scaleFactor = 1000.0;
405 else if ( str ==
"http://www.opengeospatial.org/se/units/foot" )
408 *scaleFactor = 304.8;
415 *scaleFactor = 1 / 0.00028;
427 vectorString.
append(
";" );
440 for ( ; it != realList.
constEnd(); ++it )
442 resultVector.
append( it->toDouble() );
456 vectorString.
append(
" " );
469 for ( ; it != realList.
constEnd(); ++it )
471 resultVector.
append( it->toDouble() );
481 switch ( scaleMethod )
484 encodedValue =
"diameter";
487 encodedValue =
"area";
497 if ( str ==
"diameter" )
511 if ( s.
compare(
"Lighten", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Lighten;
512 if ( s.
compare(
"Screen", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Screen;
513 if ( s.
compare(
"Dodge", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorDodge;
514 if ( s.
compare(
"Addition", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Plus;
515 if ( s.
compare(
"Darken", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Darken;
516 if ( s.
compare(
"Multiply", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Multiply;
517 if ( s.
compare(
"Burn", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorBurn;
518 if ( s.
compare(
"Overlay", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Overlay;
519 if ( s.
compare(
"SoftLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_SoftLight;
520 if ( s.
compare(
"HardLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_HardLight;
521 if ( s.
compare(
"Difference", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Difference;
522 if ( s.
compare(
"Subtract", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Exclusion;
523 return QPainter::CompositionMode_SourceOver;
536 pixmap.
fill( Qt::transparent );
538 painter.
begin( &pixmap );
554 maxBleed = layerMaxBleed > maxBleed ? layerMaxBleed : maxBleed;
564 painter.
begin( &picture );
577 pixmap.
fill( Qt::transparent );
579 painter.
begin( &pixmap );
585 return QIcon( pixmap );
596 pixmap.
fill( Qt::transparent );
599 painter.
begin( &pixmap );
606 for (
int i = 0; i < size.
width(); i++ )
619 uchar pixDataRGB[] = { 255, 255, 255, 255,
624 QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
641 #if !defined(GEOS_VERSION_MAJOR) || !defined(GEOS_VERSION_MINOR) || \
642 ((GEOS_VERSION_MAJOR<3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR<3)))
646 double x1 = p1.
x(), y1 = p1.
y(), x2 = p2.
x(), y2 = p2.
y();
648 if ( x1 == x2 && y1 == y2 )
652 t = ( x1 == x2 ? DBL_MAX : ( y2 - y1 ) / ( x2 - x1 ) );
656 angle = ( y2 > y1 ?
M_PI / 2 :
M_PI * 3 / 2 );
658 angle = ( x2 > x1 ? 0 :
M_PI );
660 angle = ( y2 > y1 ? atan( t ) :
M_PI + atan( t ) );
662 angle = ( y2 > y1 ?
M_PI + atan( t ) : atan( t ) );
670 return QPointF( pt.
x() + dist * cos( angle ), pt.
y() + dist * sin( angle ) );
677 if (( t1 == DBL_MAX && t2 == DBL_MAX ) || qAbs( atan( t1 ) - atan( t2 ) ) < 0.175 )
681 if ( t1 == DBL_MAX || t2 == DBL_MAX )
687 QPointF pSwp = p1; p1 = p2; p2 = pSwp;
688 double tSwp = t1; t1 = t2; t2 = tSwp;
696 x = (( p1.
y() - p2.
y() ) + t2 * p2.
x() - t1 * p1.
x() ) / ( t2 - t1 );
699 y = p1.
y() + t1 * ( x - p1.
x() );
705 int i, pointCount = polyline.
count();
708 resultLine.
resize( pointCount );
712 for ( i = 0; i < pointCount; ++i, tempPtr++ )
713 resultLine[i] =
QPointF( tempPtr->
x(), tempPtr->
y() );
720 for (
int ring = 0; ring < polygon.
size(); ++ring )
721 resultGeom.
append( makeOffsetGeometry( polygon[ ring ] ) );
730 if ( polyline.
count() < 2 )
732 resultLine.
append( polyline );
739 #if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
740 ((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
742 unsigned int i, pointCount = polyline.
count();
746 for ( i = 0; i < pointCount; ++i, tempPtr++ )
747 tempPolyline[i] =
QgsPoint( tempPtr->
rx(), tempPtr->
ry() );
752 int quadSegments = 0;
753 double mitreLimit = 2.0;
756 offsetGeom = tempGeometry->
buffer( -dist, quadSegments, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, mitreLimit );
758 offsetGeom = tempGeometry->
offsetCurve( dist, quadSegments, GEOSBUF_JOIN_MITRE, mitreLimit );
763 tempGeometry = offsetGeom;
781 for (
int part = 0; part < tempMPolyline.
count(); ++part )
783 resultLine.
append( makeOffsetGeometry( tempMPolyline[ part ] ) );
792 for (
int part = 0; part < tempMPolygon.
count(); ++part )
794 resultLine.
append( makeOffsetGeometry( tempMPolygon[ part ] ) );
804 resultLine.
append( polyline );
809 double angle = 0.0, t_new, t_old = 0;
812 bool first_point =
true;
814 for (
int i = 1; i < polyline.
count(); i++ )
818 if ( !
lineInfo( p1, p2, angle, t_new ) )
844 resultLine.
append( newLine );
853 int pointCount = polyline.
count();
855 if ( pointCount > 3 && polyline[ 0 ].x() == polyline[ pointCount - 1 ].x() && polyline[ 0 ].y() == polyline[ pointCount - 1 ].y() )
859 else if ( pointCount > 1 )
863 return offsetLine( polyline, dist, geometryType );
874 while ( !layerNode.
isNull() )
907 if ( layers.
count() == 0 )
916 if ( symbolType ==
"line" )
918 else if ( symbolType ==
"fill" )
920 else if ( symbolType ==
"marker" )
924 QgsDebugMsg(
"unknown symbol type " + symbolType );
963 if ( !effectElem.
isNull() )
1034 if ( symbolizerName ==
"PointSymbolizer" )
1038 if ( graphicElem.
isNull() )
1040 QgsDebugMsg(
"Graphic element not found in PointSymbolizer" );
1076 if ( symbolizerName ==
"LineSymbolizer" )
1080 if ( strokeElem.
isNull() )
1082 QgsDebugMsg(
"Stroke element not found in LineSymbolizer" );
1110 if ( symbolizerName ==
"PolygonSymbolizer" )
1117 QgsDebugMsg(
"neither Fill nor Stroke element not found in PolygonSymbolizer" );
1195 if ( strokeElem.
isNull() )
1214 if ( graphicElem.
isNull() )
1237 if ( graphicElem.
isNull() )
1241 if ( externalGraphicElem.
isNull() )
1246 if ( formatElem.
isNull() )
1250 if ( format !=
"image/svg+xml" )
1252 QgsDebugMsg(
"unsupported External Graphic format found: " + format );
1259 if ( !onlineResourceElem.
isNull() )
1264 else if ( !inlineContentElem.
isNull() )
1278 if ( graphicElem.
isNull() )
1286 if ( wellKnownNameElem.
isNull() )
1296 if ( graphicElem.
isNull() )
1305 if ( formatElem.
isNull() )
1309 if ( format !=
"ttf" )
1311 QgsDebugMsg(
"unsupported Graphic Mark format found: " + format );
1318 if ( !onlineResourceElem.
isNull() )
1322 if ( !markIndexElem.
isNull() )
1325 else if ( !inlineContentElem.
isNull() )
1341 if ( graphicElem.
isNull() )
1347 if ( it.key() ==
"widthHeightFactor" )
1359 if ( strokeElem.
isNull() )
1363 if ( graphicStrokeElem.
isNull() )
1376 if ( graphicFillElem.
isNull() )
1380 if ( graphicElem.
isNull() )
1386 QColor fillColor, borderColor;
1387 double size, borderWidth;
1388 Qt::PenStyle borderStyle;
1389 if ( !
wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderStyle, borderWidth, size ) )
1392 if ( name !=
"horline" )
1401 if ( !ok || angle == 0 )
1409 Q_UNUSED( element );
1420 if ( graphicFillElem.
isNull() )
1445 bool validFill =
false, validBorder =
false;
1450 Qt::BrushStyle fillStyle;
1452 if (
fillFromSld( fillElem, fillStyle, fillColor ) )
1458 Qt::PenStyle borderStyle;
1459 double borderWidth = 1.0, dashOffset = 0.0;
1462 if (
lineFromSld( strokeElem, borderStyle, borderColor, borderWidth,
1463 0, 0, &customDashPattern, &dashOffset ) )
1466 if ( validFill || validBorder )
1469 map[
"name"] =
"square";
1470 map[
"color"] =
encodeColor( validFill ? fillColor : Qt::transparent );
1471 map[
"color_border"] =
encodeColor( validBorder ? borderColor : Qt::transparent );
1481 bool validFill =
false, validBorder =
false;
1486 QColor fillColor, borderColor;
1487 double borderWidth = 1.0, size = 0.0,
angle = 0.0;
1492 if ( !graphicFillElem.
isNull() )
1496 if ( !graphicElem.
isNull() )
1503 while ( !graphicChildElem.
isNull() )
1505 if ( graphicChildElem.
localName() ==
"Mark" )
1509 if ( !wellKnownNameElem.
isNull() )
1517 if ( graphicChildElem.
localName() ==
"ExternalGraphic" || graphicChildElem.
localName() ==
"Mark" )
1521 if ( formatElem.
isNull() )
1528 if ( graphicChildElem.
localName() ==
"ExternalGraphic" && format !=
"image/svg+xml" )
1533 if ( graphicChildElem.
localName() ==
"Mark" && format !=
"ttf" )
1540 if ( !onlineResourceElem.
isNull() )
1542 name = onlineResourceElem.
attributeNS(
"http://www.w3.org/1999/xlink",
"href" );
1544 if ( graphicChildElem.
localName() ==
"Mark" && format ==
"ttf" )
1548 name = name.
mid( 6 );
1552 if ( markIndexElem.
isNull() )
1567 else if ( !inlineContentElem.
isNull() )
1577 if ( graphicChildElem.
localName() ==
"Mark" )
1586 if ( found && graphicChildElem.
localName() ==
"Mark" )
1593 Qt::BrushStyle markFillStyle;
1596 if (
fillFromSld( markFillElem, markFillStyle, fillColor ) )
1601 Qt::PenStyle borderStyle;
1602 double borderWidth = 1.0, dashOffset = 0.0;
1606 if (
lineFromSld( markStrokeElem, borderStyle, borderColor, borderWidth,
1607 0, 0, &customDashPattern, &dashOffset ) )
1615 if ( !opacityElem.
isNull() )
1619 if ( !sizeElem.
isNull() )
1631 double v = angleFunc.
toDouble( &ok );
1641 if ( validFill || validBorder )
1643 if ( format ==
"image/svg+xml" )
1647 map[
"fill"] = fillColor.
name();
1648 map[
"outline"] = borderColor.
name();
1658 else if ( format ==
"ttf" )
1662 map[
"chr"] = markIndex;
1663 map[
"color"] =
encodeColor( validFill ? fillColor : Qt::transparent );
1678 layerList << layers;
1686 switch ( brushStyle )
1691 case Qt::SolidPattern:
1695 if ( color.
alpha() < 255 )
1700 case Qt::CrossPattern:
1701 case Qt::DiagCrossPattern:
1702 case Qt::HorPattern:
1703 case Qt::VerPattern:
1704 case Qt::BDiagPattern:
1705 case Qt::FDiagPattern:
1706 case Qt::Dense1Pattern:
1707 case Qt::Dense2Pattern:
1708 case Qt::Dense3Pattern:
1709 case Qt::Dense4Pattern:
1710 case Qt::Dense5Pattern:
1711 case Qt::Dense6Pattern:
1712 case Qt::Dense7Pattern:
1731 wellKnownMarkerToSld( doc, graphicElem, patternName, fillColor, borderColor, Qt::SolidLine, -1, -1 );
1738 brushStyle = Qt::SolidPattern;
1739 color =
QColor(
"#808080" );
1743 brushStyle = Qt::NoBrush;
1750 if ( graphicFillElem.
isNull() )
1755 QgsDebugMsg(
QString(
"found SvgParameter %1: %2" ).arg( it.key() ).arg( it.value() ) );
1757 if ( it.key() ==
"fill" )
1758 color =
QColor( it.value() );
1759 else if ( it.key() ==
"fill-opacity" )
1766 if ( graphicElem.
isNull() )
1769 QString patternName =
"square";
1770 QColor fillColor, borderColor;
1771 double borderWidth, size;
1772 Qt::PenStyle borderStyle;
1773 if ( !
wellKnownMarkerFromSld( graphicElem, patternName, fillColor, borderColor, borderStyle, borderWidth, size ) )
1777 if ( brushStyle == Qt::NoBrush )
1789 Qt::PenStyle penStyle,
QColor color,
double width,
1790 const Qt::PenJoinStyle *penJoinStyle,
const Qt::PenCapStyle *penCapStyle,
1796 if ( penStyle == Qt::CustomDashLine && !customDashPattern )
1798 element.
appendChild( doc.
createComment(
"WARNING: Custom dash pattern required but not provided. Using default dash pattern." ) );
1799 penStyle = Qt::DashLine;
1818 case Qt::DashDotLine:
1824 case Qt::DashDotDotLine:
1833 case Qt::CustomDashLine:
1834 Q_ASSERT( customDashPattern );
1835 pattern = customDashPattern;
1846 if ( color.
alpha() < 255 )
1856 if ( pattern->
size() > 0 )
1866 Qt::PenStyle &penStyle,
QColor &color,
double &width,
1867 Qt::PenJoinStyle *penJoinStyle, Qt::PenCapStyle *penCapStyle,
1872 penStyle = Qt::SolidLine;
1873 color =
QColor(
"#000000" );
1876 *penJoinStyle = Qt::BevelJoin;
1878 *penCapStyle = Qt::SquareCap;
1879 if ( customDashPattern )
1880 customDashPattern->
clear();
1886 penStyle = Qt::NoPen;
1894 QgsDebugMsg(
QString(
"found SvgParameter %1: %2" ).arg( it.key() ).arg( it.value() ) );
1896 if ( it.key() ==
"stroke" )
1898 color =
QColor( it.value() );
1900 else if ( it.key() ==
"stroke-opacity" )
1904 else if ( it.key() ==
"stroke-width" )
1907 double w = it.value().toDouble( &ok );
1911 else if ( it.key() ==
"stroke-linejoin" && penJoinStyle )
1915 else if ( it.key() ==
"stroke-linecap" && penCapStyle )
1919 else if ( it.key() ==
"stroke-dasharray" )
1922 if ( dashPattern.
size() > 0 )
1926 bool dashPatternFound =
false;
1928 if ( dashPattern.
count() == 2 )
1930 if ( dashPattern.
at( 0 ) == 4.0 &&
1931 dashPattern.
at( 1 ) == 2.0 )
1933 penStyle = Qt::DashLine;
1934 dashPatternFound =
true;
1936 else if ( dashPattern.
at( 0 ) == 1.0 &&
1937 dashPattern.
at( 1 ) == 2.0 )
1939 penStyle = Qt::DotLine;
1940 dashPatternFound =
true;
1943 else if ( dashPattern.
count() == 4 )
1945 if ( dashPattern.
at( 0 ) == 4.0 &&
1946 dashPattern.
at( 1 ) == 2.0 &&
1947 dashPattern.
at( 2 ) == 1.0 &&
1948 dashPattern.
at( 3 ) == 2.0 )
1950 penStyle = Qt::DashDotLine;
1951 dashPatternFound =
true;
1954 else if ( dashPattern.
count() == 6 )
1956 if ( dashPattern.
at( 0 ) == 4.0 &&
1957 dashPattern.
at( 1 ) == 2.0 &&
1958 dashPattern.
at( 2 ) == 1.0 &&
1959 dashPattern.
at( 3 ) == 2.0 &&
1960 dashPattern.
at( 4 ) == 1.0 &&
1961 dashPattern.
at( 5 ) == 2.0 )
1963 penStyle = Qt::DashDotDotLine;
1964 dashPatternFound =
true;
1969 if ( !dashPatternFound )
1971 if ( customDashPattern )
1973 penStyle = Qt::CustomDashLine;
1974 *customDashPattern = dashPattern;
1978 QgsDebugMsg(
"custom dash pattern required but not provided. Using default dash pattern." );
1979 penStyle = Qt::DashLine;
1984 else if ( it.key() ==
"stroke-dashoffset" && dashOffset )
1987 double d = it.value().toDouble( &ok );
1998 QColor color,
double size )
2018 QColor &color,
double &size )
2024 if ( externalGraphicElem.
isNull() )
2030 if ( !sizeElem.
isNull() )
2043 QColor color,
double size )
2059 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2073 QColor &color,
double &size )
2088 if ( !markIndexElem.
isNull() )
2098 Qt::BrushStyle b = Qt::SolidPattern;
2104 if ( !sizeElem.
isNull() )
2117 double borderWidth,
double size )
2119 wellKnownMarkerToSld( doc, element, name, color, borderColor, Qt::SolidLine, borderWidth, size );
2124 double borderWidth,
double size )
2137 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2145 lineToSld( doc, strokeElem, borderStyle, borderColor, borderWidth );
2160 double &borderWidth,
double &size )
2162 Qt::PenStyle borderStyle;
2168 double &borderWidth,
double &size )
2174 borderColor =
QColor(
"#000000" );
2183 if ( !wellKnownNameElem.
isNull() )
2186 QgsDebugMsg(
"found Mark with well known name: " + name );
2191 Qt::BrushStyle b = Qt::SolidPattern;
2197 lineFromSld( strokeElem, borderStyle, borderColor, borderWidth );
2202 if ( !sizeElem.
isNull() )
2215 if ( !rotationFunc.
isEmpty() )
2226 if ( !rotationElem.
isNull() )
2247 if ( !opacityElem.
isNull() )
2277 if ( displacementElem.
isNull() )
2281 if ( !dispXElem.
isNull() )
2286 offset.
setX( offsetX );
2290 if ( !dispYElem.
isNull() )
2295 offset.
setY( offsetY );
2303 QColor color,
double size )
2323 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2329 Qt::PenJoinStyle joinStyle,
2330 Qt::PenCapStyle capStyle,
2335 penStyle.
append(
"PEN(" );
2338 penStyle.
append(
",w:" );
2344 if ( dashPattern && dashPattern->
size() > 0 )
2346 penStyle.
append(
",p:\"" );
2348 for ( ; pIt != dashPattern->
constEnd(); ++pIt )
2361 penStyle.
append(
",cap:" );
2376 penStyle.
append(
",j:" );
2377 switch ( joinStyle )
2393 penStyle.
append(
",dp:" );
2405 brushStyle.
append(
"BRUSH(" );
2406 brushStyle.
append(
"fc:" );
2408 brushStyle.
append(
")" );
2449 if ( geometryElem.
isNull() )
2465 if ( !filterElem.
isNull() )
2473 if ( element.
tagName() !=
"Filter" )
2476 if ( filterNodes.
size() > 0 )
2512 onlineResourceElem.
setAttribute(
"xlink:type",
"simple" );
2526 if ( onlineResourceElem.
isNull() )
2529 path = onlineResourceElem.
attributeNS(
"http://www.w3.org/1999/xlink",
"href" );
2532 if ( formatElem.
isNull() )
2553 while ( !paramElem.
isNull() )
2555 if ( paramElem.
localName() ==
"SvgParameter" || paramElem.
localName() ==
"CssParameter" )
2561 params[ name ] = value;
2583 while ( !paramElem.
isNull() )
2589 params[ name ] = value;
2612 props[propKey] = propValue;
2640 if ( e.
tagName() ==
"symbol" )
2643 if ( symbol != NULL )
2661 if ( it.key()[0] !=
'@' )
2665 subsymbols.
append( it.key() );
2668 if ( parts.
count() < 3 )
2670 QgsDebugMsg(
"found subsymbol with invalid name: " + it.key() );
2675 int symlayer = parts[2].toInt();
2677 if ( !symbols.
contains( symname ) )
2679 QgsDebugMsg(
"subsymbol references invalid symbol: " + symname );
2696 QgsDebugMsg(
"symbol layer refused subsymbol: " + it.key() );
2703 for (
int i = 0; i < subsymbols.
count(); i++ )
2704 symbols.
take( subsymbols[i] );
2727 delete symbols.
value( name );
2740 if ( rampType ==
"gradient" )
2742 else if ( rampType ==
"random" )
2744 else if ( rampType ==
"colorbrewer" )
2746 else if ( rampType ==
"cpt-city" )
2750 QgsDebugMsg(
"unknown colorramp type " + rampType );
2775 return color.
name();
2785 for ( ; it != components.
end(); ++it )
2793 if ( colors.
length() > 0 )
2800 it = components.
begin();
2801 for ( ; it != components.
end(); ++it )
2809 if ( colors.
length() > 0 )
2816 it = components.
begin();
2817 for ( ; it != components.
end(); ++it )
2825 if ( colors.
length() > 0 )
2832 it = components.
begin();
2833 for ( ; it != components.
end(); ++it )
2890 if ( dragDataElem.
tagName() ==
"ColorSchemeModelDragData" )
2893 int nChildNodes = nodeList.
size();
2896 for (
int i = 0; i < nChildNodes; ++i )
2899 if ( currentElem.
isNull() )
2906 namedColor.second = currentElem.
attribute(
"label",
"" );
2908 mimeColors << namedColor;
2913 if ( mimeColors.
length() == 0 && data->
hasFormat(
"application/x-colorobject-list" ) )
2916 QByteArray encodedData = data->
data(
"application/x-colorobject-list" );
2921 if ( colorsNodes.
length() > 0 )
2925 int nChildNodes = colorNodeList.
size();
2928 for (
int i = 0; i < nChildNodes; ++i )
2932 if ( currentElem.
isNull() )
2940 if ( colorNodes.
length() > 0 )
2945 if ( colorParts.
length() < 3 )
2950 int red = colorParts.
at( 0 ).toDouble() * 255;
2951 int green = colorParts.
at( 1 ).toDouble() * 255;
2952 int blue = colorParts.
at( 2 ).toDouble() * 255;
2954 namedColor.first =
QColor( red, green, blue );
2955 if ( nameNodes.
length() > 0 )
2958 namedColor.second = nameElem.
text();
2960 mimeColors << namedColor;
2971 for ( ; it != parsedColors.
end(); ++it )
2973 mimeColors << qMakePair( *it,
QString() );
2983 mimeColors << qMakePair( mimeColor,
QString() );
2999 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
3003 namedColor.
setAttribute(
"label", ( *colorIt ).second );
3016 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
3018 colorListString << ( *colorIt ).
first.name();
3020 mimeData->
setText( colorListString.
join(
"\n" ) );
3023 if ( colorList.
length() > 0 )
3033 if ( !file.
open( QIODevice::ReadWrite ) )
3039 stream <<
"GIMP Palette" << endl;
3042 stream <<
"Name: QGIS Palette" << endl;
3046 stream <<
"Name: " << paletteName << endl;
3048 stream <<
"Columns: 4" << endl;
3049 stream <<
"#" << endl;
3053 QColor color = ( *colorIt ).first;
3059 stream <<
"\t" << (( *colorIt ).second.isEmpty() ? color.
name() : ( *colorIt ).second ) << endl;
3070 if ( !file.
open( QIODevice::ReadOnly ) )
3073 return importedColors;
3082 return importedColors;
3092 QRegExp nameRx(
"Name:\\s*(\\S.*)$" );
3093 if ( nameRx.
indexIn( line ) != -1 )
3095 name = nameRx.
cap( 1 );
3107 return importedColors;
3111 QRegExp rx(
"^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)(\\s.*)?$" );
3112 while ( !in.
atEnd() )
3115 if ( rx.
indexIn( line ) == -1 )
3139 importedColors << qMakePair( color, label );
3144 return importedColors;
3164 containsAlpha =
false;
3170 QRegExp hexColorAlphaRx(
"^\\s*#?([0-9a-fA-F]{6})([0-9a-fA-F]{2})\\s*$" );
3171 if ( hexColorAlphaRx.
indexIn( colorStr ) != -1 )
3176 int alphaHex = hexColorAlphaRx.
cap( 2 ).
toInt( &alphaOk, 16 );
3178 if ( parsedColor.
isValid() && alphaOk )
3181 containsAlpha =
true;
3189 QRegExp hexColorRx2(
"^\\s*(?:[0-9a-fA-F]{3}){1,2}\\s*$" );
3190 if ( hexColorRx2.
indexIn( colorStr ) != -1 )
3196 containsAlpha =
false;
3203 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*$" );
3204 if ( rgbFormatRx.
indexIn( colorStr ) != -1 )
3206 int r = rgbFormatRx.
cap( 1 ).
toInt();
3207 int g = rgbFormatRx.
cap( 2 ).
toInt();
3208 int b = rgbFormatRx.
cap( 3 ).
toInt();
3209 parsedColor.
setRgb( r, g, b );
3212 containsAlpha =
false;
3218 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*$" );
3219 if ( rgbPercentFormatRx.
indexIn( colorStr ) != -1 )
3221 int r = qRound( rgbPercentFormatRx.
cap( 1 ).
toDouble() * 2.55 );
3222 int g = qRound( rgbPercentFormatRx.
cap( 2 ).
toDouble() * 2.55 );
3223 int b = qRound( rgbPercentFormatRx.
cap( 3 ).
toDouble() * 2.55 );
3224 parsedColor.
setRgb( r, g, b );
3227 containsAlpha =
false;
3233 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*$" );
3234 if ( rgbaFormatRx.
indexIn( colorStr ) != -1 )
3236 int r = rgbaFormatRx.
cap( 1 ).
toInt();
3237 int g = rgbaFormatRx.
cap( 2 ).
toInt();
3238 int b = rgbaFormatRx.
cap( 3 ).
toInt();
3239 int a = qRound( rgbaFormatRx.
cap( 4 ).
toDouble() * 255.0 );
3240 parsedColor.
setRgb( r, g, b, a );
3243 containsAlpha =
true;
3249 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*$" );
3250 if ( rgbaPercentFormatRx.
indexIn( colorStr ) != -1 )
3252 int r = qRound( rgbaPercentFormatRx.
cap( 1 ).
toDouble() * 2.55 );
3253 int g = qRound( rgbaPercentFormatRx.
cap( 2 ).
toDouble() * 2.55 );
3254 int b = qRound( rgbaPercentFormatRx.
cap( 3 ).
toDouble() * 2.55 );
3255 int a = qRound( rgbaPercentFormatRx.
cap( 4 ).
toDouble() * 255.0 );
3256 parsedColor.
setRgb( r, g, b, a );
3259 containsAlpha =
true;
3337 QImage::Format format = image->
format();
3338 if ( format != QImage::Format_ARGB32_Premultiplied && format != QImage::Format_ARGB32 )
3345 for (
int heightIndex = 0; heightIndex < image->
height(); ++heightIndex )
3347 QRgb* scanLine = ( QRgb* )image->
scanLine( heightIndex );
3348 for (
int widthIndex = 0; widthIndex < image->
width(); ++widthIndex )
3350 myRgb = scanLine[widthIndex];
3351 if ( format == QImage::Format_ARGB32_Premultiplied )
3352 scanLine[widthIndex] = qRgba( alpha * qRed( myRgb ), alpha * qGreen( myRgb ), alpha * qBlue( myRgb ), alpha * qAlpha( myRgb ) );
3354 scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), alpha * qAlpha( myRgb ) );
3362 int tab[] = { 14, 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
3363 int alpha = ( radius < 1 ) ? 16 : ( radius > 17 ) ? 1 : tab[radius-1];
3365 if ( image.
format() != QImage::Format_ARGB32_Premultiplied
3366 && image.
format() != QImage::Format_RGB32 )
3371 int r1 = rect.
top();
3373 int c1 = rect.
left();
3374 int c2 = rect.
right();
3384 i1 = i2 = ( QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3 );
3386 for (
int col = c1; col <= c2; col++ )
3388 p = image.
scanLine( r1 ) + col * 4;
3389 for (
int i = i1; i <= i2; i++ )
3390 rgba[i] = p[i] << 4;
3393 for (
int j = r1; j < r2; j++, p += bpl )
3394 for (
int i = i1; i <= i2; i++ )
3395 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3398 for (
int row = r1; row <= r2; row++ )
3400 p = image.
scanLine( row ) + c1 * 4;
3401 for (
int i = i1; i <= i2; i++ )
3402 rgba[i] = p[i] << 4;
3405 for (
int j = c1; j < c2; j++, p += 4 )
3406 for (
int i = i1; i <= i2; i++ )
3407 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3410 for (
int col = c1; col <= c2; col++ )
3412 p = image.
scanLine( r2 ) + col * 4;
3413 for (
int i = i1; i <= i2; i++ )
3414 rgba[i] = p[i] << 4;
3417 for (
int j = r1; j < r2; j++, p -= bpl )
3418 for (
int i = i1; i <= i2; i++ )
3419 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3422 for (
int row = r1; row <= r2; row++ )
3424 p = image.
scanLine( row ) + c2 * 4;
3425 for (
int i = i1; i <= i2; i++ )
3426 rgba[i] = p[i] << 4;
3429 for (
int j = c1; j < c2; j++, p -= 4 )
3430 for (
int i = i1; i <= i2; i++ )
3431 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3437 if ( alpha != 255 && alpha > 0 )
3441 double alphaFactor = alpha / 255.;
3442 int r = 0, g = 0, b = 0;
3443 rgb.
getRgb( &r, &g, &b );
3448 rgb.
setRgb( r, g, b, alpha );
3450 else if ( alpha == 0 )
3452 rgb.
setRgb( 0, 0, 0, 0 );
3459 switch ( lhs.
type() )
3463 case QVariant::UInt:
3465 case QVariant::LongLong:
3467 case QVariant::ULongLong:
3469 case QVariant::Double:
3471 case QVariant::Char:
3473 case QVariant::Date:
3475 case QVariant::Time:
3477 case QVariant::DateTime:
3484 static bool _QVariantGreaterThan(
const QVariant& lhs,
const QVariant& rhs )
3486 return ! _QVariantLessThan( lhs, rhs );
3492 if ( order == Qt::AscendingOrder )
3506 double dx = directionPoint.
x() - startPoint.
x();
3507 double dy = directionPoint.
y() - startPoint.
y();
3508 double length = sqrt( dx * dx + dy * dy );
3509 double scaleFactor = distance / length;
3510 return QPointF( startPoint.
x() + dx * scaleFactor, startPoint.
y() + dy * scaleFactor );
3520 for (
int i = 0; i < svgPaths.
size(); i++ )
3522 QDir dir( svgPaths[i] );
3523 foreach (
QString item, dir.
entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3525 svgPaths.
insert( i + 1, dir.
path() +
"/" + item );
3544 svgPaths.
append( directory );
3546 for (
int i = 0; i < svgPaths.
size(); i++ )
3548 QDir dir( svgPaths[i] );
3549 foreach (
QString item, dir.
entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3551 svgPaths.
insert( i + 1, dir.
path() +
"/" + item );
3568 if (
QFile( name ).exists() )
3577 if ( url.
scheme().
compare(
"file", Qt::CaseInsensitive ) == 0 )
3581 if (
QFile( name ).exists() )
3597 for (
int i = 0; i < svgPaths.
size(); i++ )
3599 QString svgPath = svgPaths[i];
3613 QgsDebugMsg(
"Alternative svg path: " + myLocalPath );
3614 if (
QFile( myLocalPath ).exists() )
3633 QgsDebugMsg(
"Computed alternate path but no svg there either" );
3650 bool isInSvgPathes =
false;
3651 for (
int i = 0; i < svgPaths.
size(); i++ )
3657 path = path.
mid( dir.
size() + 1 );
3658 isInSvgPathes =
true;
3663 if ( isInSvgPathes )
3672 double cx = 0, cy = 0;
3673 double area, sum = 0;
3674 for (
int i = points.
count() - 1, j = 0; j < points.
count(); i = j++ )
3676 const QPointF& p1 = points[i];
3677 const QPointF& p2 = points[j];
3678 area = p1.
x() * p2.
y() - p1.
y() * p2.
x();
3680 cx += ( p1.
x() + p2.
x() ) * area;
3681 cy += ( p1.
y() + p2.
y() ) * area;
3688 if ( points.
count() >= 2 )
3689 return QPointF(( points[0].x() + points[1].x() ) / 2, ( points[0].y() + points[1].y() ) / 2 );
3690 else if ( points.
count() == 1 )
3708 unsigned int i, pointCount = points.
count();
3711 for ( i = 0; i < pointCount; ++i ) polyline[i] =
QgsPoint( points[i].x(), points[i].y() );
3718 if ( pointOnSurfaceGeom )
3721 delete pointOnSurfaceGeom;
3734 bool inside =
false;
3736 double x = point.
x();
3737 double y = point.
y();
3739 for (
int i = 0, j = points.
count() - 1; i < points.
count(); i++ )
3741 const QPointF& p1 = points[i];
3742 const QPointF& p2 = points[j];
3744 if ( p1.
x() == x && p1.
y() == y )
3747 if (( p1.
y() < y && p2.
y() >= y ) || ( p2.
y() < y && p1.
y() >= y ) )
3749 if ( p1.
x() + ( y - p1.
y() ) / ( p2.
y() - p1.
y() )*( p2.
x() - p1.
x() ) <= x )
3760 if ( fieldOrExpression.
isEmpty() )
3779 return static_cast<const QgsExpression::NodeColumnRef*>( n )->name();
3798 breaks.
append( maximum );
3802 int minimumCount = ( int ) classes / 3;
3803 double shrink = 0.75;
3804 double highBias = 1.5;
3805 double adjustBias = 0.5 + 1.5 * highBias;
3806 int divisions = classes;
3807 double h = highBias;
3811 double dx = maximum - minimum;
3813 if ( dx == 0 && maximum == 0 )
3821 cell = qMax( qAbs( minimum ), qAbs( maximum ) );
3822 if ( adjustBias >= 1.5 * h + 0.5 )
3824 U = 1 + ( 1.0 / ( 1 + h ) );
3828 U = 1 + ( 1.5 / ( 1 + adjustBias ) );
3830 small = dx < ( cell * U * qMax( 1, divisions ) * 1e-07 * 3.0 );
3837 cell = 9 + cell / 10;
3838 cell = cell * shrink;
3840 if ( minimumCount > 1 )
3842 cell = cell / minimumCount;
3848 if ( divisions > 1 )
3850 cell = cell / divisions;
3853 if ( cell < 20 * 1e-07 )
3858 double base = pow( 10.0, floor( log10( cell ) ) );
3860 if (( 2 * base ) - cell < h *( cell - unit ) )
3863 if (( 5 * base ) - cell < adjustBias *( cell - unit ) )
3866 if (( 10.0 * base ) - cell < h *( cell - unit ) )
3873 int start = floor( minimum / unit + 1e-07 );
3874 int end = ceil( maximum / unit - 1e-07 );
3877 while ( start * unit > minimum + ( 1e-07 * unit ) )
3881 while ( end * unit < maximum - ( 1e-07 * unit ) )
3889 int k = floor( 0.5 + end - start );
3890 if ( k < minimumCount )
3892 k = minimumCount - k;
3896 start = start - k / 2 + k % 2;
3900 start = start - k / 2;
3901 end = end + k / 2 + k % 2;
3904 double minimumBreak = start * unit;
3906 int count = end - start;
3908 for (
int i = 1; i < count + 1; i++ )
3910 breaks.
append( minimumBreak + i * unit );
3916 if ( breaks.
first() < minimum )
3918 breaks[0] = minimum;
3920 if ( breaks.
last() > maximum )
3922 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 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
static Qt::BrushStyle decodeBrushStyle(QString str)
void setForceVectorOutput(bool force)
void setLocked(bool locked)
QDomNodeList elementsByTagName(const QString &tagname) const
static QgsSymbolV2Map loadSymbols(QDomElement &element)
static Qt::PenCapStyle decodeSldLineCapStyle(QString str)
virtual NodeType nodeType() const =0
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent...
QString cap(int nth) const
QString & append(QChar ch)
static void multiplyImageOpacity(QImage *image, qreal alpha)
Multiplies opacity of image pixel values with a (global) transparency value.
QString writePath(QString filename, QString relativeBasePath=QString::null) const
prepare a filename to save it to the project file
QByteArray data(const QString &mimeType) const
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
static void drawStippledBackground(QPainter *painter, QRect rect)
QgsSymbolLayerV2 * createSymbolLayer(QString name, const QgsStringMap &properties=QgsStringMap()) const
create a new instance of symbol layer given symbol layer name and properties
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)
return 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)
static const QStringList svgPaths()
Returns the pathes to svg directories.
const QString expression() const
Alias for dump()
QString readLine(qint64 maxlen)
void append(const T &value)
void fill(const QColor &color)
QString attribute(const QString &name, const QString &defValue) const
QString nodeValue() const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QDateTime toDateTime() const
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 createRotationElement(QDomDocument &doc, QDomElement &element, QString rotationFunc)
void setColorData(const QVariant &color)
static QgsStringMap getVendorOptionList(QDomElement &element)
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
const_iterator constEnd() const
const T & at(int i) const
static QString ogrFeatureStyleBrush(const QColor &fillColr)
Create ogr feature style string for brush.
double clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
static void fillToSld(QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, QColor color=QColor())
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)
QDomElement nextSiblingElement(const QString &tagName) const
static QString encodeSldFontStyle(QFont::Style style)
static QPointF decodePoint(QString str)
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 QDomElement createVendorOptionElement(QDomDocument &doc, QString name, QString value)
static QColor decodeColor(QString str)
static bool convertPolygonSymbolizerToPointMarker(QDomElement &element, QgsSymbolLayerV2List &layerList)
static QDomElement createSvgParameterElement(QDomDocument &doc, QString name, QString value)
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)
double scaleFactor() const
QString join(const QString &separator) const
static QString colorToName(const QColor &color)
Returns a friendly display name for a color.
void drawLine(const QLineF &line)
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)
static void createOnlineResourceElement(QDomDocument &doc, QDomElement &element, QString path, QString format)
QDomNodeList childNodes() const
QgsSymbolLayerV2 * createSymbolLayerFromSld(QString name, QDomElement &element) const
create a new instance of symbol layer given symbol layer name and SLD
qulonglong toULongLong(bool *ok) const
static bool needMarkerLine(QDomElement &element)
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.
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.
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 QString encodeColor(QColor color)
static Qt::BrushStyle decodeSldBrushStyle(QString str)
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
QDomElement toElement() const
static WkbType flatType(WkbType type)
QList< Key > keys() const
static QString encodePenStyle(Qt::PenStyle style)
static QDomElement saveSymbol(QString symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
static QDomElement expressionToOgcFilter(const QgsExpression &exp, QDomDocument &doc, QString *errorMessage=0)
Creates OGC filter XML element.
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.
QString canonicalFilePath() const
static QgsSymbolLayerV2 * createMarkerLayerFromSld(QDomElement &element)
static QgsRenderContext createRenderContext(QPainter *p)
Creates a render context for a pixel based device.
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 QString ogrFeatureStylePen(double width, double mmScaleFactor, double mapUnitsScaleFactor, const QColor &c, Qt::PenJoinStyle joinStyle=Qt::MiterJoin, Qt::PenCapStyle capStyle=Qt::FlatCap, double offset=0.0, const QVector< qreal > *dashPattern=0)
Create ogr feature style string for pen.
static QDomElement saveColorRamp(QString name, QgsVectorColorRampV2 *ramp, QDomDocument &doc)
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 bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
void setScaleFactor(double factor)
QString localName() const
uint toUInt(bool *ok) const
QString canonicalPath() const
int toInt(bool *ok) const
static QgsSymbolLayerV2 * createFillLayerFromSld(QDomElement &element)
static QString encodePoint(QPointF point)
bool hasAttribute(const QString &name) const
static QMimeData * colorListToMimeData(const QgsNamedColorList colorList, const bool allFormats=true)
Creates mime data from a list of named colors.
static bool saveColorsToGpl(QFile &file, const QString paletteName, QgsNamedColorList colors)
Exports colors to a gpl GIMP palette file.
static QPointF offsetPoint(QPointF pt, double angle, double dist)
static QString encodeSldAlpha(int alpha)
static bool needLinePatternFill(QDomElement &element)
static QgsPaintEffectRegistry * instance()
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
static Qt::PenCapStyle decodePenCapStyle(QString str)
static QgsNamedColorList importColorsFromGpl(QFile &file, bool &ok, QString &name)
Imports colors from a gpl GIMP palette file.
static Qt::PenStyle decodePenStyle(QString str)
void setPen(const QColor &color)
void setRenderingPass(int renderingPass)
void setAttribute(const QString &name, const QString &value)
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, QString function)
static QStringList listSvgFiles()
Return a list of all available svg files.
int toInt(bool *ok, int base) const
static QDomElement saveSymbols(QgsSymbolV2Map &symbols, QString tagName, QDomDocument &doc)
const Node * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
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
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
QPaintDevice * device() const
static QFont::Style decodeSldFontStyle(QString str)
static QgsSymbolV2::OutputUnit decodeSldUom(QString str, double *scaleFactor)
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
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
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
static Qt::PenJoinStyle decodeSldLineJoinStyle(QString str)
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)
static QStringList listSvgFilesAt(QString directory)
Return a list of svg files at the specified directory.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
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.
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)
static bool pointInPolygon(const QPolygonF &points, const QPointF &point)
Calculate whether a point is within of a QPolygonF.
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
virtual QgsSymbolV2 * subSymbol()
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
void setTexture(const QPixmap &pixmap)
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
static void labelTextToSld(QDomDocument &doc, QDomElement &element, QString label, QFont font, QColor color=QColor(), double size=-1)
const T & at(int i) const
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, QColor color, double width=-1, const Qt::PenJoinStyle *penJoinStyle=0, const Qt::PenCapStyle *penCapStyle=0, const QVector< qreal > *customDashPattern=0, double dashOffset=0.0)
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
static void createGeometryElement(QDomDocument &doc, QDomElement &element, QString geomFunc)
const_iterator constBegin() const
Contains information about the context of a rendering operation.
static int decodeSldFontWeight(QString str)
QDomNode firstChild() const
QString mid(int position, int n) const
static void createOpacityElement(QDomDocument &doc, QDomElement &element, QString alphaFunc)
static QString encodeBrushStyle(Qt::BrushStyle style)
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.
QList< QPolygonF > offsetLine(QPolygonF polyline, double dist, QGis::GeometryType geometryType)
calculate geometry shifted by a specified distance
void insert(int i, const T &value)
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.
QStringList entryList(QFlags< QDir::Filter > filters, QFlags< QDir::SortFlag > sort) const
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
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
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, QString path, QString mime, QColor color, 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 Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, QString name, QColor color, QColor borderColor=QColor(), double borderWidth=-1, double size=-1)
static QgsGeometry * fromPolyline(const QgsPolyline &polyline)
Creates a new geometry from a QgsPolyline object.
void push_back(const T &value)
static Qt::PenJoinStyle decodePenJoinStyle(QString str)
static void clearSymbolMap(QgsSymbolV2Map &symbols)
static int decodeSldAlpha(QString str)
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
static QgsSymbolV2::ScaleMethod decodeScaleMethod(QString str)
double toDouble(bool *ok) const
iterator insert(const Key &key, const T &value)
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...
static QgsStringMap getSvgParameterList(QDomElement &element)
static QPointF polygonCentroid(const QPolygonF &points)
Calculate the centroid point of a QPolygonF.
void setRasterScaleFactor(double factor)
static QgsGeometry * fromPolygon(const QgsPolygon &polygon)
Creates a new geometry from a QgsPolygon.
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 bool lineFromSld(QDomElement &element, Qt::PenStyle &penStyle, QColor &color, double &width, Qt::PenJoinStyle *penJoinStyle=0, Qt::PenCapStyle *penCapStyle=0, QVector< qreal > *customDashPattern=0, double *dashOffset=0)
static QPointF polygonPointOnSurface(const QPolygonF &points)
Calculate a point within of a QPolygonF.
static QPixmap symbolPreviewPixmap(QgsSymbolV2 *symbol, QSize size, QgsRenderContext *customContext=0)
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=0)
Draw icon of the symbol that occupyies area given by size using the painter.
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
static QPointF pointOnLineWithDistance(const QPointF &startPoint, const QPointF &directionPoint, double distance)
Returns a point on the line from startPoint to directionPoint that is a certain distance away from th...
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)
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.
static void blurImageInPlace(QImage &image, const QRect &rect, int radius, bool alphaOnly)
Blurs an image in place, e.g.
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
static QgsSymbolV2::OutputUnit decodeOutputUnit(QString str)
static QString encodeSldLineCapStyle(Qt::PenCapStyle style)
static void externalMarkerToSld(QDomDocument &doc, QDomElement &element, QString path, QString format, int *markIndex=0, QColor color=QColor(), double size=-1)
static QColor parseColor(QString colorStr, bool strictEval=false)
Attempts to parse a string as a color using a variety of common formats, including hex codes...
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 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
const T value(const Key &key) const
static bool needEllipseMarker(QDomElement &element)
static QString encodePenCapStyle(Qt::PenCapStyle style)