2016-11-03 16:59:53 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 3 11, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-11-03 16:59:53 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vpiece.h"
|
|
|
|
#include "vpiece_p.h"
|
2016-11-03 19:15:53 +01:00
|
|
|
#include "../vgeometry/vpointf.h"
|
|
|
|
#include "../vgeometry/vabstractcurve.h"
|
2017-10-15 11:25:20 +02:00
|
|
|
#include "../vgeometry/vplacelabelitem.h"
|
2016-11-03 19:15:53 +01:00
|
|
|
#include "vcontainer.h"
|
2017-04-05 12:22:33 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
2018-09-28 13:29:10 +02:00
|
|
|
#include "../ifc/exception/vexceptioninvalidnotch.h"
|
2016-11-03 19:15:53 +01:00
|
|
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QDebug>
|
2016-11-05 09:56:44 +01:00
|
|
|
#include <QPainterPath>
|
2016-11-03 16:59:53 +01:00
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
const qreal passmarkFactor = 0.5;
|
|
|
|
const qreal maxPassmarkLength = (10/*mm*/ / 25.4) * PrintDPI;
|
|
|
|
|
2017-01-31 17:09:18 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
QVector<quint32> PieceMissingNodes(const QVector<quint32> &d1Nodes, const QVector<quint32> &d2Nodes)
|
|
|
|
{
|
|
|
|
if (d1Nodes.size() == d2Nodes.size()) //-V807
|
|
|
|
{
|
|
|
|
return QVector<quint32>();
|
|
|
|
}
|
|
|
|
|
|
|
|
QSet<quint32> set1;
|
|
|
|
for (qint32 i = 0; i < d1Nodes.size(); ++i)
|
|
|
|
{
|
|
|
|
set1.insert(d1Nodes.at(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
QSet<quint32> set2;
|
|
|
|
for (qint32 j = 0; j < d2Nodes.size(); ++j)
|
|
|
|
{
|
|
|
|
set2.insert(d2Nodes.at(j));
|
|
|
|
}
|
|
|
|
|
|
|
|
const QList<quint32> set3 = set1.subtract(set2).toList();
|
|
|
|
QVector<quint32> r;
|
|
|
|
for (qint32 i = 0; i < set3.size(); ++i)
|
|
|
|
{
|
|
|
|
r.append(set3.at(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2017-03-28 12:09:00 +02:00
|
|
|
|
|
|
|
const qreal passmarkGap = (1.5/*mm*/ / 25.4) * PrintDPI;
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QLineF> CreateTwoPassmarkLines(const QLineF &line)
|
|
|
|
{
|
|
|
|
QPointF l1p1;
|
|
|
|
{
|
|
|
|
QLineF line1 = line;
|
|
|
|
line1.setAngle(line1.angle() + 90);
|
|
|
|
line1.setLength(passmarkGap/2.);
|
|
|
|
l1p1 = line1.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p1;
|
|
|
|
{
|
|
|
|
QLineF line2 = line;
|
|
|
|
line2.setAngle(line2.angle() - 90);
|
|
|
|
line2.setLength(passmarkGap/2.);
|
|
|
|
l2p1 = line2.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l1p2;
|
|
|
|
{
|
|
|
|
QLineF line1 = QLineF(line.p2(), line.p1());
|
|
|
|
line1.setAngle(line1.angle() - 90);
|
|
|
|
line1.setLength(passmarkGap/2.);
|
|
|
|
l1p2 = line1.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p2;
|
|
|
|
{
|
|
|
|
QLineF line2 = QLineF(line.p2(), line.p1());
|
|
|
|
line2.setAngle(line2.angle() + 90);
|
|
|
|
line2.setLength(passmarkGap/2.);
|
|
|
|
l2p2 = line2.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QLineF> lines;
|
|
|
|
lines.append(QLineF(l1p1, l1p2));
|
|
|
|
lines.append(QLineF(l2p1, l2p2));
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QLineF> CreateThreePassmarkLines(const QLineF &line)
|
|
|
|
{
|
|
|
|
QPointF l1p1;
|
|
|
|
{
|
|
|
|
QLineF line1 = line;
|
|
|
|
line1.setAngle(line1.angle() + 90);
|
|
|
|
line1.setLength(passmarkGap);
|
|
|
|
l1p1 = line1.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p1;
|
|
|
|
{
|
|
|
|
QLineF line2 = line;
|
|
|
|
line2.setAngle(line2.angle() - 90);
|
|
|
|
line2.setLength(passmarkGap);
|
|
|
|
l2p1 = line2.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l1p2;
|
|
|
|
{
|
|
|
|
QLineF line1 = QLineF(line.p2(), line.p1());
|
|
|
|
line1.setAngle(line1.angle() - 90);
|
|
|
|
line1.setLength(passmarkGap);
|
|
|
|
l1p2 = line1.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p2;
|
|
|
|
{
|
|
|
|
QLineF line2 = QLineF(line.p2(), line.p1());
|
|
|
|
line2.setAngle(line2.angle() + 90);
|
|
|
|
line2.setLength(passmarkGap);
|
|
|
|
l2p2 = line2.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QLineF> lines;
|
|
|
|
lines.append(QLineF(l1p1, l1p2));
|
|
|
|
lines.append(line);
|
|
|
|
lines.append(QLineF(l2p1, l2p2));
|
|
|
|
return lines;
|
|
|
|
}
|
2017-03-30 12:59:10 +02:00
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QLineF> CreateTMarkPassmark(const QLineF &line)
|
|
|
|
{
|
|
|
|
QPointF p1;
|
|
|
|
{
|
|
|
|
QLineF tmpLine = QLineF(line.p2(), line.p1());
|
|
|
|
tmpLine.setAngle(tmpLine.angle() - 90);
|
|
|
|
tmpLine.setLength(line.length() * 0.75 / 2);
|
|
|
|
p1 = tmpLine.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF p2;
|
|
|
|
{
|
|
|
|
QLineF tmpLine = QLineF(line.p2(), line.p1());
|
|
|
|
tmpLine.setAngle(tmpLine.angle() + 90);
|
|
|
|
tmpLine.setLength(line.length() * 0.75 / 2);
|
|
|
|
p2 = tmpLine.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QLineF> lines;
|
|
|
|
lines.append(line);
|
|
|
|
lines.append(QLineF(p1, p2));
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QLineF> CreateVMarkPassmark(const QLineF &line)
|
|
|
|
{
|
|
|
|
QLineF l1 = line;
|
|
|
|
l1.setAngle(l1.angle() - 35);
|
|
|
|
|
|
|
|
QLineF l2 = line;
|
|
|
|
l2.setAngle(l2.angle() + 35);
|
|
|
|
|
|
|
|
QVector<QLineF> lines;
|
|
|
|
lines.append(l1);
|
|
|
|
lines.append(l2);
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType angleType, const QLineF &line)
|
|
|
|
{
|
|
|
|
QVector<QLineF> passmarksLines;
|
|
|
|
|
2017-09-28 20:18:13 +02:00
|
|
|
if (angleType == PassmarkAngleType::Straightforward
|
|
|
|
|| angleType == PassmarkAngleType::Intersection
|
|
|
|
|| angleType == PassmarkAngleType::IntersectionOnlyLeft
|
2018-02-04 11:35:27 +01:00
|
|
|
|| angleType == PassmarkAngleType::IntersectionOnlyRight
|
|
|
|
|| angleType == PassmarkAngleType::Intersection2
|
|
|
|
|| angleType == PassmarkAngleType::Intersection2OnlyLeft
|
|
|
|
|| angleType == PassmarkAngleType::Intersection2OnlyRight)
|
2017-04-05 12:22:33 +02:00
|
|
|
{
|
|
|
|
switch (lineType)
|
|
|
|
{
|
|
|
|
case PassmarkLineType::TwoLines:
|
|
|
|
passmarksLines += CreateTwoPassmarkLines(line);
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::ThreeLines:
|
|
|
|
passmarksLines += CreateThreePassmarkLines(line);
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::TMark:
|
|
|
|
passmarksLines += CreateTMarkPassmark(line);
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::VMark:
|
|
|
|
passmarksLines += CreateVMarkPassmark(line);
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::OneLine:
|
|
|
|
default:
|
|
|
|
passmarksLines.append(line);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (lineType)
|
|
|
|
{
|
|
|
|
case PassmarkLineType::TMark:
|
|
|
|
passmarksLines += CreateTMarkPassmark(line);
|
|
|
|
break;
|
|
|
|
case PassmarkLineType::OneLine:
|
|
|
|
case PassmarkLineType::TwoLines:
|
|
|
|
case PassmarkLineType::ThreeLines:
|
|
|
|
case PassmarkLineType::VMark:
|
|
|
|
default:
|
|
|
|
passmarksLines.append(line);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return passmarksLines;
|
|
|
|
}
|
|
|
|
|
2017-03-30 12:59:10 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool IsPassmarksPossible(const QVector<VPieceNode> &path)
|
|
|
|
{
|
|
|
|
int countPointNodes = 0;
|
|
|
|
int countOthers = 0;
|
|
|
|
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto &node : path)
|
2017-03-30 12:59:10 +02:00
|
|
|
{
|
|
|
|
if (node.IsExcluded())
|
|
|
|
{
|
|
|
|
continue;// skip node
|
|
|
|
}
|
|
|
|
|
|
|
|
node.GetTypeTool() == Tool::NodePoint ? ++countPointNodes : ++countOthers;
|
|
|
|
}
|
|
|
|
|
|
|
|
return countPointNodes >= 3 || (countPointNodes >= 1 && countOthers >= 1);
|
|
|
|
}
|
2018-09-28 12:43:03 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool FixNotchPoint(const QVector<QPointF> &seamAllowance, const QPointF ¬chBase, QPointF *notch)
|
|
|
|
{
|
|
|
|
bool fixed = true;
|
|
|
|
if (not VAbstractCurve::IsPointOnCurve(seamAllowance, *notch))
|
|
|
|
{
|
|
|
|
fixed = false;
|
|
|
|
QLineF axis = QLineF(notchBase, *notch);
|
|
|
|
axis.setLength(ToPixel(50, Unit::Cm));
|
|
|
|
const QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(seamAllowance, axis);
|
|
|
|
|
|
|
|
if (points.size() > 0)
|
|
|
|
{
|
|
|
|
if (points.size() == 1)
|
|
|
|
{
|
|
|
|
*notch = points.at(0);
|
|
|
|
fixed = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMap<qreal, int> forward;
|
|
|
|
|
|
|
|
for ( qint32 i = 0; i < points.size(); ++i )
|
|
|
|
{
|
|
|
|
if (points.at(i) == notchBase)
|
|
|
|
{ // Always seek unique intersection
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QLineF length(notchBase, points.at(i));
|
|
|
|
if (qAbs(length.angle() - axis.angle()) < 0.1)
|
|
|
|
{
|
|
|
|
forward.insert(length.length(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Closest point is not always want we need. First return point in forward direction if exists.
|
|
|
|
if (not forward.isEmpty())
|
|
|
|
{
|
|
|
|
*notch = points.at(forward.first());
|
|
|
|
fixed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-20 21:18:27 +02:00
|
|
|
else
|
|
|
|
{ // Fixing distortion
|
|
|
|
QLineF axis = QLineF(notchBase, *notch);
|
|
|
|
axis.setLength(axis.length() + accuracyPointOnLine * 10);
|
|
|
|
const QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(seamAllowance, axis);
|
|
|
|
if (points.size() == 1)
|
|
|
|
{
|
|
|
|
*notch = points.first();
|
|
|
|
}
|
|
|
|
}
|
2018-09-28 12:43:03 +02:00
|
|
|
|
|
|
|
return fixed;
|
|
|
|
}
|
2017-01-31 17:09:18 +01:00
|
|
|
}
|
|
|
|
|
2016-11-03 16:59:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPiece::VPiece()
|
2016-11-24 20:26:51 +01:00
|
|
|
: VAbstractPiece(), d(new VPieceData(PiecePathType::PiecePath))
|
2016-11-03 16:59:53 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPiece::VPiece(const VPiece &piece)
|
2016-11-03 19:15:53 +01:00
|
|
|
: VAbstractPiece(piece), d (piece.d)
|
2016-11-03 16:59:53 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPiece &VPiece::operator=(const VPiece &piece)
|
|
|
|
{
|
|
|
|
if ( &piece == this )
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
2016-11-03 19:15:53 +01:00
|
|
|
VAbstractPiece::operator=(piece);
|
2016-11-03 16:59:53 +01:00
|
|
|
d = piece.d;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPiece::~VPiece()
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-23 11:54:46 +01:00
|
|
|
VPiecePath VPiece::GetPath() const
|
2016-11-03 16:59:53 +01:00
|
|
|
{
|
2016-11-23 11:54:46 +01:00
|
|
|
return d->m_path;
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-23 11:54:46 +01:00
|
|
|
VPiecePath &VPiece::GetPath()
|
2016-11-03 16:59:53 +01:00
|
|
|
{
|
2016-11-23 11:54:46 +01:00
|
|
|
return d->m_path;
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-23 11:54:46 +01:00
|
|
|
void VPiece::SetPath(const VPiecePath &path)
|
2016-11-03 16:59:53 +01:00
|
|
|
{
|
2016-11-23 11:54:46 +01:00
|
|
|
d->m_path = path;
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
2016-11-03 19:15:53 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QPointF> VPiece::MainPathPoints(const VContainer *data) const
|
|
|
|
{
|
2016-11-23 11:54:46 +01:00
|
|
|
QVector<QPointF> points = GetPath().PathPoints(data);
|
2016-11-03 19:15:53 +01:00
|
|
|
points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
|
2016-11-05 09:56:44 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-22 11:05:53 +01:00
|
|
|
QVector<VPointF> VPiece::MainPathNodePoints(const VContainer *data, bool showExcluded) const
|
2016-11-05 09:56:44 +01:00
|
|
|
{
|
2017-03-22 11:05:53 +01:00
|
|
|
return GetPath().PathNodePoints(data, showExcluded);
|
2016-11-05 09:56:44 +01:00
|
|
|
}
|
|
|
|
|
2016-11-10 13:06:09 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QPointF> VPiece::SeamAllowancePoints(const VContainer *data) const
|
|
|
|
{
|
|
|
|
SCASSERT(data != nullptr);
|
|
|
|
|
2016-11-11 16:55:02 +01:00
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
if (not IsSeamAllowance() || IsSeamAllowanceBuiltIn())
|
2016-11-10 13:06:09 +01:00
|
|
|
{
|
2016-11-11 16:55:02 +01:00
|
|
|
return QVector<QPointF>();
|
2016-11-10 13:06:09 +01:00
|
|
|
}
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
const QVector<CustomSARecord> records = FilterRecords(GetValidRecords());
|
2016-11-29 13:10:53 +01:00
|
|
|
int recordIndex = -1;
|
|
|
|
bool insertingCSA = false;
|
|
|
|
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
2017-03-30 11:26:06 +02:00
|
|
|
const QVector<VPieceNode> unitedPath = GetUnitedPath(data);
|
2016-11-29 13:10:53 +01:00
|
|
|
|
2016-11-11 16:55:02 +01:00
|
|
|
QVector<VSAPoint> pointsEkv;
|
2017-03-30 11:26:06 +02:00
|
|
|
for (int i = 0; i< unitedPath.size(); ++i)
|
2016-11-10 13:06:09 +01:00
|
|
|
{
|
2017-03-30 11:26:06 +02:00
|
|
|
const VPieceNode &node = unitedPath.at(i);
|
2017-03-22 11:05:53 +01:00
|
|
|
if (node.IsExcluded())
|
|
|
|
{
|
|
|
|
continue;// skip excluded node
|
|
|
|
}
|
|
|
|
|
2016-11-12 12:31:37 +01:00
|
|
|
switch (node.GetTypeTool())
|
2016-11-10 13:06:09 +01:00
|
|
|
{
|
|
|
|
case (Tool::NodePoint):
|
|
|
|
{
|
2016-11-29 13:10:53 +01:00
|
|
|
if (not insertingCSA)
|
|
|
|
{
|
|
|
|
pointsEkv.append(VPiecePath::PreparePointEkv(node, data));
|
|
|
|
|
|
|
|
recordIndex = IsCSAStart(records, node.GetId());
|
2017-03-30 11:26:06 +02:00
|
|
|
if (recordIndex != -1 && records.at(recordIndex).includeType == PiecePathIncludeType::AsCustomSA)
|
2016-11-29 13:10:53 +01:00
|
|
|
{
|
|
|
|
insertingCSA = true;
|
|
|
|
|
|
|
|
const VPiecePath path = data->GetPiecePath(records.at(recordIndex).path);
|
|
|
|
QVector<VSAPoint> r = path.SeamAllowancePoints(data, width, records.at(recordIndex).reverse);
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
for (int j = 0; j < r.size(); ++j)
|
2016-11-29 13:10:53 +01:00
|
|
|
{
|
2018-10-17 17:12:39 +02:00
|
|
|
r[j].SetAngleType(PieceNodeAngle::ByLengthCurve);
|
2017-03-30 11:26:06 +02:00
|
|
|
r[j].SetSABefore(0);
|
|
|
|
r[j].SetSAAfter(0);
|
2016-11-29 13:10:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pointsEkv += r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (records.at(recordIndex).endPoint == node.GetId())
|
|
|
|
{
|
|
|
|
insertingCSA = false;
|
|
|
|
recordIndex = -1;
|
|
|
|
|
|
|
|
pointsEkv.append(VPiecePath::PreparePointEkv(node, data));
|
|
|
|
}
|
|
|
|
}
|
2016-11-10 13:06:09 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case (Tool::NodeArc):
|
2017-02-10 15:47:15 +01:00
|
|
|
case (Tool::NodeElArc):
|
2016-11-10 13:06:09 +01:00
|
|
|
case (Tool::NodeSpline):
|
|
|
|
case (Tool::NodeSplinePath):
|
|
|
|
{
|
2016-11-29 13:10:53 +01:00
|
|
|
if (not insertingCSA)
|
|
|
|
{
|
|
|
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
pointsEkv += VPiecePath::CurveSeamAllowanceSegment(data, unitedPath, curve, i, node.GetReverse(),
|
|
|
|
width);
|
2016-11-29 13:10:53 +01:00
|
|
|
}
|
2016-11-10 13:06:09 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2016-11-12 12:31:37 +01:00
|
|
|
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool());
|
2016-11-10 13:06:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-29 13:10:53 +01:00
|
|
|
return Equidistant(pointsEkv, width);
|
2016-11-10 13:06:09 +01:00
|
|
|
}
|
|
|
|
|
2018-07-26 19:00:24 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QPointF> VPiece::CuttingPathPoints(const VContainer *data) const
|
|
|
|
{
|
|
|
|
if (IsSeamAllowance() and not IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
|
|
|
return SeamAllowancePoints(data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return MainPathPoints(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-08-05 10:03:19 +02:00
|
|
|
QVector<QLineF> VPiece::PassmarksLines(const VContainer *data, const QVector<QPointF> &seamAllowance) const
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2017-03-30 11:26:06 +02:00
|
|
|
const QVector<VPieceNode> unitedPath = GetUnitedPath(data);
|
|
|
|
if (not IsSeamAllowance() || not IsPassmarksPossible(unitedPath))
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
|
|
|
return QVector<QLineF>();
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QLineF> passmarks;
|
|
|
|
|
2018-09-27 14:13:43 +02:00
|
|
|
QVector<QPointF> seamPoints;
|
|
|
|
seamAllowance.isEmpty() && not IsSeamAllowanceBuiltIn() ? seamPoints = SeamAllowancePoints(data) :
|
|
|
|
seamPoints = seamAllowance;
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
for (int i = 0; i< unitedPath.size(); ++i)
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2017-03-30 11:26:06 +02:00
|
|
|
const VPieceNode &node = unitedPath.at(i);
|
2017-03-28 12:09:00 +02:00
|
|
|
if (node.IsExcluded() || not node.IsPassmark())
|
|
|
|
{
|
|
|
|
continue;// skip node
|
|
|
|
}
|
|
|
|
|
2017-04-25 19:48:32 +02:00
|
|
|
const int previousIndex = VPiecePath::FindInLoopNotExcludedUp(i, unitedPath);
|
|
|
|
const int nextIndex = VPiecePath::FindInLoopNotExcludedDown(i, unitedPath);
|
2017-03-28 12:09:00 +02:00
|
|
|
|
2018-09-27 14:13:43 +02:00
|
|
|
passmarks += CreatePassmark(unitedPath, previousIndex, i, nextIndex, data, seamPoints);
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return passmarks;
|
|
|
|
}
|
|
|
|
|
2017-10-15 11:25:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<PlaceLabelImg> VPiece::PlaceLabelPoints(const VContainer *data) const
|
|
|
|
{
|
|
|
|
QVector<PlaceLabelImg> points;
|
2018-04-02 19:38:56 +02:00
|
|
|
for(auto placeLabel : d->m_placeLabels)
|
2017-10-15 11:25:20 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2018-04-02 19:38:56 +02:00
|
|
|
const auto label = data->GeometricObject<VPlaceLabelItem>(placeLabel);
|
2018-07-20 09:30:05 +02:00
|
|
|
if (label->IsVisible())
|
|
|
|
{
|
|
|
|
points.append(label->LabelShape());
|
|
|
|
}
|
2017-10-15 11:25:20 +02:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
2017-10-24 11:02:47 +02:00
|
|
|
{
|
|
|
|
qWarning() << e.ErrorMessage();
|
2017-10-15 11:25:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
|
2018-04-02 15:49:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QPainterPath> VPiece::CurvesPainterPath(const VContainer *data) const
|
|
|
|
{
|
|
|
|
return GetPath().CurvesPainterPath(data);
|
|
|
|
}
|
|
|
|
|
2016-11-05 09:56:44 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QPainterPath VPiece::MainPathPath(const VContainer *data) const
|
|
|
|
{
|
2018-04-02 16:05:53 +02:00
|
|
|
return VPiece::MainPathPath(MainPathPoints(data));
|
2018-04-02 15:49:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-04-02 16:05:53 +02:00
|
|
|
QPainterPath VPiece::MainPathPath(const QVector<QPointF> &points)
|
2018-04-02 15:49:53 +02:00
|
|
|
{
|
2016-11-05 09:56:44 +01:00
|
|
|
QPainterPath path;
|
|
|
|
|
|
|
|
if (not points.isEmpty())
|
|
|
|
{
|
|
|
|
path.moveTo(points[0]);
|
|
|
|
for (qint32 i = 1; i < points.count(); ++i)
|
|
|
|
{
|
|
|
|
path.lineTo(points.at(i));
|
|
|
|
}
|
|
|
|
path.lineTo(points.at(0));
|
|
|
|
path.setFillRule(Qt::WindingFill);
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2016-11-08 11:53:14 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-10 13:06:09 +01:00
|
|
|
QPainterPath VPiece::SeamAllowancePath(const VContainer *data) const
|
|
|
|
{
|
2017-08-05 10:03:19 +02:00
|
|
|
return SeamAllowancePath(SeamAllowancePoints(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QPainterPath VPiece::SeamAllowancePath(const QVector<QPointF> &points) const
|
|
|
|
{
|
2016-11-10 13:06:09 +01:00
|
|
|
QPainterPath ekv;
|
|
|
|
|
|
|
|
// seam allowence
|
2017-04-05 12:22:33 +02:00
|
|
|
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn())
|
2016-11-10 13:06:09 +01:00
|
|
|
{
|
2017-08-05 10:03:19 +02:00
|
|
|
if (not points.isEmpty())
|
2016-11-10 13:06:09 +01:00
|
|
|
{
|
2017-08-05 10:03:19 +02:00
|
|
|
ekv.moveTo(points.at(0));
|
|
|
|
for (qint32 i = 1; i < points.count(); ++i)
|
2016-11-10 13:06:09 +01:00
|
|
|
{
|
2017-08-05 10:03:19 +02:00
|
|
|
ekv.lineTo(points.at(i));
|
2016-11-10 13:06:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ekv.setFillRule(Qt::WindingFill);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ekv;
|
|
|
|
}
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-08-05 10:03:19 +02:00
|
|
|
QPainterPath VPiece::PassmarksPath(const VContainer *data, const QVector<QPointF> &seamAllowance) const
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2017-08-05 10:03:19 +02:00
|
|
|
const QVector<QLineF> passmarks = PassmarksLines(data, seamAllowance);
|
2017-03-28 12:09:00 +02:00
|
|
|
QPainterPath path;
|
|
|
|
|
|
|
|
// seam allowence
|
|
|
|
if (IsSeamAllowance())
|
|
|
|
{
|
|
|
|
if (not passmarks.isEmpty())
|
|
|
|
{
|
|
|
|
for (qint32 i = 0; i < passmarks.count(); ++i)
|
|
|
|
{
|
|
|
|
path.moveTo(passmarks.at(i).p1());
|
|
|
|
path.lineTo(passmarks.at(i).p2());
|
|
|
|
}
|
|
|
|
|
|
|
|
path.setFillRule(Qt::WindingFill);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2017-10-15 11:25:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QPainterPath VPiece::PlaceLabelPath(const VContainer *data) const
|
|
|
|
{
|
|
|
|
const QVector<PlaceLabelImg> points = PlaceLabelPoints(data);
|
|
|
|
QPainterPath path;
|
|
|
|
|
|
|
|
if (not points.isEmpty())
|
|
|
|
{
|
|
|
|
for (qint32 i = 0; i < points.count(); ++i)
|
|
|
|
{
|
|
|
|
path.addPath(PlaceLabelImgPath(points.at(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
path.setFillRule(Qt::WindingFill);
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2016-11-09 13:11:58 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-09 14:53:22 +01:00
|
|
|
bool VPiece::IsInLayout() const
|
|
|
|
{
|
|
|
|
return d->m_inLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPiece::SetInLayout(bool inLayout)
|
|
|
|
{
|
|
|
|
d->m_inLayout = inLayout;
|
|
|
|
}
|
|
|
|
|
2016-11-23 17:40:27 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VPiece::IsUnited() const
|
|
|
|
{
|
|
|
|
return d->m_united;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPiece::SetUnited(bool united)
|
|
|
|
{
|
|
|
|
d->m_united = united;
|
|
|
|
}
|
|
|
|
|
2017-01-21 14:24:40 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VPiece::GetFormulaSAWidth() const
|
|
|
|
{
|
|
|
|
return d->m_formulaWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPiece::SetFormulaSAWidth(const QString &formula, qreal value)
|
|
|
|
{
|
|
|
|
SetSAWidth(value);
|
|
|
|
const qreal width = GetSAWidth();
|
2018-04-12 12:13:19 +02:00
|
|
|
width >= 0 ? d->m_formulaWidth = formula : d->m_formulaWidth = QLatin1Char('0');
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
2016-12-03 17:01:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> VPiece::GetInternalPaths() const
|
|
|
|
{
|
|
|
|
return d->m_internalPaths;
|
|
|
|
}
|
|
|
|
|
2017-01-31 15:26:28 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> &VPiece::GetInternalPaths()
|
|
|
|
{
|
|
|
|
return d->m_internalPaths;
|
|
|
|
}
|
|
|
|
|
2016-12-03 17:01:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPiece::SetInternalPaths(const QVector<quint32> &iPaths)
|
|
|
|
{
|
|
|
|
d->m_internalPaths = iPaths;
|
|
|
|
}
|
|
|
|
|
2017-01-18 09:17:18 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-01-31 15:26:28 +01:00
|
|
|
QVector<CustomSARecord> VPiece::GetCustomSARecords() const
|
2017-01-18 09:17:18 +01:00
|
|
|
{
|
2017-01-31 15:26:28 +01:00
|
|
|
return d->m_customSARecords;
|
2017-01-18 09:17:18 +01:00
|
|
|
}
|
|
|
|
|
2016-11-25 13:19:44 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-01-31 15:26:28 +01:00
|
|
|
QVector<CustomSARecord> &VPiece::GetCustomSARecords()
|
2016-11-25 13:19:44 +01:00
|
|
|
{
|
|
|
|
return d->m_customSARecords;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPiece::SetCustomSARecords(const QVector<CustomSARecord> &records)
|
|
|
|
{
|
|
|
|
d->m_customSARecords = records;
|
|
|
|
}
|
|
|
|
|
2017-01-18 09:17:18 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-01-31 15:26:28 +01:00
|
|
|
QVector<quint32> VPiece::GetPins() const
|
|
|
|
{
|
|
|
|
return d->m_pins;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> &VPiece::GetPins()
|
|
|
|
{
|
|
|
|
return d->m_pins;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPiece::SetPins(const QVector<quint32> &pins)
|
2017-01-18 09:17:18 +01:00
|
|
|
{
|
2017-01-31 15:26:28 +01:00
|
|
|
d->m_pins = pins;
|
2017-01-18 09:17:18 +01:00
|
|
|
}
|
|
|
|
|
2017-10-15 11:25:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> VPiece::GetPlaceLabels() const
|
|
|
|
{
|
|
|
|
return d->m_placeLabels;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> &VPiece::GetPlaceLabels()
|
|
|
|
{
|
|
|
|
return d->m_placeLabels;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPiece::SetPlaceLabels(const QVector<quint32> &labels)
|
|
|
|
{
|
|
|
|
d->m_placeLabels = labels;
|
|
|
|
}
|
|
|
|
|
2017-10-23 09:45:58 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QList<quint32> VPiece::Dependencies() const
|
|
|
|
{
|
|
|
|
QList<quint32> list = d->m_path.Dependencies();
|
2018-09-27 14:16:01 +02:00
|
|
|
list.reserve(list.size() + d->m_customSARecords.size() + d->m_internalPaths.size() + d->m_pins.size() +
|
|
|
|
d->m_placeLabels.size());
|
2017-10-23 09:45:58 +02:00
|
|
|
|
2018-04-03 10:15:58 +02:00
|
|
|
for (auto &record : d->m_customSARecords)
|
2017-10-23 09:45:58 +02:00
|
|
|
{
|
|
|
|
list.append(record.path);
|
|
|
|
}
|
|
|
|
|
2018-04-03 10:15:58 +02:00
|
|
|
for (auto &value : d->m_internalPaths)
|
2017-10-23 09:45:58 +02:00
|
|
|
{
|
|
|
|
list.append(value);
|
|
|
|
}
|
|
|
|
|
2018-04-03 10:15:58 +02:00
|
|
|
for (auto &value : d->m_pins)
|
2017-10-23 09:45:58 +02:00
|
|
|
{
|
|
|
|
list.append(value);
|
|
|
|
}
|
|
|
|
|
2018-04-03 10:15:58 +02:00
|
|
|
for (auto &value : d->m_placeLabels)
|
2017-10-23 09:45:58 +02:00
|
|
|
{
|
|
|
|
list.append(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-09 13:11:58 +01:00
|
|
|
/**
|
2016-11-25 14:35:52 +01:00
|
|
|
* @brief MissingNodes find missing nodes in detail. When we deleted object in detail and return this detail need
|
2016-11-09 13:11:58 +01:00
|
|
|
* understand, what nodes need make invisible.
|
|
|
|
* @param det changed detail.
|
|
|
|
* @return list with missing nodes.
|
|
|
|
*/
|
2016-11-25 15:12:33 +01:00
|
|
|
QVector<quint32> VPiece::MissingNodes(const VPiece &det) const
|
2016-11-09 13:11:58 +01:00
|
|
|
{
|
2016-11-28 09:47:36 +01:00
|
|
|
return d->m_path.MissingNodes(det.GetPath());
|
2016-11-09 13:11:58 +01:00
|
|
|
}
|
|
|
|
|
2016-11-25 15:12:33 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> VPiece::MissingCSAPath(const VPiece &det) const
|
|
|
|
{
|
2017-01-31 17:09:18 +01:00
|
|
|
QVector<quint32> oldCSARecords;
|
2016-11-25 15:12:33 +01:00
|
|
|
for (qint32 i = 0; i < d->m_customSARecords.size(); ++i)
|
|
|
|
{
|
2017-01-31 17:09:18 +01:00
|
|
|
oldCSARecords.append(d->m_customSARecords.at(i).path);
|
2016-11-25 15:12:33 +01:00
|
|
|
}
|
|
|
|
|
2017-01-31 17:09:18 +01:00
|
|
|
QVector<quint32> newCSARecords;
|
|
|
|
for (qint32 i = 0; i < det.GetCustomSARecords().size(); ++i)
|
2016-11-25 15:12:33 +01:00
|
|
|
{
|
2017-01-31 17:09:18 +01:00
|
|
|
newCSARecords.append(det.GetCustomSARecords().at(i).path);
|
2016-11-25 15:12:33 +01:00
|
|
|
}
|
|
|
|
|
2017-01-31 17:09:18 +01:00
|
|
|
return PieceMissingNodes(oldCSARecords, newCSARecords);
|
2016-11-25 15:12:33 +01:00
|
|
|
}
|
|
|
|
|
2016-11-11 16:55:02 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-12-03 17:01:39 +01:00
|
|
|
QVector<quint32> VPiece::MissingInternalPaths(const VPiece &det) const
|
|
|
|
{
|
2017-01-31 17:09:18 +01:00
|
|
|
return PieceMissingNodes(d->m_internalPaths, det.GetInternalPaths());
|
|
|
|
}
|
2016-12-03 17:01:39 +01:00
|
|
|
|
2017-01-31 17:09:18 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> VPiece::MissingPins(const VPiece &det) const
|
|
|
|
{
|
|
|
|
return PieceMissingNodes(d->m_pins, det.GetPins());
|
2016-12-03 17:01:39 +01:00
|
|
|
}
|
|
|
|
|
2017-10-15 11:25:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> VPiece::MissingPlaceLabels(const VPiece &det) const
|
|
|
|
{
|
|
|
|
return PieceMissingNodes(d->m_placeLabels, det.GetPlaceLabels());
|
|
|
|
}
|
|
|
|
|
2016-12-03 17:01:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-02-23 10:19:27 +01:00
|
|
|
void VPiece::SetPatternPieceData(const VPieceLabelData &data)
|
2017-01-12 14:51:08 +01:00
|
|
|
{
|
|
|
|
d->m_ppData = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief Returns full access to the pattern piece data object
|
|
|
|
* @return pattern piece data object
|
|
|
|
*/
|
2017-02-23 10:19:27 +01:00
|
|
|
VPieceLabelData &VPiece::GetPatternPieceData()
|
2017-01-12 14:51:08 +01:00
|
|
|
{
|
|
|
|
return d->m_ppData;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief Returns the read only reference to the pattern piece data object
|
|
|
|
* @return pattern piece data object
|
|
|
|
*/
|
2017-02-23 10:19:27 +01:00
|
|
|
const VPieceLabelData &VPiece::GetPatternPieceData() const
|
2017-01-12 14:51:08 +01:00
|
|
|
{
|
|
|
|
return d->m_ppData;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-02-23 10:26:25 +01:00
|
|
|
void VPiece::SetPatternInfo(const VPatternLabelData &info)
|
2017-01-12 14:51:08 +01:00
|
|
|
{
|
|
|
|
d->m_piPatternInfo = info;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief Returns full access to the pattern info geometry object
|
|
|
|
* @return pattern info geometry object
|
|
|
|
*/
|
2017-02-23 10:26:25 +01:00
|
|
|
VPatternLabelData &VPiece::GetPatternInfo()
|
2017-01-12 14:51:08 +01:00
|
|
|
{
|
|
|
|
return d->m_piPatternInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief Returns the read only reference to the pattern info geometry object
|
|
|
|
* @return pattern info geometry object
|
|
|
|
*/
|
2017-02-23 10:26:25 +01:00
|
|
|
const VPatternLabelData &VPiece::GetPatternInfo() const
|
2017-01-12 14:51:08 +01:00
|
|
|
{
|
|
|
|
return d->m_piPatternInfo;
|
|
|
|
}
|
|
|
|
|
2018-01-25 22:53:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPiece::SetGrainlineGeometry(const VGrainlineData &data)
|
|
|
|
{
|
|
|
|
d->m_glGrainline = data;
|
|
|
|
}
|
|
|
|
|
2017-01-12 14:51:08 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief VDetail::GetGrainlineGeometry full access to the grainline geometry object
|
|
|
|
* @return reference to grainline geometry object
|
|
|
|
*/
|
2017-02-23 10:33:17 +01:00
|
|
|
VGrainlineData &VPiece::GetGrainlineGeometry()
|
2017-01-12 14:51:08 +01:00
|
|
|
{
|
|
|
|
return d->m_glGrainline;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief VDetail::GetGrainlineGeometry returns the read-only reference to the grainline geometry object
|
|
|
|
* @return reference to grainline geometry object
|
|
|
|
*/
|
2017-02-23 10:33:17 +01:00
|
|
|
const VGrainlineData &VPiece::GetGrainlineGeometry() const
|
2017-01-12 14:51:08 +01:00
|
|
|
{
|
|
|
|
return d->m_glGrainline;
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<VPieceNode> VPiece::GetUnitedPath(const VContainer *data) const
|
|
|
|
{
|
|
|
|
SCASSERT(data != nullptr)
|
|
|
|
|
|
|
|
QVector<VPieceNode> united = d->m_path.GetNodes();
|
2017-04-05 12:22:33 +02:00
|
|
|
|
|
|
|
if (IsSeamAllowance() && IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
|
|
|
return united;
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
const QVector<CustomSARecord> records = FilterRecords(GetValidRecords());
|
|
|
|
|
|
|
|
for (int i = 0; i < records.size(); ++i)
|
|
|
|
{
|
|
|
|
if (records.at(i).includeType == PiecePathIncludeType::AsMainPath)
|
|
|
|
{
|
|
|
|
const int indexStartPoint = VPiecePath::indexOfNode(united, records.at(i).startPoint);
|
|
|
|
const int indexEndPoint = VPiecePath::indexOfNode(united, records.at(i).endPoint);
|
|
|
|
|
|
|
|
if (indexStartPoint == -1 || indexEndPoint == -1)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QVector<VPieceNode> midBefore = united.mid(0, indexStartPoint+1);
|
2018-01-15 15:20:29 +01:00
|
|
|
const QVector<VPieceNode> midAfter = united.mid(indexEndPoint, united.size() - midBefore.size());
|
2017-03-30 11:26:06 +02:00
|
|
|
|
|
|
|
QVector<VPieceNode> customNodes = data->GetPiecePath(records.at(i).path).GetNodes();
|
|
|
|
if (records.at(i).reverse)
|
|
|
|
{
|
|
|
|
customNodes = VGObject::GetReversePoints(customNodes);
|
2017-04-05 12:22:33 +02:00
|
|
|
}
|
2017-03-30 11:26:06 +02:00
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
for (int j = 0; j < customNodes.size(); ++j)
|
|
|
|
{
|
2017-03-30 11:26:06 +02:00
|
|
|
// Additionally reverse all curves
|
2017-04-05 12:22:33 +02:00
|
|
|
if (records.at(i).reverse)
|
|
|
|
{
|
|
|
|
// don't make a check because node point will ignore the change
|
2017-03-30 11:26:06 +02:00
|
|
|
customNodes[j].SetReverse(not customNodes.at(j).GetReverse());
|
|
|
|
}
|
2017-04-05 12:22:33 +02:00
|
|
|
|
|
|
|
// If seam allowance is built in main path user will not see a passmark provided by piece path
|
|
|
|
if (IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
|
|
|
customNodes[j].SetPassmark(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
customNodes[j].SetMainPathNode(false);
|
|
|
|
}
|
2017-03-30 11:26:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
united = midBefore + customNodes + midAfter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return united;
|
|
|
|
}
|
|
|
|
|
2017-01-12 14:51:08 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-29 13:10:53 +01:00
|
|
|
QVector<CustomSARecord> VPiece::GetValidRecords() const
|
2016-11-11 16:55:02 +01:00
|
|
|
{
|
2016-11-29 13:10:53 +01:00
|
|
|
QVector<CustomSARecord> records;
|
2018-09-27 14:16:01 +02:00
|
|
|
records.reserve(d->m_customSARecords.size());
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto &record : d->m_customSARecords)
|
2016-11-11 19:17:39 +01:00
|
|
|
{
|
2017-03-22 11:05:53 +01:00
|
|
|
const int indexStartPoint = d->m_path.indexOfNode(record.startPoint);
|
|
|
|
const int indexEndPoint = d->m_path.indexOfNode(record.endPoint);
|
2016-11-11 16:55:02 +01:00
|
|
|
|
2016-11-29 15:59:48 +01:00
|
|
|
if (record.startPoint > NULL_ID
|
|
|
|
&& record.path > NULL_ID
|
|
|
|
&& record.endPoint > NULL_ID
|
2017-03-22 11:05:53 +01:00
|
|
|
&& indexStartPoint != -1
|
|
|
|
&& not d->m_path.at(indexStartPoint).IsExcluded()
|
|
|
|
&& indexEndPoint != -1
|
2018-01-15 15:20:29 +01:00
|
|
|
&& not d->m_path.at(indexEndPoint).IsExcluded())
|
2016-11-11 19:17:39 +01:00
|
|
|
{
|
2016-11-29 13:10:53 +01:00
|
|
|
records.append(record);
|
2016-11-11 19:17:39 +01:00
|
|
|
}
|
|
|
|
}
|
2016-11-29 13:10:53 +01:00
|
|
|
return records;
|
|
|
|
}
|
2016-11-11 19:17:39 +01:00
|
|
|
|
2017-03-29 13:18:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<CustomSARecord> VPiece::FilterRecords(QVector<CustomSARecord> records) const
|
|
|
|
{
|
|
|
|
if (records.size() < 2)
|
|
|
|
{
|
|
|
|
return records;
|
|
|
|
}
|
|
|
|
|
2017-03-30 12:59:10 +02:00
|
|
|
// cppcheck-suppress variableScope
|
2017-03-29 13:18:33 +02:00
|
|
|
bool foundFilter = false;// Need in case "filter" will stay empty.
|
|
|
|
CustomSARecord filter;
|
|
|
|
int startIndex = d->m_path.CountNodes()-1;
|
|
|
|
|
|
|
|
for (int i = 0; i < records.size(); ++i)
|
|
|
|
{
|
|
|
|
const int indexStartPoint = d->m_path.indexOfNode(records.at(i).startPoint);
|
|
|
|
if (indexStartPoint < startIndex)
|
|
|
|
{
|
|
|
|
startIndex = i;
|
|
|
|
filter = records.at(i);
|
2017-04-06 14:50:15 +02:00
|
|
|
// cppcheck-suppress unreadVariable
|
2017-03-29 13:18:33 +02:00
|
|
|
foundFilter = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not foundFilter)
|
|
|
|
{
|
|
|
|
return records; // return as is
|
|
|
|
}
|
|
|
|
|
|
|
|
records.remove(startIndex);
|
|
|
|
|
|
|
|
QVector<CustomSARecord> secondRound;
|
2018-09-27 14:16:01 +02:00
|
|
|
secondRound.reserve(records.size());
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto &record : records)
|
2017-03-29 13:18:33 +02:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
const int indexStartPoint = d->m_path.indexOfNode(record.startPoint);
|
2017-03-29 13:18:33 +02:00
|
|
|
const int indexEndPoint = d->m_path.indexOfNode(filter.endPoint);
|
|
|
|
if (indexStartPoint > indexEndPoint)
|
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
secondRound.append(record);
|
2017-03-29 13:18:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<CustomSARecord> filtered;
|
|
|
|
filtered.append(filter);
|
|
|
|
|
|
|
|
filtered += FilterRecords(secondRound);
|
|
|
|
|
|
|
|
return filtered;
|
|
|
|
}
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-30 11:26:06 +02:00
|
|
|
QVector<VSAPoint> VPiece::GetNodeSAPoints(const QVector<VPieceNode> &path, int index, const VContainer *data) const
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
|
|
|
SCASSERT(data != nullptr)
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
if (index < 0 || index >= path.size())
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
|
|
|
return QVector<VSAPoint>();
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
const VPieceNode &node = path.at(index);
|
2017-03-28 12:09:00 +02:00
|
|
|
QVector<VSAPoint> points;
|
|
|
|
|
|
|
|
if (node.GetTypeTool() == Tool::NodePoint)
|
|
|
|
{
|
|
|
|
points.append(VPiecePath::PreparePointEkv(node, data));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
|
|
|
|
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
points += VPiecePath::CurveSeamAllowanceSegment(data, path, curve, index, node.GetReverse(), width);
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-30 11:26:06 +02:00
|
|
|
bool VPiece::GetPassmarkSAPoint(const QVector<VPieceNode> &path, int index, const VContainer *data,
|
|
|
|
VSAPoint &point) const
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
|
|
|
SCASSERT(data != nullptr)
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
const QVector<VSAPoint> points = GetNodeSAPoints(path, index, data);
|
2017-03-28 12:09:00 +02:00
|
|
|
|
|
|
|
if (points.isEmpty() || points.size() > 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
point = points.first();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-04-25 19:48:32 +02:00
|
|
|
bool VPiece::GetPassmarkPreviousSAPoints(const QVector<VPieceNode> &path, int index, const VSAPoint &passmarkSAPoint,
|
2018-09-29 21:01:13 +02:00
|
|
|
const VContainer *data, VSAPoint &point, int passmarkIndex) const
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
|
|
|
SCASSERT(data != nullptr)
|
|
|
|
|
2017-04-25 19:48:32 +02:00
|
|
|
const QVector<VSAPoint> points = GetNodeSAPoints(path, index, data);
|
2017-03-28 12:09:00 +02:00
|
|
|
|
2017-04-25 19:48:32 +02:00
|
|
|
if (points.isEmpty())
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2018-09-29 21:01:13 +02:00
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'.")
|
|
|
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
|
|
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
2017-04-25 19:48:32 +02:00
|
|
|
return false; // Something wrong
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool found = false;
|
2017-04-25 19:48:32 +02:00
|
|
|
int nodeIndex = points.size()-1;
|
2017-03-28 12:09:00 +02:00
|
|
|
do
|
|
|
|
{
|
2017-04-25 19:48:32 +02:00
|
|
|
const VSAPoint previous = points.at(nodeIndex);
|
2018-10-19 15:54:06 +02:00
|
|
|
if (not VFuzzyComparePoints(passmarkSAPoint, previous))
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2017-04-25 19:48:32 +02:00
|
|
|
point = previous;
|
2017-03-28 12:09:00 +02:00
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
--nodeIndex;
|
|
|
|
} while (nodeIndex >= 0 && not found);
|
|
|
|
|
|
|
|
if (not found)
|
|
|
|
{
|
2018-09-29 21:01:13 +02:00
|
|
|
// No warning here because of valid case of passmark collapse
|
2017-04-25 19:48:32 +02:00
|
|
|
return false; // Something wrong
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
2017-04-25 19:48:32 +02:00
|
|
|
return true;
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-04-25 10:42:08 +02:00
|
|
|
int VPiece::GetPassmarkNextSAPoints(const QVector<VPieceNode> &path, int index, const VSAPoint &passmarkSAPoint,
|
2018-09-29 21:01:13 +02:00
|
|
|
const VContainer *data, VSAPoint &point, int passmarkIndex) const
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2017-04-25 19:48:32 +02:00
|
|
|
SCASSERT(data != nullptr)
|
|
|
|
|
|
|
|
const QVector<VSAPoint> points = GetNodeSAPoints(path, index, data);
|
2017-03-28 12:09:00 +02:00
|
|
|
|
2017-04-25 19:48:32 +02:00
|
|
|
if (points.isEmpty())
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2018-09-29 21:01:13 +02:00
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'.")
|
|
|
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
|
|
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
2017-04-25 19:48:32 +02:00
|
|
|
return false; // Something wrong
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
int nodeIndex = 0;
|
|
|
|
do
|
|
|
|
{
|
2017-04-25 19:48:32 +02:00
|
|
|
const VSAPoint next = points.at(nodeIndex);
|
2018-10-19 15:54:06 +02:00
|
|
|
if (not VFuzzyComparePoints(passmarkSAPoint, next))
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2017-04-25 19:48:32 +02:00
|
|
|
point = next;
|
2017-03-28 12:09:00 +02:00
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
++nodeIndex;
|
|
|
|
|
2017-04-25 19:48:32 +02:00
|
|
|
} while (nodeIndex < points.size() && not found);
|
2017-03-28 12:09:00 +02:00
|
|
|
|
|
|
|
if (not found)
|
|
|
|
{
|
2018-09-29 21:01:13 +02:00
|
|
|
// No warning here because of valid case of passmark collapse
|
2017-04-25 19:48:32 +02:00
|
|
|
return false; // Something wrong
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
2017-04-25 19:48:32 +02:00
|
|
|
return true;
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-10-19 15:54:06 +02:00
|
|
|
bool VPiece::GetSeamPassmarkSAPoint(const VSAPoint &previousSAPoint, VSAPoint passmarkSAPoint,
|
2017-03-28 12:09:00 +02:00
|
|
|
const VSAPoint &nextSAPoint, const VContainer *data, QPointF &point) const
|
|
|
|
{
|
|
|
|
SCASSERT(data != nullptr)
|
|
|
|
|
2018-10-19 15:54:06 +02:00
|
|
|
// Correct distorsion
|
|
|
|
if (VGObject::IsPointOnLineSegment(passmarkSAPoint, previousSAPoint, nextSAPoint))
|
2017-04-18 20:39:13 +02:00
|
|
|
{
|
2018-10-19 15:54:06 +02:00
|
|
|
const QPointF p = VGObject::CorrectDistortion(passmarkSAPoint, previousSAPoint, nextSAPoint);
|
|
|
|
passmarkSAPoint.setX(p.x());
|
|
|
|
passmarkSAPoint.setY(p.y());
|
2017-04-18 20:39:13 +02:00
|
|
|
}
|
2017-03-28 12:09:00 +02:00
|
|
|
|
2018-10-19 15:54:06 +02:00
|
|
|
QVector<QPointF> ekvPoints;
|
|
|
|
ekvPoints = EkvPoint(ekvPoints, previousSAPoint, passmarkSAPoint, nextSAPoint, passmarkSAPoint,
|
|
|
|
ToPixel(GetSAWidth(), *data->GetPatternUnit()));
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
if (ekvPoints.isEmpty())
|
|
|
|
{ // Just in case
|
|
|
|
return false; // Something wrong
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ekvPoints.size() == 1 || ekvPoints.size() > 2)
|
|
|
|
{
|
|
|
|
point = ekvPoints.first();
|
|
|
|
}
|
|
|
|
else if (ekvPoints.size() == 2)
|
|
|
|
{
|
|
|
|
QLineF line = QLineF(ekvPoints.at(0), ekvPoints.at(1));
|
|
|
|
line.setLength(line.length()/2.);
|
|
|
|
point = line.p2();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-30 11:26:06 +02:00
|
|
|
bool VPiece::IsPassmarkVisible(const QVector<VPieceNode> &path, int passmarkIndex) const
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2017-03-30 11:26:06 +02:00
|
|
|
if (passmarkIndex < 0 || passmarkIndex >= path.size())
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
const VPieceNode &node = path.at(passmarkIndex);
|
2017-03-28 12:09:00 +02:00
|
|
|
if (node.GetTypeTool() != Tool::NodePoint || not node.IsPassmark() || node.IsExcluded())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
if (IsSeamAllowance() && IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
const QVector<CustomSARecord> records = FilterRecords(GetValidRecords());
|
|
|
|
if (records.isEmpty())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto &record : records)
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
if (record.includeType == PiecePathIncludeType::AsCustomSA)
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
const int indexStartPoint = VPiecePath::indexOfNode(path, record.startPoint);
|
|
|
|
const int indexEndPoint = VPiecePath::indexOfNode(path, record.endPoint);
|
2017-03-30 11:26:06 +02:00
|
|
|
if (passmarkIndex > indexStartPoint && passmarkIndex < indexEndPoint)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-30 11:26:06 +02:00
|
|
|
QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int previousIndex, int passmarkIndex,
|
2017-08-05 10:03:19 +02:00
|
|
|
int nextIndex, const VContainer *data,
|
|
|
|
const QVector<QPointF> &seamAllowance) const
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
|
|
|
SCASSERT(data != nullptr);
|
|
|
|
|
2017-03-30 11:26:06 +02:00
|
|
|
if (not IsPassmarkVisible(path, passmarkIndex))
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
|
|
|
return QVector<QLineF>();
|
|
|
|
}
|
|
|
|
|
|
|
|
VSAPoint passmarkSAPoint;
|
2017-03-30 11:26:06 +02:00
|
|
|
if (not GetPassmarkSAPoint(path, passmarkIndex, data, passmarkSAPoint))
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2018-09-28 13:29:10 +02:00
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'.")
|
|
|
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
|
|
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
|
|
|
return QVector<QLineF>();
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
|
|
|
|
2017-04-25 19:48:32 +02:00
|
|
|
VSAPoint previousSAPoint;
|
2018-09-29 21:01:13 +02:00
|
|
|
if (not GetPassmarkPreviousSAPoints(path, previousIndex, passmarkSAPoint, data, previousSAPoint, passmarkIndex))
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2018-09-29 18:36:55 +02:00
|
|
|
// No check here because it will cover valid cases
|
2017-03-28 12:09:00 +02:00
|
|
|
return QVector<QLineF>(); // Something wrong
|
|
|
|
}
|
|
|
|
|
2017-04-25 19:48:32 +02:00
|
|
|
VSAPoint nextSAPoint;
|
2018-09-29 21:01:13 +02:00
|
|
|
if (not GetPassmarkNextSAPoints(path, nextIndex, passmarkSAPoint, data, nextSAPoint, passmarkIndex))
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2018-09-29 18:36:55 +02:00
|
|
|
// No check here because it will cover valid cases
|
2017-03-28 12:09:00 +02:00
|
|
|
return QVector<QLineF>(); // Something wrong
|
|
|
|
}
|
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
if (not IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
|
|
|
QVector<QLineF> lines;
|
2017-08-05 10:03:19 +02:00
|
|
|
lines += SAPassmark(path, previousSAPoint, passmarkSAPoint, nextSAPoint, data, passmarkIndex, seamAllowance);
|
2017-04-25 10:42:08 +02:00
|
|
|
if (qApp->Settings()->IsDoublePassmark()
|
2017-05-16 14:16:50 +02:00
|
|
|
&& not IsHideMainPath()
|
2017-04-25 10:42:08 +02:00
|
|
|
&& path.at(passmarkIndex).IsMainPathNode()
|
2017-04-26 10:22:42 +02:00
|
|
|
&& path.at(passmarkIndex).GetPassmarkAngleType() != PassmarkAngleType::Intersection
|
2017-09-28 20:18:13 +02:00
|
|
|
&& path.at(passmarkIndex).GetPassmarkAngleType() != PassmarkAngleType::IntersectionOnlyLeft
|
|
|
|
&& path.at(passmarkIndex).GetPassmarkAngleType() != PassmarkAngleType::IntersectionOnlyRight
|
2018-02-04 11:35:27 +01:00
|
|
|
&& path.at(passmarkIndex).GetPassmarkAngleType() != PassmarkAngleType::Intersection2
|
|
|
|
&& path.at(passmarkIndex).GetPassmarkAngleType() != PassmarkAngleType::Intersection2OnlyLeft
|
|
|
|
&& path.at(passmarkIndex).GetPassmarkAngleType() != PassmarkAngleType::Intersection2OnlyRight
|
2017-04-26 10:22:42 +02:00
|
|
|
&& path.at(passmarkIndex).IsShowSecondPassmark())
|
2017-04-05 12:22:33 +02:00
|
|
|
{
|
2017-04-25 19:48:32 +02:00
|
|
|
lines += BuiltInSAPassmark(path, previousSAPoint, passmarkSAPoint, nextSAPoint, data, passmarkIndex);
|
2017-04-05 12:22:33 +02:00
|
|
|
}
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-25 19:48:32 +02:00
|
|
|
return BuiltInSAPassmark(path, previousSAPoint, passmarkSAPoint, nextSAPoint, data, passmarkIndex);
|
2017-04-05 12:22:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-04-25 19:48:32 +02:00
|
|
|
QVector<QLineF> VPiece::SAPassmark(const QVector<VPieceNode> &path, VSAPoint &previousSAPoint,
|
|
|
|
const VSAPoint &passmarkSAPoint, VSAPoint &nextSAPoint, const VContainer *data,
|
2017-08-05 10:03:19 +02:00
|
|
|
int passmarkIndex, const QVector<QPointF> &seamAllowance) const
|
2017-04-05 12:22:33 +02:00
|
|
|
{
|
2018-09-27 14:13:43 +02:00
|
|
|
if (seamAllowance.size() < 2)
|
|
|
|
{
|
2018-09-28 13:29:10 +02:00
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Seam allowance is "
|
|
|
|
"empty.").arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
|
|
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
2018-09-27 14:13:43 +02:00
|
|
|
return QVector<QLineF>(); // Something wrong
|
|
|
|
}
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
QPointF seamPassmarkSAPoint;
|
|
|
|
if (not GetSeamPassmarkSAPoint(previousSAPoint, passmarkSAPoint, nextSAPoint, data, seamPassmarkSAPoint))
|
|
|
|
{
|
2018-09-28 13:29:10 +02:00
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find "
|
|
|
|
"position for a notch.")
|
|
|
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
|
|
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
2017-03-28 12:09:00 +02:00
|
|
|
return QVector<QLineF>(); // Something wrong
|
|
|
|
}
|
|
|
|
|
2018-09-28 12:43:03 +02:00
|
|
|
if (not FixNotchPoint(seamAllowance, passmarkSAPoint, &seamPassmarkSAPoint))
|
|
|
|
{
|
2018-09-28 13:29:10 +02:00
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Unable to fix a "
|
|
|
|
"notch position.")
|
|
|
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
|
|
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
2018-09-28 12:43:03 +02:00
|
|
|
}
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
|
|
|
|
|
|
|
QVector<QLineF> passmarksLines;
|
|
|
|
|
2018-09-13 16:31:14 +02:00
|
|
|
qreal passmarkLength = passmarkSAPoint.MaxLocalSA(width) * passmarkFactor;
|
2017-04-05 12:22:33 +02:00
|
|
|
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
2017-03-30 11:26:06 +02:00
|
|
|
const VPieceNode &node = path.at(passmarkIndex);
|
2018-02-04 11:35:27 +01:00
|
|
|
|
|
|
|
auto PassmarkIntersection = [&passmarksLines, passmarkSAPoint, node](QLineF line,
|
|
|
|
const QVector<QPointF> &seamPoints, qreal width)
|
|
|
|
{
|
|
|
|
line.setLength(line.length()*100); // Hope 100 is enough
|
|
|
|
|
|
|
|
const QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamPoints, line);
|
|
|
|
if (not intersections.isEmpty())
|
|
|
|
{
|
|
|
|
line = QLineF(intersections.last(), passmarkSAPoint);
|
|
|
|
line.setLength(qMin(width * passmarkFactor, maxPassmarkLength));
|
|
|
|
|
|
|
|
passmarksLines += CreatePassmarkLines(node.GetPassmarkLineType(), node.GetPassmarkAngleType(), line);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
if (node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward)
|
|
|
|
{
|
|
|
|
QLineF line = QLineF(seamPassmarkSAPoint, passmarkSAPoint);
|
|
|
|
line.setLength(passmarkLength);
|
2017-04-05 12:22:33 +02:00
|
|
|
passmarksLines += CreatePassmarkLines(node.GetPassmarkLineType(), node.GetPassmarkAngleType(), line);
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
2017-04-25 10:42:08 +02:00
|
|
|
else if (node.GetPassmarkAngleType() == PassmarkAngleType::Bisector)
|
2017-03-28 12:09:00 +02:00
|
|
|
{
|
2017-04-25 19:48:32 +02:00
|
|
|
const QLineF bigLine1 = ParallelLine(previousSAPoint, passmarkSAPoint, width );
|
|
|
|
const QLineF bigLine2 = ParallelLine(passmarkSAPoint, nextSAPoint, width );
|
|
|
|
|
2017-03-28 12:09:00 +02:00
|
|
|
QLineF edge1 = QLineF(seamPassmarkSAPoint, bigLine1.p1());
|
|
|
|
QLineF edge2 = QLineF(seamPassmarkSAPoint, bigLine2.p2());
|
|
|
|
|
|
|
|
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.);
|
|
|
|
edge1.setLength(passmarkLength);
|
2017-04-05 12:22:33 +02:00
|
|
|
|
|
|
|
passmarksLines += CreatePassmarkLines(node.GetPassmarkLineType(), node.GetPassmarkAngleType(), edge1);
|
2017-03-28 12:09:00 +02:00
|
|
|
}
|
2017-09-28 20:18:13 +02:00
|
|
|
else if (node.GetPassmarkAngleType() == PassmarkAngleType::Intersection
|
|
|
|
|| node.GetPassmarkAngleType() == PassmarkAngleType::IntersectionOnlyLeft
|
|
|
|
|| node.GetPassmarkAngleType() == PassmarkAngleType::IntersectionOnlyRight)
|
2017-04-25 10:42:08 +02:00
|
|
|
{
|
2017-09-28 20:18:13 +02:00
|
|
|
if (node.GetPassmarkAngleType() == PassmarkAngleType::Intersection
|
|
|
|
|| node.GetPassmarkAngleType() == PassmarkAngleType::IntersectionOnlyRight)
|
2017-04-25 10:42:08 +02:00
|
|
|
{
|
|
|
|
// first passmark
|
2018-09-27 14:13:43 +02:00
|
|
|
PassmarkIntersection(QLineF(previousSAPoint, passmarkSAPoint), seamAllowance,
|
2018-02-04 11:35:27 +01:00
|
|
|
passmarkSAPoint.GetSAAfter(width));
|
2017-04-25 10:42:08 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 20:18:13 +02:00
|
|
|
if (node.GetPassmarkAngleType() == PassmarkAngleType::Intersection
|
|
|
|
|| node.GetPassmarkAngleType() == PassmarkAngleType::IntersectionOnlyLeft)
|
2017-04-25 10:42:08 +02:00
|
|
|
{
|
|
|
|
// second passmark
|
2018-09-27 14:13:43 +02:00
|
|
|
PassmarkIntersection(QLineF(nextSAPoint, passmarkSAPoint), seamAllowance,
|
2018-02-04 11:35:27 +01:00
|
|
|
passmarkSAPoint.GetSABefore(width));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (node.GetPassmarkAngleType() == PassmarkAngleType::Intersection2
|
|
|
|
|| node.GetPassmarkAngleType() == PassmarkAngleType::Intersection2OnlyLeft
|
|
|
|
|| node.GetPassmarkAngleType() == PassmarkAngleType::Intersection2OnlyRight)
|
|
|
|
{
|
|
|
|
if (node.GetPassmarkAngleType() == PassmarkAngleType::Intersection2
|
|
|
|
|| node.GetPassmarkAngleType() == PassmarkAngleType::Intersection2OnlyRight)
|
|
|
|
{
|
|
|
|
// first passmark
|
|
|
|
QLineF line(passmarkSAPoint, nextSAPoint);
|
|
|
|
line.setAngle(line.angle()+90);
|
2018-09-27 14:13:43 +02:00
|
|
|
PassmarkIntersection(line, seamAllowance, passmarkSAPoint.GetSAAfter(width));
|
2018-02-04 11:35:27 +01:00
|
|
|
}
|
2017-04-25 10:42:08 +02:00
|
|
|
|
2018-02-04 11:35:27 +01:00
|
|
|
if (node.GetPassmarkAngleType() == PassmarkAngleType::Intersection2
|
|
|
|
|| node.GetPassmarkAngleType() == PassmarkAngleType::Intersection2OnlyLeft)
|
|
|
|
{
|
|
|
|
// second passmark
|
|
|
|
QLineF line(passmarkSAPoint, previousSAPoint);
|
|
|
|
line.setAngle(line.angle()-90);
|
2018-09-27 14:13:43 +02:00
|
|
|
PassmarkIntersection(line, seamAllowance, passmarkSAPoint.GetSABefore(width));
|
2017-04-25 10:42:08 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-28 12:09:00 +02:00
|
|
|
|
|
|
|
return passmarksLines;
|
|
|
|
}
|
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QLineF> VPiece::BuiltInSAPassmark(const QVector<VPieceNode> &path, const VSAPoint &previousSAPoint,
|
|
|
|
const VSAPoint &passmarkSAPoint, const VSAPoint &nextSAPoint,
|
|
|
|
const VContainer *data, int passmarkIndex) const
|
|
|
|
{
|
|
|
|
QVector<QLineF> passmarksLines;
|
|
|
|
|
|
|
|
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
2018-09-13 16:31:14 +02:00
|
|
|
qreal passmarkLength = passmarkSAPoint.MaxLocalSA(width) * passmarkFactor;
|
2017-04-05 12:22:33 +02:00
|
|
|
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
|
|
|
|
|
|
|
QLineF edge1 = QLineF(passmarkSAPoint, previousSAPoint);
|
|
|
|
QLineF edge2 = QLineF(passmarkSAPoint, nextSAPoint);
|
|
|
|
|
|
|
|
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.);
|
|
|
|
edge1.setLength(passmarkLength);
|
|
|
|
|
|
|
|
const VPieceNode &node = path.at(passmarkIndex);
|
|
|
|
passmarksLines += CreatePassmarkLines(node.GetPassmarkLineType(), node.GetPassmarkAngleType(), edge1);
|
|
|
|
|
|
|
|
return passmarksLines;
|
|
|
|
}
|
|
|
|
|
2016-11-29 13:10:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VPiece::IsCSAStart(const QVector<CustomSARecord> &records, quint32 id)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < records.size(); ++i)
|
|
|
|
{
|
|
|
|
if (records.at(i).startPoint == id)
|
2016-11-11 19:17:39 +01:00
|
|
|
{
|
2016-11-29 13:10:53 +01:00
|
|
|
return i;
|
2016-11-11 19:17:39 +01:00
|
|
|
}
|
2016-11-11 16:55:02 +01:00
|
|
|
}
|
2016-11-29 13:10:53 +01:00
|
|
|
|
|
|
|
return -1;
|
2016-11-11 16:55:02 +01:00
|
|
|
}
|