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/MoleculeByOrderAction.cpp

    rd21668 r9a3882  
    5454
    5555ActionState::ptr SelectionMoleculeByOrderAction::performCall() {
    56   const molecule *mol = const_cast<const World &>(World::getInstance()).
    57       getMolecule(MoleculeByOrder(params.molindex.get()));
     56  size_t no_selected = 0;
     57  const std::vector<int> &indices = params.molindices.get();
     58  std::vector<const molecule *> mols;
     59  const World &const_world = World::getConstInstance();
     60  World &world = World::getInstance();
     61  for( std::vector<int>::const_iterator iter = indices.begin();
     62      iter != indices.end(); ++iter) {
     63    const molecule *mol = const_world.getMolecule(MoleculeByOrder(*iter));
    5864
    59   if (mol != NULL) {
    60     if (!World::getInstance().isSelected(mol)) {
    61       LOG(1, "Selecting molecule " << mol->name);
    62       World::getInstance().selectMolecule(mol);
    63       LOG(0, World::getInstance().countSelectedMolecules() << " molecules selected.");
    64       return ActionState::ptr(new SelectionMoleculeByOrderState(mol, params));
     65    if (mol != NULL) {
     66      if (!const_world.isSelected(mol)) {
     67        //LOG(1, "Selecting molecule " << mol->name);
     68        world.selectMolecule(mol);
     69        mols.push_back(mol);
     70        ++no_selected;
     71      }
    6572    } else {
    66       return Action::success;
     73      STATUS("Cannot find molecule by given index "+toString(*iter)+".");
     74      return Action::failure;
    6775    }
     76  }
     77
     78  LOG(0, no_selected << " molecules additionally selected.");
     79  if (no_selected != 0) {
     80    return ActionState::ptr(new SelectionMoleculeByOrderState(mols, params));
    6881  } else {
    69     STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+".");
    70     return Action::failure;
     82    return Action::success;
    7183  }
    7284}
     
    7587  SelectionMoleculeByOrderState *state = assert_cast<SelectionMoleculeByOrderState*>(_state.get());
    7688
    77   World::getInstance().unselectMolecule(state->mol);
     89  World &world = World::getInstance();
     90  for (std::vector<const molecule *>::const_iterator iter = state->mols.begin();
     91      iter != state->mols.end(); ++iter)
     92    world.unselectMolecule(*iter);
     93
    7894  return ActionState::ptr(_state);
    7995}
     
    8298  SelectionMoleculeByOrderState *state = assert_cast<SelectionMoleculeByOrderState*>(_state.get());
    8399
    84   World::getInstance().selectMolecule(state->mol);
     100  World &world = World::getInstance();
     101  for (std::vector<const molecule *>::const_iterator iter = state->mols.begin();
     102      iter != state->mols.end(); ++iter)
     103    world.selectMolecule(*iter);
    85104  return ActionState::ptr(_state);
    86105}
Note: See TracChangeset for help on using the changeset viewer.