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 /****************************************************************************/
14 // FXUndoList is pretty dandy but some features are missing:
15 // - we cannot find out wether we have currently begun an undo-group and
16 // thus abort() is hard to use.
17 // - onUpd-methods do not disable undo/redo while in an undo-group
18 //
19 // GNEUndoList inherits from FXUndoList and patches some methods. these are
20 // prefixed with p_
21 /****************************************************************************/
22 #ifndef GNEUndoList_h
23 #define GNEUndoList_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #include <config.h>
30 
31 #include <stack>
32 #include <string>
33 #include <fx.h>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
48 class GNEUndoList : public FXUndoList {
50  FXDECLARE_ABSTRACT(GNEUndoList)
51 
52 public:
56 
62  void p_begin(const std::string& description);
63 
69  void p_end();
70 
72  void p_clear();
73 
75  void p_abort();
76 
79 
81  void undo();
82 
84  void redo();
85 
87  void p_add(GNEChange_Attribute* cmd);
88 
90  int currentCommandGroupSize() const;
91 
95  long p_onUpdUndo(FXObject*, FXSelector, void*);
96 
98  long p_onUpdRedo(FXObject*, FXSelector, void*);
100 
102  bool hasCommandGroup() const;
103 
104 private:
106  class CommandGroup : public FXCommandGroup {
107  public:
109  CommandGroup(std::string description);
110 
112  const std::string& getDescription();
113 
115  FXString undoName() const;
116 
118  FXString redoName() const;
119 
120  private:
122  const std::string myDescription;
123  };
124 
125  // @brief the stack of currently active command groups
126  std::stack<CommandGroup*> myCommandGroups;
127 
128  // @brief the parent GNEApplicationWindow for this undolist
130 };
131 
132 
133 #endif
134 
135 /****************************************************************************/
136 
GNEUndoList::p_clear
void p_clear()
clears the undo list (implies abort)
Definition: GNEUndoList.cpp:86
GNEUndoList::myGNEApplicationWindowParent
GNEApplicationWindow *const myGNEApplicationWindowParent
Definition: GNEUndoList.h:129
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:79
GNEApplicationWindow
The main window of the Netedit.
Definition: GNEApplicationWindow.h:58
GNEUndoList::redo
void redo()
redo the last command group
Definition: GNEUndoList.cpp:122
GNEUndoList::CommandGroup::myDescription
const std::string myDescription
description of command
Definition: GNEUndoList.h:122
GNEUndoList::CommandGroup::CommandGroup
CommandGroup(std::string description)
Constructor.
Definition: GNEUndoList.cpp:236
GNEUndoList::p_add
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Definition: GNEUndoList.cpp:131
GNEUndoList::undo
void undo()
undo the last command group
Definition: GNEUndoList.cpp:113
GNEUndoList::myCommandGroups
std::stack< CommandGroup * > myCommandGroups
Definition: GNEUndoList.h:126
GNEUndoList::CommandGroup
class CommandGroup
Definition: GNEUndoList.h:106
GNEUndoList::CommandGroup::redoName
FXString redoName() const
get redo name
Definition: GNEUndoList.cpp:254
GNEUndoList::GNEUndoList
GNEUndoList(GNEApplicationWindow *parent)
FOX declaration.
Definition: GNEUndoList.cpp:65
GNEUndoList::p_abortLastCommandGroup
void p_abortLastCommandGroup()
reverts last command group
Definition: GNEUndoList.cpp:103
GNEUndoList::p_onUpdRedo
long p_onUpdRedo(FXObject *, FXSelector, void *)
event after Redo
Definition: GNEUndoList.cpp:191
GNEUndoList::p_abort
void p_abort()
reverts and discards ALL active command groups
Definition: GNEUndoList.cpp:93
GNEUndoList::currentCommandGroupSize
int currentCommandGroupSize() const
get size of current CommandGroup
Definition: GNEUndoList.cpp:141
GNEUndoList::hasCommandGroup
bool hasCommandGroup() const
Check if undoList has command group.
Definition: GNEUndoList.cpp:231
GNEUndoList::CommandGroup::getDescription
const std::string & getDescription()
get description
Definition: GNEUndoList.cpp:242
GNEUndoList::CommandGroup::undoName
FXString undoName() const
get undo Name
Definition: GNEUndoList.cpp:248
config.h
GNEChange_Attribute
the function-object for an editing operation (abstract base)
Definition: GNEChange_Attribute.h:47
GNEUndoList::p_onUpdUndo
long p_onUpdUndo(FXObject *, FXSelector, void *)
Definition: GNEUndoList.cpp:151
GNEUndoList
Definition: GNEUndoList.h:48
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:72