mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Undo Command to restore position of vertices moved by mouse or arrow key
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user