Ignore:
Timestamp:
Oct 26, 2012, 1:11:18 PM (13 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
be6b3a
Parents:
3a51bd
git-author:
Frederik Heber <heber@…> (09/21/12 13:07:26)
git-committer:
Frederik Heber <heber@…> (10/26/12 13:11:18)
Message:

Selection(Not)AtomById now works on multiple ids.

  • this closed ticket #189.
File:
1 edited

Legend:

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

    r3a51bd rf7c7cf  
    5252#include "Action_impl_pre.hpp"
    5353/** =========== define the function ====================== */
    54 Action::state_ptr SelectionAtomByIdAction::performCall() {
    55   const atom *Walker = World::getInstance().getAtom(AtomById(params.WalkerId.get()));
    56   if (Walker != NULL) {
    57     if (!World::getInstance().isSelected(Walker)) {
    58       LOG(1, "Selecting atom " << *Walker);
    59       World::getInstance().selectAtom(Walker);
    60       LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected.");
    61       return Action::state_ptr(new SelectionAtomByIdState(params));
     54Action::state_ptr SelectionAtomByIdAction::performCall()
     55{
     56  enum Sucess {
     57    NoStatus,
     58    AllAtomsUnselected,
     59    AtomsSelected,
     60    AtomMissing
     61  } status = NoStatus;
     62  const atomids_t atomids = params.atomids.get();
     63  atomids_t undoatomids;
     64  undoatomids.reserve(atomids.size());
     65  for (atomids_t::const_iterator iter = atomids.begin(); iter != atomids.end(); ++iter) {
     66    const atom *Walker = World::getInstance().getAtom(AtomById(*iter));
     67    if (Walker != NULL) {
     68      if (!World::getInstance().isSelected(Walker)) {
     69        LOG(1, "Selecting atom " << *Walker);
     70        World::getInstance().selectAtom(Walker);
     71        undoatomids.push_back(*iter);
     72        if (status < AtomMissing)
     73          status = AtomsSelected;
     74      } else {
     75        if (status == NoStatus)
     76          status = AllAtomsUnselected;
     77      }
    6278    } else {
     79      status = AtomMissing;
     80    }
     81  }
     82  LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected.");
     83
     84  switch (status) {
     85    case AtomMissing:
     86      return Action::failure;
     87      break;
     88    case AllAtomsUnselected:
    6389      return Action::success;
    64     }
    65   } else {
    66     return Action::failure;
     90      break;
     91    case AtomsSelected:
     92      return Action::state_ptr(new SelectionAtomByIdState(undoatomids, params));
     93      break;
     94    default:
     95      ASSERT(0, "SelectionAtomByIdAction::performCall() - this must not happen.");
     96      return Action::failure;
     97      break;
    6798  }
    6899}
     
    71102  SelectionAtomByIdState *state = assert_cast<SelectionAtomByIdState*>(_state.get());
    72103
    73   const atom *Walker = World::getInstance().getAtom(AtomById(state->params.WalkerId.get()));
    74   World::getInstance().unselectAtom(Walker);
     104  for (atomids_t::const_iterator iter = state->undoatomids.begin();
     105      iter != state->undoatomids.end(); ++iter) {
     106    const atom *Walker = World::getInstance().getAtom(AtomById(*iter));
     107    World::getInstance().unselectAtom(Walker);
     108  }
    75109
    76110  return Action::state_ptr(_state);
     
    80114  SelectionAtomByIdState *state = assert_cast<SelectionAtomByIdState*>(_state.get());
    81115
    82   const atom *Walker = World::getInstance().getAtom(AtomById(state->params.WalkerId.get()));
    83   World::getInstance().selectAtom(Walker);
     116  for (atomids_t::const_iterator iter = state->undoatomids.begin();
     117      iter != state->undoatomids.end(); ++iter) {
     118    const atom *Walker = World::getInstance().getAtom(AtomById(*iter));
     119    World::getInstance().selectAtom(Walker);
     120  }
    84121
    85122  return Action::state_ptr(_state);
Note: See TracChangeset for help on using the changeset viewer.