Fix bug in control point.

Do not draw control point in constructor. It creates artefacts if they enabled
from start.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-02-06 21:05:43 +02:00
parent 89d01f3fe5
commit 575068e181
4 changed files with 9 additions and 13 deletions

View File

@ -105,18 +105,14 @@ VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl->GetC1LengthFormula());
auto *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint,
static_cast<QPointF>(spl->GetP2()),
static_cast<QPointF>(spl->GetP1()),
freeAngle1, freeLength1, this);
static_cast<QPointF>(spl->GetP2()), freeAngle1, freeLength1, this);
InitControlPoint(controlPoint1);
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl->GetEndAngleFormula());
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl->GetC2LengthFormula());
auto *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint,
static_cast<QPointF>(spl->GetP3()),
static_cast<QPointF>(spl->GetP4()),
freeAngle2, freeLength2, this);
static_cast<QPointF>(spl->GetP3()), freeAngle2, freeLength2, this);
InitControlPoint(controlPoint2);
ShowHandles(detailsMode);

View File

@ -115,16 +115,14 @@ VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraph
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl.GetC1LengthFormula());
auto *controlPoint = new VControlPointSpline(i, SplinePointPosition::FirstPoint,
static_cast<QPointF>(spl.GetP2()),
static_cast<QPointF>(spl.GetP1()),
freeAngle1, freeLength1, this);
static_cast<QPointF>(spl.GetP2()), freeAngle1, freeLength1, this);
InitControlPoint(controlPoint);
const bool freeAngle2 = qmu::QmuTokenParser::IsSingle(spl.GetEndAngleFormula());
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl.GetC2LengthFormula());
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, static_cast<QPointF>(spl.GetP3()),
static_cast<QPointF>(spl.GetP4()), freeAngle2, freeLength2, this);
freeAngle2, freeLength2, this);
InitControlPoint(controlPoint);
}

View File

@ -61,6 +61,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
freeLength(true)
{
Init();
setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
@ -73,7 +74,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
* @param parent parent object.
*/
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position,
const QPointF &controlPoint, const QPointF &splinePoint, bool freeAngle,
const QPointF &controlPoint, bool freeAngle,
bool freeLength, QGraphicsItem *parent)
: VScenePoint(parent),
controlLine(nullptr),
@ -88,8 +89,9 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setAcceptHoverEvents(true);
this->setPos(controlPoint);
setVisible(false);
SetCtrlLine(controlPoint, splinePoint);
// Do not draw control point in constructor. It creates artefacts if they enabled from start.
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -52,7 +52,7 @@ class VControlPointSpline : public QObject, public VScenePoint
public:
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem * parent = nullptr);
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint,
const QPointF &splinePoint, bool freeAngle, bool freeLength, QGraphicsItem * parent = nullptr);
bool freeAngle, bool freeLength, QGraphicsItem * parent = nullptr);
virtual ~VControlPointSpline() =default;
virtual int type() const Q_DECL_OVERRIDE {return Type;}