Index: src/Actions/MoleculeAction/VerletIntegrationAction.cpp
===================================================================
--- src/Actions/MoleculeAction/VerletIntegrationAction.cpp	(revision 51cdfdda92308eff94ae477deb3170f9bd1b79a1)
+++ src/Actions/MoleculeAction/VerletIntegrationAction.cpp	(revision 1e45f1fb84ae30e44c393f19156012e19f962ac3)
@@ -3,4 +3,5 @@
  * Description: creates and alters molecular systems
  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * Copyright (C)  2013-2014 Frederik Heber. All rights reserved.
  * 
  *
@@ -35,5 +36,7 @@
 #include "CodePatterns/MemDebug.hpp"
 
+#include "Actions/UndoRedoHelpers.hpp"
 #include "Atom/atom.hpp"
+#include "Atom/AtomicInfo.hpp"
 #include "Atom/AtomSet.hpp"
 #include "CodePatterns/Log.hpp"
@@ -53,4 +56,11 @@
 using namespace MoleCuilder;
 
+enum {
+  PositionIndex=0,
+  VelocityIndex=1,
+  ForceIndex=2,
+  MAXINDEX
+} VectorIndexType;
+
 // and construct the stuff
 #include "VerletIntegrationAction.def"
@@ -64,5 +74,5 @@
   }
   // we always operate relative to current time step
-  size_t CurrentStep = WorldTime::getInstance().getTime();
+  const size_t CurrentStep = WorldTime::getInstance().getTime();
   VerletForceIntegration<std::vector<atom *> > Verlet(set, params.Deltat.get(), true);
   // parse forces into next step
@@ -74,30 +84,81 @@
       LOG(2, "File " << params.forcesfile.get() << " found and parsed.");
   }
+
+  // create undo state for all selected atoms (undo info)
+  std::vector<AtomicInfo> UndoInfo;
+  UndoInfo.reserve(set.size());
+  {
+    for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection();
+        iter != World::getInstance().endAtomSelection();
+        ++iter)
+      UndoInfo.push_back(AtomicInfo(*(iter->second)));
+  }
+
   // perform velocity verlet update
-  bool status = Verlet(CurrentStep+1, 1, 0, params.FixedCenterOfMass.get());
-  if (!status) {
-    ELOG(1, "Velocity verlet failed.");
-    return Action::failure;
-  } else {
-    LOG(2, "DEBUG: Successfully performed updates on velocity and position.");
-    // increment to next time step
-    World::getInstance().setTime(CurrentStep+1);
+  Verlet(CurrentStep+1, 1, 0, params.FixedCenterOfMass.get());
+  LOG(0, "STATUS: Successfully performed updates on velocity and position.");
+  // increment to next time step
+  World::getInstance().setTime(CurrentStep+1);
+
+  // create undo state for all selected atoms (redo info):
+  // we need:
+  // -# forces from last step (possible parsing forces file, already in UndoInfo)
+  // -# velocities from last step (..UpdateU(), already in UndoInfo)
+  // -# current position (..UpdateX())
+  std::vector<Vectors_t> UpdatedStep(MAXINDEX);
+  UpdatedStep[PositionIndex].reserve(set.size());
+  UpdatedStep[VelocityIndex].reserve(set.size());
+  UpdatedStep[ForceIndex].reserve(set.size());
+  {
+    for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection();
+        iter != World::getInstance().endAtomSelection();
+        ++iter) {
+      UpdatedStep[PositionIndex].push_back(iter->second->getPositionAtStep(CurrentStep+1));
+      UpdatedStep[VelocityIndex].push_back(iter->second->getAtomicVelocityAtStep(CurrentStep));
+      UpdatedStep[ForceIndex].push_back(iter->second->getAtomicForceAtStep(CurrentStep));
+    }
   }
-  return Action::success;
+  MoleculeVerletIntegrationState *UndoState =
+      new MoleculeVerletIntegrationState(UndoInfo, UpdatedStep, params);
+
+  return ActionState::ptr(UndoState);
 }
 
 ActionState::ptr MoleculeVerletIntegrationAction::performUndo(ActionState::ptr _state) {
-//  MoleculeVerletIntegrationState *state = assert_cast<MoleculeVerletIntegrationState*>(_state.get());
+  MoleculeVerletIntegrationState *state =
+      assert_cast<MoleculeVerletIntegrationState*>(_state.get());
 
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
+  // go back one step
+  const size_t CurrentStep = WorldTime::getInstance().getTime();
+  World::getInstance().setTime(CurrentStep-1);
 
-  STATUS("Undo of MoleculeVerletIntegrationAction not implemented.");
-  return Action::failure;
+  // remove current step for all modified atoms
+  removeLastStep(getIdsFromAtomicInfo(state->UndoInfo));
+
+  // and set back the old step (forces have been changed)
+  SetAtomsFromAtomicInfo(state->UndoInfo);
+
+  return ActionState::ptr(_state);
 }
 
 ActionState::ptr MoleculeVerletIntegrationAction::performRedo(ActionState::ptr _state){
-  STATUS("Rddo of MoleculeVerletIntegrationAction not implemented.");
-  return Action::failure;
+  MoleculeVerletIntegrationState *state =
+      assert_cast<MoleculeVerletIntegrationState*>(_state.get());
+
+  // set forces and velocities
+  ResetAtomVelocity(state->UndoInfo, state->UpdatedStep[VelocityIndex]);
+  ResetAtomForce(state->UndoInfo, state->UpdatedStep[ForceIndex]);
+
+  // set stored new state
+  addNewStep(state->UndoInfo);
+
+  // add a new time step
+  size_t CurrentStep = WorldTime::getInstance().getTime();
+  World::getInstance().setTime(CurrentStep+1);
+
+  // and set positions of the new step
+  ResetAtomPosition(state->UndoInfo, state->UpdatedStep[PositionIndex]);
+
+  return ActionState::ptr(_state);
 }
 
Index: src/Actions/MoleculeAction/VerletIntegrationAction.def
===================================================================
--- src/Actions/MoleculeAction/VerletIntegrationAction.def	(revision 51cdfdda92308eff94ae477deb3170f9bd1b79a1)
+++ src/Actions/MoleculeAction/VerletIntegrationAction.def	(revision 1e45f1fb84ae30e44c393f19156012e19f962ac3)
@@ -7,5 +7,7 @@
 
 // all includes and forward declarations necessary for non-integral types below
-class MoleculeListClass;
+#include "LinearAlgebra/Vector.hpp"
+#include <vector>
+typedef std::vector<Vector> Vectors_t;
 
 #include "Parameters/Validators/DummyValidator.hpp"
@@ -27,6 +29,6 @@
 (DummyValidator< bool >())
 
-#undef statetypes
-#undef statereferences
+#define statetypes (std::vector<AtomicInfo>)(std::vector<Vectors_t>)
+#define statereferences (UndoInfo)(UpdatedStep)
 
 // some defines for all the names, you may use ACTION, STATE and PARAMS
