Improve warning about error in calculating a curve segment.
Added in the message information about the path name.
(cherry picked from commit 75e296e839
)
This commit is contained in:
parent
e655a31ed2
commit
1483f7a0cc
|
@ -126,15 +126,25 @@ QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse) const
|
||||
QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse,
|
||||
const QString &piece) const
|
||||
{
|
||||
QString error;
|
||||
QVector<QPointF> segment = GetSegmentPoints(GetPoints(), begin, end, reverse, error);
|
||||
|
||||
if (not error.isEmpty())
|
||||
{
|
||||
const QString errorMsg = QObject::tr("Error calculating segment for curve '%1'. %2")
|
||||
.arg(name(), error);
|
||||
QString errorMsg;
|
||||
if (piece.isEmpty())
|
||||
{
|
||||
errorMsg = QObject::tr("Error calculating segment for curve '%1'. %2")
|
||||
.arg(name(), error);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMsg = QObject::tr("Error in path '%1'. Calculating segment for curve '%2' has failed. %3")
|
||||
.arg(piece, name(), error);
|
||||
}
|
||||
qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) :
|
||||
qWarning() << VAbstractApplication::patternMessageSignature + errorMsg;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@ public:
|
|||
virtual QVector<QPointF> GetPoints() const =0;
|
||||
static QVector<QPointF> GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin, const QPointF &end,
|
||||
bool reverse, QString &error);
|
||||
QVector<QPointF> GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse) const;
|
||||
QVector<QPointF> GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse,
|
||||
const QString &piece = QString()) const;
|
||||
|
||||
virtual QPainterPath GetPath() const;
|
||||
virtual qreal GetLength() const =0;
|
||||
|
|
|
@ -174,7 +174,10 @@ QVector<QPointF> VPiece::MainPathPoints(const VContainer *data) const
|
|||
{
|
||||
// DumpPiece(*this, data); // Uncomment for dumping test data
|
||||
|
||||
QVector<QPointF> points = GetPath().PathPoints(data);
|
||||
VPiecePath mainPath = GetPath();
|
||||
mainPath.SetName(tr("Main path of piece %1").arg(GetName()));
|
||||
|
||||
QVector<QPointF> points = mainPath.PathPoints(data);
|
||||
points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops
|
||||
|
||||
// DumpVector(points); // Uncomment for dumping test data
|
||||
|
@ -184,7 +187,7 @@ QVector<QPointF> VPiece::MainPathPoints(const VContainer *data) const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPiece::UniteMainPathPoints(const VContainer *data) const
|
||||
{
|
||||
QVector<QPointF> points = VPiecePath::NodesToPoints(data, GetUnitedPath(data));
|
||||
QVector<QPointF> points = VPiecePath::NodesToPoints(data, GetUnitedPath(data), GetName());
|
||||
points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops
|
||||
return points;
|
||||
}
|
||||
|
@ -731,7 +734,7 @@ QVector<QPointF> VPiece::SeamAllowancePointsWithRotation(const VContainer *data,
|
|||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
|
||||
|
||||
pointsEkv += VPiecePath::CurveSeamAllowanceSegment(data, unitedPath, curve, i, node.GetReverse(),
|
||||
width);
|
||||
width, GetName());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -899,7 +902,7 @@ QVector<VSAPoint> VPiece::GetNodeSAPoints(const QVector<VPieceNode> &path, int i
|
|||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
|
||||
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
||||
|
||||
points += VPiecePath::CurveSeamAllowanceSegment(data, path, curve, index, node.GetReverse(), width);
|
||||
points += VPiecePath::CurveSeamAllowanceSegment(data, path, curve, index, node.GetReverse(), width, GetName());
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ bool VPiecePath::IsLastToCuttingCountour() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPiecePath::PathPoints(const VContainer *data, const QVector<QPointF> &cuttingPath) const
|
||||
{
|
||||
QVector<QPointF> points = NodesToPoints(data, d->m_nodes);
|
||||
QVector<QPointF> points = NodesToPoints(data, d->m_nodes, GetName());
|
||||
|
||||
if (GetType() == PiecePathType::InternalPath && not cuttingPath.isEmpty() && points.size() > 1)
|
||||
{
|
||||
|
@ -464,7 +464,7 @@ QVector<QVector<QPointF> > VPiecePath::PathCurvePoints(const VContainer *data) c
|
|||
const QPointF begin = StartSegment(data, i, at(i).GetReverse());
|
||||
const QPointF end = EndSegment(data, i, at(i).GetReverse());
|
||||
|
||||
curves.append(curve->GetSegmentPoints(begin, end, at(i).GetReverse()));
|
||||
curves.append(curve->GetSegmentPoints(begin, end, at(i).GetReverse(), GetName()));
|
||||
break;
|
||||
}
|
||||
case (Tool::NodePoint):
|
||||
|
@ -498,7 +498,7 @@ QVector<VSAPoint> VPiecePath::SeamAllowancePoints(const VContainer *data, qreal
|
|||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(node.GetId());
|
||||
pointsEkv += CurveSeamAllowanceSegment(data, d->m_nodes, curve, i, node.GetReverse(), width);
|
||||
pointsEkv += CurveSeamAllowanceSegment(data, d->m_nodes, curve, i, node.GetReverse(), width, GetName());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -882,7 +882,7 @@ QPointF VPiecePath::NodePreviousPoint(const VContainer *data, int i) const
|
|||
const VSAPoint begin = StartSegment(data, d->m_nodes, index, node.GetReverse());
|
||||
const VSAPoint end = EndSegment(data, d->m_nodes, index, node.GetReverse());
|
||||
|
||||
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, node.GetReverse());
|
||||
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, node.GetReverse(), GetName());
|
||||
if (points.size() > 1)
|
||||
{
|
||||
return points.at(points.size()-2);
|
||||
|
@ -934,7 +934,7 @@ QPointF VPiecePath::NodeNextPoint(const VContainer *data, int i) const
|
|||
const VSAPoint begin = StartSegment(data, d->m_nodes, index, node.GetReverse());
|
||||
const VSAPoint end = EndSegment(data, d->m_nodes, index, node.GetReverse());
|
||||
|
||||
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, node.GetReverse());
|
||||
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, node.GetReverse(), GetName());
|
||||
if (points.size() > 1)
|
||||
{
|
||||
return points.at(1);
|
||||
|
@ -1084,14 +1084,14 @@ VSAPoint VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *d
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VSAPoint> VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector<VPieceNode> &nodes,
|
||||
const QSharedPointer<VAbstractCurve> &curve, int i,
|
||||
bool reverse, qreal width)
|
||||
bool reverse, qreal width, const QString &piece)
|
||||
{
|
||||
QVector<VSAPoint> pointsEkv;
|
||||
|
||||
const VSAPoint begin = StartSegment(data, nodes, i, reverse);
|
||||
const VSAPoint end = EndSegment(data, nodes, i, reverse);
|
||||
|
||||
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, reverse);
|
||||
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, reverse, piece);
|
||||
if (points.isEmpty())
|
||||
{
|
||||
return pointsEkv;
|
||||
|
@ -1193,7 +1193,8 @@ QString VPiecePath::NodeName(const QVector<VPieceNode> &nodes, int nodeIndex, co
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPiecePath::NodesToPoints(const VContainer *data, const QVector<VPieceNode> &nodes)
|
||||
QVector<QPointF> VPiecePath::NodesToPoints(const VContainer *data, const QVector<VPieceNode> &nodes,
|
||||
const QString &piece)
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
for (int i = 0; i < nodes.size(); ++i)
|
||||
|
@ -1223,7 +1224,7 @@ QVector<QPointF> VPiecePath::NodesToPoints(const VContainer *data, const QVector
|
|||
const QPointF begin = StartSegment(data, nodes, i, node.GetReverse());
|
||||
const QPointF end = EndSegment(data, nodes, i, node.GetReverse());
|
||||
|
||||
points << curve->GetSegmentPoints(begin, end, node.GetReverse());
|
||||
points << curve->GetSegmentPoints(begin, end, node.GetReverse(), piece);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -133,11 +133,13 @@ public:
|
|||
|
||||
static QVector<VSAPoint> CurveSeamAllowanceSegment(const VContainer *data, const QVector<VPieceNode> &nodes,
|
||||
const QSharedPointer<VAbstractCurve> &curve,
|
||||
int i, bool reverse, qreal width);
|
||||
int i, bool reverse, qreal width,
|
||||
const QString &piece = QString());
|
||||
|
||||
static QString NodeName(const QVector<VPieceNode> &nodes, int nodeIndex, const VContainer *data);
|
||||
|
||||
static QVector<QPointF> NodesToPoints(const VContainer *data, const QVector<VPieceNode> &nodes);
|
||||
static QVector<QPointF> NodesToPoints(const VContainer *data, const QVector<VPieceNode> &nodes,
|
||||
const QString &piece = QString());
|
||||
|
||||
private:
|
||||
QSharedDataPointer<VPiecePathData> d;
|
||||
|
|
Loading…
Reference in New Issue
Block a user