Changeset c87d6e for src/Actions


Ignore:
Timestamp:
Apr 10, 2018, 6:43:12 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
9bb8c8
Parents:
6145577
git-author:
Frederik Heber <frederik.heber@…> (11/04/17 10:00:15)
git-committer:
Frederik Heber <frederik.heber@…> (04/10/18 06:43:12)
Message:

ForceAnnealingAction's Undo removes trajectory item if it was added.

  • before Undo would not truly undo the change to the trajectory. Now, we additionally store the trajectory size and may recogniye thereby whether we added a step or not. Note that stepping the world time does not add to the trajectory, as it uses the last present map element closest to the current time step.
  • TESTFIX: XFAIL removed from Undo as it is now working. Extended Undo test to cover both cases (ForceAnnealing added new step and did not add new step).
Location:
src/Actions/MoleculeAction
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/ForceAnnealingAction.cpp

    r6145577 rc87d6e  
    9090          iter != World::getInstance().endAtomSelection();
    9191          ++iter)
    92         UndoInfo[i].push_back(AtomicInfo(*(iter->second), CurrentStep-i));
     92          UndoInfo[i].push_back(AtomicInfo(*(iter->second), CurrentStep-i));
    9393    }
    9494  }
     95  std::vector<int> UndoTrajectorySize;
     96  UndoTrajectorySize.reserve(set.size());
     97  for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection();
     98      iter != World::getInstance().endAtomSelection();
     99      ++iter)
     100    UndoTrajectorySize.push_back(iter->second->getTrajectorySize());
    95101
    96102  // instantiate optimizer
     
    129135
    130136  MoleculeForceAnnealingState *UndoState =
    131     new MoleculeForceAnnealingState(UndoInfo, RedoInfo, params);
     137    new MoleculeForceAnnealingState(UndoInfo, UndoTrajectorySize, RedoInfo, params);
    132138
    133139  return ActionState::ptr(UndoState);
     
    139145  const size_t CurrentStep = WorldTime::getInstance().getTime();
    140146
    141   // set stored old state
    142   for (int i=0;i<2;++i)
    143     SetAtomsFromAtomicInfo(state->UndoInfo[i], CurrentStep-i);
     147  // set stored old state and remove current one from trajectory if we set it
     148  for (int i=0;i<2;++i) {
     149    for(size_t j=0;j<state->UndoInfo[i].size();++j) {
     150      const AtomicInfo &_atominfo = state->UndoInfo[i][j];
     151      const atomId_t id = _atominfo.getId();
     152      atom * const _atom = World::getInstance().getAtom(AtomById(id));
     153      ASSERT( _atom != NULL,
     154          "MoleCuilder::SetAtomsFromAtomicInfo() - cannot find atom with id "
     155          +toString(id)+" in the world.");
     156      if (state->UndoTrajectorySize[j] > CurrentStep-i)
     157        _atominfo.setAtom( *_atom, CurrentStep-i );
     158      else
     159        _atom->removeSteps(state->UndoTrajectorySize[j], CurrentStep-i);
     160    }
     161  }
    144162
    145163  return ActionState::ptr(_state);
  • src/Actions/MoleculeAction/ForceAnnealingAction.def

    r6145577 rc87d6e  
    3232(DummyValidator<bool>())
    3333
    34 #define statetypes (std::vector< std::vector<AtomicInfo> >)(std::vector< std::vector<AtomicInfo> >)
    35 #define statereferences (UndoInfo)(RedoInfo)
     34#define statetypes (std::vector< std::vector<AtomicInfo> >)(std::vector<int>)(std::vector< std::vector<AtomicInfo> >)
     35#define statereferences (UndoInfo)(UndoTrajectorySize)(RedoInfo)
    3636
    3737// some defines for all the names, you may use ACTION, STATE and PARAMS
Note: See TracChangeset for help on using the changeset viewer.