2019-05-08 14:19:03 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vpassmark.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 1 5, 2019
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentina project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2019 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2019-05-08 14:19:03 +02:00
|
|
|
**
|
|
|
|
** 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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
2020-07-10 19:15:19 +02:00
|
|
|
#include <QPainterPath>
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
#include "../ifc/exception/vexceptioninvalidnotch.h"
|
|
|
|
#include "../vgeometry/vabstractcurve.h"
|
|
|
|
#include "../vgeometry/varc.h"
|
2019-11-03 09:01:32 +01:00
|
|
|
#include "../vlayout/vrawsapoint.h"
|
2023-05-11 15:23:57 +02:00
|
|
|
#include "../vmisc/compatibility.h"
|
2023-05-09 17:59:32 +02:00
|
|
|
#include "../vmisc/testpath.h" // do not remove
|
2023-05-06 19:01:15 +02:00
|
|
|
#include "../vmisc/vabstractvalapplication.h"
|
2023-05-09 17:59:32 +02:00
|
|
|
#include "../vpatterndb/testpassmark.h" // do not remove
|
2023-05-06 19:01:15 +02:00
|
|
|
#include "vgeometrydef.h"
|
|
|
|
#include "vpassmark.h"
|
2023-05-02 16:38:30 +02:00
|
|
|
|
|
|
|
#include <QJsonObject>
|
2023-05-09 17:59:57 +02:00
|
|
|
#include <QtMath>
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2019-05-27 13:57:36 +02:00
|
|
|
const qreal VPassmark::passmarkRadiusFactor = 0.45;
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
namespace
|
|
|
|
{
|
2023-05-08 16:50:22 +02:00
|
|
|
const qreal passmarkGap = MmToPixel(1.5);
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto GetSeamPassmarkSAPoint(const VPiecePassmarkData &passmarkData, const QVector<QPointF> &seamAllowance,
|
|
|
|
QPointF &point) -> PassmarkStatus
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
bool needRollback = false; // no need for rollback
|
2019-11-03 09:01:32 +01:00
|
|
|
QVector<VRawSAPoint> ekvPoints;
|
2019-05-08 14:19:03 +02:00
|
|
|
ekvPoints = VAbstractPiece::EkvPoint(ekvPoints, passmarkData.previousSAPoint, passmarkData.passmarkSAPoint,
|
|
|
|
passmarkData.nextSAPoint, passmarkData.passmarkSAPoint, passmarkData.saWidth,
|
|
|
|
&needRollback);
|
|
|
|
|
|
|
|
if (needRollback && not seamAllowance.isEmpty())
|
|
|
|
{
|
|
|
|
ekvPoints.clear();
|
2023-08-12 09:31:10 +02:00
|
|
|
ekvPoints += VRawSAPoint(seamAllowance.at(seamAllowance.size() - 1));
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ekvPoints.isEmpty())
|
2023-08-12 09:31:10 +02:00
|
|
|
{ // Just in case
|
2019-05-08 14:19:03 +02:00
|
|
|
return PassmarkStatus::Error; // Something wrong
|
|
|
|
}
|
|
|
|
|
2023-08-12 11:03:28 +02:00
|
|
|
point = ekvPoints.constFirst(); // NOLINT(cppcoreguidelines-slicing)
|
2019-05-08 14:19:03 +02:00
|
|
|
return needRollback ? PassmarkStatus::Rollback : PassmarkStatus::Common;
|
|
|
|
}
|
|
|
|
|
2019-05-27 16:05:42 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto PointsToSegments(const QVector<QPointF> &points) -> QVector<QLineF>
|
|
|
|
{
|
|
|
|
QVector<QLineF> lines;
|
|
|
|
if (points.size() >= 2)
|
|
|
|
{
|
|
|
|
lines.reserve(points.size() - 1);
|
2023-08-12 09:31:10 +02:00
|
|
|
for (int i = 0; i < points.size() - 1; ++i)
|
2023-05-06 19:01:15 +02:00
|
|
|
{
|
2023-08-12 09:31:10 +02:00
|
|
|
QLineF segment = QLineF(points.at(i), points.at(i + 1));
|
2023-05-06 19:01:15 +02:00
|
|
|
if (segment.length() > 0)
|
|
|
|
{
|
|
|
|
lines.append(segment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto PassmarkLength(const VPiecePassmarkData &passmarkData, qreal width, bool &ok) -> qreal
|
2019-05-27 16:05:42 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
auto ValidateLength = [passmarkData](qreal length)
|
|
|
|
{
|
|
|
|
if (length <= accuracyPointOnLine)
|
|
|
|
{
|
|
|
|
const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less "
|
|
|
|
"than minimal allowed.")
|
|
|
|
.arg(passmarkData.nodeName, passmarkData.pieceName);
|
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VException(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
qreal length = 0;
|
|
|
|
if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength())
|
|
|
|
{
|
|
|
|
if (passmarkData.globalPassmarkLength > accuracyPointOnLine)
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
return passmarkData.globalPassmarkLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
length = qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength);
|
|
|
|
if (not ValidateLength(length))
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok = true;
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
length = passmarkData.passmarkSAPoint.GetPasskmarkLength();
|
|
|
|
if (not ValidateLength(length))
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok = true;
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto PassmarkAngle(const VPiecePassmarkData &passmarkData, qreal angle) -> qreal
|
|
|
|
{
|
|
|
|
return passmarkData.passmarkSAPoint.IsManualPasskmarkAngle() ? passmarkData.passmarkSAPoint.GetPasskmarkAngle()
|
|
|
|
: angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto PassmarkWidth(const VPiecePassmarkData &passmarkData, qreal width) -> qreal
|
|
|
|
{
|
|
|
|
auto ValidateWidth = [passmarkData](qreal width)
|
|
|
|
{
|
|
|
|
if (qAbs(width) <= accuracyPointOnLine)
|
|
|
|
{
|
|
|
|
const QString errorMsg =
|
|
|
|
QObject::tr("Error: notch for point '%1' in piece '%2'. Width is less than minimal allowed.")
|
|
|
|
.arg(passmarkData.nodeName, passmarkData.pieceName);
|
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VException(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (not passmarkData.passmarkSAPoint.IsManualPasskmarkWidth())
|
|
|
|
{
|
|
|
|
if (qAbs(passmarkData.globalPassmarkWidth) > accuracyPointOnLine)
|
|
|
|
{
|
|
|
|
return passmarkData.globalPassmarkWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
ValidateWidth(width);
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
ValidateWidth(passmarkData.passmarkSAPoint.GetPasskmarkWidth());
|
|
|
|
return passmarkData.passmarkSAPoint.GetPasskmarkWidth();
|
|
|
|
}
|
|
|
|
|
2023-05-11 17:21:19 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto FixNotchPoint(const QVector<QPointF> &seamAllowance, const VPiecePassmarkData &data, QPointF *notch) -> bool
|
|
|
|
{
|
|
|
|
QLineF axis = QLineF(data.passmarkSAPoint, *notch);
|
|
|
|
|
|
|
|
if (data.passmarkAngleType == PassmarkAngleType::Straightforward)
|
|
|
|
{
|
|
|
|
axis.setAngle(PassmarkAngle(data, axis.angle()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Point is on seam allowance
|
|
|
|
if (VAbstractCurve::IsPointOnCurve(seamAllowance, *notch))
|
|
|
|
{ // Fixing distortion
|
|
|
|
axis.setLength(axis.length() + accuracyPointOnLine * 10);
|
|
|
|
const QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(seamAllowance, axis);
|
|
|
|
if (points.size() == 1)
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
*notch = points.constFirst();
|
2023-05-11 17:21:19 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Point is not on seam allowance
|
|
|
|
axis.setLength(ToPixel(500, Unit::Cm));
|
|
|
|
const QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(seamAllowance, axis);
|
|
|
|
|
|
|
|
if (points.empty())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (points.size() == 1)
|
|
|
|
{
|
|
|
|
*notch = points.at(0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMap<qreal, int> forward;
|
|
|
|
|
|
|
|
for (qint32 i = 0; i < points.size(); ++i)
|
|
|
|
{
|
|
|
|
if (points.at(i) == data.passmarkSAPoint)
|
|
|
|
{ // Always seek unique intersection
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QLineF length(data.passmarkSAPoint, 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());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto CreateOnePassmarkLines(const VPiecePassmarkData &passmarkData, const QLineF &line) -> QVector<QLineF>
|
|
|
|
{
|
|
|
|
Q_UNUSED(passmarkData);
|
2023-05-08 16:50:22 +02:00
|
|
|
return {line};
|
2019-05-27 16:05:42 +02:00
|
|
|
}
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto CreateTwoPassmarkLines(const VPiecePassmarkData &passmarkData, const QLineF &line,
|
|
|
|
const QVector<QPointF> &seamAllowance) -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
const qreal width = PassmarkWidth(passmarkData, passmarkGap);
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
QPointF l1p1;
|
|
|
|
{
|
|
|
|
QLineF line1 = line;
|
|
|
|
line1.setAngle(line1.angle() + 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
line1.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
l1p1 = line1.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p1;
|
|
|
|
{
|
|
|
|
QLineF line2 = line;
|
|
|
|
line2.setAngle(line2.angle() - 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
line2.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
l2p1 = line2.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l1p2;
|
|
|
|
{
|
|
|
|
QLineF line1 = QLineF(line.p2(), line.p1());
|
|
|
|
line1.setAngle(line1.angle() - 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
line1.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
l1p2 = line1.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p2;
|
|
|
|
{
|
|
|
|
QLineF line2 = QLineF(line.p2(), line.p1());
|
|
|
|
line2.setAngle(line2.angle() + 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
line2.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
l2p2 = line2.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QLineF> lines;
|
2019-05-27 13:57:36 +02:00
|
|
|
QLineF seg = VPassmark::FindIntersection(QLineF(l1p2, l1p1), seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
lines.append(QLineF(seg.p2(), seg.p1()));
|
|
|
|
|
2019-05-27 13:57:36 +02:00
|
|
|
seg = VPassmark::FindIntersection(QLineF(l2p2, l2p1), seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
lines.append(QLineF(seg.p2(), seg.p1()));
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto CreateThreePassmarkLines(const VPiecePassmarkData &passmarkData, const QLineF &line,
|
|
|
|
const QVector<QPointF> &seamAllowance) -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
const qreal width = PassmarkWidth(passmarkData, passmarkGap);
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
QPointF l1p1;
|
|
|
|
{
|
|
|
|
QLineF line1 = line;
|
|
|
|
line1.setAngle(line1.angle() + 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
line1.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
l1p1 = line1.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p1;
|
|
|
|
{
|
|
|
|
QLineF line2 = line;
|
|
|
|
line2.setAngle(line2.angle() - 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
line2.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
l2p1 = line2.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l1p2;
|
|
|
|
{
|
|
|
|
QLineF line1 = QLineF(line.p2(), line.p1());
|
|
|
|
line1.setAngle(line1.angle() - 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
line1.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
l1p2 = line1.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p2;
|
|
|
|
{
|
|
|
|
QLineF line2 = QLineF(line.p2(), line.p1());
|
|
|
|
line2.setAngle(line2.angle() + 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
line2.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
l2p2 = line2.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QLineF> lines;
|
2019-05-27 13:57:36 +02:00
|
|
|
QLineF seg = VPassmark::FindIntersection(QLineF(l1p2, l1p1), seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
lines.append(QLineF(seg.p2(), seg.p1()));
|
|
|
|
|
|
|
|
lines.append(line);
|
|
|
|
|
2019-05-27 13:57:36 +02:00
|
|
|
seg = VPassmark::FindIntersection(QLineF(l2p2, l2p1), seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
lines.append(QLineF(seg.p2(), seg.p1()));
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto CreateTMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &line) -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
const qreal width = PassmarkWidth(passmarkData, line.length() * 0.75);
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
QPointF p1;
|
|
|
|
{
|
|
|
|
QLineF tmpLine = QLineF(line.p2(), line.p1());
|
|
|
|
tmpLine.setAngle(tmpLine.angle() - 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
tmpLine.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
p1 = tmpLine.p2();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF p2;
|
|
|
|
{
|
|
|
|
QLineF tmpLine = QLineF(line.p2(), line.p1());
|
|
|
|
tmpLine.setAngle(tmpLine.angle() + 90);
|
2023-05-06 19:01:15 +02:00
|
|
|
tmpLine.setLength(width / 2.);
|
2019-05-08 14:19:03 +02:00
|
|
|
p2 = tmpLine.p2();
|
|
|
|
}
|
|
|
|
|
2024-01-23 14:57:23 +01:00
|
|
|
return {line, {QLineF(p1, p2).center(), p2}, {p2, p1}};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto CreateExternalVMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &line) -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
constexpr qreal defAngle = 35;
|
|
|
|
const qreal defWidth = line.length() * qTan(qDegreesToRadians(defAngle));
|
|
|
|
const qreal width = PassmarkWidth(passmarkData, defWidth * 2.);
|
|
|
|
const qreal angle = qRadiansToDegrees(qAtan(qAbs(width) / 2. / line.length()));
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
QLineF l1 = line;
|
2023-05-06 19:01:15 +02:00
|
|
|
l1.setAngle(l1.angle() - angle);
|
2019-05-08 14:19:03 +02:00
|
|
|
|
|
|
|
QLineF l2 = line;
|
2023-05-06 19:01:15 +02:00
|
|
|
l2.setAngle(l2.angle() + angle);
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-11-30 10:51:14 +01:00
|
|
|
return {{l1.p2(), l1.p1()}, l2};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto CreateInternalVMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &line,
|
|
|
|
const QVector<QPointF> &seamAllowance) -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
constexpr qreal defAngle = 35;
|
|
|
|
const qreal defWidth = line.length() * qTan(qDegreesToRadians(defAngle));
|
|
|
|
const qreal width = PassmarkWidth(passmarkData, defWidth * 2.);
|
|
|
|
const qreal angle = qRadiansToDegrees(qAtan(qAbs(width) / 2. / line.length()));
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
QLineF l1 = QLineF(line.p2(), line.p1());
|
2023-05-06 19:01:15 +02:00
|
|
|
l1.setAngle(l1.angle() + angle);
|
|
|
|
l1 = VPassmark::FindIntersection(l1, seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
|
|
|
|
QLineF l2 = QLineF(line.p2(), line.p1());
|
2023-05-06 19:01:15 +02:00
|
|
|
l2.setAngle(l2.angle() - angle);
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
return {{l1.p2(), l1.p1()}, VPassmark::FindIntersection(l2, seamAllowance)};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto CreateUMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &line,
|
|
|
|
const QVector<QPointF> &seamAllowance) -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
const qreal defWidth = line.length() * VPassmark::passmarkRadiusFactor * 2;
|
|
|
|
const qreal width = PassmarkWidth(passmarkData, defWidth);
|
|
|
|
const qreal radius = width / 2.;
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
QVector<QPointF> points;
|
2019-05-27 16:05:42 +02:00
|
|
|
QLineF baseLine = line;
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
QPointF l1p1;
|
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
QLineF line = baseLine;
|
|
|
|
line.setAngle(line.angle() - 90);
|
|
|
|
line.setLength(radius);
|
|
|
|
l1p1 = line.p2();
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p1;
|
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
QLineF line = baseLine;
|
|
|
|
line.setAngle(line.angle() + 90);
|
|
|
|
line.setLength(radius);
|
|
|
|
l2p1 = line.p2();
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
if (baseLine.length() - radius > accuracyPointOnLine)
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
baseLine.setLength(baseLine.length() - radius); // keep defined depth
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
QPointF l1p2;
|
|
|
|
{
|
|
|
|
QLineF line = QLineF(baseLine.p2(), baseLine.p1());
|
|
|
|
line.setAngle(line.angle() + 90);
|
|
|
|
line.setLength(radius);
|
|
|
|
l1p2 = line.p2();
|
|
|
|
}
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
QPointF l2p2;
|
|
|
|
{
|
|
|
|
QLineF line = QLineF(baseLine.p2(), baseLine.p1());
|
|
|
|
line.setAngle(line.angle() - 90);
|
|
|
|
line.setLength(radius);
|
|
|
|
l2p2 = line.p2();
|
|
|
|
}
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
QLineF seg = VPassmark::FindIntersection(QLineF(l1p2, l1p1), seamAllowance);
|
|
|
|
seg = QLineF(seg.p2(), seg.p1());
|
|
|
|
points.append(seg.p1());
|
|
|
|
points.append(seg.p2());
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-11-22 12:59:50 +01:00
|
|
|
const qreal f1 = QLineF(baseLine.p2(), l1p2).angle();
|
|
|
|
const qreal f2 = QLineF(baseLine.p2(), l2p2).angle();
|
|
|
|
VArc arc(VPointF(baseLine.p2()), radius, f1, f2);
|
|
|
|
arc.SetApproximationScale(VArc::OptimalApproximationScale(radius, f1, f2, 0.3));
|
2023-05-06 19:01:15 +02:00
|
|
|
points += arc.GetPoints();
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
seg = VPassmark::FindIntersection(QLineF(l2p2, l2p1), seamAllowance);
|
|
|
|
points.append(seg.p1());
|
|
|
|
points.append(seg.p2());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-22 12:59:50 +01:00
|
|
|
const qreal f1 = QLineF(baseLine.p1(), l1p1).angle();
|
|
|
|
const qreal f2 = QLineF(baseLine.p1(), l2p1).angle();
|
|
|
|
VArc arc(VPointF(baseLine.p1()), radius, f1, f2);
|
|
|
|
arc.SetApproximationScale(VArc::OptimalApproximationScale(radius, f1, f2, 0.3));
|
2023-05-06 19:01:15 +02:00
|
|
|
points += arc.GetPoints();
|
|
|
|
}
|
2019-05-08 14:19:03 +02:00
|
|
|
|
|
|
|
return PointsToSegments(points);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto CreateBoxMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &line,
|
|
|
|
const QVector<QPointF> &seamAllowance) -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
const qreal defWidth = line.length() * VPassmark::passmarkRadiusFactor;
|
|
|
|
const qreal width = PassmarkWidth(passmarkData, defWidth);
|
2019-05-08 14:19:03 +02:00
|
|
|
|
|
|
|
QPointF l1p1;
|
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
QLineF tmp = line;
|
|
|
|
tmp.setAngle(tmp.angle() - 90);
|
|
|
|
tmp.setLength(width / 2.);
|
|
|
|
l1p1 = tmp.p2();
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
QPointF l1p2;
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
QLineF tmp = QLineF(line.p2(), line.p1());
|
|
|
|
tmp.setAngle(tmp.angle() + 90);
|
|
|
|
tmp.setLength(width / 2.);
|
|
|
|
l1p2 = tmp.p2();
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
QPointF l2p1;
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
QLineF tmp = line;
|
|
|
|
tmp.setAngle(tmp.angle() + 90);
|
|
|
|
tmp.setLength(width / 2.);
|
|
|
|
l2p1 = tmp.p2();
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QPointF l2p2;
|
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
QLineF tmp = QLineF(line.p2(), line.p1());
|
|
|
|
tmp.setAngle(tmp.angle() - 90);
|
|
|
|
tmp.setLength(width / 2.);
|
|
|
|
l2p2 = tmp.p2();
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QPointF> points;
|
|
|
|
|
2019-05-27 13:57:36 +02:00
|
|
|
QLineF seg = VPassmark::FindIntersection(QLineF(l1p2, l1p1), seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
points.append(seg.p2());
|
|
|
|
points.append(seg.p1());
|
|
|
|
|
2019-05-27 13:57:36 +02:00
|
|
|
seg = VPassmark::FindIntersection(QLineF(l2p2, l2p1), seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
points.append(seg.p1());
|
|
|
|
points.append(seg.p2());
|
|
|
|
|
|
|
|
return PointsToSegments(points);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-06 19:01:15 +02:00
|
|
|
auto CreateCheckMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &line,
|
|
|
|
const QVector<QPointF> &seamAllowance) -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
constexpr qreal defAngle = 45;
|
2023-05-10 17:07:58 +02:00
|
|
|
qreal defWidth = qAbs(line.length() * qTan(qDegreesToRadians(defAngle)));
|
2019-05-27 13:57:36 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
if (not passmarkData.passmarkSAPoint.IsPassmarkClockwiseOpening())
|
2019-05-27 16:05:42 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
defWidth *= -1;
|
2021-05-10 15:39:17 +02:00
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
const qreal width = PassmarkWidth(passmarkData, defWidth);
|
|
|
|
const qreal angle = qRadiansToDegrees(qAtan(qAbs(width) / line.length()));
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
if (width > 0)
|
|
|
|
{ // clockwise
|
|
|
|
QLineF l1(line.p2(), line.p1());
|
2023-11-28 15:40:27 +01:00
|
|
|
l1.setAngle(l1.angle() + angle);
|
2023-05-06 19:01:15 +02:00
|
|
|
l1 = VPassmark::FindIntersection(l1, seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
return {{l1.p2(), l1.p1()}, {line.p2(), line.p1()}};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
QLineF l2(line.p2(), line.p1());
|
2023-11-28 15:40:27 +01:00
|
|
|
l2.setAngle(l2.angle() - angle);
|
2023-05-06 19:01:15 +02:00
|
|
|
l2 = VPassmark::FindIntersection(l2, seamAllowance);
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
return {line, l2};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto PassmarkToPath(const QVector<QLineF> &passmark) -> QPainterPath
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
QPainterPath path;
|
|
|
|
if (not passmark.isEmpty())
|
|
|
|
{
|
|
|
|
for (qint32 i = 0; i < passmark.count(); ++i)
|
|
|
|
{
|
|
|
|
path.moveTo(passmark.at(i).p1());
|
|
|
|
path.lineTo(passmark.at(i).p2());
|
|
|
|
}
|
|
|
|
|
|
|
|
path.setFillRule(Qt::WindingFill);
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
2023-05-08 16:50:22 +02:00
|
|
|
} // namespace
|
2019-05-08 14:19:03 +02:00
|
|
|
|
2019-09-05 13:13:22 +02:00
|
|
|
//------------------------------VPiecePassmarkData---------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPiecePassmarkData::toJson() const -> QJsonObject
|
2019-09-05 13:13:22 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
QJsonObject dataObject{
|
2019-09-05 13:13:22 +02:00
|
|
|
{"previousSAPoint", previousSAPoint.toJson()},
|
|
|
|
{"passmarkSAPoint", passmarkSAPoint.toJson()},
|
|
|
|
{"nextSAPoint", nextSAPoint.toJson()},
|
|
|
|
{"saWidth", saWidth},
|
|
|
|
{"nodeName", nodeName},
|
|
|
|
{"pieceName", pieceName},
|
|
|
|
{"passmarkLineType", static_cast<int>(passmarkLineType)},
|
|
|
|
{"passmarkAngleType", static_cast<int>(passmarkAngleType)},
|
|
|
|
{"isMainPathNode", isMainPathNode},
|
|
|
|
{"isShowSecondPassmark", isShowSecondPassmark},
|
|
|
|
{"passmarkIndex", passmarkIndex},
|
|
|
|
{"id", static_cast<qint64>(id)},
|
2023-05-06 19:01:15 +02:00
|
|
|
{"globalPassmarkLength", globalPassmarkLength},
|
|
|
|
{"globalPassmarkWidth", globalPassmarkWidth},
|
2019-09-05 13:13:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return dataObject;
|
|
|
|
}
|
|
|
|
|
2019-05-08 14:19:03 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPassmark::VPassmark(const VPiecePassmarkData &data)
|
2023-08-12 09:31:10 +02:00
|
|
|
: m_data(data),
|
|
|
|
m_null(false)
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
|
|
|
// Correct distorsion
|
2023-08-12 09:31:10 +02:00
|
|
|
if (VGObject::IsPointOnLineSegment(m_data.passmarkSAPoint, m_data.previousSAPoint, m_data.nextSAPoint))
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
2023-08-12 09:31:10 +02:00
|
|
|
const QPointF p =
|
|
|
|
VGObject::CorrectDistortion(m_data.passmarkSAPoint, m_data.previousSAPoint, m_data.nextSAPoint);
|
2019-05-27 13:57:36 +02:00
|
|
|
m_data.passmarkSAPoint.setX(p.x());
|
|
|
|
m_data.passmarkSAPoint.setY(p.y());
|
|
|
|
}
|
|
|
|
}
|
2019-05-08 14:19:03 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::FullPassmark(const VPiece &piece, const VContainer *data) const -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
if (m_null)
|
|
|
|
{
|
2022-10-28 12:55:24 +02:00
|
|
|
return {};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (not piece.IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
|
|
|
QVector<QLineF> lines;
|
|
|
|
lines += SAPassmark(piece, data, PassmarkSide::All);
|
2023-08-12 09:31:10 +02:00
|
|
|
if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark() &&
|
|
|
|
(VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath()) &&
|
|
|
|
m_data.isMainPathNode && m_data.passmarkAngleType != PassmarkAngleType::Intersection &&
|
|
|
|
m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft &&
|
|
|
|
m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight &&
|
|
|
|
m_data.passmarkAngleType != PassmarkAngleType::Intersection2 &&
|
|
|
|
m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft &&
|
|
|
|
m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight && m_data.isShowSecondPassmark)
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
lines += BuiltInSAPassmark(piece, data);
|
|
|
|
}
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
return BuiltInSAPassmark(piece, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::SAPassmark(const VPiece &piece, const VContainer *data, PassmarkSide side) const -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
if (m_null)
|
|
|
|
{
|
2022-10-28 12:55:24 +02:00
|
|
|
return {};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (not piece.IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
|
|
|
// Because rollback cannot be calulated if passmark is not first point in main path we rotate it.
|
2023-04-12 20:05:29 +02:00
|
|
|
QVector<QPointF> rotatedSeamAllowance;
|
|
|
|
CastTo(piece.SeamAllowancePointsWithRotation(data, m_data.passmarkIndex), rotatedSeamAllowance);
|
|
|
|
|
|
|
|
QVector<QPointF> seamAllowance;
|
|
|
|
CastTo(piece.SeamAllowancePoints(data), seamAllowance);
|
|
|
|
|
|
|
|
return SAPassmark(seamAllowance, rotatedSeamAllowance, side);
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
2022-10-28 12:55:24 +02:00
|
|
|
return {};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::SAPassmark(const QVector<QPointF> &seamAllowance, const QVector<QPointF> &rotatedSeamAllowance,
|
|
|
|
PassmarkSide side) const -> QVector<QLineF>
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
if (m_null)
|
|
|
|
{
|
2022-10-28 12:55:24 +02:00
|
|
|
return {};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
2023-05-09 17:59:32 +02:00
|
|
|
// DumpVector(seamAllowance, QStringLiteral("seamAllowance.json.XXXXXX")); // Uncomment for dumping test data
|
|
|
|
// DumpVector(rotatedSeamAllowance,
|
|
|
|
// QStringLiteral("rotatedSeamAllowance.json.XXXXXX")); // Uncomment for dumping test data
|
|
|
|
// DumpPassmarkData(m_data, QStringLiteral("passmarkData.json.XXXXXX")); // Uncomment for dumping test data
|
2023-04-12 20:05:29 +02:00
|
|
|
|
|
|
|
QVector<QLineF> lines = SAPassmarkBaseLine(seamAllowance, rotatedSeamAllowance, side);
|
|
|
|
if (lines.isEmpty())
|
|
|
|
{
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
lines = CreatePassmarkLines(lines, seamAllowance, side);
|
2023-05-09 17:59:32 +02:00
|
|
|
// DumpPassmarkShape(lines, QStringLiteral("passmarkShape.json.XXXXXX")); // Uncomment for dumping test data
|
2023-04-12 20:05:29 +02:00
|
|
|
return lines;
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::IsNull() const -> bool
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
return m_null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::Data() const -> VPiecePassmarkData
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
|
2019-05-27 13:57:36 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::FindIntersection(const QLineF &line, const QVector<QPointF> &seamAllowance) -> QLineF
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
|
|
|
QLineF testLine = line;
|
2023-08-12 09:31:10 +02:00
|
|
|
testLine.setLength(testLine.length() * 10);
|
2019-05-27 13:57:36 +02:00
|
|
|
QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine);
|
|
|
|
if (not intersections.isEmpty())
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
return {line.p1(), intersections.constLast()};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPassmark::PassmarkIntersection(const QVector<QPointF> &path, QLineF line, qreal width) const -> QLineF
|
|
|
|
{
|
|
|
|
line.setLength(line.length() * 100); // Hope 100 is enough
|
|
|
|
|
|
|
|
// DumpVector(path, QStringLiteral("points.json.XXXXXX")); // Uncomment for dumping test data
|
|
|
|
|
|
|
|
const QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(path, line);
|
|
|
|
|
|
|
|
// DumpVector(intersections, QStringLiteral("intersections.json.XXXXXX")); // Uncomment for dumping test data
|
|
|
|
|
|
|
|
if (not intersections.isEmpty())
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
if (intersections.constLast() != m_data.passmarkSAPoint)
|
2023-05-06 19:01:15 +02:00
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
line = QLineF(intersections.constLast(), m_data.passmarkSAPoint);
|
2023-05-06 19:01:15 +02:00
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
const qreal length = PassmarkLength(m_data, width, ok);
|
|
|
|
if (not ok)
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
line.setLength(length);
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch "
|
|
|
|
"collapse.")
|
|
|
|
.arg(m_data.nodeName, m_data.pieceName);
|
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VExceptionInvalidNotch(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find "
|
|
|
|
"intersection.")
|
|
|
|
.arg(m_data.nodeName, m_data.pieceName);
|
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VExceptionInvalidNotch(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPassmark::PassmarkStraightforwardBaseLine(const QPointF &seamPassmarkSAPoint) const -> QVector<QLineF>
|
|
|
|
{
|
|
|
|
bool ok = false;
|
|
|
|
const qreal length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok);
|
|
|
|
|
|
|
|
if (not ok)
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint);
|
|
|
|
line.setLength(length);
|
|
|
|
return {line};
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPassmark::PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const QPointF &seamPassmarkSAPoint,
|
|
|
|
const QVector<QPointF> &seamAllowance) const -> QVector<QLineF>
|
|
|
|
{
|
|
|
|
QLineF edge1;
|
|
|
|
QLineF edge2;
|
|
|
|
|
|
|
|
if (seamPassmarkType == PassmarkStatus::Common)
|
|
|
|
{
|
|
|
|
if (m_data.passmarkSAPoint.GetAngleType() == PieceNodeAngle::ByFirstEdgeSymmetry)
|
|
|
|
{
|
|
|
|
edge1 = QLineF(seamPassmarkSAPoint, seamAllowance.at(seamAllowance.size() - 2));
|
|
|
|
edge2 = QLineF(seamPassmarkSAPoint, seamAllowance.at(1));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const QLineF bigLine1 =
|
|
|
|
VAbstractPiece::ParallelLine(m_data.previousSAPoint, m_data.passmarkSAPoint, m_data.saWidth);
|
|
|
|
const QLineF bigLine2 =
|
|
|
|
VAbstractPiece::ParallelLine(m_data.passmarkSAPoint, m_data.nextSAPoint, m_data.saWidth);
|
|
|
|
|
|
|
|
edge1 = QLineF(seamPassmarkSAPoint, bigLine1.p1());
|
|
|
|
edge2 = QLineF(seamPassmarkSAPoint, bigLine2.p2());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (seamPassmarkType == PassmarkStatus::Rollback)
|
|
|
|
{
|
|
|
|
edge1 = QLineF(seamPassmarkSAPoint, seamAllowance.at(seamAllowance.size() - 2));
|
|
|
|
edge2 = QLineF(seamPassmarkSAPoint, seamAllowance.at(1));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Should never happen
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
const qreal length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok);
|
|
|
|
if (not ok)
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2) / 2.);
|
|
|
|
edge1.setLength(length);
|
|
|
|
|
|
|
|
return {edge1};
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPassmark::PassmarkIntersectionBaseLine(const QVector<QPointF> &path, PassmarkSide side) const -> QVector<QLineF>
|
|
|
|
{
|
|
|
|
QVector<QLineF> lines;
|
|
|
|
if ((m_data.passmarkAngleType == PassmarkAngleType::Intersection ||
|
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::IntersectionOnlyLeft) &&
|
|
|
|
(side == PassmarkSide::All || side == PassmarkSide::Left))
|
|
|
|
{
|
|
|
|
// first passmark
|
|
|
|
lines += PassmarkIntersection(path, QLineF(m_data.nextSAPoint, m_data.passmarkSAPoint),
|
|
|
|
m_data.passmarkSAPoint.GetSABefore(m_data.saWidth));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_data.passmarkAngleType == PassmarkAngleType::Intersection ||
|
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::IntersectionOnlyRight) &&
|
|
|
|
(side == PassmarkSide::All || side == PassmarkSide::Right))
|
|
|
|
{
|
|
|
|
// second passmark
|
|
|
|
lines += PassmarkIntersection(path, QLineF(m_data.previousSAPoint, m_data.passmarkSAPoint),
|
|
|
|
m_data.passmarkSAPoint.GetSAAfter(m_data.saWidth));
|
|
|
|
}
|
|
|
|
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPassmark::PassmarkIntersection2BaseLine(const QVector<QPointF> &path, PassmarkSide side) const -> QVector<QLineF>
|
|
|
|
{
|
|
|
|
QVector<QLineF> lines;
|
|
|
|
if ((m_data.passmarkAngleType == PassmarkAngleType::Intersection2 ||
|
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::Intersection2OnlyLeft) &&
|
|
|
|
(side == PassmarkSide::All || side == PassmarkSide::Left))
|
|
|
|
{
|
|
|
|
// first passmark
|
|
|
|
QLineF line(m_data.passmarkSAPoint, m_data.previousSAPoint);
|
|
|
|
line.setAngle(line.angle() - 90);
|
|
|
|
lines += PassmarkIntersection(path, line, m_data.passmarkSAPoint.GetSABefore(m_data.saWidth));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_data.passmarkAngleType == PassmarkAngleType::Intersection2 ||
|
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::Intersection2OnlyRight) &&
|
|
|
|
(side == PassmarkSide::All || side == PassmarkSide::Right))
|
|
|
|
{
|
|
|
|
// second passmark
|
|
|
|
QLineF line(m_data.passmarkSAPoint, m_data.nextSAPoint);
|
|
|
|
line.setAngle(line.angle() + 90);
|
|
|
|
lines += PassmarkIntersection(path, line, m_data.passmarkSAPoint.GetSAAfter(m_data.saWidth));
|
|
|
|
}
|
|
|
|
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
2019-05-27 13:57:36 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::BuiltInSAPassmark(const VPiece &piece, const VContainer *data) const -> QVector<QLineF>
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
|
|
|
if (m_null)
|
|
|
|
{
|
2023-05-08 16:50:22 +02:00
|
|
|
return {};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
2019-05-27 16:05:42 +02:00
|
|
|
const QVector<QLineF> lines = BuiltInSAPassmarkBaseLine(piece);
|
|
|
|
if (lines.isEmpty())
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
2023-05-08 16:50:22 +02:00
|
|
|
return {};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
2022-10-28 12:55:24 +02:00
|
|
|
QVector<QPointF> points;
|
|
|
|
CastTo(piece.MainPathPoints(data), points);
|
2023-05-06 19:01:15 +02:00
|
|
|
return CreatePassmarkLines(lines, points, PassmarkSide::All);
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const -> QVector<QLineF>
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
|
|
|
if (m_null)
|
|
|
|
{
|
2023-05-08 16:50:22 +02:00
|
|
|
return {};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal length = 0;
|
|
|
|
if (not piece.IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
2021-05-10 15:39:17 +02:00
|
|
|
bool ok = false;
|
|
|
|
length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok);
|
|
|
|
if (not ok)
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
2021-05-10 15:39:17 +02:00
|
|
|
return {};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_data.passmarkSAPoint.IsManualPasskmarkLength())
|
|
|
|
{
|
|
|
|
length = m_data.passmarkSAPoint.GetPasskmarkLength();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-20 10:48:47 +02:00
|
|
|
if (m_data.globalPassmarkLength > accuracyPointOnLine)
|
|
|
|
{
|
|
|
|
length = m_data.globalPassmarkLength;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2' with built "
|
|
|
|
"in seam allowance. User must manually provide length.")
|
2023-08-12 09:31:10 +02:00
|
|
|
.arg(m_data.nodeName, m_data.pieceName);
|
2021-05-20 10:48:47 +02:00
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
2023-08-12 09:31:10 +02:00
|
|
|
? throw VExceptionInvalidNotch(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2021-05-20 10:48:47 +02:00
|
|
|
return {};
|
|
|
|
}
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QLineF edge1 = QLineF(m_data.passmarkSAPoint, m_data.previousSAPoint);
|
|
|
|
QLineF edge2 = QLineF(m_data.passmarkSAPoint, m_data.nextSAPoint);
|
|
|
|
|
2023-08-12 09:31:10 +02:00
|
|
|
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2) / 2.);
|
2019-05-27 13:57:36 +02:00
|
|
|
edge1.setLength(length);
|
|
|
|
|
2022-10-28 12:55:24 +02:00
|
|
|
return {edge1};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::SAPassmarkBaseLine(const VPiece &piece, const VContainer *data, PassmarkSide side) const
|
|
|
|
-> QVector<QLineF>
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
|
|
|
if (m_null)
|
|
|
|
{
|
2022-10-28 12:55:24 +02:00
|
|
|
return {};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (not piece.IsSeamAllowanceBuiltIn())
|
|
|
|
{
|
|
|
|
// Because rollback cannot be calulated if passmark is not first point in main path we rotate it.
|
2023-04-12 20:05:29 +02:00
|
|
|
QVector<QPointF> rotatedSeamAllowance;
|
|
|
|
CastTo(piece.SeamAllowancePointsWithRotation(data, m_data.passmarkIndex), rotatedSeamAllowance);
|
|
|
|
|
|
|
|
QVector<QPointF> seamAllowance;
|
|
|
|
CastTo(piece.SeamAllowancePoints(data), seamAllowance);
|
|
|
|
|
|
|
|
return SAPassmarkBaseLine(seamAllowance, rotatedSeamAllowance, side);
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
2022-10-28 12:55:24 +02:00
|
|
|
return {};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowance, const QVector<QPointF> &rotatedSeamAllowance,
|
|
|
|
PassmarkSide side) const -> QVector<QLineF>
|
2019-05-27 13:57:36 +02:00
|
|
|
{
|
|
|
|
if (m_null)
|
|
|
|
{
|
2022-10-28 12:55:24 +02:00
|
|
|
return {};
|
2019-05-27 13:57:36 +02:00
|
|
|
}
|
|
|
|
|
2023-04-12 20:05:29 +02:00
|
|
|
if (rotatedSeamAllowance.size() < 2)
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Seam allowance is "
|
2023-08-12 09:31:10 +02:00
|
|
|
"empty.")
|
|
|
|
.arg(m_data.nodeName, m_data.pieceName);
|
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VExceptionInvalidNotch(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2023-04-12 20:05:29 +02:00
|
|
|
return {}; // Something wrong
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QPointF seamPassmarkSAPoint;
|
2023-04-12 20:05:29 +02:00
|
|
|
const PassmarkStatus seamPassmarkType = GetSeamPassmarkSAPoint(m_data, rotatedSeamAllowance, seamPassmarkSAPoint);
|
2019-05-08 14:19:03 +02:00
|
|
|
if (seamPassmarkType == PassmarkStatus::Error)
|
|
|
|
{
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find "
|
|
|
|
"position for a notch.")
|
2023-04-12 20:05:29 +02:00
|
|
|
.arg(m_data.nodeName, m_data.pieceName);
|
2023-08-12 09:31:10 +02:00
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VExceptionInvalidNotch(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2023-04-12 20:05:29 +02:00
|
|
|
return {}; // Something wrong
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
2023-08-12 09:31:10 +02:00
|
|
|
const QVector<QPointF> &path = (m_data.passmarkAngleType == PassmarkAngleType::Straightforward ||
|
2023-04-12 20:05:29 +02:00
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::Bisector)
|
|
|
|
? rotatedSeamAllowance
|
|
|
|
: seamAllowance;
|
|
|
|
|
2023-05-11 17:21:19 +02:00
|
|
|
if (not FixNotchPoint(path, m_data, &seamPassmarkSAPoint))
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Unable to fix a "
|
|
|
|
"notch position.")
|
2023-04-12 20:05:29 +02:00
|
|
|
.arg(m_data.nodeName, m_data.pieceName);
|
2023-08-12 09:31:10 +02:00
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VExceptionInvalidNotch(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)
|
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
return PassmarkStraightforwardBaseLine(seamPassmarkSAPoint);
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
2023-05-08 16:50:22 +02:00
|
|
|
|
|
|
|
if (m_data.passmarkAngleType == PassmarkAngleType::Bisector)
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
return PassmarkBisectorBaseLine(seamPassmarkType, seamPassmarkSAPoint, path);
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
2023-05-08 16:50:22 +02:00
|
|
|
|
|
|
|
if (m_data.passmarkAngleType == PassmarkAngleType::Intersection ||
|
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::IntersectionOnlyLeft ||
|
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::IntersectionOnlyRight)
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
return PassmarkIntersectionBaseLine(path, side);
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
2023-05-08 16:50:22 +02:00
|
|
|
|
|
|
|
if (m_data.passmarkAngleType == PassmarkAngleType::Intersection2 ||
|
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::Intersection2OnlyLeft ||
|
|
|
|
m_data.passmarkAngleType == PassmarkAngleType::Intersection2OnlyRight)
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
2023-05-06 19:01:15 +02:00
|
|
|
return PassmarkIntersection2BaseLine(path, side);
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
2023-04-12 20:05:29 +02:00
|
|
|
return {};
|
2019-05-08 14:19:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::SAPassmarkPath(const VPiece &piece, const VContainer *data, PassmarkSide side) const -> QPainterPath
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
return PassmarkToPath(SAPassmark(piece, data, side));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPassmark::BuiltInSAPassmarkPath(const VPiece &piece, const VContainer *data) const -> QPainterPath
|
2019-05-08 14:19:03 +02:00
|
|
|
{
|
|
|
|
return PassmarkToPath(BuiltInSAPassmark(piece, data));
|
|
|
|
}
|
2023-05-06 19:01:15 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPassmark::CreatePassmarkLines(const QVector<QLineF> &lines, const QVector<QPointF> &seamAllowance,
|
|
|
|
PassmarkSide side) const -> QVector<QLineF>
|
|
|
|
{
|
|
|
|
if (lines.isEmpty())
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
auto CreateLinesWithCorrection =
|
|
|
|
[this, side, lines, seamAllowance](
|
|
|
|
QVector<QLineF> (*create)(const VPiecePassmarkData &passmarkData, const QLineF &, const QVector<QPointF> &))
|
|
|
|
{
|
|
|
|
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
return (*create)(m_data, lines.constFirst(), seamAllowance);
|
2023-05-06 19:01:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QLineF> passmarksLines;
|
|
|
|
|
|
|
|
if (side == PassmarkSide::All || side == PassmarkSide::Left)
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
passmarksLines += (*create)(m_data, lines.constFirst(), seamAllowance);
|
2023-05-06 19:01:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (side == PassmarkSide::All || side == PassmarkSide::Right)
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
passmarksLines += (*create)(m_data, lines.constLast(), seamAllowance);
|
2023-05-06 19:01:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return passmarksLines;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto CreateLines =
|
|
|
|
[this, side, lines](QVector<QLineF> (*create)(const VPiecePassmarkData &passmarkData, const QLineF &))
|
|
|
|
{
|
|
|
|
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
return (*create)(m_data, lines.constFirst());
|
2023-05-06 19:01:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QLineF> passmarksLines;
|
|
|
|
|
|
|
|
if (side == PassmarkSide::All || side == PassmarkSide::Left)
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
passmarksLines += (*create)(m_data, lines.constFirst());
|
2023-05-06 19:01:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (side == PassmarkSide::All || side == PassmarkSide::Right)
|
|
|
|
{
|
2023-08-12 11:03:28 +02:00
|
|
|
passmarksLines += (*create)(m_data, lines.constLast());
|
2023-05-06 19:01:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return passmarksLines;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (m_data.passmarkAngleType != PassmarkAngleType::Bisector)
|
|
|
|
{
|
|
|
|
switch (m_data.passmarkLineType)
|
|
|
|
{
|
|
|
|
case PassmarkLineType::TwoLines:
|
|
|
|
return CreateLinesWithCorrection(CreateTwoPassmarkLines);
|
|
|
|
case PassmarkLineType::ThreeLines:
|
|
|
|
return CreateLinesWithCorrection(CreateThreePassmarkLines);
|
|
|
|
case PassmarkLineType::TMark:
|
|
|
|
return CreateLines(CreateTMarkPassmark);
|
|
|
|
case PassmarkLineType::ExternalVMark:
|
|
|
|
return CreateLines(CreateExternalVMarkPassmark);
|
|
|
|
case PassmarkLineType::InternalVMark:
|
|
|
|
return CreateLinesWithCorrection(CreateInternalVMarkPassmark);
|
|
|
|
case PassmarkLineType::UMark:
|
|
|
|
return CreateLinesWithCorrection(CreateUMarkPassmark);
|
|
|
|
case PassmarkLineType::BoxMark:
|
|
|
|
return CreateLinesWithCorrection(CreateBoxMarkPassmark);
|
|
|
|
case PassmarkLineType::CheckMark:
|
|
|
|
return CreateLinesWithCorrection(CreateCheckMarkPassmark);
|
|
|
|
case PassmarkLineType::OneLine:
|
|
|
|
default:
|
|
|
|
return CreateLines(CreateOnePassmarkLines);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (m_data.passmarkLineType)
|
|
|
|
{
|
|
|
|
case PassmarkLineType::TMark:
|
2023-08-12 11:03:28 +02:00
|
|
|
return CreateTMarkPassmark(m_data, lines.constFirst());
|
2023-05-06 19:01:15 +02:00
|
|
|
case PassmarkLineType::OneLine:
|
|
|
|
case PassmarkLineType::TwoLines:
|
|
|
|
case PassmarkLineType::ThreeLines:
|
|
|
|
case PassmarkLineType::ExternalVMark:
|
|
|
|
case PassmarkLineType::InternalVMark:
|
|
|
|
case PassmarkLineType::UMark:
|
|
|
|
case PassmarkLineType::BoxMark:
|
|
|
|
case PassmarkLineType::CheckMark:
|
|
|
|
default:
|
2023-08-12 11:03:28 +02:00
|
|
|
return {lines.constFirst()};
|
2023-05-06 19:01:15 +02:00
|
|
|
}
|
|
|
|
}
|