Improve piece node context menu. Added options to control passmark angle type

and passmark mark type.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-09-05 11:29:20 +03:00
parent 23ffeba014
commit 366e76a642
6 changed files with 454 additions and 143 deletions

View File

@ -29,6 +29,7 @@
- No scissors on tiled PDF bottom row. - No scissors on tiled PDF bottom row.
- All intersections are now treaded as a loop. - All intersections are now treaded as a loop.
- [#558] New export: Export pattern as step-by-step text. - [#558] New export: Export pattern as step-by-step text.
- Added options to control passmark angle type and passmark mark type.
# Version 0.6.2 (unreleased) # Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path. - [#903] Bug in tool Cut Spline path.

View File

@ -126,7 +126,8 @@ enum class PassmarkAngleType : unsigned char
IntersectionOnlyRight, IntersectionOnlyRight,
Intersection2, Intersection2,
Intersection2OnlyLeft, Intersection2OnlyLeft,
Intersection2OnlyRight Intersection2OnlyRight,
LAST_ONE_DO_NOT_USE
}; };
QString PassmarkAngleTypeToString(PassmarkAngleType type); QString PassmarkAngleTypeToString(PassmarkAngleType type);

View File

@ -64,6 +64,45 @@
const QString VNodePoint::ToolType = QStringLiteral("modeling"); const QString VNodePoint::ToolType = QStringLiteral("modeling");
namespace
{
enum class ContextMenuOption : int
{
NoSelection,
ShowLabel,
Passmark,
Exclude,
ByLength,
ByPointsIntersection,
ByFirstEdgeSymmetry,
BySecondEdgeSymmetry,
ByFirstEdgeRightAngle,
BySecondEdgeRightAngle,
Straightforward,
Bisector,
Intersection,
IntersectionOnlyLeft,
IntersectionOnlyRight,
Intersection2,
Intersection2OnlyLeft,
Intersection2OnlyRight,
OneLine,
TwoLines,
ThreeLines,
TMark,
VMark,
VMark2,
UMark,
BoxMark,
Option,
InLayout,
ForbidFlipping,
ForceFlipping,
Remove,
LAST_ONE_DO_NOT_USE
};
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VNodePoint constructor. * @brief VNodePoint constructor.
@ -266,6 +305,222 @@ void VNodePoint::HideNode()
hide(); hide();
} }
//---------------------------------------------------------------------------------------------------------------------
QHash<int, QAction *> VNodePoint::InitContextMenu(QMenu *menu, vidtype pieceId, quint32 referens)
{
SCASSERT(menu != nullptr)
QHash<int, QAction *> contextMenu;
QAction *actionShowLabel = menu->addAction(tr("Show label"));
actionShowLabel->setCheckable(true);
actionShowLabel->setChecked(VAbstractTool::data.GeometricObject<VPointF>(m_id)->IsShowLabel());
contextMenu.insert(static_cast<int>(ContextMenuOption::ShowLabel), actionShowLabel);
InitPassmarkMenu(menu, pieceId, contextMenu);
contextMenu.insert(static_cast<int>(ContextMenuOption::Exclude), menu->addAction(tr("Exclude")));
InitAngleTypeMenu(menu, pieceId, contextMenu);
InitPassmarkAngleTypeMenu(menu, pieceId, contextMenu);
InitPassmarkLineTypeMenu(menu, pieceId, contextMenu);
QAction *separatorAct = new QAction(this);
separatorAct->setSeparator(true);
menu->addAction(separatorAct);
contextMenu.insert(static_cast<int>(ContextMenuOption::Option),
menu->addAction(QIcon::fromTheme(QStringLiteral("preferences-other")), tr("Options")));
const VPiece detail = VAbstractTool::data.GetPiece(pieceId);
QAction *inLayoutOption = menu->addAction(tr("In layout"));
inLayoutOption->setCheckable(true);
inLayoutOption->setChecked(detail.IsInLayout());
contextMenu.insert(static_cast<int>(ContextMenuOption::InLayout), inLayoutOption);
QAction *forbidFlippingOption = menu->addAction(tr("Forbid flipping"));
forbidFlippingOption->setCheckable(true);
forbidFlippingOption->setChecked(detail.IsForbidFlipping());
contextMenu.insert(static_cast<int>(ContextMenuOption::ForbidFlipping), forbidFlippingOption);
QAction *forceFlippingOption = menu->addAction(tr("Force flipping"));
forceFlippingOption->setCheckable(true);
forceFlippingOption->setChecked(detail.IsForceFlipping());
contextMenu.insert(static_cast<int>(ContextMenuOption::ForceFlipping), forceFlippingOption);
QAction *actionRemove = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Delete"));
referens > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true);
contextMenu.insert(static_cast<int>(ContextMenuOption::Remove), actionRemove);
return contextMenu;
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::InitPassmarkMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu)
{
QAction *actionPassmark = menu->addAction(tr("Passmark"));
actionPassmark->setCheckable(true);
const VPiece detail = VAbstractTool::data.GetPiece(pieceId);
const int nodeIndex = detail.GetPath().indexOfNode(m_id);
if (nodeIndex != -1)
{
const VPieceNode &node = detail.GetPath().at(nodeIndex);
actionPassmark->setChecked(node.IsPassmark());
actionPassmark->setVisible(node.IsPassmark());
}
else
{
actionPassmark->setVisible(false);
}
contextMenu.insert(static_cast<int>(ContextMenuOption::Passmark), actionPassmark);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::InitAngleTypeMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu)
{
QMenu *angleTypeMenu = menu->addMenu(tr("Seam allowance angle"));
PieceNodeAngle curType = PieceNodeAngle::ByLength;
const VPiece detail = VAbstractTool::data.GetPiece(pieceId);
const int nodeIndex = detail.GetPath().indexOfNode(m_id);
if (nodeIndex != -1)
{
const VPieceNode &node = detail.GetPath().at(nodeIndex);
curType = node.GetAngleType();
angleTypeMenu->setEnabled(detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn());
}
else
{
angleTypeMenu->setVisible(false);
}
auto InitAngleAction = [angleTypeMenu, curType](const QString &name, PieceNodeAngle checkType)
{
QAction *action = angleTypeMenu->addAction(name);
action->setCheckable(true);
action->setChecked(curType == checkType);
return action;
};
Q_STATIC_ASSERT_X(static_cast<int>(PieceNodeAngle::LAST_ONE_DO_NOT_USE) == 7, "Not all types were handled.");
contextMenu.insert(static_cast<int>(ContextMenuOption::ByLength),
InitAngleAction(tr("by length"), PieceNodeAngle::ByLength));
contextMenu.insert(static_cast<int>(ContextMenuOption::ByPointsIntersection),
InitAngleAction(tr("by points intersetions"), PieceNodeAngle::ByPointsIntersection));
contextMenu.insert(static_cast<int>(ContextMenuOption::ByFirstEdgeSymmetry),
InitAngleAction(tr("by first edge symmetry"), PieceNodeAngle::ByFirstEdgeSymmetry));
contextMenu.insert(static_cast<int>(ContextMenuOption::BySecondEdgeSymmetry),
InitAngleAction(tr("by second edge symmetry"), PieceNodeAngle::BySecondEdgeSymmetry));
contextMenu.insert(static_cast<int>(ContextMenuOption::ByFirstEdgeRightAngle),
InitAngleAction(tr("by first edge right angle"), PieceNodeAngle::ByFirstEdgeRightAngle));
contextMenu.insert(static_cast<int>(ContextMenuOption::BySecondEdgeRightAngle),
InitAngleAction(tr("by second edge right angle"), PieceNodeAngle::BySecondEdgeRightAngle));
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::InitPassmarkAngleTypeMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu)
{
QMenu *passmarkAngleMenu = menu->addMenu(tr("Passmark angle"));
PassmarkAngleType passmarkAngleCurType = PassmarkAngleType::Straightforward;
const VPiece detail = VAbstractTool::data.GetPiece(pieceId);
const int nodeIndex = detail.GetPath().indexOfNode(m_id);
if (nodeIndex != -1)
{
const VPieceNode &node = detail.GetPath().at(nodeIndex);
passmarkAngleMenu->setEnabled(node.IsPassmark());
passmarkAngleCurType = node.GetPassmarkAngleType();
}
else
{
passmarkAngleMenu->setVisible(false);
}
auto InitPassmarkAngleAction = [passmarkAngleMenu, passmarkAngleCurType](const QString &name,
PassmarkAngleType checkType)
{
QAction *action = passmarkAngleMenu->addAction(name);
action->setCheckable(true);
action->setChecked(passmarkAngleCurType == checkType);
return action;
};
Q_STATIC_ASSERT_X(static_cast<int>(PassmarkAngleType::LAST_ONE_DO_NOT_USE) == 8, "Not all types were handled.");
contextMenu.insert(static_cast<int>(ContextMenuOption::Straightforward),
InitPassmarkAngleAction(tr("Straightforward"), PassmarkAngleType::Straightforward));
contextMenu.insert(static_cast<int>(ContextMenuOption::Bisector),
InitPassmarkAngleAction(tr("Bisector"), PassmarkAngleType::Bisector));
contextMenu.insert(static_cast<int>(ContextMenuOption::Intersection),
InitPassmarkAngleAction(tr("Intersection"), PassmarkAngleType::Intersection));
contextMenu.insert(static_cast<int>(ContextMenuOption::IntersectionOnlyLeft),
InitPassmarkAngleAction(tr("Intersection (only left)"),
PassmarkAngleType::IntersectionOnlyLeft));
contextMenu.insert(static_cast<int>(ContextMenuOption::IntersectionOnlyRight),
InitPassmarkAngleAction(tr("Intersection (only right)"),
PassmarkAngleType::IntersectionOnlyRight));
contextMenu.insert(static_cast<int>(ContextMenuOption::Intersection2),
InitPassmarkAngleAction(tr("Intersection 2"), PassmarkAngleType::Intersection2));
contextMenu.insert(static_cast<int>(ContextMenuOption::Intersection2OnlyLeft),
InitPassmarkAngleAction(tr("Intersection 2 (only left)"),
PassmarkAngleType::Intersection2OnlyLeft));
contextMenu.insert(static_cast<int>(ContextMenuOption::Intersection2OnlyRight),
InitPassmarkAngleAction(tr("Intersection 2 (only right)"),
PassmarkAngleType::Intersection2OnlyRight));
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::InitPassmarkLineTypeMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu)
{
QMenu *passmarkLineTypeMenu = menu->addMenu(tr("Passmark mark"));
PassmarkLineType passmarkLineCurType = PassmarkLineType::OneLine;
const VPiece detail = VAbstractTool::data.GetPiece(pieceId);
const int nodeIndex = detail.GetPath().indexOfNode(m_id);
if (nodeIndex != -1)
{
const VPieceNode &node = detail.GetPath().at(nodeIndex);
passmarkLineTypeMenu->setEnabled(node.IsPassmark());
passmarkLineCurType = node.GetPassmarkLineType();
}
else
{
passmarkLineTypeMenu->setVisible(false);
}
auto InitPassmarkLineTypeAction = [passmarkLineTypeMenu, passmarkLineCurType](const QString &name,
PassmarkLineType checkType)
{
QAction *action = passmarkLineTypeMenu->addAction(name);
action->setCheckable(true);
action->setChecked(passmarkLineCurType == checkType);
return action;
};
Q_STATIC_ASSERT_X(static_cast<int>(PassmarkLineType::LAST_ONE_DO_NOT_USE) == 8, "Not all types were handled.");
contextMenu.insert(static_cast<int>(ContextMenuOption::OneLine),
InitPassmarkLineTypeAction(tr("One line"), PassmarkLineType::OneLine));
contextMenu.insert(static_cast<int>(ContextMenuOption::TwoLines),
InitPassmarkLineTypeAction(tr("Two lines"), PassmarkLineType::TwoLines));
contextMenu.insert(static_cast<int>(ContextMenuOption::ThreeLines),
InitPassmarkLineTypeAction(tr("Three lines"), PassmarkLineType::ThreeLines));
contextMenu.insert(static_cast<int>(ContextMenuOption::TMark),
InitPassmarkLineTypeAction(tr("T mark"), PassmarkLineType::TMark));
contextMenu.insert(static_cast<int>(ContextMenuOption::VMark),
InitPassmarkLineTypeAction(tr("V mark"), PassmarkLineType::VMark));
contextMenu.insert(static_cast<int>(ContextMenuOption::VMark2),
InitPassmarkLineTypeAction(tr("V mark 2"), PassmarkLineType::VMark2));
contextMenu.insert(static_cast<int>(ContextMenuOption::UMark),
InitPassmarkLineTypeAction(tr("U mark"), PassmarkLineType::UMark));
contextMenu.insert(static_cast<int>(ContextMenuOption::BoxMark),
InitPassmarkLineTypeAction(tr("Box mark"), PassmarkLineType::BoxMark));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
@ -277,161 +532,161 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
if (VToolSeamAllowance *piece = qgraphicsitem_cast<VToolSeamAllowance *>(parentItem())) if (VToolSeamAllowance *piece = qgraphicsitem_cast<VToolSeamAllowance *>(parentItem()))
{ {
QMenu menu; QMenu menu;
QAction *actionShowLabel = menu.addAction(tr("Show label")); QHash<int, QAction *> contextMenu = InitContextMenu(&menu, piece->getId(), piece->referens());
actionShowLabel->setCheckable(true);
actionShowLabel->setChecked(VAbstractTool::data.GeometricObject<VPointF>(m_id)->IsShowLabel());
QAction *actionPassmark = menu.addAction(tr("Passmark")); PieceNodeAngle angleCurType = PieceNodeAngle::ByLength;
actionPassmark->setCheckable(true); PassmarkAngleType passmarkAngleCurType = PassmarkAngleType::Straightforward;
PassmarkLineType passmarkLineCurType = PassmarkLineType::OneLine;
QAction *actionExclude = menu.addAction(tr("Exclude"));
QMenu *angleTypeMenu = menu.addMenu(tr("Angle"));
PieceNodeAngle curType = PieceNodeAngle::ByLength;
const VPiece detail = VAbstractTool::data.GetPiece(piece->getId()); const VPiece detail = VAbstractTool::data.GetPiece(piece->getId());
const int nodeIndex = detail.GetPath().indexOfNode(m_id); const int nodeIndex = detail.GetPath().indexOfNode(m_id);
if (nodeIndex != -1) if (nodeIndex != -1)
{ {
const VPieceNode &node = detail.GetPath().at(nodeIndex); const VPieceNode &node = detail.GetPath().at(nodeIndex);
curType = node.GetAngleType(); angleCurType = node.GetAngleType();
passmarkAngleCurType = node.GetPassmarkAngleType();
actionPassmark->setChecked(node.IsPassmark()); passmarkLineCurType = node.GetPassmarkLineType();
actionPassmark->setVisible(node.IsPassmark());
angleTypeMenu->setEnabled(detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn());
}
else
{
angleTypeMenu->setVisible(false);
actionPassmark->setVisible(false);
} }
auto InitAngleAction = [angleTypeMenu, curType](const QString &name, PieceNodeAngle checkType) auto SelectSeamAllowanceAngle = [angleCurType, this](PieceNodeAngle type)
{ {
QAction *action = angleTypeMenu->addAction(name); if (angleCurType != type)
action->setCheckable(true); {
action->setChecked(curType == checkType); emit ToggleSeamAllowanceAngleType(m_id, type);
return action; }
}; };
QAction *actionByLength = InitAngleAction(tr("by length"), PieceNodeAngle::ByLength); auto SelectPassmarkAngle = [passmarkAngleCurType, this](PassmarkAngleType type)
QAction *actionByPointsIntersection = InitAngleAction(tr("by points intersetions"), {
PieceNodeAngle::ByPointsIntersection); if (passmarkAngleCurType != type)
QAction *actionByFirstEdgeSymmetry = InitAngleAction(tr("by first edge symmetry"), {
PieceNodeAngle::ByFirstEdgeSymmetry); emit TogglePassmarkAngleType(m_id, type);
QAction *actionBySecondEdgeSymmetry = InitAngleAction(tr("by second edge symmetry"), }
PieceNodeAngle::BySecondEdgeSymmetry); };
QAction *actionByFirstEdgeRightAngle = InitAngleAction(tr("by first edge right angle"),
PieceNodeAngle::ByFirstEdgeRightAngle);
QAction *actionBySecondEdgeRightAngle = InitAngleAction(tr("by second edge right angle"),
PieceNodeAngle::BySecondEdgeRightAngle);
QAction *separatorAct = new QAction(this); auto SelectPassmarkLine = [passmarkLineCurType, this](PassmarkLineType type)
separatorAct->setSeparator(true); {
menu.addAction(separatorAct); if (passmarkLineCurType != type)
{
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options")); emit TogglePassmarkLineType(m_id, type);
}
QAction *inLayoutOption = menu.addAction(tr("In layout")); };
inLayoutOption->setCheckable(true);
inLayoutOption->setChecked(detail.IsInLayout());
QAction *forbidFlippingOption = menu.addAction(tr("Forbid flipping"));
forbidFlippingOption->setCheckable(true);
forbidFlippingOption->setChecked(detail.IsForbidFlipping());
QAction *forceFlippingOption = menu.addAction(tr("Force flipping"));
forceFlippingOption->setCheckable(true);
forceFlippingOption->setChecked(detail.IsForceFlipping());
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
piece->referens() > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true);
QAction *selectedAction = menu.exec(event->screenPos()); QAction *selectedAction = menu.exec(event->screenPos());
if (selectedAction == actionOption) ContextMenuOption selectedOption = static_cast<ContextMenuOption>(
contextMenu.key(selectedAction, static_cast<int>(ContextMenuOption::NoSelection)));
Q_STATIC_ASSERT_X(static_cast<int>(ContextMenuOption::LAST_ONE_DO_NOT_USE) == 31,
"Not all options were handled.");
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(selectedOption)
{ {
emit ShowOptions(); case ContextMenuOption::LAST_ONE_DO_NOT_USE:
} Q_UNREACHABLE();
else if (selectedAction == inLayoutOption) case ContextMenuOption::NoSelection:
{ return;
emit ToggleInLayout(selectedAction->isChecked()); case ContextMenuOption::Option:
} emit ShowOptions();
else if (selectedAction == forbidFlippingOption) break;
{ case ContextMenuOption::InLayout:
emit ToggleForbidFlipping(selectedAction->isChecked()); emit ToggleInLayout(selectedAction->isChecked());
} break;
else if (selectedAction == forceFlippingOption) case ContextMenuOption::ForbidFlipping:
{ emit ToggleForbidFlipping(selectedAction->isChecked());
emit ToggleForceFlipping(selectedAction->isChecked()); break;
} case ContextMenuOption::ForceFlipping:
else if (selectedAction == actionRemove) emit ToggleForceFlipping(selectedAction->isChecked());
{ break;
try case ContextMenuOption::Remove:
{ try
emit Delete(); {
} emit Delete();
catch(const VExceptionToolWasDeleted &e) }
{ catch(const VExceptionToolWasDeleted &e)
Q_UNUSED(e); {
return;//Leave this method immediately!!! Q_UNUSED(e);
} return;//Leave this method immediately!!!
//Leave this method immediately after call!!! }
} return;//Leave this method immediately after call!!!
else if (selectedAction == actionShowLabel) case ContextMenuOption::ShowLabel:
{ qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked()));
qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked())); break;
} case ContextMenuOption::Exclude:
else if (selectedAction == actionExclude) emit ToggleExcludeState(m_id);
{ break;
emit ToggleExcludeState(m_id); case ContextMenuOption::ByLength:
} SelectSeamAllowanceAngle(PieceNodeAngle::ByLength);
else if (selectedAction == actionByLength) break;
{ case ContextMenuOption::ByPointsIntersection:
if (curType != PieceNodeAngle::ByLength) SelectSeamAllowanceAngle(PieceNodeAngle::ByPointsIntersection);
{ break;
emit ToggleAngleType(m_id, PieceNodeAngle::ByLength); case ContextMenuOption::ByFirstEdgeSymmetry:
} SelectSeamAllowanceAngle(PieceNodeAngle::ByFirstEdgeSymmetry);
} break;
else if (selectedAction == actionByPointsIntersection) case ContextMenuOption::BySecondEdgeSymmetry:
{ SelectSeamAllowanceAngle(PieceNodeAngle::BySecondEdgeSymmetry);
if (curType != PieceNodeAngle::ByPointsIntersection) break;
{ case ContextMenuOption::ByFirstEdgeRightAngle:
emit ToggleAngleType(m_id, PieceNodeAngle::ByPointsIntersection); SelectSeamAllowanceAngle(PieceNodeAngle::ByFirstEdgeRightAngle);
} break;
} case ContextMenuOption::BySecondEdgeRightAngle:
else if (selectedAction == actionByFirstEdgeSymmetry) SelectSeamAllowanceAngle(PieceNodeAngle::BySecondEdgeRightAngle);
{ break;
if (curType != PieceNodeAngle::ByFirstEdgeSymmetry) case ContextMenuOption::Passmark:
{ emit TogglePassmark(m_id, false);
emit ToggleAngleType(m_id, PieceNodeAngle::ByFirstEdgeSymmetry); break;
} case ContextMenuOption::Straightforward:
} SelectPassmarkAngle(PassmarkAngleType::Straightforward);
else if (selectedAction == actionBySecondEdgeSymmetry) break;
{ case ContextMenuOption::Bisector:
if (curType != PieceNodeAngle::BySecondEdgeSymmetry) SelectPassmarkAngle(PassmarkAngleType::Bisector);
{ break;
emit ToggleAngleType(m_id, PieceNodeAngle::BySecondEdgeSymmetry); case ContextMenuOption::Intersection:
} SelectPassmarkAngle(PassmarkAngleType::Intersection);
} break;
else if (selectedAction == actionByFirstEdgeRightAngle) case ContextMenuOption::IntersectionOnlyLeft:
{ SelectPassmarkAngle(PassmarkAngleType::IntersectionOnlyLeft);
if (curType != PieceNodeAngle::ByFirstEdgeRightAngle) break;
{ case ContextMenuOption::IntersectionOnlyRight:
emit ToggleAngleType(m_id, PieceNodeAngle::ByFirstEdgeRightAngle); SelectPassmarkAngle(PassmarkAngleType::IntersectionOnlyRight);
} break;
} case ContextMenuOption::Intersection2:
else if (selectedAction == actionBySecondEdgeRightAngle) SelectPassmarkAngle(PassmarkAngleType::Intersection2);
{ break;
if (curType != PieceNodeAngle::BySecondEdgeRightAngle) case ContextMenuOption::Intersection2OnlyLeft:
{ SelectPassmarkAngle(PassmarkAngleType::Intersection2OnlyLeft);
emit ToggleAngleType(m_id, PieceNodeAngle::BySecondEdgeRightAngle); break;
} case ContextMenuOption::Intersection2OnlyRight:
} SelectPassmarkAngle(PassmarkAngleType::Intersection2OnlyRight);
else if (selectedAction == actionPassmark) break;
{ case ContextMenuOption::OneLine:
emit TogglePassmark(m_id, false); SelectPassmarkLine(PassmarkLineType::OneLine);
} break;
case ContextMenuOption::TwoLines:
SelectPassmarkLine(PassmarkLineType::TwoLines);
break;
case ContextMenuOption::ThreeLines:
SelectPassmarkLine(PassmarkLineType::ThreeLines);
break;
case ContextMenuOption::TMark:
SelectPassmarkLine(PassmarkLineType::TMark);
break;
case ContextMenuOption::VMark:
SelectPassmarkLine(PassmarkLineType::VMark);
break;
case ContextMenuOption::VMark2:
SelectPassmarkLine(PassmarkLineType::VMark2);
break;
case ContextMenuOption::UMark:
SelectPassmarkLine(PassmarkLineType::UMark);
break;
case ContextMenuOption::BoxMark:
SelectPassmarkLine(PassmarkLineType::BoxMark);
break;
};
QT_WARNING_POP
} }
} }

