Resolved issue #620. Detail path not correct. Previous curve also should cut

segment.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-02-06 17:19:59 +02:00
parent 8a19d8a0b1
commit ac6969d64f
7 changed files with 288 additions and 24 deletions

View File

@ -55,6 +55,7 @@
- [#280] New tool: 'Hem' in Detail mode. - [#280] New tool: 'Hem' in Detail mode.
- [#509] Improve feature: Support internal Paths in Detail tool. - [#509] Improve feature: Support internal Paths in Detail tool.
- [#619] Non writable directory prevents opening. - [#619] Non writable directory prevents opening.
- [#620] Detail path not correct. Previous curve also should cut segment.
# Version 0.4.6 # Version 0.4.6
- [#594] Broken export on Mac. - [#594] Broken export on Mac.

View File

@ -0,0 +1,51 @@
<?xml version='1.0' encoding='UTF-8'?>
<pattern>
<!--Pattern created with Valentina (http://www.valentina-project.org/).-->
<version>0.4.0</version>
<unit>cm</unit>
<author/>
<description/>
<notes/>
<measurements/>
<increments/>
<draw name="Выкройка 1">
<calculation>
<point type="single" x="0.79375" y="1.05833" id="1" name="A" mx="0.132292" my="0.264583"/>
<point type="endLine" typeLine="hair" id="2" name="A1" basePoint="1" mx="0.132292" lineColor="black" my="0.264583" angle="0.520081" length="8.0384"/>
<point type="endLine" typeLine="hair" id="3" name="A2" basePoint="2" mx="0.132292" lineColor="black" my="0.264583" angle="271.245" length="14.1673"/>
<point type="endLine" typeLine="hair" id="4" name="A3" basePoint="3" mx="0.132292" lineColor="black" my="0.264583" angle="179.304" length="10.2985"/>
<point type="endLine" typeLine="hair" id="5" name="A4" basePoint="1" mx="0.132292" lineColor="black" my="0.264583" angle="286.021" length="6.87735"/>
<point type="alongLine" typeLine="none" id="6" name="A5" firstPoint="3" secondPoint="4" mx="0.132292" lineColor="black" my="0.264583" length="CurrentLength*0.8"/>
<spline type="pathInteractive" id="7" color="black">
<pathPoint angle1="239.377" pSpline="6" angle2="59.3765" length1="0" length2="2.89876"/>
<pathPoint angle1="273.972" pSpline="5" angle2="93.9724" length1="2.33261" length2="1.48524"/>
<pathPoint angle1="337.326" pSpline="1" angle2="157.326" length1="1.88356" length2="1.3254"/>
</spline>
<spline type="simpleInteractive" point4="5" angle1="59.9325" angle2="257.57" id="8" color="black" length1="4.5102" length2="3.98506" point1="4"/>
</calculation>
<modeling>
<point type="modeling" inUse="true" id="9" idObject="1" mx="0.132292" my="0.264583"/>
<point type="modeling" inUse="true" id="10" idObject="2" mx="0.132292" my="0.264583"/>
<point type="modeling" inUse="true" id="11" idObject="3" mx="0.132292" my="0.264583"/>
<point type="modeling" inUse="true" id="12" idObject="4" mx="0.132292" my="0.264583"/>
<spline type="modelingSpline" inUse="true" id="13" idObject="8"/>
<spline type="modelingPath" inUse="true" id="14" idObject="7"/>
</modeling>
<details>
<detail id="15" name="Деталь" forbidFlipping="true" united="false" seamAllowance="false" mx="0" inLayout="true" width="1" my="0" version="2">
<data rotation="0" letter="" fontSize="0" visible="false" mx="0" width="0" my="0" height="0"/>
<patternInfo rotation="0" fontSize="0" visible="false" mx="0" width="0" my="0" height="0"/>
<grainline arrows="0" rotation="" visible="false" mx="0" my="0" length=""/>
<nodes>
<node type="NodePoint" idObject="9"/>
<node type="NodePoint" idObject="10"/>
<node type="NodePoint" idObject="11"/>
<node type="NodePoint" idObject="12"/>
<node type="NodeSpline" reverse="0" idObject="13"/>
<node type="NodeSplinePath" reverse="0" idObject="14"/>
</nodes>
</detail>
</details>
<groups/>
</draw>
</pattern>

View File

@ -54,6 +54,60 @@ VSAPoint CurvePoint(VSAPoint candidate, const VContainer *data, const VPieceNode
return candidate; return candidate;
} }
//---------------------------------------------------------------------------------------------------------------------
VSAPoint CurveStartPoint(VSAPoint candidate, const VContainer *data, const VPieceNode &node,
const QVector<QPointF> &curvePoints)
{
if (node.GetTypeTool() == Tool::NodePoint)
{
return CurvePoint(candidate, data, node, curvePoints);
}
else
{
// See issue #620. Detail path not correct. Previous curve also should cut segment.
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
const QVector<QPointF> points = curve->GetPoints();
if (not points.isEmpty())
{
QPointF end; // Last point for this curve show start of next segment
node.GetReverse() ? end = points.first() : end = points.last();
if (VAbstractCurve::IsPointOnCurve(curvePoints, end))
{
candidate = VSAPoint(end);
}
}
}
return candidate;
}
//---------------------------------------------------------------------------------------------------------------------
VSAPoint CurveEndPoint(VSAPoint candidate, const VContainer *data, const VPieceNode &node,
const QVector<QPointF> &curvePoints)
{
if (node.GetTypeTool() == Tool::NodePoint)
{
return CurvePoint(candidate, data, node, curvePoints);
}
else
{
// See issue #620. Detail path not correct. Previous curve also should cut segment.
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
const QVector<QPointF> points = curve->GetPoints();
if (not points.isEmpty())
{
QPointF begin;// First point for this curve show finish of previous segment
node.GetReverse() ? begin = points.last() : begin = points.first();
if (VAbstractCurve::IsPointOnCurve(curvePoints, begin))
{
candidate = VSAPoint(begin);
}
}
}
return candidate;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief indexOfNode return index in list node using id object. * @brief indexOfNode return index in list node using id object.
@ -324,7 +378,7 @@ VSAPoint VPiecePath::StartSegment(const VContainer *data, const QVector<VPieceNo
int index = 0; int index = 0;
i == 0 ? index = nodes.size()-1 : index = i-1; i == 0 ? index = nodes.size()-1 : index = i-1;
begin = CurvePoint(begin, data, nodes.at(index), points); begin = CurveStartPoint(begin, data, nodes.at(index), points);
} }
return begin; return begin;
} }
@ -353,7 +407,7 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector<VPieceNode
int index = 0; int index = 0;
i == nodes.size() - 1 ? index = 0 : index = i+1; i == nodes.size() - 1 ? index = 0 : index = i+1;
end = CurvePoint(end, data, nodes.at(index), points); end = CurveEndPoint(end, data, nodes.at(index), points);
} }
return end; return end;
} }

View File

@ -4,7 +4,7 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT += testlib gui printsupport xml xmlpatterns QT += core testlib gui printsupport xml xmlpatterns
TARGET = ValentinaTests TARGET = ValentinaTests

View File

@ -52,12 +52,60 @@
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../vmisc/vabstractapplication.h"
class TestVApplication : public VAbstractApplication
{
public:
TestVApplication(int &argc, char ** argv);
virtual ~TestVApplication();
virtual const VTranslateVars *TrVars();
virtual void OpenSettings();
virtual bool IsAppInGUIMode() const;
virtual void InitTrVars();
};
//---------------------------------------------------------------------------------------------------------------------
TestVApplication::TestVApplication(int &argc, char **argv)
: VAbstractApplication(argc, argv)
{
}
//---------------------------------------------------------------------------------------------------------------------
TestVApplication::~TestVApplication()
{
}
//---------------------------------------------------------------------------------------------------------------------
const VTranslateVars *TestVApplication::TrVars()
{
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
void TestVApplication::OpenSettings()
{
}
//---------------------------------------------------------------------------------------------------------------------
bool TestVApplication::IsAppInGUIMode() const
{
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void TestVApplication::InitTrVars()
{
}
//---------------------------------------------------------------------------------------------------------------------
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Q_INIT_RESOURCE(schema); Q_INIT_RESOURCE(schema);
QApplication app( argc, argv );// For QPrinter TestVApplication app( argc, argv );// For QPrinter
int status = 0; int status = 0;
auto ASSERT_TEST = [&status, argc, argv](QObject* obj) auto ASSERT_TEST = [&status, argc, argv](QObject* obj)
@ -66,27 +114,27 @@ int main(int argc, char** argv)
delete obj; delete obj;
}; };
ASSERT_TEST(new TST_FindPoint()); // ASSERT_TEST(new TST_FindPoint());
ASSERT_TEST(new TST_VPiece()); ASSERT_TEST(new TST_VPiece());
ASSERT_TEST(new TST_VPoster()); // ASSERT_TEST(new TST_VPoster());
ASSERT_TEST(new TST_VAbstractPiece()); // ASSERT_TEST(new TST_VAbstractPiece());
ASSERT_TEST(new TST_VSpline()); // ASSERT_TEST(new TST_VSpline());
ASSERT_TEST(new TST_VSplinePath()); // ASSERT_TEST(new TST_VSplinePath());
ASSERT_TEST(new TST_NameRegExp()); // ASSERT_TEST(new TST_NameRegExp());
ASSERT_TEST(new TST_VLayoutDetail()); // ASSERT_TEST(new TST_VLayoutDetail());
ASSERT_TEST(new TST_VArc()); // ASSERT_TEST(new TST_VArc());
ASSERT_TEST(new TST_VEllipticalArc()); // ASSERT_TEST(new TST_VEllipticalArc());
ASSERT_TEST(new TST_QmuTokenParser()); // ASSERT_TEST(new TST_QmuTokenParser());
ASSERT_TEST(new TST_VMeasurements()); // ASSERT_TEST(new TST_VMeasurements());
ASSERT_TEST(new TST_VLockGuard()); // ASSERT_TEST(new TST_VLockGuard());
ASSERT_TEST(new TST_Misc()); // ASSERT_TEST(new TST_Misc());
ASSERT_TEST(new TST_VCommandLine()); // ASSERT_TEST(new TST_VCommandLine());
ASSERT_TEST(new TST_VAbstractCurve()); // ASSERT_TEST(new TST_VAbstractCurve());
ASSERT_TEST(new TST_VCubicBezierPath()); // ASSERT_TEST(new TST_VCubicBezierPath());
ASSERT_TEST(new TST_VGObject()); // ASSERT_TEST(new TST_VGObject());
ASSERT_TEST(new TST_VPointF()); // ASSERT_TEST(new TST_VPointF());
ASSERT_TEST(new TST_ReadVal()); // ASSERT_TEST(new TST_ReadVal());
ASSERT_TEST(new TST_VTranslateVars()); // ASSERT_TEST(new TST_VTranslateVars());
return status; return status;
} }

