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) 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); emit ChangedToolSelection(value.toBool(), m_id, m_id);
} }
@ -418,6 +418,19 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin
return spl; 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() void VAbstractSpline::InitDefShape()
{ {

View File

@ -103,6 +103,8 @@ signals:
* @param enable enable or diasable points. * @param enable enable or diasable points.
*/ */
void setEnabledPoint(bool enable); void setEnabledPoint(bool enable);
protected slots:
void CurveSelected(bool selected);
protected: protected:
/** /**
* @brief controlPoints list pointers of control points. * @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(this, &VToolSpline::setEnabledPoint, cPoint, &VControlPointSpline::setEnabledPoint);
connect(cPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSpline::contextMenuEvent); connect(cPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSpline::contextMenuEvent);
connect(cPoint, &VControlPointSpline::Released, this, &VToolSpline::CurveReleased); connect(cPoint, &VControlPointSpline::Released, this, &VToolSpline::CurveReleased);
connect(cPoint, &VControlPointSpline::Selected, this, &VToolSpline::CurveSelected);
controlPoints.append(cPoint); controlPoints.append(cPoint);
}; };

View File

@ -102,6 +102,7 @@ VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraph
connect(this, &VToolSplinePath::setEnabledPoint, cPoint, &VControlPointSpline::setEnabledPoint); connect(this, &VToolSplinePath::setEnabledPoint, cPoint, &VControlPointSpline::setEnabledPoint);
connect(cPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSplinePath::contextMenuEvent); connect(cPoint, &VControlPointSpline::ShowContextMenu, this, &VToolSplinePath::contextMenuEvent);
connect(cPoint, &VControlPointSpline::Released, this, &VToolSplinePath::CurveReleased); connect(cPoint, &VControlPointSpline::Released, this, &VToolSplinePath::CurveReleased);
connect(cPoint, &VControlPointSpline::Selected, this, &VToolSplinePath::CurveSelected);
controlPoints.append(cPoint); 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) QVariant VToolDoublePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if (change == QGraphicsItem::ItemSelectedChange) if (change == QGraphicsItem::ItemSelectedHasChanged)
{ {
if (value == true) if (value == true)
{ {

View File

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

View File

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

View File

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

View File

@ -192,11 +192,12 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
changeFinished = true; changeFinished = true;
} }
} }
if (change == QGraphicsItem::ItemSelectedChange) if (change == QGraphicsItem::ItemSelectedHasChanged)
{ {
setFlag(QGraphicsItem::ItemIsFocusable, value.toBool());
emit PointSelected(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_onlyPoint(false),
m_isHovered(false), m_isHovered(false),
m_showLabel(true), m_showLabel(true),
m_baseColor(Qt::black) m_baseColor(Qt::black),
m_selectedFromChild(false)
{ {
m_namePoint = new VGraphicsSimpleTextItem(this); m_namePoint = new VGraphicsSimpleTextItem(this);
m_lineName = new VScaledLine(this); m_lineName = new VScaledLine(this);

View File

@ -67,6 +67,8 @@ protected:
/** @brief m_baseColor base color of point. */ /** @brief m_baseColor base color of point. */
QColor m_baseColor; QColor m_baseColor;
bool m_selectedFromChild;
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE; virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent(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) QVariant VSimpleCurve::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if (change == QGraphicsItem::ItemSelectedChange) if (change == QGraphicsItem::ItemSelectedHasChanged)
{ {
emit Selected(value.toBool(), id); 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) QVariant VSimplePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if (change == QGraphicsItem::ItemSelectedChange) if (change == QGraphicsItem::ItemSelectedHasChanged)
{ {
m_namePoint->blockSignals(true); m_namePoint->blockSignals(true);
m_namePoint->setSelected(value.toBool()); m_namePoint->setSelected(value.toBool());