View File

@ -66,8 +66,10 @@ signals:
void ToggleForceFlipping(bool checked); void ToggleForceFlipping(bool checked);
void Delete(); void Delete();
void ToggleExcludeState(quint32 id); void ToggleExcludeState(quint32 id);
void ToggleAngleType(quint32 id, PieceNodeAngle type); void ToggleSeamAllowanceAngleType(quint32 id, PieceNodeAngle type);
void TogglePassmark(quint32 id, bool toggle); void TogglePassmark(quint32 id, bool toggle);
void TogglePassmarkAngleType(quint32 id, PassmarkAngleType type);
void TogglePassmarkLineType(quint32 id, PassmarkLineType type);
public slots: public slots:
virtual void FullUpdateFromFile() override; virtual void FullUpdateFromFile() override;
void NameChangePosition(const QPointF &pos); void NameChangePosition(const QPointF &pos);
@ -89,6 +91,12 @@ private:
Q_DISABLE_COPY(VNodePoint) Q_DISABLE_COPY(VNodePoint)
VNodePoint(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr, QGraphicsItem *parent = nullptr); VNodePoint(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr, QGraphicsItem *parent = nullptr);
QHash<int, QAction *> InitContextMenu(QMenu *menu, vidtype pieceId, quint32 referens);
void InitPassmarkMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu);
void InitAngleTypeMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu);
void InitPassmarkAngleTypeMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu);
void InitPassmarkLineTypeMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu);
}; };
#endif // VNODEPOINT_H #endif // VNODEPOINT_H

