Improve piece node context menu. Added options to control passmark angle type
and passmark mark type. --HG-- branch : develop
This commit is contained in:
parent
23ffeba014
commit
366e76a642
|
@ -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.
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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.
|
||||||
|
@ -267,44 +306,97 @@ void VNodePoint::HideNode()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
QHash<int, QAction *> VNodePoint::InitContextMenu(QMenu *menu, vidtype pieceId, quint32 referens)
|
||||||
{
|
{
|
||||||
if (m_suppressContextMenu)
|
SCASSERT(menu != nullptr)
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VToolSeamAllowance *piece = qgraphicsitem_cast<VToolSeamAllowance *>(parentItem()))
|
QHash<int, QAction *> contextMenu;
|
||||||
{
|
|
||||||
QMenu menu;
|
QAction *actionShowLabel = menu->addAction(tr("Show label"));
|
||||||
QAction *actionShowLabel = menu.addAction(tr("Show label"));
|
|
||||||
actionShowLabel->setCheckable(true);
|
actionShowLabel->setCheckable(true);
|
||||||
actionShowLabel->setChecked(VAbstractTool::data.GeometricObject<VPointF>(m_id)->IsShowLabel());
|
actionShowLabel->setChecked(VAbstractTool::data.GeometricObject<VPointF>(m_id)->IsShowLabel());
|
||||||
|
contextMenu.insert(static_cast<int>(ContextMenuOption::ShowLabel), actionShowLabel);
|
||||||
|
|
||||||
QAction *actionPassmark = menu.addAction(tr("Passmark"));
|
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);
|
actionPassmark->setCheckable(true);
|
||||||
|
|
||||||
QAction *actionExclude = menu.addAction(tr("Exclude"));
|
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);
|
||||||
|
|
||||||
QMenu *angleTypeMenu = menu.addMenu(tr("Angle"));
|
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;
|
PieceNodeAngle curType = PieceNodeAngle::ByLength;
|
||||||
|
|
||||||
const VPiece detail = VAbstractTool::data.GetPiece(piece->getId());
|
const VPiece detail = VAbstractTool::data.GetPiece(pieceId);
|
||||||
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();
|
curType = node.GetAngleType();
|
||||||
|
|
||||||
actionPassmark->setChecked(node.IsPassmark());
|
|
||||||
actionPassmark->setVisible(node.IsPassmark());
|
|
||||||
|
|
||||||
angleTypeMenu->setEnabled(detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn());
|
angleTypeMenu->setEnabled(detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
angleTypeMenu->setVisible(false);
|
angleTypeMenu->setVisible(false);
|
||||||
actionPassmark->setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto InitAngleAction = [angleTypeMenu, curType](const QString &name, PieceNodeAngle checkType)
|
auto InitAngleAction = [angleTypeMenu, curType](const QString &name, PieceNodeAngle checkType)
|
||||||
|
@ -315,58 +407,199 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
return action;
|
return action;
|
||||||
};
|
};
|
||||||
|
|
||||||
QAction *actionByLength = InitAngleAction(tr("by length"), PieceNodeAngle::ByLength);
|
Q_STATIC_ASSERT_X(static_cast<int>(PieceNodeAngle::LAST_ONE_DO_NOT_USE) == 7, "Not all types were handled.");
|
||||||
QAction *actionByPointsIntersection = InitAngleAction(tr("by points intersetions"),
|
contextMenu.insert(static_cast<int>(ContextMenuOption::ByLength),
|
||||||
PieceNodeAngle::ByPointsIntersection);
|
InitAngleAction(tr("by length"), PieceNodeAngle::ByLength));
|
||||||
QAction *actionByFirstEdgeSymmetry = InitAngleAction(tr("by first edge symmetry"),
|
contextMenu.insert(static_cast<int>(ContextMenuOption::ByPointsIntersection),
|
||||||
PieceNodeAngle::ByFirstEdgeSymmetry);
|
InitAngleAction(tr("by points intersetions"), PieceNodeAngle::ByPointsIntersection));
|
||||||
QAction *actionBySecondEdgeSymmetry = InitAngleAction(tr("by second edge symmetry"),
|
contextMenu.insert(static_cast<int>(ContextMenuOption::ByFirstEdgeSymmetry),
|
||||||
PieceNodeAngle::BySecondEdgeSymmetry);
|
InitAngleAction(tr("by first edge symmetry"), PieceNodeAngle::ByFirstEdgeSymmetry));
|
||||||
QAction *actionByFirstEdgeRightAngle = InitAngleAction(tr("by first edge right angle"),
|
contextMenu.insert(static_cast<int>(ContextMenuOption::BySecondEdgeSymmetry),
|
||||||
PieceNodeAngle::ByFirstEdgeRightAngle);
|
InitAngleAction(tr("by second edge symmetry"), PieceNodeAngle::BySecondEdgeSymmetry));
|
||||||
QAction *actionBySecondEdgeRightAngle = InitAngleAction(tr("by second edge right angle"),
|
contextMenu.insert(static_cast<int>(ContextMenuOption::ByFirstEdgeRightAngle),
|
||||||
PieceNodeAngle::BySecondEdgeRightAngle);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
QAction *separatorAct = new QAction(this);
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
separatorAct->setSeparator(true);
|
void VNodePoint::InitPassmarkAngleTypeMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu)
|
||||||
menu.addAction(separatorAct);
|
{
|
||||||
|
QMenu *passmarkAngleMenu = menu->addMenu(tr("Passmark angle"));
|
||||||
|
PassmarkAngleType passmarkAngleCurType = PassmarkAngleType::Straightforward;
|
||||||
|
|
||||||
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
QAction *inLayoutOption = menu.addAction(tr("In layout"));
|
auto InitPassmarkAngleAction = [passmarkAngleMenu, passmarkAngleCurType](const QString &name,
|
||||||
inLayoutOption->setCheckable(true);
|
PassmarkAngleType checkType)
|
||||||
inLayoutOption->setChecked(detail.IsInLayout());
|
{
|
||||||
|
QAction *action = passmarkAngleMenu->addAction(name);
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(passmarkAngleCurType == checkType);
|
||||||
|
return action;
|
||||||
|
};
|
||||||
|
|
||||||
QAction *forbidFlippingOption = menu.addAction(tr("Forbid flipping"));
|
Q_STATIC_ASSERT_X(static_cast<int>(PassmarkAngleType::LAST_ONE_DO_NOT_USE) == 8, "Not all types were handled.");
|
||||||
forbidFlippingOption->setCheckable(true);
|
contextMenu.insert(static_cast<int>(ContextMenuOption::Straightforward),
|
||||||
forbidFlippingOption->setChecked(detail.IsForbidFlipping());
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
QAction *forceFlippingOption = menu.addAction(tr("Force flipping"));
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
forceFlippingOption->setCheckable(true);
|
void VNodePoint::InitPassmarkLineTypeMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu)
|
||||||
forceFlippingOption->setChecked(detail.IsForceFlipping());
|
{
|
||||||
|
QMenu *passmarkLineTypeMenu = menu->addMenu(tr("Passmark mark"));
|
||||||
|
PassmarkLineType passmarkLineCurType = PassmarkLineType::OneLine;
|
||||||
|
|
||||||
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
const VPiece detail = VAbstractTool::data.GetPiece(pieceId);
|
||||||
piece->referens() > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true);
|
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)
|
||||||
|
{
|
||||||
|
if (m_suppressContextMenu)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VToolSeamAllowance *piece = qgraphicsitem_cast<VToolSeamAllowance *>(parentItem()))
|
||||||
|
{
|
||||||
|
QMenu menu;
|
||||||
|
QHash<int, QAction *> contextMenu = InitContextMenu(&menu, piece->getId(), piece->referens());
|
||||||
|
|
||||||
|
PieceNodeAngle angleCurType = PieceNodeAngle::ByLength;
|
||||||
|
PassmarkAngleType passmarkAngleCurType = PassmarkAngleType::Straightforward;
|
||||||
|
PassmarkLineType passmarkLineCurType = PassmarkLineType::OneLine;
|
||||||
|
|
||||||
|
const VPiece detail = VAbstractTool::data.GetPiece(piece->getId());
|
||||||
|
const int nodeIndex = detail.GetPath().indexOfNode(m_id);
|
||||||
|
if (nodeIndex != -1)
|
||||||
|
{
|
||||||
|
const VPieceNode &node = detail.GetPath().at(nodeIndex);
|
||||||
|
angleCurType = node.GetAngleType();
|
||||||
|
passmarkAngleCurType = node.GetPassmarkAngleType();
|
||||||
|
passmarkLineCurType = node.GetPassmarkLineType();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto SelectSeamAllowanceAngle = [angleCurType, this](PieceNodeAngle type)
|
||||||
|
{
|
||||||
|
if (angleCurType != type)
|
||||||
|
{
|
||||||
|
emit ToggleSeamAllowanceAngleType(m_id, type);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto SelectPassmarkAngle = [passmarkAngleCurType, this](PassmarkAngleType type)
|
||||||
|
{
|
||||||
|
if (passmarkAngleCurType != type)
|
||||||
|
{
|
||||||
|
emit TogglePassmarkAngleType(m_id, type);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto SelectPassmarkLine = [passmarkLineCurType, this](PassmarkLineType type)
|
||||||
|
{
|
||||||
|
if (passmarkLineCurType != type)
|
||||||
|
{
|
||||||
|
emit TogglePassmarkLineType(m_id, type);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
case ContextMenuOption::LAST_ONE_DO_NOT_USE:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
case ContextMenuOption::NoSelection:
|
||||||
|
return;
|
||||||
|
case ContextMenuOption::Option:
|
||||||
emit ShowOptions();
|
emit ShowOptions();
|
||||||
}
|
break;
|
||||||
else if (selectedAction == inLayoutOption)
|
case ContextMenuOption::InLayout:
|
||||||
{
|
|
||||||
emit ToggleInLayout(selectedAction->isChecked());
|
emit ToggleInLayout(selectedAction->isChecked());
|
||||||
}
|
break;
|
||||||
else if (selectedAction == forbidFlippingOption)
|
case ContextMenuOption::ForbidFlipping:
|
||||||
{
|
|
||||||
emit ToggleForbidFlipping(selectedAction->isChecked());
|
emit ToggleForbidFlipping(selectedAction->isChecked());
|
||||||
}
|
break;
|
||||||
else if (selectedAction == forceFlippingOption)
|
case ContextMenuOption::ForceFlipping:
|
||||||
{
|
|
||||||
emit ToggleForceFlipping(selectedAction->isChecked());
|
emit ToggleForceFlipping(selectedAction->isChecked());
|
||||||
}
|
break;
|
||||||
else if (selectedAction == actionRemove)
|
case ContextMenuOption::Remove:
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
emit Delete();
|
emit Delete();
|
||||||
|
@ -376,62 +609,84 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
return;//Leave this method immediately!!!
|
return;//Leave this method immediately!!!
|
||||||
}
|
}
|
||||||
//Leave this method immediately after call!!!
|
return;//Leave this method immediately after call!!!
|
||||||
}
|
case ContextMenuOption::ShowLabel:
|
||||||
else if (selectedAction == actionShowLabel)
|
|
||||||
{
|
|
||||||
qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked()));
|
qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked()));
|
||||||
}
|
break;
|
||||||
else if (selectedAction == actionExclude)
|
case ContextMenuOption::Exclude:
|
||||||
{
|
|
||||||
emit ToggleExcludeState(m_id);
|
emit ToggleExcludeState(m_id);
|
||||||
}
|
break;
|
||||||
else if (selectedAction == actionByLength)
|
case ContextMenuOption::ByLength:
|
||||||
{
|
SelectSeamAllowanceAngle(PieceNodeAngle::ByLength);
|
||||||
if (curType != PieceNodeAngle::ByLength)
|
break;
|
||||||
{
|
case ContextMenuOption::ByPointsIntersection:
|
||||||
emit ToggleAngleType(m_id, PieceNodeAngle::ByLength);
|
SelectSeamAllowanceAngle(PieceNodeAngle::ByPointsIntersection);
|
||||||
}
|
break;
|
||||||
}
|
case ContextMenuOption::ByFirstEdgeSymmetry:
|
||||||
else if (selectedAction == actionByPointsIntersection)
|
SelectSeamAllowanceAngle(PieceNodeAngle::ByFirstEdgeSymmetry);
|
||||||
{
|
break;
|
||||||
if (curType != PieceNodeAngle::ByPointsIntersection)
|
case ContextMenuOption::BySecondEdgeSymmetry:
|
||||||
{
|
SelectSeamAllowanceAngle(PieceNodeAngle::BySecondEdgeSymmetry);
|
||||||
emit ToggleAngleType(m_id, PieceNodeAngle::ByPointsIntersection);
|
break;
|
||||||
}
|
case ContextMenuOption::ByFirstEdgeRightAngle:
|
||||||
}
|
SelectSeamAllowanceAngle(PieceNodeAngle::ByFirstEdgeRightAngle);
|
||||||
else if (selectedAction == actionByFirstEdgeSymmetry)
|
break;
|
||||||
{
|
case ContextMenuOption::BySecondEdgeRightAngle:
|
||||||
if (curType != PieceNodeAngle::ByFirstEdgeSymmetry)
|
SelectSeamAllowanceAngle(PieceNodeAngle::BySecondEdgeRightAngle);
|
||||||
{
|
break;
|
||||||
emit ToggleAngleType(m_id, PieceNodeAngle::ByFirstEdgeSymmetry);
|
case ContextMenuOption::Passmark:
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (selectedAction == actionBySecondEdgeSymmetry)
|
|
||||||
{
|
|
||||||
if (curType != PieceNodeAngle::BySecondEdgeSymmetry)
|
|
||||||
{
|
|
||||||
emit ToggleAngleType(m_id, PieceNodeAngle::BySecondEdgeSymmetry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (selectedAction == actionByFirstEdgeRightAngle)
|
|
||||||
{
|
|
||||||
if (curType != PieceNodeAngle::ByFirstEdgeRightAngle)
|
|
||||||
{
|
|
||||||
emit ToggleAngleType(m_id, PieceNodeAngle::ByFirstEdgeRightAngle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (selectedAction == actionBySecondEdgeRightAngle)
|
|
||||||
{
|
|
||||||
if (curType != PieceNodeAngle::BySecondEdgeRightAngle)
|
|
||||||
{
|
|
||||||
emit ToggleAngleType(m_id, PieceNodeAngle::BySecondEdgeRightAngle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (selectedAction == actionPassmark)
|
|
||||||
{
|
|
||||||
emit TogglePassmark(m_id, false);
|
emit TogglePassmark(m_id, false);
|
||||||
}
|
break;
|
||||||
|
case ContextMenuOption::Straightforward:
|
||||||
|
SelectPassmarkAngle(PassmarkAngleType::Straightforward);
|
||||||
|
break;
|
||||||
|
case ContextMenuOption::Bisector:
|
||||||
|
SelectPassmarkAngle(PassmarkAngleType::Bisector);
|
||||||
|
break;
|
||||||
|
case ContextMenuOption::Intersection:
|
||||||
|
SelectPassmarkAngle(PassmarkAngleType::Intersection);
|
||||||
|
break;
|
||||||
|
case ContextMenuOption::IntersectionOnlyLeft:
|
||||||
|
SelectPassmarkAngle(PassmarkAngleType::IntersectionOnlyLeft);
|
||||||
|
break;
|
||||||
|
case ContextMenuOption::IntersectionOnlyRight:
|
||||||
|
SelectPassmarkAngle(PassmarkAngleType::IntersectionOnlyRight);
|
||||||
|
break;
|
||||||
|
case ContextMenuOption::Intersection2:
|
||||||
|
SelectPassmarkAngle(PassmarkAngleType::Intersection2);
|
||||||
|
break;
|
||||||
|
case ContextMenuOption::Intersection2OnlyLeft:
|
||||||
|
SelectPassmarkAngle(PassmarkAngleType::Intersection2OnlyLeft);
|
||||||
|
break;
|
||||||
|
case ContextMenuOption::Intersection2OnlyRight:
|
||||||
|
SelectPassmarkAngle(PassmarkAngleType::Intersection2OnlyRight);
|
||||||
|
break;
|
||||||
|
case ContextMenuOption::OneLine:
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user