Ignore:
Timestamp:
Jul 5, 2017, 7:40:05 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_oldresults, IndependentFragmentGrids_IntegrationTest
Children:
3a0371
Parents:
d21668
git-author:
Frederik Heber <frederik.heber@…> (05/09/17 11:07:11)
git-committer:
Frederik Heber <frederik.heber@…> (07/05/17 19:40:05)
Message:

SelectMoleculeByOrder and SelectionAtomByOrder now allows multiple indices.

  • of course, this is also true for unselection.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/SelectionAction/Molecules/NotMoleculeByOrderAction.cpp

    rd21668 r9a3882  
    5454
    5555ActionState::ptr SelectionNotMoleculeByOrderAction::performCall() {
    56   const molecule *mol = const_cast<const World &>(World::getInstance()).
    57       getMolecule(MoleculeByOrder(params.molindex.get()));
     56  size_t no_unselected = 0;
     57  const std::vector<int> &indices = params.molindices.get();
     58  std::vector<const molecule *> mols;
     59  for( std::vector<int>::const_iterator iter = indices.begin();
     60      iter != indices.end(); ++iter) {
     61    const molecule *mol = const_cast<const World &>(World::getInstance()).
     62        getMolecule(MoleculeByOrder(*iter));
    5863
    59   if (mol != NULL) {
    60     if (World::getInstance().isSelected(mol)) {
    61       LOG(1, "Unselecting molecule " << mol->name);
    62       World::getInstance().unselectMolecule(mol);
    63       LOG(0, World::getInstance().countSelectedMolecules() << " molecules remain selected.");
    64       return ActionState::ptr(new SelectionNotMoleculeByOrderState(mol, params));
     64    if (mol != NULL) {
     65      if (World::getInstance().isSelected(mol)) {
     66        //LOG(1, "Unselecting molecule " << mol->name);
     67        World::getInstance().unselectMolecule(mol);
     68        mols.push_back(mol);
     69        ++no_unselected;
     70      }
    6571    } else {
    66       return Action::success;
     72      STATUS("Cannot find molecule by given index "+toString(*iter)+".");
     73      return Action::failure;
    6774    }
     75  }
     76
     77  LOG(0, no_unselected << " molecules additionally unselected.");
     78  if (no_unselected != 0) {
     79    return ActionState::ptr(new SelectionNotMoleculeByOrderState(mols, params));
    6880  } else {
    69     STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+".");
    70     return Action::failure;
     81    return Action::success;
    7182  }
    7283}
     
    7586  SelectionNotMoleculeByOrderState *state = assert_cast<SelectionNotMoleculeByOrderState*>(_state.get());
    7687
    77   World::getInstance().selectMolecule(state->mol);
     88  World &world = World::getInstance();
     89  for (std::vector<const molecule *>::const_iterator iter = state->mols.begin();
     90      iter != state->mols.end(); ++iter)
     91    world.selectMolecule(*iter);
     92
    7893  return ActionState::ptr(_state);
    7994}
     
    8297  SelectionNotMoleculeByOrderState *state = assert_cast<SelectionNotMoleculeByOrderState*>(_state.get());
    8398
    84   World::getInstance().unselectMolecule(state->mol);
     99  World &world = World::getInstance();
     100  for (std::vector<const molecule *>::const_iterator iter = state->mols.begin();
     101      iter != state->mols.end(); ++iter)
     102    world.unselectMolecule(*iter);
     103
    85104  return ActionState::ptr(_state);
    86105}
Note: See TracChangeset for help on using the changeset viewer.