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() );
341 if ( lst.
count() < 2 )
344 if ( lst.
count() < 6 )
379 else if ( str ==
"MapUnit" )
383 else if ( str ==
"Pixel" )
398 *scaleFactor = 0.001;
399 return "http://www.opengeospatial.org/se/units/metre";
415 if ( str ==
"http://www.opengeospatial.org/se/units/metre" )
418 *scaleFactor = 1000.0;
421 else if ( str ==
"http://www.opengeospatial.org/se/units/foot" )
424 *scaleFactor = 304.8;
431 *scaleFactor = 1 / 0.00028;
443 vectorString.
append(
";" );
456 for ( ; it != realList.
constEnd(); ++it )
458 resultVector.
append( it->toDouble() );
472 vectorString.
append(
" " );
485 for ( ; it != realList.
constEnd(); ++it )
487 resultVector.
append( it->toDouble() );
497 switch ( scaleMethod )
500 encodedValue =
"diameter";
503 encodedValue =
"area";
513 if ( str ==
"diameter" )
527 if ( s.
compare(
"Lighten", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Lighten;
528 if ( s.
compare(
"Screen", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Screen;
529 if ( s.
compare(
"Dodge", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorDodge;
530 if ( s.
compare(
"Addition", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Plus;
531 if ( s.
compare(
"Darken", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Darken;
532 if ( s.
compare(
"Multiply", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Multiply;
533 if ( s.
compare(
"Burn", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorBurn;
534 if ( s.
compare(
"Overlay", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Overlay;
535 if ( s.
compare(
"SoftLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_SoftLight;
536 if ( s.
compare(
"HardLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_HardLight;
537 if ( s.
compare(
"Difference", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Difference;
538 if ( s.
compare(
"Subtract", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Exclusion;
539 return QPainter::CompositionMode_SourceOver;
552 pixmap.
fill( Qt::transparent );
554 painter.
begin( &pixmap );
570 maxBleed = layerMaxBleed > maxBleed ? layerMaxBleed : maxBleed;
580 painter.
begin( &picture );
593 pixmap.
fill( Qt::transparent );
595 painter.
begin( &pixmap );
601 return QIcon( pixmap );
612 pixmap.
fill( Qt::transparent );
615 painter.
begin( &pixmap );
622 for (
int i = 0; i < size.
width(); i++ )
635 uchar pixDataRGB[] = { 255, 255, 255, 255,
640 QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
657 #if !defined(GEOS_VERSION_MAJOR) || !defined(GEOS_VERSION_MINOR) || \
658 ((GEOS_VERSION_MAJOR<3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR<3)))
662 double x1 = p1.
x(), y1 = p1.
y(), x2 = p2.
x(), y2 = p2.
y();
664 if ( x1 == x2 && y1 == y2 )
668 t = ( x1 == x2 ? DBL_MAX : ( y2 - y1 ) / ( x2 - x1 ) );
672 angle = ( y2 > y1 ?
M_PI / 2 :
M_PI * 3 / 2 );
674 angle = ( x2 > x1 ? 0 :
M_PI );
676 angle = ( y2 > y1 ? atan( t ) :
M_PI + atan( t ) );
678 angle = ( y2 > y1 ?
M_PI + atan( t ) : atan( t ) );
686 return QPointF( pt.
x() + dist * cos( angle ), pt.
y() + dist * sin( angle ) );
693 if (( t1 == DBL_MAX && t2 == DBL_MAX ) || qAbs( atan( t1 ) - atan( t2 ) ) < 0.175 )
697 if ( t1 == DBL_MAX || t2 == DBL_MAX )
703 QPointF pSwp = p1; p1 = p2; p2 = pSwp;
704 double tSwp = t1; t1 = t2; t2 = tSwp;
712 x = (( p1.
y() - p2.
y() ) + t2 * p2.
x() - t1 * p1.
x() ) / ( t2 - t1 );
715 y = p1.
y() + t1 * ( x - p1.
x() );
721 int i, pointCount = polyline.
count();
724 resultLine.
resize( pointCount );
728 for ( i = 0; i < pointCount; ++i, tempPtr++ )
729 resultLine[i] =
QPointF( tempPtr->
x(), tempPtr->
y() );
737 for (
int ring = 0; ring < polygon.
size(); ++ring )
738 resultGeom.
append( makeOffsetGeometry( polygon[ ring ] ) );
747 if ( polyline.
count() < 2 )
749 resultLine.
append( polyline );
756 #if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
757 ((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
759 unsigned int i, pointCount = polyline.
count();
763 for ( i = 0; i < pointCount; ++i, tempPtr++ )
764 tempPolyline[i] =
QgsPoint( tempPtr->
rx(), tempPtr->
ry() );
769 int quadSegments = 0;
770 double mitreLimit = 2.0;
773 offsetGeom = tempGeometry->
buffer( -dist, quadSegments, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, mitreLimit );
775 offsetGeom = tempGeometry->
offsetCurve( dist, quadSegments, GEOSBUF_JOIN_MITRE, mitreLimit );
780 tempGeometry = offsetGeom;
798 for (
int part = 0; part < tempMPolyline.
count(); ++part )
800 resultLine.
append( makeOffsetGeometry( tempMPolyline[ part ] ) );
809 for (
int part = 0; part < tempMPolygon.
count(); ++part )
811 resultLine.
append( makeOffsetGeometry( tempMPolygon[ part ] ) );
821 resultLine.
append( polyline );
826 double angle = 0.0, t_new, t_old = 0;
829 bool first_point =
true;
831 for (
int i = 1; i < polyline.
count(); i++ )
835 if ( !
lineInfo( p1, p2, angle, t_new ) )
861 resultLine.
append( newLine );
870 int pointCount = polyline.
count();
872 if ( pointCount > 3 && polyline[ 0 ].x() == polyline[ pointCount - 1 ].x() && polyline[ 0 ].y() == polyline[ pointCount - 1 ].y() )
876 else if ( pointCount > 1 )
880 return offsetLine( polyline, dist, geometryType );
891 while ( !layerNode.
isNull() )
924 if ( layers.
count() == 0 )
933 if ( symbolType ==
"line" )
935 else if ( symbolType ==
"fill" )
937 else if ( symbolType ==
"marker" )
941 QgsDebugMsg(
"unknown symbol type " + symbolType );
980 if ( !effectElem.
isNull() )
1044 symbolElem.
save( stream, -1 );
1061 if ( symbolizerName ==
"PointSymbolizer" )
1065 if ( graphicElem.
isNull() )
1067 QgsDebugMsg(
"Graphic element not found in PointSymbolizer" );
1103 if ( symbolizerName ==
"LineSymbolizer" )
1107 if ( strokeElem.
isNull() )
1109 QgsDebugMsg(
"Stroke element not found in LineSymbolizer" );
1137 if ( symbolizerName ==
"PolygonSymbolizer" )
1144 QgsDebugMsg(
"neither Fill nor Stroke element not found in PolygonSymbolizer" );
1222 if ( strokeElem.
isNull() )
1241 if ( graphicElem.
isNull() )
1264 if ( graphicElem.
isNull() )
1268 if ( externalGraphicElem.
isNull() )
1273 if ( formatElem.
isNull() )
1277 if ( format !=
"image/svg+xml" )
1279 QgsDebugMsg(
"unsupported External Graphic format found: " + format );
1286 if ( !onlineResourceElem.
isNull() )
1291 else if ( !inlineContentElem.
isNull() )
1305 if ( graphicElem.
isNull() )
1313 if ( wellKnownNameElem.
isNull() )
1323 if ( graphicElem.
isNull() )
1332 if ( formatElem.
isNull() )
1336 if ( format !=
"ttf" )
1338 QgsDebugMsg(
"unsupported Graphic Mark format found: " + format );
1345 if ( !onlineResourceElem.
isNull() )
1349 if ( !markIndexElem.
isNull() )
1352 else if ( !inlineContentElem.
isNull() )
1368 if ( graphicElem.
isNull() )
1374 if ( it.key() ==
"widthHeightFactor" )
1386 if ( strokeElem.
isNull() )
1390 if ( graphicStrokeElem.
isNull() )
1403 if ( graphicFillElem.
isNull() )
1407 if ( graphicElem.
isNull() )
1413 QColor fillColor, borderColor;
1414 double size, borderWidth;
1415 Qt::PenStyle borderStyle;
1416 if ( !
wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderStyle, borderWidth, size ) )
1419 if ( name !=
"horline" )
1428 if ( !ok || angle == 0 )
1436 Q_UNUSED( element );
1447 if ( graphicFillElem.
isNull() )
1472 bool validFill =
false, validBorder =
false;
1477 Qt::BrushStyle fillStyle;
1479 if (
fillFromSld( fillElem, fillStyle, fillColor ) )
1485 Qt::PenStyle borderStyle;
1486 double borderWidth = 1.0, dashOffset = 0.0;
1489 if (
lineFromSld( strokeElem, borderStyle, borderColor, borderWidth,
1490 0, 0, &customDashPattern, &dashOffset ) )
1493 if ( validFill || validBorder )
1496 map[
"name"] =
"square";
1497 map[
"color"] =
encodeColor( validFill ? fillColor : Qt::transparent );
1498 map[
"color_border"] =
encodeColor( validBorder ? borderColor : Qt::transparent );
1508 bool validFill =
false, validBorder =
false;
1513 QColor fillColor, borderColor;
1514 double borderWidth = 1.0, size = 0.0,
angle = 0.0;
1519 if ( !graphicFillElem.
isNull() )
1523 if ( !graphicElem.
isNull() )
1530 while ( !graphicChildElem.
isNull() )
1532 if ( graphicChildElem.
localName() ==
"Mark" )
1536 if ( !wellKnownNameElem.
isNull() )
1544 if ( graphicChildElem.
localName() ==
"ExternalGraphic" || graphicChildElem.
localName() ==
"Mark" )
1548 if ( formatElem.
isNull() )
1555 if ( graphicChildElem.
localName() ==
"ExternalGraphic" && format !=
"image/svg+xml" )
1560 if ( graphicChildElem.
localName() ==
"Mark" && format !=
"ttf" )
1567 if ( !onlineResourceElem.
isNull() )
1569 name = onlineResourceElem.
attributeNS(
"http://www.w3.org/1999/xlink",
"href" );
1571 if ( graphicChildElem.
localName() ==
"Mark" && format ==
"ttf" )
1575 name = name.
mid( 6 );
1579 if ( markIndexElem.
isNull() )
1594 else if ( !inlineContentElem.
isNull() )
1604 if ( graphicChildElem.
localName() ==
"Mark" )
1613 if ( found && graphicChildElem.
localName() ==
"Mark" )
1620 Qt::BrushStyle markFillStyle;
1623 if (
fillFromSld( markFillElem, markFillStyle, fillColor ) )
1628 Qt::PenStyle borderStyle;
1629 double borderWidth = 1.0, dashOffset = 0.0;
1633 if (
lineFromSld( markStrokeElem, borderStyle, borderColor, borderWidth,
1634 0, 0, &customDashPattern, &dashOffset ) )
1642 if ( !opacityElem.
isNull() )
1646 if ( !sizeElem.
isNull() )
1658 double v = angleFunc.
toDouble( &ok );
1668 if ( validFill || validBorder )
1670 if ( format ==
"image/svg+xml" )
1674 map[
"fill"] = fillColor.
name();
1675 map[
"outline"] = borderColor.
name();
1685 else if ( format ==
"ttf" )
1689 map[
"chr"] = markIndex;
1690 map[
"color"] =
encodeColor( validFill ? fillColor : Qt::transparent );
1705 layerList << layers;
1713 switch ( brushStyle )
1718 case Qt::SolidPattern:
1722 if ( color.
alpha() < 255 )
1727 case Qt::CrossPattern:
1728 case Qt::DiagCrossPattern:
1729 case Qt::HorPattern:
1730 case Qt::VerPattern:
1731 case Qt::BDiagPattern:
1732 case Qt::FDiagPattern:
1733 case Qt::Dense1Pattern:
1734 case Qt::Dense2Pattern:
1735 case Qt::Dense3Pattern:
1736 case Qt::Dense4Pattern:
1737 case Qt::Dense5Pattern:
1738 case Qt::Dense6Pattern:
1739 case Qt::Dense7Pattern:
1758 wellKnownMarkerToSld( doc, graphicElem, patternName, fillColor, borderColor, Qt::SolidLine, -1, -1 );
1765 brushStyle = Qt::SolidPattern;
1766 color =
QColor(
"#808080" );
1770 brushStyle = Qt::NoBrush;
1777 if ( graphicFillElem.
isNull() )
1784 if ( it.key() ==
"fill" )
1785 color =
QColor( it.value() );
1786 else if ( it.key() ==
"fill-opacity" )
1793 if ( graphicElem.
isNull() )
1796 QString patternName =
"square";
1797 QColor fillColor, borderColor;
1798 double borderWidth, size;
1799 Qt::PenStyle borderStyle;
1800 if ( !
wellKnownMarkerFromSld( graphicElem, patternName, fillColor, borderColor, borderStyle, borderWidth, size ) )
1804 if ( brushStyle == Qt::NoBrush )
1816 Qt::PenStyle penStyle,
const QColor& color,
double width,
1817 const Qt::PenJoinStyle *penJoinStyle,
const Qt::PenCapStyle *penCapStyle,
1823 if ( penStyle == Qt::CustomDashLine && !customDashPattern )
1825 element.
appendChild( doc.
createComment(
"WARNING: Custom dash pattern required but not provided. Using default dash pattern." ) );
1826 penStyle = Qt::DashLine;
1845 case Qt::DashDotLine:
1851 case Qt::DashDotDotLine:
1860 case Qt::CustomDashLine:
1861 Q_ASSERT( customDashPattern );
1862 pattern = customDashPattern;
1873 if ( color.
alpha() < 255 )
1883 if ( pattern->
size() > 0 )
1893 Qt::PenStyle &penStyle,
QColor &color,
double &width,
1894 Qt::PenJoinStyle *penJoinStyle, Qt::PenCapStyle *penCapStyle,
1899 penStyle = Qt::SolidLine;
1900 color =
QColor(
"#000000" );
1903 *penJoinStyle = Qt::BevelJoin;
1905 *penCapStyle = Qt::SquareCap;
1906 if ( customDashPattern )
1907 customDashPattern->
clear();
1913 penStyle = Qt::NoPen;
1923 if ( it.key() ==
"stroke" )
1925 color =
QColor( it.value() );
1927 else if ( it.key() ==
"stroke-opacity" )
1931 else if ( it.key() ==
"stroke-width" )
1934 double w = it.value().toDouble( &ok );
1938 else if ( it.key() ==
"stroke-linejoin" && penJoinStyle )
1942 else if ( it.key() ==
"stroke-linecap" && penCapStyle )
1946 else if ( it.key() ==
"stroke-dasharray" )
1949 if ( dashPattern.
size() > 0 )
1953 bool dashPatternFound =
false;
1955 if ( dashPattern.
count() == 2 )
1957 if ( dashPattern.
at( 0 ) == 4.0 &&
1958 dashPattern.
at( 1 ) == 2.0 )
1960 penStyle = Qt::DashLine;
1961 dashPatternFound =
true;
1963 else if ( dashPattern.
at( 0 ) == 1.0 &&
1964 dashPattern.
at( 1 ) == 2.0 )
1966 penStyle = Qt::DotLine;
1967 dashPatternFound =
true;
1970 else if ( dashPattern.
count() == 4 )
1972 if ( dashPattern.
at( 0 ) == 4.0 &&
1973 dashPattern.
at( 1 ) == 2.0 &&
1974 dashPattern.
at( 2 ) == 1.0 &&
1975 dashPattern.
at( 3 ) == 2.0 )
1977 penStyle = Qt::DashDotLine;
1978 dashPatternFound =
true;
1981 else if ( dashPattern.
count() == 6 )
1983 if ( dashPattern.
at( 0 ) == 4.0 &&
1984 dashPattern.
at( 1 ) == 2.0 &&
1985 dashPattern.
at( 2 ) == 1.0 &&
1986 dashPattern.
at( 3 ) == 2.0 &&
1987 dashPattern.
at( 4 ) == 1.0 &&
1988 dashPattern.
at( 5 ) == 2.0 )
1990 penStyle = Qt::DashDotDotLine;
1991 dashPatternFound =
true;
1996 if ( !dashPatternFound )
1998 if ( customDashPattern )
2000 penStyle = Qt::CustomDashLine;
2001 *customDashPattern = dashPattern;
2005 QgsDebugMsg(
"custom dash pattern required but not provided. Using default dash pattern." );
2006 penStyle = Qt::DashLine;
2011 else if ( it.key() ==
"stroke-dashoffset" && dashOffset )
2014 double d = it.value().toDouble( &ok );
2025 const QColor& color,
double size )
2045 QColor &color,
double &size )
2051 if ( externalGraphicElem.
isNull() )
2057 if ( !sizeElem.
isNull() )
2070 const QColor& color,
double size )
2086 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2100 QColor &color,
double &size )
2115 if ( !markIndexElem.
isNull() )
2125 Qt::BrushStyle b = Qt::SolidPattern;
2131 if ( !sizeElem.
isNull() )
2144 double borderWidth,
double size )
2146 wellKnownMarkerToSld( doc, element, name, color, borderColor, Qt::SolidLine, borderWidth, size );
2150 const QString& name,
const QColor& color,
const QColor& borderColor, Qt::PenStyle borderStyle,
2151 double borderWidth,
double size )
2164 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2172 lineToSld( doc, strokeElem, borderStyle, borderColor, borderWidth );
2187 double &borderWidth,
double &size )
2189 Qt::PenStyle borderStyle;
2195 double &borderWidth,
double &size )
2201 borderColor =
QColor(
"#000000" );
2210 if ( !wellKnownNameElem.
isNull() )
2213 QgsDebugMsg(
"found Mark with well known name: " + name );
2218 Qt::BrushStyle b = Qt::SolidPattern;
2224 lineFromSld( strokeElem, borderStyle, borderColor, borderWidth );
2229 if ( !sizeElem.
isNull() )
2242 if ( !rotationFunc.
isEmpty() )
2253 if ( !rotationElem.
isNull() )
2274 if ( !opacityElem.
isNull() )
2304 if ( displacementElem.
isNull() )
2308 if ( !dispXElem.
isNull() )
2313 offset.
setX( offsetX );
2317 if ( !dispYElem.
isNull() )
2322 offset.
setY( offsetY );
2330 const QColor& color,
double size )
2350 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2356 Qt::PenJoinStyle joinStyle,
2357 Qt::PenCapStyle capStyle,
2362 penStyle.
append(
"PEN(" );
2365 penStyle.
append(
",w:" );
2371 if ( dashPattern && dashPattern->
size() > 0 )
2373 penStyle.
append(
",p:\"" );
2375 for ( ; pIt != dashPattern->
constEnd(); ++pIt )
2388 penStyle.
append(
",cap:" );
2403 penStyle.
append(
",j:" );
2404 switch ( joinStyle )
2420 penStyle.
append(
",dp:" );
2432 brushStyle.
append(
"BRUSH(" );
2433 brushStyle.
append(
"fc:" );
2435 brushStyle.
append(
")" );
2476 if ( geometryElem.
isNull() )
2492 if ( !filterElem.
isNull() )
2500 if ( element.
tagName() !=
"Filter" )
2503 if ( filterNodes.
size() > 0 )
2539 onlineResourceElem.
setAttribute(
"xlink:type",
"simple" );
2553 if ( onlineResourceElem.
isNull() )
2556 path = onlineResourceElem.
attributeNS(
"http://www.w3.org/1999/xlink",
"href" );
2559 if ( formatElem.
isNull() )
2580 while ( !paramElem.
isNull() )
2582 if ( paramElem.
localName() ==
"SvgParameter" || paramElem.
localName() ==
"CssParameter" )
2588 params[ name ] = value;
2610 while ( !paramElem.
isNull() )
2616 params[ name ] = value;
2639 props[propKey] = propValue;
2667 if ( e.
tagName() ==
"symbol" )
2670 if ( symbol != NULL )
2688 if ( it.key()[0] !=
'@' )
2692 subsymbols.
append( it.key() );
2695 if ( parts.
count() < 3 )
2697 QgsDebugMsg(
"found subsymbol with invalid name: " + it.key() );
2702 int symlayer = parts[2].toInt();
2704 if ( !symbols.
contains( symname ) )
2706 QgsDebugMsg(
"subsymbol references invalid symbol: " + symname );
2723 QgsDebugMsg(
"symbol layer refused subsymbol: " + it.key() );
2730 for (
int i = 0; i < subsymbols.
count(); i++ )
2731 symbols.
take( subsymbols[i] );
2754 delete symbols.
value( name );
2767 if ( rampType ==
"gradient" )
2769 else if ( rampType ==
"random" )
2771 else if ( rampType ==
"colorbrewer" )
2773 else if ( rampType ==
"cpt-city" )
2777 QgsDebugMsg(
"unknown colorramp type " + rampType );
2802 return color.
name();
2812 for ( ; it != components.
end(); ++it )
2820 if ( colors.
length() > 0 )
2827 it = components.
begin();
2828 for ( ; it != components.
end(); ++it )
2836 if ( colors.
length() > 0 )
2843 it = components.
begin();
2844 for ( ; it != components.
end(); ++it )
2852 if ( colors.
length() > 0 )
2859 it = components.
begin();
2860 for ( ; it != components.
end(); ++it )
2917 if ( dragDataElem.
tagName() ==
"ColorSchemeModelDragData" )
2920 int nChildNodes = nodeList.
size();
2923 for (
int i = 0; i < nChildNodes; ++i )
2926 if ( currentElem.
isNull() )
2933 namedColor.second = currentElem.
attribute(
"label",
"" );
2935 mimeColors << namedColor;
2940 if ( mimeColors.
length() == 0 && data->
hasFormat(
"application/x-colorobject-list" ) )
2943 QByteArray encodedData = data->
data(
"application/x-colorobject-list" );
2948 if ( colorsNodes.
length() > 0 )
2952 int nChildNodes = colorNodeList.
size();
2955 for (
int i = 0; i < nChildNodes; ++i )
2959 if ( currentElem.
isNull() )
2967 if ( colorNodes.
length() > 0 )
2972 if ( colorParts.
length() < 3 )
2977 int red = colorParts.
at( 0 ).toDouble() * 255;
2978 int green = colorParts.
at( 1 ).toDouble() * 255;
2979 int blue = colorParts.
at( 2 ).toDouble() * 255;
2981 namedColor.first =
QColor( red, green, blue );
2982 if ( nameNodes.
length() > 0 )
2985 namedColor.second = nameElem.
text();
2987 mimeColors << namedColor;
2998 for ( ; it != parsedColors.
end(); ++it )
3000 mimeColors << qMakePair( *it,
QString() );
3010 mimeColors << qMakePair( mimeColor,
QString() );
3026 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
3030 namedColor.
setAttribute(
"label", ( *colorIt ).second );
3043 for ( ; colorIt != colorList.
constEnd(); ++colorIt )
3045 colorListString << ( *colorIt ).
first.name();
3047 mimeData->
setText( colorListString.
join(
"\n" ) );
3050 if ( colorList.
length() > 0 )
3060 if ( !file.
open( QIODevice::ReadWrite ) )
3066 stream <<
"GIMP Palette" << endl;
3069 stream <<
"Name: QGIS Palette" << endl;
3073 stream <<
"Name: " << paletteName << endl;
3075 stream <<
"Columns: 4" << endl;
3076 stream <<
"#" << endl;
3080 QColor color = ( *colorIt ).first;
3086 stream <<
"\t" << (( *colorIt ).second.isEmpty() ? color.
name() : ( *colorIt ).second ) << endl;
3097 if ( !file.
open( QIODevice::ReadOnly ) )
3100 return importedColors;
3109 return importedColors;
3119 QRegExp nameRx(
"Name:\\s*(\\S.*)$" );
3120 if ( nameRx.
indexIn( line ) != -1 )
3122 name = nameRx.
cap( 1 );
3134 return importedColors;
3138 QRegExp rx(
"^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)(\\s.*)?$" );
3139 while ( !in.
atEnd() )
3142 if ( rx.
indexIn( line ) == -1 )
3166 importedColors << qMakePair( color, label );
3171 return importedColors;
3191 containsAlpha =
false;
3197 QRegExp hexColorAlphaRx(
"^\\s*#?([0-9a-fA-F]{6})([0-9a-fA-F]{2})\\s*$" );
3198 if ( hexColorAlphaRx.
indexIn( colorStr ) != -1 )
3203 int alphaHex = hexColorAlphaRx.
cap( 2 ).
toInt( &alphaOk, 16 );
3205 if ( parsedColor.
isValid() && alphaOk )
3208 containsAlpha =
true;
3216 QRegExp hexColorRx2(
"^\\s*(?:[0-9a-fA-F]{3}){1,2}\\s*$" );
3217 if ( hexColorRx2.
indexIn( colorStr ) != -1 )
3223 containsAlpha =
false;
3230 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*$" );
3231 if ( rgbFormatRx.
indexIn( colorStr ) != -1 )
3233 int r = rgbFormatRx.
cap( 1 ).
toInt();
3234 int g = rgbFormatRx.
cap( 2 ).
toInt();
3235 int b = rgbFormatRx.
cap( 3 ).
toInt();
3236 parsedColor.
setRgb( r, g, b );
3239 containsAlpha =
false;
3245 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*$" );
3246 if ( rgbPercentFormatRx.
indexIn( colorStr ) != -1 )
3248 int r = qRound( rgbPercentFormatRx.
cap( 1 ).
toDouble() * 2.55 );
3249 int g = qRound( rgbPercentFormatRx.
cap( 2 ).
toDouble() * 2.55 );
3250 int b = qRound( rgbPercentFormatRx.
cap( 3 ).
toDouble() * 2.55 );
3251 parsedColor.
setRgb( r, g, b );
3254 containsAlpha =
false;
3260 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*$" );
3261 if ( rgbaFormatRx.
indexIn( colorStr ) != -1 )
3263 int r = rgbaFormatRx.
cap( 1 ).
toInt();
3264 int g = rgbaFormatRx.
cap( 2 ).
toInt();
3265 int b = rgbaFormatRx.
cap( 3 ).
toInt();
3266 int a = qRound( rgbaFormatRx.
cap( 4 ).
toDouble() * 255.0 );
3267 parsedColor.
setRgb( r, g, b, a );
3270 containsAlpha =
true;
3276 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*$" );
3277 if ( rgbaPercentFormatRx.
indexIn( colorStr ) != -1 )
3279 int r = qRound( rgbaPercentFormatRx.
cap( 1 ).
toDouble() * 2.55 );
3280 int g = qRound( rgbaPercentFormatRx.
cap( 2 ).
toDouble() * 2.55 );
3281 int b = qRound( rgbaPercentFormatRx.
cap( 3 ).
toDouble() * 2.55 );
3282 int a = qRound( rgbaPercentFormatRx.
cap( 4 ).
toDouble() * 255.0 );
3283 parsedColor.
setRgb( r, g, b, a );
3286 containsAlpha =
true;
3325 double convertedSize = size * conversionFactor;
3336 return convertedSize;
3409 QImage::Format format = image->
format();
3410 if ( format != QImage::Format_ARGB32_Premultiplied && format != QImage::Format_ARGB32 )
3417 for (
int heightIndex = 0; heightIndex < image->
height(); ++heightIndex )
3419 QRgb* scanLine = ( QRgb* )image->
scanLine( heightIndex );
3420 for (
int widthIndex = 0; widthIndex < image->
width(); ++widthIndex )
3422 myRgb = scanLine[widthIndex];
3423 if ( format == QImage::Format_ARGB32_Premultiplied )
3424 scanLine[widthIndex] = qRgba( alpha * qRed( myRgb ), alpha * qGreen( myRgb ), alpha * qBlue( myRgb ), alpha * qAlpha( myRgb ) );
3426 scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), alpha * qAlpha( myRgb ) );
3434 int tab[] = { 14, 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
3435 int alpha = ( radius < 1 ) ? 16 : ( radius > 17 ) ? 1 : tab[radius-1];
3437 if ( image.
format() != QImage::Format_ARGB32_Premultiplied
3438 && image.
format() != QImage::Format_RGB32 )
3443 int r1 = rect.
top();
3445 int c1 = rect.
left();
3446 int c2 = rect.
right();
3456 i1 = i2 = ( QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3 );
3458 for (
int col = c1; col <= c2; col++ )
3460 p = image.
scanLine( r1 ) + col * 4;
3461 for (
int i = i1; i <= i2; i++ )
3462 rgba[i] = p[i] << 4;
3465 for (
int j = r1; j < r2; j++, p += bpl )
3466 for (
int i = i1; i <= i2; i++ )
3467 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3470 for (
int row = r1; row <= r2; row++ )
3472 p = image.
scanLine( row ) + c1 * 4;
3473 for (
int i = i1; i <= i2; i++ )
3474 rgba[i] = p[i] << 4;
3477 for (
int j = c1; j < c2; j++, p += 4 )
3478 for (
int i = i1; i <= i2; i++ )
3479 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3482 for (
int col = c1; col <= c2; col++ )
3484 p = image.
scanLine( r2 ) + col * 4;
3485 for (
int i = i1; i <= i2; i++ )
3486 rgba[i] = p[i] << 4;
3489 for (
int j = r1; j < r2; j++, p -= bpl )
3490 for (
int i = i1; i <= i2; i++ )
3491 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3494 for (
int row = r1; row <= r2; row++ )
3496 p = image.
scanLine( row ) + c2 * 4;
3497 for (
int i = i1; i <= i2; i++ )
3498 rgba[i] = p[i] << 4;
3501 for (
int j = c1; j < c2; j++, p -= 4 )
3502 for (
int i = i1; i <= i2; i++ )
3503 p[i] = ( rgba[i] += (( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3509 if ( alpha != 255 && alpha > 0 )
3513 double alphaFactor = alpha / 255.;
3514 int r = 0, g = 0, b = 0;
3515 rgb.
getRgb( &r, &g, &b );
3520 rgb.
setRgb( r, g, b, alpha );
3522 else if ( alpha == 0 )
3524 rgb.
setRgb( 0, 0, 0, 0 );
3531 switch ( lhs.
type() )
3535 case QVariant::UInt:
3537 case QVariant::LongLong:
3539 case QVariant::ULongLong:
3541 case QVariant::Double:
3543 case QVariant::Char:
3545 case QVariant::Date:
3547 case QVariant::Time:
3549 case QVariant::DateTime:
3556 static bool _QVariantGreaterThan(
const QVariant& lhs,
const QVariant& rhs )
3558 return ! _QVariantLessThan( lhs, rhs );
3564 if ( order == Qt::AscendingOrder )
3578 double dx = directionPoint.
x() - startPoint.
x();
3579 double dy = directionPoint.
y() - startPoint.
y();
3580 double length = sqrt( dx * dx + dy * dy );
3581 double scaleFactor = distance / length;
3582 return QPointF( startPoint.
x() + dx * scaleFactor, startPoint.
y() + dy * scaleFactor );
3592 for (
int i = 0; i < svgPaths.
size(); i++ )
3594 QDir dir( svgPaths[i] );
3595 Q_FOREACH (
const QString& item, dir.
entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3597 svgPaths.
insert( i + 1, dir.
path() +
"/" + item );
3616 svgPaths.
append( directory );
3618 for (
int i = 0; i < svgPaths.
size(); i++ )
3620 QDir dir( svgPaths[i] );
3621 Q_FOREACH (
const QString& item, dir.
entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
3623 svgPaths.
insert( i + 1, dir.
path() +
"/" + item );
3640 if (
QFile( name ).exists() )
3649 if ( url.
scheme().
compare(
"file", Qt::CaseInsensitive ) == 0 )
3653 if (
QFile( name ).exists() )
3669 for (
int i = 0; i < svgPaths.
size(); i++ )
3671 QString svgPath = svgPaths[i];
3685 QgsDebugMsg(
"Alternative svg path: " + myLocalPath );
3686 if (
QFile( myLocalPath ).exists() )
3705 QgsDebugMsg(
"Computed alternate path but no svg there either" );
3722 bool isInSvgPathes =
false;
3723 for (
int i = 0; i < svgPaths.
size(); i++ )
3729 path = path.
mid( dir.
size() + 1 );
3730 isInSvgPathes =
true;
3735 if ( isInSvgPathes )
3744 double cx = 0, cy = 0;
3745 double area, sum = 0;
3746 for (
int i = points.
count() - 1, j = 0; j < points.
count(); i = j++ )
3748 const QPointF& p1 = points[i];
3749 const QPointF& p2 = points[j];
3750 area = p1.
x() * p2.
y() - p1.
y() * p2.
x();
3752 cx += ( p1.
x() + p2.
x() ) * area;
3753 cy += ( p1.
y() + p2.
y() ) * area;
3760 if ( points.
count() >= 2 )
3761 return QPointF(( points[0].x() + points[1].x() ) / 2, ( points[0].y() + points[1].y() ) / 2 );
3762 else if ( points.
count() == 1 )
3780 unsigned int i, pointCount = points.
count();
3783 for ( i = 0; i < pointCount; ++i ) polyline[i] =
QgsPoint( points[i].x(), points[i].y() );
3790 if ( pointOnSurfaceGeom )
3793 delete pointOnSurfaceGeom;
3806 bool inside =
false;
3808 double x = point.
x();
3809 double y = point.
y();
3811 for (
int i = 0, j = points.
count() - 1; i < points.
count(); i++ )
3813 const QPointF& p1 = points[i];
3814 const QPointF& p2 = points[j];
3816 if ( p1.
x() == x && p1.
y() == y )
3819 if (( p1.
y() < y && p2.
y() >= y ) || ( p2.
y() < y && p1.
y() >= y ) )
3821 if ( p1.
x() + ( y - p1.
y() ) / ( p2.
y() - p1.
y() )*( p2.
x() - p1.
x() ) <= x )
3832 if ( fieldOrExpression.
isEmpty() )
3851 return static_cast<const QgsExpression::NodeColumnRef*>( n )->name();
3870 breaks.
append( maximum );
3874 int minimumCount = ( int ) classes / 3;
3875 double shrink = 0.75;
3876 double highBias = 1.5;
3877 double adjustBias = 0.5 + 1.5 * highBias;
3878 int divisions = classes;
3879 double h = highBias;
3883 double dx = maximum - minimum;
3885 if ( dx == 0 && maximum == 0 )
3893 cell = qMax( qAbs( minimum ), qAbs( maximum ) );
3894 if ( adjustBias >= 1.5 * h + 0.5 )
3896 U = 1 + ( 1.0 / ( 1 + h ) );
3900 U = 1 + ( 1.5 / ( 1 + adjustBias ) );
3902 small = dx < ( cell * U * qMax( 1, divisions ) * 1e-07 * 3.0 );
3909 cell = 9 + cell / 10;
3910 cell = cell * shrink;
3912 if ( minimumCount > 1 )
3914 cell = cell / minimumCount;
3920 if ( divisions > 1 )
3922 cell = cell / divisions;
3925 if ( cell < 20 * 1e-07 )
3930 double base = pow( 10.0, floor( log10( cell ) ) );
3932 if (( 2 * base ) - cell < h *( cell - unit ) )
3935 if (( 5 * base ) - cell < adjustBias *( cell - unit ) )
3938 if (( 10.0 * base ) - cell < h *( cell - unit ) )
3945 int start = floor( minimum / unit + 1e-07 );
3946 int end = ceil( maximum / unit - 1e-07 );
3949 while ( start * unit > minimum + ( 1e-07 * unit ) )
3953 while ( end * unit < maximum - ( 1e-07 * unit ) )
3961 int k = floor( 0.5 + end - start );
3962 if ( k < minimumCount )
3964 k = minimumCount - k;
3968 start = start - k / 2 + k % 2;
3972 start = start - k / 2;
3973 end = end + k / 2 + k % 2;
3976 double minimumBreak = start * unit;
3978 int count = end - start;
3981 for (
int i = 1; i < count + 1; i++ )
3983 breaks.
append( minimumBreak + i * unit );
3989 if ( breaks.
first() < minimum )
3991 breaks[0] = minimum;
3993 if ( breaks.
last() > maximum )
3995 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...
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 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)
const QString expression() const
Alias for dump()
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)
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)
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
QList< Key > keys() const
static QString encodePenStyle(Qt::PenStyle style)
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.
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 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 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 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()
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
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
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
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)
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)
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
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)
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 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.
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)
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, const QColor &color, double width=-1, const Qt::PenJoinStyle *penJoinStyle=0, const Qt::PenCapStyle *penCapStyle=0, const QVector< qreal > *customDashPattern=0, double dashOffset=0.0)
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 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 void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=0, const QColor &color=QColor(), double size=-1)
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.
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)
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 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)
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
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.
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 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
const T value(const Key &key) 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)