New feature. Allow to exclude piece node point from it's context menu.
--HG-- branch : develop
This commit is contained in:
parent
91b4c7c8fa
commit
72dde072af
|
@ -280,6 +280,8 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
actionShowLabel->setCheckable(true);
|
||||
actionShowLabel->setChecked(VAbstractTool::data.GeometricObject<VPointF>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -163,6 +163,7 @@ private slots:
|
|||
void ShowOptions();
|
||||
void ToggleInLayout(bool checked);
|
||||
void DeleteFromMenu();
|
||||
void ToggleExcludeState(quint32 id);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolSeamAllowance)
|
||||
|
|
|
@ -168,6 +168,19 @@ bool SavePieceOptions::mergeWith(const QUndoCommand *command)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const QVector<VPieceNode> nodes = m_newDet.GetPath().GetNodes();
|
||||
const QVector<VPieceNode> 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();
|
||||
|
|
|
@ -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<VPieceNode> nodes = m_newPath.GetNodes();
|
||||
const QVector<VPieceNode> 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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user