Ignore:
Timestamp:
Jan 11, 2015, 4:42:43 PM (10 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:
596cfa
Parents:
b6d92e
git-author:
Frederik Heber <heber@…> (12/12/14 08:28:30)
git-committer:
Frederik Heber <heber@…> (01/11/15 16:42:43)
Message:

Extended selection action for Molecule ids to multiple ids.

Location:
src/Actions/SelectionAction
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/SelectionAction/Atoms/NotAtomByIdAction.def

    rb6d92e rd7cad1  
    2626(STLVectorValidator< std::vector<atomId_t> >(AtomIdValidator()))
    2727
    28 
    2928#define statetypes (atomids_t)
    3029#define statereferences (undoatomids)
  • src/Actions/SelectionAction/Molecules/MoleculeByIdAction.cpp

    rb6d92e rd7cad1  
    5353/** =========== define the function ====================== */
    5454ActionState::ptr SelectionMoleculeByIdAction::performCall() {
    55   const molecule *mol = World::getInstance().getMolecule(MoleculeById(params.molindex.get()));
    56   if (mol != NULL) {
    57     if (!World::getInstance().isSelected(mol)) {
    58       LOG(1, "Selecting molecule " << mol->name);
    59       World::getInstance().selectAllMolecules(MoleculeById(params.molindex.get()));
    60       LOG(0, World::getInstance().countSelectedMolecules() << " molecules selected.");
    61       return ActionState::ptr(new SelectionMoleculeByIdState(params));
     55
     56  enum Sucess {
     57    NoStatus,
     58    AllMoleculesUnselected,
     59    MoleculesSelected,
     60    MoleculeMissing
     61  } status = NoStatus;
     62
     63  const molids_t molids = params.molids.get();
     64  molids_t undomolids;
     65  undomolids.reserve(molids.size());
     66  for (molids_t::const_iterator iter = molids.begin(); iter != molids.end(); ++iter) {
     67    const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter));
     68    if (Walker != NULL) {
     69      if (!World::getInstance().isSelected(Walker)) {
     70        LOG(1, "Selecting mol " << Walker->getName());
     71        World::getInstance().selectMolecule(Walker);
     72        undomolids.push_back(*iter);
     73        if (status < MoleculeMissing)
     74          status = MoleculesSelected;
     75      } else {
     76        if (status == NoStatus)
     77          status = AllMoleculesUnselected;
     78      }
    6279    } else {
    63       return Action::success;
     80      status = MoleculeMissing;
    6481    }
    65   } else {
    66     STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+".");
    67     return Action::failure;
    6882  }
     83  LOG(0, World::getInstance().countSelectedMolecules() << " mols selected.");
     84
     85  switch (status) {
     86    case MoleculeMissing:
     87      STATUS("Cannot find all mols with given ids.");
     88      return Action::failure;
     89      break;
     90    case AllMoleculesUnselected:
     91    case MoleculesSelected:
     92      return ActionState::ptr(new SelectionMoleculeByIdState(undomolids, params));
     93      break;
     94    default:
     95      STATUS("No mols have been selected.");
     96      return Action::failure;
     97      break;
     98  }
     99  return Action::failure;
    69100}
    70101
     
    72103  SelectionMoleculeByIdState *state = assert_cast<SelectionMoleculeByIdState*>(_state.get());
    73104
    74   World::getInstance().unselectAllMolecules(MoleculeById(state->params.molindex.get()));
     105  for (molids_t::const_iterator iter = state->undomolids.begin();
     106      iter != state->undomolids.end(); ++iter) {
     107    const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter));
     108    World::getInstance().unselectMolecule(Walker);
     109  }
    75110
    76111  return ActionState::ptr(_state);
     
    80115  SelectionMoleculeByIdState *state = assert_cast<SelectionMoleculeByIdState*>(_state.get());
    81116
    82   World::getInstance().selectAllMolecules(MoleculeById(state->params.molindex.get()));
     117  for (molids_t::const_iterator iter = state->undomolids.begin();
     118      iter != state->undomolids.end(); ++iter) {
     119    const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter));
     120    World::getInstance().selectMolecule(Walker);
     121  }
    83122
    84123  return ActionState::ptr(_state);
  • src/Actions/SelectionAction/Molecules/MoleculeByIdAction.def

    rb6d92e rd7cad1  
    77
    88// all includes and forward declarations necessary for non-integral types below
     9#include <vector>
    910#include "types.hpp"
    1011
     12typedef std::vector<moleculeId_t> molids_t;
     13
     14#include "Parameters/Validators/STLVectorValidator.hpp"
    1115#include "Parameters/Validators/Specific/MoleculeIdValidator.hpp"
    1216
     
    1418// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1519// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    16 #define paramtypes (moleculeId_t)
     20#define paramtypes (molids_t)
    1721#define paramtokens ("select-molecule-by-id")
    18 #define paramdescriptions ("molecule index")
     22#define paramdescriptions ("molecule indices to select")
    1923#undef paramdefaults
    20 #define paramreferences (molindex)
     24#define paramreferences (molids)
    2125#define paramvalids \
    22 (MoleculeIdValidator())
     26(STLVectorValidator< std::vector<moleculeId_t> >(MoleculeIdValidator()))
    2327
    24 #undef statetypes
    25 #undef statereferences
     28#define statetypes (molids_t)
     29#define statereferences (undomolids)
    2630
    2731// some defines for all the names, you may use ACTION, STATE and PARAMS
  • src/Actions/SelectionAction/Molecules/NotMoleculeByIdAction.cpp

    rb6d92e rd7cad1  
    5353/** =========== define the function ====================== */
    5454ActionState::ptr SelectionNotMoleculeByIdAction::performCall() {
    55   const molecule *mol = World::getInstance().getMolecule(MoleculeById(params.molindex.get()));
    56   if (mol != NULL) {
    57     if (World::getInstance().isSelected(mol)) {
    58       LOG(1, "Unselecting molecule " << mol->name);
    59       World::getInstance().unselectAllMolecules(MoleculeById(params.molindex.get()));
    60       LOG(0, World::getInstance().countSelectedMolecules() << " molecules remain selected.");
    61       return ActionState::ptr(new SelectionNotMoleculeByIdState(params));
     55  enum Sucess {
     56    NoStatus,
     57    AllMoleculesSelected,
     58    MoleculesUnselected,
     59    MoleculeMissing
     60  } status = NoStatus;
     61
     62  const molids_t molids = params.molids.get();
     63  molids_t undomolids;
     64  undomolids.reserve(molids.size());
     65  for (molids_t::const_iterator iter = molids.begin(); iter != molids.end(); ++iter) {
     66    const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter));
     67    if (Walker != NULL) {
     68      if (World::getInstance().isSelected(Walker)) {
     69        LOG(1, "Unselecting mol " << Walker->getName());
     70        World::getInstance().unselectMolecule(Walker);
     71        undomolids.push_back(*iter);
     72        if (status < MoleculeMissing)
     73          status = MoleculesUnselected;
     74      } else {
     75        if (status == NoStatus)
     76          status = AllMoleculesSelected;
     77      }
    6278    } else {
    63       return Action::success;
     79      status = MoleculeMissing;
    6480    }
    65   } else {
    66     STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+".");
    67     return Action::failure;
    6881  }
     82  LOG(0, World::getInstance().countSelectedMolecules() << " mols remain selected.");
     83
     84  switch (status) {
     85    case MoleculeMissing:
     86      STATUS("Cannot find all mols by given ids.");
     87      return Action::failure;
     88      break;
     89    case AllMoleculesSelected:
     90    case MoleculesUnselected:
     91      return ActionState::ptr(new SelectionNotMoleculeByIdState(undomolids, params));
     92      break;
     93    default:
     94      STATUS("No mols have been selected.");
     95      return Action::failure;
     96      break;
     97  }
     98  return Action::failure;
    6999}
    70100
     
    72102  SelectionNotMoleculeByIdState *state = assert_cast<SelectionNotMoleculeByIdState*>(_state.get());
    73103
    74   World::getInstance().selectAllMolecules(MoleculeById(state->params.molindex.get()));
     104  for (molids_t::const_iterator iter = state->undomolids.begin();
     105      iter != state->undomolids.end(); ++iter) {
     106    const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter));
     107    World::getInstance().selectMolecule(Walker);
     108  }
    75109
    76110  return ActionState::ptr(_state);
     
    80114  SelectionNotMoleculeByIdState *state = assert_cast<SelectionNotMoleculeByIdState*>(_state.get());
    81115
    82   World::getInstance().unselectAllMolecules(MoleculeById(state->params.molindex.get()));
     116  for (molids_t::const_iterator iter = state->undomolids.begin();
     117      iter != state->undomolids.end(); ++iter) {
     118    const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter));
     119    World::getInstance().unselectMolecule(Walker);
     120  }
    83121
    84122  return ActionState::ptr(_state);
  • src/Actions/SelectionAction/Molecules/NotMoleculeByIdAction.def

    rb6d92e rd7cad1  
    77
    88// all includes and forward declarations necessary for non-integral types below
     9#include <vector>
    910#include "types.hpp"
    1011
     12typedef std::vector<moleculeId_t> molids_t;
     13
     14#include "Parameters/Validators/STLVectorValidator.hpp"
    1115#include "Parameters/Validators/Specific/MoleculeIdValidator.hpp"
    1216
     
    1418// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1519// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    16 #define paramtypes (moleculeId_t)
     20#define paramtypes (molids_t)
    1721#define paramtokens ("unselect-molecule-by-id")
    18 #define paramdescriptions ("molecule index")
     22#define paramdescriptions ("molecule indices to unselect")
    1923#undef paramdefaults
    20 #define paramreferences (molindex)
     24#define paramreferences (molids)
    2125#define paramvalids \
    22 (MoleculeIdValidator())
     26(STLVectorValidator< std::vector<moleculeId_t> >(MoleculeIdValidator()))
    2327
    24 #undef statetypes
    25 #undef statereferences
     28#define statetypes (molids_t)
     29#define statereferences (undomolids)
    2630
    2731// some defines for all the names, you may use ACTION, STATE and PARAMS
Note: See TracChangeset for help on using the changeset viewer.