Skip to content

Commit 6568da6

Browse files
committed
Rename arrow symbol head width/height to length/thickness
Width/height naming is dependant on line direction, so for clarity rename them to something which doesn't depend on direction (fix #15002)
1 parent 09b6d58 commit 6568da6

File tree

7 files changed

+156
-146
lines changed

7 files changed

+156
-146
lines changed

python/core/symbology-ng/qgsarrowsymbollayer.sip

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/** \ingroup core
2+
* \class QgsArrowSymbolLayer
3+
* \brief Line symbol layer used for representing lines as arrows.
4+
* \note Added in version 2.16
5+
*/
6+
17
class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
28
{
39
%TypeHeaderCode
@@ -28,57 +34,57 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
2834
/** Return a list of attributes required to render this feature */
2935
virtual QSet<QString> usedAttributes() const;
3036

31-
/** Get current arrow width */
37+
/** Get current arrow width */
3238
double arrowWidth() const;
3339
/** Set the arrow width */
34-
void setArrowWidth( double w );
40+
void setArrowWidth( double width );
3541
/** Get the unit for the arrow width */
3642
QgsSymbolV2::OutputUnit arrowWidthUnit() const;
3743
/** Set the unit for the arrow width */
38-
void setArrowWidthUnit( QgsSymbolV2::OutputUnit u );
44+
void setArrowWidthUnit( QgsSymbolV2::OutputUnit unit );
3945
/** Get the scale for the arrow width */
4046
QgsMapUnitScale arrowWidthUnitScale() const;
4147
/** Set the scale for the arrow width */
42-
void setArrowWidthUnitScale( const QgsMapUnitScale& s );
48+
void setArrowWidthUnitScale( const QgsMapUnitScale& scale );
4349

4450
/** Get current arrow start width. Only meaningfull for single headed arrows */
4551
double arrowStartWidth() const;
4652
/** Set the arrow start width */
47-
void setArrowStartWidth( double w );
53+
void setArrowStartWidth( double width );
4854
/** Get the unit for the arrow start width */
4955
QgsSymbolV2::OutputUnit arrowStartWidthUnit() const;
5056
/** Set the unit for the arrow start width */
51-
void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit u );
57+
void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit unit );
5258
/** Get the scale for the arrow start width */
5359
QgsMapUnitScale arrowStartWidthUnitScale() const;
5460
/** Set the scale for the arrow start width */
55-
void setArrowStartWidthUnitScale( const QgsMapUnitScale& s );
56-
57-
/** Get the current arrow head width */
58-
double headWidth() const;
59-
/** Set the arrow head width */
60-
void setHeadWidth( double s );
61-
/** Get the unit for the head width */
62-
QgsSymbolV2::OutputUnit headWidthUnit() const;
63-
/** Set the unit for the head width */
64-
void setHeadWidthUnit( QgsSymbolV2::OutputUnit u );
65-
/** Get the scale for the head width */
66-
QgsMapUnitScale headWidthUnitScale() const;
67-
/** Set the scale for the head width */
68-
void setHeadWidthUnitScale( const QgsMapUnitScale& s );
61+
void setArrowStartWidthUnitScale( const QgsMapUnitScale& scale );
62+
63+
/** Get the current arrow head length */
64+
double headLength() const;
65+
/** Set the arrow head length */
66+
void setHeadLength( double length );
67+
/** Get the unit for the head length */
68+
QgsSymbolV2::OutputUnit headLengthUnit() const;
69+
/** Set the unit for the head length */
70+
void setHeadLengthUnit( QgsSymbolV2::OutputUnit unit );
71+
/** Get the scale for the head length */
72+
QgsMapUnitScale headLengthUnitScale() const;
73+
/** Set the scale for the head length */
74+
void setHeadLengthUnitScale( const QgsMapUnitScale& scale );
6975

7076
/** Get the current arrow head height */
71-
double headHeight() const;
77+
double headThickness() const;
7278
/** Set the arrow head height */
73-
void setHeadHeight( double s );
79+
void setHeadThickness( double thickness );
7480
/** Get the unit for the head height */
75-
QgsSymbolV2::OutputUnit headHeightUnit() const;
81+
QgsSymbolV2::OutputUnit headThicknessUnit() const;
7682
/** Set the unit for the head height */
77-
void setHeadHeightUnit( QgsSymbolV2::OutputUnit u );
83+
void setHeadThicknessUnit( QgsSymbolV2::OutputUnit unit );
7884
/** Get the scale for the head height */
79-
QgsMapUnitScale headHeightUnitScale() const;
85+
QgsMapUnitScale headThicknessUnitScale() const;
8086
/** Set the scale for the head height */
81-
void setHeadHeightUnitScale( const QgsMapUnitScale& s );
87+
void setHeadThicknessUnitScale( const QgsMapUnitScale& scale );
8288

