Eclipse SUMO - Simulation of Urban MObility
GNEUndoList.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <stack>
24#include <string>
25
27
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32class GNEChange;
35
36// ===========================================================================
37// class definitions
38// ===========================================================================
44 FXDECLARE_ABSTRACT(GNEUndoList)
45
46public:
48 class Iterator {
49
50 public:
52 ~Iterator();
53
55 bool end() const;
56
58 int getIndex() const;
59
61 const std::string getDescription() const;
62
64 FXIcon* getIcon() const;
65
67 Iterator& operator++(int);
68
69 protected:
71 Iterator(GNEChange* change);
72
73 private:
75 Iterator();
76
79
82 };
83
85 class UndoIterator : public Iterator {
86
87 public:
90 };
91
93 class RedoIterator : public Iterator {
94
95 public:
98 };
99
102
104 ~GNEUndoList();
105
107 void undo();
108
110 void redo();
111
115 std::string undoName() const;
116
120 std::string redoName() const;
121
128 void begin(GUIIcon icon, const std::string& description);
129
136 void begin(Supermode supermode, GUIIcon icon, const std::string& description);
137
143 void end();
144
153 void add(GNEChange* command, bool doit = false, bool merge = true);
154
157
158 /* @brief clears the undo list (implies abort)
159 * All undo and redo information will be destroyed.
160 */
161 void clear();
162
165
168
170 int currentCommandGroupSize() const;
171
174
177
179 bool hasCommandGroup() const;
180
185 bool busy() const;
186
190 long onCmdUndo(FXObject*, FXSelector, void*);
191
193 long onUpdUndo(FXObject*, FXSelector, void*);
194
196 long onCmdRedo(FXObject*, FXSelector, void*);
197
199 long onUpdRedo(FXObject*, FXSelector, void*);
201
202protected:
206 void cut();
207
213
215 bool canUndo() const;
216
218 bool canRedo() const;
219
220private:
223
224 // @brief the stack of currently active change groups
225 std::stack<GNEChangeGroup*> myChangeGroups;
226
227 // @brief the parent GNEApplicationWindow for this undolist
229};
Supermode
@brie enum for supermodes
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
The main window of the Netedit.
the function-object for an editing operation (abstract base)
GNEChange * undoList
undo list command (can be access by GNEUndoList)
friend class GNEUndoList
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:60
FOX declaration.
Definition: GNEUndoList.h:48
const std::string getDescription() const
get description
Definition: GNEUndoList.cpp:70
bool end() const
check if iterator is at the end
Definition: GNEUndoList.cpp:58
FXIcon * getIcon() const
get icon
Definition: GNEUndoList.cpp:81
Iterator()
default constructor
Iterator & operator++(int)
increment operator
Definition: GNEUndoList.cpp:92
GNEChange * myCurrentChange
current change
Definition: GNEUndoList.h:78
int getIndex() const
get index
Definition: GNEUndoList.cpp:64
RedoIterator(const GNEUndoList *undoList)
constructor for GNEUndoList
UndoIterator(const GNEUndoList *undoList)
constructor for GNEUndoList
void abortCurrentSubGroup()
Abort the current command sub-group being compiled. All commands already added to the sub-groups undo...
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
bool hasCommandGroup() const
Check if undoList has command group.
void undo()
undo the last command group
long onUpdUndo(FXObject *, FXSelector, void *)
event after Undo
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
std::string undoName() const
Return name of the first undo command available; if no undo command available this will return the em...
~GNEUndoList()
destructor
GNEApplicationWindow *const myGNEApplicationWindowParent
Definition: GNEUndoList.h:228
void abortAllChangeGroups()
reverts and discards ALL active chained change groups
Supermode getRedoSupermode() const
get redo supermode
long onUpdRedo(FXObject *, FXSelector, void *)
event after Redo
bool myWorking
Currently busy with undo or redo.
Definition: GNEUndoList.h:222
void cut()
Cut the redo list. This is automatically invoked when a new undo command is added.
bool canRedo() const
Can we redo more commands.
Supermode getUndoSupermode() const
get undo supermode
bool canUndo() const
Can we undo more commands.
std::stack< GNEChangeGroup * > myChangeGroups
Definition: GNEUndoList.h:225
void redo()
redo the last command group
long onCmdUndo(FXObject *, FXSelector, void *)
int currentCommandGroupSize() const
get size of current CommandGroup
void abortLastChangeGroup()
reverts last active chained change group
long onCmdRedo(FXObject *, FXSelector, void *)
redo change
bool busy() const
Return TRUE if currently inside undo or redo operation; this is useful to avoid generating another un...
std::string redoName() const
Return name of the first redo command available; if no Redo command available this will return the em...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute