Skip to content

Commit

Permalink
Merge pull request #2976 from nirvn/more_markers
Browse files Browse the repository at this point in the history
[symbology] add half triangle markers
  • Loading branch information
nyalldawson committed Apr 5, 2016
2 parents 9c0a291 + 7b233e5 commit f7c5c2b
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/core/symbology-ng/qgsmarkersymbollayerv2.sip
Expand Up @@ -11,7 +11,7 @@ class QgsSimpleMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
* "pentagon", "triangle", "equilateral_triangle", "star", "regular_star", "arrow",
* "circle", "cross", "cross2", "line", "x", "arrowhead", "filled_arrowhead",
* "semi_circle", "third_circle", "quarter_circle", "quarter_square", "half_square",
* "diagonal_half_square"
* "diagonal_half_square", "right_half_triangle", "left_half_triangle"
* @param color fill color for symbol
* @param borderColor border color for symbol
* @param size symbol size (in mm)
Expand Down
19 changes: 19 additions & 0 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Expand Up @@ -565,6 +565,11 @@ void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV
{
mPainterPath.addEllipse( QRectF( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height() ) );
}
else if ( symbolName == "semi_circle" )
{
mPainterPath.arcTo( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height(), 0, 180 );
mPainterPath.lineTo( 0, 0 );
}
else if ( symbolName == "rectangle" )
{
mPainterPath.addRect( QRectF( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height() ) );
Expand All @@ -583,6 +588,20 @@ void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV
mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 );
mPainterPath.lineTo( 0, -size.height() / 2.0 );
}
else if ( symbolName == "left_half_triangle" )
{
mPainterPath.moveTo( 0, size.height() / 2.0 );
mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 );
mPainterPath.lineTo( 0, -size.height() / 2.0 );
mPainterPath.lineTo( 0, size.height() / 2.0 );
}
else if ( symbolName == "right_half_triangle" )
{
mPainterPath.moveTo( -size.width() / 2.0, size.height() / 2.0 );
mPainterPath.lineTo( 0, size.height() / 2.0 );
mPainterPath.lineTo( 0, -size.height() / 2.0 );
mPainterPath.lineTo( -size.width() / 2.0, size.height() / 2.0 );
}
}

void QgsEllipseSymbolLayerV2::setOutputUnit( QgsSymbolV2::OutputUnit unit )
Expand Down
10 changes: 10 additions & 0 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Expand Up @@ -384,6 +384,16 @@ bool QgsSimpleMarkerSymbolLayerV2::prepareShape( const QString& name, QPolygonF
<< QPointF( 0, -1 );
return true;
}
else if ( name == "left_half_triangle" )
{
polygon << QPointF( 0, 1 ) << QPointF( 1, 1 ) << QPointF( 0, -1 );
return true;
}
else if ( name == "right_half_triangle" )
{
polygon << QPointF( -1, 1 ) << QPointF( 0, 1 ) << QPointF( 0, -1 );
return true;
}
else if ( name == "star" )
{
double sixth = 1.0 / 3;
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsmarkersymbollayerv2.h
Expand Up @@ -41,7 +41,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
* "pentagon", "triangle", "equilateral_triangle", "star", "regular_star", "arrow",
* "circle", "cross", "cross2", "line", "x", "arrowhead", "filled_arrowhead",
* "semi_circle", "third_circle", "quarter_circle", "quarter_square", "half_square",
* "diagonal_half_square"
* "diagonal_half_square", "right_half_triangle", "left_half_triangle"
* @param color fill color for symbol
* @param borderColor border color for symbol
* @param size symbol size (in mm)
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgsdatadefinedbutton.cpp
Expand Up @@ -904,7 +904,8 @@ QString QgsDataDefinedButton::fillStyleDesc()

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

QString QgsDataDefinedButton::customDashDesc()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp
Expand Up @@ -46,7 +46,7 @@ QgsEllipseSymbolLayerV2Widget::QgsEllipseSymbolLayerV2Widget( const QgsVectorLay
mRotationSpinBox->setClearValue( 0.0 );

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

Q_FOREACH ( const QString& name, names )
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgssymbollayerv2widget.cpp
Expand Up @@ -442,7 +442,7 @@ QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget( const Qg
QStringList names;
names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle" << "equilateral_triangle" << "star"
<< "regular_star" << "arrow" << "line" << "arrowhead" << "filled_arrowhead" << "semi_circle" << "third_circle" << "quarter_circle"
<< "quarter_square" << "half_square" << "diagonal_half_square";
<< "quarter_square" << "half_square" << "diagonal_half_square" << "right_half_triangle" << "left_half_triangle";
double markerSize = DEFAULT_POINT_SIZE * 2;
Q_FOREACH ( const QString& name, names )
{
Expand Down Expand Up @@ -544,7 +544,7 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer
"<b>star</b>|<b>regular_star</b>|<b>arrow</b>|<b>filled_arrowhead</b>|"
"<b>circle</b>|<b>cross</b>|<b>x</b>|"
"<b>cross2</b>|<b>line</b>|<b>arrowhead</b>|<b>semi_circle</b>|<b>third_circle</b>|<b>quarter_circle</b>|"
"<b>quarter_square</b>|<b>half_square</b>|<b>diagonal_half_square</b>]" ) );
"<b>quarter_square</b>|<b>half_square</b>|<b>diagonal_half_square</b>|<b>right_half_triangle</b>|<b>left_half_triangle</b>]" ) );
registerDataDefinedButton( mFillColorDDBtn, "color", QgsDataDefinedButton::String, QgsDataDefinedButton::colorAlphaDesc() );
registerDataDefinedButton( mBorderColorDDBtn, "color_border", QgsDataDefinedButton::String, QgsDataDefinedButton::colorAlphaDesc() );
registerDataDefinedButton( mOutlineWidthDDBtn, "outline_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
Expand Down

0 comments on commit f7c5c2b

Please sign in to comment.