Skip to content

Commit

Permalink
[symbology] Add a 1/2, 1/3, 1/4 arc signs to simple markers
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Mar 17, 2021
1 parent 09620ad commit b3d27aa
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Expand Up @@ -52,6 +52,9 @@ leaves the actual drawing of the symbols to subclasses.
Octagon,
SquareWithCorners,
AsteriskFill,
SemiArc,
ThirdArc,
QuarterArc,
};

static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes();
Expand Down
36 changes: 36 additions & 0 deletions src/core/symbology/qgsmarkersymbollayer.cpp
Expand Up @@ -75,6 +75,9 @@ QList<QgsSimpleMarkerSymbolLayerBase::Shape> QgsSimpleMarkerSymbolLayerBase::ava
<< CrossFill
<< Cross2
<< Line
<< SemiArc
<< ThirdArc
<< QuarterArc
<< ArrowHead
<< ArrowHeadFilled
<< SemiCircle
Expand Down Expand Up @@ -133,6 +136,9 @@ bool QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( QgsSimpleMarkerSymbolLayerBa
case Cross2:
case Line:
case ArrowHead:
case SemiArc:
case ThirdArc:
case QuarterArc:
return false;
}
return true;
Expand Down Expand Up @@ -356,6 +362,12 @@ QgsSimpleMarkerSymbolLayerBase::Shape QgsSimpleMarkerSymbolLayerBase::decodeShap
return LeftHalfTriangle;
else if ( cleaned == QLatin1String( "asterisk_fill" ) )
return AsteriskFill;
else if ( cleaned == QLatin1String( "semi_arc" ) )
return SemiArc;
else if ( cleaned == QLatin1String( "third_arc" ) )
return ThirdArc;
else if ( cleaned == QLatin1String( "quarter_arc" ) )
return QuarterArc;

if ( ok )
*ok = false;
Expand Down Expand Up @@ -418,6 +430,12 @@ QString QgsSimpleMarkerSymbolLayerBase::encodeShape( QgsSimpleMarkerSymbolLayerB
return QStringLiteral( "quarter_circle" );
case AsteriskFill:
return QStringLiteral( "asterisk_fill" );
case SemiArc:
return QStringLiteral( "semi_arc" );
case ThirdArc:
return QStringLiteral( "third_arc" );
case QuarterArc:
return QStringLiteral( "quarter_arc" );
}
return QString();
}
Expand Down Expand Up @@ -635,6 +653,9 @@ bool QgsSimpleMarkerSymbolLayerBase::shapeToPolygon( QgsSimpleMarkerSymbolLayerB
case SemiCircle:
case ThirdCircle:
case QuarterCircle:
case SemiArc:
case ThirdArc:
case QuarterArc:
return false;
}

Expand Down Expand Up @@ -667,6 +688,21 @@ bool QgsSimpleMarkerSymbolLayerBase::prepareMarkerPath( QgsSimpleMarkerSymbolLay
mPath.lineTo( 0, 0 );
return true;

case SemiArc:
mPath.moveTo( 1, 0 );
mPath.arcTo( -1, -1, 2, 2, 0, 180 );
return true;

case ThirdArc:
mPath.moveTo( 0, -1 );
mPath.arcTo( -1, -1, 2, 2, 90, 120 );
return true;

case QuarterArc:
mPath.moveTo( 0, -1 );
mPath.arcTo( -1, -1, 2, 2, 90, 90 );
return true;

case Cross:
mPath.moveTo( -1, 0 );
mPath.lineTo( 1, 0 ); // horizontal
Expand Down
3 changes: 3 additions & 0 deletions src/core/symbology/qgsmarkersymbollayer.h
Expand Up @@ -74,6 +74,9 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerBase : public QgsMarkerSymbolLayer
Octagon, //!< Octagon (since QGIS 3.18)
SquareWithCorners, //!< A square with diagonal corners (since QGIS 3.18)
AsteriskFill, //!< A filled asterisk shape (since QGIS 3.18)
SemiArc, //!< A line-only semi arc (since QGIS 3.20)
ThirdArc, //!< A line-only one third arc (since QGIS 3.20)
QuarterArc, //!< A line-only quarter arc (since QGIS 3.20)
};

//! Returns a list of all available shape types.
Expand Down

0 comments on commit b3d27aa

Please sign in to comment.