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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // FXUndoList is pretty dandy but some features are missing:
16 // - we cannot find out wether we have currently begun an undo-group and
17 // thus abort() is hard to use.
18 // - onUpd-methods do not disable undo/redo while in an undo-group
19 //
20 // GNEUndoList inherits from FXUndoList and patches some methods. these are
21 // prefixed with p_
22 /****************************************************************************/
23 #ifndef GNEUndoList_h
24 #define GNEUndoList_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #include <config.h>
31 
32 #include <stack>
33 #include <string>
34 #include <fx.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
49 class GNEUndoList : public FXUndoList {
51  FXDECLARE_ABSTRACT(GNEUndoList)
52 
53 public:
57 
63  void p_begin(const std::string& description);
64 
70  void p_end();
71 
73  void p_clear();
74 
76  void p_abort();
77 
80 
82  void undo();
83 
85  void redo();
86 
88  void p_add(GNEChange_Attribute* cmd);
89 
91  int currentCommandGroupSize() const;
92 
96  long p_onUpdUndo(FXObject*, FXSelector, void*);
97 
99  long p_onUpdRedo(FXObject*, FXSelector, void*);
101 
103  bool hasCommandGroup() const;
104 
105 private:
107  class CommandGroup : public FXCommandGroup {
108  public:
110  CommandGroup(std::string description);
111 
113  const std::string& getDescription();
114 
116  FXString undoName() const;
117 
119  FXString redoName() const;
120 
121  private:
123  const std::string myDescription;
124  };
125 
126  // @brief the stack of currently active command groups
127  std::stack<CommandGroup*> myCommandGroups;
128 
129  // @brief the parent GNEApplicationWindow for this undolist
131 };
132 
133 
134 #endif
135 
136 /****************************************************************************/
137 
GNEUndoList::p_clear
void p_clear()
clears the undo list (implies abort)
Definition: GNEUndoList.cpp:87
GNEUndoList::myGNEApplicationWindowParent
GNEApplicationWindow *const myGNEApplicationWindowParent
Definition: GNEUndoList.h:130
GNEUndoList::p_end
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:80
GNEApplicationWindow
The main window of the Netedit.
Definition: GNEApplicationWindow.h:59
GNEUndoList::redo
void redo()
redo the last command group
Definition: GNEUndoList.cpp:123
GNEUndoList::CommandGroup::myDescription
const std::string myDescription
description of command
Definition: GNEUndoList.h:123
GNEUndoList::CommandGroup::CommandGroup
CommandGroup(std::string description)
Constructor.
Definition: GNEUndoList.cpp:204
GNEUndoList::p_add
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Definition: GNEUndoList.cpp:132
GNEUndoList::undo
void undo()
undo the last command group
Definition: GNEUndoList.cpp:114
GNEUndoList::myCommandGroups
std::stack< CommandGroup * > myCommandGroups
Definition: GNEUndoList.h:127
GNEUndoList::CommandGroup
class CommandGroup
Definition: GNEUndoList.h:107
GNEUndoList::CommandGroup::redoName
FXString redoName() const
get redo name
Definition: GNEUndoList.cpp:222
GNEUndoList::GNEUndoList
GNEUndoList(GNEApplicationWindow *parent)
FOX declaration.
Definition: GNEUndoList.cpp:66
GNEUndoList::p_abortLastCommandGroup
void p_abortLastCommandGroup()
reverts last command group
Definition: GNEUndoList.cpp:104
GNEUndoList::p_onUpdRedo
long p_onUpdRedo(FXObject *, FXSelector, void *)
event after Redo
Definition: GNEUndoList.cpp:175
GNEUndoList::p_abort
void p_abort()
reverts and discards ALL active command groups
Definition: GNEUndoList.cpp:94
GNEUndoList::currentCommandGroupSize
int currentCommandGroupSize() const
get size of current CommandGroup
Definition: GNEUndoList.cpp:142
GNEUndoList::hasCommandGroup
bool hasCommandGroup() const
Check if undoList has command group.
Definition: GNEUndoList.cpp:199
GNEUndoList::CommandGroup::getDescription
const std::string & getDescription()
get description
Definition: GNEUndoList.cpp:210
GNEUndoList::CommandGroup::undoName
FXString undoName() const
get undo Name
Definition: GNEUndoList.cpp:216
config.h
GNEChange_Attribute
the function-object for an editing operation (abstract base)
Definition: GNEChange_Attribute.h:48
GNEUndoList::p_onUpdUndo
long p_onUpdUndo(FXObject *, FXSelector, void *)
Definition: GNEUndoList.cpp:152
GNEUndoList
Definition: GNEUndoList.h:49
GNEUndoList::p_begin
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:73