From 59eee652c5fea36945a4a8ce2936843bd90d0e1b Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Fri, 20 Jul 2018 11:01:34 +0200 Subject: ... --- src/gui/undocommands.h | 388 ++++++++++++++++++++++++------------------------- 1 file changed, 194 insertions(+), 194 deletions(-) (limited to 'src/gui/undocommands.h') diff --git a/src/gui/undocommands.h b/src/gui/undocommands.h index 292632e..9164f01 100644 --- a/src/gui/undocommands.h +++ b/src/gui/undocommands.h @@ -1,194 +1,194 @@ -/* - TikZiT - a GUI diagram editor for TikZ - Copyright (C) 2018 Aleks Kissinger - - 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 . -*/ - -/*! - * \file undocommands.h - * - * All changes to a TikzDocument are done via subclasses of QUndoCommand. When a controller - * (e.g. TikzScene) gets input from the user to change the document, it will push one of - * these commands onto the TikzDocument's undo stack, which automatically calls the redo() - * method of the command. - */ - -#ifndef UNDOCOMMANDS_H -#define UNDOCOMMANDS_H - -#include "tikzscene.h" - -#include -#include - -class GraphUpdateCommand : public QUndoCommand { -public: - explicit GraphUpdateCommand(TikzScene *scene, - QUndoCommand *parent = 0); - void undo() override; - void redo() override; -protected: - TikzScene *_scene; -}; - -class MoveCommand : public GraphUpdateCommand -{ -public: - explicit MoveCommand(TikzScene *scene, - QMap oldNodePositions, - QMap newNodePositions, - QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - QMap _oldNodePositions; - QMap _newNodePositions; -}; - -class EdgeBendCommand : public GraphUpdateCommand -{ -public: - explicit EdgeBendCommand(TikzScene *scene, Edge *edge, - float oldWeight, int oldBend, - int oldInAngle, int oldOutAngle, - QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - Edge *_edge; - float _oldWeight; - int _oldBend; - int _oldInAngle; - int _oldOutAngle; - float _newWeight; - int _newBend; - int _newInAngle; - int _newOutAngle; -}; - -class DeleteCommand : public GraphUpdateCommand -{ -public: - explicit DeleteCommand(TikzScene *scene, - QMap deleteNodes, - QMap deleteEdges, - QSet selEdges, - QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - QMap _deleteNodes; - QMap _deleteEdges; - QSet _selEdges; -}; - -class AddNodeCommand : public GraphUpdateCommand -{ -public: - explicit AddNodeCommand(TikzScene *scene, Node *node, QRectF newBounds, - QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - Node *_node; - QRectF _oldBounds; - QRectF _newBounds; -}; - -class AddEdgeCommand : public GraphUpdateCommand -{ -public: - explicit AddEdgeCommand(TikzScene *scene, Edge *edge, QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - Edge *_edge; -}; - -class ChangeEdgeModeCommand : public GraphUpdateCommand -{ -public: - explicit ChangeEdgeModeCommand(TikzScene *scene, Edge *edge, QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - Edge *_edge; -}; - -class ApplyStyleToNodesCommand : public GraphUpdateCommand -{ -public: - explicit ApplyStyleToNodesCommand(TikzScene *scene, QString style, QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - QString _style; - QMap _oldStyles; -}; - -class ApplyStyleToEdgesCommand : public GraphUpdateCommand -{ -public: - explicit ApplyStyleToEdgesCommand(TikzScene *scene, QString style, QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - QString _style; - QMap _oldStyles; -}; - -class PasteCommand : public GraphUpdateCommand -{ -public: - explicit PasteCommand(TikzScene *scene, Graph *graph, QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - Graph *_graph; - QSet _oldSelectedNodes; - QSet _oldSelectedEdges; -}; - -class ChangeLabelCommand : public GraphUpdateCommand -{ -public: - explicit ChangeLabelCommand(TikzScene *scene, - Graph *graph, - QMap oldLabels, - QString newLabel, - QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - Graph *_graph; - QMap _oldLabels; - QString _newLabel; -}; - -class ReplaceGraphCommand : public GraphUpdateCommand -{ -public: - explicit ReplaceGraphCommand(TikzScene *scene, - Graph *oldGraph, - Graph *newGraph, - QUndoCommand *parent = 0); - void undo() override; - void redo() override; -private: - Graph *_oldGraph; - Graph *_newGraph; -}; - -#endif // UNDOCOMMANDS_H +/* + TikZiT - a GUI diagram editor for TikZ + Copyright (C) 2018 Aleks Kissinger + + 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 . +*/ + +/*! + * \file undocommands.h + * + * All changes to a TikzDocument are done via subclasses of QUndoCommand. When a controller + * (e.g. TikzScene) gets input from the user to change the document, it will push one of + * these commands onto the TikzDocument's undo stack, which automatically calls the redo() + * method of the command. + */ + +#ifndef UNDOCOMMANDS_H +#define UNDOCOMMANDS_H + +#include "tikzscene.h" + +#include +#include + +class GraphUpdateCommand : public QUndoCommand { +public: + explicit GraphUpdateCommand(TikzScene *scene, + QUndoCommand *parent = 0); + void undo() override; + void redo() override; +protected: + TikzScene *_scene; +}; + +class MoveCommand : public GraphUpdateCommand +{ +public: + explicit MoveCommand(TikzScene *scene, + QMap oldNodePositions, + QMap newNodePositions, + QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + QMap _oldNodePositions; + QMap _newNodePositions; +}; + +class EdgeBendCommand : public GraphUpdateCommand +{ +public: + explicit EdgeBendCommand(TikzScene *scene, Edge *edge, + float oldWeight, int oldBend, + int oldInAngle, int oldOutAngle, + QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + Edge *_edge; + float _oldWeight; + int _oldBend; + int _oldInAngle; + int _oldOutAngle; + float _newWeight; + int _newBend; + int _newInAngle; + int _newOutAngle; +}; + +class DeleteCommand : public GraphUpdateCommand +{ +public: + explicit DeleteCommand(TikzScene *scene, + QMap deleteNodes, + QMap deleteEdges, + QSet selEdges, + QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + QMap _deleteNodes; + QMap _deleteEdges; + QSet _selEdges; +}; + +class AddNodeCommand : public GraphUpdateCommand +{ +public: + explicit AddNodeCommand(TikzScene *scene, Node *node, QRectF newBounds, + QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + Node *_node; + QRectF _oldBounds; + QRectF _newBounds; +}; + +class AddEdgeCommand : public GraphUpdateCommand +{ +public: + explicit AddEdgeCommand(TikzScene *scene, Edge *edge, QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + Edge *_edge; +}; + +class ChangeEdgeModeCommand : public GraphUpdateCommand +{ +public: + explicit ChangeEdgeModeCommand(TikzScene *scene, Edge *edge, QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + Edge *_edge; +}; + +class ApplyStyleToNodesCommand : public GraphUpdateCommand +{ +public: + explicit ApplyStyleToNodesCommand(TikzScene *scene, QString style, QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + QString _style; + QMap _oldStyles; +}; + +class ApplyStyleToEdgesCommand : public GraphUpdateCommand +{ +public: + explicit ApplyStyleToEdgesCommand(TikzScene *scene, QString style, QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + QString _style; + QMap _oldStyles; +}; + +class PasteCommand : public GraphUpdateCommand +{ +public: + explicit PasteCommand(TikzScene *scene, Graph *graph, QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + Graph *_graph; + QSet _oldSelectedNodes; + QSet _oldSelectedEdges; +}; + +class ChangeLabelCommand : public GraphUpdateCommand +{ +public: + explicit ChangeLabelCommand(TikzScene *scene, + Graph *graph, + QMap oldLabels, + QString newLabel, + QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + Graph *_graph; + QMap _oldLabels; + QString _newLabel; +}; + +class ReplaceGraphCommand : public GraphUpdateCommand +{ +public: + explicit ReplaceGraphCommand(TikzScene *scene, + Graph *oldGraph, + Graph *newGraph, + QUndoCommand *parent = 0); + void undo() override; + void redo() override; +private: + Graph *_oldGraph; + Graph *_newGraph; +}; + +#endif // UNDOCOMMANDS_H -- cgit v1.2.3