Changeset 87c1cc


Ignore:
Timestamp:
Apr 23, 2021, 9:02:12 PM (5 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
2390e6
Parents:
d54e37
git-author:
Frederik Heber <frederik.heber@…> (04/10/21 19:57:13)
git-committer:
Frederik Heber <frederik.heber@…> (04/23/21 21:02:12)
Message:

FIX: NotAtomByElementAction used atom ptr instead of ids for undo state.

Location:
src/Actions/SelectionAction/Atoms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/SelectionAction/Atoms/NotAtomByElementAction.cpp

    rd54e37 r87c1cc  
    5757ActionState::ptr SelectionNotAtomByElementAction::performCall() {
    5858  LOG(1, "Unselecting atoms of type " << *params.elemental.get());
    59   std::vector<const atom *> unselectedAtoms = const_cast<const World &>(World::getInstance()).
    60       getAllAtoms(!AtomsBySelection());
     59  // build undo state: get all previously unselected atoms of the given type
     60  const World &world = World::getConstInstance();
     61  const std::vector<const atom *> atoms_of_element = world.
     62      getAllAtoms(AtomByType(params.elemental.get()));
     63  std::vector<atomId_t> unselectedAtomIds;
     64  unselectedAtomIds.reserve(atoms_of_element.size());
     65  BOOST_FOREACH(const atom * _atom, atoms_of_element) {
     66    if (!world.isSelected(_atom))
     67      unselectedAtomIds.push_back(_atom->getId());
     68  }
    6169  World::getInstance().unselectAllAtoms(AtomByType(params.elemental.get()));
    62   LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected.");
    63   return ActionState::ptr(new SelectionNotAtomByElementState(unselectedAtoms,params));
     70  LOG(0, world.countSelectedAtoms() << " atoms remain selected.");
     71  return ActionState::ptr(new SelectionNotAtomByElementState(unselectedAtomIds,params));
    6472}
    6573
     
    6876
    6977  World::getInstance().selectAllAtoms(AtomByType(state->params.elemental.get()));
    70   BOOST_FOREACH(const atom *_atom, state->unselectedAtoms)
    71     World::getInstance().unselectAtom(_atom);
     78  BOOST_FOREACH(const atomId_t _atomid, state->unselectedAtomIds)
     79    World::getInstance().unselectAtom(_atomid);
    7280
    7381  return ActionState::ptr(_state);
  • src/Actions/SelectionAction/Atoms/NotAtomByElementAction.def

    rd54e37 r87c1cc  
    2222(ElementValidator())
    2323
    24 #define statetypes (std::vector<const atom*>)
    25 #define statereferences (unselectedAtoms)
     24#define statetypes (std::vector<atomId_t>)
     25#define statereferences (unselectedAtomIds)
    2626
    2727// some defines for all the names, you may use ACTION, STATE and PARAMS
Note: See TracChangeset for help on using the changeset viewer.