Fixed bug. After full parse undocommand Move labe losts connection to tool.
--HG-- branch : develop
This commit is contained in:
parent
f2b07a482c
commit
40662bb948
|
@ -18,6 +18,7 @@
|
||||||
- Removed crash sending system for Windows.
|
- Removed crash sending system for Windows.
|
||||||
- Added new language Polish (Poland).
|
- Added new language Polish (Poland).
|
||||||
- [#755] New feature. Toggle point label.
|
- [#755] New feature. Toggle point label.
|
||||||
|
- Fixed bug. After full parse undocommand Move labe losts connection to tool.
|
||||||
|
|
||||||
# Version 0.5.1
|
# Version 0.5.1
|
||||||
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
||||||
|
|
|
@ -85,6 +85,25 @@ void VAbstractOperation::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractOperation::DoChangePosition(quint32 id, const QPointF &pos)
|
||||||
|
{
|
||||||
|
if (operatedObjects.contains(id))
|
||||||
|
{
|
||||||
|
VAbstractSimple *obj = operatedObjects.value(id);
|
||||||
|
if (obj && obj->GetType() == GOType::Point)
|
||||||
|
{
|
||||||
|
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
|
||||||
|
SCASSERT(item != nullptr)
|
||||||
|
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||||
|
point->setMx(pos.x());
|
||||||
|
point->setMy(pos.y());
|
||||||
|
VAbstractTool::data.UpdateGObject(id, point);
|
||||||
|
item->RefreshPointGeometry(*(point.data()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VAbstractOperation::IsLabelVisible(quint32 id) const
|
bool VAbstractOperation::IsLabelVisible(quint32 id) const
|
||||||
{
|
{
|
||||||
|
@ -433,7 +452,7 @@ void VAbstractOperation::LabelChangePosition(const QPointF &pos, quint32 labelId
|
||||||
{
|
{
|
||||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
|
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
|
||||||
SCASSERT(item != nullptr)
|
SCASSERT(item != nullptr)
|
||||||
ChangePosition(item, labelId, pos);
|
UpdateNamePosition(labelId, pos - item->pos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,12 +493,16 @@ void VAbstractOperation::ChangeLabelVisibility(quint32 id, bool visible)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractOperation::UpdateNamePosition(quint32 id)
|
void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
if (operatedObjects.contains(id))
|
||||||
auto moveLabel = new OperationMoveLabel(m_id, doc, point->mx(), point->my(), id);
|
{
|
||||||
connect(moveLabel, &OperationMoveLabel::ChangePosition, this, &VAbstractOperation::DoChangePosition);
|
VAbstractSimple *obj = operatedObjects.value(id);
|
||||||
qApp->getUndoStack()->push(moveLabel);
|
if (obj && obj->GetType() == GOType::Point)
|
||||||
|
{
|
||||||
|
qApp->getUndoStack()->push(new OperationMoveLabel(m_id, doc, pos, id));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -537,23 +560,6 @@ void VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType curveTyp
|
||||||
operatedObjects.insert(id, curve);
|
operatedObjects.insert(id, curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VAbstractOperation::DoChangePosition(quint32 id, qreal mx, qreal my)
|
|
||||||
{
|
|
||||||
if (operatedObjects.contains(id))
|
|
||||||
{
|
|
||||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
|
||||||
point->setMx(mx);
|
|
||||||
point->setMy(my);
|
|
||||||
VAbstractTool::data.UpdateGObject(id, point);
|
|
||||||
|
|
||||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(operatedObjects.value(id));
|
|
||||||
SCASSERT(item != nullptr)
|
|
||||||
|
|
||||||
item->RefreshPointGeometry(*point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractOperation::AllowCurveHover(bool enabled, GOType type)
|
void VAbstractOperation::AllowCurveHover(bool enabled, GOType type)
|
||||||
{
|
{
|
||||||
|
@ -592,14 +598,6 @@ void VAbstractOperation::AllowCurveSelecting(bool enabled, GOType type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VAbstractOperation::ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos)
|
|
||||||
{
|
|
||||||
const QPointF p = pos - item->pos();
|
|
||||||
DoChangePosition(id, p.x(), p.y());
|
|
||||||
UpdateNamePosition(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractOperation::InitOperatedObjects()
|
void VAbstractOperation::InitOperatedObjects()
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,6 +87,7 @@ public:
|
||||||
|
|
||||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
|
||||||
|
virtual void DoChangePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
||||||
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
@ -137,7 +138,7 @@ protected:
|
||||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||||
virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void UpdateNamePosition(quint32 id);
|
void UpdateNamePosition(quint32 id, const QPointF &pos);
|
||||||
void SaveSourceDestination(QDomElement &tag);
|
void SaveSourceDestination(QDomElement &tag);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -152,15 +153,11 @@ protected:
|
||||||
|
|
||||||
QString ComplexPointToolTip(quint32 itemId) const;
|
QString ComplexPointToolTip(quint32 itemId) const;
|
||||||
QString ComplexCurveToolTip(quint32 itemId) const;
|
QString ComplexCurveToolTip(quint32 itemId) const;
|
||||||
protected slots:
|
|
||||||
void DoChangePosition(quint32 id, qreal mx, qreal my);
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VAbstractOperation)
|
Q_DISABLE_COPY(VAbstractOperation)
|
||||||
|
|
||||||
void AllowCurveHover(bool enabled, GOType type);
|
void AllowCurveHover(bool enabled, GOType type);
|
||||||
void AllowCurveSelecting(bool enabled, GOType type);
|
void AllowCurveSelecting(bool enabled, GOType type);
|
||||||
|
|
||||||
void ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -159,13 +159,13 @@ void VToolDoublePoint::SetLabelVisible(quint32 id, bool visible)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
|
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
|
||||||
{
|
{
|
||||||
ChangePosition(firstPoint, p1id, pos);
|
UpdateNamePosition(p1id, pos - firstPoint->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolDoublePoint::Label2ChangePosition(const QPointF &pos)
|
void VToolDoublePoint::Label2ChangePosition(const QPointF &pos)
|
||||||
{
|
{
|
||||||
ChangePosition(secondPoint, p2id, pos);
|
UpdateNamePosition(p2id, pos - secondPoint->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -220,23 +220,23 @@ void VToolDoublePoint::FullUpdateFromFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolDoublePoint::DoChangePosition(quint32 id, qreal mx, qreal my)
|
void VToolDoublePoint::DoChangePosition(quint32 id, const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (id == p1id)
|
if (id == p1id)
|
||||||
{
|
{
|
||||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
|
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(p1id);
|
||||||
point->setMx(mx);
|
point->setMx(pos.x());
|
||||||
point->setMy(my);
|
point->setMy(pos.y());
|
||||||
VAbstractTool::data.UpdateGObject(p1id, point);
|
VAbstractTool::data.UpdateGObject(p1id, point);
|
||||||
firstPoint->RefreshPointGeometry(*point);
|
firstPoint->RefreshPointGeometry(*(point.data()));
|
||||||
}
|
}
|
||||||
else if (id == p2id)
|
else if (id == p2id)
|
||||||
{
|
{
|
||||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
|
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(p2id);
|
||||||
point->setMx(mx);
|
point->setMx(pos.x());
|
||||||
point->setMy(my);
|
point->setMy(pos.y());
|
||||||
VAbstractTool::data.UpdateGObject(p2id, point);
|
VAbstractTool::data.UpdateGObject(p2id, point);
|
||||||
secondPoint->RefreshPointGeometry(*point);
|
secondPoint->RefreshPointGeometry(*(point.data()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,23 +277,15 @@ void VToolDoublePoint::ToolSelectionType(const SelectionType &type)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolDoublePoint::UpdateNamePosition(quint32 id)
|
void VToolDoublePoint::UpdateNamePosition(quint32 id, const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (id == p1id)
|
if (id == p1id)
|
||||||
{
|
{
|
||||||
const VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
|
qApp->getUndoStack()->push(new MoveDoubleLabel(doc, pos, MoveDoublePoint::FirstPoint, m_id, p1id));
|
||||||
|
|
||||||
auto moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), MoveDoublePoint::FirstPoint, m_id, p1id);
|
|
||||||
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
|
|
||||||
qApp->getUndoStack()->push(moveLabel);
|
|
||||||
}
|
}
|
||||||
else if (id == p2id)
|
else if (id == p2id)
|
||||||
{
|
{
|
||||||
const VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
|
qApp->getUndoStack()->push(new MoveDoubleLabel(doc, pos, MoveDoublePoint::SecondPoint, m_id, p2id));
|
||||||
|
|
||||||
auto moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), MoveDoublePoint::SecondPoint, m_id, p2id);
|
|
||||||
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
|
|
||||||
qApp->getUndoStack()->push(moveLabel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
void setNameP2(const QString &name);
|
void setNameP2(const QString &name);
|
||||||
|
|
||||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
virtual void DoChangePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
||||||
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
@ -76,7 +77,6 @@ public slots:
|
||||||
void Point1Selected(bool selected);
|
void Point1Selected(bool selected);
|
||||||
void Point2Selected(bool selected);
|
void Point2Selected(bool selected);
|
||||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||||
virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE;
|
|
||||||
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
||||||
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
||||||
void AllowLabelHover(bool enabled);
|
void AllowLabelHover(bool enabled);
|
||||||
|
@ -90,7 +90,7 @@ protected:
|
||||||
quint32 p1id;
|
quint32 p1id;
|
||||||
quint32 p2id;
|
quint32 p2id;
|
||||||
|
|
||||||
virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE;
|
virtual void UpdateNamePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE;
|
||||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
||||||
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
|
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -147,19 +147,19 @@ void VToolSinglePoint::SetLabelVisible(quint32 id, bool visible)
|
||||||
*/
|
*/
|
||||||
void VToolSinglePoint::NameChangePosition(const QPointF &pos)
|
void VToolSinglePoint::NameChangePosition(const QPointF &pos)
|
||||||
{
|
{
|
||||||
ChangePosition(this, m_id, pos);
|
UpdateNamePosition(m_id, pos - this->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief UpdateNamePosition save new position label to the pattern file.
|
* @brief UpdateNamePosition save new position label to the pattern file.
|
||||||
*/
|
*/
|
||||||
void VToolSinglePoint::UpdateNamePosition(quint32 id)
|
void VToolSinglePoint::UpdateNamePosition(quint32 id, const QPointF &pos)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
if (id == m_id)
|
||||||
auto moveLabel = new MoveLabel(doc, point->mx(), point->my(), id);
|
{
|
||||||
connect(moveLabel, &MoveLabel::ChangePosition, this, &VToolSinglePoint::DoChangePosition);
|
qApp->getUndoStack()->push(new MoveLabel(doc, pos, id));
|
||||||
qApp->getUndoStack()->push(moveLabel);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -324,17 +324,20 @@ void VToolSinglePoint::ChangeLabelVisibility(quint32 id, bool visible)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSinglePoint::DoChangePosition(quint32 id, qreal mx, qreal my)
|
void VToolSinglePoint::DoChangePosition(quint32 id, const QPointF &pos)
|
||||||
{
|
{
|
||||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
if (id == m_id)
|
||||||
point->setMx(mx);
|
{
|
||||||
point->setMy(my);
|
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||||
|
point->setMx(pos.x());
|
||||||
|
point->setMy(pos.y());
|
||||||
VAbstractTool::data.UpdateGObject(id, point);
|
VAbstractTool::data.UpdateGObject(id, point);
|
||||||
m_namePoint->blockSignals(true);
|
m_namePoint->blockSignals(true);
|
||||||
m_namePoint->setPos(QPointF(mx, my));
|
m_namePoint->setPos(pos);
|
||||||
m_namePoint->blockSignals(false);
|
m_namePoint->blockSignals(false);
|
||||||
RefreshLine();
|
RefreshLine();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSinglePoint::AllowHover(bool enabled)
|
void VToolSinglePoint::AllowHover(bool enabled)
|
||||||
|
|
|
@ -79,6 +79,7 @@ public:
|
||||||
void SetEnabled(bool enabled);
|
void SetEnabled(bool enabled);
|
||||||
|
|
||||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
virtual void DoChangePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
||||||
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
@ -89,14 +90,13 @@ public slots:
|
||||||
void PointChoosed();
|
void PointChoosed();
|
||||||
void PointSelected(bool selected);
|
void PointSelected(bool selected);
|
||||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||||
virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE;
|
|
||||||
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
||||||
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
||||||
void AllowLabelHover(bool enabled);
|
void AllowLabelHover(bool enabled);
|
||||||
void AllowLabelSelecting(bool enabled);
|
void AllowLabelSelecting(bool enabled);
|
||||||
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE;
|
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE;
|
||||||
protected:
|
protected:
|
||||||
virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE;
|
virtual void UpdateNamePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE;
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
|
||||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -64,16 +64,11 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;
|
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;
|
||||||
void DeleteFromLabel();
|
void DeleteFromLabel();
|
||||||
virtual void DoChangePosition(quint32 id, qreal mx, qreal my) =0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetPointName(quint32 id, const QString &name);
|
void SetPointName(quint32 id, const QString &name);
|
||||||
|
|
||||||
template <typename T>
|
virtual void UpdateNamePosition(quint32 id, const QPointF &pos)=0;
|
||||||
void ChangePosition(T *item, quint32 id, const QPointF &pos);
|
|
||||||
|
|
||||||
|
|
||||||
virtual void UpdateNamePosition(quint32 id)=0;
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void InitToolConnections(VMainGraphicsScene *scene, T *tool);
|
static void InitToolConnections(VMainGraphicsScene *scene, T *tool);
|
||||||
|
@ -107,15 +102,6 @@ void VAbstractPoint::ShowToolVisualization(bool show)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
template <typename T>
|
|
||||||
void VAbstractPoint::ChangePosition(T *item, quint32 id, const QPointF &pos)
|
|
||||||
{
|
|
||||||
const QPointF p = pos - item->pos();
|
|
||||||
DoChangePosition(id, p.x(), p.y());
|
|
||||||
UpdateNamePosition(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void VAbstractPoint::InitToolConnections(VMainGraphicsScene *scene, T *tool)
|
void VAbstractPoint::InitToolConnections(VMainGraphicsScene *scene, T *tool)
|
||||||
|
|
|
@ -257,3 +257,10 @@ void VDrawTool::SetLabelVisible(quint32 id, bool visible)
|
||||||
Q_UNUSED(id)
|
Q_UNUSED(id)
|
||||||
Q_UNUSED(visible)
|
Q_UNUSED(visible)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDrawTool::DoChangePosition(quint32 id, const QPointF &pos)
|
||||||
|
{
|
||||||
|
Q_UNUSED(id)
|
||||||
|
Q_UNUSED(pos)
|
||||||
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
|
|
||||||
virtual bool IsLabelVisible(quint32 id) const;
|
virtual bool IsLabelVisible(quint32 id) const;
|
||||||
virtual void SetLabelVisible(quint32 id, bool visible);
|
virtual void SetLabelVisible(quint32 id, bool visible);
|
||||||
|
virtual void DoChangePosition(quint32 id, const QPointF &pos);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ChangedToolSelection(bool selected, quint32 object, quint32 tool);
|
void ChangedToolSelection(bool selected, quint32 object, quint32 tool);
|
||||||
|
|
|
@ -36,26 +36,15 @@
|
||||||
#include "../vundocommand.h"
|
#include "../vundocommand.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MoveAbstractLabel::MoveAbstractLabel(VAbstractPattern *doc, quint32 pointId, double x, double y,
|
MoveAbstractLabel::MoveAbstractLabel(VAbstractPattern *doc, quint32 pointId, const QPointF &pos, QUndoCommand *parent)
|
||||||
QUndoCommand *parent)
|
|
||||||
: VUndoCommand(QDomElement(), doc, parent),
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
m_oldMx(0.0),
|
m_oldPos(),
|
||||||
m_oldMy(0.0),
|
m_newPos(pos)
|
||||||
m_newMx(x),
|
|
||||||
m_newMy(y),
|
|
||||||
m_isRedo(false),
|
|
||||||
m_scene(qApp->getCurrentScene())
|
|
||||||
{
|
{
|
||||||
nodeId = pointId;
|
nodeId = pointId;
|
||||||
qCDebug(vUndo, "Point id %u", nodeId);
|
qCDebug(vUndo, "Point id %u", nodeId);
|
||||||
|
|
||||||
qCDebug(vUndo, "Label new Mx %f", m_newMx);
|
qCDebug(vUndo, "Label new position (%f;%f)", m_newPos.x(), m_newPos.y());
|
||||||
qCDebug(vUndo, "Label new My %f", m_newMy);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
MoveAbstractLabel::~MoveAbstractLabel()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -63,10 +52,7 @@ void MoveAbstractLabel::undo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Undo.");
|
qCDebug(vUndo, "Undo.");
|
||||||
|
|
||||||
Do(m_oldMx, m_oldMy);
|
Do(m_oldPos);
|
||||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
|
||||||
m_isRedo = true;
|
|
||||||
emit ChangePosition(nodeId, m_oldMx, m_oldMy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -74,10 +60,5 @@ void MoveAbstractLabel::redo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Redo.");
|
qCDebug(vUndo, "Redo.");
|
||||||
|
|
||||||
Do(m_newMx, m_newMy);
|
Do(m_newPos);
|
||||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
|
||||||
if (m_isRedo)
|
|
||||||
{
|
|
||||||
emit ChangePosition(nodeId, m_newMx, m_newMy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,30 +41,20 @@ class QGraphicsScene;
|
||||||
|
|
||||||
class MoveAbstractLabel : public VUndoCommand
|
class MoveAbstractLabel : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
MoveAbstractLabel(VAbstractPattern *doc, quint32 pointId, double x, double y, QUndoCommand *parent = nullptr);
|
MoveAbstractLabel(VAbstractPattern *doc, quint32 pointId, const QPointF &pos, QUndoCommand *parent = nullptr);
|
||||||
virtual ~MoveAbstractLabel();
|
virtual ~MoveAbstractLabel()=default;
|
||||||
|
|
||||||
virtual void undo() Q_DECL_OVERRIDE;
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
virtual void redo() Q_DECL_OVERRIDE;
|
virtual void redo() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
quint32 GetPointId() const;
|
quint32 GetPointId() const;
|
||||||
double GetNewMx() const;
|
QPointF GetNewPos() const;
|
||||||
double GetNewMy() const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void ChangePosition(quint32 id, qreal mx, qreal my);
|
|
||||||
protected:
|
protected:
|
||||||
double m_oldMx;
|
QPointF m_oldPos;
|
||||||
double m_oldMy;
|
QPointF m_newPos;
|
||||||
double m_newMx;
|
|
||||||
double m_newMy;
|
|
||||||
bool m_isRedo;
|
|
||||||
//Need for resizing scene rect
|
|
||||||
QGraphicsScene *m_scene;
|
|
||||||
|
|
||||||
virtual void Do(double mx, double my)=0;
|
virtual void Do(const QPointF &pos)=0;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MoveAbstractLabel)
|
Q_DISABLE_COPY(MoveAbstractLabel)
|
||||||
};
|
};
|
||||||
|
@ -76,15 +66,9 @@ inline quint32 MoveAbstractLabel::GetPointId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline double MoveAbstractLabel::GetNewMx() const
|
inline QPointF MoveAbstractLabel::GetNewPos() const
|
||||||
{
|
{
|
||||||
return m_newMx;
|
return m_newPos;
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline double MoveAbstractLabel::GetNewMy() const
|
|
||||||
{
|
|
||||||
return m_newMy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MOVEABSTRACTLABEL_H
|
#endif // MOVEABSTRACTLABEL_H
|
||||||
|
|
|
@ -37,13 +37,15 @@
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vundocommand.h"
|
#include "../vundocommand.h"
|
||||||
#include "moveabstractlabel.h"
|
#include "moveabstractlabel.h"
|
||||||
|
#include "../vtools/tools/drawTools/vdrawtool.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, MoveDoublePoint type,
|
MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const QPointF &pos, MoveDoublePoint type,
|
||||||
quint32 toolId, quint32 pointId, QUndoCommand *parent)
|
quint32 toolId, quint32 pointId, QUndoCommand *parent)
|
||||||
: MoveAbstractLabel(doc, pointId, x, y, parent),
|
: MoveAbstractLabel(doc, pointId, pos, parent),
|
||||||
m_type(type),
|
m_type(type),
|
||||||
m_idTool(toolId)
|
m_idTool(toolId),
|
||||||
|
m_scene(qApp->getCurrentScene())
|
||||||
{
|
{
|
||||||
if (type == MoveDoublePoint::FirstPoint)
|
if (type == MoveDoublePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
|
@ -59,19 +61,19 @@ MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const d
|
||||||
{
|
{
|
||||||
if (type == MoveDoublePoint::FirstPoint)
|
if (type == MoveDoublePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx1, "0.0"));
|
m_oldPos.rx() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx1, "0.0"));
|
||||||
m_oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy1, "0.0"));
|
m_oldPos.ry() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy1, "0.0"));
|
||||||
|
|
||||||
qCDebug(vUndo, "Label old Mx1 %f", m_oldMx);
|
qCDebug(vUndo, "Label old Mx1 %f", m_oldPos.x());
|
||||||
qCDebug(vUndo, "Label old My1 %f", m_oldMy);
|
qCDebug(vUndo, "Label old My1 %f", m_oldPos.y());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx2, "0.0"));
|
m_oldPos.rx() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx2, "0.0"));
|
||||||
m_oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy2, "0.0"));
|
m_oldPos.ry() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy2, "0.0"));
|
||||||
|
|
||||||
qCDebug(vUndo, "Label old Mx2 %f", m_oldMx);
|
qCDebug(vUndo, "Label old Mx2 %f", m_oldPos.x());
|
||||||
qCDebug(vUndo, "Label old My2 %f", m_oldMy);
|
qCDebug(vUndo, "Label old My2 %f", m_oldPos.y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -80,10 +82,6 @@ MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
MoveDoubleLabel::~MoveDoubleLabel()
|
|
||||||
{}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool MoveDoubleLabel::mergeWith(const QUndoCommand *command)
|
bool MoveDoubleLabel::mergeWith(const QUndoCommand *command)
|
||||||
{
|
{
|
||||||
|
@ -97,18 +95,17 @@ bool MoveDoubleLabel::mergeWith(const QUndoCommand *command)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_newMx = moveCommand->GetNewMx();
|
m_newPos = moveCommand->GetNewPos();
|
||||||
m_newMy = moveCommand->GetNewMy();
|
|
||||||
|
|
||||||
if (m_type == MoveDoublePoint::FirstPoint)
|
if (m_type == MoveDoublePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Label new Mx1 %f", m_newMx);
|
qCDebug(vUndo, "Label new Mx1 %f", m_newPos.x());
|
||||||
qCDebug(vUndo, "Label new My1 %f", m_newMy);
|
qCDebug(vUndo, "Label new My1 %f", m_newPos.y());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Label new Mx2 %f", m_newMx);
|
qCDebug(vUndo, "Label new Mx2 %f", m_newPos.x());
|
||||||
qCDebug(vUndo, "Label new My2 %f", m_newMy);
|
qCDebug(vUndo, "Label new My2 %f", m_newPos.y());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -120,17 +117,17 @@ int MoveDoubleLabel::id() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveDoubleLabel::Do(double mx, double my)
|
void MoveDoubleLabel::Do(const QPointF &pos)
|
||||||
{
|
{
|
||||||
if (m_type == MoveDoublePoint::FirstPoint)
|
if (m_type == MoveDoublePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "New mx1 %f", mx);
|
qCDebug(vUndo, "New mx1 %f", pos.x());
|
||||||
qCDebug(vUndo, "New my1 %f", my);
|
qCDebug(vUndo, "New my1 %f", pos.y());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "New mx2 %f", mx);
|
qCDebug(vUndo, "New mx2 %f", pos.x());
|
||||||
qCDebug(vUndo, "New my2 %f", my);
|
qCDebug(vUndo, "New my2 %f", pos.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
|
QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
|
||||||
|
@ -138,14 +135,20 @@ void MoveDoubleLabel::Do(double mx, double my)
|
||||||
{
|
{
|
||||||
if (m_type == MoveDoublePoint::FirstPoint)
|
if (m_type == MoveDoublePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrMx1, QString().setNum(qApp->fromPixel(mx)));
|
doc->SetAttribute(domElement, AttrMx1, QString().setNum(qApp->fromPixel(pos.x())));
|
||||||
doc->SetAttribute(domElement, AttrMy1, QString().setNum(qApp->fromPixel(my)));
|
doc->SetAttribute(domElement, AttrMy1, QString().setNum(qApp->fromPixel(pos.y())));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrMx2, QString().setNum(qApp->fromPixel(mx)));
|
doc->SetAttribute(domElement, AttrMx2, QString().setNum(qApp->fromPixel(pos.x())));
|
||||||
doc->SetAttribute(domElement, AttrMy2, QString().setNum(qApp->fromPixel(my)));
|
doc->SetAttribute(domElement, AttrMy2, QString().setNum(qApp->fromPixel(pos.y())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (VDrawTool *tool = qobject_cast<VDrawTool *>(VAbstractPattern::getTool(m_idTool)))
|
||||||
|
{
|
||||||
|
tool->DoChangePosition(nodeId, pos);
|
||||||
|
}
|
||||||
|
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,11 +41,10 @@ enum class MoveDoublePoint: char { FirstPoint, SecondPoint };
|
||||||
|
|
||||||
class MoveDoubleLabel : public MoveAbstractLabel
|
class MoveDoubleLabel : public MoveAbstractLabel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, MoveDoublePoint type,
|
MoveDoubleLabel(VAbstractPattern *doc, const QPointF &pos, MoveDoublePoint type,
|
||||||
quint32 toolId, quint32 pointId, QUndoCommand *parent = nullptr);
|
quint32 toolId, quint32 pointId, QUndoCommand *parent = nullptr);
|
||||||
virtual ~MoveDoubleLabel() Q_DECL_OVERRIDE;
|
virtual ~MoveDoubleLabel()=default;
|
||||||
|
|
||||||
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
|
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
|
||||||
virtual int id() const Q_DECL_OVERRIDE;
|
virtual int id() const Q_DECL_OVERRIDE;
|
||||||
|
@ -53,11 +52,13 @@ public:
|
||||||
quint32 GetToolId() const;
|
quint32 GetToolId() const;
|
||||||
MoveDoublePoint GetPointType() const;
|
MoveDoublePoint GetPointType() const;
|
||||||
protected:
|
protected:
|
||||||
virtual void Do(double mx, double my) Q_DECL_OVERRIDE;
|
virtual void Do(const QPointF &pos) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MoveDoubleLabel)
|
Q_DISABLE_COPY(MoveDoubleLabel)
|
||||||
MoveDoublePoint m_type;
|
MoveDoublePoint m_type;
|
||||||
quint32 m_idTool;
|
quint32 m_idTool;
|
||||||
|
//Need for resizing scene rect
|
||||||
|
QGraphicsScene *m_scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -37,21 +37,23 @@
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vundocommand.h"
|
#include "../vundocommand.h"
|
||||||
#include "moveabstractlabel.h"
|
#include "moveabstractlabel.h"
|
||||||
|
#include "../vtools/tools/drawTools/vdrawtool.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MoveLabel::MoveLabel(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QUndoCommand *parent)
|
MoveLabel::MoveLabel(VAbstractPattern *doc, const QPointF &pos, const quint32 &id, QUndoCommand *parent)
|
||||||
: MoveAbstractLabel(doc, id, x, y, parent)
|
: MoveAbstractLabel(doc, id, pos, parent),
|
||||||
|
m_scene(qApp->getCurrentScene())
|
||||||
{
|
{
|
||||||
setText(tr("move point label"));
|
setText(tr("move point label"));
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0"));
|
m_oldPos.rx() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0"));
|
||||||
m_oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy, "0.0"));
|
m_oldPos.ry() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy, "0.0"));
|
||||||
|
|
||||||
qCDebug(vUndo, "Label old Mx %f", m_oldMx);
|
qCDebug(vUndo, "Label old Mx %f", m_oldPos.x());
|
||||||
qCDebug(vUndo, "Label old My %f", m_oldMy);
|
qCDebug(vUndo, "Label old My %f", m_oldPos.y());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -59,10 +61,6 @@ MoveLabel::MoveLabel(VAbstractPattern *doc, const double &x, const double &y, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
MoveLabel::~MoveLabel()
|
|
||||||
{}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool MoveLabel::mergeWith(const QUndoCommand *command)
|
bool MoveLabel::mergeWith(const QUndoCommand *command)
|
||||||
{
|
{
|
||||||
|
@ -75,10 +73,9 @@ bool MoveLabel::mergeWith(const QUndoCommand *command)
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(vUndo, "Mergin undo.");
|
qCDebug(vUndo, "Mergin undo.");
|
||||||
m_newMx = moveCommand->GetNewMx();
|
m_newPos = moveCommand->GetNewPos();
|
||||||
m_newMy = moveCommand->GetNewMy();
|
qCDebug(vUndo, "Label new Mx %f", m_newPos.x());
|
||||||
qCDebug(vUndo, "Label new Mx %f", m_newMx);
|
qCDebug(vUndo, "Label new My %f", m_newPos.y());
|
||||||
qCDebug(vUndo, "Label new My %f", m_newMy);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,16 +86,22 @@ int MoveLabel::id() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveLabel::Do(double mx, double my)
|
void MoveLabel::Do(const QPointF &pos)
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "New mx %f", mx);
|
qCDebug(vUndo, "New mx %f", pos.x());
|
||||||
qCDebug(vUndo, "New my %f", my);
|
qCDebug(vUndo, "New my %f", pos.y());
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
|
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(pos.x())));
|
||||||
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(my)));
|
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(pos.y())));
|
||||||
|
|
||||||
|
if (VDrawTool *tool = qobject_cast<VDrawTool *>(VAbstractPattern::getTool(nodeId)))
|
||||||
|
{
|
||||||
|
tool->DoChangePosition(nodeId, pos);
|
||||||
|
}
|
||||||
|
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,18 +39,18 @@
|
||||||
|
|
||||||
class MoveLabel : public MoveAbstractLabel
|
class MoveLabel : public MoveAbstractLabel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
MoveLabel(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id,
|
MoveLabel(VAbstractPattern *doc, const QPointF &pos, const quint32 &id, QUndoCommand *parent = nullptr);
|
||||||
QUndoCommand *parent = nullptr);
|
virtual ~MoveLabel()=default;
|
||||||
virtual ~MoveLabel();
|
|
||||||
|
|
||||||
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
|
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
|
||||||
virtual int id() const Q_DECL_OVERRIDE;
|
virtual int id() const Q_DECL_OVERRIDE;
|
||||||
protected:
|
protected:
|
||||||
virtual void Do(double mx, double my) Q_DECL_OVERRIDE;
|
virtual void Do(const QPointF &pos) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MoveLabel)
|
Q_DISABLE_COPY(MoveLabel)
|
||||||
|
//Need for resizing scene rect
|
||||||
|
QGraphicsScene *m_scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MOVELABEL_H
|
#endif // MOVELABEL_H
|
||||||
|
|
|
@ -38,12 +38,14 @@
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vundocommand.h"
|
#include "../vundocommand.h"
|
||||||
#include "moveabstractlabel.h"
|
#include "moveabstractlabel.h"
|
||||||
|
#include "../vtools/tools/drawTools/vdrawtool.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
OperationMoveLabel::OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, double x, double y, quint32 idPoint,
|
OperationMoveLabel::OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, const QPointF &pos, quint32 idPoint,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: MoveAbstractLabel(doc, idPoint, x, y, parent),
|
: MoveAbstractLabel(doc, idPoint, pos, parent),
|
||||||
m_idTool(idTool)
|
m_idTool(idTool),
|
||||||
|
m_scene(qApp->getCurrentScene())
|
||||||
{
|
{
|
||||||
setText(tr("move point label"));
|
setText(tr("move point label"));
|
||||||
|
|
||||||
|
@ -52,11 +54,11 @@ OperationMoveLabel::OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, do
|
||||||
const QDomElement element = GetDestinationObject(m_idTool, nodeId);
|
const QDomElement element = GetDestinationObject(m_idTool, nodeId);
|
||||||
if (element.isElement())
|
if (element.isElement())
|
||||||
{
|
{
|
||||||
m_oldMx = qApp->toPixel(doc->GetParametrDouble(element, AttrMx, "0.0"));
|
m_oldPos.rx() = qApp->toPixel(doc->GetParametrDouble(element, AttrMx, "0.0"));
|
||||||
m_oldMy = qApp->toPixel(doc->GetParametrDouble(element, AttrMy, "0.0"));
|
m_oldPos.ry() = qApp->toPixel(doc->GetParametrDouble(element, AttrMy, "0.0"));
|
||||||
|
|
||||||
qCDebug(vUndo, "Label old Mx %f", m_oldMx);
|
qCDebug(vUndo, "Label old Mx %f", m_oldPos.x());
|
||||||
qCDebug(vUndo, "Label old My %f", m_oldMy);
|
qCDebug(vUndo, "Label old My %f", m_oldPos.y());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -64,11 +66,6 @@ OperationMoveLabel::OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
OperationMoveLabel::~OperationMoveLabel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool OperationMoveLabel::mergeWith(const QUndoCommand *command)
|
bool OperationMoveLabel::mergeWith(const QUndoCommand *command)
|
||||||
{
|
{
|
||||||
|
@ -81,10 +78,9 @@ bool OperationMoveLabel::mergeWith(const QUndoCommand *command)
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(vUndo, "Mergin undo.");
|
qCDebug(vUndo, "Mergin undo.");
|
||||||
m_newMx = moveCommand->GetNewMx();
|
m_newPos = moveCommand->GetNewPos();
|
||||||
m_newMy = moveCommand->GetNewMy();
|
qCDebug(vUndo, "Label new Mx %f", m_newPos.x());
|
||||||
qCDebug(vUndo, "Label new Mx %f", m_newMx);
|
qCDebug(vUndo, "Label new My %f", m_newPos.y());
|
||||||
qCDebug(vUndo, "Label new My %f", m_newMy);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,16 +91,22 @@ int OperationMoveLabel::id() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void OperationMoveLabel::Do(double mx, double my)
|
void OperationMoveLabel::Do(const QPointF &pos)
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "New mx %f", mx);
|
qCDebug(vUndo, "New mx %f", pos.x());
|
||||||
qCDebug(vUndo, "New my %f", my);
|
qCDebug(vUndo, "New my %f", pos.y());
|
||||||
|
|
||||||
QDomElement domElement = GetDestinationObject(m_idTool, nodeId);
|
QDomElement domElement = GetDestinationObject(m_idTool, nodeId);
|
||||||
if (not domElement.isNull() && domElement.isElement())
|
if (not domElement.isNull() && domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
|
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(pos.x())));
|
||||||
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(my)));
|
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(pos.y())));
|
||||||
|
|
||||||
|
if (VDrawTool *tool = qobject_cast<VDrawTool *>(VAbstractPattern::getTool(m_idTool)))
|
||||||
|
{
|
||||||
|
tool->DoChangePosition(nodeId, pos);
|
||||||
|
}
|
||||||
|
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,21 +40,22 @@
|
||||||
|
|
||||||
class OperationMoveLabel : public MoveAbstractLabel
|
class OperationMoveLabel : public MoveAbstractLabel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, double x, double y, quint32 idPoint,
|
OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, const QPointF &pos, quint32 idPoint,
|
||||||
QUndoCommand *parent = nullptr);
|
QUndoCommand *parent = nullptr);
|
||||||
virtual ~OperationMoveLabel();
|
virtual ~OperationMoveLabel()=default;
|
||||||
|
|
||||||
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
|
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
|
||||||
virtual int id() const Q_DECL_OVERRIDE;
|
virtual int id() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
quint32 GetToolId() const;
|
quint32 GetToolId() const;
|
||||||
protected:
|
protected:
|
||||||
virtual void Do(double mx, double my) Q_DECL_OVERRIDE;
|
virtual void Do(const QPointF &pos) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(OperationMoveLabel)
|
Q_DISABLE_COPY(OperationMoveLabel)
|
||||||
quint32 m_idTool;
|
quint32 m_idTool;
|
||||||
|
//Need for resizing scene rect
|
||||||
|
QGraphicsScene *m_scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user