mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
105 lines
2.5 KiB
C++
105 lines
2.5 KiB
C++
/*
|
|
* Commands.h
|
|
*
|
|
* (c) 2014 Sofian Audry -- info(@)sofianaudry(.)com
|
|
* (c) 2014 Alexandre Quessy -- alexandre(@)quessy(.)net
|
|
* (c) 2014 Dame Diongue -- baydamd(@)gmail(.)com
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef COMMANDS_H_
|
|
#define COMMANDS_H_
|
|
|
|
#include <QUndoCommand>
|
|
#include "MainWindow.h"
|
|
#include "MapperGLCanvas.h"
|
|
|
|
enum CommandId {
|
|
CMD_KEY_MOVE_VERTEX,
|
|
CMD_MOUSE_MOVE_VERTEX,
|
|
};
|
|
|
|
class AddShapesCommand : public QUndoCommand
|
|
{
|
|
public:
|
|
AddShapesCommand(MainWindow *mainWindow, uid mappingId, QUndoCommand *parent = 0);
|
|
void undo();
|
|
void redo();
|
|
|
|
private:
|
|
MainWindow *m_mainWindow;
|
|
Mapping::ptr m_mappingPtr;
|
|
uid m_mappingId;
|
|
|
|
};
|
|
|
|
class MoveVertexCommand : public QUndoCommand
|
|
{
|
|
public:
|
|
enum MoveVertexOption {
|
|
KEY_MOVE,
|
|
MOUSE_MOVE,
|
|
MOUSE_RELEASE
|
|
};
|
|
MoveVertexCommand(MapperGLCanvas* canvas, int activeVertex, const QPointF &point, MoveVertexOption option, QUndoCommand *parent = 0);
|
|
|
|
int id() const;
|
|
void undo();
|
|
void redo();
|
|
bool mergeWith(const QUndoCommand* other);
|
|
|
|
protected:
|
|
// Information pertaining to the moving of vertex.
|
|
MapperGLCanvas* _canvas;
|
|
QWeakPointer<MShape> _shape;
|
|
int _movedVertex;
|
|
QPointF _vertexPosition;
|
|
|
|
// Did we use keys to move that vertex?
|
|
int _option;
|
|
|
|
// Clone of the original shape used for undoing purposes.
|
|
MShape::ptr _originalShape;
|
|
};
|
|
|
|
class MoveShapesCommand : public QUndoCommand
|
|
{
|
|
public:
|
|
MoveShapesCommand(MapperGLCanvas *mapperGLCanvas, QMouseEvent *event, const QPointF &point, QUndoCommand *parent = 0);
|
|
void undo();
|
|
void redo();
|
|
|
|
private:
|
|
MapperGLCanvas *m_mapperGLCanvas;
|
|
MShape *m_shape;
|
|
QMouseEvent *m_event;
|
|
QPointF newPosition, oldPosition;
|
|
};
|
|
|
|
class DeleteMappingCommand : public QUndoCommand
|
|
{
|
|
public:
|
|
DeleteMappingCommand(MainWindow *mainWindow, uid mappingId, QUndoCommand *parent = 0);
|
|
void undo();
|
|
void redo();
|
|
|
|
private:
|
|
MainWindow *m_mainWindow;
|
|
Mapping::ptr m_mappingPtr;
|
|
uid m_mappingId;
|
|
};
|
|
|
|
#endif /* COMMANDS_H_ */
|