Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEUndoList.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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 const std::string getTimeStamp() const;
65
67 FXIcon* getIcon() const;
68
70 Iterator& operator++(int);
71
72 protected:
74 Iterator(GNEChange* change);
75
76 private:
78 Iterator();
79
82
85 };
86
88 class UndoIterator : public Iterator {
89
90 public:
93 };
94
96 class RedoIterator : public Iterator {
97
98 public:
101 };
102
105
107 ~GNEUndoList();
108
110 void undo();
111
113 void redo();
114
118 std::string undoName() const;
119
123 std::string redoName() const;
124
131 void begin(GUIIcon icon, const std::string& description);
132
139 void begin(const GNEAttributeCarrier* AC, const std::string& description);
140
147 void begin(Supermode supermode, GUIIcon icon, const std::string& description);
148
154 void end();
155
164 void add(GNEChange* command, bool doit = false, bool merge = true);
165
166 /* @brief clears the undo list (implies abort)
167 * All undo and redo information will be destroyed.
168 */
169 void clear();
170
173
176
178 int currentCommandGroupSize() const;
179
182
185
187 bool hasCommandGroup() const;
188
193 bool busy() const;
194
198 long onCmdUndo(FXObject*, FXSelector, void*);
199
201 long onUpdUndo(FXObject*, FXSelector, void*);
202
204 long onCmdRedo(FXObject*, FXSelector, void*);
205
207 long onUpdRedo(FXObject*, FXSelector, void*);
209
210protected:
214 void cut();
215
221
223 bool canUndo() const;
224
226 bool canRedo() const;
227
228private:
231
232 // @brief the stack of currently active change groups
233 std::stack<GNEChangeGroup*> myChangeGroups;
234
235 // @brief the parent GNEApplicationWindow for this undolist
237};
Supermode
@brie enum for supermodes
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
The main window of 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:56
FOX declaration.
Definition GNEUndoList.h:48
const std::string getTimeStamp() const
get timeStamp
const std::string getDescription() const
get description
bool end() const
check if iterator is at the end
FXIcon * getIcon() const
get icon
Iterator()
default constructor
Iterator & operator++(int)
increment operator
GNEChange * myCurrentChange
current change
Definition GNEUndoList.h:81
int getIndex() const
get index
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
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.
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
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...