Arrow length should follow line width.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-02-06 20:45:07 +02:00
parent f4b92b2cf1
commit 89d01f3fe5
4 changed files with 13 additions and 8 deletions

View File

@ -36,8 +36,7 @@
#include <QtDebug>
#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<DirectionArrow> 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<DirectionArrow> &arrows
return path;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::LengthCurveDirectionArrow()
{
return qApp->Settings()->GetLineWidth() * 8.0;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::PathLength(const QVector<QPointF> &path)
{

View File

@ -100,7 +100,7 @@ public:
virtual QVector<DirectionArrow> DirectionArrows() const;
static QPainterPath ShowDirection(const QVector<DirectionArrow> &arrows, qreal width);
static const qreal lengthCurveDirectionArrow;
static qreal LengthCurveDirectionArrow();
protected:
virtual void CreateName() =0;
private:

View File

@ -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();

View File

@ -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())