Block actions with grainline depend on restrictions.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-02-27 22:06:48 +02:00
parent 83b9e3e5ff
commit 5fbdb4f7f0
4 changed files with 40 additions and 17 deletions

View File

@ -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;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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();

View File

@ -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));

View File

@ -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();