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 <QtDebug>
#include "vabstractcurve_p.h" #include "vabstractcurve_p.h"
#include "../vmisc/vabstractapplication.h"
const qreal VAbstractCurve::lengthCurveDirectionArrow = 14;
VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode) VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode)
:VGObject(type, idObject, mode), d (new VAbstractCurveData()) :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 //Reverse line because we want start arrow from this point
arrow = QLineF(arrow.p2(), arrow.p1()); arrow = QLineF(arrow.p2(), arrow.p1());
const qreal angle = arrow.angle();//we each time change line angle, better save original angle value 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; DirectionArrow dArrow;
@ -400,6 +399,12 @@ QPainterPath VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows
return path; return path;
} }
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::LengthCurveDirectionArrow()
{
return qApp->Settings()->GetLineWidth() * 8.0;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::PathLength(const QVector<QPointF> &path) qreal VAbstractCurve::PathLength(const QVector<QPointF> &path)
{ {

View File

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

View File

@ -85,7 +85,7 @@ QPainterPath VAbstractSpline::shape() const
if (m_isHovered || detailsMode) if (m_isHovered || detailsMode)
{ {
path.addPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(), path.addPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(),
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow, ScaleWidth(VAbstractCurve::LengthCurveDirectionArrow(),
SceneScale(scene())))); SceneScale(scene()))));
} }
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
@ -114,7 +114,7 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->setBrush(brush()); painter->setBrush(brush());
painter->drawPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(), painter->drawPath(VAbstractCurve::ShowDirection(curve->DirectionArrows(),
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow, ScaleWidth(VAbstractCurve::LengthCurveDirectionArrow(),
SceneScale(scene())))); SceneScale(scene()))));
painter->restore(); painter->restore();

View File

@ -60,7 +60,7 @@ QPainterPath VCurvePathItem::shape() const
} }
const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows, const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows,
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow, ScaleWidth(VAbstractCurve::LengthCurveDirectionArrow(),
SceneScale(scene()))); SceneScale(scene())));
if (arrowsPath != QPainterPath()) if (arrowsPath != QPainterPath())
{ {
@ -76,7 +76,7 @@ void VCurvePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
ScalePenWidth(); ScalePenWidth();
const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows, const QPainterPath arrowsPath = VAbstractCurve::ShowDirection(m_directionArrows,
ScaleWidth(VAbstractCurve::lengthCurveDirectionArrow, ScaleWidth(VAbstractCurve::LengthCurveDirectionArrow(),
SceneScale(scene()))); SceneScale(scene())));
if (arrowsPath != QPainterPath()) if (arrowsPath != QPainterPath())