View File

@ -32,6 +32,7 @@
#include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecenode.h"
#include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/vpiecepath.h"
#include "../vgeometry/vsplinepath.h" #include "../vgeometry/vsplinepath.h"
#include "../vmisc/vabstractapplication.h"
#include <QtTest> #include <QtTest>
@ -49,6 +50,7 @@ void TST_VPiece::ClearLoop()
// Check correct seam allowance // Check correct seam allowance
const Unit unit = Unit::Mm; const Unit unit = Unit::Mm;
VContainer *data = new VContainer(nullptr, &unit); VContainer *data = new VContainer(nullptr, &unit);
qApp->setPatternUnit(unit);
data->UpdateGObject(304, new VPointF(61.866708661417327, 446.92270866141735, "Ф1", 5.0000125984251973, data->UpdateGObject(304, new VPointF(61.866708661417327, 446.92270866141735, "Ф1", 5.0000125984251973,
9.9999874015748045)); 9.9999874015748045));
@ -141,3 +143,110 @@ void TST_VPiece::ClearLoop()
// Begin comparison // Begin comparison
Comparison(pointsEkv, origPoints); Comparison(pointsEkv, origPoints);
} }
//---------------------------------------------------------------------------------------------------------------------
void TST_VPiece::Issue620()
{
// See file <root>/src/app/share/collection/bugs/Issue_#620.vit
// Check main path
const Unit unit = Unit::Cm;
VContainer *data = new VContainer(nullptr, &unit);
qApp->setPatternUnit(unit);
data->UpdateGObject(1, new VPointF(30, 39.999874015748034, "A", 5.0000125984251973, 9.9999874015748045));
data->UpdateGObject(2, new VPointF(333.80102715408322, 37.242158125518621, "A1", 5.0000125984251973,
9.9999874015748045));
data->UpdateGObject(3, new VPointF(345.43524385831239, 572.57275904711241, "A2", 5.0000125984251973,
9.9999874015748045));
VPointF *p4 = new VPointF(-43.770684129917051, 567.84465074396087, "A3", 5.0000125984251973,
9.9999874015748045);
data->UpdateGObject(4, p4);
VPointF *p5 = new VPointF(101.73836126698214, 289.83563666815587, "A4", 5.0000125984251973, 9.9999874015748045);
data->UpdateGObject(5, p5);
data->UpdateGObject(6, new VPointF(34.070501467722302, 568.79027240459118, "A5", 5.0000125984251973,
9.9999874015748045));
QVector<VSplinePoint> points;
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(6);
VSplinePoint p(*point.data(), 239.37700000000001, "239.377", 419.37700000000001, "59.3765",
0, "0", 109.55943307086613, "2.89876");
points.append(p);
}
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(5);
VSplinePoint p(*point.data(), 273.97199999999998, "273.972", 453.97199999999998, "93.9724",
88.161637795275595, "2.33261", 56.135055118110238, "1.48524");
points.append(p);
}
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(1);
VSplinePoint p(*point.data(), 337.32600000000002, "337.326", 157.32599999999999, "157.326",
71.189669291338589, "1.88356", 50.093858267716534, "1.3254");
points.append(p);
}
data->UpdateGObject(7, new VSplinePath(points));
data->UpdateGObject(8, new VSpline(*p4, *p5, 59.932499999999997, "59.9325", 257.56999999999999,
"257.57", 170.46425196850396, "4.5102", 150.6164409448819,
"3.98506"));
VPiece detail;
detail.SetSeamAllowance(false);
detail.SetSAWidth(7);
detail.GetPath().Append(VPieceNode(1, Tool::NodePoint));
detail.GetPath().Append(VPieceNode(2, Tool::NodePoint));
detail.GetPath().Append(VPieceNode(3, Tool::NodePoint));
detail.GetPath().Append(VPieceNode(4, Tool::NodePoint));
detail.GetPath().Append(VPieceNode(8, Tool::NodeSpline));
detail.GetPath().Append(VPieceNode(7, Tool::NodeSplinePath));
const QVector<QPointF> pointsEkv = detail.MainPathPoints(data);
QVector<QPointF> origPoints;
origPoints.append(QPointF(30.0, 39.999874015748034));
origPoints.append(QPointF(333.8010271540832, 37.24215812551862));
origPoints.append(QPointF(345.4352438583124, 572.5727590471124));
origPoints.append(QPointF(-43.77068412991705, 567.8446507439609));
origPoints.append(QPointF(-35.87661251446703, 554.334665281764));
origPoints.append(QPointF(-21.170117796937717, 530.280231438072));
origPoints.append(QPointF(-7.679257977133303, 509.352260960953));
origPoints.append(QPointF(4.687459520857305, 491.0705525945524));
origPoints.append(QPointF(21.441835284502346, 467.3785713839818));
origPoints.append(QPointF(40.52832726053379, 440.9303122452387));
origPoints.append(QPointF(52.86115234049136, 422.54889846842264));
origPoints.append(QPointF(60.404360001732, 410.06053639339046));
origPoints.append(QPointF(67.46387337253645, 396.85702763809604));
origPoints.append(QPointF(74.13118502881582, 382.4581709466849));
origPoints.append(QPointF(80.49778754648119, 366.3837650633026));
origPoints.append(QPointF(86.65517350144364, 348.15360873209477));
origPoints.append(QPointF(92.69483546961428, 327.287500697207));
origPoints.append(QPointF(98.70826602690417, 303.30523970278495));
origPoints.append(QPointF(101.73836126698214, 289.83563666815587));
origPoints.append(QPointF(100.33414592841483, 265.38578532087524));
origPoints.append(QPointF(96.68026149584162, 212.73003048920282));
origPoints.append(QPointF(93.50326130663731, 183.65468712210458));
origPoints.append(QPointF(90.71558574640727, 163.99193793167092));
origPoints.append(QPointF(87.25149211813451, 144.48122290748523));
origPoints.append(QPointF(83.01539723892088, 125.48779016127345));
origPoints.append(QPointF(77.91171792586823, 107.37688780476151));
origPoints.append(QPointF(73.4247676790375, 94.64014475361638));
origPoints.append(QPointF(70.13263046316489, 86.58901147237839));
origPoints.append(QPointF(66.56983159845231, 78.96396285141125));
origPoints.append(QPointF(62.72442318703749, 71.81065490468066));
origPoints.append(QPointF(58.58445733105817, 65.17474364615236));
origPoints.append(QPointF(54.13798613265208, 59.10188508979212));
origPoints.append(QPointF(49.373061693956934, 53.63773524956568));
origPoints.append(QPointF(44.277736117110486, 48.827950139438784));
origPoints.append(QPointF(38.84006150425045, 44.71818577337716));
origPoints.append(QPointF(33.04808995751456, 41.35409816534657));
// Begin comparison
Comparison(pointsEkv, origPoints);
}

View File

@ -39,6 +39,7 @@ public:
private slots: private slots:
void ClearLoop(); void ClearLoop();
void Issue620();
private: private:
Q_DISABLE_COPY(TST_VPiece) Q_DISABLE_COPY(TST_VPiece)