Undo Command to restore position of vertices moved by mouse or arrow key

This commit is contained in:
baydam
2015-01-19 14:35:19 +00:00
parent 146a7e4a43
commit 078a27f8ce
4 changed files with 53 additions and 6 deletions
+26
View File
@@ -22,3 +22,29 @@ void AddShapesCommand::redo()
m_mainWindow->addMappingItem(currentId);
}
}
MoveVertexCommand::MoveVertexCommand(MapperGLCanvas *mapperGLCanvas, Shape *shape, int activeVertex, const QPointF &point, QUndoCommand *parent) :
QUndoCommand(parent)
{
m_mapperGLCanvas = mapperGLCanvas;
m_shape = shape;
m_activeVertex = activeVertex;
newPosition = point;
oldPosition = m_shape->getVertex(m_activeVertex);
}
void MoveVertexCommand::undo()
{
m_shape->setVertex(m_activeVertex, oldPosition);
m_mapperGLCanvas->update();
emit m_mapperGLCanvas->shapeChanged(m_mapperGLCanvas->getCurrentShape());
}
void MoveVertexCommand::redo()
{
m_shape->setVertex(m_activeVertex, newPosition);
m_mapperGLCanvas->update();
emit m_mapperGLCanvas->shapeChanged(m_mapperGLCanvas->getCurrentShape());
}