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.
|
||||
- All intersections are now treaded as a loop.
|
||||
- [#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)
|
||||
- [#903] Bug in tool Cut Spline path.
|
||||
|
|
|
@ -126,7 +126,8 @@ enum class PassmarkAngleType : unsigned char
|
|||
IntersectionOnlyRight,
|
||||
Intersection2,
|
||||
Intersection2OnlyLeft,
|
||||
Intersection2OnlyRight
|
||||
Intersection2OnlyRight,
|
||||
LAST_ONE_DO_NOT_USE
|
||||
};
|
||||
|
||||
QString PassmarkAngleTypeToString(PassmarkAngleType type);
|
||||
|
|
|
@ -64,6 +64,45 @@
|
|||
|
||||
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.
|
||||
|
@ -266,6 +305,222 @@ void VNodePoint::HideNode()
|
|||
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)
|
||||
{
|
||||
|
@ -277,161 +532,161 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
if (VToolSeamAllowance *piece = qgraphicsitem_cast<VToolSeamAllowance *>(parentItem()))
|
||||
{
|
||||
QMenu menu;
|
||||
QAction *actionShowLabel = menu.addAction(tr("Show label"));
|
||||
actionShowLabel->setCheckable(true);
|
||||
actionShowLabel->setChecked(VAbstractTool::data.GeometricObject<VPointF>(m_id)->IsShowLabel());
|
||||
QHash<int, QAction *> contextMenu = InitContextMenu(&menu, piece->getId(), piece->referens());
|
||||
|
||||
QAction *actionPassmark = menu.addAction(tr("Passmark"));
|
||||
actionPassmark->setCheckable(true);
|
||||
|
||||
QAction *actionExclude = menu.addAction(tr("Exclude"));
|
||||
|
||||
QMenu *angleTypeMenu = menu.addMenu(tr("Angle"));
|
||||
PieceNodeAngle curType = PieceNodeAngle::ByLength;
|
||||
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);
|
||||
curType = node.GetAngleType();
|
||||
|
||||
actionPassmark->setChecked(node.IsPassmark());
|
||||
actionPassmark->setVisible(node.IsPassmark());
|
||||
|
||||
angleTypeMenu->setEnabled(detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn());
|
||||
}
|
||||
else
|
||||
{
|
||||
angleTypeMenu->setVisible(false);
|
||||
actionPassmark->setVisible(false);
|
||||
angleCurType = node.GetAngleType();
|
||||
passmarkAngleCurType = node.GetPassmarkAngleType();
|
||||
passmarkLineCurType = node.GetPassmarkLineType();
|
||||
}
|
||||
|
||||
auto InitAngleAction = [angleTypeMenu, curType](const QString &name, PieceNodeAngle checkType)
|
||||
auto SelectSeamAllowanceAngle = [angleCurType, this](PieceNodeAngle type)
|
||||
{
|
||||
QAction *action = angleTypeMenu->addAction(name);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(curType == checkType);
|
||||
return action;
|
||||
if (angleCurType != type)
|
||||
{
|
||||
emit ToggleSeamAllowanceAngleType(m_id, type);
|
||||
}
|
||||
};
|
||||
|
||||
QAction *actionByLength = InitAngleAction(tr("by length"), PieceNodeAngle::ByLength);
|
||||
QAction *actionByPointsIntersection = InitAngleAction(tr("by points intersetions"),
|
||||
PieceNodeAngle::ByPointsIntersection);
|
||||
QAction *actionByFirstEdgeSymmetry = InitAngleAction(tr("by first edge symmetry"),
|
||||
PieceNodeAngle::ByFirstEdgeSymmetry);
|
||||
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);
|
||||
auto SelectPassmarkAngle = [passmarkAngleCurType, this](PassmarkAngleType type)
|
||||
{
|
||||
if (passmarkAngleCurType != type)
|
||||
{
|
||||
emit TogglePassmarkAngleType(m_id, type);
|
||||
}
|
||||
};
|
||||
|
||||
QAction *separatorAct = new QAction(this);
|
||||
separatorAct->setSeparator(true);
|
||||
menu.addAction(separatorAct);
|
||||
|
||||
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
||||
|
||||
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);
|
||||
auto SelectPassmarkLine = [passmarkLineCurType, this](PassmarkLineType type)
|
||||
{
|
||||
if (passmarkLineCurType != type)
|
||||
{
|
||||
emit TogglePassmarkLineType(m_id, type);
|
||||
}
|
||||
};
|
||||
|
||||
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();
|
||||
}
|
||||
else if (selectedAction == inLayoutOption)
|
||||
{
|
||||
emit ToggleInLayout(selectedAction->isChecked());
|
||||
}
|
||||
else if (selectedAction == forbidFlippingOption)
|
||||
{
|
||||
emit ToggleForbidFlipping(selectedAction->isChecked());
|
||||
}
|
||||
else if (selectedAction == forceFlippingOption)
|
||||
{
|
||||
emit ToggleForceFlipping(selectedAction->isChecked());
|
||||
}
|
||||
else if (selectedAction == actionRemove)
|
||||
{
|
||||
try
|
||||
{
|
||||
emit Delete();
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
//Leave this method immediately after call!!!
|
||||
}
|
||||
else if (selectedAction == actionShowLabel)
|
||||
{
|
||||
qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked()));
|
||||
}
|
||||
else if (selectedAction == actionExclude)
|
||||
{
|
||||
emit ToggleExcludeState(m_id);
|
||||
}
|
||||
else if (selectedAction == actionByLength)
|
||||
{
|
||||
if (curType != PieceNodeAngle::ByLength)
|
||||
{
|
||||
emit ToggleAngleType(m_id, PieceNodeAngle::ByLength);
|
||||
}
|
||||
}
|
||||
else if (selectedAction == actionByPointsIntersection)
|
||||
{
|
||||
if (curType != PieceNodeAngle::ByPointsIntersection)
|
||||
{
|
||||
emit ToggleAngleType(m_id, PieceNodeAngle::ByPointsIntersection);
|
||||
}
|
||||
}
|
||||
else if (selectedAction == actionByFirstEdgeSymmetry)
|
||||
{
|
||||
if (curType != PieceNodeAngle::ByFirstEdgeSymmetry)
|
||||
{
|
||||
emit ToggleAngleType(m_id, PieceNodeAngle::ByFirstEdgeSymmetry);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
case ContextMenuOption::LAST_ONE_DO_NOT_USE:
|
||||
Q_UNREACHABLE();
|
||||
case ContextMenuOption::NoSelection:
|
||||
return;
|
||||
case ContextMenuOption::Option:
|
||||
emit ShowOptions();
|
||||
break;
|
||||
case ContextMenuOption::InLayout:
|
||||
emit ToggleInLayout(selectedAction->isChecked());
|
||||
break;
|
||||
case ContextMenuOption::ForbidFlipping:
|
||||
emit ToggleForbidFlipping(selectedAction->isChecked());
|
||||
break;
|
||||
case ContextMenuOption::ForceFlipping:
|
||||
emit ToggleForceFlipping(selectedAction->isChecked());
|
||||
break;
|
||||
case ContextMenuOption::Remove:
|
||||
try
|
||||
{
|
||||
emit Delete();
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
return;//Leave this method immediately after call!!!
|
||||
case ContextMenuOption::ShowLabel:
|
||||
qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked()));
|
||||
break;
|
||||
case ContextMenuOption::Exclude:
|
||||
emit ToggleExcludeState(m_id);
|
||||
break;
|
||||
case ContextMenuOption::ByLength:
|
||||
SelectSeamAllowanceAngle(PieceNodeAngle::ByLength);
|
||||
break;
|
||||
case ContextMenuOption::ByPointsIntersection:
|
||||
SelectSeamAllowanceAngle(PieceNodeAngle::ByPointsIntersection);
|
||||
break;
|
||||
case ContextMenuOption::ByFirstEdgeSymmetry:
|
||||
SelectSeamAllowanceAngle(PieceNodeAngle::ByFirstEdgeSymmetry);
|
||||
break;
|
||||
case ContextMenuOption::BySecondEdgeSymmetry:
|
||||
SelectSeamAllowanceAngle(PieceNodeAngle::BySecondEdgeSymmetry);
|
||||
break;
|
||||
case ContextMenuOption::ByFirstEdgeRightAngle:
|
||||
SelectSeamAllowanceAngle(PieceNodeAngle::ByFirstEdgeRightAngle);
|
||||
break;
|
||||
case ContextMenuOption::BySecondEdgeRightAngle:
|
||||
SelectSeamAllowanceAngle(PieceNodeAngle::BySecondEdgeRightAngle);
|
||||
break;
|
||||
case ContextMenuOption::Passmark:
|
||||
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 Delete();
|
||||
void ToggleExcludeState(quint32 id);
|
||||
void ToggleAngleType(quint32 id, PieceNodeAngle type);
|
||||
void ToggleSeamAllowanceAngleType(quint32 id, PieceNodeAngle type);
|
||||
void TogglePassmark(quint32 id, bool toggle);
|
||||
void TogglePassmarkAngleType(quint32 id, PassmarkAngleType type);
|
||||
void TogglePassmarkLineType(quint32 id, PassmarkLineType type);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile() override;
|
||||
void NameChangePosition(const QPointF &pos);
|
||||
|
@ -89,6 +91,12 @@ private:
|
|||
Q_DISABLE_COPY(VNodePoint)
|
||||
|
||||
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
|
||||
|
|
|
@ -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,
|
||||
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::ToggleExcludeState, parent, &VToolSeamAllowance::ToggleExcludeState,
|
||||
Qt::UniqueConnection);
|
||||
connect(tool, &VNodePoint::ToggleAngleType, parent, &VToolSeamAllowance::ToggleNodePointAngleType,
|
||||
Qt::UniqueConnection);
|
||||
connect(tool, &VNodePoint::ToggleSeamAllowanceAngleType, parent,
|
||||
&VToolSeamAllowance::ToggleNodePointAngleType, Qt::UniqueConnection);
|
||||
connect(tool, &VNodePoint::TogglePassmark, parent, &VToolSeamAllowance::ToggleNodePointPassmark,
|
||||
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->SetParentType(ParentType::Item);
|
||||
tool->SetExluded(node.IsExcluded());
|
||||
|
|
|
@ -169,6 +169,8 @@ private slots:
|
|||
void ToggleExcludeState(quint32 id);
|
||||
void ToggleNodePointAngleType(quint32 id, PieceNodeAngle type);
|
||||
void ToggleNodePointPassmark(quint32 id, bool toggle);
|
||||
void TogglePassmarkAngleType(quint32 id, PassmarkAngleType type);
|
||||
void TogglePassmarkLineType(quint32 id, PassmarkLineType type);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolSeamAllowance)
|
||||
|
|
Loading…
Reference in New Issue
Block a user