Block moving point label if tool is active.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-03-19 13:13:13 +02:00
parent c77b165cf0
commit f1b7726646
19 changed files with 45 additions and 10 deletions

View File

@ -328,6 +328,7 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolAlongLine::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolAlongLine::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);

View File

@ -209,6 +209,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolBisector::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolBisector::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);

View File

@ -136,6 +136,7 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCurveIntersectAxis::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCurveIntersectAxis::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCurveIntersectAxis::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
doc->IncrementReferens(curveId);

View File

@ -174,6 +174,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutArc::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutArc::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutArc::EnableToolMove);
doc->AddTool(id, point);
doc->AddTool(arc1id, point);
doc->AddTool(arc2id, point);

View File

@ -183,6 +183,7 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSpline::EnableToolMove);
doc->AddTool(id, point);
doc->AddTool(spl1id, point);
doc->AddTool(spl2id, point);

View File

@ -231,6 +231,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSplinePath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSplinePath::EnableToolMove);
doc->AddTool(id, point);
doc->AddTool(splPath1id, point);
doc->AddTool(splPath2id, point);

View File

@ -173,6 +173,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolEndLine::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolEndLine::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolEndLine::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
return point;

View File

@ -169,6 +169,7 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolHeight::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolHeight::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolHeight::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
doc->IncrementReferens(p1LineId);

View File

@ -176,6 +176,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersect::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersect::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(p1Line1Id);
doc->IncrementReferens(p2Line1Id);

View File

@ -148,6 +148,7 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersectAxis::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersectAxis::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersectAxis::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
doc->IncrementReferens(firstPointId);

View File

@ -169,6 +169,7 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolNormal::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolNormal::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);

View File

@ -193,6 +193,12 @@ void VToolPoint::DeleteFromLabel()
DeleteTool(); //Leave this method immediately after call!!!
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPoint::EnableToolMove(bool move)
{
namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.

View File

@ -59,6 +59,7 @@ public slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
void Disable(bool disable);
void DeleteFromLabel();
virtual void EnableToolMove(bool move);
protected:
/** @brief radius radius circle. */
qreal radius;

View File

@ -210,6 +210,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfContact::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfContact::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(center);
doc->IncrementReferens(firstPointId);

View File

@ -151,6 +151,7 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co
connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersection::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersection::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);

View File

@ -213,6 +213,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu
connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolShoulderPoint::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolShoulderPoint::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(p1Line);
doc->IncrementReferens(p2Line);

View File

@ -350,4 +350,5 @@ void VToolSinglePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
void VToolSinglePoint::EnableToolMove(bool move)
{
this->setFlag(QGraphicsItem::ItemIsMovable, move);
VToolPoint::EnableToolMove(move);
}

View File

@ -162,6 +162,7 @@ VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName
connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolTriangle::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolTriangle::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(axisP1Id);
doc->IncrementReferens(axisP2Id);

View File

@ -121,10 +121,13 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
* @param event hover enter event.
*/
void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
{
this->setBrush(Qt::green);
VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1);
}
QGraphicsSimpleTextItem::hoverEnterEvent(event);
}
@ -136,10 +139,13 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
if (flags() & QGraphicsItem::ItemIsMovable)
{
this->setBrush(Qt::black);
//Disable cursor-arrow-openhand
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
}
QGraphicsSimpleTextItem::hoverLeaveEvent(event);
}
@ -155,22 +161,28 @@ void VGraphicsSimpleTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
VApplication::setOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
QGraphicsSimpleTextItem::mousePressEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
//Disable cursor-arrow-closehand
VApplication::restoreOverrideCursor(cursorArrowCloseHand);
}
}
QGraphicsSimpleTextItem::mouseReleaseEvent(event);
}