2020-03-24 20:18:39 +01:00
|
|
|
#include "MoveParts.h"
|
|
|
|
|
|
|
|
#include "../Part.h"
|
|
|
|
|
|
|
|
MoveParts::MoveParts(Scene* scene, const QList<Part*>& parts, QPointF relPos)
|
|
|
|
:m_scene(scene), m_parts(parts), m_relPos(relPos)
|
|
|
|
{
|
|
|
|
setText("Move parts by " + QString::number(relPos.x()) + ", " + QString::number(relPos.y()));
|
|
|
|
}
|
|
|
|
|
|
|
|
MoveParts::~MoveParts()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoveParts::redo()
|
|
|
|
{
|
|
|
|
if(m_isFirstRedo)
|
|
|
|
m_isFirstRedo = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(auto part : m_parts)
|
2020-03-29 18:25:08 +02:00
|
|
|
part->setPos(part->getPos() + m_relPos);
|
2020-03-24 20:18:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MoveParts::undo()
|
|
|
|
{
|
|
|
|
for(auto part : m_parts)
|
2020-03-29 18:25:08 +02:00
|
|
|
part->setPos(part->getPos() - m_relPos);
|
2020-03-24 20:18:39 +01:00
|
|
|
}
|