Resolved issue #969. Fix length to label after soom.
--HG-- branch : develop
This commit is contained in:
parent
41850e3b80
commit
218ef45d1e
|
@ -16,6 +16,7 @@
|
||||||
- [#965] Control passmark length with formula.
|
- [#965] Control passmark length with formula.
|
||||||
- New placelabel shape Circle.
|
- New placelabel shape Circle.
|
||||||
- Two new passmark types: U and Box.
|
- Two new passmark types: U and Box.
|
||||||
|
- [#969] Fix length to label after soom.
|
||||||
|
|
||||||
# Version 0.6.2 (unreleased)
|
# Version 0.6.2 (unreleased)
|
||||||
- [#903] Bug in tool Cut Spline path.
|
- [#903] Bug in tool Cut Spline path.
|
||||||
|
|
|
@ -341,9 +341,7 @@ void VToolSinglePoint::ChangeLabelPosition(quint32 id, const QPointF &pos)
|
||||||
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||||
point->setMx(pos.x());
|
point->setMx(pos.x());
|
||||||
point->setMy(pos.y());
|
point->setMy(pos.y());
|
||||||
m_namePoint->blockSignals(true);
|
m_namePoint->SetRealPos(pos);
|
||||||
m_namePoint->setPos(pos);
|
|
||||||
m_namePoint->blockSignals(false);
|
|
||||||
RefreshLine();
|
RefreshLine();
|
||||||
|
|
||||||
if (QGraphicsScene *sc = scene())
|
if (QGraphicsScene *sc = scene())
|
||||||
|
|
|
@ -143,9 +143,7 @@ void VNodePoint::ChangeLabelPosition(quint32 id, const QPointF &pos)
|
||||||
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||||
point->setMx(pos.x());
|
point->setMx(pos.x());
|
||||||
point->setMy(pos.y());
|
point->setMy(pos.y());
|
||||||
m_namePoint->blockSignals(true);
|
m_namePoint->SetRealPos(pos);
|
||||||
m_namePoint->setPos(pos);
|
|
||||||
m_namePoint->blockSignals(false);
|
|
||||||
RefreshLine();
|
RefreshLine();
|
||||||
if (QGraphicsScene *sc = scene())
|
if (QGraphicsScene *sc = scene())
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,17 +96,15 @@ void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic
|
||||||
const qreal scale = SceneScale(scene);
|
const qreal scale = SceneScale(scene);
|
||||||
if (scale > 1 && not VFuzzyComparePossibleNulls(m_oldScale, scale))
|
if (scale > 1 && not VFuzzyComparePossibleNulls(m_oldScale, scale))
|
||||||
{
|
{
|
||||||
const QRectF nameRec = boundingRect();
|
|
||||||
setTransformOriginPoint(nameRec.center());
|
|
||||||
setScale(1/scale);
|
setScale(1/scale);
|
||||||
|
CorrectLabelPosition();
|
||||||
UpdateLine();
|
UpdateLine();
|
||||||
m_oldScale = scale;
|
m_oldScale = scale;
|
||||||
}
|
}
|
||||||
else if (scale <= 1 && not VFuzzyComparePossibleNulls(m_oldScale, 1.0))
|
else if (scale <= 1 && not VFuzzyComparePossibleNulls(m_oldScale, 1.0))
|
||||||
{
|
{
|
||||||
const QRectF nameRec = boundingRect();
|
|
||||||
setTransformOriginPoint(nameRec.center());
|
|
||||||
setScale(1);
|
setScale(1);
|
||||||
|
CorrectLabelPosition();
|
||||||
UpdateLine();
|
UpdateLine();
|
||||||
m_oldScale = 1;
|
m_oldScale = 1;
|
||||||
}
|
}
|
||||||
|
@ -145,6 +143,34 @@ void VGraphicsSimpleTextItem::SetShowParentTooltip(bool show)
|
||||||
m_showParentTooltip = show;
|
m_showParentTooltip = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsSimpleTextItem::SetRealPos(QPointF pos)
|
||||||
|
{
|
||||||
|
m_realPos = pos;
|
||||||
|
|
||||||
|
CorrectLabelPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsSimpleTextItem::CorrectLabelPosition()
|
||||||
|
{
|
||||||
|
const qreal scale = SceneScale(scene());
|
||||||
|
QPointF newPos = m_realPos;
|
||||||
|
|
||||||
|
if (scale > 1)
|
||||||
|
{
|
||||||
|
QLineF line(QPointF(), m_realPos);
|
||||||
|
line.setLength(line.length() / scale);
|
||||||
|
newPos = line.p2();
|
||||||
|
}
|
||||||
|
|
||||||
|
blockSignals(true);
|
||||||
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||||
|
setPos(newPos);
|
||||||
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
|
blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief itemChange handle item change.
|
* @brief itemChange handle item change.
|
||||||
|
@ -162,8 +188,6 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
|
||||||
if (changeFinished)
|
if (changeFinished)
|
||||||
{
|
{
|
||||||
changeFinished = false;
|
changeFinished = false;
|
||||||
QPointF newPos = value.toPointF() + this->parentItem()->pos();
|
|
||||||
emit NameChangePosition(newPos);
|
|
||||||
if (scene())
|
if (scene())
|
||||||
{
|
{
|
||||||
const QList<QGraphicsView *> viewList = scene()->views();
|
const QList<QGraphicsView *> viewList = scene()->views();
|
||||||
|
@ -198,6 +222,17 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_realPos = value.toPointF();
|
||||||
|
const qreal scale = SceneScale(scene());
|
||||||
|
if (scale > 1)
|
||||||
|
{
|
||||||
|
QLineF line(QPointF(), m_realPos);
|
||||||
|
line.setLength(line.length() * scale);
|
||||||
|
m_realPos = line.p2();
|
||||||
|
}
|
||||||
|
emit NameChangePosition(m_realPos + this->parentItem()->pos());
|
||||||
|
|
||||||
changeFinished = true;
|
changeFinished = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vgraphicssimpletextitem.h
|
** @file vgraphicssimpletextitem.h
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
@ -63,6 +63,10 @@ public:
|
||||||
void LabelSelectionType(const SelectionType &type);
|
void LabelSelectionType(const SelectionType &type);
|
||||||
|
|
||||||
void SetShowParentTooltip(bool show);
|
void SetShowParentTooltip(bool show);
|
||||||
|
|
||||||
|
void SetRealPos(QPointF pos);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief NameChangePosition emit when label change position.
|
* @brief NameChangePosition emit when label change position.
|
||||||
|
@ -91,8 +95,11 @@ private:
|
||||||
SelectionType selectionType;
|
SelectionType selectionType;
|
||||||
qreal m_oldScale;
|
qreal m_oldScale;
|
||||||
bool m_showParentTooltip;
|
bool m_showParentTooltip;
|
||||||
|
QPointF m_realPos{};
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
void CorrectLabelPosition();
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -105,11 +105,14 @@ void VScenePoint::RefreshPointGeometry(const VPointF &point)
|
||||||
m_showLabel = point.IsShowLabel();
|
m_showLabel = point.IsShowLabel();
|
||||||
|
|
||||||
m_namePoint->blockSignals(true);
|
m_namePoint->blockSignals(true);
|
||||||
m_namePoint->setText(point.name());
|
m_namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||||
m_namePoint->setPos(QPointF(point.mx(), point.my()));
|
m_namePoint->SetRealPos(QPointF(point.mx(), point.my()));
|
||||||
m_namePoint->setVisible(m_showLabel);
|
m_namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
m_namePoint->blockSignals(false);
|
m_namePoint->blockSignals(false);
|
||||||
|
|
||||||
|
m_namePoint->setText(point.name());
|
||||||
|
m_namePoint->setVisible(m_showLabel);
|
||||||
|
|
||||||
RefreshLine();
|
RefreshLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user