diff --git a/python/core/symbology-ng/qgsarrowsymbollayer.sip b/python/core/symbology-ng/qgsarrowsymbollayer.sip index e0f423c8818c..322b9b58760d 100644 --- a/python/core/symbology-ng/qgsarrowsymbollayer.sip +++ b/python/core/symbology-ng/qgsarrowsymbollayer.sip @@ -1,3 +1,9 @@ +/** \ingroup core + * \class QgsArrowSymbolLayer + * \brief Line symbol layer used for representing lines as arrows. + * \note Added in version 2.16 + */ + class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 { %TypeHeaderCode @@ -28,57 +34,57 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 /** Return a list of attributes required to render this feature */ virtual QSet usedAttributes() const; - /** Get current arrow width */ + /** Get current arrow width */ double arrowWidth() const; /** Set the arrow width */ - void setArrowWidth( double w ); + void setArrowWidth( double width ); /** Get the unit for the arrow width */ QgsSymbolV2::OutputUnit arrowWidthUnit() const; /** Set the unit for the arrow width */ - void setArrowWidthUnit( QgsSymbolV2::OutputUnit u ); + void setArrowWidthUnit( QgsSymbolV2::OutputUnit unit ); /** Get the scale for the arrow width */ QgsMapUnitScale arrowWidthUnitScale() const; /** Set the scale for the arrow width */ - void setArrowWidthUnitScale( const QgsMapUnitScale& s ); + void setArrowWidthUnitScale( const QgsMapUnitScale& scale ); /** Get current arrow start width. Only meaningfull for single headed arrows */ double arrowStartWidth() const; /** Set the arrow start width */ - void setArrowStartWidth( double w ); + void setArrowStartWidth( double width ); /** Get the unit for the arrow start width */ QgsSymbolV2::OutputUnit arrowStartWidthUnit() const; /** Set the unit for the arrow start width */ - void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit u ); + void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit unit ); /** Get the scale for the arrow start width */ QgsMapUnitScale arrowStartWidthUnitScale() const; /** Set the scale for the arrow start width */ - void setArrowStartWidthUnitScale( const QgsMapUnitScale& s ); - - /** Get the current arrow head width */ - double headWidth() const; - /** Set the arrow head width */ - void setHeadWidth( double s ); - /** Get the unit for the head width */ - QgsSymbolV2::OutputUnit headWidthUnit() const; - /** Set the unit for the head width */ - void setHeadWidthUnit( QgsSymbolV2::OutputUnit u ); - /** Get the scale for the head width */ - QgsMapUnitScale headWidthUnitScale() const; - /** Set the scale for the head width */ - void setHeadWidthUnitScale( const QgsMapUnitScale& s ); + void setArrowStartWidthUnitScale( const QgsMapUnitScale& scale ); + + /** Get the current arrow head length */ + double headLength() const; + /** Set the arrow head length */ + void setHeadLength( double length ); + /** Get the unit for the head length */ + QgsSymbolV2::OutputUnit headLengthUnit() const; + /** Set the unit for the head length */ + void setHeadLengthUnit( QgsSymbolV2::OutputUnit unit ); + /** Get the scale for the head length */ + QgsMapUnitScale headLengthUnitScale() const; + /** Set the scale for the head length */ + void setHeadLengthUnitScale( const QgsMapUnitScale& scale ); /** Get the current arrow head height */ - double headHeight() const; + double headThickness() const; /** Set the arrow head height */ - void setHeadHeight( double s ); + void setHeadThickness( double thickness ); /** Get the unit for the head height */ - QgsSymbolV2::OutputUnit headHeightUnit() const; + QgsSymbolV2::OutputUnit headThicknessUnit() const; /** Set the unit for the head height */ - void setHeadHeightUnit( QgsSymbolV2::OutputUnit u ); + void setHeadThicknessUnit( QgsSymbolV2::OutputUnit unit ); /** Get the scale for the head height */ - QgsMapUnitScale headHeightUnitScale() const; + QgsMapUnitScale headThicknessUnitScale() const; /** Set the scale for the head height */ - void setHeadHeightUnitScale( const QgsMapUnitScale& s ); + void setHeadThicknessUnitScale( const QgsMapUnitScale& scale ); /** Return whether it is a curved arrow or a straight one */ bool isCurved() const; @@ -101,7 +107,7 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 /** Get the current head type */ HeadType headType() const; /** Set the head type */ - void setHeadType( HeadType t ); + void setHeadType( HeadType type ); /** Possible arrow types */ enum ArrowType @@ -114,7 +120,7 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 /** Get the current arrow type */ ArrowType arrowType() const; /** Set the arrow type */ - void setArrowType( ArrowType t ); + void setArrowType( ArrowType type ); /** * Should be reimplemented by subclasses to return a string map that diff --git a/src/core/symbology-ng/qgsarrowsymbollayer.cpp b/src/core/symbology-ng/qgsarrowsymbollayer.cpp index 03d7f13c195a..e7bd28b0550c 100644 --- a/src/core/symbology-ng/qgsarrowsymbollayer.cpp +++ b/src/core/symbology-ng/qgsarrowsymbollayer.cpp @@ -21,18 +21,18 @@ QgsArrowSymbolLayer::QgsArrowSymbolLayer() , mArrowWidthUnit( QgsSymbolV2::MM ) , mArrowStartWidth( 1.0 ) , mArrowStartWidthUnit( QgsSymbolV2::MM ) - , mHeadWidth( 1.5 ) - , mHeadWidthUnit( QgsSymbolV2::MM ) - , mHeadHeight( 1.5 ) - , mHeadHeightUnit( QgsSymbolV2::MM ) + , mHeadLength( 1.5 ) + , mHeadLengthUnit( QgsSymbolV2::MM ) + , mHeadThickness( 1.5 ) + , mHeadThicknessUnit( QgsSymbolV2::MM ) , mHeadType( HeadSingle ) , mArrowType( ArrowPlain ) , mIsCurved( true ) , mIsRepeated( true ) , mScaledArrowWidth( 1.0 ) , mScaledArrowStartWidth( 1.0 ) - , mScaledHeadWidth( 1.5 ) - , mScaledHeadHeight( 1.5 ) + , mScaledHeadLength( 1.5 ) + , mScaledHeadThickness( 1.5 ) , mScaledOffset( 0.0 ) , mComputedHeadType( HeadSingle ) , mComputedArrowType( ArrowPlain ) @@ -83,23 +83,23 @@ QgsSymbolLayerV2* QgsArrowSymbolLayer::create( const QgsStringMap& props ) if ( props.contains( "is_repeated" ) ) l->setIsRepeated( props["is_repeated"].toInt() == 1 ); - if ( props.contains( "head_width" ) ) - l->setHeadWidth( props["head_width"].toDouble() ); + if ( props.contains( "head_length" ) ) + l->setHeadLength( props["head_length"].toDouble() ); - if ( props.contains( "head_width_unit" ) ) - l->setHeadWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_width_unit"] ) ); + if ( props.contains( "head_length_unit" ) ) + l->setHeadLengthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_length_unit"] ) ); - if ( props.contains( "head_width_unit_scale" ) ) - l->setHeadWidthUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_width_unit_scale"] ) ); + if ( props.contains( "head_length_unit_scale" ) ) + l->setHeadLengthUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_length_unit_scale"] ) ); - if ( props.contains( "head_height" ) ) - l->setHeadHeight( props["head_height"].toDouble() ); + if ( props.contains( "head_thickness" ) ) + l->setHeadThickness( props["head_thickness"].toDouble() ); - if ( props.contains( "head_height_unit" ) ) - l->setHeadHeightUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_height_unit"] ) ); + if ( props.contains( "head_thickness_unit" ) ) + l->setHeadThicknessUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_thickness_unit"] ) ); - if ( props.contains( "head_height_unit_scale" ) ) - l->setHeadHeightUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_height_unit_scale"] ) ); + if ( props.contains( "head_thickness_unit_scale" ) ) + l->setHeadThicknessUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_thickness_unit_scale"] ) ); if ( props.contains( "head_type" ) ) l->setHeadType( static_cast( props["head_type"].toInt() ) ); @@ -152,13 +152,13 @@ QgsStringMap QgsArrowSymbolLayer::properties() const map["is_curved"] = QString::number( isCurved() ? 1 : 0 ); map["is_repeated"] = QString::number( isRepeated() ? 1 : 0 ); - map["head_width"] = QString::number( headWidth() ); - map["head_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headWidthUnit() ); - map["head_width_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headWidthUnitScale() ); + map["head_length"] = QString::number( headLength() ); + map["head_length_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headLengthUnit() ); + map["head_length_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headLengthUnitScale() ); - map["head_height"] = QString::number( headHeight() ); - map["head_height_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headHeightUnit() ); - map["head_height_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headHeightUnitScale() ); + map["head_thickness"] = QString::number( headThickness() ); + map["head_thickness_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headThicknessUnit() ); + map["head_thickness_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headThicknessUnitScale() ); map["head_type"] = QString::number( headType() ); map["arrow_type"] = QString::number( arrowType() ); @@ -186,8 +186,8 @@ void QgsArrowSymbolLayer::startRender( QgsSymbolV2RenderContext& context ) mExpressionScope.reset( new QgsExpressionContextScope() ); mScaledArrowWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), arrowWidth(), arrowWidthUnit(), arrowWidthUnitScale() ); mScaledArrowStartWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), arrowStartWidth(), arrowStartWidthUnit(), arrowStartWidthUnitScale() ); - mScaledHeadWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), headWidth(), headWidthUnit(), headWidthUnitScale() ); - mScaledHeadHeight = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), headHeight(), headHeightUnit(), headHeightUnitScale() ); + mScaledHeadLength = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), headLength(), headLengthUnit(), headLengthUnitScale() ); + mScaledHeadThickness = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), headThickness(), headThicknessUnit(), headThicknessUnitScale() ); mScaledOffset = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), offset(), offsetUnit(), offsetMapUnitScale() ); mComputedHeadType = headType(); mComputedArrowType = arrowType(); @@ -632,22 +632,22 @@ void QgsArrowSymbolLayer::_resolveDataDefined( QgsSymbolV2RenderContext& context mScaledArrowStartWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, arrowStartWidthUnit(), arrowStartWidthUnitScale() ); } } - if ( hasDataDefinedProperty( "head_width" ) ) + if ( hasDataDefinedProperty( "head_length" ) ) { - context.setOriginalValueVariable( headWidth() ); - double w = evaluateDataDefinedProperty( "head_width", context, QVariant(), &ok ).toDouble(); + context.setOriginalValueVariable( headLength() ); + double w = evaluateDataDefinedProperty( "head_length", context, QVariant(), &ok ).toDouble(); if ( ok ) { - mScaledHeadWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, headWidthUnit(), headWidthUnitScale() ); + mScaledHeadLength = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, headLengthUnit(), headLengthUnitScale() ); } } - if ( hasDataDefinedProperty( "head_height" ) ) + if ( hasDataDefinedProperty( "head_thickness" ) ) { - context.setOriginalValueVariable( headHeight() ); - double w = evaluateDataDefinedProperty( "head_height", context, QVariant(), &ok ).toDouble(); + context.setOriginalValueVariable( headThickness() ); + double w = evaluateDataDefinedProperty( "head_thickness", context, QVariant(), &ok ).toDouble(); if ( ok ) { - mScaledHeadHeight = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, headHeightUnit(), headHeightUnitScale() ); + mScaledHeadThickness = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), w, headThicknessUnit(), headThicknessUnitScale() ); } } if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OFFSET ) ) @@ -708,7 +708,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re // destination point QPointF pd( points.back() ); - QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset ); + QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset ); mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() ); } // straight arrow @@ -719,7 +719,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re // destination point QPointF pd( points.at( 1 ) ); - QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset ); + QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset ); mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() ); } } @@ -739,7 +739,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re // destination point QPointF pd( points.at( pIdx + 2 ) ); - QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset ); + QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset ); mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() ); } // straight arrow @@ -750,7 +750,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re // destination point QPointF pd( points.at( pIdx + 1 ) ); - QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset ); + QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset ); mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() ); } } @@ -769,7 +769,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re // destination point QPointF pd( points.back() ); - QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset ); + QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset ); mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() ); } } @@ -786,7 +786,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re // destination point QPointF pd( points.at( pIdx + 1 ) ); - QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset ); + QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset ); mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() ); } } diff --git a/src/core/symbology-ng/qgsarrowsymbollayer.h b/src/core/symbology-ng/qgsarrowsymbollayer.h index a9146e61fc0c..14ac204cba5f 100644 --- a/src/core/symbology-ng/qgsarrowsymbollayer.h +++ b/src/core/symbology-ng/qgsarrowsymbollayer.h @@ -18,9 +18,13 @@ #include "qgssymbollayerv2.h" -/** - * This class is used for representing lines as arrows. + +/** \ingroup core + * \class QgsArrowSymbolLayer + * \brief Line symbol layer used for representing lines as arrows. + * \note Added in version 2.16 */ + class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 { public: @@ -51,54 +55,54 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 /** Get current arrow width */ double arrowWidth() const { return mArrowWidth; } /** Set the arrow width */ - void setArrowWidth( double w ) { mArrowWidth = w; } + void setArrowWidth( double width ) { mArrowWidth = width; } /** Get the unit for the arrow width */ QgsSymbolV2::OutputUnit arrowWidthUnit() const { return mArrowWidthUnit; } /** Set the unit for the arrow width */ - void setArrowWidthUnit( QgsSymbolV2::OutputUnit u ) { mArrowWidthUnit = u; } + void setArrowWidthUnit( QgsSymbolV2::OutputUnit unit ) { mArrowWidthUnit = unit; } /** Get the scale for the arrow width */ QgsMapUnitScale arrowWidthUnitScale() const { return mArrowWidthUnitScale; } /** Set the scale for the arrow width */ - void setArrowWidthUnitScale( const QgsMapUnitScale& s ) { mArrowWidthUnitScale = s; } + void setArrowWidthUnitScale( const QgsMapUnitScale& scale ) { mArrowWidthUnitScale = scale; } /** Get current arrow start width. Only meaningfull for single headed arrows */ double arrowStartWidth() const { return mArrowStartWidth; } /** Set the arrow start width */ - void setArrowStartWidth( double w ) { mArrowStartWidth = w; } + void setArrowStartWidth( double width ) { mArrowStartWidth = width; } /** Get the unit for the arrow start width */ QgsSymbolV2::OutputUnit arrowStartWidthUnit() const { return mArrowStartWidthUnit; } /** Set the unit for the arrow start width */ - void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit u ) { mArrowStartWidthUnit = u; } + void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit unit ) { mArrowStartWidthUnit = unit; } /** Get the scale for the arrow start width */ QgsMapUnitScale arrowStartWidthUnitScale() const { return mArrowStartWidthUnitScale; } /** Set the scale for the arrow start width */ - void setArrowStartWidthUnitScale( const QgsMapUnitScale& s ) { mArrowStartWidthUnitScale = s; } - - /** Get the current arrow head width */ - double headWidth() const { return mHeadWidth; } - /** Set the arrow head width */ - void setHeadWidth( double s ) { mHeadWidth = s; } - /** Get the unit for the head width */ - QgsSymbolV2::OutputUnit headWidthUnit() const { return mHeadWidthUnit; } - /** Set the unit for the head width */ - void setHeadWidthUnit( QgsSymbolV2::OutputUnit u ) { mHeadWidthUnit = u; } - /** Get the scale for the head width */ - QgsMapUnitScale headWidthUnitScale() const { return mHeadWidthUnitScale; } - /** Set the scale for the head width */ - void setHeadWidthUnitScale( const QgsMapUnitScale& s ) { mHeadWidthUnitScale = s; } + void setArrowStartWidthUnitScale( const QgsMapUnitScale& scale ) { mArrowStartWidthUnitScale = scale; } + + /** Get the current arrow head length */ + double headLength() const { return mHeadLength; } + /** Set the arrow head length */ + void setHeadLength( double length ) { mHeadLength = length; } + /** Get the unit for the head length */ + QgsSymbolV2::OutputUnit headLengthUnit() const { return mHeadLengthUnit; } + /** Set the unit for the head length */ + void setHeadLengthUnit( QgsSymbolV2::OutputUnit unit ) { mHeadLengthUnit = unit; } + /** Get the scale for the head length */ + QgsMapUnitScale headLengthUnitScale() const { return mHeadLengthUnitScale; } + /** Set the scale for the head length */ + void setHeadLengthUnitScale( const QgsMapUnitScale& scale ) { mHeadLengthUnitScale = scale; } /** Get the current arrow head height */ - double headHeight() const { return mHeadHeight; } + double headThickness() const { return mHeadThickness; } /** Set the arrow head height */ - void setHeadHeight( double s ) { mHeadHeight = s; } + void setHeadThickness( double thickness ) { mHeadThickness = thickness; } /** Get the unit for the head height */ - QgsSymbolV2::OutputUnit headHeightUnit() const { return mHeadHeightUnit; } + QgsSymbolV2::OutputUnit headThicknessUnit() const { return mHeadThicknessUnit; } /** Set the unit for the head height */ - void setHeadHeightUnit( QgsSymbolV2::OutputUnit u ) { mHeadHeightUnit = u; } + void setHeadThicknessUnit( QgsSymbolV2::OutputUnit unit ) { mHeadThicknessUnit = unit; } /** Get the scale for the head height */ - QgsMapUnitScale headHeightUnitScale() const { return mHeadHeightUnitScale; } + QgsMapUnitScale headThicknessUnitScale() const { return mHeadThicknessUnitScale; } /** Set the scale for the head height */ - void setHeadHeightUnitScale( const QgsMapUnitScale& s ) { mHeadHeightUnitScale = s; } + void setHeadThicknessUnitScale( const QgsMapUnitScale& scale ) { mHeadThicknessUnitScale = scale; } /** Return whether it is a curved arrow or a straight one */ bool isCurved() const { return mIsCurved; } @@ -121,7 +125,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 /** Get the current head type */ HeadType headType() const { return mHeadType; } /** Set the head type */ - void setHeadType( HeadType t ) { mHeadType = t; } + void setHeadType( HeadType type ) { mHeadType = type; } /** Possible arrow types */ enum ArrowType @@ -134,7 +138,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 /** Get the current arrow type */ ArrowType arrowType() const { return mArrowType; } /** Set the arrow type */ - void setArrowType( ArrowType t ) { mArrowType = t; } + void setArrowType( ArrowType type ) { mArrowType = type; } /** * Should be reimplemented by subclasses to return a string map that @@ -173,12 +177,12 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 QgsSymbolV2::OutputUnit mArrowStartWidthUnit; QgsMapUnitScale mArrowStartWidthUnitScale; - double mHeadWidth; - QgsSymbolV2::OutputUnit mHeadWidthUnit; - QgsMapUnitScale mHeadWidthUnitScale; - double mHeadHeight; - QgsSymbolV2::OutputUnit mHeadHeightUnit; - QgsMapUnitScale mHeadHeightUnitScale; + double mHeadLength; + QgsSymbolV2::OutputUnit mHeadLengthUnit; + QgsMapUnitScale mHeadLengthUnitScale; + double mHeadThickness; + QgsSymbolV2::OutputUnit mHeadThicknessUnit; + QgsMapUnitScale mHeadThicknessUnitScale; HeadType mHeadType; ArrowType mArrowType; @@ -187,8 +191,8 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2 double mScaledArrowWidth; double mScaledArrowStartWidth; - double mScaledHeadWidth; - double mScaledHeadHeight; + double mScaledHeadLength; + double mScaledHeadThickness; double mScaledOffset; HeadType mComputedHeadType; ArrowType mComputedArrowType; diff --git a/src/gui/symbology-ng/qgsarrowsymbollayerwidget.cpp b/src/gui/symbology-ng/qgsarrowsymbollayerwidget.cpp index 272e178dd2ea..8f17cca68b7d 100644 --- a/src/gui/symbology-ng/qgsarrowsymbollayerwidget.cpp +++ b/src/gui/symbology-ng/qgsarrowsymbollayerwidget.cpp @@ -25,8 +25,8 @@ QgsArrowSymbolLayerWidget::QgsArrowSymbolLayerWidget( const QgsVectorLayer* vl, mArrowWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel ); mArrowStartWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel ); - mHeadWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel ); - mHeadHeightUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel ); + mHeadLengthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel ); + mHeadThicknessUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel ); mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel ); mOffsetSpin->setClearValue( 0.0 ); @@ -49,12 +49,12 @@ void QgsArrowSymbolLayerWidget::setSymbolLayer( QgsSymbolLayerV2* layer ) mArrowStartWidthUnitWidget->setUnit( mLayer->arrowStartWidthUnit() ); mArrowStartWidthUnitWidget->setMapUnitScale( mLayer->arrowStartWidthUnitScale() ); - mHeadWidthSpin->setValue( mLayer->headWidth() ); - mHeadWidthUnitWidget->setUnit( mLayer->headWidthUnit() ); - mHeadWidthUnitWidget->setMapUnitScale( mLayer->headWidthUnitScale() ); - mHeadHeightSpin->setValue( mLayer->headHeight() ); - mHeadHeightUnitWidget->setUnit( mLayer->headHeightUnit() ); - mHeadHeightUnitWidget->setMapUnitScale( mLayer->headHeightUnitScale() ); + mHeadLengthSpin->setValue( mLayer->headLength() ); + mHeadLengthUnitWidget->setUnit( mLayer->headLengthUnit() ); + mHeadLengthUnitWidget->setMapUnitScale( mLayer->headLengthUnitScale() ); + mHeadThicknessSpin->setValue( mLayer->headThickness() ); + mHeadThicknessUnitWidget->setUnit( mLayer->headThicknessUnit() ); + mHeadThicknessUnitWidget->setMapUnitScale( mLayer->headThicknessUnitScale() ); mHeadTypeCombo->setCurrentIndex( mLayer->headType() ); mArrowTypeCombo->setCurrentIndex( mLayer->arrowType() ); @@ -68,8 +68,8 @@ void QgsArrowSymbolLayerWidget::setSymbolLayer( QgsSymbolLayerV2* layer ) registerDataDefinedButton( mArrowWidthDDBtn, "arrow_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() ); registerDataDefinedButton( mArrowStartWidthDDBtn, "arrow_start_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() ); - registerDataDefinedButton( mHeadWidthDDBtn, "head_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() ); - registerDataDefinedButton( mHeadHeightDDBtn, "head_height", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() ); + registerDataDefinedButton( mHeadWidthDDBtn, "head_length", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() ); + registerDataDefinedButton( mHeadHeightDDBtn, "head_thickness", QgsDataDefinedButton::Double, QgsDataDefinedButton::doubleDesc() ); registerDataDefinedButton( mHeadTypeDDBtn, "head_type", QgsDataDefinedButton::Int, QgsDataDefinedButton::intDesc() ); registerDataDefinedButton( mArrowTypeDDBtn, "arrow_type", QgsDataDefinedButton::Int, QgsDataDefinedButton::intDesc() ); registerDataDefinedButton( mOffsetDDBtn, "offset", QgsDataDefinedButton::String, QgsDataDefinedButton::doubleDesc() ); @@ -99,21 +99,21 @@ void QgsArrowSymbolLayerWidget::on_mArrowStartWidthSpin_valueChanged( double d ) emit changed(); } -void QgsArrowSymbolLayerWidget::on_mHeadWidthSpin_valueChanged( double d ) +void QgsArrowSymbolLayerWidget::on_mHeadLengthSpin_valueChanged( double d ) { if ( !mLayer ) return; - mLayer->setHeadWidth( d ); + mLayer->setHeadLength( d ); emit changed(); } -void QgsArrowSymbolLayerWidget::on_mHeadHeightSpin_valueChanged( double d ) +void QgsArrowSymbolLayerWidget::on_mHeadThicknessSpin_valueChanged( double d ) { if ( !mLayer ) return; - mLayer->setHeadHeight( d ); + mLayer->setHeadThickness( d ); emit changed(); } @@ -137,23 +137,23 @@ void QgsArrowSymbolLayerWidget::on_mArrowStartWidthUnitWidget_changed() emit changed(); } -void QgsArrowSymbolLayerWidget::on_mHeadWidthUnitWidget_changed() +void QgsArrowSymbolLayerWidget::on_mHeadLengthUnitWidget_changed() { if ( !mLayer ) return; - mLayer->setHeadWidthUnit( mHeadWidthUnitWidget->unit() ); - mLayer->setHeadWidthUnitScale( mHeadWidthUnitWidget->getMapUnitScale() ); + mLayer->setHeadLengthUnit( mHeadLengthUnitWidget->unit() ); + mLayer->setHeadLengthUnitScale( mHeadLengthUnitWidget->getMapUnitScale() ); emit changed(); } -void QgsArrowSymbolLayerWidget::on_mHeadHeightUnitWidget_changed() +void QgsArrowSymbolLayerWidget::on_mHeadThicknessUnitWidget_changed() { if ( !mLayer ) return; - mLayer->setHeadHeightUnit( mHeadHeightUnitWidget->unit() ); - mLayer->setHeadHeightUnitScale( mHeadHeightUnitWidget->getMapUnitScale() ); + mLayer->setHeadThicknessUnit( mHeadThicknessUnitWidget->unit() ); + mLayer->setHeadThicknessUnitScale( mHeadThicknessUnitWidget->getMapUnitScale() ); emit changed(); } diff --git a/src/gui/symbology-ng/qgsarrowsymbollayerwidget.h b/src/gui/symbology-ng/qgsarrowsymbollayerwidget.h index b8ebde5354e4..e43b02fcbdfa 100644 --- a/src/gui/symbology-ng/qgsarrowsymbollayerwidget.h +++ b/src/gui/symbology-ng/qgsarrowsymbollayerwidget.h @@ -51,10 +51,10 @@ class GUI_EXPORT QgsArrowSymbolLayerWidget: public QgsSymbolLayerV2Widget, priva void on_mArrowStartWidthSpin_valueChanged( double d ); void on_mArrowStartWidthUnitWidget_changed(); - void on_mHeadWidthSpin_valueChanged( double d ); - void on_mHeadWidthUnitWidget_changed(); - void on_mHeadHeightSpin_valueChanged( double d ); - void on_mHeadHeightUnitWidget_changed(); + void on_mHeadLengthSpin_valueChanged( double d ); + void on_mHeadLengthUnitWidget_changed(); + void on_mHeadThicknessSpin_valueChanged( double d ); + void on_mHeadThicknessUnitWidget_changed(); void on_mHeadTypeCombo_currentIndexChanged( int ); void on_mArrowTypeCombo_currentIndexChanged( int ); diff --git a/src/ui/symbollayer/qgsarrowsymbollayerwidgetbase.ui b/src/ui/symbollayer/qgsarrowsymbollayerwidgetbase.ui index 5b51c7ced805..446f38b8c54c 100644 --- a/src/ui/symbollayer/qgsarrowsymbollayerwidgetbase.ui +++ b/src/ui/symbollayer/qgsarrowsymbollayerwidgetbase.ui @@ -72,7 +72,7 @@ - + 1 @@ -91,7 +91,7 @@ - + @@ -222,7 +222,7 @@ - Head height + Head thickness @@ -236,7 +236,7 @@ - Head width + Head length Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -246,7 +246,7 @@ - + 1 @@ -268,7 +268,7 @@ - + @@ -356,16 +356,16 @@ - - QgsDataDefinedButton - QToolButton -
qgsdatadefinedbutton.h
-
QgsDoubleSpinBox QDoubleSpinBox
qgsdoublespinbox.h
+ + QgsDataDefinedButton + QToolButton +
qgsdatadefinedbutton.h
+
QgsUnitSelectionWidget QWidget diff --git a/tests/src/python/test_qgsarrowsymbollayer.py b/tests/src/python/test_qgsarrowsymbollayer.py index 41d9a99f7269..784eeca04a56 100644 --- a/tests/src/python/test_qgsarrowsymbollayer.py +++ b/tests/src/python/test_qgsarrowsymbollayer.py @@ -77,13 +77,13 @@ def tearDown(self): def test_1(self): sym = self.lines_layer.rendererV2().symbol() - sym_layer = QgsArrowSymbolLayer.create({'head_width': '6.5', 'head_height': '6.5'}) + sym_layer = QgsArrowSymbolLayer.create({'head_length': '6.5', 'head_thickness': '6.5'}) dd = QgsDataDefined("(@geometry_point_num % 4) * 2") sym_layer.setDataDefinedProperty("arrow_width", dd) dd2 = QgsDataDefined("(@geometry_point_num % 4) * 2") - sym_layer.setDataDefinedProperty("head_width", dd2) + sym_layer.setDataDefinedProperty("head_length", dd2) dd3 = QgsDataDefined("(@geometry_point_num % 4) * 2") - sym_layer.setDataDefinedProperty("head_height", dd3) + sym_layer.setDataDefinedProperty("head_thickness", dd3) fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'}) sym_layer.setSubSymbol(fill_sym) sym.changeSymbolLayer(0, sym_layer) @@ -99,7 +99,7 @@ def test_1(self): def test_2(self): sym = self.lines_layer.rendererV2().symbol() # double headed - sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '5', 'head_width': '4', 'head_height': '6', 'head_type': '2'}) + sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '5', 'head_length': '4', 'head_thickness': '6', 'head_type': '2'}) fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'}) sym_layer.setSubSymbol(fill_sym) sym.changeSymbolLayer(0, sym_layer) @@ -115,7 +115,7 @@ def test_2(self): def test_3(self): sym = self.lines_layer.rendererV2().symbol() # double headed - sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_width': '6', 'head_height': '8', 'head_type': '0', 'arrow_type': '1', 'is_curved': '0'}) + sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_length': '6', 'head_thickness': '8', 'head_type': '0', 'arrow_type': '1', 'is_curved': '0'}) fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'}) sym_layer.setSubSymbol(fill_sym) sym.changeSymbolLayer(0, sym_layer) @@ -133,7 +133,7 @@ def test_3(self): def test_unrepeated(self): sym = self.lines_layer.rendererV2().symbol() # double headed - sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_width': '6', 'head_height': '8', 'head_type': '0', 'arrow_type': '0'}) + sym_layer = QgsArrowSymbolLayer.create({'arrow_width': '7', 'head_length': '6', 'head_thickness': '8', 'head_type': '0', 'arrow_type': '0'}) # no repetition sym_layer.setIsRepeated(False) fill_sym = QgsFillSymbolV2.createSimple({'color': '#8bcfff', 'outline_color': '#000000', 'outline_style': 'solid', 'outline_width': '1'})