Skip to content

Commit f7c5c2b

Browse files
committed
Merge pull request #2976 from nirvn/more_markers
[symbology] add half triangle markers
2 parents 9c0a291 + 7b233e5 commit f7c5c2b

7 files changed

+36
-6
lines changed

python/core/symbology-ng/qgsmarkersymbollayerv2.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class QgsSimpleMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
1111
* "pentagon", "triangle", "equilateral_triangle", "star", "regular_star", "arrow",
1212
* "circle", "cross", "cross2", "line", "x", "arrowhead", "filled_arrowhead",
1313
* "semi_circle", "third_circle", "quarter_circle", "quarter_square", "half_square",
14-
* "diagonal_half_square"
14+
* "diagonal_half_square", "right_half_triangle", "left_half_triangle"
1515
* @param color fill color for symbol
1616
* @param borderColor border color for symbol
1717
* @param size symbol size (in mm)

src/core/symbology-ng/qgsellipsesymbollayerv2.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,11 @@ void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV
565565
{
566566
mPainterPath.addEllipse( QRectF( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height() ) );
567567
}
568+
else if ( symbolName == "semi_circle" )
569+
{
570+
mPainterPath.arcTo( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height(), 0, 180 );
571+
mPainterPath.lineTo( 0, 0 );
572+
}
568573
else if ( symbolName == "rectangle" )
569574
{
570575
mPainterPath.addRect( QRectF( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height() ) );
@@ -583,6 +588,20 @@ void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV
583588
mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 );
584589
mPainterPath.lineTo( 0, -size.height() / 2.0 );
585590
}
591+
else if ( symbolName == "left_half_triangle" )
592+
{
593+
mPainterPath.moveTo( 0, size.height() / 2.0 );
594+
mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 );
595+
mPainterPath.lineTo( 0, -size.height() / 2.0 );
596+
mPainterPath.lineTo( 0, size.height() / 2.0 );
597+
}
598+
else if ( symbolName == "right_half_triangle" )
599+
{
600+
mPainterPath.moveTo( -size.width() / 2.0, size.height() / 2.0 );
601+
mPainterPath.lineTo( 0, size.height() / 2.0 );
602+
mPainterPath.lineTo( 0, -size.height() / 2.0 );
603+
mPainterPath.lineTo( -size.width() / 2.0, size.height() / 2.0 );
604+
}
586605
}
587606

588607
void QgsEllipseSymbolLayerV2::setOutputUnit( QgsSymbolV2::OutputUnit unit )

src/core/symbology-ng/qgsmarkersymbollayerv2.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,16 @@ bool QgsSimpleMarkerSymbolLayerV2::prepareShape( const QString& name, QPolygonF
384384
<< QPointF( 0, -1 );
385385
return true;
386386
}
387+
else if ( name == "left_half_triangle" )
388+
{
389+
polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 );
390+
return true;
391+
}
392+
else if ( name == "right_half_triangle" )
393+
{
394+
polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 );
395+
return true;
396+
}
387397
else if ( name == "star" )
388398
{
389399
double sixth = 1.0 / 3;

src/core/symbology-ng/qgsmarkersymbollayerv2.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
4141
* "pentagon", "triangle", "equilateral_triangle", "star", "regular_star", "arrow",
4242
* "circle", "cross", "cross2", "line", "x", "arrowhead", "filled_arrowhead",
4343
* "semi_circle", "third_circle", "quarter_circle", "quarter_square", "half_square",
44-
* "diagonal_half_square"
44+
* "diagonal_half_square", "right_half_triangle", "left_half_triangle"
4545
* @param color fill color for symbol
4646
* @param borderColor border color for symbol
4747
* @param size symbol size (in mm)

src/gui/qgsdatadefinedbutton.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,8 @@ QString QgsDataDefinedButton::fillStyleDesc()
904904

905905
QString QgsDataDefinedButton::markerStyleDesc()
906906
{
907-
return trString() + QLatin1String( "[<b>circle</b>|<b>rectangle</b>|<b>cross</b>|<b>triangle</b>]" );
907+
return trString() + QLatin1String( "[<b>circle</b>|<b>rectangle</b>|<b>cross</b>|<b>triangle"
908+
"</b>|<b>right_half_triangle</b>|<b>left_half_triangle</b>|<b>semi_circle</b>]" );
908909
}
909910

910911
QString QgsDataDefinedButton::customDashDesc()

src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ QgsEllipseSymbolLayerV2Widget::QgsEllipseSymbolLayerV2Widget( const QgsVectorLay
4646
mRotationSpinBox->setClearValue( 0.0 );
4747

4848
QStringList names;
49-
names << "circle" << "rectangle" << "cross" << "triangle";
49+
names << "circle" << "rectangle" << "cross" << "triangle" << "right_half_triangle" << "left_half_triangle" << "semi_circle";
5050
QSize iconSize = mShapeListWidget->iconSize();
5151

5252
Q_FOREACH ( const QString& name, names )

src/gui/symbology-ng/qgssymbollayerv2widget.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget( const Qg
442442
QStringList names;
443443
names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle" << "equilateral_triangle" << "star"
444444
<< "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead" << "semi_circle" << "third_circle" << "quarter_circle"
445-
<< "quarter_square" << "half_square" << "diagonal_half_square";
445+
<< "quarter_square" << "half_square" << "diagonal_half_square" << "right_half_triangle" << "left_half_triangle";
446446
double markerSize = DEFAULT_POINT_SIZE * 2;
447447
Q_FOREACH ( const QString& name, names )
448448
{
@@ -544,7 +544,7 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer
544544
"<b>star</b>|<b>regular_star</b>|<b>arrow</b>|<b>filled_arrowhead</b>|"
545545
"<b>circle</b>|<b>cross</b>|<b>x</b>|"
546546
"<b>cross2</b>|<b>line</b>|<b>arrowhead</b>|<b>semi_circle</b>|<b>third_circle</b>|<b>quarter_circle</b>|"
547-
"<b>quarter_square</b>|<b>half_square</b>|<b>diagonal_half_square</b>]" ) );
547+
"<b>quarter_square</b>|<b>half_square</b>|<b>diagonal_half_square</b>|<b>right_half_triangle</b>|<b>left_half_triangle</b>]" ) );
548548
registerDataDefinedButton( mFillColorDDBtn, "color", QgsDataDefinedButton::String, QgsDataDefinedButton::colorAlphaDesc() );
549549
registerDataDefinedButton( mBorderColorDDBtn, "color_border", QgsDataDefinedButton::String, QgsDataDefinedButton::colorAlphaDesc() );
550550
registerDataDefinedButton( mOutlineWidthDDBtn, "outline_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );

0 commit comments

Comments
 (0)