Skip to content

Commit 6568da6

Browse files
committedJun 14, 2016
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
}

‎src/core/symbology-ng/qgsarrowsymbollayer.h

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818

1919
#include "qgssymbollayerv2.h"
2020

21-
/**
22-
* This class is used for representing lines as arrows.
21+
22+
/** \ingroup core
23+
* \class QgsArrowSymbolLayer
24+
* \brief Line symbol layer used for representing lines as arrows.
25+
* \note Added in version 2.16
2326
*/
27+
2428
class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
2529
{
2630
public:
@@ -51,54 +55,54 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
5155
/** Get current arrow width */
5256
double arrowWidth() const { return mArrowWidth; }
5357
/** Set the arrow width */
54-
void setArrowWidth( double w ) { mArrowWidth = w; }
58+
void setArrowWidth( double width ) { mArrowWidth = width; }
5559
/** Get the unit for the arrow width */
5660
QgsSymbolV2::OutputUnit arrowWidthUnit() const { return mArrowWidthUnit; }
5761
/** Set the unit for the arrow width */
58-
void setArrowWidthUnit( QgsSymbolV2::OutputUnit u ) { mArrowWidthUnit = u; }
62+
void setArrowWidthUnit( QgsSymbolV2::OutputUnit unit ) { mArrowWidthUnit = unit; }
5963
/** Get the scale for the arrow width */
6064
QgsMapUnitScale arrowWidthUnitScale() const { return mArrowWidthUnitScale; }
6165
/** Set the scale for the arrow width */
62-
void setArrowWidthUnitScale( const QgsMapUnitScale& s ) { mArrowWidthUnitScale = s; }
66+
void setArrowWidthUnitScale( const QgsMapUnitScale& scale ) { mArrowWidthUnitScale = scale; }
6367

6468
/** Get current arrow start width. Only meaningfull for single headed arrows */
6569
double arrowStartWidth() const { return mArrowStartWidth; }
6670
/** Set the arrow start width */
67-
void setArrowStartWidth( double w ) { mArrowStartWidth = w; }
71+
void setArrowStartWidth( double width ) { mArrowStartWidth = width; }
6872
/** Get the unit for the arrow start width */
6973
QgsSymbolV2::OutputUnit arrowStartWidthUnit() const { return mArrowStartWidthUnit; }
7074
/** Set the unit for the arrow start width */
71-
void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit u ) { mArrowStartWidthUnit = u; }
75+
void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit unit ) { mArrowStartWidthUnit = unit; }
7276
/** Get the scale for the arrow start width */
7377
QgsMapUnitScale arrowStartWidthUnitScale() const { return mArrowStartWidthUnitScale; }
7478
/** Set the scale for the arrow start width */
75-
void setArrowStartWidthUnitScale( const QgsMapUnitScale& s ) { mArrowStartWidthUnitScale = s; }
76-
77-
/** Get the current arrow head width */
78-
double headWidth() const { return mHeadWidth; }
79-
/** Set the arrow head width */
80-
void setHeadWidth( double s ) { mHeadWidth = s; }
81-
/** Get the unit for the head width */
82-
QgsSymbolV2::OutputUnit headWidthUnit() const { return mHeadWidthUnit; }
83-
/** Set the unit for the head width */
84-
void setHeadWidthUnit( QgsSymbolV2::OutputUnit u ) { mHeadWidthUnit = u; }
85-
/** Get the scale for the head width */
86-
QgsMapUnitScale headWidthUnitScale() const { return mHeadWidthUnitScale; }
87-
/** Set the scale for the head width */
88-
void setHeadWidthUnitScale( const QgsMapUnitScale& s ) { mHeadWidthUnitScale = s; }
79+
void setArrowStartWidthUnitScale( const QgsMapUnitScale& scale ) { mArrowStartWidthUnitScale = scale; }
80+
81+
/** Get the current arrow head length */
82+
double headLength() const { return mHeadLength; }
83+
/** Set the arrow head length */
84+
void setHeadLength( double length ) { mHeadLength = length; }
85+
/** Get the unit for the head length */
86+
QgsSymbolV2::OutputUnit headLengthUnit() const { return mHeadLengthUnit; }
87+
/** Set the unit for the head length */
88+
void setHeadLengthUnit( QgsSymbolV2::OutputUnit unit ) { mHeadLengthUnit = unit; }
89+
/** Get the scale for the head length */
90+
QgsMapUnitScale headLengthUnitScale() const { return mHeadLengthUnitScale; }
91+
/** Set the scale for the head length */
92+
void setHeadLengthUnitScale( const QgsMapUnitScale& scale ) { mHeadLengthUnitScale = scale; }
8993

