From 5fbdb4f7f006d11a8f0c0f40d980bb629efccd5d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 27 Feb 2017 22:06:48 +0200 Subject: [PATCH] Block actions with grainline depend on restrictions. --HG-- branch : feature --- src/libs/vtools/tools/vtoolseamallowance.cpp | 8 ++-- src/libs/vwidgets/vgrainlineitem.cpp | 45 +++++++++++++++----- src/libs/vwidgets/vpieceitem.cpp | 2 +- src/libs/vwidgets/vpieceitem.h | 2 +- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 681d9b28c..f7576d5ab 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1187,7 +1187,7 @@ VPieceItem::MoveType VToolSeamAllowance::FindLabelGeometry(const VPatternLabelDa labelWidth = labelData.GetLabelWidth(); labelHeight = labelData.GetLabelHeight(); pos = labelData.GetPos(); - return VTextGraphicsItem::Movable; + return VTextGraphicsItem::AllModifications; } //--------------------------------------------------------------------------------------------------------------------- @@ -1215,7 +1215,7 @@ VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineD pos = grainline.p1(); - return VPieceItem::OnlyRotatable; + return VPieceItem::NotMovable; } catch(const VExceptionBadId &) { @@ -1247,7 +1247,7 @@ VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineD if (isResizable && isRotatable) { - return VPieceItem::Movable; + return VPieceItem::AllModifications; } else { @@ -1261,7 +1261,7 @@ VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineD return VPieceItem::OnlyRotatable; } } - return VPieceItem::NotMovable; + return VPieceItem::OnlyMovable; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/vgrainlineitem.cpp b/src/libs/vwidgets/vgrainlineitem.cpp index c0cb1b87e..30e6f6acc 100644 --- a/src/libs/vwidgets/vgrainlineitem.cpp +++ b/src/libs/vwidgets/vgrainlineitem.cpp @@ -310,6 +310,12 @@ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME) { if (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick) { + if (m_moveType == NotMovable) + { + pME->ignore(); + return; + } + m_ptStartPos = pos(); m_ptStartMove = pME->scenePos(); m_dStartLength = m_dLength; @@ -317,25 +323,42 @@ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME) m_dAngle = GetAngle(mapToParent(pME->pos())); m_ptRotCenter = m_ptCenter; - if (m_eMode != mRotate) + if (m_moveType == OnlyRotatable) { - if (m_polyResize.containsPoint(pME->pos(), Qt::OddEvenFill) == true) - { - m_eMode = mResize; - SetOverrideCursor(Qt::SizeFDiagCursor); - } - else + if (m_eMode != mRotate) { m_eMode = mMove; SetOverrideCursor(cursorArrowCloseHand, 1, 1); } } - else + else if (m_moveType == OnlyMovable) { + m_eMode = mMove; SetOverrideCursor(cursorArrowCloseHand, 1, 1); } - setZValue(ACTIVE_Z); - Update(); + else + { + if (m_eMode != mRotate) + { + if (m_polyResize.containsPoint(pME->pos(), Qt::OddEvenFill) == true) + { + m_eMode = mResize; + SetOverrideCursor(Qt::SizeFDiagCursor); + } + else + { + m_eMode = mMove; + SetOverrideCursor(cursorArrowCloseHand, 1, 1); + } + } + else + { + SetOverrideCursor(cursorArrowCloseHand, 1, 1); + } + + setZValue(ACTIVE_Z); + Update(); + } } } @@ -431,7 +454,7 @@ void VGrainlineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) { if (bShort == true) { - if (m_bReleased == true) + if (m_bReleased == true && m_moveType != OnlyResizable && m_moveType != OnlyMovable) { m_eMode = mRotate; Update(); diff --git a/src/libs/vwidgets/vpieceitem.cpp b/src/libs/vwidgets/vpieceitem.cpp index f2f8e4c54..40ea08864 100644 --- a/src/libs/vwidgets/vpieceitem.cpp +++ b/src/libs/vwidgets/vpieceitem.cpp @@ -38,7 +38,7 @@ VPieceItem::VPieceItem(QGraphicsItem *pParent) m_eMode(VPieceItem::mNormal), m_bReleased(false), m_ptRotCenter(), - m_moveType(Movable), + m_moveType(AllModifications), m_inactiveZ(1) { m_rectBoundingBox.setTopLeft(QPointF(0, 0)); diff --git a/src/libs/vwidgets/vpieceitem.h b/src/libs/vwidgets/vpieceitem.h index 32509f5f6..a1cb1c4bc 100644 --- a/src/libs/vwidgets/vpieceitem.h +++ b/src/libs/vwidgets/vpieceitem.h @@ -36,7 +36,7 @@ class VPieceItem : public QGraphicsObject { Q_OBJECT public: - enum MoveType {Movable, OnlyResizable, OnlyRotatable, NotMovable, Error}; + enum MoveType {AllModifications, OnlyResizable, OnlyRotatable, OnlyMovable, NotMovable, Error}; explicit VPieceItem(QGraphicsItem* pParent = nullptr); virtual ~VPieceItem();