Fixes creating spline path.
--HG-- branch : feature
This commit is contained in:
parent
b124b8402e
commit
35b9dea4b2
|
@ -87,7 +87,7 @@ void VSplinePoint::SetAngle1(const qreal &value)
|
||||||
line.setAngle(value);
|
line.setAngle(value);
|
||||||
d->angle1 = line.angle();
|
d->angle1 = line.angle();
|
||||||
|
|
||||||
line.setAngle(value+180);
|
line.setAngle(d->angle1+180);
|
||||||
d->angle2 = line.angle();
|
d->angle2 = line.angle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void VSplinePoint::SetAngle2(const qreal &value)
|
||||||
line.setAngle(value);
|
line.setAngle(value);
|
||||||
d->angle2 = line.angle();
|
d->angle2 = line.angle();
|
||||||
|
|
||||||
line.setAngle(value-180);
|
line.setAngle(d->angle2+180);
|
||||||
d->angle1 = line.angle();
|
d->angle1 = line.angle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ void DialogSpline::SaveData()
|
||||||
kAsm2 = ui->doubleSpinBoxKasm2->value();
|
kAsm2 = ui->doubleSpinBoxKasm2->value();
|
||||||
kCurve = ui->doubleSpinBoxKcurve->value();
|
kCurve = ui->doubleSpinBoxKcurve->value();
|
||||||
|
|
||||||
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
|
auto path = qobject_cast<VisToolSpline *>(vis);
|
||||||
SCASSERT(path != nullptr);
|
SCASSERT(path != nullptr);
|
||||||
|
|
||||||
path->setObject1Id(GetP1());
|
path->setObject1Id(GetP1());
|
||||||
|
@ -149,6 +149,7 @@ void DialogSpline::SaveData()
|
||||||
path->SetKAsm1(kAsm1);
|
path->SetKAsm1(kAsm1);
|
||||||
path->SetKAsm2(kAsm2);
|
path->SetKAsm2(kAsm2);
|
||||||
path->SetKCurve(kCurve);
|
path->SetKCurve(kCurve);
|
||||||
|
path->SetMode(Mode::Show);
|
||||||
path->RefreshGeometry();
|
path->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
|
||||||
ui->listWidget->setFocus(Qt::OtherFocusReason);
|
ui->listWidget->setFocus(Qt::OtherFocusReason);
|
||||||
ui->doubleSpinBoxKcurve->setValue(path.GetKCurve());
|
ui->doubleSpinBoxKcurve->setValue(path.GetKCurve());
|
||||||
|
|
||||||
VisToolSplinePath *visPath = qobject_cast<VisToolSplinePath *>(vis);
|
auto visPath = qobject_cast<VisToolSplinePath *>(vis);
|
||||||
SCASSERT(visPath != nullptr);
|
SCASSERT(visPath != nullptr);
|
||||||
visPath->setPath(path);
|
visPath->setPath(path);
|
||||||
ui->listWidget->blockSignals(false);
|
ui->listWidget->blockSignals(false);
|
||||||
|
@ -155,9 +155,10 @@ void DialogSplinePath::SaveData()
|
||||||
{
|
{
|
||||||
SavePath();
|
SavePath();
|
||||||
|
|
||||||
VisToolSplinePath *visPath = qobject_cast<VisToolSplinePath *>(vis);
|
auto visPath = qobject_cast<VisToolSplinePath *>(vis);
|
||||||
SCASSERT(visPath != nullptr);
|
SCASSERT(visPath != nullptr);
|
||||||
visPath->setPath(path);
|
visPath->setPath(path);
|
||||||
|
visPath->SetMode(Mode::Show);
|
||||||
visPath->RefreshGeometry();
|
visPath->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,22 @@ void VisToolSplinePath::RefreshGeometry()
|
||||||
|
|
||||||
if (mode == Mode::Creation)
|
if (mode == Mode::Creation)
|
||||||
{
|
{
|
||||||
|
if (size > 1)
|
||||||
|
{
|
||||||
|
for (qint32 i = 1; i<=path.Count(); ++i)
|
||||||
|
{
|
||||||
|
const int preLastPoint = (path.Count() - 1) * 2;
|
||||||
|
const int lastPoint = preLastPoint + 1;
|
||||||
|
|
||||||
|
VSpline spl = path.GetSpline(i);
|
||||||
|
|
||||||
|
ctrlPoints[preLastPoint]->RefreshCtrlPoint(i, SplinePointPosition::FirstPoint, spl.GetP2(),
|
||||||
|
spl.GetP1().toQPointF());
|
||||||
|
ctrlPoints[lastPoint]->RefreshCtrlPoint(i, SplinePointPosition::LastPoint, spl.GetP3(),
|
||||||
|
spl.GetP4().toQPointF());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Creating(pathPoints.at(size-1).P().toQPointF(), size);
|
Creating(pathPoints.at(size-1).P().toQPointF(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,29 +176,6 @@ QGraphicsEllipseItem *VisToolSplinePath::getPoint(quint32 i)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QSharedPointer<VSpline> VisToolSplinePath::NewCurveSegmen(const QPointF &pSpl, int size)
|
|
||||||
{
|
|
||||||
auto spline = QSharedPointer<VSpline>(new VSpline(VPointF(pSpl), ctrlPoint, Visualization::scenePos,
|
|
||||||
VPointF(Visualization::scenePos), path.GetKCurve()));
|
|
||||||
|
|
||||||
if (size == 1)
|
|
||||||
{
|
|
||||||
path[size-1].SetAngle2(spline->GetStartAngle());
|
|
||||||
path[size-1].SetKAsm2(spline->GetKasm1());
|
|
||||||
emit PathChanged(path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
path[size-1].SetAngle2(spline->GetStartAngle());
|
|
||||||
path[size-1].SetKAsm1(spline->GetKasm1());
|
|
||||||
path[size-1].SetKAsm2(spline->GetKasm1());
|
|
||||||
emit PathChanged(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return spline;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolSplinePath::Creating(const QPointF &pSpl, int size)
|
void VisToolSplinePath::Creating(const QPointF &pSpl, int size)
|
||||||
{
|
{
|
||||||
|
@ -224,15 +217,15 @@ void VisToolSplinePath::Creating(const QPointF &pSpl, int size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLineF ctrlLine (pSpl, Visualization::scenePos);
|
||||||
|
ctrlLine.setAngle(ctrlLine.angle()+180);
|
||||||
|
|
||||||
if (size == 1)
|
if (size == 1)
|
||||||
{
|
{
|
||||||
ctrlPoints[lastPoint]->RefreshCtrlPoint(size, SplinePointPosition::FirstPoint, ctrlPoint, pSpl);
|
ctrlPoints[lastPoint]->RefreshCtrlPoint(size, SplinePointPosition::FirstPoint, ctrlPoint, pSpl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QLineF ctrlLine (pSpl, Visualization::scenePos);
|
|
||||||
ctrlLine.setAngle(ctrlLine.angle()+180);
|
|
||||||
|
|
||||||
ctrlPoints[preLastPoint]->RefreshCtrlPoint(size-1, SplinePointPosition::LastPoint, ctrlLine.p2(), pSpl);
|
ctrlPoints[preLastPoint]->RefreshCtrlPoint(size-1, SplinePointPosition::LastPoint, ctrlLine.p2(), pSpl);
|
||||||
ctrlPoints[lastPoint]->RefreshCtrlPoint(size, SplinePointPosition::FirstPoint, ctrlPoint, pSpl);
|
ctrlPoints[lastPoint]->RefreshCtrlPoint(size, SplinePointPosition::FirstPoint, ctrlPoint, pSpl);
|
||||||
}
|
}
|
||||||
|
@ -243,14 +236,32 @@ void VisToolSplinePath::Creating(const QPointF &pSpl, int size)
|
||||||
if (size == 1)
|
if (size == 1)
|
||||||
{
|
{
|
||||||
path[size-1].SetAngle2(spline.GetStartAngle());
|
path[size-1].SetAngle2(spline.GetStartAngle());
|
||||||
|
if (ctrlPoint != pSpl)
|
||||||
|
{
|
||||||
path[size-1].SetKAsm2(spline.GetKasm1());
|
path[size-1].SetKAsm2(spline.GetKasm1());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path[size-1].SetKAsm2(0);
|
||||||
|
}
|
||||||
emit PathChanged(path);
|
emit PathChanged(path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const VSpline spl = path.GetSpline(size - 1);
|
||||||
|
VSpline preSpl(spl.GetP1(), spl.GetP2(), ctrlLine.p2(), VPointF(pSpl), path.GetKCurve());
|
||||||
|
|
||||||
path[size-1].SetAngle2(spline.GetStartAngle());
|
path[size-1].SetAngle2(spline.GetStartAngle());
|
||||||
path[size-1].SetKAsm1(spline.GetKasm1());
|
if (ctrlPoint != pSpl)
|
||||||
|
{
|
||||||
|
path[size-1].SetKAsm1(preSpl.GetKasm2());
|
||||||
path[size-1].SetKAsm2(spline.GetKasm1());
|
path[size-1].SetKAsm2(spline.GetKasm1());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path[size-1].SetKAsm1(0);
|
||||||
|
path[size-1].SetKAsm2(0);
|
||||||
|
}
|
||||||
emit PathChanged(path);
|
emit PathChanged(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,7 +273,15 @@ void VisToolSplinePath::Creating(const QPointF &pSpl, int size)
|
||||||
VPointF(Visualization::scenePos), path.GetKCurve());
|
VPointF(Visualization::scenePos), path.GetKCurve());
|
||||||
|
|
||||||
path[size-1].SetAngle2(spline.GetStartAngle());
|
path[size-1].SetAngle2(spline.GetStartAngle());
|
||||||
|
|
||||||
|
if (ctrlPoint != pSpl)
|
||||||
|
{
|
||||||
path[size-1].SetKAsm2(spline.GetKasm1());
|
path[size-1].SetKAsm2(spline.GetKasm1());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path[size-1].SetKAsm2(0);
|
||||||
|
}
|
||||||
emit PathChanged(path);
|
emit PathChanged(path);
|
||||||
|
|
||||||
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
DrawPath(newCurveSegment, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||||
|
|
|
@ -69,7 +69,6 @@ protected:
|
||||||
QPointF ctrlPoint;
|
QPointF ctrlPoint;
|
||||||
|
|
||||||
QGraphicsEllipseItem * getPoint(quint32 i);
|
QGraphicsEllipseItem * getPoint(quint32 i);
|
||||||
QSharedPointer<VSpline> NewCurveSegmen(const QPointF &pSpl, int size);
|
|
||||||
void Creating(const QPointF &pSpl, int size);
|
void Creating(const QPointF &pSpl, int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user