58 myCurrentChange(undoList->undoList),
68 return myCurrentChange ==
nullptr;
80 std::string
redoName = myCurrentChange->redoName();
103 myCurrentChange = myCurrentChange->next;
127 throw ProcessError(
"GNEChangeGroup::undo: cannot call undo inside begin-end block");
150 throw ProcessError(
"GNEChangeGroup::redo: cannot call undo inside begin-end block");
205 throw ProcessError(
"GNEChangeGroup::begin: already working on undo or redo");
210 while (changeGroup->
group) {
211 changeGroup = changeGroup->
group;
237 if (!changeGroup->
group) {
238 throw ProcessError(
"GNEChangeGroup::end: no matching call to begin");
242 throw ProcessError(
"GNEChangeGroup::end: already working on undo or redo");
246 changeGroup = changeGroup->
group;
249 change = changeGroup->
group;
250 changeGroup->
group =
nullptr;
252 if (!change->
empty()) {
263 if (undoRedoDialog->shown()) {
328 throw ProcessError(
"GNEChangeGroup::add: nullptr change argument");
332 throw ProcessError(
"GNEChangeGroup::add: already working on undo or redo");
342 while (changeGroup->
group) {
343 changeGroup = changeGroup->
group;
384 return begin->getGroupSupermode();
400 return begin->getGroupSupermode();
434 const FXButton* button =
dynamic_cast<FXButton*
>(sender);
438 if (enable && !button->isEnabled()) {
439 sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
441 }
else if (!enable && button->isEnabled()) {
442 sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
446 sender->handle(
this, enable ? FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE) : FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
449 FXMenuCommand* menuCommand =
dynamic_cast<FXMenuCommand*
>(sender);
458 caption =
"Cannot Undo in the middle of " +
myChangeGroups.top()->getDescription();
462 menuCommand->setText(caption.c_str());
463 menuCommand->update();
481 const FXButton* button =
dynamic_cast<FXButton*
>(sender);
485 if (enable && !button->isEnabled()) {
486 sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE),
nullptr);
488 }
else if (!enable && button->isEnabled()) {
489 sender->handle(
this, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
493 sender->handle(
this, enable ? FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE) : FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE),
nullptr);
496 FXMenuCommand* menuCommand =
dynamic_cast<FXMenuCommand*
>(sender);
505 caption =
"Cannot Redo in the middle of " +
myChangeGroups.top()->getDescription();
509 menuCommand->setText(caption.c_str());
510 menuCommand->update();
533 if (!changeGroup->
group) {
534 throw ProcessError(
"GNEChangeGroup::abort: no matching call to begin");
538 throw ProcessError(
"GNEChangeGroup::abort: already working on undo or redo");
542 changeGroup = changeGroup->
group;
545 delete changeGroup->
group;
547 changeGroup->
group =
nullptr;
FXDEFMAP(GNEUndoList) GNEUndoListMap[]
@ DATA_SELECT
mode for selecting data elements
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
@ NETWORK_SELECT
mode for selecting network elements
@ DEMAND_SELECT
mode for selecting demand elements
@ MID_HOTKEY_CTRL_Y_REDO
Undo.
@ MID_HOTKEY_CTRL_Z_UNDO
Redo.
GUIIcon
An enumeration of icons used by the gui applications.
The main window of the Netedit.
void updateControls()
update control contents after undo/redo or recompute
GNEViewNet * getViewNet()
get pointer to viewNet
GNEUndoListDialog * getUndoListDialog()
get pointer to undoList dialog
const std::string & isUndoRedoEnabled() const
check if undo-redo is enabled
the function-object for an editing operation (abstract base)
bool trueChange()
wether original and new value differ
GNEChange * undoList
undo list command (can be access by GNEUndoList)
GUIIcon getGroupIcon() const
get icon associated with this ChangeGroup
GNEChange * redoList
redo list command (can be access by GNEUndoList)
GNEChangeGroup * group
group (can be access by GNEUndoList)
bool empty() const
Return TRUE if empty.
GNEChangeGroup()
FOX need this.
the function-object for an editing operation (abstract base)
virtual void redo()=0
redo action/operation
virtual void undo()=0
undo action/operation
Supermode getSupermode() const
get supermode
bool mergeWith(GNEChange *command)
Called by the undo system to try and merge the new incoming command with this command; should return ...
virtual std::string redoName() const =0
return rendoName
virtual std::string undoName() const =0
return undoName
bool canMerge() const
Return TRUE if this command can be merged with previous undo commands. This is useful to combine e....
SelectionInformation * getSelectionInformation() const
getmodul for selection information
const std::string getDescription() const
get description
bool end() const
check if iterator is at the end
FXIcon * getIcon() const
get icon
Iterator & operator++(int)
increment operator
int getIndex() const
get index
void updateList()
update data table
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...
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...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
void enableIntervalBarUpdate()
enable interval bar update
void disableIntervalBarUpdate()
enable interval bar update
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewNetHelper::IntervalBar & getIntervalBar()
get interval bar
GNEViewParent * getViewParent() const
get the net object
void updateViewNet() const
Mark the entire GNEViewNet to be repainted later.
GNESelectorFrame * getSelectorFrame() const
get frame for select elements
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Supermode currentSupermode
the current supermode