From 89d01f3fe5c1c62b4266e674d48e61e80c82925b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 6 Feb 2018 20:45:07 +0200 Subject: [PATCH] Arrow length should follow line width. --HG-- branch : develop --- src/libs/vgeometry/vabstractcurve.cpp | 11 ++++++++--- src/libs/vgeometry/vabstractcurve.h | 2 +- .../tools/drawTools/toolcurve/vabstractspline.cpp | 4 ++-- src/libs/vwidgets/vcurvepathitem.cpp | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index 860350c1e..b9186f479 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -36,8 +36,7 @@ #include #include "vabstractcurve_p.h" - -const qreal VAbstractCurve::lengthCurveDirectionArrow = 14; +#include "../vmisc/vabstractapplication.h" VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode) :VGObject(type, idObject, mode), d (new VAbstractCurveData()) @@ -357,7 +356,7 @@ QVector VAbstractCurve::DirectionArrows() const //Reverse line because we want start arrow from this point arrow = QLineF(arrow.p2(), arrow.p1()); const qreal angle = arrow.angle();//we each time change line angle, better save original angle value - arrow.setLength(lengthCurveDirectionArrow);//arrow length in pixels + arrow.setLength(VAbstractCurve::LengthCurveDirectionArrow()); DirectionArrow dArrow; @@ -400,6 +399,12 @@ QPainterPath VAbstractCurve::ShowDirection(const QVector &arrows return path; } +//--------------------------------------------------------------------------------------------------------------------- +qreal VAbstractCurve::LengthCurveDirectionArrow() +{ + return qApp->Settings()->GetLineWidth() * 8.0; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VAbstractCurve::PathLength(const QVector &path) { diff --git a/src/libs/vgeometry/vabstractcurve.h b/src/libs/vgeometry/vabstractcurve.h index 0525ec77d..5e7c7c0f6 100644 --- a/src/libs/vgeometry/vabstractcurve.h +++ b/src/libs/vgeometry/vabstractcurve.h @@ -100,7 +100,7 @@ public: virtual QVector DirectionArrows() const; static QPainterPath ShowDirection(const QVector &arrows, qreal width); - static const qreal lengthCurveDirectionArrow; + static qreal LengthCurveDirectionArrow(); protected: virtual void CreateName() =0; private: diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index 7a411eb51..b883b080b 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -85,7 +85,7 @@ QPainterPath VAbstractSpline::shape() const if (m_isHovered || detailsMode) { path.addPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(), - ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow, + ScaleWidth(VAbstractCurve::LengthCurveDirectionArrow(), SceneScale(scene())))); } path.setFillRule(Qt::WindingFill); @@ -114,7 +114,7 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o painter->setBrush(brush()); painter->drawPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(), - ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow, + ScaleWidth(VAbstractCurve::LengthCurveDirectionArrow(), SceneScale(scene())))); painter->restore(); diff --git a/src/libs/vwidgets/vcurvepathitem.cpp b/src/libs/vwidgets/vcurvepathitem.cpp index c0b3f8403..712ceb785 100644 --- a/src/libs/vwidgets/vcurvepathitem.cpp +++ b/src/libs/vwidgets/vcurvepathitem.cpp @@ -60,7 +60,7 @@ QPainterPath VCurvePathItem::shape() const } const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows, - ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow, + ScaleWidth(VAbstractCurve::LengthCurveDirectionArrow(), SceneScale(scene()))); if (arrowsPath != QPainterPath()) { @@ -76,7 +76,7 @@ void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op ScalePenWidth(); const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows, - ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow, + ScaleWidth(VAbstractCurve::LengthCurveDirectionArrow(), SceneScale(scene()))); if (arrowsPath != QPainterPath())