Decrement/increment custom seam allowance in tool seam allowance undocommands.
--HG-- branch : feature
This commit is contained in:
parent
cb95210d1e
commit
8e9b01a93a
|
@ -250,12 +250,12 @@ void VPiece::SetCustomSARecords(const QVector<CustomSARecord> &records)
|
|||
* @param det changed detail.
|
||||
* @return list with missing nodes.
|
||||
*/
|
||||
QVector<VPieceNode> VPiece::MissingNodes(const VPiece &det) const
|
||||
QVector<quint32> VPiece::MissingNodes(const VPiece &det) const
|
||||
{
|
||||
const QVector<VPieceNode> pNodes = d->m_path.GetNodes();
|
||||
if (pNodes.size() == det.GetPath().CountNodes()) //-V807
|
||||
{
|
||||
return QVector<VPieceNode>();
|
||||
return QVector<quint32>();
|
||||
}
|
||||
|
||||
QSet<quint32> set1;
|
||||
|
@ -271,19 +271,50 @@ QVector<VPieceNode> VPiece::MissingNodes(const VPiece &det) const
|
|||
}
|
||||
|
||||
const QList<quint32> set3 = set1.subtract(set2).toList();
|
||||
QVector<VPieceNode> nodes;
|
||||
QVector<quint32> nodes;
|
||||
for (qint32 i = 0; i < set3.size(); ++i)
|
||||
{
|
||||
const int index = indexOfNode(pNodes, set3.at(i));
|
||||
if (index != -1)
|
||||
{
|
||||
nodes.append(pNodes.at(index));
|
||||
nodes.append(pNodes.at(index).GetId());
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<quint32> VPiece::MissingCSAPath(const VPiece &det) const
|
||||
{
|
||||
const QVector<CustomSARecord> detRecords = det.GetCustomSARecords();
|
||||
if (d->m_customSARecords.size() == detRecords.size()) //-V807
|
||||
{
|
||||
return QVector<quint32>();
|
||||
}
|
||||
|
||||
QSet<quint32> set1;
|
||||
for (qint32 i = 0; i < d->m_customSARecords.size(); ++i)
|
||||
{
|
||||
set1.insert(d->m_customSARecords.at(i).path);
|
||||
}
|
||||
|
||||
QSet<quint32> set2;
|
||||
for (qint32 j = 0; j < detRecords.size(); ++j)
|
||||
{
|
||||
set2.insert(detRecords.at(j).path);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief indexOfNode return index in list node using id object.
|
||||
|
|
|
@ -78,7 +78,8 @@ public:
|
|||
QVector<CustomSARecord> GetCustomSARecords() const;
|
||||
void SetCustomSARecords(const QVector<CustomSARecord> &records);
|
||||
|
||||
QVector<VPieceNode> MissingNodes(const VPiece &det) const;
|
||||
QVector<quint32> MissingNodes(const VPiece &det) const;
|
||||
QVector<quint32> MissingCSAPath(const VPiece &det) const;
|
||||
|
||||
int indexOfNode(const quint32 &id) const;
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ void AddPiece::undo()
|
|||
}
|
||||
|
||||
DecrementReferences(m_detail.GetPath().GetNodes());
|
||||
DecrementReferences(m_detail.GetCustomSARecords());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -107,6 +107,7 @@ void DeletePiece::redo()
|
|||
toolDet->hide();
|
||||
|
||||
DecrementReferences(m_detail.GetPath().GetNodes());
|
||||
DecrementReferences(m_detail.GetCustomSARecords());
|
||||
emit NeedFullParsing(); // Doesn't work when UnionDetail delete detail.
|
||||
}
|
||||
else
|
||||
|
|
|
@ -78,6 +78,7 @@ void SavePieceOptions::undo()
|
|||
VToolSeamAllowance::AddCSARecords(doc, domElement, m_oldDet.GetCustomSARecords());
|
||||
|
||||
IncrementReferences(m_oldDet.MissingNodes(m_newDet));
|
||||
IncrementReferences(m_oldDet.MissingCSAPath(m_newDet));
|
||||
emit NeedLiteParsing(Document::LiteParse);
|
||||
}
|
||||
else
|
||||
|
@ -104,6 +105,8 @@ void SavePieceOptions::redo()
|
|||
VToolSeamAllowance::AddCSARecords(doc, domElement, m_newDet.GetCustomSARecords());
|
||||
|
||||
DecrementReferences(m_oldDet.MissingNodes(m_newDet));
|
||||
DecrementReferences(m_oldDet.MissingCSAPath(m_newDet));
|
||||
|
||||
emit NeedLiteParsing(Document::LiteParse);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -95,19 +95,71 @@ void VUndoCommand::DecrementReferences(const QVector<VNodeDetail> &nodes) const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VUndoCommand::IncrementReferences(const QVector<VPieceNode> &nodes) const
|
||||
void VUndoCommand::IncrementReferences(const QVector<quint32> &nodes) const
|
||||
{
|
||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(nodes.at(i).GetId());
|
||||
doc->IncrementReferens(nodes.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VUndoCommand::DecrementReferences(const QVector<quint32> &nodes) const
|
||||
{
|
||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
doc->DecrementReferens(nodes.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VUndoCommand::IncrementReferences(const QVector<CustomSARecord> &nodes) const
|
||||
{
|
||||
QVector<quint32> n;
|
||||
|
||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
n.append(nodes.at(i).path);
|
||||
}
|
||||
|
||||
IncrementReferences(n);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VUndoCommand::DecrementReferences(const QVector<CustomSARecord> &nodes) const
|
||||
{
|
||||
QVector<quint32> n;
|
||||
|
||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
n.append(nodes.at(i).path);
|
||||
}
|
||||
|
||||
DecrementReferences(n);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VUndoCommand::IncrementReferences(const QVector<VPieceNode> &nodes) const
|
||||
{
|
||||
QVector<quint32> n;
|
||||
|
||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
n.append(nodes.at(i).GetId());
|
||||
}
|
||||
|
||||
IncrementReferences(n);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VUndoCommand::DecrementReferences(const QVector<VPieceNode> &nodes) const
|
||||
{
|
||||
QVector<quint32> n;
|
||||
|
||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
doc->DecrementReferens(nodes.at(i).GetId());
|
||||
n.append(nodes.at(i).GetId());
|
||||
}
|
||||
|
||||
DecrementReferences(n);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,13 @@ protected:
|
|||
|
||||
void IncrementReferences(const QVector<VNodeDetail> &nodes) const;
|
||||
void DecrementReferences(const QVector<VNodeDetail> &nodes) const;
|
||||
|
||||
void IncrementReferences(const QVector<quint32> &nodes) const;
|
||||
void DecrementReferences(const QVector<quint32> &nodes) const;
|
||||
|
||||
void IncrementReferences(const QVector<CustomSARecord> &nodes) const;
|
||||
void DecrementReferences(const QVector<CustomSARecord> &nodes) const;
|
||||
|
||||
void IncrementReferences(const QVector<VPieceNode> &nodes) const;
|
||||
void DecrementReferences(const QVector<VPieceNode> &nodes) const;
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user