39 #include <QDomDocument> 41 #include <QDomElement> 48 #define POINTS_TO_MM 2.83464567 52 return QStringLiteral(
"%1,%2,%3,%4" ).arg( color.red() ).arg( color.green() ).arg( color.blue() ).arg( color.alpha() );
57 const QStringList lst = str.split(
',' );
58 if ( lst.count() < 3 )
62 int red, green, blue, alpha;
64 green = lst[1].toInt();
65 blue = lst[2].toInt();
67 if ( lst.count() > 3 )
69 alpha = lst[3].toInt();
71 return QColor( red, green, blue, alpha );
77 result.sprintf(
"%.2g", alpha / 255.0 );
84 double alpha = str.toDouble( &ok );
85 if ( !ok || alpha > 1 )
96 case QFont::StyleNormal:
97 return QStringLiteral(
"normal" );
98 case QFont::StyleItalic:
99 return QStringLiteral(
"italic" );
100 case QFont::StyleOblique:
101 return QStringLiteral(
"oblique" );
109 if ( str == QLatin1String(
"normal" ) )
return QFont::StyleNormal;
110 if ( str == QLatin1String(
"italic" ) )
return QFont::StyleItalic;
111 if ( str == QLatin1String(
"oblique" ) )
return QFont::StyleOblique;
112 return QFont::StyleNormal;
117 if ( weight == 50 )
return QStringLiteral(
"normal" );
118 if ( weight == 75 )
return QStringLiteral(
"bold" );
122 if ( weight < 0 )
return QStringLiteral(
"100" );
123 if ( weight > 99 )
return QStringLiteral(
"900" );
124 return QString::number( weight * 800 / 99 + 100 );
130 int weight = str.toInt( &ok );
132 return static_cast< int >( QFont::Normal );
136 if ( weight > 900 )
return 99;
137 if ( weight < 100 )
return 0;
138 return ( weight - 100 ) * 99 / 800;
146 return QStringLiteral(
"no" );
148 return QStringLiteral(
"solid" );
150 return QStringLiteral(
"dash" );
152 return QStringLiteral(
"dot" );
153 case Qt::DashDotLine:
154 return QStringLiteral(
"dash dot" );
155 case Qt::DashDotDotLine:
156 return QStringLiteral(
"dash dot dot" );
158 return QStringLiteral(
"???" );
164 if ( str == QLatin1String(
"no" ) )
return Qt::NoPen;
165 if ( str == QLatin1String(
"solid" ) )
return Qt::SolidLine;
166 if ( str == QLatin1String(
"dash" ) )
return Qt::DashLine;
167 if ( str == QLatin1String(
"dot" ) )
return Qt::DotLine;
168 if ( str == QLatin1String(
"dash dot" ) )
return Qt::DashDotLine;
169 if ( str == QLatin1String(
"dash dot dot" ) )
return Qt::DashDotDotLine;
170 return Qt::SolidLine;
178 return QStringLiteral(
"bevel" );
180 return QStringLiteral(
"miter" );
182 return QStringLiteral(
"round" );
184 return QStringLiteral(
"???" );
190 const QString cleaned = str.toLower().trimmed();
191 if ( cleaned == QLatin1String(
"bevel" ) )
192 return Qt::BevelJoin;
193 if ( cleaned == QLatin1String(
"miter" ) )
194 return Qt::MiterJoin;
195 if ( cleaned == QLatin1String(
"round" ) )
196 return Qt::RoundJoin;
197 return Qt::BevelJoin;
205 return QStringLiteral(
"bevel" );
207 return QStringLiteral(
"mitre" );
209 return QStringLiteral(
"round" );
217 if ( str == QLatin1String(
"bevel" ) )
return Qt::BevelJoin;
218 if ( str == QLatin1String(
"mitre" ) )
return Qt::MiterJoin;
219 if ( str == QLatin1String(
"round" ) )
return Qt::RoundJoin;
220 return Qt::BevelJoin;
228 return QStringLiteral(
"square" );
230 return QStringLiteral(
"flat" );
232 return QStringLiteral(
"round" );
234 return QStringLiteral(
"???" );
240 if ( str == QLatin1String(
"square" ) )
return Qt::SquareCap;
241 if ( str == QLatin1String(
"flat" ) )
return Qt::FlatCap;
242 if ( str == QLatin1String(
"round" ) )
return Qt::RoundCap;
243 return Qt::SquareCap;
251 return QStringLiteral(
"square" );
253 return QStringLiteral(
"butt" );
255 return QStringLiteral(
"round" );
263 if ( str == QLatin1String(
"square" ) )
return Qt::SquareCap;
264 if ( str == QLatin1String(
"butt" ) )
return Qt::FlatCap;
265 if ( str == QLatin1String(
"round" ) )
return Qt::RoundCap;
266 return Qt::SquareCap;
273 case Qt::SolidPattern :
274 return QStringLiteral(
"solid" );
275 case Qt::HorPattern :
276 return QStringLiteral(
"horizontal" );
277 case Qt::VerPattern :
278 return QStringLiteral(
"vertical" );
279 case Qt::CrossPattern :
280 return QStringLiteral(
"cross" );
281 case Qt::BDiagPattern :
282 return QStringLiteral(
"b_diagonal" );
283 case Qt::FDiagPattern :
284 return QStringLiteral(
"f_diagonal" );
285 case Qt::DiagCrossPattern :
286 return QStringLiteral(
"diagonal_x" );
287 case Qt::Dense1Pattern :
288 return QStringLiteral(
"dense1" );
289 case Qt::Dense2Pattern :
290 return QStringLiteral(
"dense2" );
291 case Qt::Dense3Pattern :
292 return QStringLiteral(
"dense3" );
293 case Qt::Dense4Pattern :
294 return QStringLiteral(
"dense4" );
295 case Qt::Dense5Pattern :
296 return QStringLiteral(
"dense5" );
297 case Qt::Dense6Pattern :
298 return QStringLiteral(
"dense6" );
299 case Qt::Dense7Pattern :
300 return QStringLiteral(
"dense7" );
302 return QStringLiteral(
"no" );
304 return QStringLiteral(
"???" );
310 if ( str == QLatin1String(
"solid" ) )
return Qt::SolidPattern;
311 if ( str == QLatin1String(
"horizontal" ) )
return Qt::HorPattern;
312 if ( str == QLatin1String(
"vertical" ) )
return Qt::VerPattern;
313 if ( str == QLatin1String(
"cross" ) )
return Qt::CrossPattern;
314 if ( str == QLatin1String(
"b_diagonal" ) )
return Qt::BDiagPattern;
315 if ( str == QLatin1String(
"f_diagonal" ) )
return Qt::FDiagPattern;
316 if ( str == QLatin1String(
"diagonal_x" ) )
return Qt::DiagCrossPattern;
317 if ( str == QLatin1String(
"dense1" ) )
return Qt::Dense1Pattern;
318 if ( str == QLatin1String(
"dense2" ) )
return Qt::Dense2Pattern;
319 if ( str == QLatin1String(
"dense3" ) )
return Qt::Dense3Pattern;
320 if ( str == QLatin1String(
"dense4" ) )
return Qt::Dense4Pattern;
321 if ( str == QLatin1String(
"dense5" ) )
return Qt::Dense5Pattern;
322 if ( str == QLatin1String(
"dense6" ) )
return Qt::Dense6Pattern;
323 if ( str == QLatin1String(
"dense7" ) )
return Qt::Dense7Pattern;
324 if ( str == QLatin1String(
"no" ) )
return Qt::NoBrush;
325 return Qt::SolidPattern;
332 case Qt::CrossPattern:
333 return QStringLiteral(
"cross" );
334 case Qt::DiagCrossPattern:
335 return QStringLiteral(
"x" );
342 return QStringLiteral(
"horline" );
344 return QStringLiteral(
"line" );
345 case Qt::BDiagPattern:
346 return QStringLiteral(
"slash" );
347 case Qt::FDiagPattern:
348 return QStringLiteral(
"backslash" );
351 case Qt::Dense1Pattern:
352 case Qt::Dense2Pattern:
353 case Qt::Dense3Pattern:
354 case Qt::Dense4Pattern:
355 case Qt::Dense5Pattern:
356 case Qt::Dense6Pattern:
357 case Qt::Dense7Pattern:
367 if ( str == QLatin1String(
"horline" ) )
return Qt::HorPattern;
368 if ( str == QLatin1String(
"line" ) )
return Qt::VerPattern;
369 if ( str == QLatin1String(
"cross" ) )
return Qt::CrossPattern;
370 if ( str == QLatin1String(
"slash" ) )
return Qt::BDiagPattern;
371 if ( str == QLatin1String(
"backshash" ) )
return Qt::FDiagPattern;
372 if ( str == QLatin1String(
"x" ) )
return Qt::DiagCrossPattern;
374 if ( str.startsWith( QLatin1String(
"brush://" ) ) )
386 QString s = value.toString().toLower().trimmed();
387 if ( s == QLatin1String(
"single" ) )
389 else if ( s == QLatin1String(
"reversed" ) )
391 else if ( s == QLatin1String(
"double" ) )
393 else if ( value.toInt() == 1 )
395 else if ( value.toInt() == 2 )
397 else if ( value.toInt( &intOk ) == 0 && intOk )
411 QString s = value.toString().toLower().trimmed();
412 if ( s == QLatin1String(
"plain" ) )
414 else if ( s == QLatin1String(
"lefthalf" ) )
416 else if ( s == QLatin1String(
"righthalf" ) )
418 else if ( value.toInt() == 1 )
420 else if ( value.toInt() == 2 )
422 else if ( value.toInt( &intOk ) == 0 && intOk )
437 QStringList lst = str.split(
',' );
438 if ( lst.count() != 2 )
439 return QPointF( 0, 0 );
440 return QPointF( lst[0].toDouble(), lst[1].toDouble() );
448 if ( value.isNull() )
451 if ( value.type() == QVariant::List )
453 const QVariantList list = value.toList();
454 if ( list.size() != 2 )
458 bool convertOk =
false;
459 double x = list.at( 0 ).toDouble( &convertOk );
462 double y = list.at( 1 ).toDouble( &convertOk );
467 return QPointF( x, y );
475 const QStringList list = value.toString().trimmed().split(
',' );
476 if ( list.count() != 2 )
478 bool convertOk =
false;
479 double x = list.at( 0 ).toDouble( &convertOk );
482 double y = list.at( 1 ).toDouble( &convertOk );
487 return QPointF( x, y );
501 QStringList lst =
string.split(
',' );
502 if ( lst.count() != 2 )
503 return QSizeF( 0, 0 );
504 return QSizeF( lst[0].toDouble(), lst[1].toDouble() );
512 if ( value.isNull() )
515 if ( value.type() == QVariant::List )
517 const QVariantList list = value.toList();
518 if ( list.size() != 2 )
522 bool convertOk =
false;
523 double x = list.at( 0 ).toDouble( &convertOk );
526 double y = list.at( 1 ).toDouble( &convertOk );
531 return QSizeF( x, y );
539 const QStringList list = value.toString().trimmed().split(
',' );
540 if ( list.count() != 2 )
542 bool convertOk =
false;
543 double x = list.at( 0 ).toDouble( &convertOk );
546 double y = list.at( 1 ).toDouble( &convertOk );
551 return QSizeF( x, y );
572 if ( str.startsWith( QLatin1String(
"3x:" ) ) )
575 QString chopped = str.mid( 3 );
576 lst = chopped.split(
',' );
580 lst = str.split(
',' );
582 if ( lst.count() < 2 )
585 double minScale = lst[0].toDouble();
587 minScale = minScale != 0 ? 1.0 / minScale : 0;
588 double maxScale = lst[1].toDouble();
590 maxScale = maxScale != 0 ? 1.0 / maxScale : 0;
592 if ( lst.count() < 6 )
612 *scaleFactor = 0.001;
613 return QStringLiteral(
"http://www.opengeospatial.org/se/units/metre" );
620 *scaleFactor = 1 / 0.28;
629 if ( str == QLatin1String(
"http://www.opengeospatial.org/se/units/metre" ) )
632 *scaleFactor = 1000.0;
635 else if ( str == QLatin1String(
"http://www.opengeospatial.org/se/units/foot" ) )
638 *scaleFactor = 304.8;
645 *scaleFactor = 1 / 0.00028;
651 QString vectorString;
652 QVector<qreal>::const_iterator it = v.constBegin();
653 for ( ; it != v.constEnd(); ++it )
655 if ( it != v.constBegin() )
657 vectorString.append(
';' );
659 vectorString.append( QString::number( *it ) );
666 QVector<qreal> resultVector;
668 QStringList realList = s.split(
';' );
669 QStringList::const_iterator it = realList.constBegin();
670 for ( ; it != realList.constEnd(); ++it )
672 resultVector.append( it->toDouble() );
680 QString vectorString;
681 QVector<qreal>::const_iterator it = v.constBegin();
682 for ( ; it != v.constEnd(); ++it )
684 if ( it != v.constBegin() )
686 vectorString.append(
' ' );
688 vectorString.append( QString::number( *it ) );
695 QVector<qreal> resultVector;
697 QStringList realList = s.split(
' ' );
698 QStringList::const_iterator it = realList.constBegin();
699 for ( ; it != realList.constEnd(); ++it )
701 resultVector.append( it->toDouble() );
709 QString encodedValue;
711 switch ( scaleMethod )
714 encodedValue = QStringLiteral(
"diameter" );
717 encodedValue = QStringLiteral(
"area" );
727 if ( str == QLatin1String(
"diameter" ) )
741 if ( s.compare( QLatin1String(
"Lighten" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Lighten;
742 if ( s.compare( QLatin1String(
"Screen" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Screen;
743 if ( s.compare( QLatin1String(
"Dodge" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorDodge;
744 if ( s.compare( QLatin1String(
"Addition" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Plus;
745 if ( s.compare( QLatin1String(
"Darken" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Darken;
746 if ( s.compare( QLatin1String(
"Multiply" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Multiply;
747 if ( s.compare( QLatin1String(
"Burn" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorBurn;
748 if ( s.compare( QLatin1String(
"Overlay" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Overlay;
749 if ( s.compare( QLatin1String(
"SoftLight" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_SoftLight;
750 if ( s.compare( QLatin1String(
"HardLight" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_HardLight;
751 if ( s.compare( QLatin1String(
"Difference" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Difference;
752 if ( s.compare( QLatin1String(
"Subtract" ), Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Exclusion;
753 return QPainter::CompositionMode_SourceOver;
764 QPixmap pixmap( size );
765 pixmap.fill( Qt::transparent );
767 painter.begin( &pixmap );
768 painter.setRenderHint( QPainter::Antialiasing );
777 size.setWidth( size.rwidth() - ( padding * 2 ) );
778 size.setHeight( size.rheight() - ( padding * 2 ) );
779 painter.translate( padding, padding );
789 std::unique_ptr<QgsSymbol> symbol_noDD( symbol->
clone( ) );
791 for (
const auto &layer : layers )
793 for (
int i = 0; i < layer->dataDefinedProperties().count(); ++i )
795 QgsProperty &prop = layer->dataDefinedProperties().property( i );
801 symbol_noDD->drawPreviewIcon( &painter, size, customContext, selected, expressionContext );
805 std::unique_ptr<QgsSymbol> symbolClone( symbol->
clone( ) );
806 symbolClone->drawPreviewIcon( &painter, size, customContext, selected, expressionContext );
820 maxBleed = layerMaxBleed > maxBleed ? layerMaxBleed : maxBleed;
830 painter.begin( &picture );
831 painter.setRenderHint( QPainter::Antialiasing );
835 std::unique_ptr< QgsSymbolLayer > layerClone( layer->
clone() );
836 layerClone->drawPreviewIcon( symbolContext, size );
843 QPixmap pixmap( size );
844 pixmap.fill( Qt::transparent );
846 painter.begin( &pixmap );
847 painter.setRenderHint( QPainter::Antialiasing );
855 std::unique_ptr< QgsSymbolLayer > layerClone( layer->
clone() );
856 layerClone->drawPreviewIcon( symbolContext, size );
858 return QIcon( pixmap );
868 QPixmap pixmap( size );
869 pixmap.fill( Qt::transparent );
872 painter.begin( &pixmap );
875 drawStippledBackground( &painter, QRect( padding, padding, size.width() - padding * 2, size.height() - padding * 2 ) );
879 for (
int i = 0; i < size.width(); i++ )
881 QPen pen( ramp->
color( static_cast< double >( i ) / size.width() ) );
882 painter.setPen( pen );
883 painter.drawLine( i, 0 + padding, i, size.height() - 1 - padding );
892 uchar pixDataRGB[] = { 255, 255, 255, 255,
897 QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
899 int width = ( rect.width() < rect.height() ) ?
900 rect.width() / 2.5 : rect.height() / 2.5;
901 QPixmap pix = QPixmap::fromImage( img.scaled( width, width ) );
904 brush.setTexture( pix );
905 painter->fillRect( rect, brush );
910 qreal s = ( markerSize - 1 ) / 2.0;
915 p.setPen( QColor( 50, 100, 120, 200 ) );
916 p.setBrush( QColor( 200, 200, 210, 120 ) );
917 p.drawEllipse( x - s, y - s, s * 2, s * 2 );
920 p.setPen( QColor( 255, 0, 0 ) );
921 p.drawLine( x - s, y + s, x + s, y - s );
922 p.drawLine( x - s, y - s, x + s, y + s );
934 static QPolygonF makeOffsetGeometry(
const QgsPolylineXY &polyline )
936 int i, pointCount = polyline.count();
938 QPolygonF resultLine;
939 resultLine.resize( pointCount );
943 for ( i = 0; i < pointCount; ++i, tempPtr++ )
944 resultLine[i] = QPointF( tempPtr->
x(), tempPtr->
y() );
948 static QList<QPolygonF> makeOffsetGeometry(
const QgsPolygonXY &polygon )
950 QList<QPolygonF> resultGeom;
951 resultGeom.reserve( polygon.size() );
952 for (
int ring = 0; ring < polygon.size(); ++ring )
953 resultGeom.append( makeOffsetGeometry( polygon[ ring ] ) );
959 QList<QPolygonF> resultLine;
961 if ( polyline.count() < 2 )
963 resultLine.append( polyline );
967 unsigned int i, pointCount = polyline.count();
970 QPointF *tempPtr = polyline.data();
971 for ( i = 0; i < pointCount; ++i, tempPtr++ )
972 tempPolyline[i] =
QgsPointXY( tempPtr->rx(), tempPtr->ry() );
975 if ( !tempGeometry.
isNull() )
977 int quadSegments = 0;
978 double miterLimit = 2.0;
986 if ( !offsetGeom.
isNull() )
988 tempGeometry = offsetGeom;
993 resultLine.append( makeOffsetGeometry( line ) );
998 resultLine.append( makeOffsetGeometry( tempGeometry.
asPolygon() ) );
1004 resultLine.reserve( tempMPolyline.count() );
1005 for (
int part = 0; part < tempMPolyline.count(); ++part )
1007 resultLine.append( makeOffsetGeometry( tempMPolyline[ part ] ) );
1014 resultLine.reserve( tempMPolygon.count() );
1015 for (
int part = 0; part < tempMPolygon.count(); ++part )
1017 resultLine.append( makeOffsetGeometry( tempMPolygon[ part ] ) );
1025 resultLine.append( polyline );
1035 QDomNode layerNode = element.firstChild();
1037 while ( !layerNode.isNull() )
1039 QDomElement e = layerNode.toElement();
1042 if ( e.tagName() != QLatin1String(
"layer" ) )
1053 QDomElement s = e.firstChildElement( QStringLiteral(
"symbol" ) );
1060 QgsDebugMsg(
"symbol layer refused subsymbol: " + s.attribute(
"name" ) );
1063 layers.append( layer );
1067 layerNode = layerNode.nextSibling();
1070 if ( layers.isEmpty() )
1072 QgsDebugMsg( QStringLiteral(
"no layers for symbol" ) );
1076 QString symbolType = element.attribute( QStringLiteral(
"type" ) );
1079 if ( symbolType == QLatin1String(
"line" ) )
1081 else if ( symbolType == QLatin1String(
"fill" ) )
1083 else if ( symbolType == QLatin1String(
"marker" ) )
1087 QgsDebugMsg(
"unknown symbol type " + symbolType );
1091 if ( element.hasAttribute( QStringLiteral(
"outputUnit" ) ) )
1095 if ( element.hasAttribute( ( QStringLiteral(
"mapUnitScale" ) ) ) )
1098 double oldMin = element.attribute( QStringLiteral(
"mapUnitMinScale" ), QStringLiteral(
"0.0" ) ).toDouble();
1099 mapUnitScale.
minScale = oldMin != 0 ? 1.0 / oldMin : 0;
1100 double oldMax = element.attribute( QStringLiteral(
"mapUnitMaxScale" ), QStringLiteral(
"0.0" ) ).toDouble();
1101 mapUnitScale.
maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
1104 symbol->
setOpacity( element.attribute( QStringLiteral(
"alpha" ), QStringLiteral(
"1.0" ) ).toDouble() );
1105 symbol->
setClipFeaturesToExtent( element.attribute( QStringLiteral(
"clip_to_extent" ), QStringLiteral(
"1" ) ).toInt() );
1106 symbol->
setForceRHR( element.attribute( QStringLiteral(
"force_rhr" ), QStringLiteral(
"0" ) ).toInt() );
1112 QString layerClass = element.attribute( QStringLiteral(
"class" ) );
1113 bool locked = element.attribute( QStringLiteral(
"locked" ) ).toInt();
1114 bool enabled = element.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"1" ) ).toInt();
1115 int pass = element.attribute( QStringLiteral(
"pass" ) ).toInt();
1132 QDomElement effectElem = element.firstChildElement( QStringLiteral(
"effect" ) );
1133 if ( !effectElem.isNull() )
1141 QDomElement ddProps = element.firstChildElement( QStringLiteral(
"data_defined_properties" ) );
1142 if ( !ddProps.isNull() )
1161 return QStringLiteral(
"line" );
1163 return QStringLiteral(
"marker" );
1165 return QStringLiteral(
"fill" );
1174 QDomElement symEl = doc.createElement( QStringLiteral(
"symbol" ) );
1175 symEl.setAttribute( QStringLiteral(
"type" ), _nameForSymbolType( symbol->
type() ) );
1176 symEl.setAttribute( QStringLiteral(
"name" ), name );
1177 symEl.setAttribute( QStringLiteral(
"alpha" ), QString::number( symbol->
opacity() ) );
1178 symEl.setAttribute( QStringLiteral(
"clip_to_extent" ), symbol->
clipFeaturesToExtent() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
1179 symEl.setAttribute( QStringLiteral(
"force_rhr" ), symbol->
forceRHR() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
1186 QDomElement layerEl = doc.createElement( QStringLiteral(
"layer" ) );
1187 layerEl.setAttribute( QStringLiteral(
"class" ), layer->
layerType() );
1188 layerEl.setAttribute( QStringLiteral(
"enabled" ), layer->
enabled() );
1189 layerEl.setAttribute( QStringLiteral(
"locked" ), layer->
isLocked() );
1190 layerEl.setAttribute( QStringLiteral(
"pass" ), layer->
renderingPass() );
1201 QDomElement ddProps = doc.createElement( QStringLiteral(
"data_defined_properties" ) );
1203 layerEl.appendChild( ddProps );
1205 if (
const QgsSymbol *subSymbol = const_cast< QgsSymbolLayer * >( layer )->subSymbol() )
1207 QString subname = QStringLiteral(
"@%1@%2" ).arg( name ).arg( i );
1208 QDomElement subEl =
saveSymbol( subname, subSymbol, doc, context );
1209 layerEl.appendChild( subEl );
1211 symEl.appendChild( layerEl );
1219 QDomDocument doc( QStringLiteral(
"qgis-symbol-definition" ) );
1222 QTextStream stream( &props );
1223 symbolElem.save( stream, -1 );
1233 if ( element.isNull() )
1238 QString symbolizerName = element.localName();
1240 if ( symbolizerName == QLatin1String(
"PointSymbolizer" ) )
1243 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1244 if ( graphicElem.isNull() )
1246 QgsDebugMsg( QStringLiteral(
"Graphic element not found in PointSymbolizer" ) );
1282 if ( symbolizerName == QLatin1String(
"LineSymbolizer" ) )
1285 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
1286 if ( strokeElem.isNull() )
1288 QgsDebugMsg( QStringLiteral(
"Stroke element not found in LineSymbolizer" ) );
1318 if ( symbolizerName == QLatin1String(
"PolygonSymbolizer" ) )
1321 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
1322 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
1323 if ( fillElem.isNull() && strokeElem.isNull() )
1325 QgsDebugMsg( QStringLiteral(
"neither Fill nor Stroke element not found in PolygonSymbolizer" ) );
1343 if ( l->
layerType() == QLatin1String(
"SimpleFill" ) || l->
layerType() == QLatin1String(
"SVGFill" ) )
1379 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
1380 if ( fillElem.isNull() )
1382 QgsDebugMsg( QStringLiteral(
"Fill element not found" ) );
1402 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
1403 if ( strokeElem.isNull() )
1405 QgsDebugMsg( QStringLiteral(
"Stroke element not found" ) );
1421 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1422 if ( graphicElem.isNull() )
1424 QgsDebugMsg( QStringLiteral(
"Graphic element not found" ) );
1444 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1445 if ( graphicElem.isNull() )
1448 QDomElement externalGraphicElem = graphicElem.firstChildElement( QStringLiteral(
"ExternalGraphic" ) );
1449 if ( externalGraphicElem.isNull() )
1453 QDomElement formatElem = externalGraphicElem.firstChildElement( QStringLiteral(
"Format" ) );
1454 if ( formatElem.isNull() )
1457 QString format = formatElem.firstChild().nodeValue();
1458 if ( format != QLatin1String(
"image/svg+xml" ) )
1460 QgsDebugMsg(
"unsupported External Graphic format found: " + format );
1465 QDomElement onlineResourceElem = externalGraphicElem.firstChildElement( QStringLiteral(
"OnlineResource" ) );
1466 QDomElement inlineContentElem = externalGraphicElem.firstChildElement( QStringLiteral(
"InlineContent" ) );
1467 if ( !onlineResourceElem.isNull() )
1472 else if ( !inlineContentElem.isNull() )
1485 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1486 if ( graphicElem.isNull() )
1489 QDomElement markElem = graphicElem.firstChildElement( QStringLiteral(
"Mark" ) );
1490 if ( markElem.isNull() )
1493 QDomElement wellKnownNameElem = markElem.firstChildElement( QStringLiteral(
"WellKnownName" ) );
1494 return !wellKnownNameElem.isNull();
1500 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1501 if ( graphicElem.isNull() )
1504 QDomElement markElem = graphicElem.firstChildElement( QStringLiteral(
"Mark" ) );
1505 if ( markElem.isNull() )
1509 QDomElement formatElem = markElem.firstChildElement( QStringLiteral(
"Format" ) );
1510 if ( formatElem.isNull() )
1513 QString format = formatElem.firstChild().nodeValue();
1514 if ( format != QLatin1String(
"ttf" ) )
1516 QgsDebugMsg(
"unsupported Graphic Mark format found: " + format );
1521 QDomElement onlineResourceElem = markElem.firstChildElement( QStringLiteral(
"OnlineResource" ) );
1522 QDomElement inlineContentElem = markElem.firstChildElement( QStringLiteral(
"InlineContent" ) );
1523 if ( !onlineResourceElem.isNull() )
1526 QDomElement markIndexElem = markElem.firstChildElement( QStringLiteral(
"MarkIndex" ) );
1527 if ( !markIndexElem.isNull() )
1530 else if ( !inlineContentElem.isNull() )
1545 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
1546 if ( graphicElem.isNull() )
1550 for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
1552 if ( it.key() == QLatin1String(
"widthHeightFactor" ) )
1563 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
1564 if ( strokeElem.isNull() )
1567 QDomElement graphicStrokeElem = strokeElem.firstChildElement( QStringLiteral(
"GraphicStroke" ) );
1568 if ( graphicStrokeElem.isNull() )
1576 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
1577 if ( fillElem.isNull() )
1580 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
1581 if ( graphicFillElem.isNull() )
1584 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
1585 if ( graphicElem.isNull() )
1591 QColor fillColor, strokeColor;
1592 double size, strokeWidth;
1593 Qt::PenStyle strokeStyle;
1594 if ( !
wellKnownMarkerFromSld( graphicElem, name, fillColor, strokeColor, strokeStyle, strokeWidth, size ) )
1597 if ( name != QLatin1String(
"horline" ) )
1605 double angle = angleFunc.toDouble( &ok );
1617 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
1618 if ( fillElem.isNull() )
1621 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
1622 if ( graphicFillElem.isNull() )
1642 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
1643 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
1647 bool validFill =
false, validStroke =
false;
1652 Qt::BrushStyle fillStyle;
1654 if (
fillFromSld( fillElem, fillStyle, fillColor ) )
1660 Qt::PenStyle strokeStyle;
1661 double strokeWidth = 1.0, dashOffset = 0.0;
1662 QVector<qreal> customDashPattern;
1664 if (
lineFromSld( strokeElem, strokeStyle, strokeColor, strokeWidth,
1665 nullptr,
nullptr, &customDashPattern, &dashOffset ) )
1668 if ( validFill || validStroke )
1671 map[QStringLiteral(
"name" )] = QStringLiteral(
"square" );
1672 map[QStringLiteral(
"color" )] =
encodeColor( validFill ? fillColor : Qt::transparent );
1673 map[QStringLiteral(
"color_border" )] =
encodeColor( validStroke ? strokeColor : Qt::transparent );
1674 map[QStringLiteral(
"size" )] = QString::number( 6 );
1675 map[QStringLiteral(
"angle" )] = QString::number( 0 );
1676 map[QStringLiteral(
"offset" )] =
encodePoint( QPointF( 0, 0 ) );
1683 bool validFill =
false, validStroke =
false;
1686 QString name, format;
1688 QColor fillColor, strokeColor;
1689 double strokeWidth = 1.0, size = 0.0,
angle = 0.0;
1693 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
1694 if ( !graphicFillElem.isNull() )
1697 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
1698 if ( !graphicElem.isNull() )
1704 QDomElement graphicChildElem = graphicElem.firstChildElement();
1705 while ( !graphicChildElem.isNull() )
1707 if ( graphicChildElem.localName() == QLatin1String(
"Mark" ) )
1710 QDomElement wellKnownNameElem = graphicChildElem.firstChildElement( QStringLiteral(
"WellKnownName" ) );
1711 if ( !wellKnownNameElem.isNull() )
1713 name = wellKnownNameElem.firstChild().nodeValue();
1719 if ( graphicChildElem.localName() == QLatin1String(
"ExternalGraphic" ) || graphicChildElem.localName() == QLatin1String(
"Mark" ) )
1722 QDomElement formatElem = graphicChildElem.firstChildElement( QStringLiteral(
"Format" ) );
1723 if ( formatElem.isNull() )
1726 format = formatElem.firstChild().nodeValue();
1730 if ( graphicChildElem.localName() == QLatin1String(
"ExternalGraphic" ) && format != QLatin1String(
"image/svg+xml" ) )
1735 if ( graphicChildElem.localName() == QLatin1String(
"Mark" ) && format != QLatin1String(
"ttf" ) )
1739 QDomElement onlineResourceElem = graphicChildElem.firstChildElement( QStringLiteral(
"OnlineResource" ) );
1740 QDomElement inlineContentElem = graphicChildElem.firstChildElement( QStringLiteral(
"InlineContent" ) );
1742 if ( !onlineResourceElem.isNull() )
1744 name = onlineResourceElem.attributeNS( QStringLiteral(
"http://www.w3.org/1999/xlink" ), QStringLiteral(
"href" ) );
1746 if ( graphicChildElem.localName() == QLatin1String(
"Mark" ) && format == QLatin1String(
"ttf" ) )
1749 if ( name.startsWith( QLatin1String(
"ttf://" ) ) )
1750 name = name.mid( 6 );
1753 QDomElement markIndexElem = graphicChildElem.firstChildElement( QStringLiteral(
"MarkIndex" ) );
1754 if ( markIndexElem.isNull() )
1758 int v = markIndexElem.firstChild().nodeValue().toInt( &ok );
1769 else if ( !inlineContentElem.isNull() )
1779 if ( graphicChildElem.localName() == QLatin1String(
"Mark" ) )
1781 name = QStringLiteral(
"square" );
1788 if ( found && graphicChildElem.localName() == QLatin1String(
"Mark" ) )
1795 Qt::BrushStyle markFillStyle;
1797 QDomElement markFillElem = graphicChildElem.firstChildElement( QStringLiteral(
"Fill" ) );
1798 if (
fillFromSld( markFillElem, markFillStyle, fillColor ) )
1803 Qt::PenStyle strokeStyle;
1804 double strokeWidth = 1.0, dashOffset = 0.0;
1805 QVector<qreal> customDashPattern;
1807 QDomElement markStrokeElem = graphicChildElem.firstChildElement( QStringLiteral(
"Stroke" ) );
1808 if (
lineFromSld( markStrokeElem, strokeStyle, strokeColor, strokeWidth,
1809 nullptr,
nullptr, &customDashPattern, &dashOffset ) )
1816 QDomElement opacityElem = graphicElem.firstChildElement( QStringLiteral(
"Opacity" ) );
1817 if ( !opacityElem.isNull() )
1818 fillColor.setAlpha(
decodeSldAlpha( opacityElem.firstChild().nodeValue() ) );
1820 QDomElement sizeElem = graphicElem.firstChildElement( QStringLiteral(
"Size" ) );
1821 if ( !sizeElem.isNull() )
1824 double v = sizeElem.firstChild().nodeValue().toDouble( &ok );
1833 double v = angleFunc.toDouble( &ok );
1843 if ( validFill || validStroke )
1845 if ( format == QLatin1String(
"image/svg+xml" ) )
1848 map[QStringLiteral(
"name" )] = name;
1849 map[QStringLiteral(
"fill" )] = fillColor.name();
1850 map[QStringLiteral(
"outline" )] = strokeColor.name();
1851 map[QStringLiteral(
"outline-width" )] = QString::number( strokeWidth );
1853 map[QStringLiteral(
"size" )] = QString::number( size );
1855 map[QStringLiteral(
"angle" )] = QString::number(
angle );
1856 if ( !offset.isNull() )
1857 map[QStringLiteral(
"offset" )] =
encodePoint( offset );
1860 else if ( format == QLatin1String(
"ttf" ) )
1863 map[QStringLiteral(
"font" )] = name;
1864 map[QStringLiteral(
"chr" )] = markIndex;
1865 map[QStringLiteral(
"color" )] =
encodeColor( validFill ? fillColor : Qt::transparent );
1867 map[QStringLiteral(
"size" )] = QString::number( size );
1869 map[QStringLiteral(
"angle" )] = QString::number(
angle );
1870 if ( !offset.isNull() )
1871 map[QStringLiteral(
"offset" )] =
encodePoint( offset );
1877 if ( layers.isEmpty() )
1880 layerList << layers;
1887 QString patternName;
1888 switch ( brushStyle )
1893 case Qt::SolidPattern:
1894 if ( color.isValid() )
1897 if ( color.alpha() < 255 )
1902 case Qt::CrossPattern:
1903 case Qt::DiagCrossPattern:
1904 case Qt::HorPattern:
1905 case Qt::VerPattern:
1906 case Qt::BDiagPattern:
1907 case Qt::FDiagPattern:
1908 case Qt::Dense1Pattern:
1909 case Qt::Dense2Pattern:
1910 case Qt::Dense3Pattern:
1911 case Qt::Dense4Pattern:
1912 case Qt::Dense5Pattern:
1913 case Qt::Dense6Pattern:
1914 case Qt::Dense7Pattern:
1919 element.appendChild( doc.createComment( QStringLiteral(
"Qt::BrushStyle '%1'' not supported yet" ).arg( brushStyle ) ) );
1923 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
1924 element.appendChild( graphicFillElem );
1926 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
1927 graphicFillElem.appendChild( graphicElem );
1929 QColor fillColor = patternName.startsWith( QLatin1String(
"brush://" ) ) ? color : QColor();
1930 QColor strokeColor = !patternName.startsWith( QLatin1String(
"brush://" ) ) ? color : QColor();
1933 wellKnownMarkerToSld( doc, graphicElem, patternName, fillColor, strokeColor, Qt::SolidLine, -1, -1 );
1940 brushStyle = Qt::SolidPattern;
1941 color = QColor( 128, 128, 128 );
1943 if ( element.isNull() )
1945 brushStyle = Qt::NoBrush;
1950 QDomElement graphicFillElem = element.firstChildElement( QStringLiteral(
"GraphicFill" ) );
1952 if ( graphicFillElem.isNull() )
1955 for ( QgsStringMap::iterator it = svgParams.begin(); it != svgParams.end(); ++it )
1957 QgsDebugMsg( QStringLiteral(
"found SvgParameter %1: %2" ).arg( it.key(), it.value() ) );
1959 if ( it.key() == QLatin1String(
"fill" ) )
1960 color = QColor( it.value() );
1961 else if ( it.key() == QLatin1String(
"fill-opacity" ) )
1967 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
1968 if ( graphicElem.isNull() )
1971 QString patternName = QStringLiteral(
"square" );
1972 QColor fillColor, strokeColor;
1973 double strokeWidth, size;
1974 Qt::PenStyle strokeStyle;
1975 if ( !
wellKnownMarkerFromSld( graphicElem, patternName, fillColor, strokeColor, strokeStyle, strokeWidth, size ) )
1979 if ( brushStyle == Qt::NoBrush )
1982 QColor
c = patternName.startsWith( QLatin1String(
"brush://" ) ) ? fillColor : strokeColor;
1991 Qt::PenStyle penStyle,
const QColor &color,
double width,
1992 const Qt::PenJoinStyle *penJoinStyle,
const Qt::PenCapStyle *penCapStyle,
1993 const QVector<qreal> *customDashPattern,
double dashOffset )
1995 QVector<qreal> dashPattern;
1996 const QVector<qreal> *pattern = &dashPattern;
1998 if ( penStyle == Qt::CustomDashLine && !customDashPattern )
2000 element.appendChild( doc.createComment( QStringLiteral(
"WARNING: Custom dash pattern required but not provided. Using default dash pattern." ) ) );
2001 penStyle = Qt::DashLine;
2013 dashPattern.push_back( 4.0 );
2014 dashPattern.push_back( 2.0 );
2017 dashPattern.push_back( 1.0 );
2018 dashPattern.push_back( 2.0 );
2020 case Qt::DashDotLine:
2021 dashPattern.push_back( 4.0 );
2022 dashPattern.push_back( 2.0 );
2023 dashPattern.push_back( 1.0 );
2024 dashPattern.push_back( 2.0 );
2026 case Qt::DashDotDotLine:
2027 dashPattern.push_back( 4.0 );
2028 dashPattern.push_back( 2.0 );
2029 dashPattern.push_back( 1.0 );
2030 dashPattern.push_back( 2.0 );
2031 dashPattern.push_back( 1.0 );
2032 dashPattern.push_back( 2.0 );
2035 case Qt::CustomDashLine:
2036 Q_ASSERT( customDashPattern );
2037 pattern = customDashPattern;
2041 element.appendChild( doc.createComment( QStringLiteral(
"Qt::BrushStyle '%1'' not supported yet" ).arg( penStyle ) ) );
2045 if ( color.isValid() )
2048 if ( color.alpha() < 255 )
2055 else if ( width == 0 )
2065 if ( !pattern->isEmpty() )
2075 Qt::PenStyle &penStyle, QColor &color,
double &width,
2076 Qt::PenJoinStyle *penJoinStyle, Qt::PenCapStyle *penCapStyle,
2077 QVector<qreal> *customDashPattern,
double *dashOffset )
2081 penStyle = Qt::SolidLine;
2082 color = QColor( 0, 0, 0 );
2085 *penJoinStyle = Qt::BevelJoin;
2087 *penCapStyle = Qt::SquareCap;
2088 if ( customDashPattern )
2089 customDashPattern->clear();
2093 if ( element.isNull() )
2095 penStyle = Qt::NoPen;
2101 for ( QgsStringMap::iterator it = svgParams.begin(); it != svgParams.end(); ++it )
2103 QgsDebugMsg( QStringLiteral(
"found SvgParameter %1: %2" ).arg( it.key(), it.value() ) );
2105 if ( it.key() == QLatin1String(
"stroke" ) )
2107 color = QColor( it.value() );
2109 else if ( it.key() == QLatin1String(
"stroke-opacity" ) )
2113 else if ( it.key() == QLatin1String(
"stroke-width" ) )
2116 double w = it.value().toDouble( &ok );
2120 else if ( it.key() == QLatin1String(
"stroke-linejoin" ) && penJoinStyle )
2124 else if ( it.key() == QLatin1String(
"stroke-linecap" ) && penCapStyle )
2128 else if ( it.key() == QLatin1String(
"stroke-dasharray" ) )
2131 if ( !dashPattern.isEmpty() )
2135 bool dashPatternFound =
false;
2137 if ( dashPattern.count() == 2 )
2139 if ( dashPattern.at( 0 ) == 4.0 &&
2140 dashPattern.at( 1 ) == 2.0 )
2142 penStyle = Qt::DashLine;
2143 dashPatternFound =
true;
2145 else if ( dashPattern.at( 0 ) == 1.0 &&
2146 dashPattern.at( 1 ) == 2.0 )
2148 penStyle = Qt::DotLine;
2149 dashPatternFound =
true;
2152 else if ( dashPattern.count() == 4 )
2154 if ( dashPattern.at( 0 ) == 4.0 &&
2155 dashPattern.at( 1 ) == 2.0 &&
2156 dashPattern.at( 2 ) == 1.0 &&
2157 dashPattern.at( 3 ) == 2.0 )
2159 penStyle = Qt::DashDotLine;
2160 dashPatternFound =
true;
2163 else if ( dashPattern.count() == 6 )
2165 if ( dashPattern.at( 0 ) == 4.0 &&
2166 dashPattern.at( 1 ) == 2.0 &&
2167 dashPattern.at( 2 ) == 1.0 &&
2168 dashPattern.at( 3 ) == 2.0 &&
2169 dashPattern.at( 4 ) == 1.0 &&
2170 dashPattern.at( 5 ) == 2.0 )
2172 penStyle = Qt::DashDotDotLine;
2173 dashPatternFound =
true;
2178 if ( !dashPatternFound )
2180 if ( customDashPattern )
2182 penStyle = Qt::CustomDashLine;
2183 *customDashPattern = dashPattern;
2187 QgsDebugMsg( QStringLiteral(
"custom dash pattern required but not provided. Using default dash pattern." ) );
2188 penStyle = Qt::DashLine;
2193 else if ( it.key() == QLatin1String(
"stroke-dashoffset" ) && dashOffset )
2196 double d = it.value().toDouble( &ok );
2206 const QString &path,
const QString &mime,
2207 const QColor &color,
double size )
2209 QDomElement externalGraphicElem = doc.createElement( QStringLiteral(
"se:ExternalGraphic" ) );
2210 element.appendChild( externalGraphicElem );
2219 QDomElement sizeElem = doc.createElement( QStringLiteral(
"se:Size" ) );
2221 element.appendChild( sizeElem );
2226 const QString &path,
const QColor &fillColor,
double size,
const QColor &strokeColor,
double strokeWidth )
2233 graphicElem.appendChild( doc.createComment( QStringLiteral(
"Parametric SVG" ) ) );
2237 graphicElem.appendChild( doc.createComment( QStringLiteral(
"Plain SVG fallback, no parameters" ) ) );
2240 graphicElem.appendChild( doc.createComment( QStringLiteral(
"Well known marker fallback" ) ) );
2246 QDomElement sizeElem = doc.createElement( QStringLiteral(
"se:Size" ) );
2248 graphicElem.appendChild( sizeElem );
2256 if ( fillColor.isValid() )
2258 url.addQueryItem( QStringLiteral(
"fill" ), fillColor.name() );
2259 url.addQueryItem( QStringLiteral(
"fill-opacity" ),
encodeSldAlpha( fillColor.alpha() ) );
2263 url.addQueryItem( QStringLiteral(
"fill" ), QStringLiteral(
"#000000" ) );
2264 url.addQueryItem( QStringLiteral(
"fill-opacity" ), QStringLiteral(
"1" ) );
2266 if ( strokeColor.isValid() )
2268 url.addQueryItem( QStringLiteral(
"outline" ), strokeColor.name() );
2269 url.addQueryItem( QStringLiteral(
"outline-opacity" ),
encodeSldAlpha( strokeColor.alpha() ) );
2273 url.addQueryItem( QStringLiteral(
"outline" ), QStringLiteral(
"#000000" ) );
2274 url.addQueryItem( QStringLiteral(
"outline-opacity" ), QStringLiteral(
"1" ) );
2276 url.addQueryItem( QStringLiteral(
"outline-width" ), QString::number( strokeWidth ) );
2277 QString params = url.encodedQuery();
2278 if ( params.isEmpty() )
2284 return basePath +
"?" + params;
2289 QString &path, QString &mime,
2290 QColor &color,
double &size )
2295 QDomElement externalGraphicElem = element.firstChildElement( QStringLiteral(
"ExternalGraphic" ) );
2296 if ( externalGraphicElem.isNull() )
2301 QDomElement sizeElem = element.firstChildElement( QStringLiteral(
"Size" ) );
2302 if ( !sizeElem.isNull() )
2305 double s = sizeElem.firstChild().nodeValue().toDouble( &ok );
2314 const QString &path,
const QString &format,
int *markIndex,
2315 const QColor &color,
double size )
2317 QDomElement markElem = doc.createElement( QStringLiteral(
"se:Mark" ) );
2318 element.appendChild( markElem );
2324 QDomElement markIndexElem = doc.createElement( QStringLiteral(
"se:MarkIndex" ) );
2325 markIndexElem.appendChild( doc.createTextNode( QString::number( *markIndex ) ) );
2326 markElem.appendChild( markIndexElem );
2330 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2331 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2332 markElem.appendChild( fillElem );
2337 QDomElement sizeElem = doc.createElement( QStringLiteral(
"se:Size" ) );
2339 element.appendChild( sizeElem );
2344 QString &path, QString &format,
int &markIndex,
2345 QColor &color,
double &size )
2353 QDomElement markElem = element.firstChildElement( QStringLiteral(
"Mark" ) );
2354 if ( markElem.isNull() )
2359 QDomElement markIndexElem = markElem.firstChildElement( QStringLiteral(
"MarkIndex" ) );
2360 if ( !markIndexElem.isNull() )
2363 int i = markIndexElem.firstChild().nodeValue().toInt( &ok );
2369 QDomElement fillElem = markElem.firstChildElement( QStringLiteral(
"Fill" ) );
2370 Qt::BrushStyle b = Qt::SolidPattern;
2375 QDomElement sizeElem = element.firstChildElement( QStringLiteral(
"Size" ) );
2376 if ( !sizeElem.isNull() )
2379 double s = sizeElem.firstChild().nodeValue().toDouble( &ok );
2388 const QString &name,
const QColor &color,
const QColor &strokeColor, Qt::PenStyle strokeStyle,
2389 double strokeWidth,
double size )
2391 QDomElement markElem = doc.createElement( QStringLiteral(
"se:Mark" ) );
2392 element.appendChild( markElem );
2394 QDomElement wellKnownNameElem = doc.createElement( QStringLiteral(
"se:WellKnownName" ) );
2395 wellKnownNameElem.appendChild( doc.createTextNode( name ) );
2396 markElem.appendChild( wellKnownNameElem );
2399 if ( color.isValid() )
2401 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2402 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2403 markElem.appendChild( fillElem );
2407 if ( strokeColor.isValid() )
2409 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
2410 lineToSld( doc, strokeElem, strokeStyle, strokeColor, strokeWidth );
2411 markElem.appendChild( strokeElem );
2417 QDomElement sizeElem = doc.createElement( QStringLiteral(
"se:Size" ) );
2419 element.appendChild( sizeElem );
2424 QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle,
2425 double &strokeWidth,
double &size )
2429 name = QStringLiteral(
"square" );
2431 strokeColor = QColor( 0, 0, 0 );
2435 QDomElement markElem = element.firstChildElement( QStringLiteral(
"Mark" ) );
2436 if ( markElem.isNull() )
2439 QDomElement wellKnownNameElem = markElem.firstChildElement( QStringLiteral(
"WellKnownName" ) );
2440 if ( !wellKnownNameElem.isNull() )
2442 name = wellKnownNameElem.firstChild().nodeValue();
2443 QgsDebugMsg(
"found Mark with well known name: " + name );
2447 QDomElement fillElem = markElem.firstChildElement( QStringLiteral(
"Fill" ) );
2448 Qt::BrushStyle b = Qt::SolidPattern;
2453 QDomElement strokeElem = markElem.firstChildElement( QStringLiteral(
"Stroke" ) );
2454 lineFromSld( strokeElem, strokeStyle, strokeColor, strokeWidth );
2458 QDomElement sizeElem = element.firstChildElement( QStringLiteral(
"Size" ) );
2459 if ( !sizeElem.isNull() )
2462 double s = sizeElem.firstChild().nodeValue().toDouble( &ok );
2472 if ( !rotationFunc.isEmpty() )
2474 QDomElement rotationElem = doc.createElement( QStringLiteral(
"se:Rotation" ) );
2476 element.appendChild( rotationElem );
2482 QDomElement rotationElem = element.firstChildElement( QStringLiteral(
"Rotation" ) );
2483 if ( !rotationElem.isNull() )
2493 if ( !alphaFunc.isEmpty() )
2495 QDomElement opacityElem = doc.createElement( QStringLiteral(
"se:Opacity" ) );
2497 element.appendChild( opacityElem );
2503 QDomElement opacityElem = element.firstChildElement( QStringLiteral(
"Opacity" ) );
2504 if ( !opacityElem.isNull() )
2513 if ( offset.isNull() )
2516 QDomElement displacementElem = doc.createElement( QStringLiteral(
"se:Displacement" ) );
2517 element.appendChild( displacementElem );
2519 QDomElement dispXElem = doc.createElement( QStringLiteral(
"se:DisplacementX" ) );
2520 dispXElem.appendChild( doc.createTextNode(
qgsDoubleToString( offset.x(), 2 ) ) );
2522 QDomElement dispYElem = doc.createElement( QStringLiteral(
"se:DisplacementY" ) );
2523 dispYElem.appendChild( doc.createTextNode(
qgsDoubleToString( offset.y(), 2 ) ) );
2525 displacementElem.appendChild( dispXElem );
2526 displacementElem.appendChild( dispYElem );
2533 QDomElement anchorElem = doc.createElement( QStringLiteral(
"se:AnchorPoint" ) );
2534 element.appendChild( anchorElem );
2536 QDomElement anchorXElem = doc.createElement( QStringLiteral(
"se:AnchorPointX" ) );
2537 anchorXElem.appendChild( doc.createTextNode(
qgsDoubleToString( anchor.x() ) ) );
2539 QDomElement anchorYElem = doc.createElement( QStringLiteral(
"se:AnchorPointY" ) );
2540 anchorYElem.appendChild( doc.createTextNode(
qgsDoubleToString( anchor.y() ) ) );
2542 anchorElem.appendChild( anchorXElem );
2543 anchorElem.appendChild( anchorYElem );
2548 offset = QPointF( 0, 0 );
2550 QDomElement displacementElem = element.firstChildElement( QStringLiteral(
"Displacement" ) );
2551 if ( displacementElem.isNull() )
2554 QDomElement dispXElem = displacementElem.firstChildElement( QStringLiteral(
"DisplacementX" ) );
2555 if ( !dispXElem.isNull() )
2558 double offsetX = dispXElem.firstChild().nodeValue().toDouble( &ok );
2560 offset.setX( offsetX );
2563 QDomElement dispYElem = displacementElem.firstChildElement( QStringLiteral(
"DisplacementY" ) );
2564 if ( !dispYElem.isNull() )
2567 double offsetY = dispYElem.firstChild().nodeValue().toDouble( &ok );
2569 offset.setY( offsetY );
2576 const QString &label,
const QFont &font,
2577 const QColor &color,
double size )
2579 QDomElement labelElem = doc.createElement( QStringLiteral(
"se:Label" ) );
2580 labelElem.appendChild( doc.createTextNode( label ) );
2581 element.appendChild( labelElem );
2583 QDomElement fontElem = doc.createElement( QStringLiteral(
"se:Font" ) );
2584 element.appendChild( fontElem );
2588 fontElem.appendChild( createSldParameterElement( doc,
"font-style",
encodeSldFontStyle( font.style() ) ) );
2589 fontElem.appendChild( createSldParameterElement( doc,
"font-weight",
encodeSldFontWeight( font.weight() ) ) );
2594 if ( color.isValid() )
2596 QDomElement fillElem = doc.createElement( QStringLiteral(
"Fill" ) );
2597 fillToSld( doc, fillElem, Qt::SolidPattern, color );
2598 element.appendChild( fillElem );
2603 Qt::PenJoinStyle joinStyle,
2604 Qt::PenCapStyle capStyle,
2606 const QVector<qreal> *dashPattern )
2609 penStyle.append(
"PEN(" );
2610 penStyle.append(
"c:" );
2611 penStyle.append( c.name() );
2612 penStyle.append(
",w:" );
2614 penStyle.append( QString::number( width * mmScaleFactor ) );
2615 penStyle.append(
"mm" );
2618 if ( dashPattern && !dashPattern->isEmpty() )
2620 penStyle.append(
",p:\"" );
2621 QVector<qreal>::const_iterator pIt = dashPattern->constBegin();
2622 for ( ; pIt != dashPattern->constEnd(); ++pIt )
2624 if ( pIt != dashPattern->constBegin() )
2626 penStyle.append(
' ' );
2628 penStyle.append( QString::number( *pIt * mapUnitScaleFactor ) );
2629 penStyle.append(
'g' );
2631 penStyle.append(
'\"' );
2635 penStyle.append(
",cap:" );
2639 penStyle.append(
'p' );
2642 penStyle.append(
'r' );
2646 penStyle.append(
'b' );
2650 penStyle.append(
",j:" );
2651 switch ( joinStyle )
2654 penStyle.append(
'b' );
2657 penStyle.append(
'r' );
2661 penStyle.append(
'm' );
2667 penStyle.append(
",dp:" );
2668 penStyle.append( QString::number( offset * mapUnitScaleFactor ) );
2669 penStyle.append(
'g' );
2672 penStyle.append(
')' );
2679 brushStyle.append(
"BRUSH(" );
2680 brushStyle.append(
"fc:" );
2681 brushStyle.append( fillColor.name() );
2682 brushStyle.append(
')' );
2688 if ( geomFunc.isEmpty() )
2691 QDomElement geometryElem = doc.createElement( QStringLiteral(
"Geometry" ) );
2692 element.appendChild( geometryElem );
2722 QDomElement geometryElem = element.firstChildElement( QStringLiteral(
"Geometry" ) );
2723 if ( geometryElem.isNull() )
2735 element.appendChild( doc.createComment(
"Parser Error: " + expr.
parserErrorString() +
" - Expression was: " + function ) );
2739 if ( !filterElem.isNull() )
2740 element.appendChild( filterElem );
2751 element.appendChild( doc.createComment(
"Parser Error: " + expr.
parserErrorString() +
" - Expression was: " + function ) );
2755 if ( !filterElem.isNull() )
2756 element.appendChild( filterElem );
2763 QDomElement elem = element;
2764 if ( element.tagName() != QLatin1String(
"Filter" ) )
2766 QDomNodeList filterNodes = element.elementsByTagName( QStringLiteral(
"Filter" ) );
2767 if ( !filterNodes.isEmpty() )
2769 elem = filterNodes.at( 0 ).toElement();
2773 if ( elem.isNull() )
2798 const QString &path,
const QString &format )
2802 QDomElement onlineResourceElem = doc.createElement( QStringLiteral(
"se:OnlineResource" ) );
2803 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:type" ), QStringLiteral(
"simple" ) );
2804 onlineResourceElem.setAttribute( QStringLiteral(
"xlink:href" ), url );
2805 element.appendChild( onlineResourceElem );
2807 QDomElement formatElem = doc.createElement( QStringLiteral(
"se:Format" ) );
2808 formatElem.appendChild( doc.createTextNode( format ) );
2809 element.appendChild( formatElem );
2816 QDomElement onlineResourceElem = element.firstChildElement( QStringLiteral(
"OnlineResource" ) );
2817 if ( onlineResourceElem.isNull() )
2820 path = onlineResourceElem.attributeNS( QStringLiteral(
"http://www.w3.org/1999/xlink" ), QStringLiteral(
"href" ) );
2822 QDomElement formatElem = element.firstChildElement( QStringLiteral(
"Format" ) );
2823 if ( formatElem.isNull() )
2826 format = formatElem.firstChild().nodeValue();
2833 QDomElement nodeElem = doc.createElement( QStringLiteral(
"se:SvgParameter" ) );
2834 nodeElem.setAttribute( QStringLiteral(
"name" ), name );
2835 nodeElem.appendChild( doc.createTextNode( value ) );
2844 QDomElement paramElem = element.firstChildElement();
2845 while ( !paramElem.isNull() )
2847 if ( paramElem.localName() == QLatin1String(
"SvgParameter" ) || paramElem.localName() == QLatin1String(
"CssParameter" ) )
2849 QString name = paramElem.attribute( QStringLiteral(
"name" ) );
2850 if ( paramElem.firstChild().nodeType() == QDomNode::TextNode )
2852 value = paramElem.firstChild().nodeValue();
2856 if ( paramElem.firstChild().nodeType() == QDomNode::ElementNode &&
2857 paramElem.firstChild().localName() == QLatin1String(
"Literal" ) )
2859 QgsDebugMsg( paramElem.firstChild().localName() );
2860 value = paramElem.firstChild().firstChild().nodeValue();
2864 QgsDebugMsg( QStringLiteral(
"unexpected child of %1" ).arg( paramElem.localName() ) );
2868 if ( !name.isEmpty() && !value.isEmpty() )
2869 params[ name ] = value;
2872 paramElem = paramElem.nextSiblingElement();
2880 QDomElement nodeElem = doc.createElement( QStringLiteral(
"se:VendorOption" ) );
2881 nodeElem.setAttribute( QStringLiteral(
"name" ), name );
2882 nodeElem.appendChild( doc.createTextNode( value ) );
2890 QDomElement paramElem = element.firstChildElement( QStringLiteral(
"VendorOption" ) );
2891 while ( !paramElem.isNull() )
2893 QString name = paramElem.attribute( QStringLiteral(
"name" ) );
2894 QString value = paramElem.firstChild().nodeValue();
2896 if ( !name.isEmpty() && !value.isEmpty() )
2897 params[ name ] = value;
2899 paramElem = paramElem.nextSiblingElement( QStringLiteral(
"VendorOption" ) );
2909 QDomElement e = element.firstChildElement();
2910 while ( !e.isNull() )
2912 if ( e.tagName() == QLatin1String(
"prop" ) )
2914 QString propKey = e.attribute( QStringLiteral(
"k" ) );
2915 QString propValue = e.attribute( QStringLiteral(
"v" ) );
2916 props[propKey] = propValue;
2918 e = e.nextSiblingElement();
2926 for ( QgsStringMap::iterator it = props.begin(); it != props.end(); ++it )
2928 QDomElement propEl = doc.createElement( QStringLiteral(
"prop" ) );
2929 propEl.setAttribute( QStringLiteral(
"k" ), it.key() );
2930 propEl.setAttribute( QStringLiteral(
"v" ), it.value() );
2931 element.appendChild( propEl );
2940 QDomElement e = element.firstChildElement();
2942 while ( !e.isNull() )
2944 if ( e.tagName() == QLatin1String(
"symbol" ) )
2948 symbols.insert( e.attribute( QStringLiteral(
"name" ) ), symbol );
2954 e = e.nextSiblingElement();
2961 QStringList subsymbols;
2963 for ( QMap<QString, QgsSymbol *>::iterator it = symbols.begin(); it != symbols.end(); ++it )
2965 if ( it.key()[0] !=
'@' )
2969 subsymbols.append( it.key() );
2971 QStringList parts = it.key().split(
'@' );
2972 if ( parts.count() < 3 )
2974 QgsDebugMsg(
"found subsymbol with invalid name: " + it.key() );
2978 QString symname = parts[1];
2979 int symlayer = parts[2].toInt();
2981 if ( !symbols.contains( symname ) )
2983 QgsDebugMsg(
"subsymbol references invalid symbol: " + symname );
2991 QgsDebugMsg(
"subsymbol references invalid symbol layer: " + QString::number( symlayer ) );
3000 QgsDebugMsg(
"symbol layer refused subsymbol: " + it.key() );
3007 for (
int i = 0; i < subsymbols.count(); i++ )
3008 symbols.take( subsymbols[i] );
3015 QDomElement symbolsElem = doc.createElement( tagName );
3018 for ( QMap<QString, QgsSymbol *>::iterator its = symbols.begin(); its != symbols.end(); ++its )
3020 QDomElement symEl =
saveSymbol( its.key(), its.value(), doc, context );
3021 symbolsElem.appendChild( symEl );
3029 qDeleteAll( symbols );
3038 std::unique_ptr< QMimeData >mimeData(
new QMimeData );
3040 QDomDocument symbolDoc;
3042 symbolDoc.appendChild( symbolElem );
3043 mimeData->setText( symbolDoc.toString() );
3046 mimeData->setColorData( symbol->
color() );
3048 return mimeData.release();
3056 QString text = data->text();
3057 if ( !text.isEmpty() )
3062 if ( doc.setContent( text ) )
3064 elem = doc.documentElement();
3066 if ( elem.nodeName() != QStringLiteral(
"symbol" ) )
3067 elem = elem.firstChildElement( QStringLiteral(
"symbol" ) );
3078 QString rampType = element.attribute( QStringLiteral(
"type" ) );
3083 if ( rampType == QLatin1String(
"gradient" ) )
3085 else if ( rampType == QLatin1String(
"random" ) )
3087 else if ( rampType == QLatin1String(
"colorbrewer" ) )
3089 else if ( rampType == QLatin1String(
"cpt-city" ) )
3091 else if ( rampType == QLatin1String(
"preset" ) )
3095 QgsDebugMsg(
"unknown colorramp type " + rampType );
3103 QDomElement rampEl = doc.createElement( QStringLiteral(
"colorramp" ) );
3104 rampEl.setAttribute( QStringLiteral(
"type" ), ramp->
type() );
3105 rampEl.setAttribute( QStringLiteral(
"name" ), name );
3113 QVariantMap rampMap;
3115 rampMap.insert( QStringLiteral(
"type" ), ramp->
type() );
3116 rampMap.insert( QStringLiteral(
"name" ), name );
3120 QVariantMap propertyMap;
3121 for (
auto property = properties.constBegin();
property != properties.constEnd(); ++property )
3123 propertyMap.insert( property.key(),
property.value() );
3126 rampMap.insert( QStringLiteral(
"properties" ), propertyMap );
3132 QVariantMap rampMap = value.toMap();
3134 QString rampType = rampMap.
value( QStringLiteral(
"type" ) ).toString();
3137 QVariantMap propertyMap = rampMap.value( QStringLiteral(
"properties" ) ).toMap();
3140 for (
auto property = propertyMap.constBegin();
property != propertyMap.constEnd(); ++property )
3142 props.insert( property.key(),
property.value().toString() );
3145 if ( rampType == QLatin1String(
"gradient" ) )
3147 else if ( rampType == QLatin1String(
"random" ) )
3149 else if ( rampType == QLatin1String(
"colorbrewer" ) )
3151 else if ( rampType == QLatin1String(
"cpt-city" ) )
3153 else if ( rampType == QLatin1String(
"preset" ) )
3157 QgsDebugMsg(
"unknown colorramp type " + rampType );
3164 if ( !color.isValid() )
3171 return color.name();
3176 QList<QColor> colors;
3179 QStringList components = colorStr.simplified().split( QRegExp(
"(,|\\s)" ) );
3180 QStringList::iterator it = components.begin();
3181 for ( ; it != components.end(); ++it )
3184 if ( result.isValid() )
3189 if ( colors.length() > 0 )
3195 components = colorStr.split( QRegExp(
"(,|\n)" ) );
3196 it = components.begin();
3197 for ( ; it != components.end(); ++it )
3200 if ( result.isValid() )
3205 if ( colors.length() > 0 )
3211 components = colorStr.simplified().split( QString(
' ' ) );
3212 it = components.begin();
3213 for ( ; it != components.end(); ++it )
3216 if ( result.isValid() )
3221 if ( colors.length() > 0 )
3227 components = colorStr.split(
'\n' );
3228 it = components.begin();
3229 for ( ; it != components.end(); ++it )
3232 if ( result.isValid() )
3245 QMimeData *mimeData =
new QMimeData;
3246 mimeData->setColorData( QVariant( color ) );
3247 mimeData->setText( color.name() );
3254 QColor mimeColor = mimeData->colorData().value<QColor>();
3255 if ( mimeColor.isValid() )
3264 if ( textColor.isValid() )
3278 if ( data->hasFormat( QStringLiteral(
"text/xml" ) ) )
3281 QByteArray encodedData = data->data( QStringLiteral(
"text/xml" ) );
3282 QDomDocument xmlDoc;
3283 xmlDoc.setContent( encodedData );
3285 QDomElement dragDataElem = xmlDoc.documentElement();
3286 if ( dragDataElem.tagName() == QLatin1String(
"ColorSchemeModelDragData" ) )
3288 QDomNodeList nodeList = dragDataElem.childNodes();
3289 int nChildNodes = nodeList.size();
3290 QDomElement currentElem;
3292 for (
int i = 0; i < nChildNodes; ++i )
3294 currentElem = nodeList.at( i ).toElement();
3295 if ( currentElem.isNull() )
3300 QPair< QColor, QString> namedColor;
3302 namedColor.second = currentElem.attribute( QStringLiteral(
"label" ), QString() );
3304 mimeColors << namedColor;
3309 if ( mimeColors.length() == 0 && data->hasFormat( QStringLiteral(
"application/x-colorobject-list" ) ) )
3312 QByteArray encodedData = data->data( QStringLiteral(
"application/x-colorobject-list" ) );
3313 QDomDocument xmlDoc;
3314 xmlDoc.setContent( encodedData );
3316 QDomNodeList colorsNodes = xmlDoc.elementsByTagName( QStringLiteral(
"colors" ) );
3317 if ( colorsNodes.length() > 0 )
3319 QDomElement colorsElem = colorsNodes.at( 0 ).toElement();
3320 QDomNodeList colorNodeList = colorsElem.childNodes();
3321 int nChildNodes = colorNodeList.size();
3322 QDomElement currentElem;
3324 for (
int i = 0; i < nChildNodes; ++i )
3327 currentElem = colorNodeList.at( i ).toElement();
3328 if ( currentElem.isNull() )
3333 QDomNodeList colorNodes = currentElem.elementsByTagName( QStringLiteral(
"color" ) );
3334 QDomNodeList nameNodes = currentElem.elementsByTagName( QStringLiteral(
"name" ) );
3336 if ( colorNodes.length() > 0 )
3338 QDomElement colorElem = colorNodes.at( 0 ).toElement();
3340 QStringList colorParts = colorElem.text().simplified().split(
' ' );
3341 if ( colorParts.length() < 3 )
3346 int red = colorParts.at( 0 ).toDouble() * 255;
3347 int green = colorParts.at( 1 ).toDouble() * 255;
3348 int blue = colorParts.at( 2 ).toDouble() * 255;
3349 QPair< QColor, QString> namedColor;
3350 namedColor.first = QColor( red, green, blue );
3351 if ( nameNodes.length() > 0 )
3353 QDomElement nameElem = nameNodes.at( 0 ).toElement();
3354 namedColor.second = nameElem.text();
3356 mimeColors << namedColor;
3362 if ( mimeColors.length() == 0 && data->hasText() )
3366 QList< QColor >::iterator it = parsedColors.begin();
3367 for ( ; it != parsedColors.end(); ++it )
3369 mimeColors << qMakePair( *it, QString() );
3373 if ( mimeColors.length() == 0 && data->hasColor() )
3376 QColor mimeColor = data->colorData().value<QColor>();
3377 if ( mimeColor.isValid() )
3379 mimeColors << qMakePair( mimeColor, QString() );
3389 QMimeData *mimeData =
new QMimeData();
3390 QDomDocument xmlDoc;
3391 QDomElement xmlRootElement = xmlDoc.createElement( QStringLiteral(
"ColorSchemeModelDragData" ) );
3392 xmlDoc.appendChild( xmlRootElement );
3394 QgsNamedColorList::const_iterator colorIt = colorList.constBegin();
3395 for ( ; colorIt != colorList.constEnd(); ++colorIt )
3397 QDomElement namedColor = xmlDoc.createElement( QStringLiteral(
"NamedColor" ) );
3399 namedColor.setAttribute( QStringLiteral(
"label" ), ( *colorIt ).second );
3400 xmlRootElement.appendChild( namedColor );
3402 mimeData->setData( QStringLiteral(
"text/xml" ), xmlDoc.toByteArray() );
3410 colorIt = colorList.constBegin();
3411 QStringList colorListString;
3412 for ( ; colorIt != colorList.constEnd(); ++colorIt )
3414 colorListString << ( *colorIt ).first.name();
3416 mimeData->setText( colorListString.join( QStringLiteral(
"\n" ) ) );
3419 if ( colorList.length() > 0 )
3421 mimeData->setColorData( QVariant( colorList.at( 0 ).first ) );
3429 if ( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
3434 QTextStream stream( &file );
3435 stream <<
"GIMP Palette" << endl;
3436 if ( paletteName.isEmpty() )
3438 stream <<
"Name: QGIS Palette" << endl;
3442 stream <<
"Name: " << paletteName << endl;
3444 stream <<
"Columns: 4" << endl;
3445 stream <<
'#' << endl;
3447 for ( QgsNamedColorList::ConstIterator colorIt = colors.constBegin(); colorIt != colors.constEnd(); ++colorIt )
3449 QColor color = ( *colorIt ).first;
3450 if ( !color.isValid() )
3454 stream << QStringLiteral(
"%1 %2 %3" ).arg( color.red(), 3 ).arg( color.green(), 3 ).arg( color.blue(), 3 );
3455 stream <<
"\t" << ( ( *colorIt ).second.isEmpty() ? color.name() : ( *colorIt ).second ) << endl;
3466 if ( !file.open( QIODevice::ReadOnly ) )
3469 return importedColors;
3472 QTextStream in( &file );
3474 QString line = in.readLine();
3475 if ( !line.startsWith( QLatin1String(
"GIMP Palette" ) ) )
3478 return importedColors;
3482 while ( !in.atEnd() && !line.startsWith( QLatin1String(
"Name:" ) ) && !line.startsWith(
'#' ) )
3484 line = in.readLine();
3486 if ( line.startsWith( QLatin1String(
"Name:" ) ) )
3488 QRegExp nameRx(
"Name:\\s*(\\S.*)$" );
3489 if ( nameRx.indexIn( line ) != -1 )
3491 name = nameRx.cap( 1 );
3496 while ( !in.atEnd() && !line.startsWith(
'#' ) )
3498 line = in.readLine();
3503 return importedColors;
3507 QRegExp rx(
"^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)(\\s.*)?$" );
3508 while ( !in.atEnd() )
3510 line = in.readLine();
3511 if ( rx.indexIn( line ) == -1 )
3515 int red = rx.cap( 1 ).toInt();
3516 int green = rx.cap( 2 ).toInt();
3517 int blue = rx.cap( 3 ).toInt();
3518 QColor color = QColor( red, green, blue );
3519 if ( !color.isValid() )
3526 if ( rx.captureCount() > 3 )
3528 label = rx.cap( 4 ).simplified();
3535 importedColors << qMakePair( color, label );
3540 return importedColors;
3553 QRegExp hexColorAlphaRx(
"^\\s*#?([0-9a-fA-F]{6})([0-9a-fA-F]{2})\\s*$" );
3554 int hexColorIndex = hexColorAlphaRx.indexIn( colorStr );
3557 if ( hexColorIndex == -1 && QColor::isValidColor( colorStr ) )
3560 parsedColor.setNamedColor( colorStr );
3561 if ( parsedColor.isValid() )
3563 containsAlpha =
false;
3569 if ( hexColorIndex > -1 )
3571 QString hexColor = hexColorAlphaRx.cap( 1 );
3572 parsedColor.setNamedColor( QStringLiteral(
"#" ) + hexColor );
3574 int alphaHex = hexColorAlphaRx.cap( 2 ).toInt( &alphaOk, 16 );
3576 if ( parsedColor.isValid() && alphaOk )
3578 parsedColor.setAlpha( alphaHex );
3579 containsAlpha =
true;
3587 QRegExp hexColorRx2(
"^\\s*(?:[0-9a-fA-F]{3}){1,2}\\s*$" );
3588 if ( hexColorRx2.indexIn( colorStr ) != -1 )
3591 parsedColor.setNamedColor( QStringLiteral(
"#" ) + colorStr );
3592 if ( parsedColor.isValid() )
3594 containsAlpha =
false;
3601 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*$" );
3602 if ( rgbFormatRx.indexIn( colorStr ) != -1 )
3604 int r = rgbFormatRx.cap( 1 ).toInt();
3605 int g = rgbFormatRx.cap( 2 ).toInt();
3606 int b = rgbFormatRx.cap( 3 ).toInt();
3607 parsedColor.setRgb( r, g, b );
3608 if ( parsedColor.isValid() )
3610 containsAlpha =
false;
3616 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*$" );
3617 if ( rgbPercentFormatRx.indexIn( colorStr ) != -1 )
3619 int r = std::round( rgbPercentFormatRx.cap( 1 ).toDouble() * 2.55 );
3620 int g = std::round( rgbPercentFormatRx.cap( 2 ).toDouble() * 2.55 );
3621 int b = std::round( rgbPercentFormatRx.cap( 3 ).toDouble() * 2.55 );
3622 parsedColor.setRgb( r, g, b );
3623 if ( parsedColor.isValid() )
3625 containsAlpha =
false;
3631 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*$" );
3632 if ( rgbaFormatRx.indexIn( colorStr ) != -1 )
3634 int r = rgbaFormatRx.cap( 1 ).toInt();
3635 int g = rgbaFormatRx.cap( 2 ).toInt();
3636 int b = rgbaFormatRx.cap( 3 ).toInt();
3637 int a = std::round( rgbaFormatRx.cap( 4 ).toDouble() * 255.0 );
3638 parsedColor.setRgb( r, g, b, a );
3639 if ( parsedColor.isValid() )
3641 containsAlpha =
true;
3647 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*$" );
3648 if ( rgbaPercentFormatRx.indexIn( colorStr ) != -1 )
3650 int r = std::round( rgbaPercentFormatRx.cap( 1 ).toDouble() * 2.55 );
3651 int g = std::round( rgbaPercentFormatRx.cap( 2 ).toDouble() * 2.55 );
3652 int b = std::round( rgbaPercentFormatRx.cap( 3 ).toDouble() * 2.55 );
3653 int a = std::round( rgbaPercentFormatRx.cap( 4 ).toDouble() * 255.0 );
3654 parsedColor.setRgb( r, g, b, a );
3655 if ( parsedColor.isValid() )
3657 containsAlpha =
true;
3674 QImage::Format format = image->format();
3675 if ( format != QImage::Format_ARGB32_Premultiplied && format != QImage::Format_ARGB32 )
3677 QgsDebugMsg( QStringLiteral(
"no alpha channel." ) );
3682 for (
int heightIndex = 0; heightIndex < image->height(); ++heightIndex )
3684 QRgb *scanLine =
reinterpret_cast< QRgb *
>( image->scanLine( heightIndex ) );
3685 for (
int widthIndex = 0; widthIndex < image->width(); ++widthIndex )
3687 myRgb = scanLine[widthIndex];
3688 if ( format == QImage::Format_ARGB32_Premultiplied )
3689 scanLine[widthIndex] = qRgba( opacity * qRed( myRgb ), opacity * qGreen( myRgb ), opacity * qBlue( myRgb ), opacity * qAlpha( myRgb ) );
3691 scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), opacity * qAlpha( myRgb ) );
3699 int tab[] = { 14, 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
3700 int alpha = ( radius < 1 ) ? 16 : ( radius > 17 ) ? 1 : tab[radius - 1];
3702 if ( image.format() != QImage::Format_ARGB32_Premultiplied
3703 && image.format() != QImage::Format_RGB32 )
3705 image = image.convertToFormat( QImage::Format_ARGB32_Premultiplied );
3708 int r1 = rect.top();
3709 int r2 = rect.bottom();
3710 int c1 = rect.left();
3711 int c2 = rect.right();
3713 int bpl = image.bytesPerLine();
3721 i1 = i2 = ( QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3 );
3723 for (
int col = c1; col <= c2; col++ )
3725 p = image.scanLine( r1 ) + col * 4;
3726 for (
int i = i1; i <= i2; i++ )
3727 rgba[i] = p[i] << 4;
3730 for (
int j = r1; j < r2; j++, p += bpl )
3731 for (
int i = i1; i <= i2; i++ )
3732 p[i] = ( rgba[i] += ( ( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3735 for (
int row = r1; row <= r2; row++ )
3737 p = image.scanLine( row ) + c1 * 4;
3738 for (
int i = i1; i <= i2; i++ )
3739 rgba[i] = p[i] << 4;
3742 for (
int j = c1; j < c2; j++, p += 4 )
3743 for (
int i = i1; i <= i2; i++ )
3744 p[i] = ( rgba[i] += ( ( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3747 for (
int col = c1; col <= c2; col++ )
3749 p = image.scanLine( r2 ) + col * 4;
3750 for (
int i = i1; i <= i2; i++ )
3751 rgba[i] = p[i] << 4;
3754 for (
int j = r1; j < r2; j++, p -= bpl )
3755 for (
int i = i1; i <= i2; i++ )
3756 p[i] = ( rgba[i] += ( ( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3759 for (
int row = r1; row <= r2; row++ )
3761 p = image.scanLine( row ) + c2 * 4;
3762 for (
int i = i1; i <= i2; i++ )
3763 rgba[i] = p[i] << 4;
3766 for (
int j = c1; j < c2; j++, p -= 4 )
3767 for (
int i = i1; i <= i2; i++ )
3768 p[i] = ( rgba[i] += ( ( p[i] << 4 ) - rgba[i] ) * alpha / 16 ) >> 4;
3774 if ( alpha != 255 && alpha > 0 )
3778 double alphaFactor = alpha / 255.;
3779 int r = 0, g = 0, b = 0;
3780 rgb.getRgb( &r, &g, &b );
3785 rgb.setRgb( r, g, b, alpha );
3787 else if ( alpha == 0 )
3789 rgb.setRgb( 0, 0, 0, 0 );
3795 if ( order == Qt::AscendingOrder )
3809 double dx = directionPoint.x() - startPoint.x();
3810 double dy = directionPoint.y() - startPoint.y();
3811 double length = std::sqrt( dx * dx + dy * dy );
3812 double scaleFactor = distance / length;
3813 return QPointF( startPoint.x() + dx * scaleFactor, startPoint.y() + dy * scaleFactor );
3823 for (
int i = 0; i < svgPaths.size(); i++ )
3825 QDir dir( svgPaths[i] );
3826 const auto svgSubPaths = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
3827 for (
const QString &item : svgSubPaths )
3829 svgPaths.insert( i + 1, dir.path() +
'/' + item );
3832 const auto svgFiles = dir.entryList( QStringList(
"*.svg" ), QDir::Files );
3833 for (
const QString &item : svgFiles )
3836 list.append( dir.path() +
'/' + item );
3848 QStringList svgPaths;
3849 svgPaths.append( directory );
3851 for (
int i = 0; i < svgPaths.size(); i++ )
3853 QDir dir( svgPaths[i] );
3854 const auto svgSubPaths = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
3855 for (
const QString &item : svgSubPaths )
3857 svgPaths.insert( i + 1, dir.path() +
'/' + item );
3860 const auto svgFiles = dir.entryList( QStringList(
"*.svg" ), QDir::Files );
3861 for (
const QString &item : svgFiles )
3863 list.append( dir.path() +
'/' + item );
3875 if ( n.startsWith( QLatin1String(
"base64:" ) ) )
3879 if ( QFileInfo::exists( n ) )
3880 return QFileInfo( n ).canonicalFilePath();
3884 if ( name.contains( QLatin1String(
"://" ) ) )
3887 if ( url.isValid() && !url.scheme().isEmpty() )
3889 if ( url.scheme().compare( QLatin1String(
"file" ), Qt::CaseInsensitive ) == 0 )
3892 name = url.toLocalFile();
3893 if ( QFile( name ).exists() )
3895 return QFileInfo( name ).canonicalFilePath();
3909 for (
int i = 0; i < svgPaths.size(); i++ )
3911 QString svgPath = svgPaths[i];
3912 if ( svgPath.endsWith( QChar(
'/' ) ) )
3923 QString myLocalPath = svgPath + QDir::separator() + name;
3926 if ( QFile( myLocalPath ).exists() )
3929 return QFileInfo( myLocalPath ).canonicalFilePath();
3933 return pathResolver.
readPath( name );
3941 if ( p.startsWith( QLatin1String(
"base64:" ) ) )
3944 if ( !QFileInfo::exists( p ) )
3947 QString path = QFileInfo( p ).canonicalFilePath();
3951 bool isInSvgPaths =
false;
3952 for (
int i = 0; i < svgPaths.size(); i++ )
3954 QString dir = QFileInfo( svgPaths[i] ).canonicalFilePath();
3956 if ( !dir.isEmpty() && path.startsWith( dir ) )
3958 path = path.mid( dir.size() + 1 );
3959 isInSvgPaths =
true;
3974 double cx = 0, cy = 0;
3975 double area, sum = 0;
3976 for (
int i = points.count() - 1, j = 0; j < points.count(); i = j++ )
3978 const QPointF &p1 = points[i];
3979 const QPointF &p2 = points[j];
3980 area = p1.x() * p2.y() - p1.y() * p2.x();
3982 cx += ( p1.x() + p2.x() ) * area;
3983 cy += ( p1.y() + p2.y() ) * area;
3990 if ( points.count() >= 2 )
3991 return QPointF( ( points[0].x() + points[1].x() ) / 2, ( points[0].y() + points[1].y() ) / 2 );
3992 else if ( points.count() == 1 )
4000 return QPointF( cx, cy );
4007 if ( ( rings && rings->count() > 0 ) || !
pointInPolygon( points, centroid ) )
4009 unsigned int i, pointCount = points.count();
4011 for ( i = 0; i < pointCount; ++i ) polyline[i] =
QgsPointXY( points[i].x(), points[i].y() );
4017 QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
4018 for ( ; ringIt != rings->constEnd(); ++ringIt )
4020 pointCount = ( *ringIt ).count();
4022 for ( i = 0; i < pointCount; ++i ) polyline[i] =
QgsPointXY( ( *ringIt )[i].x(), ( *ringIt )[i].y() );
4028 if ( !pointOnSurfaceGeom.
isNull() )
4031 centroid.
setX( point.
x() );
4032 centroid.setY( point.
y() );
4037 return QPointF( centroid.x(), centroid.y() );
4042 bool inside =
false;
4044 double x = point.x();
4045 double y = point.y();
4047 for (
int i = 0, j = points.count() - 1; i < points.count(); i++ )
4049 const QPointF &p1 = points[i];
4050 const QPointF &p2 = points[j];
4055 if ( ( p1.y() < y && p2.y() >= y ) || ( p2.y() < y && p1.y() >= y ) )
4057 if ( p1.x() + ( y - p1.y() ) / ( p2.y() - p1.y() ) * ( p2.x() - p1.x() ) <= x )
4068 if ( fieldOrExpression.isEmpty() )
4087 return static_cast<const QgsExpressionNodeColumnRef *>( n )->name();
4103 QList<double> breaks;
4106 breaks.append( maximum );
4110 int minimumCount =
static_cast< int >( classes ) / 3;
4111 double shrink = 0.75;
4112 double highBias = 1.5;
4113 double adjustBias = 0.5 + 1.5 * highBias;
4114 int divisions = classes;
4115 double h = highBias;
4118 double dx = maximum - minimum;
4128 cell = std::max( std::fabs( minimum ), std::fabs( maximum ) );
4129 if ( adjustBias >= 1.5 * h + 0.5 )
4131 U = 1 + ( 1.0 / ( 1 + h ) );
4135 U = 1 + ( 1.5 / ( 1 + adjustBias ) );
4137 small = dx < ( cell * U * std::max( 1, divisions ) * 1e-07 * 3.0 );
4144 cell = 9 + cell / 10;
4145 cell = cell * shrink;
4147 if ( minimumCount > 1 )
4149 cell = cell / minimumCount;
4155 if ( divisions > 1 )
4157 cell = cell / divisions;
4160 if ( cell < 20 * 1e-07 )
4165 double base = std::pow( 10.0, std::floor( std::log10( cell ) ) );
4167 if ( ( 2 * base ) - cell < h * ( cell - unit ) )
4170 if ( ( 5 * base ) - cell < adjustBias * ( cell - unit ) )
4173 if ( ( 10.0 * base ) - cell < h * ( cell - unit ) )
4180 int start = std::floor( minimum / unit + 1e-07 );
4181 int end = std::ceil( maximum / unit - 1e-07 );
4184 while ( start * unit > minimum + ( 1e-07 * unit ) )
4188 while ( end * unit < maximum - ( 1e-07 * unit ) )
4192 QgsDebugMsg( QStringLiteral(
"pretty classes: %1" ).arg( end ) );
4196 int k = std::floor( 0.5 + end - start );
4197 if ( k < minimumCount )
4199 k = minimumCount - k;
4203 start = start - k / 2 + k % 2;
4207 start = start - k / 2;
4208 end = end + k / 2 + k % 2;
4211 double minimumBreak = start * unit;
4213 int count = end - start;
4215 breaks.reserve( count );
4216 for (
int i = 1; i < count + 1; i++ )
4218 breaks.append( minimumBreak + i * unit );
4221 if ( breaks.isEmpty() )
4224 if ( breaks.first() < minimum )
4226 breaks[0] = minimum;
4228 if ( breaks.last() > maximum )
4230 breaks[breaks.count() - 1] = maximum;
4235 if ( minimum < 0.0 && maximum > 0.0 )
4237 QList<double> breaksMinusZero;
4238 for (
int i = 0; i < breaks.count(); i++ )
4240 breaksMinusZero.append( breaks[i] - 0.0 );
4243 for (
int i = 1; i < breaks.count(); i++ )
4245 if ( std::abs( breaksMinusZero[i] ) < std::abs( breaksMinusZero[i - 1] ) )
4248 breaks[posOfMin] = 0.0;
4257 bool roundToUnit =
false;
4260 if ( props.contains( QStringLiteral(
"uomScale" ) ) )
4263 scale = props.value( QStringLiteral(
"uomScale" ) ).toDouble( &ok );
4272 if ( props.value( QStringLiteral(
"uom" ) ) == QLatin1String(
"http://www.opengeospatial.org/se/units/metre" ) )
4297 scale = 1 / 0.28 * 25.4;
4321 double rescaled = size * scale;
4326 rescaled = std::round( rescaled );
4333 double x =
rescaleUom( point.x(), unit, props );
4334 double y =
rescaleUom( point.y(), unit, props );
4335 return QPointF( x, y );
4340 QVector<qreal> result;
4341 QVector<qreal>::const_iterator it = array.constBegin();
4342 for ( ; it != array.constEnd(); ++it )
4344 result.append(
rescaleUom( *it, unit, props ) );
4351 if ( !props.value( QStringLiteral(
"scaleMinDenom" ), QString() ).isEmpty() )
4353 QDomElement scaleMinDenomElem = doc.createElement( QStringLiteral(
"se:MinScaleDenominator" ) );
4354 scaleMinDenomElem.appendChild( doc.createTextNode(
qgsDoubleToString( props.value( QStringLiteral(
"scaleMinDenom" ) ).toDouble() ) ) );
4355 ruleElem.appendChild( scaleMinDenomElem );
4358 if ( !props.value( QStringLiteral(
"scaleMaxDenom" ), QString() ).isEmpty() )
4360 QDomElement scaleMaxDenomElem = doc.createElement( QStringLiteral(
"se:MaxScaleDenominator" ) );
4361 scaleMaxDenomElem.appendChild( doc.createTextNode(
qgsDoubleToString( props.value( QStringLiteral(
"scaleMaxDenom" ) ).toDouble() ) ) );
4362 ruleElem.appendChild( scaleMaxDenomElem );
4371 double parentScaleMinDenom = props.value( QStringLiteral(
"scaleMinDenom" ), QStringLiteral(
"0" ) ).toDouble( &ok );
4372 if ( !ok || parentScaleMinDenom <= 0 )
4373 props[ QStringLiteral(
"scaleMinDenom" )] = QString::number( mScaleMinDenom );
4375 props[ QStringLiteral(
"scaleMinDenom" )] = QString::number( std::max( parentScaleMinDenom, mScaleMinDenom ) );
4381 double parentScaleMaxDenom = props.value( QStringLiteral(
"scaleMaxDenom" ), QStringLiteral(
"0" ) ).toDouble( &ok );
4382 if ( !ok || parentScaleMaxDenom <= 0 )
4383 props[ QStringLiteral(
"scaleMaxDenom" )] = QString::number( mScaleMaxDenom );
4385 props[ QStringLiteral(
"scaleMaxDenom" )] = QString::number( std::min( parentScaleMaxDenom, mScaleMaxDenom ) );
4393 if ( uom == QLatin1String(
"http://www.opengeospatial.org/se/units/metre" ) )
4395 scale = 1.0 / 0.00028;
4397 else if ( uom == QLatin1String(
"http://www.opengeospatial.org/se/units/foot" ) )
4399 scale = 304.8 / 0.28;
4406 return size * scale;
static void mergeScaleDependencies(double mScaleMinDenom, double mScaleMaxDenom, QgsStringMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any.
static void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
Class for parsing and evaluation of expressions (formerly called "search strings").
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers. ...
The class is used as a container of context for various read/write operations on other objects...
static QgsSymbol * symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
Meters value as Map units.
static QIcon symbolLayerPreviewIcon(const QgsSymbolLayer *layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
Draws a symbol layer preview to an icon.
static QgsStringMap parseProperties(QDomElement &element)
static QgsSymbolLayer * loadSymbolLayer(QDomElement &element, const QgsReadWriteContext &context)
Reads and returns symbol layer from XML. Caller is responsible for deleting the returned object...
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
static QgsSymbol::ScaleMethod decodeScaleMethod(const QString &str)
static QgsGeometry fromPolylineXY(const QgsPolylineXY &polyline)
Creates a new LineString geometry from a list of QgsPointXY points.
static QStringList listSvgFilesAt(const QString &directory)
Returns a list of svg files at the specified directory.
static bool needFontMarker(QDomElement &element)
void setRenderingPass(int renderingPass)
Specifies the rendering pass in which this symbol layer should be rendered.
static QPointF toPoint(const QVariant &value, bool *ok=nullptr)
Converts a value to a point.
static Qt::BrushStyle decodeBrushStyle(const QString &str)
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
void setLocked(bool locked)
static bool hasWellKnownMark(QDomElement &element)
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map...
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string ma...
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
static QgsStringMap getSvgParameterList(QDomElement &element)
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
static QPicture symbolLayerPreviewPicture(const QgsSymbolLayer *layer, QgsUnitTypes::RenderUnit units, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
Draws a symbol layer preview to a QPicture.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the layer.
Calculate scale by the diameter.
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
static QString encodeSldAlpha(int alpha)
Abstract base class for all rendered symbols.
static QgsArrowSymbolLayer::ArrowType decodeArrowType(const QVariant &value, bool *ok=nullptr)
Decodes a value representing an arrow type.
static QString encodeSldBrushStyle(Qt::BrushStyle style)
static QString encodeSize(QSizeF size)
Encodes a QSizeF to a string.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
virtual bool readXml(const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions)
Reads property collection state from an XML element.
static void applyScaleDependency(QDomDocument &doc, QDomElement &ruleElem, QgsStringMap &props)
Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into t...
static Qt::PenCapStyle decodeSldLineCapStyle(const QString &str)
static void createOnlineResourceElement(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format)
QgsWkbTypes::Type wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
static QDomElement createSvgParameterElement(QDomDocument &doc, const QString &name, const QString &value)
static bool geometryFromSldElement(QDomElement &element, QString &geomFunc)
A class to represent a 2D point.
QgsSymbolLayer * createSymbolLayer(const QString &name, const QgsStringMap &properties=QgsStringMap()) const
create a new instance of symbol layer given symbol layer name and properties
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
static QgsNamedColorList colorListFromMimeData(const QMimeData *data)
Attempts to parse mime data as a list of named colors.
static QString fieldOrExpressionFromExpression(QgsExpression *expression)
Returns a field name if the whole expression is just a name of the field .
static bool functionFromSldElement(QDomElement &element, QString &function)
Abstract base class for color ramps.
static QString ogrFeatureStyleBrush(const QColor &fillColr)
Create ogr feature style string for brush.
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
static QDomElement saveColorRamp(const QString &name, QgsColorRamp *ramp, QDomDocument &doc)
Encodes a color ramp's settings to an XML element.
static bool needMarkerLine(QDomElement &element)
static void externalMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
static QPointF polygonPointOnSurface(const QPolygonF &points, QList< QPolygonF > *rings=nullptr)
Calculate a point on the surface of a QPolygonF.
static bool onlineResourceFromSldElement(QDomElement &element, QString &path, QString &format)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
A geometry is the spatial representation of a feature.
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
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...
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
static void clearSymbolMap(QgsSymbolMap &symbols)
OperationResult addRing(const QVector< QgsPointXY > &ring)
Adds a new ring to this geometry.
static QFont::Style decodeSldFontStyle(const QString &str)
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
static QgsSymbol * loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element.
Percentage of another measurement (e.g., canvas size, feature size)
static QgsArrowSymbolLayer::HeadType decodeArrowHeadType(const QVariant &value, bool *ok=nullptr)
Decodes a value representing an arrow head type.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
static bool createExpressionElement(QDomDocument &doc, QDomElement &element, const QString &function)
Creates a OGC Expression element based on the provided function expression.
QString parserErrorString() const
Returns parser error.
QMap< QString, QString > QgsStringMap
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
double maxScale
The maximum scale, or 0.0 if unset.
A marker symbol type, for rendering Point and MultiPoint geometries.
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
A line symbol type, for rendering LineString and MultiLineString geometries.
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...
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects. ...
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
bool hasFeature() const
Returns true if the context has a feature associated with it.
static QString getSvgParametricPath(const QString &basePath, const QColor &fillColor, const QColor &strokeColor, double strokeWidth)
Encodes a reference to a parametric SVG into a path with parameters according to the SVG Parameters s...
static QVector< qreal > decodeRealVector(const QString &s)
static QString encodeColor(const QColor &color)
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
QgsMultiPolylineXY asMultiPolyline() const
Returns the contents of the geometry as a multi-linestring.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
static QPointF pointOnLineWithDistance(QPointF startPoint, QPointF directionPoint, double distance)
Returns a point on the line from startPoint to directionPoint that is a certain distance away from th...
static QSizeF toSize(const QVariant &value, bool *ok=nullptr)
Converts a value to a size.
SymbolType
Type of the symbol.
static QString encodePenStyle(Qt::PenStyle style)
static QString svgSymbolPathToName(const QString &path, const QgsPathResolver &pathResolver)
Determines an SVG symbol's name from its path.
static double rescaleUom(double size, QgsUnitTypes::RenderUnit unit, const QgsStringMap &props)
Rescales the given size based on the uomScale found in the props, if any is found, otherwise returns the value un-modified.
static int decodeSldFontWeight(const QString &str)
int renderingPass() const
Specifies the rendering pass in which this symbol layer should be rendered.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
bool isProjectColor() const
Returns true if the property is set to a linked project color.
static QgsUnitTypes::RenderUnit decodeSldUom(const QString &str, double *scaleFactor)
Decodes a SLD unit of measure string to a render unit.
static QgsNamedColorList importColorsFromGpl(QFile &file, bool &ok, QString &name)
Imports colors from a gpl GIMP palette file.
#define QgsDebugMsgLevel(str, level)
static QDomElement saveSymbols(QgsSymbolMap &symbols, const QString &tagName, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a collection of symbols to XML with specified tagName for the top-level element.
bool forceRHR() const
Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-...
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &mime, const QColor &color, double size=-1)
static QString encodeSldRealVector(const QVector< qreal > &v)
static bool needEllipseMarker(QDomElement &element)
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
static QgsStringMap getVendorOptionList(QDomElement &element)
QgsPolygonXY asPolygon() const
Returns the contents of the geometry as a polygon.
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...
Calculate scale by the area.
static bool needSvgMarker(QDomElement &element)
static QVariant colorRampToVariant(const QString &name, QgsColorRamp *ramp)
Saves a color ramp to a QVariantMap, wrapped in a QVariant.
static QString colorToName(const QColor &color)
Returns a friendly display name for a color.
static QMimeData * symbolToMimeData(const QgsSymbol *symbol)
Creates new mime data from a symbol.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
void setActive(bool active)
Sets whether the property is currently active.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QIcon colorRampPreviewIcon(QgsColorRamp *ramp, QSize size, int padding=0)
Returns an icon preview for a color ramp.
static int decodeSldAlpha(const QString &str)
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides...
virtual double value(int index) const =0
Returns relative value between [0,1] of color at specified index.
static QString encodeSldLineJoinStyle(Qt::PenJoinStyle style)
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.
static QgsSymbolLayer * createMarkerLayerFromSld(QDomElement &element)
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
ArrowType
Possible arrow types.
QgsGeometry offsetCurve(double distance, int segments, JoinStyle joinStyle, double miterLimit) const
Returns an offset line at a given distance and side from an input line.
QList< QgsSymbolLayer * > QgsSymbolLayerList
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
static QgsColorRamp * loadColorRamp(QDomElement &element)
Creates a color ramp from the settings encoded in an XML element.
static QString encodeSldUom(QgsUnitTypes::RenderUnit unit, double *scaleFactor)
Encodes a render unit into an SLD unit of measure string.
QColor color() const
Returns the symbol's color.
static QgsSymbolLayer * createFillLayerFromSld(QDomElement &element)
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
Abstract base class for all nodes that can appear in an expression.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
static QPainter::CompositionMode decodeBlendMode(const QString &s)
static Qt::PenCapStyle decodePenCapStyle(const QString &str)
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the layer.
static bool needLinePatternFill(QDomElement &element)
static void parametricSvgToSld(QDomDocument &doc, QDomElement &graphicElem, const QString &path, const QColor &fillColor, double size, const QColor &strokeColor, double strokeWidth)
Encodes a reference to a parametric SVG into SLD, as a succession of parametric SVG using URL paramet...
virtual QString type() const =0
Returns a string representing the color ramp type.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
static bool lineFromSld(QDomElement &element, Qt::PenStyle &penStyle, QColor &color, double &width, Qt::PenJoinStyle *penJoinStyle=nullptr, Qt::PenCapStyle *penCapStyle=nullptr, QVector< qreal > *customDashPattern=nullptr, double *dashOffset=nullptr)
void setEnabled(bool enabled)
Sets whether symbol layer is enabled and should be drawn.
A store for object properties.
static QString encodeSldFontStyle(QFont::Style style)
static QStringList listSvgFiles()
Returns a list of all available svg files.
static QgsExpression * fieldOrExpressionToExpression(const QString &fieldOrExpression)
Returns a new valid expression instance for given field or expression string.
static QgsSymbolMap loadSymbols(QDomElement &element, const QgsReadWriteContext &context)
Reads a collection of symbols from XML and returns them in a map. Caller is responsible for deleting ...
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
static bool opacityFromSldElement(QDomElement &element, QString &alphaFunc)
static Qt::PenStyle decodePenStyle(const QString &str)
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
static void premultiplyColor(QColor &rgb, int alpha)
Converts a QColor into a premultiplied ARGB QColor value using a specified alpha value.
static bool needPointPatternFill(QDomElement &element)
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
void setX(double x)
Sets the x value of the point.
static QString encodeSldFontWeight(int weight)
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
static QPixmap colorRampPreviewPixmap(QgsColorRamp *ramp, QSize size, int padding=0)
Returns a pixmap preview for a color ramp.
static bool pointInPolygon(const QPolygonF &points, QPointF point)
Calculate whether a point is within of a QPolygonF.
QString expression() const
Returns the original, unmodified expression string.
QgsExpressionContext & expressionContext()
Gets the expression context.
static QSizeF decodeSize(const QString &string)
Decodes a QSizeF from a string.
static Qt::BrushStyle decodeSldBrushStyle(const QString &str)
static QgsGeometry fromPolygonXY(const QgsPolygonXY &polygon)
Creates a new geometry from a QgsPolygon.
static QString symbolProperties(QgsSymbol *symbol)
Returns a string representing the symbol.
static QString encodeScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
static bool hasExternalGraphic(QDomElement &element)
static bool externalMarkerFromSld(QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &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...
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
static void sortVariantList(QList< QVariant > &list, Qt::SortOrder order)
Sorts the passed list in requested order.
static QPointF polygonCentroid(const QPolygonF &points)
Calculate the centroid point of a QPolygonF.
VertexMarkerType
Editing vertex markers.
static bool convertPolygonSymbolizerToPointMarker(QDomElement &element, QgsSymbolLayerList &layerList)
static void drawVertexMarker(double x, double y, QPainter &p, QgsSymbolLayerUtils::VertexMarkerType type, int markerSize)
Draws a vertex symbol at (painter) coordinates x, y.
static QVector< qreal > decodeSldRealVector(const QString &s)
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsColorRamp from a map of properties.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
static bool saveColorsToGpl(QFile &file, const QString &paletteName, const QgsNamedColorList &colors)
Exports colors to a gpl GIMP palette file.
Contains information about the context of a rendering operation.
void resolvePaths(const QString &name, QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving) const
Resolve paths in properties of a particular symbol layer.
static void createOpacityElement(QDomDocument &doc, QDomElement &element, const QString &alphaFunc)
static void labelTextToSld(QDomDocument &doc, QDomElement &element, const QString &label, const QFont &font, const QColor &color=QColor(), double size=-1)
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
static void blurImageInPlace(QImage &image, QRect rect, int radius, bool alphaOnly)
Blurs an image in place, e.g. creating Qt-independent drop shadows.
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
bool hasDataDefinedProperties() const
Returns whether the symbol utilizes any data defined properties.
Points (e.g., for font sizes)
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
SymbolType type() const
Returns the symbol's type.
Struct for storing maximum and minimum scales for measurements in map units.
static QString encodeBrushStyle(Qt::BrushStyle style)
const QgsExpressionNode * rootNode() const
Returns the root node of the expression.
static void createAnchorPointElement(QDomDocument &doc, QDomElement &element, QPointF anchor)
Creates a SE 1.1 anchor point element as a child of the specified element.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
QgsSymbolLayer * createSymbolLayerFromSld(const QString &name, QDomElement &element) const
create a new instance of symbol layer given symbol layer name and SLD
static QDomElement expressionToOgcFilter(const QgsExpression &exp, QDomDocument &doc, QString *errorMessage=nullptr)
Creates OGC filter XML element.
static QMimeData * colorToMimeData(const QColor &color)
Creates mime data from a color.
static bool needSvgFill(QDomElement &element)
virtual QgsStringMap properties() const =0
Returns a string map containing all the color ramp's properties.
static QDomElement expressionToOgcExpression(const QgsExpression &exp, QDomDocument &doc, QString *errorMessage=nullptr)
Creates an OGC expression XML element.
static QPixmap symbolPreviewPixmap(const QgsSymbol *symbol, QSize size, int padding=0, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr)
Returns a pixmap preview for a color ramp.
QMap< QString, QgsSymbol *> QgsSymbolMap
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
static QMimeData * colorListToMimeData(const QgsNamedColorList &colorList, bool allFormats=true)
Creates mime data from a list of named colors.
QList< QPolygonF > offsetLine(QPolygonF polyline, double dist, QgsWkbTypes::GeometryType geometryType)
calculate geometry shifted by a specified distance
static QStringList svgPaths()
Returns the paths to svg directories.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static QgsSymbolLayer * createLineLayerFromSld(QDomElement &element)
QgsPolylineXY asPolyline() const
Returns the contents of the geometry as a polyline.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
static void fillToSld(QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, const QColor &color=QColor())
void appendScopes(const QList< QgsExpressionContextScope *> &scopes)
Appends a list of scopes to the end of the context.
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, const QColor &color, double width=-1, const Qt::PenJoinStyle *penJoinStyle=nullptr, const Qt::PenCapStyle *penCapStyle=nullptr, const QVector< qreal > *customDashPattern=nullptr, double dashOffset=0.0)
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
static QString encodePenCapStyle(Qt::PenCapStyle style)
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent...
qreal opacity() const
Returns the opacity for the symbol.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
Resolves relative paths into absolute paths and vice versa.
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string m...
HeadType
Possible head types.
Flat cap (in line with start/end of line)
static QgsExpression * expressionFromOgcFilter(const QDomElement &element, QgsVectorLayer *layer=nullptr)
Parse XML with OGC filter into QGIS expression.
double minScale
The minimum scale, or 0.0 if unset.
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element.
static Type flatType(Type type)
Returns the flat type for a WKB type.
static QString ogrFeatureStylePen(double width, double mmScaleFactor, double mapUnitsScaleFactor, const QColor &c, Qt::PenJoinStyle joinStyle=Qt::MiterJoin, Qt::PenCapStyle capStyle=Qt::FlatCap, double offset=0.0, const QVector< qreal > *dashPattern=nullptr)
Create ogr feature style string for pen.
virtual QgsExpressionNode::NodeType nodeType() const =0
Gets the type of this node.
static void multiplyImageOpacity(QImage *image, qreal opacity)
Multiplies opacity of image pixel values with a (global) transparency value.
QgsMultiPolygonXY asMultiPolygon() const
Returns the contents of the geometry as a multi-polygon.
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
static void saveProperties(QgsStringMap props, QDomDocument &doc, QDomElement &element)
static Qt::PenJoinStyle decodeSldLineJoinStyle(const QString &str)
static bool createSymbolLayerListFromSld(QDomElement &element, QgsWkbTypes::GeometryType geomType, QgsSymbolLayerList &layers)
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 void drawStippledBackground(QPainter *painter, QRect rect)
static QString encodeSldLineCapStyle(Qt::PenCapStyle style)
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
bool isActive() const
Returns whether the property is currently active.
static QString encodeRealVector(const QVector< qreal > &v)
RenderUnit
Rendering size units.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
static QColor decodeColor(const QString &str)
static QColor colorFromMimeData(const QMimeData *data, bool &hasAlpha)
Attempts to parse mime data as a color.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.