Changeset 0ec9f5
- Timestamp:
- Apr 23, 2021, 9:02:12 PM (5 years ago)
- Branches:
- Candidate_v1.7.0, stable
- Children:
- 0fbea3
- Parents:
- 5061d9
- git-author:
- Frederik Heber <frederik.heber@…> (04/06/21 20:09:39)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/23/21 21:02:12)
- Files:
-
- 4 added
- 12 edited
-
doc/userguide/userguide.xml (modified) (1 diff)
-
src/Actions/ActionHistory.cpp (modified) (2 diffs)
-
src/Actions/ActionHistory.hpp (modified) (2 diffs)
-
src/Actions/ActionQueue.cpp (modified) (1 diff)
-
src/Actions/ActionQueue.hpp (modified) (2 diffs)
-
src/Actions/CommandAction/UndoMarkAction.cpp (added)
-
src/Actions/CommandAction/UndoMarkAction.def (added)
-
src/Actions/CommandAction/UndoMarkAction.hpp (added)
-
src/Actions/GlobalListOfActions.hpp (modified) (1 diff)
-
src/Actions/Makefile.am (modified) (3 diffs)
-
src/Actions/UndoAction.cpp (modified) (1 diff)
-
src/Actions/UndoAction.def (modified) (2 diffs)
-
tests/Python/AllActions/options.dat (modified) (2 diffs)
-
tests/regression/Makefile.am (modified) (1 diff)
-
tests/regression/Options/UndoMark/testsuite-options-undo-mark.at (added)
-
tests/regression/Options/testsuite-options.at (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doc/userguide/userguide.xml
r5061d9 r0ec9f5 426 426 superfluous but it comes in very handy in the interactive ones. Also 427 427 this should tell you that actions are placed internally in a queue, i.e. a history, 428 that undo and redo manipulate.</para> 428 that undo and redo manipulate.</para> 429 <para>Furthermore, a specific event in the history of actions can be 430 marked using 431 <programlisting>... --add-atom H --domain-position "0,0,0" --undo-mark --select-all-atoms --remove-atom</programlisting> 432 Using this mark (that is unset by <programlisting>--undo-mark 0</programlisting>) 433 one can then step directly back to that event by undoing all actions in between 434 the current and the marked event. 435 <programlisting>--undo --till-mark 1</programlisting> 436 Here, this will jump back to when the hydrogen atom was just added. 437 This function is required as not all actions produce an event in the Action 438 history. Certain events will just calculate something and output, i.e. they 439 do not change the state. However, thereby one cannot simply count actions 440 to return back to a specific state. Hence, this function allows to mark a 441 specific state beforehand. 442 </para> 429 443 <para>Due to a current limitation of the implementation each command can be used on the command-line only once. Note that this <emphasis role="italic">only</emphasis> applies to the command-line interface. All other interfaces, especially all interactive ones, do not have such a restriction. For the command-line interface there are several ways to work around it. Either by splitting the whole chain of commands into several chunks, each using only unique commands and using the input file (the state) to contain and transport the intermediate stages as input for the next stage. Or to switch to other commands: often there are several possible ways of achieving a goal, especially when using selections.</para> 430 444 <para>Being done now with the preliminaries we now go through all available actions present in MoleCuilder.</para> -
src/Actions/ActionHistory.cpp
r5061d9 r0ec9f5 64 64 HistoryElement elem = history.back(); 65 65 LOG(1, "INFO: Undoing action " << elem.action->getName()); 66 if ((mark != NULL) && (mark == &elem)) { 67 LOG(2, "DEBUG: Undoing marked item in ActionHistory, hence resetting mark."); 68 mark = NULL; 69 } 66 70 history.pop_back(); 67 71 ActionState::ptr newState = elem.action->undo(elem.state); … … 93 97 } 94 98 99 void ActionHistory::setMark() { 100 mark = &(history.back()); 101 } 102 103 void ActionHistory::unsetMark() { 104 mark = NULL; 105 } 106 107 void ActionHistory::undoTillMark() { 108 if (mark == NULL) { 109 undoLast(); 110 } else { 111 while (mark != &(history.back())) 112 undoLast(); 113 } 114 } 115 95 116 void ActionHistory::addElement(Action* action,ActionState::ptr state){ 96 117 yrotsih.clear(); -
src/Actions/ActionHistory.hpp
r5061d9 r0ec9f5 43 43 bool hasRedo(); 44 44 45 void setMark(); 46 void unsetMark(); 47 void undoTillMark(); 48 45 49 void addElement(Action*,ActionState::ptr); 46 50 void clear(); … … 49 53 std::deque<HistoryElement> history; 50 54 std::deque<HistoryElement> yrotsih; 55 56 //!> marks a specific state in the history to allow undoing directly till that 57 HistoryElement * mark; 51 58 52 59 public: -
src/Actions/ActionQueue.cpp
r5061d9 r0ec9f5 412 412 } 413 413 414 void ActionQueue::setMark() { 415 history->setMark(); 416 } 417 418 void ActionQueue::unsetMark() { 419 history->unsetMark(); 420 } 421 422 void ActionQueue::undoTillMark() 423 { 424 history->undoTillMark(); 425 } 426 414 427 bool ActionQueue::canUndo() const 415 428 { -
src/Actions/ActionQueue.hpp
r5061d9 r0ec9f5 129 129 void outputAsPython(std::ostream &output) const; 130 130 131 /** Undoes last called Ac friend void ::cleanUp();tion.131 /** Undoes last called Action. 132 132 * 133 133 */ … … 138 138 */ 139 139 void redoLast(); 140 141 /** 142 * Marks the current item of the action history to allow returning to that state lateron. 143 */ 144 void setMark(); 145 146 /** 147 * Resets any currently marked item in the action history. 148 */ 149 void unsetMark(); 150 151 /** Undoes actions till a set mark in the ActionHistory. 152 * 153 */ 154 void undoTillMark(); 140 155 141 156 /** Checks whether there is one completed Action stored in ActionHistory in the past. -
src/Actions/GlobalListOfActions.hpp
r5061d9 r0ec9f5 54 54 (CommandSetRandomNumbersDistribution) \ 55 55 (CommandStoreSession) \ 56 (CommandUndoMark) \ 56 57 (CommandVerbose) \ 57 58 (CommandVersion) \ -
src/Actions/Makefile.am
r5061d9 r0ec9f5 207 207 Actions/CommandAction/NoDryRunAction.cpp \ 208 208 Actions/CommandAction/StoreSessionAction.cpp \ 209 Actions/CommandAction/UndoMarkAction.cpp \ 209 210 Actions/CommandAction/VerboseAction.cpp \ 210 211 Actions/CommandAction/VersionAction.cpp \ … … 219 220 Actions/CommandAction/NoDryRunAction.hpp \ 220 221 Actions/CommandAction/StoreSessionAction.hpp \ 222 Actions/CommandAction/UndoMarkAction.hpp \ 221 223 Actions/CommandAction/VerboseAction.hpp \ 222 224 Actions/CommandAction/VersionAction.hpp \ … … 231 233 Actions/CommandAction/NoDryRunAction.def \ 232 234 Actions/CommandAction/StoreSessionAction.def \ 235 Actions/CommandAction/UndoMarkAction.def \ 233 236 Actions/CommandAction/VerboseAction.def \ 234 237 Actions/CommandAction/VersionAction.def \ -
src/Actions/UndoAction.cpp
r5061d9 r0ec9f5 52 52 ActionState::ptr UndoAction::performCall(){ 53 53 // std::cout << "Undo" << std::endl; 54 ActionQueue::getInstance().undoLast(); 54 if (params.undoTillMark.get()) 55 ActionQueue::getInstance().undoTillMark(); 56 else 57 ActionQueue::getInstance().undoLast(); 55 58 return Action::success; 56 59 } -
src/Actions/UndoAction.def
r5061d9 r0ec9f5 13 13 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 14 14 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 15 #undef paramtypes 16 #undef paramreferences 17 #undef paramtokens 18 #undef paramdescriptions 19 #undef paramdefaults 15 #define paramtypes (bool) 16 #define paramtokens ("till-mark") 17 #define paramdescriptions ("whether to undo just a single step (false) or until a previously set mark (true)") 18 #define paramdefaults (PARAM_DEFAULT(false)) 19 #define paramreferences (undoTillMark) 20 #define paramvalids (DummyValidator<bool>()) 20 21 21 22 // some defines for all the names, you may use ACTION, STATE and PARAMS … … 27 28 28 29 // finally the information stored in the ActionTrait specialization 29 #define DESCRIPTION "undo last action "30 #define DESCRIPTION "undo last action or until a given mark" 30 31 #undef SHORTFORM -
tests/Python/AllActions/options.dat
r5061d9 r0ec9f5 250 250 take_best_of "5" 251 251 tesselation_radius "5." 252 till-mark "0" 252 253 time_step_zero "0" 253 254 training_file "training.dat" … … 255 256 translate_shapes "1. 2. 3." 256 257 translation "0. 0. 0." 258 undo-mark "0" 257 259 unselect_atom_by_element "1" 258 260 unselect_atom_by_element "4" -
tests/regression/Makefile.am
r5061d9 r0ec9f5 180 180 $(srcdir)/Options/Session/testsuite-options-store-session-python.at \ 181 181 $(srcdir)/Options/SetDefaultName/testsuite-options-set-default-name.at \ 182 $(srcdir)/Options/UndoMark/testsuite-options-undo-mark.at \ 182 183 $(srcdir)/Options/Verbosity/testsuite-options-verbosity.at \ 183 184 $(srcdir)/Options/Warranty/testsuite-options-warranty.at \ -
tests/regression/Options/testsuite-options.at
r5061d9 r0ec9f5 55 55 m4_include([Options/DryRun/testsuite-options-no-dryrun.at]) 56 56 m4_include([Options/DryRun/testsuite-options-dryrun-storesession.at]) 57 58 # test undo mark 59 m4_include([Options/UndoMark/testsuite-options-undo-mark.at])
Note:
See TracChangeset
for help on using the changeset viewer.
