diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index 4125a1ae3..5f04ab030 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -280,6 +280,8 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) actionShowLabel->setCheckable(true); actionShowLabel->setChecked(VAbstractTool::data.GeometricObject(m_id)->IsShowLabel()); + QAction *actionExclude = menu.addAction(tr("Exclude")); + QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); piece->referens() > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true); @@ -309,6 +311,10 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked())); } + else if (selectedAction == actionExclude) + { + emit ToggleExcludeState(m_id); + } } } diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.h b/src/libs/vtools/tools/nodeDetails/vnodepoint.h index 25186dd68..e2f0d44a4 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.h +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.h @@ -63,6 +63,7 @@ signals: void ShowOptions(); void ToggleInLayout(bool checked); void Delete(); + void ToggleExcludeState(quint32 id); public slots: virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; void NameChangePosition(const QPointF &pos); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 2b100586a..4cc0724b2 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1398,6 +1398,26 @@ void VToolSeamAllowance::DeleteFromMenu() DeleteToolWithConfirm(); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::ToggleExcludeState(quint32 id) +{ + const VPiece oldDet = VAbstractTool::data.GetPiece(m_id); + VPiece newDet = oldDet; + + for (int i = 0; i< oldDet.GetPath().CountNodes(); ++i) + { + VPieceNode node = oldDet.GetPath().at(i); + if (node.GetId() == id && node.GetTypeTool() == Tool::NodePoint) + { + node.SetExcluded(not node.IsExcluded()); + newDet.GetPath()[i] = node; + + qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); + return; + } + } +} + //--------------------------------------------------------------------------------------------------------------------- VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData, qreal &rotationAngle, qreal &labelWidth, qreal &labelHeight, QPointF &pos) @@ -1617,6 +1637,8 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc connect(tool, &VNodePoint::ToggleInLayout, parent, &VToolSeamAllowance::ToggleInLayout, Qt::UniqueConnection); connect(tool, &VNodePoint::Delete, parent, &VToolSeamAllowance::DeleteFromMenu, Qt::UniqueConnection); + connect(tool, &VNodePoint::ToggleExcludeState, parent, &VToolSeamAllowance::ToggleExcludeState, + Qt::UniqueConnection); connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem, Qt::UniqueConnection); tool->setParentItem(parent); tool->SetParentType(ParentType::Item); diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 889e1a9c4..27b35f03b 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -163,6 +163,7 @@ private slots: void ShowOptions(); void ToggleInLayout(bool checked); void DeleteFromMenu(); + void ToggleExcludeState(quint32 id); private: Q_DISABLE_COPY(VToolSeamAllowance) diff --git a/src/libs/vtools/undocommands/savepieceoptions.cpp b/src/libs/vtools/undocommands/savepieceoptions.cpp index b525a86ee..4a1e78c99 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.cpp +++ b/src/libs/vtools/undocommands/savepieceoptions.cpp @@ -168,6 +168,19 @@ bool SavePieceOptions::mergeWith(const QUndoCommand *command) { return false; } + + const QVector nodes = m_newDet.GetPath().GetNodes(); + const QVector candidateNodes = candidate.GetPath().GetNodes(); + + SCASSERT(nodes.size() == candidateNodes.size()) + + for (int i = 0; i < nodes.size(); ++i) + { + if (nodes.at(i).IsExcluded() != candidateNodes.at(i).IsExcluded()) + { + return false; + } + } } m_newDet = saveCommand->NewDet(); diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.cpp b/src/libs/vtools/undocommands/savepiecepathoptions.cpp index 2cd26a408..9c2fc6df1 100644 --- a/src/libs/vtools/undocommands/savepiecepathoptions.cpp +++ b/src/libs/vtools/undocommands/savepiecepathoptions.cpp @@ -36,6 +36,7 @@ #include "../vmisc/logging.h" #include "../tools/nodeDetails/vtoolpiecepath.h" #include "../tools/vtoolseamallowance.h" +#include "../vpatterndb/vpiecenode.h" //--------------------------------------------------------------------------------------------------------------------- SavePiecePathOptions::SavePiecePathOptions(quint32 pieceId, const VPiecePath &oldPath, const VPiecePath &newPath, @@ -138,6 +139,19 @@ bool SavePiecePathOptions::mergeWith(const QUndoCommand *command) { return false; } + + const QVector nodes = m_newPath.GetNodes(); + const QVector candidateNodes = candidate.GetNodes(); + + SCASSERT(nodes.size() == candidateNodes.size()) + + for (int i = 0; i < nodes.size(); ++i) + { + if (nodes.at(i).IsExcluded() != candidateNodes.at(i).IsExcluded()) + { + return false; + } + } } m_newPath = saveCommand->NewPath();