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(); labelWidth = labelData.GetLabelWidth();
labelHeight = labelData.GetLabelHeight(); labelHeight = labelData.GetLabelHeight();
pos = labelData.GetPos(); pos = labelData.GetPos();
return VTextGraphicsItem::Movable; return VTextGraphicsItem::AllModifications;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1215,7 +1215,7 @@ VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineD
pos = grainline.p1(); pos = grainline.p1();
return VPieceItem::OnlyRotatable; return VPieceItem::NotMovable;
} }
catch(const VExceptionBadId &) catch(const VExceptionBadId &)
{ {
@ -1247,7 +1247,7 @@ VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineD
if (isResizable && isRotatable) if (isResizable && isRotatable)
{ {
return VPieceItem::Movable; return VPieceItem::AllModifications;
} }
else else
{ {
@ -1261,7 +1261,7 @@ VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineD
return VPieceItem::OnlyRotatable; 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 (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick)
{ {
if (m_moveType == NotMovable)
{
pME->ignore();
return;
}
m_ptStartPos = pos(); m_ptStartPos = pos();
m_ptStartMove = pME->scenePos(); m_ptStartMove = pME->scenePos();
m_dStartLength = m_dLength; m_dStartLength = m_dLength;
@ -317,25 +323,42 @@ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME)
m_dAngle = GetAngle(mapToParent(pME->pos())); m_dAngle = GetAngle(mapToParent(pME->pos()));
m_ptRotCenter = m_ptCenter; m_ptRotCenter = m_ptCenter;
if (m_eMode != mRotate) if (m_moveType == OnlyRotatable)
{ {
if (m_polyResize.containsPoint(pME->pos(), Qt::OddEvenFill) == true) if (m_eMode != mRotate)
{
m_eMode = mResize;
SetOverrideCursor(Qt::SizeFDiagCursor);
}
else
{ {
m_eMode = mMove; m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1); SetOverrideCursor(cursorArrowCloseHand, 1, 1);
} }
} }
else else if (m_moveType == OnlyMovable)
{ {
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1); SetOverrideCursor(cursorArrowCloseHand, 1, 1);
} }
setZValue(ACTIVE_Z); else
Update(); {
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 (bShort == true)
{ {
if (m_bReleased == true) if (m_bReleased == true && m_moveType != OnlyResizable && m_moveType != OnlyMovable)
{ {
m_eMode = mRotate; m_eMode = mRotate;
Update(); Update();

View File

@ -38,7 +38,7 @@ VPieceItem::VPieceItem(QGraphicsItem *pParent)
m_eMode(VPieceItem::mNormal), m_eMode(VPieceItem::mNormal),
m_bReleased(false), m_bReleased(false),
m_ptRotCenter(), m_ptRotCenter(),
m_moveType(Movable), m_moveType(AllModifications),
m_inactiveZ(1) m_inactiveZ(1)
{ {
m_rectBoundingBox.setTopLeft(QPointF(0, 0)); m_rectBoundingBox.setTopLeft(QPointF(0, 0));

View File

@ -36,7 +36,7 @@ class VPieceItem : public QGraphicsObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum MoveType {Movable, OnlyResizable, OnlyRotatable, NotMovable, Error}; enum MoveType {AllModifications, OnlyResizable, OnlyRotatable, OnlyMovable, NotMovable, Error};
explicit VPieceItem(QGraphicsItem* pParent = nullptr); explicit VPieceItem(QGraphicsItem* pParent = nullptr);
virtual ~VPieceItem(); virtual ~VPieceItem();