Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #42291 from nirvn/add_markers
Add semi arc sign simple & ellipse markers, add missing arrow sign to ellispe marker
- Loading branch information
|
@@ -51,6 +51,17 @@ Creates the symbol layer |
|
|
void setSymbolName( const QString &name ); |
|
|
QString symbolName() const; |
|
|
|
|
|
bool shapeIsFilled( const QString &symbolName ) const; |
|
|
%Docstring |
|
|
Returns ``True`` if a shape has a fill. |
|
|
|
|
|
:param symbolName: name of shape to test |
|
|
|
|
|
:return: ``True`` if shape uses a fill, or ``False`` if shape uses lines only |
|
|
|
|
|
.. versionadded:: 3.20 |
|
|
%End |
|
|
|
|
|
virtual void setSize( double size ); |
|
|
|
|
|
|
|
|
|
@@ -52,6 +52,9 @@ leaves the actual drawing of the symbols to subclasses. |
|
|
Octagon, |
|
|
SquareWithCorners, |
|
|
AsteriskFill, |
|
|
HalfArc, |
|
|
ThirdArc, |
|
|
QuarterArc, |
|
|
}; |
|
|
|
|
|
static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes(); |
|
|
|
@@ -280,8 +280,16 @@ void QgsEllipseSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContext & |
|
|
transform.rotate( angle ); |
|
|
} |
|
|
|
|
|
p->setPen( context.selected() ? mSelPen : mPen ); |
|
|
p->setBrush( context.selected() ? mSelBrush : mBrush ); |
|
|
if ( shapeIsFilled( mSymbolName ) ) |
|
|
{ |
|
|
p->setPen( context.selected() ? mSelPen : mPen ); |
|
|
p->setBrush( context.selected() ? mSelBrush : mBrush ); |
|
|
} |
|
|
else |
|
|
{ |
|
|
p->setPen( context.selected() ? mSelPen : mPen ); |
|
|
p->setBrush( QBrush() ); |
|
|
} |
|
|
p->drawPath( transform.map( mPainterPath ) ); |
|
|
} |
|
|
|
|
@@ -627,6 +635,17 @@ void QgsEllipseSymbolLayer::preparePath( const QString &symbolName, QgsSymbolRen |
|
|
mPainterPath.moveTo( -size.width() / 2.0, 0 ); |
|
|
mPainterPath.lineTo( size.width() / 2.0, 0 ); |
|
|
} |
|
|
else if ( symbolName == QLatin1String( "arrow" ) ) |
|
|
{ |
|
|
mPainterPath.moveTo( -size.width() / 2.0, size.height() / 2.0 ); |
|
|
mPainterPath.lineTo( 0, -size.height() / 2.0 ); |
|
|
mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 ); |
|
|
} |
|
|
else if ( symbolName == QLatin1String( "half_arc" ) ) |
|
|
{ |
|
|
mPainterPath.moveTo( size.width() / 2.0, 0 ); |
|
|
mPainterPath.arcTo( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height(), 0, 180 ); |
|
|
} |
|
|
else if ( symbolName == QLatin1String( "triangle" ) ) |
|
|
{ |
|
|
mPainterPath.moveTo( 0, -size.height() / 2.0 ); |
|
@@ -650,6 +669,11 @@ void QgsEllipseSymbolLayer::preparePath( const QString &symbolName, QgsSymbolRen |
|
|
} |
|
|
} |
|
|
|
|
|
bool QgsEllipseSymbolLayer::shapeIsFilled( const QString &symbolName ) const |
|
|
{ |
|
|
return symbolName == QLatin1String( "cross" ) || symbolName == QLatin1String( "arrow" ) || symbolName == QLatin1String( "half_arc" ) ? false : true; |
|
|
} |
|
|
|
|
|
void QgsEllipseSymbolLayer::setSize( double size ) |
|
|
{ |
|
|
if ( mSymbolWidth >= mSymbolHeight ) |
|
|
|
@@ -52,6 +52,14 @@ class CORE_EXPORT QgsEllipseSymbolLayer: public QgsMarkerSymbolLayer |
|
|
void setSymbolName( const QString &name ) { mSymbolName = name; } |
|
|
QString symbolName() const { return mSymbolName; } |
|
|
|
|
|
/** |
|
|
* Returns TRUE if a shape has a fill. |
|
|
* \param symbolName name of shape to test |
|
|
* \returns TRUE if shape uses a fill, or FALSE if shape uses lines only |
|
|
* \since QGIS 3.20 |
|
|
*/ |
|
|
bool shapeIsFilled( const QString &symbolName ) const; |
|
|
|
|
|
void setSize( double size ) override; |
|
|
|
|
|
void setSymbolWidth( double w ); |
|
|
|
@@ -75,6 +75,9 @@ QList<QgsSimpleMarkerSymbolLayerBase::Shape> QgsSimpleMarkerSymbolLayerBase::ava |
|
|
<< CrossFill |
|
|
<< Cross2 |
|
|
<< Line |
|
|
<< HalfArc |
|
|
<< ThirdArc |
|
|
<< QuarterArc |
|
|
<< ArrowHead |
|
|
<< ArrowHeadFilled |
|
|
<< SemiCircle |
|
@@ -133,6 +136,9 @@ bool QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( QgsSimpleMarkerSymbolLayerBa |
|
|
case Cross2: |
|
|
case Line: |
|
|
case ArrowHead: |
|
|
case HalfArc: |
|
|
case ThirdArc: |
|
|
case QuarterArc: |
|
|
return false; |
|
|
} |
|
|
return true; |
|
@@ -356,6 +362,12 @@ QgsSimpleMarkerSymbolLayerBase::Shape QgsSimpleMarkerSymbolLayerBase::decodeShap |
|
|
return LeftHalfTriangle; |
|
|
else if ( cleaned == QLatin1String( "asterisk_fill" ) ) |
|
|
return AsteriskFill; |
|
|
else if ( cleaned == QLatin1String( "half_arc" ) ) |
|
|
return HalfArc; |
|
|
else if ( cleaned == QLatin1String( "third_arc" ) ) |
|
|
return ThirdArc; |
|
|
else if ( cleaned == QLatin1String( "quarter_arc" ) ) |
|
|
return QuarterArc; |
|
|
|
|
|
if ( ok ) |
|
|
*ok = false; |
|
@@ -418,6 +430,12 @@ QString QgsSimpleMarkerSymbolLayerBase::encodeShape( QgsSimpleMarkerSymbolLayerB |
|
|
return QStringLiteral( "quarter_circle" ); |
|
|
case AsteriskFill: |
|
|
return QStringLiteral( "asterisk_fill" ); |
|
|
case HalfArc: |
|
|
return QStringLiteral( "half_arc" ); |
|
|
case ThirdArc: |
|
|
return QStringLiteral( "third_arc" ); |
|
|
case QuarterArc: |
|
|
return QStringLiteral( "quarter_arc" ); |
|
|
} |
|
|
return QString(); |
|
|
} |
|
@@ -635,6 +653,9 @@ bool QgsSimpleMarkerSymbolLayerBase::shapeToPolygon( QgsSimpleMarkerSymbolLayerB |
|
|
case SemiCircle: |
|
|
case ThirdCircle: |
|
|
case QuarterCircle: |
|
|
case HalfArc: |
|
|
case ThirdArc: |
|
|
case QuarterArc: |
|
|
return false; |
|
|
} |
|
|
|
|
@@ -667,6 +688,21 @@ bool QgsSimpleMarkerSymbolLayerBase::prepareMarkerPath( QgsSimpleMarkerSymbolLay |
|
|
mPath.lineTo( 0, 0 ); |
|
|
return true; |
|
|
|
|
|
case HalfArc: |
|
|
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 |
|
|
|
@@ -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) |
|
|
HalfArc, //!< A line-only half arc (since QGIS 3.20) |
|
|
ThirdArc, //!< A line-only one third arc (since QGIS 3.20) |
|
|
QuarterArc, //!< A line-only one quarter arc (since QGIS 3.20) |
|
|
}; |
|
|
|
|
|
//! Returns a list of all available shape types. |
|
|
|
@@ -66,7 +66,7 @@ QgsEllipseSymbolLayerWidget::QgsEllipseSymbolLayerWidget( QgsVectorLayer *vl, QW |
|
|
mRotationSpinBox->setClearValue( 0.0 ); |
|
|
|
|
|
QStringList names; |
|
|
names << QStringLiteral( "circle" ) << QStringLiteral( "rectangle" ) << QStringLiteral( "diamond" ) << QStringLiteral( "cross" ) << QStringLiteral( "triangle" ) << QStringLiteral( "right_half_triangle" ) << QStringLiteral( "left_half_triangle" ) << QStringLiteral( "semi_circle" ); |
|
|
names << QStringLiteral( "circle" ) << QStringLiteral( "rectangle" ) << QStringLiteral( "diamond" ) << QStringLiteral( "cross" ) << QStringLiteral( "arrow" ) << QStringLiteral( "half_arc" ) << QStringLiteral( "triangle" ) << QStringLiteral( "right_half_triangle" ) << QStringLiteral( "left_half_triangle" ) << QStringLiteral( "semi_circle" ); |
|
|
|
|
|
int size = mShapeListWidget->iconSize().width(); |
|
|
size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) ); |
|
|