Enable/Disable Passmark through Context Menu in detail mode.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2020-01-10 14:04:41 +02:00
parent 680e66c4cd
commit f13ec746a9

View File

@ -359,24 +359,18 @@ QHash<int, QAction *> VNodePoint::InitContextMenu(QMenu *menu, vidtype pieceId,
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VNodePoint::InitPassmarkMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu) void VNodePoint::InitPassmarkMenu(QMenu *menu, vidtype pieceId, QHash<int, QAction *> &contextMenu)
{ {
QAction *actionPassmark = menu->addAction(tr("Passmark")); SCASSERT(menu != nullptr)
actionPassmark->setCheckable(true);
const VPiece detail = VAbstractTool::data.GetPiece(pieceId); 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); QAction *actionPassmark = menu->addAction(tr("Passmark"));
actionPassmark->setCheckable(true);
actionPassmark->setChecked(node.IsPassmark()); actionPassmark->setChecked(detail.GetPath().at(nodeIndex).IsPassmark());
actionPassmark->setVisible(node.IsPassmark());
}
else
{
actionPassmark->setVisible(false);
}
contextMenu.insert(static_cast<int>(ContextMenuOption::Passmark), actionPassmark); contextMenu.insert(static_cast<int>(ContextMenuOption::Passmark), actionPassmark);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -537,6 +531,7 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
PieceNodeAngle angleCurType = PieceNodeAngle::ByLength; PieceNodeAngle angleCurType = PieceNodeAngle::ByLength;
PassmarkAngleType passmarkAngleCurType = PassmarkAngleType::Straightforward; PassmarkAngleType passmarkAngleCurType = PassmarkAngleType::Straightforward;
PassmarkLineType passmarkLineCurType = PassmarkLineType::OneLine; PassmarkLineType passmarkLineCurType = PassmarkLineType::OneLine;
bool isPassmark = false;
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);
@ -546,6 +541,7 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
angleCurType = node.GetAngleType(); angleCurType = node.GetAngleType();
passmarkAngleCurType = node.GetPassmarkAngleType(); passmarkAngleCurType = node.GetPassmarkAngleType();
passmarkLineCurType = node.GetPassmarkLineType(); passmarkLineCurType = node.GetPassmarkLineType();
isPassmark = node.IsPassmark();
} }
auto SelectSeamAllowanceAngle = [angleCurType, this](PieceNodeAngle type) auto SelectSeamAllowanceAngle = [angleCurType, this](PieceNodeAngle type)
@ -635,7 +631,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
SelectSeamAllowanceAngle(PieceNodeAngle::BySecondEdgeRightAngle); SelectSeamAllowanceAngle(PieceNodeAngle::BySecondEdgeRightAngle);
break; break;
case ContextMenuOption::Passmark: case ContextMenuOption::Passmark:
emit TogglePassmark(m_id, false); emit TogglePassmark(m_id, not isPassmark);
break; break;
case ContextMenuOption::Straightforward: case ContextMenuOption::Straightforward:
SelectPassmarkAngle(PassmarkAngleType::Straightforward); SelectPassmarkAngle(PassmarkAngleType::Straightforward);