Resolved issue #444. Length along Path seems not valid.
--HG-- branch : develop
This commit is contained in:
parent
9470f76ba9
commit
e3acc16a76
|
@ -1,4 +1,5 @@
|
|||
# Version 0.5.0
|
||||
- [#444] Length along Path seems not valid.
|
||||
- Added new curve path segment variables.
|
||||
- Toggle ScrollHandDrag mode by clicking a middle mouse button.
|
||||
- Added horizontal scrolling by pressiong Shift + mouse wheel.
|
||||
|
|
|
@ -74,13 +74,24 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
|
|||
QPointF &spl2p3) const
|
||||
{
|
||||
//Always need return two splines, so we must correct wrong length.
|
||||
if (length < GetLength()*0.02)
|
||||
const qreal minLength = ToPixel(1, Unit::Mm);
|
||||
const qreal fullLength = GetLength();
|
||||
|
||||
if (fullLength <= minLength)
|
||||
{
|
||||
length = GetLength()*0.02;
|
||||
spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF();
|
||||
return QPointF();
|
||||
}
|
||||
else if ( length > GetLength()*0.98)
|
||||
|
||||
const qreal maxLength = fullLength - minLength;
|
||||
|
||||
if (length < minLength)
|
||||
{
|
||||
length = GetLength()*0.98;
|
||||
length = minLength;
|
||||
}
|
||||
else if (length > maxLength)
|
||||
{
|
||||
length = maxLength;
|
||||
}
|
||||
|
||||
const qreal parT = GetParmT(length);
|
||||
|
|
|
@ -156,28 +156,42 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
|
|||
}
|
||||
|
||||
//Always need return two spline paths, so we must correct wrong length.
|
||||
const qreal minLength = ToPixel(1, Unit::Mm);
|
||||
qreal fullLength = GetLength();
|
||||
if (length < fullLength * 0.02)
|
||||
|
||||
if (fullLength <= minLength)
|
||||
{
|
||||
length = fullLength * 0.02;
|
||||
p1 = p2 = -1;
|
||||
spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF();
|
||||
return QPointF();
|
||||
}
|
||||
else if ( length > fullLength * 0.98)
|
||||
|
||||
const qreal maxLength = fullLength - minLength;
|
||||
|
||||
if (length < minLength)
|
||||
{
|
||||
length = fullLength * 0.98;
|
||||
length = minLength;
|
||||
}
|
||||
else if (length > maxLength)
|
||||
{
|
||||
length = maxLength;
|
||||
}
|
||||
|
||||
fullLength = 0;
|
||||
for (qint32 i = 1; i <= CountSubSpl(); ++i)
|
||||
{
|
||||
const VSpline spl = GetSpline(i);
|
||||
fullLength += spl.GetLength();
|
||||
const qreal splLength = spl.GetLength();
|
||||
fullLength += splLength;
|
||||
if (fullLength > length)
|
||||
{
|
||||
p1 = i-1;
|
||||
p2 = i;
|
||||
return spl.CutSpline(length - (fullLength - spl.GetLength()), spl1p2, spl1p3, spl2p2, spl2p3);
|
||||
return spl.CutSpline(length - (fullLength - splLength), spl1p2, spl1p3, spl2p2, spl2p3);
|
||||
}
|
||||
}
|
||||
p1 = p2 = -1;
|
||||
spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF();
|
||||
return QPointF();
|
||||
}
|
||||
|
||||
|
|
|
@ -270,13 +270,25 @@ QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
|
|||
{
|
||||
//Always need return two arcs, so we must correct wrong length.
|
||||
qreal len = 0;
|
||||
if (length < this->GetLength()*0.02)
|
||||
const qreal minLength = ToPixel(1, Unit::Mm);
|
||||
const qreal fullLength = GetLength();
|
||||
|
||||
if (fullLength <= minLength)
|
||||
{
|
||||
len = this->GetLength()*0.02;
|
||||
arc1 = VArc();
|
||||
arc2 = VArc();
|
||||
return QPointF();
|
||||
}
|
||||
else if ( length > this->GetLength()*0.98)
|
||||
|
||||
const qreal maxLength = fullLength - minLength;
|
||||
|
||||
if (length < minLength)
|
||||
{
|
||||
len = this->GetLength()*0.98;
|
||||
len = minLength;
|
||||
}
|
||||
else if (length > maxLength)
|
||||
{
|
||||
len = maxLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -322,13 +322,25 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
|
|||
{
|
||||
//Always need return two arcs, so we must correct wrong length.
|
||||
qreal len = 0;
|
||||
if (length < this->GetLength()*0.02)
|
||||
const qreal minLength = ToPixel(1, Unit::Mm);
|
||||
const qreal fullLength = GetLength();
|
||||
|
||||
if (fullLength <= minLength)
|
||||
{
|
||||
len = this->GetLength()*0.02;
|
||||
arc1 = VEllipticalArc();
|
||||
arc2 = VEllipticalArc();
|
||||
return QPointF();
|
||||
}
|
||||
else if ( length > this->GetLength()*0.98)
|
||||
|
||||
const qreal maxLength = fullLength - minLength;
|
||||
|
||||
if (length < minLength)
|
||||
{
|
||||
len = this->GetLength()*0.98;
|
||||
len = minLength;
|
||||
}
|
||||
else if (length > maxLength)
|
||||
{
|
||||
len = maxLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user