Fix bug with spline's control point.
Fix infinite redrawing. --HG-- branch : develop
This commit is contained in:
parent
d3cf15f5b8
commit
969dd163bf
|
@ -61,7 +61,8 @@ VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint3
|
||||||
controlPoints(),
|
controlPoints(),
|
||||||
sceneType(SceneObject::Unknown),
|
sceneType(SceneObject::Unknown),
|
||||||
m_isHovered(false),
|
m_isHovered(false),
|
||||||
detailsMode(false)
|
detailsMode(false),
|
||||||
|
m_parentRefresh(false)
|
||||||
{
|
{
|
||||||
InitDefShape();
|
InitDefShape();
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
|
@ -98,8 +99,8 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||||
setPen(QPen(CorrectColor(this, curve->GetColor()), width, LineStyleToPenStyle(curve->GetPenStyle()), Qt::RoundCap));
|
setPen(QPen(CorrectColor(this, curve->GetColor()), width, LineStyleToPenStyle(curve->GetPenStyle()), Qt::RoundCap));
|
||||||
|
|
||||||
RefreshCtrlPoints();
|
auto PaintSpline = [this, curve](QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
if (m_isHovered || detailsMode)
|
if (m_isHovered || detailsMode)
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
@ -118,6 +119,19 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsPathItem::paint(painter, option, widget);
|
QGraphicsPathItem::paint(painter, option, widget);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (not m_parentRefresh)
|
||||||
|
{
|
||||||
|
RefreshCtrlPoints();
|
||||||
|
m_parentRefresh = true;
|
||||||
|
PaintSpline(painter, option, widget);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_parentRefresh = false;
|
||||||
|
PaintSpline(painter, option, widget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -156,12 +170,22 @@ void VAbstractSpline::DetailsMode(bool mode)
|
||||||
void VAbstractSpline::AllowHover(bool enabled)
|
void VAbstractSpline::AllowHover(bool enabled)
|
||||||
{
|
{
|
||||||
setAcceptHoverEvents(enabled);
|
setAcceptHoverEvents(enabled);
|
||||||
|
|
||||||
|
foreach (auto *point, controlPoints)
|
||||||
|
{
|
||||||
|
point->setAcceptHoverEvents(enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractSpline::AllowSelecting(bool enabled)
|
void VAbstractSpline::AllowSelecting(bool enabled)
|
||||||
{
|
{
|
||||||
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||||
|
|
||||||
|
foreach (auto *point, controlPoints)
|
||||||
|
{
|
||||||
|
point->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -148,6 +148,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VAbstractSpline)
|
Q_DISABLE_COPY(VAbstractSpline)
|
||||||
|
|
||||||
|
bool m_parentRefresh;
|
||||||
|
|
||||||
void InitDefShape();
|
void InitDefShape();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,11 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
|
||||||
void VToolSpline::EnableToolMove(bool move)
|
void VToolSpline::EnableToolMove(bool move)
|
||||||
{
|
{
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, move);
|
this->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||||
|
|
||||||
|
foreach (auto *point, controlPoints)
|
||||||
|
{
|
||||||
|
point->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -292,6 +292,11 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons
|
||||||
void VToolSplinePath::EnableToolMove(bool move)
|
void VToolSplinePath::EnableToolMove(bool move)
|
||||||
{
|
{
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, move);
|
this->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||||
|
|
||||||
|
foreach (auto *point, controlPoints)
|
||||||
|
{
|
||||||
|
point->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user