Incorrect duplication of a piece. Missing restoring pins.
This commit is contained in:
parent
95fb3f3d89
commit
e00cfb9890
|
@ -1,6 +1,7 @@
|
|||
# Version 0.7.46 (unreleased)
|
||||
- Fix incorrect calculation of value for multisize measurements in Valentina.
|
||||
- [smart-pattern/valentina#109] Pattern label template placeholder with dimension label value.
|
||||
- Incorrect duplication of a piece. Missing restoring pins.
|
||||
|
||||
# Version 0.7.45 Feb 26, 2021
|
||||
- Fix incorrect seam allowance for angle type second edge right angle.
|
||||
|
|
|
@ -86,6 +86,57 @@ const QString VToolSeamAllowance::AttrTopPin = QStringLiteral("top
|
|||
const QString VToolSeamAllowance::AttrBottomPin = QStringLiteral("bottomPin");
|
||||
const QString VToolSeamAllowance::AttrPiecePriority = QStringLiteral("priority");
|
||||
|
||||
namespace
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
auto FixLabelPins(T itemData, const QMap<quint32, quint32> &mappedPins) -> T
|
||||
{
|
||||
itemData.SetCenterPin(mappedPins.value(itemData.CenterPin(), NULL_ID));
|
||||
itemData.SetTopLeftPin(mappedPins.value(itemData.TopLeftPin(), NULL_ID));
|
||||
itemData.SetBottomRightPin(mappedPins.value(itemData.BottomRightPin(), NULL_ID));
|
||||
return itemData;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
auto FixGrainlinePins(T itemData, const QMap<quint32, quint32> &mappedPins) -> T
|
||||
{
|
||||
itemData.SetCenterPin(mappedPins.value(itemData.CenterPin(), NULL_ID));
|
||||
itemData.SetTopPin(mappedPins.value(itemData.TopPin(), NULL_ID));
|
||||
itemData.SetBottomPin(mappedPins.value(itemData.BottomPin(), NULL_ID));
|
||||
return itemData;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto DuplicatePins(const QVector<quint32> &pins, const VToolSeamAllowanceInitData &initData) -> QMap<quint32, quint32>
|
||||
{
|
||||
QMap<quint32, quint32> newPins;
|
||||
for(auto p : pins)
|
||||
{
|
||||
QSharedPointer<VPointF> pin = initData.data->GeometricObject<VPointF>(p);
|
||||
|
||||
auto *tool = qobject_cast<VAbstractNode *>(VAbstractPattern::getTool(p));
|
||||
SCASSERT(tool != nullptr)
|
||||
|
||||
VToolPinInitData initNodeData;
|
||||
initNodeData.id = initData.data->AddGObject(new VPointF(*pin));
|
||||
initNodeData.pointId = pin->getIdObject();
|
||||
initNodeData.idObject = NULL_ID; // piece id
|
||||
initNodeData.doc = initData.doc;
|
||||
initNodeData.data = initData.data;
|
||||
initNodeData.parse = Document::FullParse;
|
||||
initNodeData.typeCreation = Source::FromTool;
|
||||
initNodeData.drawName = initData.drawName;
|
||||
initNodeData.idTool = tool->GetIdTool();
|
||||
|
||||
VToolPin::Create(initNodeData);
|
||||
newPins.insert(p, initNodeData.id);
|
||||
}
|
||||
return newPins;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolSeamAllowance *VToolSeamAllowance::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data)
|
||||
|
@ -192,7 +243,7 @@ VToolSeamAllowance *VToolSeamAllowance::Duplicate(const QPointer<DialogTool> &di
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolSeamAllowance *VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &initData)
|
||||
auto VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &initData) -> VToolSeamAllowance *
|
||||
{
|
||||
VPiece dupDetail = initData.detail;
|
||||
|
||||
|
@ -201,9 +252,14 @@ VToolSeamAllowance *VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &in
|
|||
dupDetail.SetCustomSARecords(DuplicateCustomSARecords(initData.detail.GetCustomSARecords(), initData,
|
||||
replacements));
|
||||
dupDetail.SetInternalPaths(DuplicateInternalPaths(initData.detail.GetInternalPaths(), initData));
|
||||
dupDetail.SetPins(DuplicatePins(initData.detail.GetPins(), initData));
|
||||
dupDetail.SetPlaceLabels(DuplicatePlaceLabels(initData.detail.GetPlaceLabels(), initData));
|
||||
|
||||
const QMap<quint32, quint32> mappedPins = DuplicatePins(initData.detail.GetPins(), initData);
|
||||
dupDetail.SetPins(mappedPins.values().toVector());
|
||||
dupDetail.SetPatternPieceData(FixLabelPins(initData.detail.GetPatternPieceData(), mappedPins));
|
||||
dupDetail.SetPatternInfo(FixLabelPins(initData.detail.GetPatternInfo(), mappedPins));
|
||||
dupDetail.SetGrainlineGeometry(FixGrainlinePins(initData.detail.GetGrainlineGeometry(), mappedPins));
|
||||
|
||||
initData.detail = dupDetail;
|
||||
return VToolSeamAllowance::Create(initData);
|
||||
}
|
||||
|
@ -2108,36 +2164,6 @@ QVector<quint32> VToolSeamAllowance::DuplicateInternalPaths(const QVector<quint3
|
|||
return newPaths;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<quint32> VToolSeamAllowance::DuplicatePins(const QVector<quint32> &pins,
|
||||
const VToolSeamAllowanceInitData &initData)
|
||||
{
|
||||
QVector<quint32> newPins;
|
||||
newPins.reserve(pins.size());
|
||||
for(auto p : pins)
|
||||
{
|
||||
QSharedPointer<VPointF> pin = initData.data->GeometricObject<VPointF>(p);
|
||||
|
||||
VAbstractNode *tool = qobject_cast<VAbstractNode *>(VAbstractPattern::getTool(p));
|
||||
SCASSERT(tool != nullptr)
|
||||
|
||||
VToolPinInitData initNodeData;
|
||||
initNodeData.id = initData.data->AddGObject(new VPointF(*pin));
|
||||
initNodeData.pointId = pin->getIdObject();
|
||||
initNodeData.idObject = NULL_ID; // piece id
|
||||
initNodeData.doc = initData.doc;
|
||||
initNodeData.data = initData.data;
|
||||
initNodeData.parse = Document::FullParse;
|
||||
initNodeData.typeCreation = Source::FromTool;
|
||||
initNodeData.drawName = initData.drawName;
|
||||
initNodeData.idTool = tool->GetIdTool();
|
||||
|
||||
VToolPin::Create(initNodeData);
|
||||
newPins.append(initNodeData.id);
|
||||
}
|
||||
return newPins;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<quint32> VToolSeamAllowance::DuplicatePlaceLabels(const QVector<quint32> &placeLabels,
|
||||
const VToolSeamAllowanceInitData &initData)
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
static VToolSeamAllowance* Create(VToolSeamAllowanceInitData &initData);
|
||||
static VToolSeamAllowance* Duplicate(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc);
|
||||
static VToolSeamAllowance* Duplicate(VToolSeamAllowanceInitData &initData);
|
||||
static auto Duplicate(VToolSeamAllowanceInitData &initData) -> VToolSeamAllowance *;
|
||||
|
||||
static const quint8 pieceVersion;
|
||||
|
||||
|
@ -194,7 +194,7 @@ private:
|
|||
/** @brief m_geometryIsReady is true when a piece's geometry is ready and checks for validity can be enabled. */
|
||||
bool m_geometryIsReady{false};
|
||||
|
||||
VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
explicit VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
|
||||
void UpdateExcludeState();
|
||||
void UpdateInternalPaths();
|
||||
|
@ -233,7 +233,6 @@ private:
|
|||
|
||||
static QVector<quint32> DuplicateInternalPaths(const QVector<quint32> &iPaths,
|
||||
const VToolSeamAllowanceInitData &initData);
|
||||
static QVector<quint32> DuplicatePins(const QVector<quint32> &pins, const VToolSeamAllowanceInitData &initData);
|
||||
static QVector<quint32> DuplicatePlaceLabels(const QVector<quint32> &placeLabels,
|
||||
const VToolSeamAllowanceInitData &initData);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user