9094
/** Get the current arrow head height */
91-
double headHeight() const { return mHeadHeight; }
95+
double headThickness() const { return mHeadThickness; }
9296
/** Set the arrow head height */
93-
void setHeadHeight( double s ) { mHeadHeight = s; }
97+
void setHeadThickness( double thickness ) { mHeadThickness = thickness; }
9498
/** Get the unit for the head height */
95-
QgsSymbolV2::OutputUnit headHeightUnit() const { return mHeadHeightUnit; }
99+
QgsSymbolV2::OutputUnit headThicknessUnit() const { return mHeadThicknessUnit; }
96100
/** Set the unit for the head height */
97-
void setHeadHeightUnit( QgsSymbolV2::OutputUnit u ) { mHeadHeightUnit = u; }
101+
void setHeadThicknessUnit( QgsSymbolV2::OutputUnit unit ) { mHeadThicknessUnit = unit; }
98102
/** Get the scale for the head height */
99-
QgsMapUnitScale headHeightUnitScale() const { return mHeadHeightUnitScale; }
103+
QgsMapUnitScale headThicknessUnitScale() const { return mHeadThicknessUnitScale; }
100104
/** Set the scale for the head height */
101-
void setHeadHeightUnitScale( const QgsMapUnitScale& s ) { mHeadHeightUnitScale = s; }
105+
void setHeadThicknessUnitScale( const QgsMapUnitScale& scale ) { mHeadThicknessUnitScale = scale; }
102106

103107
/** Return whether it is a curved arrow or a straight one */
104108
bool isCurved() const { return mIsCurved; }
@@ -121,7 +125,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
121125
/** Get the current head type */
122126
HeadType headType() const { return mHeadType; }
123127
/** Set the head type */
124-
void setHeadType( HeadType t ) { mHeadType = t; }
128+
void setHeadType( HeadType type ) { mHeadType = type; }
125129

126130
/** Possible arrow types */
127131
enum ArrowType
@@ -134,7 +138,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
134138
/** Get the current arrow type */
135139
ArrowType arrowType() const { return mArrowType; }
136140
/** Set the arrow type */
137-
void setArrowType( ArrowType t ) { mArrowType = t; }
141+
void setArrowType( ArrowType type ) { mArrowType = type; }
138142