8389
/** Return whether it is a curved arrow or a straight one */
8490
bool isCurved() const;
@@ -101,7 +107,7 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
101107
/** Get the current head type */
102108
HeadType headType() const;
103109
/** Set the head type */
104-
void setHeadType( HeadType t );
110+
void setHeadType( HeadType type );
105111

106112
/** Possible arrow types */
107113
enum ArrowType
@@ -114,7 +120,7 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
114120
/** Get the current arrow type */
115121
ArrowType arrowType() const;
116122
/** Set the arrow type */
117-
void setArrowType( ArrowType t );
123+
void setArrowType( ArrowType type );
118124

119125
/**
120126
* Should be reimplemented by subclasses to return a string map that

src/core/symbology-ng/qgsarrowsymbollayer.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ QgsArrowSymbolLayer::QgsArrowSymbolLayer()
2121
, mArrowWidthUnit( QgsSymbolV2::MM )
2222
, mArrowStartWidth( 1.0 )
2323
, mArrowStartWidthUnit( QgsSymbolV2::MM )
24-
, mHeadWidth( 1.5 )
25-
, mHeadWidthUnit( QgsSymbolV2::MM )
26-
, mHeadHeight( 1.5 )
27-
, mHeadHeightUnit( QgsSymbolV2::MM )
24+
, mHeadLength( 1.5 )
25+
, mHeadLengthUnit( QgsSymbolV2::MM )
26+
, mHeadThickness( 1.5 )
27+
, mHeadThicknessUnit( QgsSymbolV2::MM )
2828
, mHeadType( HeadSingle )
2929
, mArrowType( ArrowPlain )
3030
, mIsCurved( true )
3131
, mIsRepeated( true )
3232
, mScaledArrowWidth( 1.0 )
3333
, mScaledArrowStartWidth( 1.0 )
34-
, mScaledHeadWidth( 1.5 )
35-
, mScaledHeadHeight( 1.5 )
34+
, mScaledHeadLength( 1.5 )
35+
, mScaledHeadThickness( 1.5 )
3636
, mScaledOffset( 0.0 )
3737
, mComputedHeadType( HeadSingle )
3838
, mComputedArrowType( ArrowPlain )
@@ -83,23 +83,23 @@ QgsSymbolLayerV2* QgsArrowSymbolLayer::create( const QgsStringMap& props )
8383
if ( props.contains( "is_repeated" ) )
8484
l->setIsRepeated( props["is_repeated"].toInt() == 1 );
8585

86-
if ( props.contains( "head_width" ) )
87-
l->setHeadWidth( props["head_width"].toDouble() );
86+
if ( props.contains( "head_length" ) )
87+
l->setHeadLength( props["head_length"].toDouble() );
8888

89-
if ( props.contains( "head_width_unit" ) )
90-
l->setHeadWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_width_unit"] ) );
89+
if ( props.contains( "head_length_unit" ) )
90+
l->setHeadLengthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_length_unit"] ) );
9191

92-
if ( props.contains( "head_width_unit_scale" ) )
93-
l->setHeadWidthUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_width_unit_scale"] ) );
92+
if ( props.contains( "head_length_unit_scale" ) )
93+
l->setHeadLengthUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_length_unit_scale"] ) );
9494

95-
if ( props.contains( "head_height" ) )
96-
l->setHeadHeight( props["head_height"].toDouble() );
95+
if ( props.contains( "head_thickness" ) )
96+
l->setHeadThickness( props["head_thickness"].toDouble() );
9797

98-
if ( props.contains( "head_height_unit" ) )
99-
l->setHeadHeightUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_height_unit"] ) );
98+
if ( props.contains( "head_thickness_unit" ) )
99+
l->setHeadThicknessUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_thickness_unit"] ) );
100100

101-
if ( props.contains( "head_height_unit_scale" ) )
102-
l->setHeadHeightUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_height_unit_scale"] ) );
101+
if ( props.contains( "head_thickness_unit_scale" ) )
102+
l->setHeadThicknessUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_thickness_unit_scale"] ) );
103103

104104
if ( props.contains( "head_type" ) )
105105
l->setHeadType( static_cast<HeadType>( props["head_type"].toInt() ) );
@@ -152,13 +152,13 @@ QgsStringMap QgsArrowSymbolLayer::properties() const
152152
map["is_curved"] = QString::number( isCurved() ? 1 : 0 );
153153
map["is_repeated"] = QString::number( isRepeated() ? 1 : 0 );
154154

155-
map["head_width"] = QString::number( headWidth() );
156-
map["head_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headWidthUnit() );
157-
map["head_width_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headWidthUnitScale() );
155+
map["head_length"] = QString::number( headLength() );
156+
map["head_length_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headLengthUnit() );
157+
map["head_length_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headLengthUnitScale() );
158158

159-
map["head_height"] = QString::number( headHeight() );
160-
map["head_height_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headHeightUnit() );
161-
map["head_height_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headHeightUnitScale() );
159+
map["head_thickness"] = QString::number( headThickness() );
160+
map["head_thickness_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headThicknessUnit() );
161+
map["head_thickness_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headThicknessUnitScale() );
162162

163163
map["head_type"] = QString::number( headType() );
164164
map["arrow_type"] = QString::number( arrowType() );
@@ -186,8 +186,8 @@ void QgsArrowSymbolLayer::startRender( QgsSymbolV2RenderContext& context )
186186
mExpressionScope.reset( new QgsExpressionContextScope() );
187187
mScaledArrowWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), arrowWidth(), arrowWidthUnit(), arrowWidthUnitScale() );
188188
mScaledArrowStartWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), arrowStartWidth(), arrowStartWidthUnit(), arrowStartWidthUnitScale() );
189-
mScaledHeadWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), headWidth(), headWidthUnit(), headWidthUnitScale() );
190-
mScaledHeadHeight = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), headHeight(), headHeightUnit(), headHeightUnitScale() );
189+
mScaledHeadLength = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), headLength(), headLengthUnit(), headLengthUnitScale() );
190+
mScaledHeadThickness = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), headThickness(), headThicknessUnit(), headThicknessUnitScale() );
191191
mScaledOffset = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), offset(), offsetUnit(), offsetMapUnitScale() );
192192
mComputedHeadType = headType();
193193
mComputedArrowType = arrowType();
@@ -632,22 +632,22 @@ void QgsArrowSymbolLayer::_resolveDataDefined( QgsSymbolV2RenderContext& context
632632
mScaledArrowStartWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, arrowStartWidthUnit(), arrowStartWidthUnitScale() );
633633
}
634634
}
635-
if ( hasDataDefinedProperty( "head_width" ) )
635+
if ( hasDataDefinedProperty( "head_length" ) )
636636
{
637-
context.setOriginalValueVariable( headWidth() );
638-
double w = evaluateDataDefinedProperty( "head_width", context, QVariant(), &ok ).toDouble();
637+
context.setOriginalValueVariable( headLength() );
638+
double w = evaluateDataDefinedProperty( "head_length", context, QVariant(), &ok ).toDouble();
639639
if ( ok )
640640
{
641-
mScaledHeadWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, headWidthUnit(), headWidthUnitScale() );
641+
mScaledHeadLength = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, headLengthUnit(), headLengthUnitScale() );
642642
}
643643
}
644-
if ( hasDataDefinedProperty( "head_height" ) )
644+
if ( hasDataDefinedProperty( "head_thickness" ) )
645645
{
646-
context.setOriginalValueVariable( headHeight() );
647-
double w = evaluateDataDefinedProperty( "head_height", context, QVariant(), &ok ).toDouble();
646+
context.setOriginalValueVariable( headThickness() );
647+
double w = evaluateDataDefinedProperty( "head_thickness", context, QVariant(), &ok ).toDouble();
648648
if ( ok )
649649
{
650-
mScaledHeadHeight = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, headHeightUnit(), headHeightUnitScale() );
650+
mScaledHeadThickness = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, headThicknessUnit(), headThicknessUnitScale() );
651651
}
652652
}
653653
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OFFSET ) )
@@ -708,7 +708,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re
708708
// destination point
709709
QPointF pd( points.back() );
710710

711-
QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
711+
QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
712712
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
713713
}
714714
// straight arrow
@@ -719,7 +719,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re
719719
// destination point
720720
QPointF pd( points.at( 1 ) );
721721

722-
QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
722+
QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
723723
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
724724
}
725725
}
@@ -739,7 +739,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re
739739
// destination point
740740
QPointF pd( points.at( pIdx + 2 ) );
741741

742-
QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
742+
QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
743743
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
744744
}
745745
// straight arrow
@@ -750,7 +750,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re
750750
// destination point
751751
QPointF pd( points.at( pIdx + 1 ) );
752752

753-
QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
753+
QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
754754
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
755755
}
756756
}
@@ -769,7 +769,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re
769769
// destination point
770770
QPointF pd( points.back() );
771771

772-
QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
772+
QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
773773
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
774774
}
775775
}
@@ -786,7 +786,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re
786786
// destination point
787787
QPointF pd( points.at( pIdx + 1 ) );
788788

789-
QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
789+
QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
790790
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
791791
}
792792
}

0 commit comments

Comments
 (0)