Puzzle app. Fix piece position move when update layout data.
This commit is contained in:
parent
3058c2fc33
commit
bf58addbe3
|
@ -45,6 +45,7 @@
|
|||
- Fix filling piece label data.
|
||||
- New piece option Follow grainline.
|
||||
- Validate sheet and layout names before proposing file name.
|
||||
- Puzzle app. Fix piece position move when update layout data.
|
||||
|
||||
# Valentina 0.7.52 September 12, 2022
|
||||
- Fix crash when default locale is ru.
|
||||
|
|
|
@ -118,19 +118,27 @@ void VPLayout::AddPiece(const VPLayoutPtr &layout, const VPPiecePtr &piece)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPLayout::AddPiece(const VPPiecePtr &piece)
|
||||
{
|
||||
if (not piece.isNull())
|
||||
if (piece.isNull())
|
||||
{
|
||||
if (not m_pieces.contains(piece->GetUniqueID()))
|
||||
return;
|
||||
}
|
||||
|
||||
VPPiece::CleanPosition(piece);
|
||||
|
||||
if (not m_pieces.contains(piece->GetUniqueID()))
|
||||
{
|
||||
m_pieces.insert(piece->GetUniqueID(), piece);
|
||||
}
|
||||
else
|
||||
{
|
||||
VPPiecePtr oldPiece = m_pieces.value(piece->GetUniqueID());
|
||||
if (not oldPiece.isNull())
|
||||
{
|
||||
m_pieces.insert(piece->GetUniqueID(), piece);
|
||||
oldPiece->Update(piece);
|
||||
}
|
||||
else
|
||||
{
|
||||
VPPiecePtr oldPiece = m_pieces.value(piece->GetUniqueID());
|
||||
if (not oldPiece.isNull())
|
||||
{
|
||||
oldPiece->Update(piece);
|
||||
}
|
||||
m_pieces.insert(piece->GetUniqueID(), piece);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -447,3 +447,65 @@ void VPPiece::SetCopyNumber(quint16 newCopyNumber)
|
|||
{
|
||||
m_copyNumber = qMax(static_cast<quint16>(1), newCopyNumber);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPPiece::CleanPosition(const VPPiecePtr &piece)
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
CastTo(piece->GetExternalContourPoints(), points);
|
||||
if (points.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QPointF offset = BoundingRect(points).topLeft();
|
||||
if (qFuzzyIsNull(offset.x()) && qFuzzyIsNull(offset.y()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QTransform matrix;
|
||||
matrix.translate(-offset.x(), -offset.y());
|
||||
|
||||
piece->SetContourPoints(MapVector(piece->GetContourPoints(), matrix), piece->IsHideMainPath());
|
||||
piece->SetSeamAllowancePoints(MapVector(piece->GetSeamAllowancePoints(), matrix), piece->IsSeamAllowance(),
|
||||
piece->IsSeamAllowanceBuiltIn());
|
||||
|
||||
{
|
||||
QVector<VLayoutPiecePath> internalPaths = piece->GetInternalPaths();
|
||||
for (auto &path : internalPaths)
|
||||
{
|
||||
path.SetPoints(MapVector(path.Points(), matrix));
|
||||
}
|
||||
piece->SetInternalPaths(internalPaths);
|
||||
}
|
||||
|
||||
{
|
||||
QVector<VLayoutPassmark> passmarks = piece->GetPassmarks();
|
||||
for (auto &passmark : passmarks)
|
||||
{
|
||||
passmark.lines = MapVector(passmark.lines, matrix);
|
||||
passmark.baseLine = matrix.map(passmark.baseLine);
|
||||
}
|
||||
piece->SetPassmarks(passmarks);
|
||||
}
|
||||
|
||||
{
|
||||
QVector<VLayoutPlaceLabel> placeLabels = piece->GetPlaceLabels();
|
||||
for (auto &label : placeLabels)
|
||||
{
|
||||
label.SetCenter(matrix.map(label.Center()));
|
||||
label.SetBox(label.Box().translated(-offset.x(), -offset.y()));
|
||||
}
|
||||
piece->SetPlaceLabels(placeLabels);
|
||||
}
|
||||
|
||||
{
|
||||
VPieceGrainline grainline = piece->GetGrainline();
|
||||
grainline.SetMainLine(matrix.map(grainline.GetMainLine()));
|
||||
piece->SetGrainline(grainline);
|
||||
}
|
||||
|
||||
piece->SetPieceLabelRect(MapVector(piece->GetPieceLabelRect(), matrix));
|
||||
piece->SetPatternLabelRect(MapVector(piece->GetPatternLabelRect(), matrix));
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ public:
|
|||
auto StickyPosition(qreal &dx, qreal &dy) const -> bool;
|
||||
|
||||
static auto PathsSuperposition(const QVector<QPointF> &path1, const QVector<QPointF> &path2) -> bool;
|
||||
static void CleanPosition(const VPPiecePtr &piece);
|
||||
|
||||
auto IsValid(QString &error) const -> bool;
|
||||
|
||||
|
|
|
@ -221,7 +221,8 @@ public:
|
|||
|
||||
auto MapPlaceLabelShape(PlaceLabelImg shape) const -> PlaceLabelImg;
|
||||
|
||||
template <class T> static auto MapVector(QVector<T> points, const QTransform &matrix, bool mirror) -> QVector<T>;
|
||||
template <class T>
|
||||
static auto MapVector(QVector<T> points, const QTransform &matrix, bool mirror = false) -> QVector<T>;
|
||||
|
||||
template <class T>
|
||||
static auto MapPoint(T obj, const QTransform &matrix) -> typename std::enable_if<!IsLayoutPoint<T>::value, T>::type;
|
||||
|
|
Loading…
Reference in New Issue
Block a user