Ignore:
Timestamp:
Jul 12, 2017, 7:10:22 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Action_Thermostats, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
3b74fa
Parents:
f56e14
git-author:
Frederik Heber <frederik.heber@…> (05/09/17 11:07:11)
git-committer:
Frederik Heber <frederik.heber@…> (07/12/17 19:10:22)
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/Atoms/NotAtomByOrderAction.cpp

    rf56e14 r0716eac  
    5454/** =========== define the function ====================== */
    5555ActionState::ptr SelectionNotAtomByOrderAction::performCall() {
    56   const atom * Walker = const_cast<const World &>(World::getInstance()).
    57       getAtom(AtomByOrder(params.order.get()));
    58   if (Walker != NULL) {
    59     if (World::getInstance().isSelected(Walker)) {
    60       LOG(1, "Unselecting atom " << *Walker);
    61       World::getInstance().unselectAtom(Walker);
    62       LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected.");
    63       return ActionState::ptr(new SelectionNotAtomByOrderState(Walker->getId(), params));
     56  size_t no_unselected = 0;
     57  const std::vector<int> &indices = params.orders.get();
     58  std::vector<atomId_t> atomids;
     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 atom * const walker = const_world.getAtom(AtomByOrder(*iter));
     64
     65    if (walker != NULL) {
     66      if (const_world.isSelected(walker)) {
     67        //LOG(1, "Unselecting atom " << *walker);
     68        world.unselectAtom(walker);
     69        atomids.push_back(walker->getId());
     70        ++no_unselected;
     71      }
    6472    } else {
    65       return Action::success;
     73      STATUS("Cannot find atom by given index "+toString(*iter)+".");
     74      return Action::failure;
    6675    }
     76  }
     77
     78  LOG(0, no_unselected << " atoms additionally unselected.");
     79  if (no_unselected != 0) {
     80    return ActionState::ptr(new SelectionNotAtomByOrderState(atomids, params));
    6781  } else {
    68     STATUS("Cannot find atom by given order of "+toString(params.order.get())+".");
    69     return Action::failure;
     82    return Action::success;
    7083  }
    7184}
     
    7487  SelectionNotAtomByOrderState *state = assert_cast<SelectionNotAtomByOrderState*>(_state.get());
    7588
    76   World::getInstance().selectAllAtoms(AtomById(state->WalkerId));
     89  World &world = World::getInstance();
     90  for (std::vector<atomId_t>::const_iterator iter = state->WalkerIds.begin();
     91      iter != state->WalkerIds.end(); ++iter)
     92    world.selectAllAtoms(AtomById(*iter));
    7793
    7894  return ActionState::ptr(_state);
     
    8298  SelectionNotAtomByOrderState *state = assert_cast<SelectionNotAtomByOrderState*>(_state.get());
    8399
    84   World::getInstance().unselectAllAtoms(AtomById(state->WalkerId));
     100  World &world = World::getInstance();
     101  for (std::vector<atomId_t>::const_iterator iter = state->WalkerIds.begin();
     102      iter != state->WalkerIds.end(); ++iter)
     103    world.unselectAllAtoms(AtomById(*iter));
    85104
    86105  return ActionState::ptr(_state);
Note: See TracChangeset for help on using the changeset viewer.