When create group selecting a control point should also select a curve.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-10-30 08:34:18 +02:00
parent 55754d227b
commit cbf3e4d5df
15 changed files with 44 additions and 13 deletions

View File

@ -258,7 +258,7 @@ void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
*/
QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
if (change == QGraphicsItem::ItemSelectedHasChanged)
{
emit ChangedToolSelection(value.toBool(), m_id, m_id);
}
@ -418,6 +418,19 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin
return spl;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::CurveSelected(bool selected)
{
setSelected(selected);
foreach (auto *point, controlPoints)
{
point->blockSignals(true);
point->setSelected(selected);
point->blockSignals(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::InitDefShape()
{

View File

@ -103,6 +103,8 @@ signals:
* @param enable enable or diasable points.
*/
void setEnabledPoint(bool enable);
protected slots:
void CurveSelected(bool selected);
protected:
/**
* @brief controlPoints list pointers of control points.

View File

@ -97,6 +97,7 @@ VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
connect(this, &VToolSpline::setEnabledPoint, cPoint, &VControlPointSpline::setEnabledPoint);
connect(cPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSpline::contextMenuEvent);
connect(cPoint, &VControlPointSpline::Released, this, &VToolSpline::CurveReleased);
connect(cPoint, &VControlPointSpline::Selected, this, &VToolSpline::CurveSelected);
controlPoints.append(cPoint);
};

View File

@ -102,6 +102,7 @@ VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraph
connect(this, &VToolSplinePath::setEnabledPoint, cPoint, &VControlPointSpline::setEnabledPoint);
connect(cPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSplinePath::contextMenuEvent);
connect(cPoint, &VControlPointSpline::Released, this, &VToolSplinePath::CurveReleased);
connect(cPoint, &VControlPointSpline::Selected, this, &VToolSplinePath::CurveSelected);
controlPoints.append(cPoint);
};

View File

@ -314,7 +314,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id, const QPointF &pos)
*/
QVariant VToolDoublePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
if (change == QGraphicsItem::ItemSelectedHasChanged)
{
if (value == true)
{

View File

@ -214,7 +214,9 @@ void VToolSinglePoint::PointChoosed()
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::PointSelected(bool selected)
{
m_selectedFromChild = true;
setSelected(selected);
m_selectedFromChild = false;
}
//---------------------------------------------------------------------------------------------------------------------
@ -261,11 +263,15 @@ void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
*/
QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
if (change == QGraphicsItem::ItemSelectedHasChanged)
{
m_namePoint->blockSignals(true);
m_namePoint->setSelected(value.toBool());
m_namePoint->blockSignals(false);
if (not m_selectedFromChild)
{
m_namePoint->blockSignals(true);
m_namePoint->setSelected(value.toBool());
m_namePoint->blockSignals(false);
}
emit ChangedToolSelection(value.toBool(), m_id, m_id);
}

View File

@ -326,7 +326,7 @@ void VToolLine::RemoveReferens()
*/
QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
if (change == QGraphicsItem::ItemSelectedHasChanged)
{
emit ChangedToolSelection(value.toBool(), m_id, m_id);
}

View File

@ -1060,7 +1060,7 @@ QVariant VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change
}
}
if (change == QGraphicsItem::ItemSelectedChange)
if (change == QGraphicsItem::ItemSelectedHasChanged)
{
if (value == true)
{

View File

@ -210,6 +210,9 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang
}
break;
}
case QGraphicsItem::ItemSelectedHasChanged:
emit Selected(value.toBool());
break;
default:
break;
}

View File

@ -75,6 +75,7 @@ signals:
*/
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
void Released();
void Selected(bool selected);
public slots:
void RefreshCtrlPoint(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint,
const QPointF &splinePoint, bool freeAngle = true, bool freeLength = true);

View File

@ -192,11 +192,12 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
changeFinished = true;
}
}
if (change == QGraphicsItem::ItemSelectedChange)
if (change == QGraphicsItem::ItemSelectedHasChanged)
{
setFlag(QGraphicsItem::ItemIsFocusable, value.toBool());
emit PointSelected(value.toBool());
}
return QGraphicsItem::itemChange(change, value);
return QGraphicsSimpleTextItem::itemChange(change, value);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -48,7 +48,8 @@ VScenePoint::VScenePoint(QGraphicsItem *parent)
m_onlyPoint(false),
m_isHovered(false),
m_showLabel(true),
m_baseColor(Qt::black)
m_baseColor(Qt::black),
m_selectedFromChild(false)
{
m_namePoint = new VGraphicsSimpleTextItem(this);
m_lineName = new VScaledLine(this);

View File

@ -67,6 +67,8 @@ protected:
/** @brief m_baseColor base color of point. */
QColor m_baseColor;
bool m_selectedFromChild;
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;

View File

@ -146,7 +146,7 @@ void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
//---------------------------------------------------------------------------------------------------------------------
QVariant VSimpleCurve::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
if (change == QGraphicsItem::ItemSelectedHasChanged)
{
emit Selected(value.toBool(), id);
}

View File

@ -220,7 +220,7 @@ void VSimplePoint::keyReleaseEvent(QKeyEvent *event)
//---------------------------------------------------------------------------------------------------------------------
QVariant VSimplePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
if (change == QGraphicsItem::ItemSelectedHasChanged)
{
m_namePoint->blockSignals(true);
m_namePoint->setSelected(value.toBool());