139143
/**
140144
* Should be reimplemented by subclasses to return a string map that
@@ -173,12 +177,12 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
173177
QgsSymbolV2::OutputUnit mArrowStartWidthUnit;
174178
QgsMapUnitScale mArrowStartWidthUnitScale;
175179

176-
double mHeadWidth;
177-
QgsSymbolV2::OutputUnit mHeadWidthUnit;
178-
QgsMapUnitScale mHeadWidthUnitScale;
179-
double mHeadHeight;
180-
QgsSymbolV2::OutputUnit mHeadHeightUnit;
181-
QgsMapUnitScale mHeadHeightUnitScale;
180+
double mHeadLength;
181+
QgsSymbolV2::OutputUnit mHeadLengthUnit;
182+
QgsMapUnitScale mHeadLengthUnitScale;
183+
double mHeadThickness;
184+
QgsSymbolV2::OutputUnit mHeadThicknessUnit;
185+
QgsMapUnitScale mHeadThicknessUnitScale;
182186

183187
HeadType mHeadType;
184188
ArrowType mArrowType;
@@ -187,8 +191,8 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
187191

188192
double mScaledArrowWidth;
189193
double mScaledArrowStartWidth;
190-
double mScaledHeadWidth;
191-
double mScaledHeadHeight;
194+
double mScaledHeadLength;
195+
double mScaledHeadThickness;
192196
double mScaledOffset;
193197
HeadType mComputedHeadType;
194198
ArrowType mComputedArrowType;

‎src/gui/symbology-ng/qgsarrowsymbollayerwidget.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ QgsArrowSymbolLayerWidget::QgsArrowSymbolLayerWidget( const QgsVectorLayer* vl,
2525

2626
mArrowWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
2727
mArrowStartWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
28-
mHeadWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
29-
mHeadHeightUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
28+
mHeadLengthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
29+
mHeadThicknessUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
3030
mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
3131

3232
mOffsetSpin->setClearValue( 0.0 );
@@ -49,12 +49,12 @@ void QgsArrowSymbolLayerWidget::setSymbolLayer( QgsSymbolLayerV2* layer )
4949
mArrowStartWidthUnitWidget->setUnit( mLayer->arrowStartWidthUnit() );
5050
mArrowStartWidthUnitWidget->setMapUnitScale( mLayer->arrowStartWidthUnitScale() );
5151

52-
mHeadWidthSpin->setValue( mLayer->headWidth() );
53-
mHeadWidthUnitWidget->setUnit( mLayer->headWidthUnit() );
54-
mHeadWidthUnitWidget->setMapUnitScale( mLayer->headWidthUnitScale() );
55-
mHeadHeightSpin->setValue( mLayer->headHeight() );
56-
mHeadHeightUnitWidget->setUnit( mLayer->headHeightUnit() );
57-
mHeadHeightUnitWidget->setMapUnitScale( mLayer->headHeightUnitScale() );
52+
mHeadLengthSpin->setValue( mLayer->headLength() );
53+
mHeadLengthUnitWidget->setUnit( mLayer->headLengthUnit() );
54+
mHeadLengthUnitWidget->setMapUnitScale( mLayer->headLengthUnitScale() );
55+
mHeadThicknessSpin->setValue( mLayer->headThickness() );
56+
mHeadThicknessUnitWidget->setUnit( mLayer->headThicknessUnit() );
57+
mHeadThicknessUnitWidget->setMapUnitScale( mLayer->headThicknessUnitScale() );
5858

5959
mHeadTypeCombo->setCurrentIndex( mLayer->headType() );
6060
mArrowTypeCombo->setCurrentIndex( mLayer->arrowType() );
@@ -68,8 +68,8 @@ void QgsArrowSymbolLayerWidget::setSymbolLayer( QgsSymbolLayerV2* layer )
6868

6969
registerDataDefinedButton( mArrowWidthDDBtn, "arrow_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
7070
registerDataDefinedButton( mArrowStartWidthDDBtn, "arrow_start_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
71-
registerDataDefinedButton( mHeadWidthDDBtn, "head_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
72-
registerDataDefinedButton( mHeadHeightDDBtn, "head_height", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
71+
registerDataDefinedButton( mHeadWidthDDBtn, "head_length", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
72+
registerDataDefinedButton( mHeadHeightDDBtn, "head_thickness", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() );
7373
registerDataDefinedButton( mHeadTypeDDBtn, "head_type", QgsDataDefinedButton::Int, QgsDataDefinedButton::intDesc() );
7474
registerDataDefinedButton( mArrowTypeDDBtn, "arrow_type", QgsDataDefinedButton::Int, QgsDataDefinedButton::intDesc() );
7575
registerDataDefinedButton( mOffsetDDBtn, "offset", QgsDataDefinedButton::String, QgsDataDefinedButton::doubleDesc() );
@@ -99,21 +99,21 @@ void QgsArrowSymbolLayerWidget::on_mArrowStartWidthSpin_valueChanged( double d )
9999
emit changed();
100100
}
101101

102-
void QgsArrowSymbolLayerWidget::on_mHeadWidthSpin_valueChanged( double d )
102+
void QgsArrowSymbolLayerWidget::on_mHeadLengthSpin_valueChanged( double d )
103103
{
104104
if ( !mLayer )
105105
return;
106106

107-
mLayer->setHeadWidth( d );
107+
mLayer->setHeadLength( d );
108108
emit changed();
109109
}
110110

111-
void QgsArrowSymbolLayerWidget::on_mHeadHeightSpin_valueChanged( double d )
111+
void QgsArrowSymbolLayerWidget::on_mHeadThicknessSpin_valueChanged( double d )
112112
{
113113
if ( !mLayer )
114114
return;
115115

116-
mLayer->setHeadHeight( d );
116+
mLayer->setHeadThickness( d );
117117
emit changed();
118118
}
119119

@@ -137,23 +137,23 @@ void QgsArrowSymbolLayerWidget::on_mArrowStartWidthUnitWidget_changed()
137137
emit changed();
138138
}
139139

140-
void QgsArrowSymbolLayerWidget::on_mHeadWidthUnitWidget_changed()
140+
void QgsArrowSymbolLayerWidget::on_mHeadLengthUnitWidget_changed()
141141
{
142142
if ( !mLayer )
143143
return;
144144

145-
mLayer->setHeadWidthUnit( mHeadWidthUnitWidget->unit() );
146-
mLayer->setHeadWidthUnitScale( mHeadWidthUnitWidget->getMapUnitScale() );
145+
mLayer->setHeadLengthUnit( mHeadLengthUnitWidget->unit() );
146+
mLayer->setHeadLengthUnitScale( mHeadLengthUnitWidget->getMapUnitScale() );
147147
emit changed();
148148
}
149149

150-
void QgsArrowSymbolLayerWidget::on_mHeadHeightUnitWidget_changed()
150+
void QgsArrowSymbolLayerWidget::on_mHeadThicknessUnitWidget_changed()
151151
{
152152
if ( !mLayer )
153153
return;
154154

155-
mLayer->setHeadHeightUnit( mHeadHeightUnitWidget->unit() );
156-
mLayer->setHeadHeightUnitScale( mHeadHeightUnitWidget->getMapUnitScale() );
155+
mLayer->setHeadThicknessUnit( mHeadThicknessUnitWidget->unit() );
156+
mLayer->setHeadThicknessUnitScale( mHeadThicknessUnitWidget->getMapUnitScale() );
157157
emit changed();
158158
}
159159

‎src/gui/symbology-ng/qgsarrowsymbollayerwidget.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ class GUI_EXPORT QgsArrowSymbolLayerWidget: public QgsSymbolLayerV2Widget, priva
5151
void on_mArrowStartWidthSpin_valueChanged( double d );
5252
void on_mArrowStartWidthUnitWidget_changed();
5353

54-
void on_mHeadWidthSpin_valueChanged( double d );
55-
void on_mHeadWidthUnitWidget_changed();
56-
void on_mHeadHeightSpin_valueChanged( double d );
57-
void on_mHeadHeightUnitWidget_changed();
54+
void on_mHeadLengthSpin_valueChanged( double d );
55+
void on_mHeadLengthUnitWidget_changed();
56+
void on_mHeadThicknessSpin_valueChanged( double d );
57+
void on_mHeadThicknessUnitWidget_changed();
5858

5959
void on_mHeadTypeCombo_currentIndexChanged( int );
6060
void on_mArrowTypeCombo_currentIndexChanged( int );

‎src/ui/symbollayer/qgsarrowsymbollayerwidgetbase.ui

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<item row="5" column="1">
7373
<layout class="QHBoxLayout" name="horizontalLayout_2">
7474
<item>
75-
<widget class="QgsDoubleSpinBox" name="mHeadHeightSpin">
75+
<widget class="QgsDoubleSpinBox" name="mHeadThicknessSpin">
7676
<property name="sizePolicy">
7777
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
7878
<horstretch>1</horstretch>
@@ -91,7 +91,7 @@
9191
</widget>
9292
</item>
9393
<item>
94-
<widget class="QgsUnitSelectionWidget" name="mHeadHeightUnitWidget" native="true"/>
94+
<widget class="QgsUnitSelectionWidget" name="mHeadThicknessUnitWidget" native="true"/>
9595
</item>
9696
</layout>
9797
</item>
@@ -222,7 +222,7 @@
222222
<item row="5" column="0">
223223
<widget class="QLabel" name="label_2">
224224
<property name="text">
225-
<string>Head height</string>
225+
<string>Head thickness</string>
226226
</property>
227227
</widget>
228228
</item>
@@ -236,7 +236,7 @@
236236
<item row="4" column="0">
237237
<widget class="QLabel" name="label_9">
238238
<property name="text">
239-
<string>Head width</string>
239+
<string>Head length</string>
240240
</property>
241241
<property name="alignment">
242242
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@@ -246,7 +246,7 @@
246246
<item row="4" column="1">
247247
<layout class="QHBoxLayout" name="horizontalLayout_7">
248248
<item>
249-
<widget class="QgsDoubleSpinBox" name="mHeadWidthSpin">
249+
<widget class="QgsDoubleSpinBox" name="mHeadLengthSpin">
250250
<property name="sizePolicy">
251251
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
252252
<horstretch>1</horstretch>
@@ -268,7 +268,7 @@
268268
</widget>
269269
</item>
270270
<item>
271-
<widget class="QgsUnitSelectionWidget" name="mHeadWidthUnitWidget" native="true"/>
271+
<widget class="QgsUnitSelectionWidget" name="mHeadLengthUnitWidget" native="true"/>
272272
</item>
273273
</layout>
274274
</item>
@@ -356,16 +356,16 @@
356356
</layout>
357357
</widget>
358358
<customwidgets>
359-
<customwidget>
360-
<class>QgsDataDefinedButton</class>
361-
<extends>QToolButton</extends>
362-
<header>qgsdatadefinedbutton.h</header>
363-
</customwidget>
364359
<customwidget>
365360
<class>QgsDoubleSpinBox</class>
366361
<extends>QDoubleSpinBox</extends>
367362
<header>qgsdoublespinbox.h</header>
368363
</customwidget>
364+
<customwidget>
365+
<class>QgsDataDefinedButton</class>
366+
<extends>QToolButton</extends>
367+
<header>qgsdatadefinedbutton.h</header>
368+
</customwidget>
369369
<customwidget>
370370
<class>QgsUnitSelectionWidget</class>
371371
<extends>QWidget</extends>

‎tests/src/python/test_qgsarrowsymbollayer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ def tearDown(self):
7777

7878
def test_1(self):
7979
sym = self.lines_layer.rendererV2().symbol()
80-
sym_layer = QgsArrowSymbolLayer.create({'head_width': '6.5', 'head_height': '6.5'})
80+
sym_layer = QgsArrowSymbolLayer.create({'head_length': '6.5', 'head_thickness': '6.5'})
8181
dd = QgsDataDefined("(@geometry_point_num % 4) * 2")
8282
sym_layer.setDataDefinedProperty("arrow_width", dd)
8383
dd2 = QgsDataDefined("(@geometry_point_num % 4) * 2")
84-
sym_layer.setDataDefinedProperty("head_width", dd2)
84+
sym_layer.setDataDefinedProperty("head_length", dd2)
8585
dd3 = QgsDataDefined("(@geometry_point_num % 4) * 2")
86-
sym_layer.setDataDefinedProperty("head_height", dd3)
86+
sym_layer.setDataDefinedProperty("head_thickness", dd3)
8787
fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})
8888
sym_layer.setSubSymbol(fill_sym)
8989
sym.changeSymbolLayer(0, sym_layer)
@@ -99,7 +99,7 @@ def test_1(self):
9999
def test_2(self):
100100
sym = self.lines_layer.rendererV2().symbol()
101101
# double headed
102-
sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '5', 'head_width': '4', 'head_height': '6', 'head_type': '2'})
102+
sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '5', 'head_length': '4', 'head_thickness': '6', 'head_type': '2'})
103103
fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})
104104
sym_layer.setSubSymbol(fill_sym)
105105
sym.changeSymbolLayer(0, sym_layer)
@@ -115,7 +115,7 @@ def test_2(self):
115115
def test_3(self):
116116
sym = self.lines_layer.rendererV2().symbol()
117117
# double headed
118-
sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_width': '6', 'head_height': '8', 'head_type': '0', 'arrow_type': '1', 'is_curved': '0'})
118+
sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_length': '6', 'head_thickness': '8', 'head_type': '0', 'arrow_type': '1', 'is_curved': '0'})
119119
fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})
120120
sym_layer.setSubSymbol(fill_sym)
121121
sym.changeSymbolLayer(0, sym_layer)
@@ -133,7 +133,7 @@ def test_3(self):
133133
def test_unrepeated(self):
134134
sym = self.lines_layer.rendererV2().symbol()
135135
# double headed
136-
sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_width': '6', 'head_height': '8', 'head_type': '0', 'arrow_type': '0'})
136+
sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_length': '6', 'head_thickness': '8', 'head_type': '0', 'arrow_type': '0'})
137137
# no repetition
138138
sym_layer.setIsRepeated(False)
139139
fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})

0 commit comments

Comments
 (0)
Please sign in to comment.