38 std::unique_ptr< QgsSimpleLineSymbolLayer > simpleLine = std::make_unique< QgsSimpleLineSymbolLayer >( foreColor, size );
39 simpleLine->setWidthUnit( sizeUnit );
40 simpleLine->setPenCapStyle( Qt::RoundCap );
41 simpleLine->setPenJoinStyle( Qt::RoundJoin );
43 QVector< qreal > dashPattern;
44 double patternOffset = 0;
55 simpleLine->setPenStyle( Qt::NoPen );
64 dashPattern << 1 << 2.2;
68 dashPattern << 2 << 2;
72 dashPattern << 4 << 2;
76 dashPattern << 8 << 2;
80 dashPattern << 16 << 4;
84 dashPattern << 32 << 8;
88 dashPattern << 10.5 << 4.5;
92 dashPattern << 1 << 13.5 / 2;
96 dashPattern << 4 << 8;
100 dashPattern << 8 << 8;
104 dashPattern << 16 << 16;
108 dashPattern << 10 << 5 << 1 << 5;
112 dashPattern << 18 << 3 << 1 << 3;
116 dashPattern << 20 << 3 << 4 << 3;
120 dashPattern << 32 << 12 << 6 << 12;
124 dashPattern << 32 << 6 << 4 << 6 << 4 << 6;
128 dashPattern << 32 << 6 << 4 << 6 << 4 << 6 << 4 << 6;
132 dashPattern << 11 << 5 << 1 << 5 << 1 << 5;
136 dashPattern << 20 << 4 << 1 << 4 << 1 << 4;
140 dashPattern << 20 << 4 << 1 << 4 << 1 << 4 << 1 << 4;
144 dashPattern << 6 << 2 << 1 << 2;
148 dashPattern << 6 << 2 << 1 << 2 << 1 << 2;
152 dashPattern << 10.5 << 2 << 1 << 2 << 4 << 2 << 1 << 2;
159 dashPattern << 18 << 4;
163 dashPattern << 7 << 4;
167 dashPattern << 16 << 6;
180 dashPattern << 20 << 15;
192 dashPattern << 4 << 8;
203 dashPattern << 15 << 4;
221 dashPattern << 10 << 5;
229 dashPattern << 12 << 20;
233 dashPattern << 20 << 8;
251 dashPattern << 0 << 4 << 1 << 4;
282 context.
pushWarning( QObject::tr(
"The line style is not supported in QGIS" ) );
288 simpleLine->setWidth( simpleLine->width() * 2 );
296 QgsDebugMsg( QStringLiteral(
"Unknown line symbol identifier %1" ).arg( identifier ) );
300 if ( !dashPattern.isEmpty() )
303 for (
int i = 0; i < dashPattern.size() ; ++i )
304 dashPattern[ i ] *= size;
306 simpleLine->setCustomDashVector( dashPattern );
307 simpleLine->setUseCustomDashPattern(
true );
308 simpleLine->setCustomDashPatternUnit( sizeUnit );
310 simpleLine->setDashPatternOffset( patternOffset * size );
311 simpleLine->setDashPatternOffsetUnit( sizeUnit );
314 std::unique_ptr< QgsLineSymbol > symbol = std::make_unique< QgsLineSymbol >(
QgsSymbolLayerList() << simpleLine.release() );
316 if ( ( identifier >= 26 && identifier < 29 ) || ( identifier >= 31 && identifier < 34 ) || ( identifier >= 36 && identifier < 38 ) || ( identifier >= 47 && identifier <= 53 ) || identifier == 118 )
318 std::unique_ptr< QgsHashedLineSymbolLayer > hash = std::make_unique< QgsHashedLineSymbolLayer >();
322 double lineOffset = 0;
324 switch ( identifier )
423 hash->setInterval( spacing * size );
424 hash->setIntervalUnit( sizeUnit );
426 hash->setOffset( lineOffset * size );
427 hash->setOffsetUnit( sizeUnit );
429 hash->setOffsetAlongLine( offset * size );
430 hash->setOffsetAlongLineUnit( sizeUnit );
432 hash->setHashLength( length * size );
433 hash->setHashLengthUnit( sizeUnit );
435 std::unique_ptr< QgsSimpleLineSymbolLayer > subSimpleLine = std::make_unique< QgsSimpleLineSymbolLayer >( foreColor, size );
436 subSimpleLine->setWidthUnit( sizeUnit );
437 subSimpleLine->setPenCapStyle( Qt::RoundCap );
438 subSimpleLine->setPenJoinStyle( Qt::RoundJoin );
440 std::unique_ptr< QgsLineSymbol > subSymbol = std::make_unique< QgsLineSymbol >(
QgsSymbolLayerList() << subSimpleLine.release() );
441 hash->setSubSymbol( subSymbol.release() );
443 if ( identifier == 31 || identifier == 33 )
445 std::unique_ptr< QgsHashedLineSymbolLayer > hash2( hash->clone() );
446 hash->setOffsetAlongLine( hash->offsetAlongLine() - size );
447 hash2->setOffsetAlongLine( hash2->offsetAlongLine() + size );
448 symbol->appendSymbolLayer( hash2.release() );
450 else if ( identifier == 36 || identifier == 37 )
452 std::unique_ptr< QgsHashedLineSymbolLayer > hash2( hash->clone() );
453 hash2->setOffsetAlongLine( dashPattern.at( 0 ) );
454 symbol->appendSymbolLayer( hash2.release() );
456 else if ( identifier == 52 || identifier == 53 )
458 std::unique_ptr< QgsHashedLineSymbolLayer > hash2( hash->clone() );
459 hash2->setOffsetAlongLine( hash->offsetAlongLine() * 2 );
460 symbol->appendSymbolLayer( hash2.release() );
462 else if ( identifier == 118 )
464 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setColor( QColor( 0, 0, 0 ) );
465 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setWidth( 0 );
466 symbol->symbolLayer( 0 )->setLocked(
true );
468 std::unique_ptr<QgsSimpleLineSymbolLayer > secondRail( qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->clone() );
469 const double offset = 2 * size;
470 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setOffset( offset );
471 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setOffsetUnit( sizeUnit );
472 secondRail->setOffset( -offset );
473 secondRail->setOffsetUnit( sizeUnit );
475 secondRail->setLocked(
true );
476 symbol->appendSymbolLayer( secondRail.release() );
478 symbol->appendSymbolLayer( hash.release() );
480 else if ( ( identifier >= 29 && identifier < 31 ) || ( identifier >= 34 && identifier < 36 ) )
484 switch ( identifier )
502 std::unique_ptr< QgsHashedLineSymbolLayer > hash = std::make_unique< QgsHashedLineSymbolLayer >();
503 hash->setInterval( spacing * size * 2 );
504 hash->setIntervalUnit( sizeUnit );
506 hash->setOffsetAlongLine( offset * size );
507 hash->setOffsetAlongLineUnit( sizeUnit );
509 hash->setHashLength( 3.5 * size * 0.5 );
510 hash->setHashLengthUnit( sizeUnit );
512 std::unique_ptr< QgsSimpleLineSymbolLayer > subSimpleLine = std::make_unique< QgsSimpleLineSymbolLayer >( foreColor, size );
513 subSimpleLine->setWidthUnit( sizeUnit );
514 subSimpleLine->setPenCapStyle( Qt::RoundCap );
515 subSimpleLine->setPenJoinStyle( Qt::RoundJoin );
517 std::unique_ptr< QgsLineSymbol > subSymbol = std::make_unique< QgsLineSymbol >(
QgsSymbolLayerList() << subSimpleLine.release() );
518 hash->setSubSymbol( subSymbol.release() );
519 std::unique_ptr< QgsHashedLineSymbolLayer > hash2( hash->clone() );
521 hash->setOffset( -hash->hashLength() );
522 hash->setOffsetUnit( hash->hashLengthUnit() );
523 hash2->setOffset( hash->hashLength() );
524 hash2->setOffsetUnit( hash->hashLengthUnit() );
525 hash2->setOffsetAlongLine( hash2->offsetAlongLine() + hash2->interval() * 0.5 );
527 switch ( identifier )
531 symbol->appendSymbolLayer( hash.release() );
532 symbol->appendSymbolLayer( hash2.release() );
538 std::unique_ptr< QgsHashedLineSymbolLayer > hash3( hash->clone() );
539 std::unique_ptr< QgsHashedLineSymbolLayer > hash4( hash2->clone() );
541 hash->setOffsetAlongLine( hash->offsetAlongLine() - size );
542 hash3->setOffsetAlongLine( hash3->offsetAlongLine() + size );
543 hash2->setOffsetAlongLine( hash2->offsetAlongLine() - size );
544 hash4->setOffsetAlongLine( hash4->offsetAlongLine() + size );
546 symbol->appendSymbolLayer( hash.release() );
547 symbol->appendSymbolLayer( hash2.release() );
548 symbol->appendSymbolLayer( hash3.release() );
549 symbol->appendSymbolLayer( hash4.release() );
554 else if ( ( identifier >= 38 && identifier < 41 ) || ( identifier >= 54 && identifier <= 61 ) || ( identifier >= 78 && identifier <= 109 ) || ( identifier >= 114 && identifier <= 117 ) )
556 std::unique_ptr< QgsMarkerLineSymbolLayer > marker = std::make_unique< QgsMarkerLineSymbolLayer >();
560 double markerSize = 1;
562 double lineOffset = 0;
565 switch ( identifier )
806 if ( identifier >= 78 && identifier <= 109 )
808 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setColor( QColor( 0, 0, 0 ) );
809 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setWidth( 0 );
810 symbol->symbolLayer( 0 )->setLocked(
true );
812 if ( ( identifier >= 84 && identifier <= 85 ) || ( identifier >= 92 && identifier <= 93 ) || ( identifier >= 100 && identifier <= 101 ) || ( identifier >= 108 && identifier <= 109 ) )
814 std::unique_ptr<QgsSimpleLineSymbolLayer > secondRail( qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->clone() );
816 double offset = 2 * size;
817 if ( identifier == 85 || identifier == 93 || identifier == 101 || identifier == 109 )
820 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setOffset( offset );
821 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setOffsetUnit( sizeUnit );
822 secondRail->setOffset( -offset );
823 secondRail->setOffsetUnit( sizeUnit );
825 secondRail->setLocked(
true );
826 symbol->appendSymbolLayer( secondRail.release() );
830 marker->setPlacement( placement );
831 marker->setInterval( spacing * size );
832 marker->setIntervalUnit( sizeUnit );
834 marker->setOffsetAlongLine( offset * size );
835 marker->setOffsetAlongLineUnit( sizeUnit );
837 marker->setOffset( lineOffset * size );
838 marker->setOffsetUnit( sizeUnit );
840 std::unique_ptr< QgsSimpleMarkerSymbolLayer > subSimpleMarker = std::make_unique< QgsSimpleMarkerSymbolLayer >( shape, markerSize * size );
841 subSimpleMarker->setColor( foreColor );
842 subSimpleMarker->setSizeUnit( sizeUnit );
843 subSimpleMarker->setStrokeWidth( size );
844 subSimpleMarker->setStrokeWidthUnit( sizeUnit );
845 subSimpleMarker->setAngle(
angle );
847 subSimpleMarker->setPenJoinStyle( Qt::RoundJoin );
848 subSimpleMarker->setPenCapStyle( Qt::RoundCap );
856 subSimpleMarker->setStrokeStyle( Qt::NoPen );
859 std::unique_ptr< QgsMarkerSymbol > subSymbol = std::make_unique< QgsMarkerSymbol >(
QgsSymbolLayerList() << subSimpleMarker.release() );
860 marker->setSubSymbol( subSymbol.release() );
862 if ( identifier == 56 )
864 std::unique_ptr< QgsMarkerLineSymbolLayer > marker2( marker->clone() );
865 marker2->setOffsetAlongLine( 19 * size );
866 qgis::down_cast< QgsMarkerSymbol * >( marker2->subSymbol() )->setAngle( 0 );
867 symbol->appendSymbolLayer( marker2.release() );
869 else if ( identifier == 61 )
871 std::unique_ptr< QgsMarkerLineSymbolLayer > marker2( marker->clone() );
873 qgis::down_cast< QgsMarkerSymbol * >( marker2->subSymbol() )->setAngle( 180 );
874 symbol->appendSymbolLayer( marker2.release() );
876 else if ( identifier == 80 || identifier == 88 || identifier == 96 || identifier == 104 )
878 std::unique_ptr< QgsMarkerLineSymbolLayer > marker2( marker->clone() );
880 qgis::down_cast< QgsMarkerSymbol * >( marker2->subSymbol() )->setAngle( 180 );
881 symbol->appendSymbolLayer( marker2.release() );
884 if ( identifier == 116 )
886 std::unique_ptr< QgsMarkerLineSymbolLayer > marker2( marker->clone() );
889 marker2->setOffsetAlongLine( 16 * size );
890 marker2->setOffset( -1.5 * size );
891 symbol->appendSymbolLayer( marker2.release() );
894 symbol->appendSymbolLayer( marker.release() );
896 else if ( identifier >= 41 && identifier < 45 )
898 const int count = identifier - 40;
900 simpleLine->
setCustomDashVector( QVector< qreal >() << 0 << 5.25 * size << 4 * size << ( 3.25 * size + ( count - 1 ) * ( 7.25 * size ) ) );
904 for (
int i = 1 ; i < count; ++i )
906 std::unique_ptr< QgsSimpleLineSymbolLayer > dashLine( simpleLine->
clone() );
908 dashLine->setCustomDashVector( QVector< qreal >() << 0 << 5.25 * size + ( i * 7.25 * size ) << 4 * size << ( 3.25 * size + ( count - 1 - i ) * ( 7.25 * size ) ) );
909 symbol->appendSymbolLayer( dashLine.release() );
912 std::unique_ptr< QgsSimpleLineSymbolLayer > simpleLine2 = std::make_unique< QgsSimpleLineSymbolLayer >( foreColor, 1.6 * size );
913 simpleLine2->setWidthUnit( sizeUnit );
914 simpleLine2->setPenCapStyle( Qt::RoundCap );
915 simpleLine2->setPenJoinStyle( Qt::RoundJoin );
917 simpleLine2->setCustomDashVector( QVector< qreal >() << 2 * size << 10.5 * size + ( count - 1 ) * ( 7.25 * size ) );
918 simpleLine2->setUseCustomDashPattern(
true );
919 simpleLine2->setCustomDashPatternUnit( sizeUnit );
921 symbol->appendSymbolLayer( simpleLine2.release() );
923 else if ( identifier == 45 )
925 std::unique_ptr< QgsSimpleLineSymbolLayer > simpleLine2 = std::make_unique< QgsSimpleLineSymbolLayer >( foreColor, 1.6 * size );
926 simpleLine2->setWidthUnit( sizeUnit );
927 simpleLine2->setPenCapStyle( Qt::RoundCap );
928 simpleLine2->setPenJoinStyle( Qt::RoundJoin );
930 simpleLine2->setCustomDashVector( QVector< qreal >() << 0 << 2 * size << 1.25 * size << 6.5 * size );
931 simpleLine2->setUseCustomDashPattern(
true );
932 simpleLine2->setCustomDashPatternUnit( sizeUnit );
934 symbol->appendSymbolLayer( simpleLine2.release() );
936 else if ( identifier == 46 )
938 std::unique_ptr< QgsHashedLineSymbolLayer > hashLine = std::make_unique< QgsHashedLineSymbolLayer >();
940 hashLine->setInterval( 4 * size );
941 hashLine->setIntervalUnit( sizeUnit );
942 hashLine->setOffsetAlongLine( 2 * size );
943 hashLine->setOffsetAlongLineUnit( sizeUnit );
944 hashLine->setHashLength( 3.8 * size );
945 hashLine->setHashLengthUnit( sizeUnit );
947 hashLine->setSubSymbol( symbol.release() );
949 symbol = std::make_unique< QgsLineSymbol >(
QgsSymbolLayerList() << hashLine.release() );
951 else if ( identifier == 62 )
953 std::unique_ptr< QgsMarkerLineSymbolLayer > markerLine = std::make_unique< QgsMarkerLineSymbolLayer >();
955 markerLine->setOffsetAlongLine( 2 * size );
956 markerLine->setOffsetAlongLineUnit( sizeUnit );
958 std::unique_ptr< QgsSimpleMarkerSymbolLayer > subSimpleMarker = std::make_unique< QgsSimpleMarkerSymbolLayer >(
QgsSimpleMarkerSymbolLayer::Line, size * 4 );
959 subSimpleMarker->setColor( foreColor );
960 subSimpleMarker->setSizeUnit( sizeUnit );
961 subSimpleMarker->setStrokeWidth( 1.25 * size );
962 subSimpleMarker->setStrokeWidthUnit( sizeUnit );
963 subSimpleMarker->setAngle( 90 );
965 subSimpleMarker->setPenJoinStyle( Qt::RoundJoin );
966 subSimpleMarker->setPenCapStyle( Qt::RoundCap );
968 std::unique_ptr< QgsMarkerSymbol > subSymbol = std::make_unique< QgsMarkerSymbol >(
QgsSymbolLayerList() << subSimpleMarker.release() );
969 markerLine->setSubSymbol( subSymbol.release() );
971 symbol->appendSymbolLayer( markerLine.release() );
973 else if ( ( identifier >= 63 && identifier <= 69 ) || ( identifier >= 72 && identifier <= 77 ) )
975 std::unique_ptr< QgsSimpleLineSymbolLayer > upperLine( qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->clone() );
976 upperLine->setUseCustomDashPattern(
false );
978 if ( identifier < 65 || ( identifier >= 68 && identifier <= 69 ) || identifier == 73 )
980 upperLine->setColor( QColor( 255, 255, 255 ) );
981 upperLine->setLocked(
true );
983 else if ( identifier < 67 || identifier == 72 || identifier == 75 || identifier == 76 )
985 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setColor( QColor( 0, 0, 0 ) );
986 symbol->symbolLayer( 0 )->setLocked(
true );
988 else if ( identifier <= 69 || identifier == 77 )
990 upperLine->setColor( QColor( 0, 0, 0 ) );
991 upperLine->setLocked(
true );
993 upperLine->setWidth( upperLine->width() * 0.9 );
996 upperLine->setRenderingPass( 1 );
999 if ( identifier >= 73 && identifier <= 75 )
1001 upperLine->setCustomDashVector( QVector< qreal >() << 0 << 10 * size << 12 * size << 2 * size );
1002 upperLine->setUseCustomDashPattern(
true );
1003 upperLine->setCustomDashPatternUnit( sizeUnit );
1005 else if ( identifier == 76 )
1007 upperLine->setCustomDashVector( QVector< qreal >() << 0 << 10 * size << 24 * size << 14 * size );
1008 upperLine->setUseCustomDashPattern(
true );
1009 upperLine->setCustomDashPatternUnit( sizeUnit );
1012 if ( identifier == 75 || identifier == 76 )
1014 std::unique_ptr< QgsSimpleLineSymbolLayer > middleLine = std::make_unique< QgsSimpleLineSymbolLayer >( QColor( 255, 255, 255 ), upperLine->width() );
1015 middleLine->setWidthUnit( sizeUnit );
1016 middleLine->setLocked(
true );
1017 middleLine->setPenCapStyle( Qt::RoundCap );
1018 middleLine->setPenJoinStyle( Qt::RoundJoin );
1022 middleLine->setRenderingPass( 1 );
1023 upperLine->setRenderingPass( 2 );
1025 symbol->appendSymbolLayer( middleLine.release() );
1028 symbol->appendSymbolLayer( upperLine.release() );
1030 if ( identifier == 64 || identifier == 66 )
1032 std::unique_ptr< QgsSimpleLineSymbolLayer > middleLine = std::make_unique< QgsSimpleLineSymbolLayer >( identifier == 64 ? foreColor : QColor( 0, 0, 0 ), 0 );
1033 if ( identifier == 66 )
1034 middleLine->setLocked(
true );
1038 middleLine->setRenderingPass( 2 );
1040 symbol->appendSymbolLayer( middleLine.release() );
1043 else if ( identifier == 69 )
1045 std::unique_ptr< QgsHashedLineSymbolLayer > hashedLine = std::make_unique< QgsHashedLineSymbolLayer >();
1047 std::unique_ptr< QgsSimpleLineSymbolLayer > middleLine = std::make_unique< QgsSimpleLineSymbolLayer >( foreColor, 0 );
1048 hashedLine->setSubSymbol(
new QgsLineSymbol( { middleLine.release() } ) );
1049 hashedLine->setInterval( 18 * size );
1050 hashedLine->setIntervalUnit( sizeUnit );
1051 hashedLine->setOffsetAlongLine( 4 * size );
1052 hashedLine->setOffsetAlongLineUnit( sizeUnit );
1053 hashedLine->setHashLength( 8 * size );
1054 hashedLine->setHashLengthUnit( sizeUnit );
1058 hashedLine->setRenderingPass( 2 );
1060 symbol->appendSymbolLayer( hashedLine.release() );
1062 else if ( identifier == 77 )
1064 std::unique_ptr< QgsSimpleLineSymbolLayer > middleLine = std::make_unique< QgsSimpleLineSymbolLayer >( QColor( 255, 255, 255 ), qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 1 ) )->width() );
1065 middleLine->setWidthUnit( sizeUnit );
1066 middleLine->setLocked(
true );
1067 middleLine->setPenCapStyle( Qt::RoundCap );
1068 middleLine->setPenJoinStyle( Qt::RoundJoin );
1069 middleLine->setCustomDashVector( QVector< qreal >() << 0 << 10 * size << 12 * size << 2 * size );
1070 middleLine->setUseCustomDashPattern(
true );
1071 middleLine->setCustomDashPatternUnit( sizeUnit );
1074 middleLine->setRenderingPass( 2 );
1076 symbol->appendSymbolLayer( middleLine.release() );
1079 else if ( identifier >= 70 && identifier <= 71 )
1081 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setColor( QColor( 0, 0, 0 ) );
1082 qgis::down_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) )->setLocked(
true );
1084 std::unique_ptr< QgsSimpleLineSymbolLayer > simpleLine2 = std::make_unique< QgsSimpleLineSymbolLayer >( foreColor, size );
1085 simpleLine2->setWidthUnit( sizeUnit );
1086 simpleLine2->setPenCapStyle( Qt::RoundCap );
1087 simpleLine2->setPenJoinStyle( Qt::RoundJoin );
1089 if ( identifier == 70 )
1090 simpleLine2->setCustomDashVector( QVector< qreal >() << 0 << 12 * size << 12 * size << 0 );
1091 else if ( identifier == 71 )
1092 simpleLine2->setCustomDashVector( QVector< qreal >() << 0 << 16 * size << 12 * size << 4 * size );
1094 simpleLine2->setUseCustomDashPattern(
true );
1095 simpleLine2->setCustomDashPatternUnit( sizeUnit );
1097 symbol->appendSymbolLayer( simpleLine2.release() );
1100 return symbol.release();
1105 Qt::BrushStyle style = Qt::SolidPattern;
1107 bool useLineFill =
false;
1108 bool crossFill =
false;
1109 double lineAngle = 0;
1110 double lineWidth = 0;
1111 double lineSpacing = 1;
1112 switch ( identifier )
1116 style = Qt::NoBrush;
1120 style = Qt::SolidPattern;
1125 style = Qt::HorPattern;
1130 style = Qt::VerPattern;
1135 style = Qt::FDiagPattern;
1140 style = Qt::BDiagPattern;
1145 style = Qt::CrossPattern;
1150 style = Qt::DiagCrossPattern;
1154 style = Qt::Dense1Pattern;
1158 style = Qt::Dense2Pattern;
1162 style = Qt::Dense3Pattern;
1166 style = Qt::Dense4Pattern;
1170 style = Qt::Dense5Pattern;
1174 style = Qt::Dense6Pattern;
1178 style = Qt::Dense7Pattern;
1350 context.
pushWarning( QObject::tr(
"The brush style is not supported in QGIS" ) );
1355 if ( backColor.isValid() && style != Qt::SolidPattern && ( useLineFill || style != Qt::NoBrush ) )
1357 std::unique_ptr< QgsSimpleFillSymbolLayer > backgroundFill = std::make_unique< QgsSimpleFillSymbolLayer >( backColor );
1358 backgroundFill->setLocked(
true );
1359 backgroundFill->setStrokeStyle( Qt::NoPen );
1360 layers << backgroundFill.release();
1365 std::unique_ptr< QgsSimpleFillSymbolLayer > foregroundFill = std::make_unique< QgsSimpleFillSymbolLayer >( foreColor );
1366 foregroundFill->setBrushStyle( style );
1367 foregroundFill->setStrokeStyle( Qt::NoPen );
1368 layers << foregroundFill.release();
1372 std::unique_ptr< QgsLinePatternFillSymbolLayer > lineFill = std::make_unique< QgsLinePatternFillSymbolLayer >();
1374 std::unique_ptr< QgsSimpleLineSymbolLayer > simpleLine = std::make_unique< QgsSimpleLineSymbolLayer >( foreColor, lineWidth );
1378 lineFill->setDistance( lineSpacing );
1380 lineFill->setLineAngle( lineAngle );
1384 std::unique_ptr< QgsLinePatternFillSymbolLayer > lineFill2( lineFill->clone() );
1385 lineFill2->setLineAngle( lineFill->lineAngle() + 90 );
1386 layers << lineFill2.release();
1389 layers << lineFill.release();
1397 bool isFilled =
true;
1398 bool isNull =
false;
1399 bool hasShadow =
false;
1402 QPointF shadowOffset;
1403 switch ( identifier )
1407 shape = QgsSimpleMarkerSymbolLayer::Shape::Square;
1412 shape = QgsSimpleMarkerSymbolLayer::Shape::Square;
1416 shape = QgsSimpleMarkerSymbolLayer::Shape::Diamond;
1420 shape = QgsSimpleMarkerSymbolLayer::Shape::Circle;
1424 shape = QgsSimpleMarkerSymbolLayer::Shape::Star;
1428 shape = QgsSimpleMarkerSymbolLayer::Shape::Triangle;
1432 shape = QgsSimpleMarkerSymbolLayer::Shape::Triangle;
1437 shape = QgsSimpleMarkerSymbolLayer::Shape::Square;
1442 shape = QgsSimpleMarkerSymbolLayer::Shape::Diamond;
1447 shape = QgsSimpleMarkerSymbolLayer::Shape::Circle;
1452 shape = QgsSimpleMarkerSymbolLayer::Shape::Star;
1457 shape = QgsSimpleMarkerSymbolLayer::Shape::Triangle;
1462 shape = QgsSimpleMarkerSymbolLayer::Shape::Triangle;
1468 shape = QgsSimpleMarkerSymbolLayer::Shape::Square;
1470 shadowOffset = QPointF( size * 0.1, size * 0.1 );
1474 shape = QgsSimpleMarkerSymbolLayer::Shape::Triangle;
1475 shadowOffset = QPointF( size * 0.2, size * 0.1 );
1480 shape = QgsSimpleMarkerSymbolLayer::Shape::Circle;
1481 shadowOffset = QPointF( size * 0.1, size * 0.1 );
1486 shape = QgsSimpleMarkerSymbolLayer::Shape::Arrow;
1493 shape = QgsSimpleMarkerSymbolLayer::Shape::Arrow;
1500 shape = QgsSimpleMarkerSymbolLayer::Shape::Cross;
1504 shape = QgsSimpleMarkerSymbolLayer::Shape::Cross2;
1508 shape = QgsSimpleMarkerSymbolLayer::Shape::Cross;
1512 context.
pushWarning( QObject::tr(
"The symbol is not supported in QGIS" ) );
1516 std::unique_ptr< QgsSimpleMarkerSymbolLayer > simpleMarker = std::make_unique< QgsSimpleMarkerSymbolLayer >( shape, size );
1517 simpleMarker->setSizeUnit( sizeUnit );
1518 simpleMarker->setAngle(
angle );
1519 simpleMarker->setVerticalAnchorPoint( vertAlign );
1523 simpleMarker->setFillColor( QColor( 0, 0, 0, 0 ) );
1524 simpleMarker->setStrokeStyle( Qt::NoPen );
1528 simpleMarker->setColor( color );
1529 simpleMarker->setStrokeColor( QColor( 0, 0, 0 ) );
1530 simpleMarker->setStrokeWidth( 0 );
1534 simpleMarker->setFillColor( QColor( 0, 0, 0, 0 ) );
1535 simpleMarker->setStrokeColor( color );
1541 std::unique_ptr< QgsSimpleMarkerSymbolLayer > shadow( simpleMarker->clone() );
1542 shadow->setColor( QColor( 0, 0, 0 ) );
1543 shadow->setLocked(
true );
1544 shadow->setOffset( shadowOffset );
1545 shadow->setOffsetUnit( sizeUnit );
1547 symbols << shadow.release();
1548 symbols << simpleMarker.release();
1552 if ( identifier == 51 )
1554 std::unique_ptr< QgsSimpleMarkerSymbolLayer > second( simpleMarker->clone() );
1555 second->setShape( QgsSimpleMarkerSymbolLayer::Shape::Cross2 );
1556 symbols << second.release();
1558 symbols << simpleMarker.release();
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
Context for a MapInfo symbol conversion operation.
void pushWarning(const QString &warning)
Pushes a warning message generated during the conversion.
static QgsFillSymbol * convertFillSymbol(int identifier, QgsMapInfoSymbolConversionContext &context, const QColor &foreColor, const QColor &backColor=QColor())
Converts the MapInfo fill symbol with the specified identifier to a QgsFillSymbol.
static QgsLineSymbol * convertLineSymbol(int identifier, QgsMapInfoSymbolConversionContext &context, const QColor &foreColor, double size, QgsUnitTypes::RenderUnit sizeUnit, bool interleaved=false)
Converts the MapInfo line symbol with the specified identifier to a QgsLineSymbol.
static QgsMarkerSymbol * convertMarkerSymbol(int identifier, QgsMapInfoSymbolConversionContext &context, const QColor &color, double size, QgsUnitTypes::RenderUnit sizeUnit)
Converts the MapInfo marker symbol with the specified identifier to a QgsMarkerSymbol.
VerticalAnchorPoint
Symbol vertical anchor points.
@ VCenter
Align to vertical center of symbol.
@ Top
Align to top of symbol.
A marker symbol type, for rendering Point and MultiPoint geometries.
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
void setCustomDashPatternUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for lengths used in the custom dash pattern.
void setUseCustomDashPattern(bool b)
Sets whether the line uses a custom dash pattern.
void setCustomDashVector(const QVector< qreal > &vector)
Sets the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ren...
QgsSimpleLineSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
static bool shapeIsFilled(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Returns true if a symbol shape has a fill.
Shape
Marker symbol shapes.
@ ArrowHead
Right facing arrow head (unfilled, lines only)
@ Octagon
Octagon (since QGIS 3.18)
@ Cross2
Rotated cross (lines only), "x" shape.
@ Cross
Cross (lines only)
@ EquilateralTriangle
Equilateral triangle.
@ SemiCircle
Semi circle (top half)
Placement
Defines how/where the templated symbol should be placed on the line.
@ LastVertex
Place symbols on the last vertex in the line.
@ FirstVertex
Place symbols on the first vertex in the line.
@ Interval
Place symbols at regular intervals.
RenderUnit
Rendering size units.
@ RenderPoints
Points (e.g., for font sizes)
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)
QList< QgsSymbolLayer * > QgsSymbolLayerList