View File

@ -1526,6 +1526,46 @@ void VToolSeamAllowance::ToggleNodePointPassmark(quint32 id, bool toggle)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::TogglePassmarkAngleType(quint32 id, PassmarkAngleType type)
{
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.SetPassmarkAngleType(type);
newDet.GetPath()[i] = node;
qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id));
return;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::TogglePassmarkLineType(quint32 id, PassmarkLineType type)
{
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.SetPassmarkLineType(type);
newDet.GetPath()[i] = node;
qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id));
return;
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData, VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData,
const QVector<quint32> &pins, qreal &rotationAngle, const QVector<quint32> &pins, qreal &rotationAngle,
@ -1754,11 +1794,15 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc
connect(tool, &VNodePoint::Delete, parent, &VToolSeamAllowance::DeleteFromMenu, Qt::UniqueConnection); connect(tool, &VNodePoint::Delete, parent, &VToolSeamAllowance::DeleteFromMenu, Qt::UniqueConnection);
connect(tool, &VNodePoint::ToggleExcludeState, parent, &VToolSeamAllowance::ToggleExcludeState, connect(tool, &VNodePoint::ToggleExcludeState, parent, &VToolSeamAllowance::ToggleExcludeState,
Qt::UniqueConnection); Qt::UniqueConnection);
connect(tool, &VNodePoint::ToggleAngleType, parent, &VToolSeamAllowance::ToggleNodePointAngleType, connect(tool, &VNodePoint::ToggleSeamAllowanceAngleType, parent,
Qt::UniqueConnection); &VToolSeamAllowance::ToggleNodePointAngleType, Qt::UniqueConnection);
connect(tool, &VNodePoint::TogglePassmark, parent, &VToolSeamAllowance::ToggleNodePointPassmark, connect(tool, &VNodePoint::TogglePassmark, parent, &VToolSeamAllowance::ToggleNodePointPassmark,
Qt::UniqueConnection); Qt::UniqueConnection);
connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem, Qt::UniqueConnection); connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem, Qt::UniqueConnection);
connect(tool, &VNodePoint::TogglePassmarkAngleType, parent,
&VToolSeamAllowance::TogglePassmarkAngleType, Qt::UniqueConnection);
connect(tool, &VNodePoint::TogglePassmarkLineType, parent,
&VToolSeamAllowance::TogglePassmarkLineType, Qt::UniqueConnection);
tool->setParentItem(parent); tool->setParentItem(parent);
tool->SetParentType(ParentType::Item); tool->SetParentType(ParentType::Item);
tool->SetExluded(node.IsExcluded()); tool->SetExluded(node.IsExcluded());

View File

@ -169,6 +169,8 @@ private slots:
void ToggleExcludeState(quint32 id); void ToggleExcludeState(quint32 id);
void ToggleNodePointAngleType(quint32 id, PieceNodeAngle type); void ToggleNodePointAngleType(quint32 id, PieceNodeAngle type);
void ToggleNodePointPassmark(quint32 id, bool toggle); void ToggleNodePointPassmark(quint32 id, bool toggle);
void TogglePassmarkAngleType(quint32 id, PassmarkAngleType type);
void TogglePassmarkLineType(quint32 id, PassmarkLineType type);
private: private:
Q_DISABLE_COPY(VToolSeamAllowance) Q_DISABLE_COPY(VToolSeamAllowance)